@@ -195,7 +195,7 @@ real_t GridMap::get_collision_priority() const {
195195
196196void GridMap::set_physics_material (Ref<PhysicsMaterial> p_material) {
197197 physics_material = p_material;
198- _recreate_octant_data ();
198+ _update_physics_bodies_characteristics ();
199199}
200200
201201Ref<PhysicsMaterial> GridMap::get_physics_material () const {
@@ -370,8 +370,8 @@ void GridMap::set_cell_item(const Vector3i &p_position, int p_item, int p_rot) {
370370 PhysicsServer3D::get_singleton ()->body_set_collision_mask (g->static_body , collision_mask);
371371 PhysicsServer3D::get_singleton ()->body_set_collision_priority (g->static_body , collision_priority);
372372 if (physics_material.is_valid ()) {
373- PhysicsServer3D::get_singleton ()->body_set_param (g->static_body , PhysicsServer3D::BODY_PARAM_FRICTION, physics_material->get_friction ());
374- PhysicsServer3D::get_singleton ()->body_set_param (g->static_body , PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material->get_bounce ());
373+ PhysicsServer3D::get_singleton ()->body_set_param (g->static_body , PhysicsServer3D::BODY_PARAM_FRICTION, physics_material->computed_friction ());
374+ PhysicsServer3D::get_singleton ()->body_set_param (g->static_body , PhysicsServer3D::BODY_PARAM_BOUNCE, physics_material->computed_bounce ());
375375 }
376376 SceneTree *st = SceneTree::get_singleton ();
377377
@@ -748,6 +748,19 @@ void GridMap::_update_physics_bodies_collision_properties() {
748748 }
749749}
750750
751+ void GridMap::_update_physics_bodies_characteristics () {
752+ real_t friction = 1.0 ;
753+ real_t bounce = 0.0 ;
754+ if (physics_material.is_valid ()) {
755+ friction = physics_material->computed_friction ();
756+ bounce = physics_material->computed_bounce ();
757+ }
758+ for (const KeyValue<OctantKey, Octant *> &E : octant_map) {
759+ PhysicsServer3D::get_singleton ()->body_set_param (E.value ->static_body , PhysicsServer3D::BODY_PARAM_FRICTION, friction);
760+ PhysicsServer3D::get_singleton ()->body_set_param (E.value ->static_body , PhysicsServer3D::BODY_PARAM_BOUNCE, bounce);
761+ }
762+ }
763+
751764void GridMap::_octant_enter_world (const OctantKey &p_key) {
752765 ERR_FAIL_COND (!octant_map.has (p_key));
753766 Octant &g = *octant_map[p_key];
0 commit comments