|
@@ -265,13 +265,13 @@ RigidBodyBullet::RigidBodyBullet() :
|
|
|
angularDamp(0),
|
|
|
can_sleep(true),
|
|
|
omit_forces_integration(false),
|
|
|
+ can_integrate_forces(false),
|
|
|
maxCollisionsDetection(0),
|
|
|
collisionsCount(0),
|
|
|
maxAreasWhereIam(10),
|
|
|
areaWhereIamCount(0),
|
|
|
countGravityPointSpaces(0),
|
|
|
isScratchedSpaceOverrideModificator(false),
|
|
|
- isTransformChanged(false),
|
|
|
previousActiveState(true),
|
|
|
force_integration_callback(NULL) {
|
|
|
|
|
@@ -332,7 +332,7 @@ void RigidBodyBullet::reload_body() {
|
|
|
void RigidBodyBullet::set_space(SpaceBullet *p_space) {
|
|
|
// Clear the old space if there is one
|
|
|
if (space) {
|
|
|
- isTransformChanged = false;
|
|
|
+ can_integrate_forces = false;
|
|
|
|
|
|
// Remove all eventual constraints
|
|
|
assert_no_constraints();
|
|
@@ -349,8 +349,8 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) {
|
|
|
}
|
|
|
|
|
|
void RigidBodyBullet::dispatch_callbacks() {
|
|
|
- /// The check isTransformChanged is necessary in order to call integrated forces only when the first transform is sent
|
|
|
- if ((btBody->isKinematicObject() || btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && isTransformChanged) {
|
|
|
+ /// The check isFirstTransformChanged is necessary in order to call integrated forces only when the first transform is sent
|
|
|
+ if ((btBody->isKinematicObject() || btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && can_integrate_forces) {
|
|
|
|
|
|
if (omit_forces_integration)
|
|
|
btBody->clearForces();
|
|
@@ -399,10 +399,6 @@ void RigidBodyBullet::set_force_integration_callback(ObjectID p_id, const String
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void RigidBodyBullet::scratch() {
|
|
|
- isTransformChanged = true;
|
|
|
-}
|
|
|
-
|
|
|
void RigidBodyBullet::scratch_space_override_modificator() {
|
|
|
isScratchedSpaceOverrideModificator = true;
|
|
|
}
|
|
@@ -417,6 +413,11 @@ void RigidBodyBullet::on_collision_checker_start() {
|
|
|
collisionsCount = 0;
|
|
|
}
|
|
|
|
|
|
+void RigidBodyBullet::on_collision_checker_end() {
|
|
|
+ // Always true if active and not a static or kinematic body
|
|
|
+ isTransformChanged = btBody->isActive() && !btBody->isStaticOrKinematicObject();
|
|
|
+}
|
|
|
+
|
|
|
bool RigidBodyBullet::add_collision_object(RigidBodyBullet *p_otherObject, const Vector3 &p_hitWorldLocation, const Vector3 &p_hitLocalLocation, const Vector3 &p_hitNormal, const float &p_appliedImpulse, int p_other_shape_index, int p_local_shape_index) {
|
|
|
|
|
|
if (collisionsCount >= maxCollisionsDetection) {
|
|
@@ -519,7 +520,7 @@ real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const {
|
|
|
|
|
|
void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) {
|
|
|
// This is necessary to block force_integration untile next move
|
|
|
- isTransformChanged = false;
|
|
|
+ can_integrate_forces = false;
|
|
|
destroy_kinematic_utilities();
|
|
|
// The mode change is relevant to its mass
|
|
|
switch (p_mode) {
|
|
@@ -776,8 +777,7 @@ void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transfor
|
|
|
// The kinematic use MotionState class
|
|
|
godotMotionState->moveBody(p_global_transform);
|
|
|
}
|
|
|
- btBody->setWorldTransform(p_global_transform);
|
|
|
- scratch();
|
|
|
+ CollisionObjectBullet::set_transform__bullet(p_global_transform);
|
|
|
}
|
|
|
|
|
|
const btTransform &RigidBodyBullet::get_transform__bullet() const {
|
|
@@ -986,6 +986,11 @@ void RigidBodyBullet::reload_kinematic_shapes() {
|
|
|
kinematic_utilities->copyAllOwnerShapes();
|
|
|
}
|
|
|
|
|
|
+void RigidBodyBullet::notify_transform_changed() {
|
|
|
+ RigidCollisionObjectBullet::notify_transform_changed();
|
|
|
+ can_integrate_forces = true;
|
|
|
+}
|
|
|
+
|
|
|
void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
|
|
|
|
|
|
btVector3 localInertia(0, 0, 0);
|