GeezerVison is showing github.com — Use C++ std::{min,max,swap} instead of custom ones. · realthunder/solvespace@28166e6
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/bsp.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -25,7 +25,7 @@ SBsp3 *SBsp3::FromMesh(SMesh *m) { | 25 | 25 | while(n > 1) { | 26 | 26 | int k = rand() % n; | 27 | 27 | n--; | 28 | | - SWAP(STriangle, mc.l.elem[k], mc.l.elem[n]); | | 28 | + swap(mc.l.elem[k], mc.l.elem[n]); | 29 | 29 | } | 30 | 30 |
| 31 | 31 | for(i = 0; i < mc.l.n; i++) { | |
Collapse file Copy file name to clipboardExpand all lines: src/confscreen.cpp +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -316,7 +316,7 @@ void TextWindow::ShowConfiguration(void) { | 316 | 316 | bool TextWindow::EditControlDoneForConfiguration(const char *s) { | 317 | 317 | switch(edit.meaning) { | 318 | 318 | case EDIT_LIGHT_INTENSITY: | 319 | | - SS.lightIntensity[edit.i] = min(1, max(0, atof(s))); | | 319 | + SS.lightIntensity[edit.i] = min(1.0, max(0.0, atof(s))); | 320 | 320 | InvalidateGraphics(); | 321 | 321 | break; | 322 | 322 |
| @@ -341,7 +341,7 @@ bool TextWindow::EditControlDoneForConfiguration(const char *s) { | 341 | 341 | break; | 342 | 342 | } | 343 | 343 | case EDIT_CHORD_TOLERANCE: { | 344 | | - SS.chordTol = min(10, max(0.1, atof(s))); | | 344 | + SS.chordTol = min(10.0, max(0.1, atof(s))); | 345 | 345 | SS.GenerateAll(0, INT_MAX); | 346 | 346 | break; | 347 | 347 | } | @@ -351,7 +351,7 @@ bool TextWindow::EditControlDoneForConfiguration(const char *s) { | 351 | 351 | break; | 352 | 352 | } | 353 | 353 | case EDIT_CAMERA_TANGENT: { | 354 | | - SS.cameraTangent = (min(2, max(0, atof(s))))/1000.0; | | 354 | + SS.cameraTangent = (min(2.0, max(0.0, atof(s))))/1000.0; | 355 | 355 | if(!SS.usePerspectiveProj) { | 356 | 356 | Message("The perspective factor will have no effect until you " | 357 | 357 | "enable View -> Use Perspective Projection."); | |
Collapse file Copy file name to clipboardExpand all lines: src/constraint.cpp +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -369,7 +369,7 @@ void Constraint::MenuConstrain(int id) { | 369 | 369 | if((l1->group.v != SS.GW.activeGroup.v) || | 370 | 370 | (l1->construction && !(l0->construction))) | 371 | 371 | { | 372 | | - SWAP(Entity *, l0, l1); | | 372 | + swap(l0, l1); | 373 | 373 | } | 374 | 374 | c.ptA = l1->point[0]; | 375 | 375 | c.ptB = l1->point[1]; | @@ -476,7 +476,7 @@ void Constraint::MenuConstrain(int id) { | 476 | 476 | Entity *nfree = SK.GetEntity(c.entityA); | 477 | 477 | Entity *nref = SK.GetEntity(c.entityB); | 478 | 478 | if(nref->group.v == SS.GW.activeGroup.v) { | 479 | | - SWAP(Entity *, nref, nfree); | | 479 | + swap(nref, nfree); | 480 | 480 | } | 481 | 481 | if(nfree->group.v == SS.GW.activeGroup.v && | 482 | 482 | nref ->group.v != SS.GW.activeGroup.v) | @@ -491,7 +491,7 @@ void Constraint::MenuConstrain(int id) { | 491 | 491 | // There might be an odd*90 degree rotation about the | 492 | 492 | // normal vector; allow that, since the numerical | 493 | 493 | // constraint does | 494 | | - SWAP(Vector, ru, rv); | | 494 | + swap(ru, rv); | 495 | 495 | } | 496 | 496 | fu = fu.Dot(ru) > 0 ? ru : ru.ScaledBy(-1); | 497 | 497 | fv = fv.Dot(rv) > 0 ? rv : rv.ScaledBy(-1); | @@ -582,7 +582,7 @@ void Constraint::MenuConstrain(int id) { | 582 | 582 | Entity *line = SK.GetEntity(gs.entity[0]); | 583 | 583 | Entity *arc = SK.GetEntity(gs.entity[1]); | 584 | 584 | if(line->type == Entity::ARC_OF_CIRCLE) { | 585 | | - SWAP(Entity *, line, arc); | | 585 | + swap(line, arc); | 586 | 586 | } | 587 | 587 | Vector l0 = SK.GetEntity(line->point[0])->PointGetNum(), | 588 | 588 | l1 = SK.GetEntity(line->point[1])->PointGetNum(); | @@ -606,7 +606,7 @@ void Constraint::MenuConstrain(int id) { | 606 | 606 | Entity *line = SK.GetEntity(gs.entity[0]); | 607 | 607 | Entity *cubic = SK.GetEntity(gs.entity[1]); | 608 | 608 | if(line->type == Entity::CUBIC) { | 609 | | - SWAP(Entity *, line, cubic); | | 609 | + swap(line, cubic); | 610 | 610 | } | 611 | 611 | Vector l0 = SK.GetEntity(line->point[0])->PointGetNum(), | 612 | 612 | l1 = SK.GetEntity(line->point[1])->PointGetNum(); | |
Collapse file Copy file name to clipboardExpand all lines: src/constrainteq.cpp +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -592,7 +592,7 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) { | 592 | 592 | EntityBase *a = SK.GetEntity(entityA); | 593 | 593 | EntityBase *b = SK.GetEntity(entityB); | 594 | 594 | if(b->group.v != group.v) { | 595 | | - SWAP(EntityBase *, a, b); | | 595 | + swap(a, b); | 596 | 596 | } | 597 | 597 |
| 598 | 598 | ExprVector au = a->NormalExprsU(), | @@ -744,7 +744,7 @@ void ConstraintBase::GenerateReal(IdList<Equation,hEquation> *l) { | 744 | 744 | case PARALLEL: { | 745 | 745 | EntityBase *ea = SK.GetEntity(entityA), *eb = SK.GetEntity(entityB); | 746 | 746 | if(eb->group.v != group.v) { | 747 | | - SWAP(EntityBase *, ea, eb); | | 747 | + swap(ea, eb); | 748 | 748 | } | 749 | 749 | ExprVector a = ea->VectorGetExprs(); | 750 | 750 | ExprVector b = eb->VectorGetExprs(); | |
Collapse file Copy file name to clipboardExpand all lines: src/drawconstraint.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -727,7 +727,7 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) { | 727 | 727 | // a bit of bias to stop it from flickering between the | 728 | 728 | // two possibilities | 729 | 729 | if(fabs(u.Dot(ru)) < fabs(v.Dot(ru)) + LENGTH_EPS) { | 730 | | - SWAP(Vector, u, v); | | 730 | + swap(u, v); | 731 | 731 | } | 732 | 732 | if(u.Dot(ru) < 0) u = u.ScaledBy(-1); | 733 | 733 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/dsc.h +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -216,7 +216,7 @@ class List { | 216 | 216 | void Reverse(void) { | 217 | 217 | int i; | 218 | 218 | for(i = 0; i < (n/2); i++) { | 219 | | - SWAP(T, elem[i], elem[(n-1)-i]); | | 219 | + swap(elem[i], elem[(n-1)-i]); | 220 | 220 | } | 221 | 221 | } | 222 | 222 | }; | |
Collapse file Copy file name to clipboardExpand all lines: src/export.cpp +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,7 +48,7 @@ void SolveSpaceUI::ExportSectionTo(const char *filename) { | 48 | 48 | vt = vt.WithMagnitude(1); | 49 | 49 |
| 50 | 50 | if(fabs(SS.GW.projUp.Dot(vt)) < fabs(SS.GW.projUp.Dot(ut))) { | 51 | | - SWAP(Vector, ut, vt); | | 51 | + swap(ut, vt); | 52 | 52 | } | 53 | 53 | if(SS.GW.projRight.Dot(ut) < 0) ut = ut.ScaledBy(-1); | 54 | 54 | if(SS.GW.projUp. Dot(vt) < 0) vt = vt.ScaledBy(-1); | @@ -280,11 +280,11 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s | 280 | 280 | // And calculate lighting for the triangle | 281 | 281 | Vector n = tt.Normal().WithMagnitude(1); | 282 | 282 | double lighting = SS.ambientIntensity + | 283 | | - max(0, (SS.lightIntensity[0])*(n.Dot(l0))) + | 284 | | - max(0, (SS.lightIntensity[1])*(n.Dot(l1))); | 285 | | - double r = min(1, tt.meta.color.redF() *lighting), | 286 | | - g = min(1, tt.meta.color.greenF()*lighting), | 287 | | - b = min(1, tt.meta.color.blueF() *lighting); | | 283 | + max(0.0, (SS.lightIntensity[0])*(n.Dot(l0))) + | | 284 | + max(0.0, (SS.lightIntensity[1])*(n.Dot(l1))); | | 285 | + double r = min(1.0, tt.meta.color.redF() * lighting), | | 286 | + g = min(1.0, tt.meta.color.greenF() * lighting), | | 287 | + b = min(1.0, tt.meta.color.blueF() * lighting); | 288 | 288 | tt.meta.color = RGBf(r, g, b); | 289 | 289 | smp.AddTriangle(&tt); | 290 | 290 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/exportvector.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -112,7 +112,7 @@ void DxfFileWriter::Bezier(SBezier *sb) { | 112 | 112 | theta1 = atan2(sb->ctrl[2].y - c.y, sb->ctrl[2].x - c.x), | 113 | 113 | dtheta = WRAP_SYMMETRIC(theta1 - theta0, 2*PI); | 114 | 114 | if(dtheta < 0) { | 115 | | - SWAP(double, theta0, theta1); | | 115 | + swap(theta0, theta1); | 116 | 116 | } | 117 | 117 |
| 118 | 118 | fprintf(f, | |
Collapse file Copy file name to clipboardExpand all lines: src/graphicswin.cpp +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -384,7 +384,7 @@ void GraphicsWindow::ZoomToFit(bool includingInvisibles) { | 384 | 384 | if(EXACT(dy != 0)) scaley = 0.9*height/dy; | 385 | 385 | scale = min(scalex, scaley); | 386 | 386 |
| 387 | | - scale = min(300, scale); | | 387 | + scale = min(300.0, scale); | 388 | 388 | scale = max(0.003, scale); | 389 | 389 | } | 390 | 390 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/group.cpp +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -97,7 +97,7 @@ void Group::MenuGroup(int id) { | 97 | 97 | vt = vt.WithMagnitude(1); | 98 | 98 |
| 99 | 99 | if(fabs(SS.GW.projUp.Dot(vt)) < fabs(SS.GW.projUp.Dot(ut))) { | 100 | | - SWAP(Vector, ut, vt); | | 100 | + swap(ut, vt); | 101 | 101 | g.predef.swapUV = true; | 102 | 102 | } | 103 | 103 | if(SS.GW.projRight.Dot(ut) < 0) g.predef.negateU = true; | @@ -317,7 +317,7 @@ void Group::Generate(IdList<Entity,hEntity> *entity, | 317 | 317 | Vector n = u.Cross(v); | 318 | 318 | v = (n.Cross(u)).WithMagnitude(1); | 319 | 319 |
| 320 | | - if(predef.swapUV) SWAP(Vector, u, v); | | 320 | + if(predef.swapUV) swap(u, v); | 321 | 321 | if(predef.negateU) u = u.ScaledBy(-1); | 322 | 322 | if(predef.negateV) v = v.ScaledBy(-1); | 323 | 323 | q = Quaternion::From(u, v); | |
|