margin of collision improvement

This commit is contained in:
austin 2022-03-30 23:41:03 -04:00
parent 32d8fe21cc
commit 3724f2dcf8
2 changed files with 9 additions and 7 deletions

View File

@ -37,12 +37,12 @@
"idleAnim" : "Sword|Idle", "idleAnim" : "Sword|Idle",
"collidable": { "collidable": {
"type" : "CUBE", "type" : "CUBE",
"dimension1" : 0.1, "dimension1" : 0.03,
"dimension2" : 0.1, "dimension2" : 0.03,
"dimension3" : 0.35, "dimension3" : 0.2,
"offsetX" : 0, "offsetX" : 0.0,
"offsetY" : 0.05, "offsetY" : 0.05,
"offsetZ" : 0 "offsetZ" : 0.0
}, },
"iconPath" : "Textures/icons/itemIconWeapon.png" "iconPath" : "Textures/icons/itemIconWeapon.png"
}, },

View File

@ -48,6 +48,8 @@ public class PhysicsUtils {
int arrayLength = heightfield.length; int arrayLength = heightfield.length;
int arrayWidth = heightfield[0].length; int arrayWidth = heightfield[0].length;
float collisionMargin = 0.08f;
/* /*
Traditional buffer code not working for some reason Traditional buffer code not working for some reason
@ -72,7 +74,7 @@ public class PhysicsUtils {
for(int y = 0; y < arrayWidth; y++){ for(int y = 0; y < arrayWidth; y++){
vertices[vertexInserterPos] = x; vertices[vertexInserterPos] = x;
vertexInserterPos++; vertexInserterPos++;
vertices[vertexInserterPos] = heightfield[x][y]; vertices[vertexInserterPos] = heightfield[x][y] - collisionMargin;
vertexInserterPos++; vertexInserterPos++;
vertices[vertexInserterPos] = y; vertices[vertexInserterPos] = y;
vertexInserterPos++; vertexInserterPos++;
@ -142,7 +144,7 @@ public class PhysicsUtils {
); );
//uncomment if we start falling through things again //uncomment if we start falling through things again
// terrainShape.setMargin(0.08f); terrainShape.setMargin(collisionMargin);
// terrainShape.localGetSupportingVertex(new javax.vecmath.Vector3f(1,0,0), aabbMin); // terrainShape.localGetSupportingVertex(new javax.vecmath.Vector3f(1,0,0), aabbMin);
// terrainShape.recalcLocalAabb(); // terrainShape.recalcLocalAabb();