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

Method Draw

Source/Objects/navmeshconnectionobject.cpp:228–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228void NavmeshConnectionObject::Draw() {
229 if (g_debug_runtime_disable_navmesh_connection_object_draw) {
230 return;
231 }
232
233 if (!Graphics::Instance()->media_mode() && scenegraph_->map_editor->state_ != MapEditor::kInGame && this->editor_visible) {
234 DebugDraw::Instance()->AddWireSphere(GetTranslation(), 0.5f, vec4(0.2f, 0.2f, 0.9f, 0.5f), _delete_on_draw);
235
236 // Need to do this to ensure the state is updated for rendering.
237 UpdatePolyAreas();
238
239 std::vector<NavMeshConnectionData>::iterator iter = connections.begin();
240 for (; iter != connections.end(); iter++) {
241 Object* obj = scenegraph_->GetObjectFromID(iter->other_object_id);
242 if (obj == NULL) {
243 LOGW_ONCE("Navemesh connection object is connected to -1");
244 return;
245 }
246
247 // All connections are two way right now, so we only draw in one direction.
248 if (this->GetID() > obj->GetID()) {
249 vec4 color = vec4(1.0f, 0, 0, 1.0f);
250 DDFlag dd_flag = _DD_NO_FLAG;
251
252 if (iter->offmesh_connection_id == -1) {
253 dd_flag = _DD_DASHED;
254 }
255
256 SamplePolyAreas poly_area = iter->poly_area;
257 if (poly_area == SAMPLE_POLYAREA_JUMP1) {
258 color = vec4(0, 0.9f, 0, 1.0f);
259 } else if (poly_area == SAMPLE_POLYAREA_JUMP2) {
260 color = vec4(83 / 255.0f, 255 / 255.0f, 26 / 255.0f, 1.0f);
261 } else if (poly_area == SAMPLE_POLYAREA_JUMP3) {
262 color = vec4(184 / 255.0f, 138 / 255.0f, 0 / 255.0f, 1.0f);
263 } else if (poly_area == SAMPLE_POLYAREA_JUMP4) {
264 color = vec4(0, 61 / 255.0f, 245 / 255.0f, 1.0f);
265 } else if (poly_area == SAMPLE_POLYAREA_JUMP5) {
266 color = vec4(102 / 255.0f, 51 / 255.0f, 255 / 255.0f, 1.0f);
267 }
268
269 DebugDraw::Instance()->AddLine(GetTranslation(), obj->GetTranslation(), color, _delete_on_draw, dd_flag);
270 }
271 }
272 }
273}
274
275void NavmeshConnectionObject::FinalizeLoadedConnections() {
276 Object::FinalizeLoadedConnections();

Callers

nothing calls this directly

Calls 10

GetTranslationFunction · 0.85
media_modeMethod · 0.80
AddWireSphereMethod · 0.80
GetObjectFromIDMethod · 0.80
GetTranslationMethod · 0.80
vec4Class · 0.50
beginMethod · 0.45
endMethod · 0.45
GetIDMethod · 0.45
AddLineMethod · 0.45

Tested by

no test coverage detected