Skip to content

Commit 30ef348

Browse files
authored
Merge pull request #1610 from Azaezel/alpha41/physicsFindings
physics findings
2 parents 50ee960 + 4c083d7 commit 30ef348

File tree

6 files changed

+15
-14
lines changed

6 files changed

+15
-14
lines changed

Engine/source/T3D/item.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,9 @@ void Item::updateWorkingCollisionSet(const U32 mask, const F32 dt)
658658
{
659659
// It is assumed that we will never accelerate more than 10 m/s for gravity...
660660
//
661-
Point3F scaledVelocity = mVelocity * dt;
661+
Point3F scaledVelocity = mVelocity * dt * TickSec;
662662
F32 len = scaledVelocity.len();
663-
F32 newLen = len + (10 * dt);
663+
F32 newLen = len + (mDataBlock->getShape()->mRadius * dt * TickSec);
664664

665665
// Check to see if it is actually necessary to construct the new working list,
666666
// or if we can use the cached version from the last query. We use the x

Engine/source/T3D/player.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6097,7 +6097,7 @@ void Player::updateWorkingCollisionSet()
60976097
// box by the possible movement in that tick.
60986098
Point3F scaledVelocity = mVelocity * TickSec;
60996099
F32 len = scaledVelocity.len();
6100-
F32 newLen = len + (10.0f * TickSec);
6100+
F32 newLen = len + (mDataBlock->getShape()->mRadius * TickSec);
61016101

61026102
// Check to see if it is actually necessary to construct the new working list,
61036103
// or if we can use the cached version from the last query. We use the x

Engine/source/T3D/rigid.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ Rigid::Rigid()
4747
friction = 0.5f;
4848
atRest = false;
4949

50-
sleepLinearThreshold = 0.0004f;
51-
sleepAngThreshold = 0.0004f;
50+
sleepLinearThreshold = POINT_EPSILON;
51+
sleepAngThreshold = POINT_EPSILON;
5252
sleepTimeThreshold = 0.75f;
5353
sleepTimer = 0.0f;
5454
}
@@ -71,7 +71,7 @@ void Rigid::integrate(F32 delta)
7171
linVelocity = linMomentum * oneOverMass;
7272

7373
// 2. advance orientation if ang vel significant
74-
F32 angle = angVelocity.len();
74+
F32 angle = angVelocity.len()*delta;
7575
if (mFabs(angle)> POINT_EPSILON)
7676
{
7777
QuatF dq;
@@ -101,7 +101,7 @@ void Rigid::integrate(F32 delta)
101101
}
102102

103103
// 5. refresh ang velocity
104-
updateAngularVelocity();
104+
updateAngularVelocity(delta);
105105

106106

107107
// 6. CoM update
@@ -138,7 +138,7 @@ void Rigid::updateCenterOfMass()
138138

139139
void Rigid::applyImpulse(const Point3F &r, const Point3F &impulse)
140140
{
141-
if (impulse.lenSquared() < mass) return;
141+
if ((impulse.lenSquared() - mass) < POINT_EPSILON) return;
142142
wake();
143143

144144
// Linear momentum and velocity
@@ -304,7 +304,8 @@ void Rigid::trySleep(F32 dt)
304304
// If there is active force/torque, don’t sleep
305305
if (!force.isZero() || !torque.isZero())
306306
{
307-
sleepTimer = 0.0f; return;
307+
sleepTimer = 0.0f;
308+
return;
308309
}
309310

310311
const F32 linV2 = linVelocity.lenSquared();

Engine/source/T3D/rigid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Rigid
105105
//
106106
void setSleepThresholds(F32 linVel2, F32 angVel2, F32 timeToSleep);
107107
void wake();
108-
TORQUE_FORCEINLINE void updateAngularVelocity() { invWorldInertia.mulV(angMomentum, &angVelocity); }
108+
TORQUE_FORCEINLINE void updateAngularVelocity(F32 delta) { Point3F deltaVel = angVelocity * delta; invWorldInertia.mulV(angMomentum, &deltaVel); }
109109
};
110110

111111

Engine/source/T3D/rigidShape.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ void RigidShape::updatePos(F32 dt)
11381138

11391139
// Update collision information based on our current pos.
11401140
bool collided = false;
1141-
if (!mDisableMove)
1141+
if (!mRigid.atRest && !mDisableMove)
11421142
{
11431143
collided = updateCollision(dt);
11441144

@@ -1151,7 +1151,7 @@ void RigidShape::updatePos(F32 dt)
11511151
{
11521152
F32 k = mRigid.getKineticEnergy();
11531153
F32 G = mNetGravity* dt * TickMs / mDataBlock->integration;
1154-
F32 Kg = mRigid.mass * G * G;
1154+
F32 Kg = mRigid.mass * G * G * TickSec;
11551155
if (k < sRestTol * Kg && ++restCount > sRestCount)
11561156
mRigid.setAtRest();
11571157
}
@@ -1447,7 +1447,7 @@ void RigidShape::updateWorkingCollisionSet(const U32 mask)
14471447
// working list is updated on a Tick basis, which means we only expand our box by
14481448
// the possible movement in that tick, plus some extra for caching purposes
14491449
Box3F convexBox = mConvex.getBoundingBox(getTransform(), getScale());
1450-
F32 len = (mRigid.linVelocity.len() + 50) * TickSec;
1450+
F32 len = (mRigid.linVelocity.len() + mDataBlock->getShape()->mRadius) * TickSec;
14511451
F32 l = (len * 1.1) + 0.1; // fudge factor
14521452
convexBox.minExtents -= Point3F(l, l, l);
14531453
convexBox.maxExtents += Point3F(l, l, l);

Engine/source/T3D/vehicles/vehicle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ void Vehicle::updatePos(F32 dt)
827827
{
828828
F32 k = mRigid.getKineticEnergy();
829829
F32 G = mNetGravity* dt * TickMs / mDataBlock->integration;
830-
F32 Kg = 0.5 * mRigid.mass * G * G;
830+
F32 Kg = mRigid.mass * G * G * TickSec;
831831
if (k < sRestTol * Kg && ++restCount > sRestCount)
832832
mRigid.setAtRest();
833833
}

0 commit comments

Comments
 (0)