Skip to content

Commit

Permalink
HelloWorld: define "cout" as a field
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Nov 10, 2024
1 parent cd2ebd1 commit c7bb782
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/test/java/testjoltjni/app/helloworld/HelloWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ of this software and associated documentation files (the "Software"), to deal
package testjoltjni.app.helloworld;
import com.github.stephengold.joltjni.*;
import com.github.stephengold.joltjni.enumerate.*;
import java.io.PrintStream;
import testjoltjni.TestUtils;

/**
Expand All @@ -33,6 +34,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
public class HelloWorld {

static PrintStream cout=System.out;



Expand Down Expand Up @@ -103,25 +105,25 @@ static class MyContactListener extends CustomContactListener
// See: ContactListener
int onContactValidate(long body1Va, long body2Va, double offsetX, double offsetY, double offsetZ, long inCollisionResult)
{
System.out.println("Contact validate callback");
cout .println( "Contact validate callback" ) ;

// Allows you to ignore a contact before it is created (using layers to not make objects collide is cheaper!)
return ValidateResult.AcceptAllContactsForThisBodyPair.ordinal();
}

public void onContactAdded(long body1Va, long body2Va, long manifoldVa, long settingsVa)
{
System.out.println("A contact was added");
cout .println( "A contact was added" ) ;
}

public void onContactPersisted(long body1Va, long body2Va, long manifoldVa, long settingsVa)
{
System.out.println("A contact was persisted");
cout .println( "A contact was persisted" ) ;
}

public void onContactRemoved(long pairVa)
{
System.out.println("A contact was removed");
cout .println( "A contact was removed" ) ;
}
};

Expand All @@ -131,12 +133,12 @@ static class MyBodyActivationListener extends CustomBodyActivationListener
public
void onBodyActivated(long idVa, long inBodyUserData)
{
System.out.println("A body got activated");
cout .println( "A body got activated" ) ;
}

public void onBodyDeactivated(long idVa, long inBodyUserData)
{
System.out.println("A body went to sleep");
cout .println( "A body went to sleep" ) ;
}
};

Expand Down Expand Up @@ -272,7 +274,7 @@ public static void main(String[] argv)
// Output current position and velocity of the sphere
RVec3 position = body_interface.getCenterOfMassPosition(sphere_id);
Vec3 velocity = body_interface.getLinearVelocity(sphere_id);
System.out.println("Step " + step + ": Position = " + position + ", Velocity = " + velocity);
cout .println( "Step " + step + ": Position = " + position + ", Velocity = " + velocity ) ;

// If you take larger steps than 1 / 60th of a second you need to do multiple collision steps in order to keep the simulation stable. Do 1 collision step per 1 / 60th of a second (round up).
final int cCollisionSteps = 1;
Expand Down

0 comments on commit c7bb782

Please sign in to comment.