MCPcopy Create free account
hub / github.com/c3d/tao3D / ObjectInRectangle

Method ObjectInRectangle

tao/selection.cpp:59–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57
58
59uint Identify::ObjectInRectangle(const Box &rectangle,
60 uint *handlePtr,
61 uint *characterPtr,
62 uint *childPtr,
63 uint *parentPtr)
64// ----------------------------------------------------------------------------
65// Find the top-most object in the given box, return # of objects
66// ----------------------------------------------------------------------------
67{
68 // Create the select buffer and switch to select mode
69 GLuint capacity = widget->selectionCapacity();
70 GLuint selected = 0;
71 GLuint handleId = 0;
72 GLuint charSelected = 0;
73 GLuint childSelected = 0;
74 GLuint parentId = 0;
75 int hits = 0;
76
77 widget->stats.begin(Statistics::SELECT);
78
79 GLuint *buffer = new GLuint[capacity];
80 memset(buffer, 0, capacity * sizeof(GLuint));
81 GL.SelectBuffer(capacity, buffer);
82 GL.RenderMode(GL_SELECT);
83
84 // Adjust viewport for rendering
85 widget->setup(widget->width(), widget->height(), &rectangle);
86
87 // Initialize names
88 GL.InitNames();
89
90 // Draw the items in "Identity" mode (simplified drawing)
91 widget->identifySelection();
92
93 // Get number of hits and extract selection
94 // Each record is as follows:
95 // [0]: Depth of the name stack
96 // [1]: Minimum depth
97 // [2]: Maximum depth
98 // [3..3+[0]-1]: List of names
99
100 hits = GL.RenderMode(GL_RENDER);
101 if (hits > 0)
102 {
103 GLuint depth = ~0U;
104 GLuint *ptr = buffer;
105 for (int i = 0; i < hits && !handleId; i++)
106 {
107 uint size = ptr[0];
108 GLuint *selPtr = ptr + 3;
109 GLuint *selNext = selPtr + size;
110
111 if ((*selPtr & Widget::SELECTION_MASK) && ptr[1] <= depth)
112 {
113 depth = ptr[1];
114 childSelected = false;
115
116 IFTRACE(selection)

Callers

nothing calls this directly

Calls 11

selectionCapacityMethod · 0.80
SelectBufferMethod · 0.80
RenderModeMethod · 0.80
setupMethod · 0.80
InitNamesMethod · 0.80
identifySelectionMethod · 0.80
IFTRACEFunction · 0.70
beginMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected