MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _octant_update

Method _octant_update

modules/gridmap/grid_map.cpp:608–842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606}
607
608bool GridMap::_octant_update(const OctantKey &p_key) {
609 ERR_FAIL_COND_V(!octant_map.has(p_key), false);
610 Octant &g = *octant_map[p_key];
611 if (!g.dirty) {
612 return false;
613 }
614
615#ifndef PHYSICS_3D_DISABLED
616 //erase body shapes
617 PhysicsServer3D::get_singleton()->body_clear_shapes(g.static_body);
618
619 //erase body shapes debug
620 if (g.collision_debug.is_valid()) {
621 RS::get_singleton()->mesh_clear(g.collision_debug);
622 }
623#endif // PHYSICS_3D_DISABLED
624
625#ifndef NAVIGATION_3D_DISABLED
626 //erase navigation
627 for (KeyValue<IndexKey, Octant::NavigationCell> &E : g.navigation_cell_ids) {
628 if (E.value.region.is_valid()) {
629 NavigationServer3D::get_singleton()->free(E.value.region);
630 E.value.region = RID();
631 }
632 if (E.value.navigation_mesh_debug_instance.is_valid()) {
633 RS::get_singleton()->free(E.value.navigation_mesh_debug_instance);
634 E.value.navigation_mesh_debug_instance = RID();
635 }
636 }
637 g.navigation_cell_ids.clear();
638#endif // NAVIGATION_3D_DISABLED
639
640 //erase multimeshes
641
642 for (int i = 0; i < g.multimesh_instances.size(); i++) {
643 RS::get_singleton()->free(g.multimesh_instances[i].instance);
644 RS::get_singleton()->free(g.multimesh_instances[i].multimesh);
645 }
646 g.multimesh_instances.clear();
647
648 if (g.cells.is_empty()) {
649 //octant no longer needed
650 _octant_clean_up(p_key);
651 return true;
652 }
653
654 Vector<Vector3> col_debug;
655
656 /**
657 * foreach item in this octant,
658 * set item's multimesh's instance count to number of cells which have this item
659 * and set said multimesh bounding box to one containing all cells which have this item
660 */
661
662 struct MultiMeshItemPlacement {
663 Transform3D transform;
664 IndexKey index_key;
665 };

Callers

nothing calls this directly

Calls 15

RIDClass · 0.85
get_scenarioMethod · 0.80
has_itemMethod · 0.80
get_item_meshMethod · 0.80
get_item_shapesMethod · 0.80
add_vertices_to_arrayMethod · 0.80
instance_set_baseMethod · 0.80

Tested by

no test coverage detected