Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Fixed crashes with VS Control blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Tri0de committed Dec 31, 2020
1 parent 571b889 commit c2d7e2a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void addBuoyancyForces() {
final int hash = cachedPotentialHits.get(i);
SpatialDetector.setPosWithRespectTo(hash, centerPotentialHit, currentPos);

final Vector3dc waterPosInShipSpace = physicsTransform.transformPosition(JOML.convertDouble(currentPos, temp0).add(.5, .5, .5), TransformType.GLOBAL_TO_SUBSPACE);
final Vector3dc waterPosInShipSpace = physicsTransform.transformPositionNew(JOML.convertDouble(currentPos, temp0).add(.5, .5, .5), TransformType.GLOBAL_TO_SUBSPACE);

final int minX = (int) Math.floor(waterPosInShipSpace.x() - .5);
final int minY = (int) Math.floor(waterPosInShipSpace.y() - .5);
Expand All @@ -124,7 +124,7 @@ public void addBuoyancyForces() {
if (terrainOctree.get(x & 15, y & 15, z & 15)) {
// Assume both the water block and terrain block are spheres, then compute the volume
// that overlaps
final Vector3dc shipSolidBlockPosInWorld = physicsTransform.transformPosition(temp2.set(x + .5, y + .5, z + .5), TransformType.SUBSPACE_TO_GLOBAL);
final Vector3dc shipSolidBlockPosInWorld = physicsTransform.transformPositionNew(temp2.set(x + .5, y + .5, z + .5), TransformType.SUBSPACE_TO_GLOBAL);

final double volumeDisplaced = calculateAABBOverlap(
waterPosInWorld.x() - shipSolidBlockPosInWorld.x(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,28 @@ public static Matrix4d createTransform(ShipTransform prev, ShipTransform current
return current.subspaceToGlobal.mul(prev.globalToSubspace, new Matrix4d());
}

public Vector3d transformPosition(Vector3d position, TransformType transformType) {
/**
* Better than {@link #transformPosition(Vector3d, TransformType)}
*/
public Vector3d transformPositionNew(Vector3d position, TransformType transformType) {
return getTransformMatrix(transformType).transformPosition(position);
}

public Vector3d transformDirection(Vector3d direction, TransformType transformType) {
/**
* Better than {@link #transformDirection(Vector3d, TransformType)}
*/
public Vector3d transformDirectionNew(Vector3d direction, TransformType transformType) {
return getTransformMatrix(transformType).transformDirection(direction);
}

public void transformPosition(Vector3d position, TransformType transformType) {
getTransformMatrix(transformType).transformPosition(position);
}

public void transformDirection(Vector3d direction, TransformType transformType) {
getTransformMatrix(transformType).transformDirection(direction);
}

public Vec3d transform(Vec3d vec3d, TransformType transformType) {
Vector3d vec3dAsVector = JOML.convert(vec3d);
transformPosition(vec3dAsVector, transformType);
Expand Down

0 comments on commit c2d7e2a

Please sign in to comment.