Eliminate some entity copies in lathe groups. Eliminates a crash due to copy numbers going over 1000. May break some older files with constaints on lathed entities. (#582)

pull/583/head
phkahler 2020-04-21 00:44:27 -04:00 committed by GitHub
parent b55dac7620
commit 45eb246865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 19 deletions

View File

@ -516,9 +516,6 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
Vector axis_pos = SK.GetEntity(predef.origin)->PointGetNum();
Vector axis_dir = SK.GetEntity(predef.entityB)->VectorGetNum();
// Remapped entity index.
int ai = 1;
// Not using range-for here because we're changing the size of entity in the loop.
for(i = 0; i < entity->n; i++) {
Entity *e = &(entity->Get(i));
@ -529,24 +526,22 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
// As soon as I call CopyEntity, e may become invalid! That
// adds entities, which may cause a realloc.
CopyEntity(entity, SK.GetEntity(predef.origin), 0, ai,
NO_PARAM, NO_PARAM, NO_PARAM,
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
CopyAs::NUMERIC);
// this is the regular copy of all entities
CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_START,
NO_PARAM, NO_PARAM, NO_PARAM,
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
CopyAs::NUMERIC);
CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_END,
NO_PARAM, NO_PARAM, NO_PARAM,
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
CopyAs::NUMERIC);
MakeLatheCircles(entity, param, he, axis_pos, axis_dir, ai);
if (e->IsPoint()) {
// for points this copy is used for the circle centers
CopyEntity(entity, SK.GetEntity(he), 0, REMAP_LATHE_ARC_CENTER,
NO_PARAM, NO_PARAM, NO_PARAM,
NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM,
CopyAs::NUMERIC);
MakeLatheCircles(entity, param, he, axis_pos, axis_dir);
};
MakeLatheSurfacesSelectable(entity, he, axis_dir);
ai++;
}
return;
}
@ -589,7 +584,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity,
}
// Arcs are not generated for revolve groups, for now, because our current arc
// entity is not chiral, and dragging a revolve may break the arc by inverting it.
// MakeLatheCircles(entity, param, he, axis_pos, axis_dir, ai);
// MakeLatheCircles(entity, param, he, axis_pos, axis_dir);
MakeLatheSurfacesSelectable(entity, he, axis_dir);
}
@ -853,15 +848,15 @@ void Group::MakeExtrusionLines(IdList<Entity,hEntity> *el, hEntity in) {
}
}
void Group::MakeLatheCircles(IdList<Entity,hEntity> *el, IdList<Param,hParam> *param, hEntity in, Vector pt, Vector axis, int ai) {
void Group::MakeLatheCircles(IdList<Entity,hEntity> *el, IdList<Param,hParam> *param, hEntity in, Vector pt, Vector axis) {
Entity *ep = SK.GetEntity(in);
Entity en = {};
if(ep->IsPoint()) {
// A point gets revolved to form an arc.
en.point[0] = Remap(predef.origin, ai);
en.point[0] = Remap(ep->h, REMAP_LATHE_ARC_CENTER);
en.point[1] = Remap(ep->h, REMAP_LATHE_START);
en.point[2] = Remap(ep->h, REMAP_LATHE_END);
en.point[2] = en.point[1]; //Remap(ep->h, REMAP_LATHE_END);
// Get arc center and point on arc.
Entity *pc = SK.GetEntity(en.point[0]);

View File

@ -279,10 +279,11 @@ public:
REMAP_LATHE_END = 1007,
REMAP_PT_TO_ARC = 1008,
REMAP_PT_TO_NORMAL = 1009,
REMAP_LATHE_ARC_CENTER = 1010,
};
hEntity Remap(hEntity in, int copyNumber);
void MakeExtrusionLines(EntityList *el, hEntity in);
void MakeLatheCircles(IdList<Entity,hEntity> *el, IdList<Param,hParam> *param, hEntity in, Vector pt, Vector axis, int ai);
void MakeLatheCircles(IdList<Entity,hEntity> *el, IdList<Param,hParam> *param, hEntity in, Vector pt, Vector axis);
void MakeLatheSurfacesSelectable(IdList<Entity, hEntity> *el, hEntity in, Vector axis);
void MakeExtrusionTopBottomFaces(EntityList *el, hEntity pt);
void CopyEntity(EntityList *el,