Skip to content

Commit 548a432

Browse files
committed
Made XNA Physics alternative that has the same effect but better.
1 parent e58df68 commit 548a432

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

engine/source/game/marble/marble.cpp

+12-9
Original file line numberDiff line numberDiff line change
@@ -2262,22 +2262,25 @@ ConsoleMethod(Marble, setMode, void, 3, 3, "(mode)")
22622262
ConsoleMethod(Marble, setPhysics, void, 3, 3, "(physics)")
22632263
{
22642264
const char* physics = argv[2];
2265-
U32 physicsFlags[3];
2266-
const char* physicsStrings[3];
2265+
U32 physicsFlags[Marble::MBPhysics_Count];
2266+
const char* physicsStrings[Marble::MBPhysics_Count];
22672267

2268-
physicsStrings[0] = "MBU";
2269-
physicsFlags[0] = Marble::MBU;
2268+
physicsStrings[Marble::MBU] = "MBU";
2269+
physicsFlags[Marble::MBU] = Marble::MBU;
22702270

2271-
physicsStrings[1] = "MBG";
2272-
physicsFlags[1] = Marble::MBG;
2271+
physicsStrings[Marble::MBG] = "MBG";
2272+
physicsFlags[Marble::MBG] = Marble::MBG;
22732273

2274-
physicsStrings[2] = "XNA";
2275-
physicsFlags[2] = Marble::XNA;
2274+
physicsStrings[Marble::XNA] = "XNA";
2275+
physicsFlags[Marble::XNA] = Marble::XNA;
2276+
2277+
physicsStrings[Marble::XNASlopes] = "XNASlopes";
2278+
physicsFlags[Marble::XNASlopes] = Marble::XNASlopes;
22762279

22772280
S32 i = 0;
22782281
while (dStricmp(physicsStrings[i], physics))
22792282
{
2280-
if (++i >= 3)
2283+
if (++i >= Marble::MBPhysics_Count)
22812284
{
22822285
Con::errorf("Marble:: Unknown physics mode: %s", physics);
22832286
return;

engine/source/game/marble/marble.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ class Marble : public ShapeBase
7070
{
7171
MBU,
7272
MBG,
73-
XNA
73+
XNA,
74+
XNASlopes,
75+
MBPhysics_Count
7476
};
7577

7678
enum UpdateMaskBits

engine/source/game/marble/marblephysics.cpp

+16-13
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,21 @@ void Marble::applyContactForces(const Move* move, bool isCentered, Point3D& aCon
106106
}
107107
}
108108

109-
for (S32 i = 0; i < mContacts.size(); i++)
109+
if (mPhysics != XNASlopes)
110110
{
111-
Contact* contact = &mContacts[i];
111+
for (S32 i = 0; i < mContacts.size(); i++)
112+
{
113+
Contact *contact = &mContacts[i];
112114

113-
F64 normalForce = -mDot(contact->normal, A);
115+
F64 normalForce = -mDot(contact->normal, A);
114116

115-
if (normalForce > 0.0 &&
116-
(mVelocity.x - contact->surfaceVelocity.x) * contact->normal.x
117-
+ (mVelocity.y - contact->surfaceVelocity.y) * contact->normal.y
118-
+ (mVelocity.z - contact->surfaceVelocity.z) * contact->normal.z <= 0.0001)
119-
{
120-
A += contact->normal * normalForce;
117+
if (normalForce > 0.0 &&
118+
(mVelocity.x - contact->surfaceVelocity.x) * contact->normal.x
119+
+ (mVelocity.y - contact->surfaceVelocity.y) * contact->normal.y
120+
+ (mVelocity.z - contact->surfaceVelocity.z) * contact->normal.z <= 0.0001)
121+
{
122+
A += contact->normal * normalForce;
123+
}
121124
}
122125
}
123126

@@ -634,10 +637,10 @@ void Marble::advancePhysics(const Move* move, U32 timeDelta)
634637

635638
F64 moveTime = timeStep;
636639
computeFirstPlatformIntersect(moveTime, smPathItrVec);
637-
//if (mPhysics == XNA)
638-
// mPosition += mVelocity * moveTime; // XNA
639-
//else
640-
testMove(mVelocity, mPosition, moveTime, mRadius, sCollisionMask, false); // MBU
640+
if (mPhysics == XNA)
641+
mPosition += mVelocity * moveTime; // XNA
642+
else
643+
testMove(mVelocity, mPosition, moveTime, mRadius, sCollisionMask, false); // MBU
641644

642645
if (!mMovePathSize && timeStep * 0.99 > moveTime && moveTime > 0.001000000047497451)
643646
{

game/marble/data/missions/Multiplayer/Polysoup/polysoup.mis

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ name = $Text::LevelNameMP26;
1111
difficulty = "4";
1212
gameType = "MultiPlayer";
1313
gameMode = "Scrum";
14-
physics = "XNA";
14+
physics = "XNASlopes";
1515
time = "300000";
1616
maxGemsPerGroup = "9";
1717
desc = "A preview mission";

0 commit comments

Comments
 (0)