Skip to content

Commit

Permalink
TargetTrackerCamera: fix crash if enabled too early in log mode
Browse files Browse the repository at this point in the history
closes #92
  • Loading branch information
Gama11 committed Jul 28, 2016
1 parent 39a551b commit 9cd885f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/rv/ui/view/TargetTrackerCamera.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public TargetTrackerCamera(ISelectable target, FPCamera camera, GameState gs) {
}

public void update() {
if (!enabled)
if (!enabled || target.getPosition() == null)
return;

float scale = (float) (1 - (0.02f * playbackSpeed));
Expand Down
40 changes: 21 additions & 19 deletions src/rv/world/objects/Ball.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,30 @@ public void update(SceneGraph sg) {
if (node == null)
return;

Model model = content.getModel(node.getName());
if (!model.isLoaded()) {
return;
}

Vec3f min = new Vec3f(Float.POSITIVE_INFINITY);
Vec3f max = new Vec3f(Float.NEGATIVE_INFINITY);

Model model = content.getModel(node.getName());
if (model.isLoaded()) {
Vec3f[] corners = model.getMesh().getBounds().getCorners();
Matrix modelMat = WorldModel.COORD_TFN.times(node.getWorldTransform());
for (int j = 0; j < 8; j++) {
Vec3f v = modelMat.transform(corners[j]);
if (v.x < min.x)
min.x = v.x;
if (v.y < min.y)
min.y = v.y;
if (v.z < min.z)
min.z = v.z;
if (v.x > max.x)
max.x = v.x;
if (v.y > max.y)
max.y = v.y;
if (v.z > max.z)
max.z = v.z;
}
Vec3f[] corners = model.getMesh().getBounds().getCorners();
Matrix modelMat = WorldModel.COORD_TFN.times(node.getWorldTransform());
for (int j = 0; j < 8; j++) {
Vec3f v = modelMat.transform(corners[j]);
if (v.x < min.x)
min.x = v.x;
if (v.y < min.y)
min.y = v.y;
if (v.z < min.z)
min.z = v.z;
if (v.x > max.x)
max.x = v.x;
if (v.y > max.y)
max.y = v.y;
if (v.z > max.z)
max.z = v.z;
}

bounds = new BoundingBox(min, max);
Expand Down

0 comments on commit 9cd885f

Please sign in to comment.