Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "chore: remove finite check from LocalPlayer" #4788

Merged
merged 3 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import org.terasology.engine.logic.characters.CharacterComponent;
import org.terasology.engine.logic.characters.CharacterMovementComponent;
import org.terasology.engine.logic.characters.CharacterSystem;
import org.terasology.engine.logic.characters.events.ActivationPredicted;
import org.terasology.engine.logic.characters.events.ActivationRequest;
import org.terasology.engine.logic.common.ActivateEvent;
import org.terasology.engine.logic.location.LocationComponent;
import org.terasology.engine.logic.characters.events.ActivationPredicted;
import org.terasology.engine.logic.characters.events.ActivationRequest;
import org.terasology.engine.math.Direction;
import org.terasology.engine.network.ClientComponent;
import org.terasology.engine.physics.HitResult;
Expand Down Expand Up @@ -99,7 +99,13 @@ public boolean isValid() {
*/
public Vector3f getPosition(Vector3f dest) {
LocationComponent location = getCharacterEntity().getComponent(LocationComponent.class);
return location.getWorldPosition(dest);
if (location != null) {
Vector3f result = location.getWorldPosition(new Vector3f());
if (result.isFinite()) { //TODO: MP finite check seems to hide a larger underlying problem
dest.set(result);
}
}
return dest;
}

/**
Expand All @@ -110,7 +116,13 @@ public Vector3f getPosition(Vector3f dest) {
*/
public Quaternionf getRotation(Quaternionf dest) {
LocationComponent location = getCharacterEntity().getComponent(LocationComponent.class);
return location.getWorldRotation(dest);
if (location != null) {
Quaternionf result = location.getWorldRotation(new Quaternionf());
if (result.isFinite()) { //TODO: MP finite check seems to hide a larger underlying problem
dest.set(result);
}
}
return dest;
}

/**
Expand All @@ -121,8 +133,18 @@ public Quaternionf getRotation(Quaternionf dest) {
*/
public Vector3f getViewPosition(Vector3f dest) {
ClientComponent clientComponent = getClientEntity().getComponent(ClientComponent.class);
if (clientComponent == null) {
return dest;
}
LocationComponent location = clientComponent.camera.getComponent(LocationComponent.class);
return location.getWorldPosition(dest);
if (location != null) {
Vector3f result = location.getWorldPosition(new Vector3f());
if (result.isFinite()) { //TODO: MP finite check seems to hide a larger underlying problem
dest.set(result);
return dest;
}
}
return getPosition(dest);
}

/**
Expand All @@ -133,8 +155,18 @@ public Vector3f getViewPosition(Vector3f dest) {
*/
public Quaternionf getViewRotation(Quaternionf dest) {
ClientComponent clientComponent = getClientEntity().getComponent(ClientComponent.class);
if (clientComponent == null) {
return new Quaternionf();
}
LocationComponent location = clientComponent.camera.getComponent(LocationComponent.class);
return location.getWorldRotation(dest);
if (location != null) {
Quaternionf result = location.getWorldRotation(new Quaternionf());
if (result.isFinite()) { //TODO: MP finite check seems to hide a larger underlying problem
dest.set(result);
return dest;
}
}
return getRotation(dest);
}

/**
Expand All @@ -150,7 +182,10 @@ public Vector3f getViewDirection(Vector3f dest) {

public Vector3f getVelocity(Vector3f dest) {
CharacterMovementComponent movement = getCharacterEntity().getComponent(CharacterMovementComponent.class);
return dest.set(movement.getVelocity());
if (movement != null) {
return dest.set(movement.getVelocity());
}
return dest;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ public String get() {
debugLine3.bindText(new ReadOnlyBinding<String>() {
@Override
public String get() {
if (!localPlayer.isValid()) {
return "";
}
Vector3f pos = localPlayer.getPosition(new Vector3f());
Vector3i chunkPos = Chunks.toChunkPos(pos, new Vector3i());
Vector3f rotation = localPlayer.getViewDirection(new Vector3f());
Expand Down