Skip to content

Commit

Permalink
Get rid of the MAX_SELECTED restriction in GroupSelection().
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Aug 13, 2016
1 parent 0bf6167 commit e2e9167
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -33,6 +33,7 @@ Bug fixes:
* Fix TTF font metrics (restore the behavior from version 2.0).
* Forcibly show the current group once we start a drawing operation.
* DXF export: always declare layers before using them.
* Do not truncate operations on selections to first 32 selected entities.

2.1
---
Expand Down
23 changes: 15 additions & 8 deletions src/draw.cpp
Expand Up @@ -230,7 +230,7 @@ void GraphicsWindow::SelectByMarquee() {
void GraphicsWindow::GroupSelection() {
gs = {};
int i;
for(i = 0; i < selection.n && i < MAX_SELECTED; i++) {
for(i = 0; i < selection.n; i++) {
Selection *s = &(selection.elem[i]);
if(s->entity.v) {
(gs.n)++;
Expand All @@ -241,27 +241,33 @@ void GraphicsWindow::GroupSelection() {

// A list of points, and a list of all entities that aren't points.
if(e->IsPoint()) {
gs.point[(gs.points)++] = s->entity;
gs.points++;
gs.point.push_back(s->entity);
} else {
gs.entity[(gs.entities)++] = s->entity;
gs.entities++;
gs.entity.push_back(s->entity);
}

// And an auxiliary list of normals, including normals from
// workplanes.
if(e->IsNormal()) {
gs.anyNormal[(gs.anyNormals)++] = s->entity;
gs.anyNormals++;
gs.anyNormal.push_back(s->entity);
} else if(e->IsWorkplane()) {
gs.anyNormal[(gs.anyNormals)++] = e->Normal()->h;
gs.anyNormals++;
gs.anyNormal.push_back(e->Normal()->h);
}

// And of vectors (i.e., stuff with a direction to constrain)
if(e->HasVector()) {
gs.vector[(gs.vectors)++] = s->entity;
gs.vectors++;
gs.vector.push_back(s->entity);
}

// Faces (which are special, associated/drawn with triangles)
if(e->IsFace()) {
gs.face[(gs.faces)++] = s->entity;
gs.faces++;
gs.face.push_back(s->entity);
}

if(e->HasEndpoints()) {
Expand All @@ -286,7 +292,8 @@ void GraphicsWindow::GroupSelection() {
}
}
if(s->constraint.v) {
gs.constraint[(gs.constraints)++] = s->constraint;
gs.constraints++;
gs.constraint.push_back(s->constraint);
Constraint *c = SK.GetConstraint(s->constraint);
if(c->IsStylable()) gs.stylables++;
if(c->HasLabel()) gs.constraintLabels++;
Expand Down
13 changes: 6 additions & 7 deletions src/ui.h
Expand Up @@ -667,14 +667,13 @@ class GraphicsWindow {
void HitTestMakeSelection(Point2d mp);
void ClearSelection();
void ClearNonexistentSelectionItems();
enum { MAX_SELECTED = 32 };
struct {
hEntity point[MAX_SELECTED];
hEntity entity[MAX_SELECTED];
hEntity anyNormal[MAX_SELECTED];
hEntity vector[MAX_SELECTED];
hEntity face[MAX_SELECTED];
hConstraint constraint[MAX_SELECTED];
std::vector<hEntity> point;
std::vector<hEntity> entity;
std::vector<hEntity> anyNormal;
std::vector<hEntity> vector;
std::vector<hEntity> face;
std::vector<hConstraint> constraint;
int points;
int entities;
int workplanes;
Expand Down

0 comments on commit e2e9167

Please sign in to comment.