diff options
Diffstat (limited to 'servers/physics_3d/soft_body_3d_sw.h')
| -rw-r--r-- | servers/physics_3d/soft_body_3d_sw.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/servers/physics_3d/soft_body_3d_sw.h b/servers/physics_3d/soft_body_3d_sw.h index ac8bcbf0b9..be0620c506 100644 --- a/servers/physics_3d/soft_body_3d_sw.h +++ b/servers/physics_3d/soft_body_3d_sw.h @@ -31,6 +31,7 @@ #ifndef SOFT_BODY_3D_SW_H #define SOFT_BODY_3D_SW_H +#include "area_3d_sw.h" #include "collision_object_3d_sw.h" #include "core/math/aabb.h" @@ -100,14 +101,20 @@ class SoftBody3DSW : public CollisionObject3DSW { real_t drag_coefficient = 0.0; // [0,1] LocalVector<int> pinned_vertices; + Vector3 gravity; + SelfList<SoftBody3DSW> active_list; Set<Constraint3DSW *> constraints; + Vector<AreaCMP> areas; + VSet<RID> exceptions; uint64_t island_step = 0; + _FORCE_INLINE_ void _compute_area_gravity(const Area3DSW *p_area); + public: SoftBody3DSW(); @@ -129,6 +136,25 @@ public: _FORCE_INLINE_ uint64_t get_island_step() const { return island_step; } _FORCE_INLINE_ void set_island_step(uint64_t p_step) { island_step = p_step; } + _FORCE_INLINE_ void add_area(Area3DSW *p_area) { + int index = areas.find(AreaCMP(p_area)); + if (index > -1) { + areas.write[index].refCount += 1; + } else { + areas.ordered_insert(AreaCMP(p_area)); + } + } + + _FORCE_INLINE_ void remove_area(Area3DSW *p_area) { + int index = areas.find(AreaCMP(p_area)); + if (index > -1) { + areas.write[index].refCount -= 1; + if (areas[index].refCount < 1) { + areas.remove(index); + } + } + } + virtual void set_space(Space3DSW *p_space); void set_mesh(const Ref<Mesh> &p_mesh); |
