MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / GetEditorLineCollisions

Function GetEditorLineCollisions

Source/Editors/map_editor.cpp:139–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137};
138
139static void GetEditorLineCollisions(SceneGraph* scenegraph, const vec3& start, const vec3& end, std::vector<Collision>& collisions, const TypeEnable& type_enable) {
140 PROFILER_ZONE(g_profiler_ctx, "GetEditorLineCollisions");
141 scenegraph->LineCheckAll(start, end, &collisions);
142 if (collisions.empty()) {
143 return;
144 }
145 std::sort(collisions.begin(), collisions.end(), CollisionCompare(start));
146
147 for (int i = 0; i < (int)collisions.size();) {
148 if (collisions[i].hit_what->GetType() == _group ||
149 collisions[i].hit_what->GetType() == _prefab ||
150 !(collisions[i].hit_what->permission_flags & Object::CAN_SELECT) ||
151 !type_enable.IsTypeEnabled(collisions[i].hit_what->GetType())) {
152 collisions.erase(collisions.begin() + i);
153 } else if (collisions[i].hit_what->parent &&
154 (collisions[i].hit_what->parent->GetType() == _group ||
155 collisions[i].hit_what->parent->GetType() == _prefab)) {
156 int depth = 1;
157 while (collisions[i].hit_what->parent &&
158 (collisions[i].hit_what->parent->GetType() == _group ||
159 collisions[i].hit_what->parent->GetType() == _prefab)
160
161 ) {
162 bool is_duplicate = false;
163 for (int j = 0; j < i; ++j) { // Don't allow same group to be in list twice
164 if (collisions[i].hit_what->parent == collisions[j].hit_what) {
165 is_duplicate = true;
166 break;
167 }
168 }
169 if (!is_duplicate) {
170 ++depth;
171 collisions.insert(collisions.begin() + i, collisions[i]);
172 collisions[i].hit_what = collisions[i].hit_what->parent;
173 } else {
174 break;
175 }
176 }
177 i += depth;
178 } else {
179 ++i;
180 }
181 }
182}
183
184// Given a set of selected objects, what kind of connections are possible
185static Object::ConnectionType GetConnectionType(const std::vector<Object*>& selected) {

Callers 2

HandleScrollSelectMethod · 0.85

Calls 11

CollisionCompareClass · 0.85
LineCheckAllMethod · 0.80
sortFunction · 0.50
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
GetTypeMethod · 0.45
IsTypeEnabledMethod · 0.45
eraseMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected