Faster loading of 3D preview and much less memory used

This commit is contained in:
Alessandro Ranellucci 2015-01-24 23:35:29 +01:00
parent 8cfd2e33d8
commit a5c0ffe963
8 changed files with 202 additions and 163 deletions

View file

@ -3,47 +3,26 @@
#include <myinit.h>
#include "libslic3r/GUI/3DScene.hpp"
%name{Slic3r::GUI::_3DScene::GLVertexArray} class GLVertexArray {
GLVertexArray();
~GLVertexArray();
void load_mesh(TriangleMesh* mesh) const
%code%{ THIS->load_mesh(*mesh); %};
size_t size() const
%code%{ RETVAL = THIS->verts.size(); %};
void* verts_ptr() const
%code%{ RETVAL = THIS->verts.empty() ? 0 : &THIS->verts.front(); %};
void* norms_ptr() const
%code%{ RETVAL = THIS->verts.empty() ? 0 : &THIS->norms.front(); %};
};
%package{Slic3r::GUI::_3DScene};
%{
void
_extrusionentity_to_verts_do(Lines lines, std::vector<double> widths, std::vector<double> heights, bool closed, double top_z, Point* copy, SV* qverts, SV* qnorms, SV* tverts, SV* tnorms)
_extrusionentity_to_verts_do(Lines lines, std::vector<double> widths, std::vector<double> heights, bool closed, double top_z, Point* copy, GLVertexArray* qverts, GLVertexArray* tverts)
CODE:
Pointf3s _qverts, _qnorms, _tverts, _tnorms;
_3DScene::_extrusionentity_to_verts_do(lines, widths, heights, closed,
top_z, *copy, &_qverts, &_qnorms, &_tverts, &_tnorms);
{
AV* av = (AV*)SvRV(qverts);
for (Pointf3s::const_iterator it = _qverts.begin(); it != _qverts.end(); ++it) {
av_push(av, newSVnv(it->x));
av_push(av, newSVnv(it->y));
av_push(av, newSVnv(it->z));
}
}
{
AV* av = (AV*)SvRV(qnorms);
for (Pointf3s::const_iterator it = _qnorms.begin(); it != _qnorms.end(); ++it) {
av_push(av, newSVnv(it->x));
av_push(av, newSVnv(it->y));
av_push(av, newSVnv(it->z));
}
}
{
AV* av = (AV*)SvRV(tverts);
for (Pointf3s::const_iterator it = _tverts.begin(); it != _tverts.end(); ++it) {
av_push(av, newSVnv(it->x));
av_push(av, newSVnv(it->y));
av_push(av, newSVnv(it->z));
}
}
{
AV* av = (AV*)SvRV(tnorms);
for (Pointf3s::const_iterator it = _tnorms.begin(); it != _tnorms.end(); ++it) {
av_push(av, newSVnv(it->x));
av_push(av, newSVnv(it->y));
av_push(av, newSVnv(it->z));
}
}
top_z, *copy, qverts, tverts);
%}