Added function to control 6DOF precision
This commit is contained in:
parent
631cf676c3
commit
a395d809a5
8 changed files with 58 additions and 1 deletions
|
|
@ -1471,6 +1471,22 @@ bool BulletPhysicsServer::generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis
|
|||
return generic_6dof_joint->get_flag(p_axis, p_flag);
|
||||
}
|
||||
|
||||
void BulletPhysicsServer::generic_6dof_joint_set_precision(RID p_joint, int p_precision) {
|
||||
JointBullet *joint = joint_owner.get(p_joint);
|
||||
ERR_FAIL_COND(!joint);
|
||||
ERR_FAIL_COND(joint->get_type() != JOINT_6DOF);
|
||||
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
|
||||
generic_6dof_joint->set_precision(p_precision);
|
||||
}
|
||||
|
||||
int BulletPhysicsServer::generic_6dof_joint_get_precision(RID p_joint) {
|
||||
JointBullet *joint = joint_owner.get(p_joint);
|
||||
ERR_FAIL_COND_V(!joint, 0);
|
||||
ERR_FAIL_COND_V(joint->get_type() != JOINT_6DOF, 0);
|
||||
Generic6DOFJointBullet *generic_6dof_joint = static_cast<Generic6DOFJointBullet *>(joint);
|
||||
return generic_6dof_joint->get_precision();
|
||||
}
|
||||
|
||||
void BulletPhysicsServer::free(RID p_rid) {
|
||||
if (shape_owner.owns(p_rid)) {
|
||||
|
||||
|
|
|
|||
|
|
@ -375,6 +375,9 @@ public:
|
|||
virtual void generic_6dof_joint_set_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag, bool p_enable);
|
||||
virtual bool generic_6dof_joint_get_flag(RID p_joint, Vector3::Axis p_axis, G6DOFJointAxisFlag p_flag);
|
||||
|
||||
virtual void generic_6dof_joint_set_precision(RID p_joint, int precision);
|
||||
virtual int generic_6dof_joint_get_precision(RID p_joint);
|
||||
|
||||
/* MISC */
|
||||
|
||||
virtual void free(RID p_rid);
|
||||
|
|
|
|||
|
|
@ -265,3 +265,11 @@ bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOF
|
|||
ERR_FAIL_INDEX_V(p_axis, 3, false);
|
||||
return flags[p_axis][p_flag];
|
||||
}
|
||||
|
||||
void Generic6DOFJointBullet::set_precision(int p_precision) {
|
||||
sixDOFConstraint->setOverrideNumSolverIterations(MAX(1, p_precision));
|
||||
}
|
||||
|
||||
int Generic6DOFJointBullet::get_precision() const {
|
||||
return sixDOFConstraint->getOverrideNumSolverIterations();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ public:
|
|||
|
||||
void set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value);
|
||||
bool get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const;
|
||||
|
||||
void set_precision(int p_precision);
|
||||
int get_precision() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue