Initialize variables in servers/physics
This commit is contained in:
parent
7b21b1bb60
commit
91257c3900
53 changed files with 362 additions and 624 deletions
|
|
@ -329,17 +329,7 @@ Area3DSW::Area3DSW() :
|
|||
monitor_query_list(this),
|
||||
moved_list(this) {
|
||||
_set_static(true); //areas are never active
|
||||
space_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
|
||||
gravity = 9.80665;
|
||||
gravity_vector = Vector3(0, -1, 0);
|
||||
gravity_is_point = false;
|
||||
gravity_distance_scale = 0;
|
||||
point_attenuation = 1;
|
||||
angular_damp = 0.1;
|
||||
linear_damp = 0.1;
|
||||
priority = 0;
|
||||
set_ray_pickable(false);
|
||||
monitorable = false;
|
||||
}
|
||||
|
||||
Area3DSW::~Area3DSW() {
|
||||
|
|
|
|||
|
|
@ -41,20 +41,20 @@ class SoftBody3DSW;
|
|||
class Constraint3DSW;
|
||||
|
||||
class Area3DSW : public CollisionObject3DSW {
|
||||
PhysicsServer3D::AreaSpaceOverrideMode space_override_mode;
|
||||
real_t gravity;
|
||||
Vector3 gravity_vector;
|
||||
bool gravity_is_point;
|
||||
real_t gravity_distance_scale;
|
||||
real_t point_attenuation;
|
||||
real_t linear_damp;
|
||||
real_t angular_damp;
|
||||
PhysicsServer3D::AreaSpaceOverrideMode space_override_mode = PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED;
|
||||
real_t gravity = 9.80665;
|
||||
Vector3 gravity_vector = Vector3(0, -1, 0);
|
||||
bool gravity_is_point = false;
|
||||
real_t gravity_distance_scale = 0.0;
|
||||
real_t point_attenuation = 1.0;
|
||||
real_t linear_damp = 0.1;
|
||||
real_t angular_damp = 0.1;
|
||||
real_t wind_force_magnitude = 0.0;
|
||||
real_t wind_attenuation_factor = 0.0;
|
||||
Vector3 wind_source;
|
||||
Vector3 wind_direction;
|
||||
int priority;
|
||||
bool monitorable;
|
||||
int priority = 0;
|
||||
bool monitorable = false;
|
||||
|
||||
ObjectID monitor_callback_id;
|
||||
StringName monitor_callback_method;
|
||||
|
|
@ -68,8 +68,8 @@ class Area3DSW : public CollisionObject3DSW {
|
|||
struct BodyKey {
|
||||
RID rid;
|
||||
ObjectID instance_id;
|
||||
uint32_t body_shape;
|
||||
uint32_t area_shape;
|
||||
uint32_t body_shape = 0;
|
||||
uint32_t area_shape = 0;
|
||||
|
||||
_FORCE_INLINE_ bool operator<(const BodyKey &p_key) const {
|
||||
if (rid == p_key.rid) {
|
||||
|
|
@ -90,10 +90,9 @@ class Area3DSW : public CollisionObject3DSW {
|
|||
};
|
||||
|
||||
struct BodyState {
|
||||
int state;
|
||||
int state = 0;
|
||||
_FORCE_INLINE_ void inc() { state++; }
|
||||
_FORCE_INLINE_ void dec() { state--; }
|
||||
_FORCE_INLINE_ BodyState() { state = 0; }
|
||||
};
|
||||
|
||||
Map<BodyKey, BodyState> monitored_soft_bodies;
|
||||
|
|
@ -232,8 +231,8 @@ void Area3DSW::remove_area_from_query(Area3DSW *p_area, uint32_t p_area_shape, u
|
|||
}
|
||||
|
||||
struct AreaCMP {
|
||||
Area3DSW *area;
|
||||
int refCount;
|
||||
Area3DSW *area = nullptr;
|
||||
int refCount = 0;
|
||||
_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() {}
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ class Body3DSW : public CollisionObject3DSW {
|
|||
struct Contact {
|
||||
Vector3 local_pos;
|
||||
Vector3 local_normal;
|
||||
real_t depth;
|
||||
int local_shape;
|
||||
real_t depth = 0.0;
|
||||
int local_shape = 0;
|
||||
Vector3 collider_pos;
|
||||
int collider_shape;
|
||||
int collider_shape = 0;
|
||||
ObjectID collider_instance_id;
|
||||
RID collider;
|
||||
Vector3 collider_velocity_at_pos;
|
||||
|
|
|
|||
|
|
@ -41,18 +41,18 @@ protected:
|
|||
struct Contact {
|
||||
Vector3 position;
|
||||
Vector3 normal;
|
||||
int index_A, index_B;
|
||||
int index_A = 0, index_B = 0;
|
||||
Vector3 local_A, local_B;
|
||||
real_t acc_normal_impulse; // accumulated normal impulse (Pn)
|
||||
real_t acc_normal_impulse = 0.0; // accumulated normal impulse (Pn)
|
||||
Vector3 acc_tangent_impulse; // accumulated tangent impulse (Pt)
|
||||
real_t acc_bias_impulse; // accumulated normal impulse for position bias (Pnb)
|
||||
real_t acc_bias_impulse_center_of_mass; // accumulated normal impulse for position bias applied to com
|
||||
real_t mass_normal;
|
||||
real_t bias;
|
||||
real_t bounce;
|
||||
real_t acc_bias_impulse = 0.0; // accumulated normal impulse for position bias (Pnb)
|
||||
real_t acc_bias_impulse_center_of_mass = 0.0; // accumulated normal impulse for position bias applied to com
|
||||
real_t mass_normal = 0.0;
|
||||
real_t bias = 0.0;
|
||||
real_t bounce = 0.0;
|
||||
|
||||
real_t depth;
|
||||
bool active;
|
||||
real_t depth = 0.0;
|
||||
bool active = false;
|
||||
Vector3 rA, rB; // Offset in world orientation with respect to center of mass
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,4 @@ BroadPhase3DSW *BroadPhase3DBVH::_create() {
|
|||
BroadPhase3DBVH::BroadPhase3DBVH() {
|
||||
bvh.set_pair_callback(_pair_callback, this);
|
||||
bvh.set_unpair_callback(_unpair_callback, this);
|
||||
pair_callback = nullptr;
|
||||
pair_userdata = nullptr;
|
||||
unpair_userdata = nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,10 @@ class BroadPhase3DBVH : public BroadPhase3DSW {
|
|||
static void *_pair_callback(void *, uint32_t, CollisionObject3DSW *, int, uint32_t, CollisionObject3DSW *, int);
|
||||
static void _unpair_callback(void *, uint32_t, CollisionObject3DSW *, int, uint32_t, CollisionObject3DSW *, int, void *);
|
||||
|
||||
PairCallback pair_callback;
|
||||
void *pair_userdata;
|
||||
UnpairCallback unpair_callback;
|
||||
void *unpair_userdata;
|
||||
PairCallback pair_callback = nullptr;
|
||||
void *pair_userdata = nullptr;
|
||||
UnpairCallback unpair_callback = nullptr;
|
||||
void *unpair_userdata = nullptr;
|
||||
|
||||
public:
|
||||
// 0 is an invalid ID
|
||||
|
|
|
|||
|
|
@ -236,11 +236,5 @@ void CollisionObject3DSW::_shape_changed() {
|
|||
|
||||
CollisionObject3DSW::CollisionObject3DSW(Type p_type) :
|
||||
pending_shape_update_list(this) {
|
||||
_static = true;
|
||||
type = p_type;
|
||||
space = nullptr;
|
||||
|
||||
collision_layer = 1;
|
||||
collision_mask = 1;
|
||||
ray_pickable = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,26 +56,24 @@ private:
|
|||
Type type;
|
||||
RID self;
|
||||
ObjectID instance_id;
|
||||
uint32_t collision_layer;
|
||||
uint32_t collision_mask;
|
||||
uint32_t collision_layer = 1;
|
||||
uint32_t collision_mask = 1;
|
||||
|
||||
struct Shape {
|
||||
Transform3D xform;
|
||||
Transform3D xform_inv;
|
||||
BroadPhase3DSW::ID bpid;
|
||||
AABB aabb_cache; //for rayqueries
|
||||
real_t area_cache;
|
||||
Shape3DSW *shape;
|
||||
bool disabled;
|
||||
|
||||
Shape() { disabled = false; }
|
||||
real_t area_cache = 0.0;
|
||||
Shape3DSW *shape = nullptr;
|
||||
bool disabled = false;
|
||||
};
|
||||
|
||||
Vector<Shape> shapes;
|
||||
Space3DSW *space;
|
||||
Space3DSW *space = nullptr;
|
||||
Transform3D transform;
|
||||
Transform3D inv_transform;
|
||||
bool _static;
|
||||
bool _static = true;
|
||||
|
||||
SelfList<CollisionObject3DSW> pending_shape_update_list;
|
||||
|
||||
|
|
@ -102,7 +100,7 @@ protected:
|
|||
virtual void _shapes_changed() = 0;
|
||||
void _set_space(Space3DSW *p_space);
|
||||
|
||||
bool ray_pickable;
|
||||
bool ray_pickable = true;
|
||||
|
||||
CollisionObject3DSW(Type p_type);
|
||||
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@
|
|||
|
||||
struct _CollectorCallback {
|
||||
CollisionSolver3DSW::CallbackResult callback;
|
||||
void *userdata;
|
||||
bool swap;
|
||||
bool collided;
|
||||
void *userdata = nullptr;
|
||||
bool swap = false;
|
||||
bool collided = false;
|
||||
Vector3 normal;
|
||||
Vector3 *prev_axis;
|
||||
Vector3 *prev_axis = nullptr;
|
||||
|
||||
_FORCE_INLINE_ void call(const Vector3 &p_point_A, const Vector3 &p_point_B) {
|
||||
if (swap) {
|
||||
|
|
@ -606,15 +606,15 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po
|
|||
|
||||
template <class ShapeA, class ShapeB, bool withMargin = false>
|
||||
class SeparatorAxisTest {
|
||||
const ShapeA *shape_A;
|
||||
const ShapeB *shape_B;
|
||||
const Transform3D *transform_A;
|
||||
const Transform3D *transform_B;
|
||||
real_t best_depth;
|
||||
const ShapeA *shape_A = nullptr;
|
||||
const ShapeB *shape_B = nullptr;
|
||||
const Transform3D *transform_A = nullptr;
|
||||
const Transform3D *transform_B = nullptr;
|
||||
real_t best_depth = 1e15;
|
||||
Vector3 best_axis;
|
||||
_CollectorCallback *callback;
|
||||
real_t margin_A;
|
||||
real_t margin_B;
|
||||
_CollectorCallback *callback = nullptr;
|
||||
real_t margin_A = 0.0;
|
||||
real_t margin_B = 0.0;
|
||||
Vector3 separator_axis;
|
||||
|
||||
public:
|
||||
|
|
@ -749,7 +749,6 @@ public:
|
|||
}
|
||||
|
||||
_FORCE_INLINE_ SeparatorAxisTest(const ShapeA *p_shape_A, const Transform3D &p_transform_A, const ShapeB *p_shape_B, const Transform3D &p_transform_B, _CollectorCallback *p_callback, real_t p_margin_A = 0, real_t p_margin_B = 0) {
|
||||
best_depth = 1e15;
|
||||
shape_A = p_shape_A;
|
||||
shape_B = p_shape_B;
|
||||
transform_A = &p_transform_A;
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ struct sResults {
|
|||
|
||||
Vector3 witnesses[2];
|
||||
Vector3 normal;
|
||||
real_t distance;
|
||||
real_t distance = 0.0;
|
||||
};
|
||||
|
||||
// Shorthands
|
||||
|
|
|
|||
|
|
@ -92,20 +92,8 @@ ConeTwistJoint3DSW::ConeTwistJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Trans
|
|||
m_rbAFrame = rbAFrame;
|
||||
m_rbBFrame = rbBFrame;
|
||||
|
||||
m_swingSpan1 = Math_TAU / 8.0;
|
||||
m_swingSpan2 = Math_TAU / 8.0;
|
||||
m_twistSpan = Math_TAU;
|
||||
m_biasFactor = 0.3f;
|
||||
m_relaxationFactor = 1.0f;
|
||||
|
||||
m_angularOnly = false;
|
||||
m_solveTwistLimit = false;
|
||||
m_solveSwingLimit = false;
|
||||
|
||||
A->add_constraint(this, 0);
|
||||
B->add_constraint(this, 1);
|
||||
|
||||
m_appliedImpulse = 0;
|
||||
}
|
||||
|
||||
bool ConeTwistJoint3DSW::setup(real_t p_timestep) {
|
||||
|
|
|
|||
|
|
@ -67,39 +67,39 @@ public:
|
|||
Body3DSW *B;
|
||||
};
|
||||
|
||||
Body3DSW *_arr[2];
|
||||
Body3DSW *_arr[2] = { nullptr, nullptr };
|
||||
};
|
||||
|
||||
JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints
|
||||
JacobianEntry3DSW m_jac[3] = {}; //3 orthogonal linear constraints
|
||||
|
||||
real_t m_appliedImpulse;
|
||||
real_t m_appliedImpulse = 0.0;
|
||||
Transform3D m_rbAFrame;
|
||||
Transform3D m_rbBFrame;
|
||||
|
||||
real_t m_limitSoftness;
|
||||
real_t m_biasFactor;
|
||||
real_t m_relaxationFactor;
|
||||
real_t m_limitSoftness = 0.0;
|
||||
real_t m_biasFactor = 0.3;
|
||||
real_t m_relaxationFactor = 1.0;
|
||||
|
||||
real_t m_swingSpan1;
|
||||
real_t m_swingSpan2;
|
||||
real_t m_twistSpan;
|
||||
real_t m_swingSpan1 = Math_TAU / 8.0;
|
||||
real_t m_swingSpan2 = 0.0;
|
||||
real_t m_twistSpan = 0.0;
|
||||
|
||||
Vector3 m_swingAxis;
|
||||
Vector3 m_twistAxis;
|
||||
|
||||
real_t m_kSwing;
|
||||
real_t m_kTwist;
|
||||
real_t m_kSwing = 0.0;
|
||||
real_t m_kTwist = 0.0;
|
||||
|
||||
real_t m_twistLimitSign;
|
||||
real_t m_swingCorrection;
|
||||
real_t m_twistCorrection;
|
||||
real_t m_twistLimitSign = 0.0;
|
||||
real_t m_swingCorrection = 0.0;
|
||||
real_t m_twistCorrection = 0.0;
|
||||
|
||||
real_t m_accSwingLimitImpulse;
|
||||
real_t m_accTwistLimitImpulse;
|
||||
real_t m_accSwingLimitImpulse = 0.0;
|
||||
real_t m_accTwistLimitImpulse = 0.0;
|
||||
|
||||
bool m_angularOnly;
|
||||
bool m_solveTwistLimit;
|
||||
bool m_solveSwingLimit;
|
||||
bool m_angularOnly = false;
|
||||
bool m_solveTwistLimit = false;
|
||||
bool m_solveSwingLimit = false;
|
||||
|
||||
public:
|
||||
virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_CONE_TWIST; }
|
||||
|
|
|
|||
|
|
@ -65,43 +65,28 @@ class G6DOFRotationalLimitMotor3DSW {
|
|||
public:
|
||||
//! limit_parameters
|
||||
//!@{
|
||||
real_t m_loLimit; //!< joint limit
|
||||
real_t m_hiLimit; //!< joint limit
|
||||
real_t m_targetVelocity; //!< target motor velocity
|
||||
real_t m_maxMotorForce; //!< max force on motor
|
||||
real_t m_maxLimitForce; //!< max force on limit
|
||||
real_t m_damping; //!< Damping.
|
||||
real_t m_limitSoftness; //! Relaxation factor
|
||||
real_t m_ERP; //!< Error tolerance factor when joint is at limit
|
||||
real_t m_bounce; //!< restitution factor
|
||||
bool m_enableMotor;
|
||||
bool m_enableLimit;
|
||||
real_t m_loLimit = -1e30; //!< joint limit
|
||||
real_t m_hiLimit = 1e30; //!< joint limit
|
||||
real_t m_targetVelocity = 0.0; //!< target motor velocity
|
||||
real_t m_maxMotorForce = 0.1; //!< max force on motor
|
||||
real_t m_maxLimitForce = 300.0; //!< max force on limit
|
||||
real_t m_damping = 1.0; //!< Damping.
|
||||
real_t m_limitSoftness = 0.5; //! Relaxation factor
|
||||
real_t m_ERP = 0.5; //!< Error tolerance factor when joint is at limit
|
||||
real_t m_bounce = 0.0; //!< restitution factor
|
||||
bool m_enableMotor = false;
|
||||
bool m_enableLimit = false;
|
||||
|
||||
//!@}
|
||||
|
||||
//! temp_variables
|
||||
//!@{
|
||||
real_t m_currentLimitError; //!< How much is violated this limit
|
||||
int m_currentLimit; //!< 0=free, 1=at lo limit, 2=at hi limit
|
||||
real_t m_accumulatedImpulse;
|
||||
real_t m_currentLimitError = 0.0; //!< How much is violated this limit
|
||||
int m_currentLimit = 0; //!< 0=free, 1=at lo limit, 2=at hi limit
|
||||
real_t m_accumulatedImpulse = 0.0;
|
||||
//!@}
|
||||
|
||||
G6DOFRotationalLimitMotor3DSW() {
|
||||
m_accumulatedImpulse = 0.f;
|
||||
m_targetVelocity = 0;
|
||||
m_maxMotorForce = 0.1f;
|
||||
m_maxLimitForce = 300.0f;
|
||||
m_loLimit = -1e30;
|
||||
m_hiLimit = 1e30;
|
||||
m_ERP = 0.5f;
|
||||
m_bounce = 0.0f;
|
||||
m_damping = 1.0f;
|
||||
m_limitSoftness = 0.5f;
|
||||
m_currentLimit = 0;
|
||||
m_currentLimitError = 0;
|
||||
m_enableMotor = false;
|
||||
m_enableLimit = false;
|
||||
}
|
||||
G6DOFRotationalLimitMotor3DSW() {}
|
||||
|
||||
//! Is limited
|
||||
bool isLimited() {
|
||||
|
|
@ -125,30 +110,16 @@ public:
|
|||
|
||||
class G6DOFTranslationalLimitMotor3DSW {
|
||||
public:
|
||||
Vector3 m_lowerLimit; //!< the constraint lower limits
|
||||
Vector3 m_upperLimit; //!< the constraint upper limits
|
||||
Vector3 m_accumulatedImpulse;
|
||||
Vector3 m_lowerLimit = Vector3(0.0, 0.0, 0.0); //!< the constraint lower limits
|
||||
Vector3 m_upperLimit = Vector3(0.0, 0.0, 0.0); //!< the constraint upper limits
|
||||
Vector3 m_accumulatedImpulse = Vector3(0.0, 0.0, 0.0);
|
||||
//! Linear_Limit_parameters
|
||||
//!@{
|
||||
Vector3 m_limitSoftness; //!< Softness for linear limit
|
||||
Vector3 m_damping; //!< Damping for linear limit
|
||||
Vector3 m_restitution; //! Bounce parameter for linear limit
|
||||
Vector3 m_limitSoftness = Vector3(0.7, 0.7, 0.7); //!< Softness for linear limit
|
||||
Vector3 m_damping = Vector3(1.0, 1.0, 1.0); //!< Damping for linear limit
|
||||
Vector3 m_restitution = Vector3(0.5, 0.5, 0.5); //! Bounce parameter for linear limit
|
||||
//!@}
|
||||
bool enable_limit[3];
|
||||
|
||||
G6DOFTranslationalLimitMotor3DSW() {
|
||||
m_lowerLimit = Vector3(0.f, 0.f, 0.f);
|
||||
m_upperLimit = Vector3(0.f, 0.f, 0.f);
|
||||
m_accumulatedImpulse = Vector3(0.f, 0.f, 0.f);
|
||||
|
||||
m_limitSoftness = Vector3(1, 1, 1) * 0.7f;
|
||||
m_damping = Vector3(1, 1, 1) * real_t(1.0f);
|
||||
m_restitution = Vector3(1, 1, 1) * real_t(0.5f);
|
||||
|
||||
enable_limit[0] = true;
|
||||
enable_limit[1] = true;
|
||||
enable_limit[2] = true;
|
||||
}
|
||||
bool enable_limit[3] = { true, true, true };
|
||||
|
||||
//! Test limit
|
||||
/*!
|
||||
|
|
@ -180,7 +151,7 @@ protected:
|
|||
Body3DSW *B;
|
||||
};
|
||||
|
||||
Body3DSW *_arr[2];
|
||||
Body3DSW *_arr[2] = { nullptr, nullptr };
|
||||
};
|
||||
|
||||
//! relative_frames
|
||||
|
|
@ -208,7 +179,7 @@ protected:
|
|||
protected:
|
||||
//! temporal variables
|
||||
//!@{
|
||||
real_t m_timeStep;
|
||||
real_t m_timeStep = 0.0;
|
||||
Transform3D m_calculatedTransformA;
|
||||
Transform3D m_calculatedTransformB;
|
||||
Vector3 m_calculatedAxisAngleDiff;
|
||||
|
|
@ -216,7 +187,7 @@ protected:
|
|||
|
||||
Vector3 m_AnchorPos; // point between pivots of bodies A and B to solve linear axes
|
||||
|
||||
bool m_useLinearReferenceFrameA;
|
||||
bool m_useLinearReferenceFrameA = false;
|
||||
|
||||
//!@}
|
||||
|
||||
|
|
|
|||
|
|
@ -79,21 +79,6 @@ HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform3D &
|
|||
m_rbBFrame.basis[1][2] *= real_t(-1.);
|
||||
m_rbBFrame.basis[2][2] *= real_t(-1.);
|
||||
|
||||
//start with free
|
||||
m_lowerLimit = Math_PI;
|
||||
m_upperLimit = -Math_PI;
|
||||
|
||||
m_useLimit = false;
|
||||
m_biasFactor = 0.3f;
|
||||
m_relaxationFactor = 1.0f;
|
||||
m_limitSoftness = 0.9f;
|
||||
m_solveLimit = false;
|
||||
|
||||
tau = 0.3;
|
||||
|
||||
m_angularOnly = false;
|
||||
m_enableAngularMotor = false;
|
||||
|
||||
A->add_constraint(this, 0);
|
||||
B->add_constraint(this, 1);
|
||||
}
|
||||
|
|
@ -135,21 +120,6 @@ HingeJoint3DSW::HingeJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Vector3 &pivo
|
|||
rbAxisB1.y, rbAxisB2.y, -axisInB.y,
|
||||
rbAxisB1.z, rbAxisB2.z, -axisInB.z);
|
||||
|
||||
//start with free
|
||||
m_lowerLimit = Math_PI;
|
||||
m_upperLimit = -Math_PI;
|
||||
|
||||
m_useLimit = false;
|
||||
m_biasFactor = 0.3f;
|
||||
m_relaxationFactor = 1.0f;
|
||||
m_limitSoftness = 0.9f;
|
||||
m_solveLimit = false;
|
||||
|
||||
tau = 0.3;
|
||||
|
||||
m_angularOnly = false;
|
||||
m_enableAngularMotor = false;
|
||||
|
||||
A->add_constraint(this, 0);
|
||||
B->add_constraint(this, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class HingeJoint3DSW : public Joint3DSW {
|
|||
Body3DSW *B;
|
||||
};
|
||||
|
||||
Body3DSW *_arr[2];
|
||||
Body3DSW *_arr[2] = {};
|
||||
};
|
||||
|
||||
JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints
|
||||
|
|
@ -69,31 +69,31 @@ class HingeJoint3DSW : public Joint3DSW {
|
|||
Transform3D m_rbAFrame; // constraint axii. Assumes z is hinge axis.
|
||||
Transform3D m_rbBFrame;
|
||||
|
||||
real_t m_motorTargetVelocity;
|
||||
real_t m_maxMotorImpulse;
|
||||
real_t m_motorTargetVelocity = 0.0;
|
||||
real_t m_maxMotorImpulse = 0.0;
|
||||
|
||||
real_t m_limitSoftness;
|
||||
real_t m_biasFactor;
|
||||
real_t m_relaxationFactor;
|
||||
real_t m_limitSoftness = 0.9;
|
||||
real_t m_biasFactor = 0.3;
|
||||
real_t m_relaxationFactor = 1.0;
|
||||
|
||||
real_t m_lowerLimit;
|
||||
real_t m_upperLimit;
|
||||
real_t m_lowerLimit = Math_PI;
|
||||
real_t m_upperLimit = -Math_PI;
|
||||
|
||||
real_t m_kHinge;
|
||||
real_t m_kHinge = 0.0;
|
||||
|
||||
real_t m_limitSign;
|
||||
real_t m_correction;
|
||||
real_t m_limitSign = 0.0;
|
||||
real_t m_correction = 0.0;
|
||||
|
||||
real_t m_accLimitImpulse;
|
||||
real_t m_accLimitImpulse = 0.0;
|
||||
|
||||
real_t tau;
|
||||
real_t tau = 0.3;
|
||||
|
||||
bool m_useLimit;
|
||||
bool m_angularOnly;
|
||||
bool m_enableAngularMotor;
|
||||
bool m_solveLimit;
|
||||
bool m_useLimit = false;
|
||||
bool m_angularOnly = false;
|
||||
bool m_enableAngularMotor = false;
|
||||
bool m_solveLimit = false;
|
||||
|
||||
real_t m_appliedImpulse;
|
||||
real_t m_appliedImpulse = 0.0;
|
||||
|
||||
public:
|
||||
virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_HINGE; }
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ public:
|
|||
Vector3 m_0MinvJt;
|
||||
Vector3 m_1MinvJt;
|
||||
//Optimization: can be stored in the w/last component of one of the vectors
|
||||
real_t m_Adiag;
|
||||
real_t m_Adiag = 1.0;
|
||||
};
|
||||
|
||||
#endif // JACOBIAN_ENTRY_SW_H
|
||||
|
|
|
|||
|
|
@ -171,11 +171,6 @@ PinJoint3DSW::PinJoint3DSW(Body3DSW *p_body_a, const Vector3 &p_pos_a, Body3DSW
|
|||
m_pivotInA = p_pos_a;
|
||||
m_pivotInB = p_pos_b;
|
||||
|
||||
m_tau = 0.3;
|
||||
m_damping = 1;
|
||||
m_impulseClamp = 0;
|
||||
m_appliedImpulse = 0;
|
||||
|
||||
A->add_constraint(this, 0);
|
||||
B->add_constraint(this, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,15 +60,15 @@ class PinJoint3DSW : public Joint3DSW {
|
|||
Body3DSW *B;
|
||||
};
|
||||
|
||||
Body3DSW *_arr[2];
|
||||
Body3DSW *_arr[2] = {};
|
||||
};
|
||||
|
||||
real_t m_tau; //bias
|
||||
real_t m_damping;
|
||||
real_t m_impulseClamp;
|
||||
real_t m_appliedImpulse;
|
||||
real_t m_tau = 0.3; //bias
|
||||
real_t m_damping = 1.0;
|
||||
real_t m_impulseClamp = 0.0;
|
||||
real_t m_appliedImpulse = 0.0;
|
||||
|
||||
JacobianEntry3DSW m_jac[3]; //3 orthogonal linear constraints
|
||||
JacobianEntry3DSW m_jac[3] = {}; //3 orthogonal linear constraints
|
||||
|
||||
Vector3 m_pivotInA;
|
||||
Vector3 m_pivotInB;
|
||||
|
|
|
|||
|
|
@ -72,41 +72,6 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
|
|||
return (y < 0.0f) ? -angle : angle;
|
||||
}
|
||||
|
||||
void SliderJoint3DSW::initParams() {
|
||||
m_lowerLinLimit = real_t(1.0);
|
||||
m_upperLinLimit = real_t(-1.0);
|
||||
m_lowerAngLimit = real_t(0.);
|
||||
m_upperAngLimit = real_t(0.);
|
||||
m_softnessDirLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
m_restitutionDirLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
m_dampingDirLin = real_t(0.);
|
||||
m_softnessDirAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
m_restitutionDirAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
m_dampingDirAng = real_t(0.);
|
||||
m_softnessOrthoLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
m_restitutionOrthoLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
m_dampingOrthoLin = SLIDER_CONSTRAINT_DEF_DAMPING;
|
||||
m_softnessOrthoAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
m_restitutionOrthoAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
m_dampingOrthoAng = SLIDER_CONSTRAINT_DEF_DAMPING;
|
||||
m_softnessLimLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
m_restitutionLimLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
m_dampingLimLin = SLIDER_CONSTRAINT_DEF_DAMPING;
|
||||
m_softnessLimAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
m_restitutionLimAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
m_dampingLimAng = SLIDER_CONSTRAINT_DEF_DAMPING;
|
||||
|
||||
m_poweredLinMotor = false;
|
||||
m_targetLinMotorVelocity = real_t(0.);
|
||||
m_maxLinMotorForce = real_t(0.);
|
||||
m_accumulatedLinMotorImpulse = real_t(0.0);
|
||||
|
||||
m_poweredAngMotor = false;
|
||||
m_targetAngMotorVelocity = real_t(0.);
|
||||
m_maxAngMotorForce = real_t(0.);
|
||||
m_accumulatedAngMotorImpulse = real_t(0.0);
|
||||
} // SliderJointSW::initParams()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -120,8 +85,6 @@ SliderJoint3DSW::SliderJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform3D
|
|||
|
||||
A->add_constraint(this, 0);
|
||||
B->add_constraint(this, 1);
|
||||
|
||||
initParams();
|
||||
} // SliderJointSW::SliderJointSW()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -73,53 +73,53 @@ protected:
|
|||
Body3DSW *B;
|
||||
};
|
||||
|
||||
Body3DSW *_arr[2];
|
||||
Body3DSW *_arr[2] = { nullptr, nullptr };
|
||||
};
|
||||
|
||||
Transform3D m_frameInA;
|
||||
Transform3D m_frameInB;
|
||||
|
||||
// linear limits
|
||||
real_t m_lowerLinLimit;
|
||||
real_t m_upperLinLimit;
|
||||
real_t m_lowerLinLimit = 1.0;
|
||||
real_t m_upperLinLimit = -1.0;
|
||||
// angular limits
|
||||
real_t m_lowerAngLimit;
|
||||
real_t m_upperAngLimit;
|
||||
real_t m_lowerAngLimit = 0.0;
|
||||
real_t m_upperAngLimit = 0.0;
|
||||
// softness, restitution and damping for different cases
|
||||
// DirLin - moving inside linear limits
|
||||
// LimLin - hitting linear limit
|
||||
// DirAng - moving inside angular limits
|
||||
// LimAng - hitting angular limit
|
||||
// OrthoLin, OrthoAng - against constraint axis
|
||||
real_t m_softnessDirLin;
|
||||
real_t m_restitutionDirLin;
|
||||
real_t m_dampingDirLin;
|
||||
real_t m_softnessDirAng;
|
||||
real_t m_restitutionDirAng;
|
||||
real_t m_dampingDirAng;
|
||||
real_t m_softnessLimLin;
|
||||
real_t m_restitutionLimLin;
|
||||
real_t m_dampingLimLin;
|
||||
real_t m_softnessLimAng;
|
||||
real_t m_restitutionLimAng;
|
||||
real_t m_dampingLimAng;
|
||||
real_t m_softnessOrthoLin;
|
||||
real_t m_restitutionOrthoLin;
|
||||
real_t m_dampingOrthoLin;
|
||||
real_t m_softnessOrthoAng;
|
||||
real_t m_restitutionOrthoAng;
|
||||
real_t m_dampingOrthoAng;
|
||||
real_t m_softnessDirLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
real_t m_restitutionDirLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
real_t m_dampingDirLin = 0.0;
|
||||
real_t m_softnessDirAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
real_t m_restitutionDirAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
real_t m_dampingDirAng = 0.0;
|
||||
real_t m_softnessLimLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
real_t m_restitutionLimLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
real_t m_dampingLimLin = SLIDER_CONSTRAINT_DEF_DAMPING;
|
||||
real_t m_softnessLimAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
real_t m_restitutionLimAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
real_t m_dampingLimAng = SLIDER_CONSTRAINT_DEF_DAMPING;
|
||||
real_t m_softnessOrthoLin = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
real_t m_restitutionOrthoLin = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
real_t m_dampingOrthoLin = SLIDER_CONSTRAINT_DEF_DAMPING;
|
||||
real_t m_softnessOrthoAng = SLIDER_CONSTRAINT_DEF_SOFTNESS;
|
||||
real_t m_restitutionOrthoAng = SLIDER_CONSTRAINT_DEF_RESTITUTION;
|
||||
real_t m_dampingOrthoAng = SLIDER_CONSTRAINT_DEF_DAMPING;
|
||||
|
||||
// for interlal use
|
||||
bool m_solveLinLim;
|
||||
bool m_solveAngLim;
|
||||
bool m_solveLinLim = false;
|
||||
bool m_solveAngLim = false;
|
||||
|
||||
JacobianEntry3DSW m_jacLin[3];
|
||||
real_t m_jacLinDiagABInv[3];
|
||||
JacobianEntry3DSW m_jacLin[3] = {};
|
||||
real_t m_jacLinDiagABInv[3] = {};
|
||||
|
||||
JacobianEntry3DSW m_jacAng[3];
|
||||
JacobianEntry3DSW m_jacAng[3] = {};
|
||||
|
||||
real_t m_timeStep;
|
||||
real_t m_timeStep = 0.0;
|
||||
Transform3D m_calculatedTransformA;
|
||||
Transform3D m_calculatedTransformB;
|
||||
|
||||
|
|
@ -132,23 +132,20 @@ protected:
|
|||
Vector3 m_relPosA;
|
||||
Vector3 m_relPosB;
|
||||
|
||||
real_t m_linPos;
|
||||
real_t m_linPos = 0.0;
|
||||
|
||||
real_t m_angDepth;
|
||||
real_t m_kAngle;
|
||||
real_t m_angDepth = 0.0;
|
||||
real_t m_kAngle = 0.0;
|
||||
|
||||
bool m_poweredLinMotor;
|
||||
real_t m_targetLinMotorVelocity;
|
||||
real_t m_maxLinMotorForce;
|
||||
real_t m_accumulatedLinMotorImpulse;
|
||||
bool m_poweredLinMotor = false;
|
||||
real_t m_targetLinMotorVelocity = 0.0;
|
||||
real_t m_maxLinMotorForce = 0.0;
|
||||
real_t m_accumulatedLinMotorImpulse = 0.0;
|
||||
|
||||
bool m_poweredAngMotor;
|
||||
real_t m_targetAngMotorVelocity;
|
||||
real_t m_maxAngMotorForce;
|
||||
real_t m_accumulatedAngMotorImpulse;
|
||||
|
||||
//------------------------
|
||||
void initParams();
|
||||
bool m_poweredAngMotor = false;
|
||||
real_t m_targetAngMotorVelocity = 0.0;
|
||||
real_t m_maxAngMotorForce = 0.0;
|
||||
real_t m_accumulatedAngMotorImpulse = 0.0;
|
||||
|
||||
public:
|
||||
// constructors
|
||||
|
|
|
|||
|
|
@ -1744,11 +1744,5 @@ PhysicsServer3DSW::PhysicsServer3DSW(bool p_using_threads) {
|
|||
singletonsw = this;
|
||||
BroadPhase3DSW::create_func = BroadPhase3DBVH::_create;
|
||||
|
||||
island_count = 0;
|
||||
active_objects = 0;
|
||||
collision_pairs = 0;
|
||||
using_threads = p_using_threads;
|
||||
active = true;
|
||||
flushing_queries = false;
|
||||
doing_sync = false;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -42,18 +42,18 @@ class PhysicsServer3DSW : public PhysicsServer3D {
|
|||
GDCLASS(PhysicsServer3DSW, PhysicsServer3D);
|
||||
|
||||
friend class PhysicsDirectSpaceState3DSW;
|
||||
bool active;
|
||||
int iterations;
|
||||
bool active = true;
|
||||
int iterations = 0;
|
||||
|
||||
int island_count;
|
||||
int active_objects;
|
||||
int collision_pairs;
|
||||
int island_count = 0;
|
||||
int active_objects = 0;
|
||||
int collision_pairs = 0;
|
||||
|
||||
bool using_threads;
|
||||
bool doing_sync;
|
||||
bool flushing_queries;
|
||||
bool using_threads = false;
|
||||
bool doing_sync = false;
|
||||
bool flushing_queries = false;
|
||||
|
||||
Step3DSW *stepper;
|
||||
Step3DSW *stepper = nullptr;
|
||||
Set<const Space3DSW *> active_spaces;
|
||||
|
||||
mutable RID_PtrOwner<Shape3DSW, true> shape_owner;
|
||||
|
|
|
|||
|
|
@ -119,8 +119,6 @@ PhysicsServer3DWrapMT::PhysicsServer3DWrapMT(PhysicsServer3D *p_contained, bool
|
|||
command_queue(p_create_thread) {
|
||||
physics_3d_server = p_contained;
|
||||
create_thread = p_create_thread;
|
||||
step_pending = 0;
|
||||
step_thread_up = false;
|
||||
|
||||
pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
|
||||
|
||||
|
|
@ -131,7 +129,6 @@ PhysicsServer3DWrapMT::PhysicsServer3DWrapMT(PhysicsServer3D *p_contained, bool
|
|||
}
|
||||
|
||||
main_thread = Thread::get_caller_id();
|
||||
first_frame = true;
|
||||
}
|
||||
|
||||
PhysicsServer3DWrapMT::~PhysicsServer3DWrapMT() {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class PhysicsServer3DWrapMT : public PhysicsServer3D {
|
|||
bool create_thread = false;
|
||||
|
||||
Semaphore step_sem;
|
||||
int step_pending;
|
||||
int step_pending = 0;
|
||||
void thread_step(real_t p_delta);
|
||||
void thread_flush();
|
||||
|
||||
|
|
|
|||
|
|
@ -101,11 +101,6 @@ const Map<ShapeOwner3DSW *, int> &Shape3DSW::get_owners() const {
|
|||
return owners;
|
||||
}
|
||||
|
||||
Shape3DSW::Shape3DSW() {
|
||||
custom_bias = 0;
|
||||
configured = false;
|
||||
}
|
||||
|
||||
Shape3DSW::~Shape3DSW() {
|
||||
ERR_FAIL_COND(owners.size());
|
||||
}
|
||||
|
|
@ -244,10 +239,7 @@ Variant SeparationRayShape3DSW::get_data() const {
|
|||
return d;
|
||||
}
|
||||
|
||||
SeparationRayShape3DSW::SeparationRayShape3DSW() {
|
||||
length = 1;
|
||||
slide_on_slope = false;
|
||||
}
|
||||
SeparationRayShape3DSW::SeparationRayShape3DSW() {}
|
||||
|
||||
/********** SPHERE *************/
|
||||
|
||||
|
|
@ -311,9 +303,7 @@ Variant SphereShape3DSW::get_data() const {
|
|||
return radius;
|
||||
}
|
||||
|
||||
SphereShape3DSW::SphereShape3DSW() {
|
||||
radius = 0;
|
||||
}
|
||||
SphereShape3DSW::SphereShape3DSW() {}
|
||||
|
||||
/********** BOX *************/
|
||||
|
||||
|
|
@ -502,8 +492,7 @@ Variant BoxShape3DSW::get_data() const {
|
|||
return half_extents;
|
||||
}
|
||||
|
||||
BoxShape3DSW::BoxShape3DSW() {
|
||||
}
|
||||
BoxShape3DSW::BoxShape3DSW() {}
|
||||
|
||||
/********** CAPSULE *************/
|
||||
|
||||
|
|
@ -668,9 +657,7 @@ Variant CapsuleShape3DSW::get_data() const {
|
|||
return d;
|
||||
}
|
||||
|
||||
CapsuleShape3DSW::CapsuleShape3DSW() {
|
||||
height = radius = 0;
|
||||
}
|
||||
CapsuleShape3DSW::CapsuleShape3DSW() {}
|
||||
|
||||
/********** CYLINDER *************/
|
||||
|
||||
|
|
@ -848,9 +835,7 @@ Variant CylinderShape3DSW::get_data() const {
|
|||
return d;
|
||||
}
|
||||
|
||||
CylinderShape3DSW::CylinderShape3DSW() {
|
||||
height = radius = 0;
|
||||
}
|
||||
CylinderShape3DSW::CylinderShape3DSW() {}
|
||||
|
||||
/********** CONVEX POLYGON *************/
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ public:
|
|||
class Shape3DSW {
|
||||
RID self;
|
||||
AABB aabb;
|
||||
bool configured;
|
||||
real_t custom_bias;
|
||||
bool configured = false;
|
||||
real_t custom_bias = 0.0;
|
||||
|
||||
Map<ShapeOwner3DSW *, int> owners;
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ public:
|
|||
bool is_owner(ShapeOwner3DSW *p_owner) const;
|
||||
const Map<ShapeOwner3DSW *, int> &get_owners() const;
|
||||
|
||||
Shape3DSW();
|
||||
Shape3DSW() {}
|
||||
virtual ~Shape3DSW();
|
||||
};
|
||||
|
||||
|
|
@ -138,8 +138,8 @@ public:
|
|||
};
|
||||
|
||||
class SeparationRayShape3DSW : public Shape3DSW {
|
||||
real_t length;
|
||||
bool slide_on_slope;
|
||||
real_t length = 1.0;
|
||||
bool slide_on_slope = false;
|
||||
|
||||
void _setup(real_t p_length, bool p_slide_on_slope);
|
||||
|
||||
|
|
@ -166,7 +166,7 @@ public:
|
|||
};
|
||||
|
||||
class SphereShape3DSW : public Shape3DSW {
|
||||
real_t radius;
|
||||
real_t radius = 0.0;
|
||||
|
||||
void _setup(real_t p_radius);
|
||||
|
||||
|
|
@ -218,8 +218,8 @@ public:
|
|||
};
|
||||
|
||||
class CapsuleShape3DSW : public Shape3DSW {
|
||||
real_t height;
|
||||
real_t radius;
|
||||
real_t height = 0.0;
|
||||
real_t radius = 0.0;
|
||||
|
||||
void _setup(real_t p_height, real_t p_radius);
|
||||
|
||||
|
|
@ -247,8 +247,8 @@ public:
|
|||
};
|
||||
|
||||
class CylinderShape3DSW : public Shape3DSW {
|
||||
real_t height;
|
||||
real_t radius;
|
||||
real_t height = 0.0;
|
||||
real_t radius = 0.0;
|
||||
|
||||
void _setup(real_t p_height, real_t p_radius);
|
||||
|
||||
|
|
@ -308,7 +308,7 @@ struct ConcavePolygonShape3DSW : public ConcaveShape3DSW {
|
|||
|
||||
struct Face {
|
||||
Vector3 normal;
|
||||
int indices[3];
|
||||
int indices[3] = {};
|
||||
};
|
||||
|
||||
Vector<Face> faces;
|
||||
|
|
@ -316,10 +316,10 @@ struct ConcavePolygonShape3DSW : public ConcaveShape3DSW {
|
|||
|
||||
struct BVH {
|
||||
AABB aabb;
|
||||
int left;
|
||||
int right;
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
|
||||
int face_index;
|
||||
int face_index = 0;
|
||||
};
|
||||
|
||||
Vector<BVH> bvh;
|
||||
|
|
@ -469,7 +469,7 @@ struct FaceShape3DSW : public Shape3DSW {
|
|||
};
|
||||
|
||||
struct MotionShape3DSW : public Shape3DSW {
|
||||
Shape3DSW *shape;
|
||||
Shape3DSW *shape = nullptr;
|
||||
Vector3 motion;
|
||||
|
||||
virtual PhysicsServer3D::ShapeType get_type() const override { return PhysicsServer3D::SHAPE_CONVEX_POLYGON; }
|
||||
|
|
|
|||
|
|
@ -1142,18 +1142,6 @@ PhysicsDirectSpaceState3DSW *Space3DSW::get_direct_state() {
|
|||
}
|
||||
|
||||
Space3DSW::Space3DSW() {
|
||||
collision_pairs = 0;
|
||||
active_objects = 0;
|
||||
island_count = 0;
|
||||
contact_debug_count = 0;
|
||||
|
||||
locked = false;
|
||||
contact_recycle_radius = 0.01;
|
||||
contact_max_separation = 0.05;
|
||||
contact_max_allowed_penetration = 0.01;
|
||||
test_motion_min_contact_depth = 0.00001;
|
||||
|
||||
constraint_bias = 0.01;
|
||||
body_linear_velocity_sleep_threshold = GLOBAL_DEF("physics/3d/sleep_threshold_linear", 0.1);
|
||||
body_angular_velocity_sleep_threshold = GLOBAL_DEF("physics/3d/sleep_threshold_angular", Math::deg2rad(8.0));
|
||||
body_time_to_sleep = GLOBAL_DEF("physics/3d/time_before_sleep", 0.5);
|
||||
|
|
@ -1163,14 +1151,9 @@ Space3DSW::Space3DSW() {
|
|||
broadphase = BroadPhase3DSW::create_func();
|
||||
broadphase->set_pair_callback(_broadphase_pair, this);
|
||||
broadphase->set_unpair_callback(_broadphase_unpair, this);
|
||||
area = nullptr;
|
||||
|
||||
direct_access = memnew(PhysicsDirectSpaceState3DSW);
|
||||
direct_access->space = this;
|
||||
|
||||
for (int i = 0; i < ELAPSED_TIME_MAX; i++) {
|
||||
elapsed_time[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Space3DSW::~Space3DSW() {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
uint64_t elapsed_time[ELAPSED_TIME_MAX];
|
||||
uint64_t elapsed_time[ELAPSED_TIME_MAX] = {};
|
||||
|
||||
PhysicsDirectSpaceState3DSW *direct_access;
|
||||
RID self;
|
||||
|
|
@ -90,13 +90,13 @@ private:
|
|||
|
||||
Set<CollisionObject3DSW *> objects;
|
||||
|
||||
Area3DSW *area;
|
||||
Area3DSW *area = nullptr;
|
||||
|
||||
real_t contact_recycle_radius;
|
||||
real_t contact_max_separation;
|
||||
real_t contact_max_allowed_penetration;
|
||||
real_t constraint_bias;
|
||||
real_t test_motion_min_contact_depth;
|
||||
real_t contact_recycle_radius = 0.01;
|
||||
real_t contact_max_separation = 0.05;
|
||||
real_t contact_max_allowed_penetration = 0.01;
|
||||
real_t constraint_bias = 0.01;
|
||||
real_t test_motion_min_contact_depth = 0.00001;
|
||||
|
||||
enum {
|
||||
INTERSECTION_QUERY_MAX = 2048
|
||||
|
|
@ -110,18 +110,18 @@ private:
|
|||
real_t body_time_to_sleep;
|
||||
real_t body_angular_velocity_damp_ratio;
|
||||
|
||||
bool locked;
|
||||
bool locked = false;
|
||||
|
||||
real_t last_step = 0.001;
|
||||
|
||||
int island_count;
|
||||
int active_objects;
|
||||
int collision_pairs;
|
||||
int island_count = 0;
|
||||
int active_objects = 0;
|
||||
int collision_pairs = 0;
|
||||
|
||||
RID static_global_body;
|
||||
|
||||
Vector<Vector3> contact_debug;
|
||||
int contact_debug_count;
|
||||
int contact_debug_count = 0;
|
||||
|
||||
friend class PhysicsDirectSpaceState3DSW;
|
||||
|
||||
|
|
|
|||
|
|
@ -407,8 +407,6 @@ void Step3DSW::step(Space3DSW *p_space, real_t p_delta, int p_iterations) {
|
|||
}
|
||||
|
||||
Step3DSW::Step3DSW() {
|
||||
_step = 1;
|
||||
|
||||
body_islands.reserve(BODY_ISLAND_COUNT_RESERVE);
|
||||
constraint_islands.reserve(ISLAND_COUNT_RESERVE);
|
||||
all_constraints.reserve(CONSTRAINT_COUNT_RESERVE);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
#include "core/templates/thread_work_pool.h"
|
||||
|
||||
class Step3DSW {
|
||||
uint64_t _step;
|
||||
uint64_t _step = 1;
|
||||
|
||||
int iterations = 0;
|
||||
real_t delta = 0.0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue