Skip to content

Commit

Permalink
samples: trivial refactoring for more compact code
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Nov 11, 2024
1 parent ef2b31e commit 2b32ee1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ of this software and associated documentation files (the "Software"), to deal

public class BroadPhaseInsertionTest extends BroadPhaseTest{
DefaultRandomEngine mRandomGenerator = new DefaultRandomEngine();
int mCurrentBody = 0;
int mCurrentBody;
int mDirection = 1;
public void Initialize()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ of this software and associated documentation files (the "Software"), to deal
* https://github.com/jrouwe/JoltPhysics/blob/master/Samples/Tests/Character/CharacterPlanetTest.cpp
*/
public class CharacterPlanetTest extends Test{
final float cPlanetRadius = 20.0f;
float cPlanetRadius=20;
final float cCharacterHeightStanding = 1.35f;
final float cCharacterRadiusStanding = 0.3f;
final float cJumpSpeed = 4.0f;
float cJumpSpeed=4;
CharacterVirtualRef mCharacter=new CharacterVirtualRef();
Vec3 mDesiredVelocity=Vec3.sZero();
Vec3 mDesiredVelocityWS=Vec3.sZero();
boolean mJump = false;
boolean mJump;

public void Initialize()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ of this software and associated documentation files (the "Software"), to deal
* https://github.com/jrouwe/JoltPhysics/blob/master/Samples/Tests/Constraints/PoweredHingeConstraintTest.cpp
*/
public class PoweredHingeConstraintTest extends Test{
float sMaxAngularAcceleration = Jolt.degreesToRadians(3600.0f);
float sMaxFrictionAngularAcceleration = 0.0f;
float sFrequency = 2.0f;
float sDamping = 1.0f;
HingeConstraint mConstraint = null;
float sMaxAngularAcceleration=Jolt.degreesToRadians(3600);
float sMaxFrictionAngularAcceleration;
float sFrequency=2;
float sDamping=1;
HingeConstraint mConstraint;
float mInertiaBody2AsSeenFromConstraint;

public void Initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ of this software and associated documentation files (the "Software"), to deal
* https://github.com/jrouwe/JoltPhysics/blob/master/Samples/Tests/Constraints/SwingTwistConstraintTest.cpp
*/
public class SwingTwistConstraintTest extends Test{
float sNormalHalfConeAngle=Jolt.degreesToRadians(60);
float sPlaneHalfConeAngle=Jolt.degreesToRadians(20);
float sTwistMinAngle=Jolt.degreesToRadians(-10);
float sTwistMaxAngle=Jolt.degreesToRadians(20);
float sNormalHalfConeAngle=degreesToRadians(60);
float sPlaneHalfConeAngle=degreesToRadians(20);
float sTwistMinAngle=degreesToRadians(-10);
float sTwistMaxAngle=degreesToRadians(20);
List<TwoBodyConstraintRef>mConstraints=new ArrayList<>();

public void Initialize()
Expand All @@ -54,13 +54,13 @@ public void Initialize()
group_filter.disableCollision(i, i + 1);

Body prev = null;
Quat rotation = Quat.sRotation(Vec3.sAxisZ(), 0.5f * Jolt.JPH_PI);
Quat rotation = Quat.sRotation(Vec3.sAxisZ(), 0.5f * JPH_PI);
RVec3 position=new RVec3(0, 25, 0);
for (int i = 0; i < cChainLength; ++i)
{
Op.plusEquals(position ,new Vec3(2.0f * half_cylinder_height, 0, 0));

Body segment = mBodyInterface.createBody(new BodyCreationSettings(new CapsuleShape(half_cylinder_height, 0.5f), position, Op.multiply(Quat.sRotation(Vec3.sAxisX(), 0.25f * Jolt.JPH_PI * i) , rotation), i == 0? EMotionType.Static : EMotionType.Dynamic, i == 0? Layers.NON_MOVING : Layers.MOVING));
Body segment = mBodyInterface.createBody(new BodyCreationSettings(new CapsuleShape(half_cylinder_height, 0.5f), position, Op.multiply(Quat.sRotation(Vec3.sAxisX(), 0.25f * JPH_PI * i) , rotation), i == 0? EMotionType.Static : EMotionType.Dynamic, i == 0? Layers.NON_MOVING : Layers.MOVING));
segment.setCollisionGroup(new CollisionGroup(group_filter, 0, (i)));
mBodyInterface.addBody(segment.getId(), EActivation.Activate);
if (i != 0)
Expand Down
12 changes: 4 additions & 8 deletions src/test/java/testjoltjni/app/samples/vehicle/TankTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,15 @@ public class TankTest extends VehicleTest{
Body mTankBody;
Body mTurretBody;
Body mBarrelBody;
boolean mFire;
float mBarrelPitch, mBrake, mForward, mReloadTime, mTurretHeading;
VehicleConstraint mVehicleConstraint;
HingeConstraint mTurretHinge;
HingeConstraint mBarrelHinge;
float mReloadTime = 0.0f;
RVec3 mCameraPivot = RVec3.sZero();
float mForward = 0.0f;
float mPreviousForward = 1.0f;
RVec3 mCameraPivot=RVec3.sZero();
float mPreviousForward=1;
float mLeftRatio=1;
float mRightRatio=1;
float mBrake = 0.0f;
float mTurretHeading = 0.0f;
float mBarrelPitch = 0.0f;
boolean mFire = false;

public void Initialize()
{
Expand Down

0 comments on commit 2b32ee1

Please sign in to comment.