MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DrawObjectSelectionBrackets

Function DrawObjectSelectionBrackets

Descent3/renderobject.cpp:659–693  ·  view source on GitHub ↗

Draws the little corner brackets around the selected object Actually, only draws those either in front or in back of the object, based on front_flag

Source from the content-addressed store, hash-verified

657// Draws the little corner brackets around the selected object
658// Actually, only draws those either in front or in back of the object, based on front_flag
659void DrawObjectSelectionBrackets(object *obj, bool front_flag) {
660 vector viewvec;
661 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
662 float line_len;
663 // Get vector from object to viewer
664 g3_GetViewPosition(&viewvec);
665 viewvec -= obj->pos;
666 // Get length of line segments we're drawing
667 line_len = (pm->maxs.x - pm->mins.x) * 0.2f;
668 // Do each corner
669 for (int c = 0; c < 8; c++) {
670 vector corner;
671 // Get the corner relative to the object
672 corner = (obj->orient.rvec * ((c & 1) ? pm->mins.x : pm->maxs.x)) +
673 (obj->orient.uvec * ((c & 2) ? pm->mins.y : pm->maxs.y)) +
674 (obj->orient.fvec * ((c & 4) ? pm->mins.z : pm->maxs.z));
675 // See if this corner is in front or in back of the object, as specified
676 if (((corner * viewvec) > 0.0) != front_flag)
677 continue;
678 // Get absolute position in 3-space
679 corner += obj->pos;
680 // Draw line for each axis at this corner
681 for (int a = 0; a < 3; a++) {
682 g3Point pp0, pp1;
683 vector t;
684 // Grab the x,y, or z axis, and scale by the line segment length
685 t = corner + ((((vector *)&obj->orient)[a]) * ((c & (1 << a)) ? line_len : -line_len));
686 // Rotate both ends of the line
687 g3_RotatePoint(&pp0, &corner);
688 g3_RotatePoint(&pp1, &t);
689 // Draw!
690 g3_DrawLine(GR_RGB(255, 255, 255), &pp0, &pp1);
691 }
692 }
693}
694#endif
695#ifdef _DEBUG
696static float ArrayX[10][20] = {{-1, 1, 1, -1, -1},

Callers 1

RenderObjectFunction · 0.85

Calls 4

g3_GetViewPositionFunction · 0.85
g3_RotatePointFunction · 0.85
g3_DrawLineFunction · 0.85
GR_RGBFunction · 0.50

Tested by

no test coverage detected