A very important optimisation; if we know that our mesh/shell is
identical to the previous group's (because our thisShell and thisMesh are empty), then display the previous group's instead. This saves us re-triangulating the shell (or recalculating the edges of a triangle mesh) every time our group gets regenerated, which was horribly slow. [git-p4: depot-paths = "//depot/solvespace/": change = 2004]
This commit is contained in:
parent
4ca7548ffe
commit
3f5c439873
|
@ -376,20 +376,13 @@ Group *Group::PreviousGroup(void) {
|
||||||
Group *g = &(SK.group.elem[i]);
|
Group *g = &(SK.group.elem[i]);
|
||||||
if(g->h.v == h.v) break;
|
if(g->h.v == h.v) break;
|
||||||
}
|
}
|
||||||
if(i == 0 || i >= SK.group.n) oops();
|
if(i == 0 || i >= SK.group.n) return NULL;
|
||||||
return &(SK.group.elem[i-1]);
|
return &(SK.group.elem[i-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::Draw(void) {
|
void Group::DrawDisplayItems(int t) {
|
||||||
// Everything here gets drawn whether or not the group is hidden; we
|
|
||||||
// can control this stuff independently, with show/hide solids, edges,
|
|
||||||
// mesh, etc.
|
|
||||||
|
|
||||||
// Triangulate the shells if necessary.
|
|
||||||
GenerateDisplayItems();
|
|
||||||
|
|
||||||
int specColor;
|
int specColor;
|
||||||
if(type == DRAWING_3D || type == DRAWING_WORKPLANE) {
|
if(t == DRAWING_3D || t == DRAWING_WORKPLANE) {
|
||||||
specColor = RGB(25, 25, 25); // force the color to something dim
|
specColor = RGB(25, 25, 25); // force the color to something dim
|
||||||
} else {
|
} else {
|
||||||
specColor = -1; // use the model color
|
specColor = -1; // use the model color
|
||||||
|
@ -425,6 +418,25 @@ void Group::Draw(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SS.GW.showMesh) glxDebugMesh(&displayMesh);
|
if(SS.GW.showMesh) glxDebugMesh(&displayMesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Group::Draw(void) {
|
||||||
|
// Everything here gets drawn whether or not the group is hidden; we
|
||||||
|
// can control this stuff independently, with show/hide solids, edges,
|
||||||
|
// mesh, etc.
|
||||||
|
|
||||||
|
Group *pg = PreviousGroup();
|
||||||
|
if(pg && thisMesh.IsEmpty() && thisShell.IsEmpty()) {
|
||||||
|
// We don't contribute any new solid model in this group, so our
|
||||||
|
// display items are identical to the previous group's; which means
|
||||||
|
// that we can just display those, and stop ourselves from
|
||||||
|
// recalculating for those every time we get a change in this group.
|
||||||
|
pg->GenerateDisplayItems();
|
||||||
|
pg->DrawDisplayItems(type);
|
||||||
|
} else {
|
||||||
|
GenerateDisplayItems();
|
||||||
|
DrawDisplayItems(type);
|
||||||
|
}
|
||||||
|
|
||||||
// And finally show the polygons too
|
// And finally show the polygons too
|
||||||
if(!SS.GW.showShaded) return;
|
if(!SS.GW.showShaded) return;
|
||||||
|
|
3
sketch.h
3
sketch.h
|
@ -210,10 +210,11 @@ public:
|
||||||
void GenerateLoops(void);
|
void GenerateLoops(void);
|
||||||
// And the mesh stuff
|
// And the mesh stuff
|
||||||
Group *PreviousGroup(void);
|
Group *PreviousGroup(void);
|
||||||
void GenerateDisplayItems(void);
|
|
||||||
void GenerateShellAndMesh(void);
|
void GenerateShellAndMesh(void);
|
||||||
template<class T> void GenerateForStepAndRepeat(T *a, T *b, T *o, int how);
|
template<class T> void GenerateForStepAndRepeat(T *a, T *b, T *o, int how);
|
||||||
template<class T> void GenerateForBoolean(T *a, T *b, T *o);
|
template<class T> void GenerateForBoolean(T *a, T *b, T *o);
|
||||||
|
void GenerateDisplayItems(void);
|
||||||
|
void DrawDisplayItems(int t);
|
||||||
void Draw(void);
|
void Draw(void);
|
||||||
|
|
||||||
SPolygon GetPolygon(void);
|
SPolygon GetPolygon(void);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user