More physics debugging

This commit is contained in:
austin 2022-03-30 23:28:27 -04:00
parent 470996d8f1
commit 32d8fe21cc
3 changed files with 26 additions and 9 deletions

View File

@ -692,6 +692,21 @@ public class LoadingThread extends Thread {
// } // }
// }}); // }});
// Globals.entityManager.registerBehaviorTree(new BehaviorTree() {
// int i = 0;
// public void simulate(){
// if(i < 10000){
// i++;
// if(i % 100 == 0){
// Entity sword = ItemUtils.spawnBasicItem("Katana");
// EntityUtils.getPosition(sword).set(new Vector3f(1,1.4f,2));
// EntityUtils.getRotation(sword).set(new Quaternionf().rotationY((float)(Math.PI/2.0)));
// }
// }
// }});
// DebugVisualizerUtils.spawnVectorVisualizer(new Vector3d(0,0,0), new Vector3d(-1,-1,-1)); // DebugVisualizerUtils.spawnVectorVisualizer(new Vector3d(0,0,0), new Vector3d(-1,-1,-1));
// Entity shorts = ItemUtils.spawnBasicItem("boots1"); // Entity shorts = ItemUtils.spawnBasicItem("boots1");

View File

@ -89,11 +89,13 @@ public class CollidableTree {
Vector3d torqueVec = new Vector3d(collisionPoint).cross(forceDir).normalize(); Vector3d torqueVec = new Vector3d(collisionPoint).cross(forceDir).normalize();
// double torqueMag = Math.abs(impulse.force); // double torqueMag = Math.abs(impulse.force);
double torqueMag = Math.sqrt(impulse.getCollisionPoint().length()) * impulse.getForce(); double torqueMag = Math.sqrt(impulse.getCollisionPoint().length()) * impulse.getForce();
if(!impulse.getType().equals(Collidable.TYPE_TERRAIN)){ if(impulse.getType().equals(Collidable.TYPE_TERRAIN)){
torqueMag = torqueMag * 10; torqueMag = torqueMag * 3;
} else {
torqueMag = 0;
} }
torqueMag = torqueMag * 10;
// } else {
// torqueMag = 0;
// }
// if(impulse.type.matches(Collidable.TYPE_ITEM) && ItemUtils.isItem(parent)){ // if(impulse.type.matches(Collidable.TYPE_ITEM) && ItemUtils.isItem(parent)){
// // System.out.println(rotation); // // System.out.println(rotation);
// if(impulse.collisionPoint.x < 0){ // if(impulse.collisionPoint.x < 0){
@ -105,7 +107,7 @@ public class CollidableTree {
// cumulativeTorque.add(new Vector3d(impulse.getCollisionPoint()).cross(impulse.getDirection())); // cumulativeTorque.add(new Vector3d(impulse.getCollisionPoint()).cross(impulse.getDirection()));
// } // }
if(impulse.type.matches(Collidable.TYPE_CREATURE)){ if(impulse.type.matches(Collidable.TYPE_CREATURE)){
System.out.println("Impulse: " + impulse.getCollisionPoint() + " x " + impulse.getDirection() + " ->f " + impulse.force); // System.out.println("Impulse: " + impulse.getCollisionPoint() + " x " + impulse.getDirection() + " ->f " + impulse.force);
// incrementer++; // incrementer++;
// if(incrementer > 5){ // if(incrementer > 5){
// Globals.microSimulation.freeze(); // Globals.microSimulation.freeze();
@ -136,7 +138,7 @@ public class CollidableTree {
// } // }
//friction //friction
if(angularVelocity.lengthSquared() > 0.001){ if(angularVelocity.lengthSquared() > 0.001){
angularVelocity.slerp(new Quaternionf(0,0,0,1), 0.01f); angularVelocity.slerp(new Quaternionf(0,0,0,1), 0.03f);
// angularVelocity.scale((float)(Math.sqrt(angularVelocity.lengthSquared()) * 0.9)); // angularVelocity.scale((float)(Math.sqrt(angularVelocity.lengthSquared()) * 0.9));
// System.out.println(angularVelocity); // System.out.println(angularVelocity);
} }

View File

@ -130,7 +130,7 @@ public class GravityTree {
if(hitFraction < 0){ if(hitFraction < 0){
hitFraction = 1; hitFraction = 1;
} }
collidable.addImpulse(new Impulse(new Vector3d(0,-1,0), new Vector3d(0,0,0), new Vector3d(0,0,0), gravityDif * hitFraction,"gravity")); collidable.addImpulse(new Impulse(new Vector3d(0,-1,0), new Vector3d(0,0,0), new Vector3d(position), gravityDif * hitFraction,"gravity"));
// System.out.println(hitFraction); // System.out.println(hitFraction);
// bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(new Vector3f((float)position.x,(float)position.y,(float)position.z)),1.0f); // bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(new Vector3f((float)position.x,(float)position.y,(float)position.z)),1.0f);
// body.setWorldTransform(new electrosphere.linearmath.Transform(bodyTransformMatrix)); // body.setWorldTransform(new electrosphere.linearmath.Transform(bodyTransformMatrix));