summaryrefslogtreecommitdiff
path: root/servers/physics/body_sw.h
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics/body_sw.h')
-rw-r--r--servers/physics/body_sw.h262
1 files changed, 138 insertions, 124 deletions
diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h
index 2383d2d688..4b1af6fca5 100644
--- a/servers/physics/body_sw.h
+++ b/servers/physics/body_sw.h
@@ -29,16 +29,14 @@
#ifndef BODY_SW_H
#define BODY_SW_H
+#include "area_sw.h"
#include "collision_object_sw.h"
#include "vset.h"
-#include "area_sw.h"
class ConstraintSW;
-
class BodySW : public CollisionObjectSW {
-
PhysicsServer::BodyMode mode;
Vector3 linear_velocity;
@@ -78,7 +76,6 @@ class BodySW : public CollisionObjectSW {
real_t area_angular_damp;
real_t area_linear_damp;
-
SelfList<BodySW> active_list;
SelfList<BodySW> inertia_update_list;
SelfList<BodySW> direct_state_query_list;
@@ -96,23 +93,25 @@ class BodySW : public CollisionObjectSW {
virtual void _shapes_changed();
Transform new_transform;
- Map<ConstraintSW*,int> constraint_map;
+ Map<ConstraintSW *, int> constraint_map;
struct AreaCMP {
AreaSW *area;
int refCount;
- _FORCE_INLINE_ bool operator==(const AreaCMP& p_cmp) const { return area->get_self() == p_cmp.area->get_self();}
- _FORCE_INLINE_ bool operator<(const AreaCMP& p_cmp) const { return area->get_priority() < p_cmp.area->get_priority();}
+ _FORCE_INLINE_ bool operator==(const AreaCMP &p_cmp) const { return area->get_self() == p_cmp.area->get_self(); }
+ _FORCE_INLINE_ bool operator<(const AreaCMP &p_cmp) const { return area->get_priority() < p_cmp.area->get_priority(); }
_FORCE_INLINE_ AreaCMP() {}
- _FORCE_INLINE_ AreaCMP(AreaSW *p_area) { area=p_area; refCount=1;}
+ _FORCE_INLINE_ AreaCMP(AreaSW *p_area) {
+ area = p_area;
+ refCount = 1;
+ }
};
Vector<AreaCMP> areas;
struct Contact {
-
Vector3 local_pos;
Vector3 local_normal;
real_t depth;
@@ -136,7 +135,6 @@ class BodySW : public CollisionObjectSW {
ForceIntegrationCallback *fi_callback;
-
uint64_t island_step;
BodySW *island_next;
BodySW *island_list_next;
@@ -145,16 +143,14 @@ class BodySW : public CollisionObjectSW {
_FORCE_INLINE_ void _update_transform_dependant();
-friend class PhysicsDirectBodyStateSW; // i give up, too many functions to expose
+ friend class PhysicsDirectBodyStateSW; // i give up, too many functions to expose
public:
-
-
- void set_force_integration_callback(ObjectID p_id,const StringName& p_method,const Variant& p_udata=Variant());
+ void set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant());
_FORCE_INLINE_ void add_area(AreaSW *p_area) {
int index = areas.find(AreaCMP(p_area));
- if( index > -1 ) {
+ if (index > -1) {
areas[index].refCount += 1;
} else {
areas.ordered_insert(AreaCMP(p_area));
@@ -163,77 +159,80 @@ public:
_FORCE_INLINE_ void remove_area(AreaSW *p_area) {
int index = areas.find(AreaCMP(p_area));
- if( index > -1 ) {
+ if (index > -1) {
areas[index].refCount -= 1;
- if( areas[index].refCount < 1 )
+ if (areas[index].refCount < 1)
areas.remove(index);
}
}
- _FORCE_INLINE_ void set_max_contacts_reported(int p_size) { contacts.resize(p_size); contact_count=0; if (mode==PhysicsServer::BODY_MODE_KINEMATIC && p_size) set_active(true);}
+ _FORCE_INLINE_ void set_max_contacts_reported(int p_size) {
+ contacts.resize(p_size);
+ contact_count = 0;
+ if (mode == PhysicsServer::BODY_MODE_KINEMATIC && p_size) set_active(true);
+ }
_FORCE_INLINE_ int get_max_contacts_reported() const { return contacts.size(); }
_FORCE_INLINE_ bool can_report_contacts() const { return !contacts.empty(); }
- _FORCE_INLINE_ void add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, real_t p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos);
-
+ _FORCE_INLINE_ void add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_normal, real_t p_depth, int p_local_shape, const Vector3 &p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID &p_collider, const Vector3 &p_collider_velocity_at_pos);
- _FORCE_INLINE_ void add_exception(const RID& p_exception) { exceptions.insert(p_exception);}
- _FORCE_INLINE_ void remove_exception(const RID& p_exception) { exceptions.erase(p_exception);}
- _FORCE_INLINE_ bool has_exception(const RID& p_exception) const { return exceptions.has(p_exception);}
- _FORCE_INLINE_ const VSet<RID>& get_exceptions() const { return exceptions;}
+ _FORCE_INLINE_ void add_exception(const RID &p_exception) { exceptions.insert(p_exception); }
+ _FORCE_INLINE_ void remove_exception(const RID &p_exception) { exceptions.erase(p_exception); }
+ _FORCE_INLINE_ bool has_exception(const RID &p_exception) const { return exceptions.has(p_exception); }
+ _FORCE_INLINE_ const VSet<RID> &get_exceptions() const { return exceptions; }
_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 set_island_step(uint64_t p_step) { island_step = p_step; }
- _FORCE_INLINE_ BodySW* get_island_next() const { return island_next; }
- _FORCE_INLINE_ void set_island_next(BodySW* p_next) { island_next=p_next; }
+ _FORCE_INLINE_ BodySW *get_island_next() const { return island_next; }
+ _FORCE_INLINE_ void set_island_next(BodySW *p_next) { island_next = p_next; }
- _FORCE_INLINE_ BodySW* get_island_list_next() const { return island_list_next; }
- _FORCE_INLINE_ void set_island_list_next(BodySW* p_next) { island_list_next=p_next; }
+ _FORCE_INLINE_ BodySW *get_island_list_next() const { return island_list_next; }
+ _FORCE_INLINE_ void set_island_list_next(BodySW *p_next) { island_list_next = p_next; }
- _FORCE_INLINE_ void add_constraint(ConstraintSW* p_constraint, int p_pos) { constraint_map[p_constraint]=p_pos; }
- _FORCE_INLINE_ void remove_constraint(ConstraintSW* p_constraint) { constraint_map.erase(p_constraint); }
- const Map<ConstraintSW*,int>& get_constraint_map() const { return constraint_map; }
+ _FORCE_INLINE_ void add_constraint(ConstraintSW *p_constraint, int p_pos) { constraint_map[p_constraint] = p_pos; }
+ _FORCE_INLINE_ void remove_constraint(ConstraintSW *p_constraint) { constraint_map.erase(p_constraint); }
+ const Map<ConstraintSW *, int> &get_constraint_map() const { return constraint_map; }
- _FORCE_INLINE_ void set_omit_force_integration(bool p_omit_force_integration) { omit_force_integration=p_omit_force_integration; }
+ _FORCE_INLINE_ void set_omit_force_integration(bool p_omit_force_integration) { omit_force_integration = p_omit_force_integration; }
_FORCE_INLINE_ bool get_omit_force_integration() const { return omit_force_integration; }
_FORCE_INLINE_ Basis get_principal_inertia_axes() const { return principal_inertia_axes; }
_FORCE_INLINE_ Vector3 get_center_of_mass() const { return center_of_mass; }
- _FORCE_INLINE_ Vector3 xform_local_to_principal(const Vector3& p_pos) const { return principal_inertia_axes_local.xform(p_pos - center_of_mass_local); }
+ _FORCE_INLINE_ Vector3 xform_local_to_principal(const Vector3 &p_pos) const { return principal_inertia_axes_local.xform(p_pos - center_of_mass_local); }
- _FORCE_INLINE_ void set_linear_velocity(const Vector3& p_velocity) {linear_velocity=p_velocity; }
+ _FORCE_INLINE_ void set_linear_velocity(const Vector3 &p_velocity) { linear_velocity = p_velocity; }
_FORCE_INLINE_ Vector3 get_linear_velocity() const { return linear_velocity; }
- _FORCE_INLINE_ void set_angular_velocity(const Vector3& p_velocity) { angular_velocity=p_velocity; }
+ _FORCE_INLINE_ void set_angular_velocity(const Vector3 &p_velocity) { angular_velocity = p_velocity; }
_FORCE_INLINE_ Vector3 get_angular_velocity() const { return angular_velocity; }
- _FORCE_INLINE_ const Vector3& get_biased_linear_velocity() const { return biased_linear_velocity; }
- _FORCE_INLINE_ const Vector3& get_biased_angular_velocity() const { return biased_angular_velocity; }
+ _FORCE_INLINE_ const Vector3 &get_biased_linear_velocity() const { return biased_linear_velocity; }
+ _FORCE_INLINE_ const Vector3 &get_biased_angular_velocity() const { return biased_angular_velocity; }
- _FORCE_INLINE_ void apply_impulse(const Vector3& p_pos, const Vector3& p_j) {
+ _FORCE_INLINE_ void apply_impulse(const Vector3 &p_pos, const Vector3 &p_j) {
linear_velocity += p_j * _inv_mass;
- angular_velocity += _inv_inertia_tensor.xform( (p_pos-center_of_mass).cross(p_j) );
+ angular_velocity += _inv_inertia_tensor.xform((p_pos - center_of_mass).cross(p_j));
}
- _FORCE_INLINE_ void apply_torque_impulse(const Vector3& p_j) {
+ _FORCE_INLINE_ void apply_torque_impulse(const Vector3 &p_j) {
angular_velocity += _inv_inertia_tensor.xform(p_j);
}
- _FORCE_INLINE_ void apply_bias_impulse(const Vector3& p_pos, const Vector3& p_j) {
+ _FORCE_INLINE_ void apply_bias_impulse(const Vector3 &p_pos, const Vector3 &p_j) {
biased_linear_velocity += p_j * _inv_mass;
- biased_angular_velocity += _inv_inertia_tensor.xform( (p_pos-center_of_mass).cross(p_j) );
+ biased_angular_velocity += _inv_inertia_tensor.xform((p_pos - center_of_mass).cross(p_j));
}
- _FORCE_INLINE_ void apply_bias_torque_impulse(const Vector3& p_j) {
+ _FORCE_INLINE_ void apply_bias_torque_impulse(const Vector3 &p_j) {
biased_angular_velocity += _inv_inertia_tensor.xform(p_j);
}
- _FORCE_INLINE_ void add_force(const Vector3& p_force, const Vector3& p_pos) {
+ _FORCE_INLINE_ void add_force(const Vector3 &p_force, const Vector3 &p_pos) {
applied_force += p_force;
applied_torque += p_pos.cross(p_force);
@@ -243,7 +242,7 @@ public:
_FORCE_INLINE_ bool is_active() const { return active; }
_FORCE_INLINE_ void wakeup() {
- if ((!get_space()) || mode==PhysicsServer::BODY_MODE_STATIC || mode==PhysicsServer::BODY_MODE_KINEMATIC)
+ if ((!get_space()) || mode == PhysicsServer::BODY_MODE_STATIC || mode == PhysicsServer::BODY_MODE_KINEMATIC)
return;
set_active(true);
}
@@ -254,16 +253,16 @@ public:
void set_mode(PhysicsServer::BodyMode p_mode);
PhysicsServer::BodyMode get_mode() const;
- void set_state(PhysicsServer::BodyState p_state, const Variant& p_variant);
+ void set_state(PhysicsServer::BodyState p_state, const Variant &p_variant);
Variant get_state(PhysicsServer::BodyState p_state) const;
- void set_applied_force(const Vector3& p_force) { applied_force=p_force; }
+ void set_applied_force(const Vector3 &p_force) { applied_force = p_force; }
Vector3 get_applied_force() const { return applied_force; }
- void set_applied_torque(const Vector3& p_torque) { applied_torque=p_torque; }
+ void set_applied_torque(const Vector3 &p_torque) { applied_torque = p_torque; }
Vector3 get_applied_torque() const { return applied_torque; }
- _FORCE_INLINE_ void set_continuous_collision_detection(bool p_enable) { continuous_cd=p_enable; }
+ _FORCE_INLINE_ void set_continuous_collision_detection(bool p_enable) { continuous_cd = p_enable; }
_FORCE_INLINE_ bool is_continuous_collision_detection_enabled() const { return continuous_cd; }
void set_space(SpaceSW *p_space);
@@ -277,33 +276,32 @@ public:
_FORCE_INLINE_ Vector3 get_gravity() const { return gravity; }
_FORCE_INLINE_ real_t get_bounce() const { return bounce; }
- _FORCE_INLINE_ void set_axis_lock(PhysicsServer::BodyAxisLock p_lock) { axis_lock=p_lock; }
+ _FORCE_INLINE_ void set_axis_lock(PhysicsServer::BodyAxisLock p_lock) { axis_lock = p_lock; }
_FORCE_INLINE_ PhysicsServer::BodyAxisLock get_axis_lock() const { return axis_lock; }
void integrate_forces(real_t p_step);
void integrate_velocities(real_t p_step);
- _FORCE_INLINE_ Vector3 get_velocity_in_local_point(const Vector3& rel_pos) const {
+ _FORCE_INLINE_ Vector3 get_velocity_in_local_point(const Vector3 &rel_pos) const {
- return linear_velocity + angular_velocity.cross(rel_pos-center_of_mass);
+ return linear_velocity + angular_velocity.cross(rel_pos - center_of_mass);
}
- _FORCE_INLINE_ real_t compute_impulse_denominator(const Vector3& p_pos, const Vector3& p_normal) const {
+ _FORCE_INLINE_ real_t compute_impulse_denominator(const Vector3 &p_pos, const Vector3 &p_normal) const {
- Vector3 r0 = p_pos - get_transform().origin - center_of_mass;
+ Vector3 r0 = p_pos - get_transform().origin - center_of_mass;
- Vector3 c0 = (r0).cross(p_normal);
+ Vector3 c0 = (r0).cross(p_normal);
- Vector3 vec = (_inv_inertia_tensor.xform_inv(c0)).cross(r0);
+ Vector3 vec = (_inv_inertia_tensor.xform_inv(c0)).cross(r0);
- return _inv_mass + p_normal.dot(vec);
-
- }
+ return _inv_mass + p_normal.dot(vec);
+ }
- _FORCE_INLINE_ real_t compute_angular_impulse_denominator(const Vector3& p_axis) const {
+ _FORCE_INLINE_ real_t compute_angular_impulse_denominator(const Vector3 &p_axis) const {
- return p_axis.dot( _inv_inertia_tensor.xform_inv(p_axis) );
- }
+ return p_axis.dot(_inv_inertia_tensor.xform_inv(p_axis));
+ }
//void simulate_motion(const Transform& p_xform,real_t p_step);
void call_queries();
@@ -313,117 +311,133 @@ public:
BodySW();
~BodySW();
-
};
-
//add contact inline
-void BodySW::add_contact(const Vector3& p_local_pos,const Vector3& p_local_normal, real_t p_depth, int p_local_shape, const Vector3& p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID& p_collider,const Vector3& p_collider_velocity_at_pos) {
+void BodySW::add_contact(const Vector3 &p_local_pos, const Vector3 &p_local_normal, real_t p_depth, int p_local_shape, const Vector3 &p_collider_pos, int p_collider_shape, ObjectID p_collider_instance_id, const RID &p_collider, const Vector3 &p_collider_velocity_at_pos) {
- int c_max=contacts.size();
+ int c_max = contacts.size();
- if (c_max==0)
+ if (c_max == 0)
return;
Contact *c = &contacts[0];
+ int idx = -1;
- int idx=-1;
-
- if (contact_count<c_max) {
- idx=contact_count++;
+ if (contact_count < c_max) {
+ idx = contact_count++;
} else {
- real_t least_depth=1e20;
- int least_deep=-1;
- for(int i=0;i<c_max;i++) {
+ real_t least_depth = 1e20;
+ int least_deep = -1;
+ for (int i = 0; i < c_max; i++) {
- if (i==0 || c[i].depth<least_depth) {
- least_deep=i;
- least_depth=c[i].depth;
+ if (i == 0 || c[i].depth < least_depth) {
+ least_deep = i;
+ least_depth = c[i].depth;
}
}
- if (least_deep>=0 && least_depth<p_depth) {
+ if (least_deep >= 0 && least_depth < p_depth) {
- idx=least_deep;
+ idx = least_deep;
}
- if (idx==-1)
+ if (idx == -1)
return; //none least deepe than this
}
- c[idx].local_pos=p_local_pos;
- c[idx].local_normal=p_local_normal;
- c[idx].depth=p_depth;
- c[idx].local_shape=p_local_shape;
- c[idx].collider_pos=p_collider_pos;
- c[idx].collider_shape=p_collider_shape;
- c[idx].collider_instance_id=p_collider_instance_id;
- c[idx].collider=p_collider;
- c[idx].collider_velocity_at_pos=p_collider_velocity_at_pos;
-
+ c[idx].local_pos = p_local_pos;
+ c[idx].local_normal = p_local_normal;
+ c[idx].depth = p_depth;
+ c[idx].local_shape = p_local_shape;
+ c[idx].collider_pos = p_collider_pos;
+ c[idx].collider_shape = p_collider_shape;
+ c[idx].collider_instance_id = p_collider_instance_id;
+ c[idx].collider = p_collider;
+ c[idx].collider_velocity_at_pos = p_collider_velocity_at_pos;
}
-
class PhysicsDirectBodyStateSW : public PhysicsDirectBodyState {
- GDCLASS( PhysicsDirectBodyStateSW, PhysicsDirectBodyState );
+ GDCLASS(PhysicsDirectBodyStateSW, PhysicsDirectBodyState);
public:
-
static PhysicsDirectBodyStateSW *singleton;
BodySW *body;
real_t step;
- virtual Vector3 get_total_gravity() const { return body->gravity; } // get gravity vector working on this body space/area
- virtual real_t get_total_angular_damp() const { return body->area_angular_damp; } // get density of this body space/area
- virtual real_t get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area
+ virtual Vector3 get_total_gravity() const { return body->gravity; } // get gravity vector working on this body space/area
+ virtual real_t get_total_angular_damp() const { return body->area_angular_damp; } // get density of this body space/area
+ virtual real_t get_total_linear_damp() const { return body->area_linear_damp; } // get density of this body space/area
virtual Vector3 get_center_of_mass() const { return body->get_center_of_mass(); }
virtual Basis get_principal_inertia_axes() const { return body->get_principal_inertia_axes(); }
- virtual real_t get_inverse_mass() const { return body->get_inv_mass(); } // get the mass
- virtual Vector3 get_inverse_inertia() const { return body->get_inv_inertia(); } // get density of this body space
- virtual Basis get_inverse_inertia_tensor() const { return body->get_inv_inertia_tensor(); } // get density of this body space
+ virtual real_t get_inverse_mass() const { return body->get_inv_mass(); } // get the mass
+ virtual Vector3 get_inverse_inertia() const { return body->get_inv_inertia(); } // get density of this body space
+ virtual Basis get_inverse_inertia_tensor() const { return body->get_inv_inertia_tensor(); } // get density of this body space
- virtual void set_linear_velocity(const Vector3& p_velocity) { body->set_linear_velocity(p_velocity); }
- virtual Vector3 get_linear_velocity() const { return body->get_linear_velocity(); }
+ virtual void set_linear_velocity(const Vector3 &p_velocity) { body->set_linear_velocity(p_velocity); }
+ virtual Vector3 get_linear_velocity() const { return body->get_linear_velocity(); }
- virtual void set_angular_velocity(const Vector3& p_velocity) { body->set_angular_velocity(p_velocity); }
- virtual Vector3 get_angular_velocity() const { return body->get_angular_velocity(); }
+ virtual void set_angular_velocity(const Vector3 &p_velocity) { body->set_angular_velocity(p_velocity); }
+ virtual Vector3 get_angular_velocity() const { return body->get_angular_velocity(); }
- virtual void set_transform(const Transform& p_transform) { body->set_state(PhysicsServer::BODY_STATE_TRANSFORM,p_transform); }
- virtual Transform get_transform() const { return body->get_transform(); }
+ virtual void set_transform(const Transform &p_transform) { body->set_state(PhysicsServer::BODY_STATE_TRANSFORM, p_transform); }
+ virtual Transform get_transform() const { return body->get_transform(); }
- virtual void add_force(const Vector3& p_force, const Vector3& p_pos) { body->add_force(p_force,p_pos); }
- virtual void apply_impulse(const Vector3& p_pos, const Vector3& p_j) { body->apply_impulse(p_pos,p_j); }
- virtual void apply_torque_impulse(const Vector3& p_j) { body->apply_torque_impulse(p_j); }
+ virtual void add_force(const Vector3 &p_force, const Vector3 &p_pos) { body->add_force(p_force, p_pos); }
+ virtual void apply_impulse(const Vector3 &p_pos, const Vector3 &p_j) { body->apply_impulse(p_pos, p_j); }
+ virtual void apply_torque_impulse(const Vector3 &p_j) { body->apply_torque_impulse(p_j); }
- virtual void set_sleep_state(bool p_enable) { body->set_active(!p_enable); }
- virtual bool is_sleeping() const { return !body->is_active(); }
+ virtual void set_sleep_state(bool p_enable) { body->set_active(!p_enable); }
+ virtual bool is_sleeping() const { return !body->is_active(); }
- virtual int get_contact_count() const { return body->contact_count; }
+ virtual int get_contact_count() const { return body->contact_count; }
virtual Vector3 get_contact_local_pos(int p_contact_idx) const {
- ERR_FAIL_INDEX_V(p_contact_idx,body->contact_count,Vector3());
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Vector3());
return body->contacts[p_contact_idx].local_pos;
}
- virtual Vector3 get_contact_local_normal(int p_contact_idx) const { ERR_FAIL_INDEX_V(p_contact_idx,body->contact_count,Vector3()); return body->contacts[p_contact_idx].local_normal; }
- virtual int get_contact_local_shape(int p_contact_idx) const { ERR_FAIL_INDEX_V(p_contact_idx,body->contact_count,-1); return body->contacts[p_contact_idx].local_shape; }
-
- virtual RID get_contact_collider(int p_contact_idx) const { ERR_FAIL_INDEX_V(p_contact_idx,body->contact_count,RID()); return body->contacts[p_contact_idx].collider; }
- virtual Vector3 get_contact_collider_pos(int p_contact_idx) const { ERR_FAIL_INDEX_V(p_contact_idx,body->contact_count,Vector3()); return body->contacts[p_contact_idx].collider_pos; }
- virtual ObjectID get_contact_collider_id(int p_contact_idx) const { ERR_FAIL_INDEX_V(p_contact_idx,body->contact_count,0); return body->contacts[p_contact_idx].collider_instance_id; }
- virtual int get_contact_collider_shape(int p_contact_idx) const { ERR_FAIL_INDEX_V(p_contact_idx,body->contact_count,0); return body->contacts[p_contact_idx].collider_shape; }
- virtual Vector3 get_contact_collider_velocity_at_pos(int p_contact_idx) const { ERR_FAIL_INDEX_V(p_contact_idx,body->contact_count,Vector3()); return body->contacts[p_contact_idx].collider_velocity_at_pos; }
+ virtual Vector3 get_contact_local_normal(int p_contact_idx) const {
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Vector3());
+ return body->contacts[p_contact_idx].local_normal;
+ }
+ virtual int get_contact_local_shape(int p_contact_idx) const {
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, -1);
+ return body->contacts[p_contact_idx].local_shape;
+ }
- virtual PhysicsDirectSpaceState* get_space_state();
+ virtual RID get_contact_collider(int p_contact_idx) const {
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, RID());
+ return body->contacts[p_contact_idx].collider;
+ }
+ virtual Vector3 get_contact_collider_pos(int p_contact_idx) const {
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Vector3());
+ return body->contacts[p_contact_idx].collider_pos;
+ }
+ virtual ObjectID get_contact_collider_id(int p_contact_idx) const {
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, 0);
+ return body->contacts[p_contact_idx].collider_instance_id;
+ }
+ virtual int get_contact_collider_shape(int p_contact_idx) const {
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, 0);
+ return body->contacts[p_contact_idx].collider_shape;
+ }
+ virtual Vector3 get_contact_collider_velocity_at_pos(int p_contact_idx) const {
+ ERR_FAIL_INDEX_V(p_contact_idx, body->contact_count, Vector3());
+ return body->contacts[p_contact_idx].collider_velocity_at_pos;
+ }
+ virtual PhysicsDirectSpaceState *get_space_state();
virtual real_t get_step() const { return step; }
- PhysicsDirectBodyStateSW() { singleton=this; body=NULL; }
+ PhysicsDirectBodyStateSW() {
+ singleton = this;
+ body = NULL;
+ }
};
-
#endif // BODY__SW_H