Merge remote-tracking branch 'origin/develop' into feat/picocli
This commit is contained in:
commit
59f8ef54af
@ -24,7 +24,6 @@ import org.terasology.config.Config;
|
||||
import org.terasology.entitySystem.entity.EntityRef;
|
||||
import org.terasology.entitySystem.systems.BaseComponentSystem;
|
||||
import org.terasology.logic.players.LocalPlayer;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.math.TeraMath;
|
||||
import org.terasology.physics.CollisionGroup;
|
||||
import org.terasology.physics.HitResult;
|
||||
@ -112,8 +111,8 @@ public class CameraTargetSystem extends BaseComponentSystem {
|
||||
}
|
||||
|
||||
|
||||
HitResult hitInfo = physics.rayTrace(JomlUtil.from(localPlayer.getViewPosition()),
|
||||
JomlUtil.from(localPlayer.getViewDirection()), targetDistance, filter);
|
||||
HitResult hitInfo = physics.rayTrace(localPlayer.getViewPosition(new Vector3f()),
|
||||
localPlayer.getViewDirection(new Vector3f()), targetDistance, filter);
|
||||
updateFocalDistance(hitInfo, delta);
|
||||
Vector3i newBlockPos = null;
|
||||
|
||||
@ -144,7 +143,7 @@ public class CameraTargetSystem extends BaseComponentSystem {
|
||||
if (hitInfo.isHit()) {
|
||||
Vector3f playerToTargetRay = new Vector3f();
|
||||
//calculate the distance from the player to the hit point
|
||||
hitInfo.getHitPoint().sub(JomlUtil.from(localPlayer.getViewPosition()), playerToTargetRay);
|
||||
hitInfo.getHitPoint().sub(localPlayer.getViewPosition(new Vector3f()), playerToTargetRay);
|
||||
//gradually adjust focalDistance from it's current value to the hit point distance
|
||||
focalDistance = TeraMath.lerp(focalDistance, playerToTargetRay.length(), delta * focusRate);
|
||||
//if nothing was hit, gradually adjust the focusDistance to the maximum length of the update function trace
|
||||
@ -157,13 +156,15 @@ public class CameraTargetSystem extends BaseComponentSystem {
|
||||
public String toString() {
|
||||
|
||||
if (targetBlockPos != null) {
|
||||
Vector3f pos = localPlayer.getViewPosition(new Vector3f());
|
||||
Vector3f dir = localPlayer.getViewDirection(new Vector3f());
|
||||
return String.format("From: %f %f %f, Dir: %f %f %f, Hit %d %d %d %f %f %f",
|
||||
localPlayer.getViewPosition().x,
|
||||
localPlayer.getViewPosition().y,
|
||||
localPlayer.getViewPosition().z,
|
||||
localPlayer.getViewDirection().x,
|
||||
localPlayer.getViewDirection().y,
|
||||
localPlayer.getViewDirection().z,
|
||||
pos.x,
|
||||
pos.y,
|
||||
pos.z,
|
||||
dir.x,
|
||||
dir.y,
|
||||
dir.z,
|
||||
targetBlockPos.x,
|
||||
targetBlockPos.y,
|
||||
targetBlockPos.z,
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.terasology.logic.characters;
|
||||
|
||||
import org.terasology.entitySystem.event.Event;
|
||||
import org.joml.Vector3f;
|
||||
import org.terasology.entitySystem.event.Event;
|
||||
|
||||
public class CharacterImpulseEvent implements Event {
|
||||
Vector3f direction;
|
||||
|
@ -7,7 +7,6 @@ import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.terasology.entitySystem.entity.EntityRef;
|
||||
import org.terasology.logic.location.LocationComponent;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.math.TeraMath;
|
||||
import org.terasology.physics.engine.CharacterCollider;
|
||||
import org.terasology.physics.engine.PhysicsEngine;
|
||||
@ -59,19 +58,19 @@ public final class CharacterMovementSystemUtility {
|
||||
// Only set the gaze entity rotation if it is not the same as the main entity.
|
||||
// The character is assumed to only rotate side to side, introducing pitch makes things act strangely
|
||||
LocationComponent gazeLocation = gazeEntity.getComponent(LocationComponent.class);
|
||||
gazeLocation.setLocalRotation(JomlUtil.from(rotation));
|
||||
gazeLocation.setLocalRotation(rotation);
|
||||
gazeEntity.saveComponent(gazeLocation);
|
||||
}
|
||||
}
|
||||
|
||||
public void setToInterpolateState(EntityRef entity, CharacterStateEvent a, CharacterStateEvent b, long time) {
|
||||
float t = (float) (time - a.getTime()) / (b.getTime() - a.getTime());
|
||||
Vector3f newPos = a.getPosition().lerp(b.getPosition(),t);
|
||||
Quaternionf newRot = a.getRotation().nlerp(b.getRotation(),t);
|
||||
|
||||
Vector3f newPos = a.getPosition().lerp(b.getPosition(), t, new Vector3f());
|
||||
Quaternionf newRot = a.getRotation().nlerp(b.getRotation(), t, new Quaternionf());
|
||||
|
||||
entity.updateComponent(LocationComponent.class, location -> {
|
||||
location.setWorldPosition(JomlUtil.from(newPos));
|
||||
location.setWorldRotation(JomlUtil.from(newRot));
|
||||
location.setWorldPosition(newPos);
|
||||
location.setWorldRotation(newRot);
|
||||
return location;
|
||||
});
|
||||
|
||||
@ -111,7 +110,7 @@ public final class CharacterMovementSystemUtility {
|
||||
|
||||
private void extrapolateLocationComponent(EntityRef entity, CharacterStateEvent state, Vector3f newPos) {
|
||||
LocationComponent location = entity.getComponent(LocationComponent.class);
|
||||
location.setWorldPosition(JomlUtil.from(newPos));
|
||||
location.setWorldPosition(newPos);
|
||||
location.setWorldRotation(state.getRotation());
|
||||
entity.saveComponent(location);
|
||||
}
|
||||
|
@ -17,7 +17,9 @@
|
||||
package org.terasology.logic.characters;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Quaternionfc;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3fc;
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.network.BroadcastEvent;
|
||||
import org.terasology.network.NetworkEvent;
|
||||
@ -56,9 +58,9 @@ public class CharacterStateEvent extends NetworkEvent {
|
||||
public CharacterStateEvent(
|
||||
long time,
|
||||
int sequenceNumber,
|
||||
Vector3f position,
|
||||
Quaternionf rotation,
|
||||
Vector3f velocity,
|
||||
Vector3fc position,
|
||||
Quaternionfc rotation,
|
||||
Vector3fc velocity,
|
||||
float yaw,
|
||||
float pitch,
|
||||
MovementMode mode,
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.terasology.logic.characters;
|
||||
|
||||
import org.joml.Math;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
@ -155,7 +156,7 @@ public class KinematicCharacterMover implements CharacterMover {
|
||||
|
||||
for (int y = 0; y < characterHeightInBlocks; y++) {
|
||||
// send a block enter/leave event for this character
|
||||
entity.send(new OnEnterBlockEvent(oldBlocks[y], newBlocks[y], JomlUtil.from(new Vector3i(0, y, 0))));
|
||||
entity.send(new OnEnterBlockEvent(oldBlocks[y], newBlocks[y], new Vector3i(0, y, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -338,10 +339,11 @@ public class KinematicCharacterMover implements CharacterMover {
|
||||
private void followToParent(final CharacterStateEvent state, EntityRef entity) {
|
||||
LocationComponent locationComponent = entity.getComponent(LocationComponent.class);
|
||||
if (!locationComponent.getParent().equals(EntityRef.NULL)) {
|
||||
Vector3f velocity = new Vector3f(locationComponent.getWorldPosition(new Vector3f()));
|
||||
Vector3f position = locationComponent.getWorldPosition(new Vector3f());
|
||||
Vector3f velocity = new Vector3f(position);
|
||||
velocity.sub(state.getPosition());
|
||||
state.getVelocity().set(velocity);
|
||||
state.getPosition().set(locationComponent.getWorldPosition(new Vector3f()));
|
||||
state.getPosition().set(position);
|
||||
}
|
||||
}
|
||||
|
||||
@ -576,9 +578,9 @@ public class KinematicCharacterMover implements CharacterMover {
|
||||
CharacterMoveInputEvent input) {
|
||||
if (movementComp.faceMovementDirection && result.getVelocity().lengthSquared() > 0.01f) {
|
||||
float yaw = (float) Math.atan2(result.getVelocity().x, result.getVelocity().z);
|
||||
result.getRotation().set(0, 1, 0, yaw);
|
||||
result.getRotation().setAngleAxis(yaw, 0, 1, 0);
|
||||
} else {
|
||||
result.getRotation().set(new Quaternionf().rotationYXZ(org.joml.Math.toRadians(input.getYaw()), 0, 0));
|
||||
result.getRotation().set(new Quaternionf().rotationYXZ(Math.toRadians(input.getYaw()), 0, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -645,7 +647,7 @@ public class KinematicCharacterMover implements CharacterMover {
|
||||
distanceMoved.sub(state.getPosition());
|
||||
state.getPosition().set(moveResult.getFinalPosition());
|
||||
if (input.isFirstRun() && distanceMoved.length() > 0) {
|
||||
entity.send(new MovedEvent(new Vector3f(distanceMoved), new Vector3f(state.getPosition())));
|
||||
entity.send(new MovedEvent(distanceMoved, state.getPosition()));
|
||||
}
|
||||
|
||||
// Upon hitting solid ground, reset the number of jumps back to the maximum value.
|
||||
|
@ -20,6 +20,7 @@ package org.terasology.logic.characters;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.terasology.engine.Time;
|
||||
@ -35,7 +36,6 @@ import org.terasology.logic.characters.events.SetMovementModeEvent;
|
||||
import org.terasology.logic.location.LocationComponent;
|
||||
import org.terasology.logic.players.LocalPlayer;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.joml.Vector3f;
|
||||
import org.terasology.network.NetworkSystem;
|
||||
import org.terasology.physics.engine.CharacterCollider;
|
||||
import org.terasology.physics.engine.PhysicsEngine;
|
||||
@ -52,7 +52,8 @@ import java.util.Map;
|
||||
|
||||
@RegisterSystem(RegisterMode.AUTHORITY)
|
||||
@Share(PredictionSystem.class)
|
||||
public class ServerCharacterPredictionSystem extends BaseComponentSystem implements UpdateSubscriberSystem, PredictionSystem {
|
||||
public class ServerCharacterPredictionSystem extends BaseComponentSystem implements UpdateSubscriberSystem,
|
||||
PredictionSystem {
|
||||
public static final int RENDER_DELAY = 100;
|
||||
public static final int MAX_INPUT_OVERFLOW = 100;
|
||||
public static final int MAX_INPUT_UNDERFLOW = 100;
|
||||
@ -98,7 +99,8 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
characterMovementSystemUtility = new CharacterMovementSystemUtility(physics);
|
||||
}
|
||||
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class, AliveCharacterComponent.class})
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class,
|
||||
AliveCharacterComponent.class})
|
||||
public void onCreate(final OnActivatedComponent event, final EntityRef entity) {
|
||||
physics.getCharacterCollider(entity);
|
||||
CircularBuffer<CharacterStateEvent> stateBuffer = CircularBuffer.create(BUFFER_SIZE);
|
||||
@ -106,7 +108,8 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
characterStates.put(entity, stateBuffer);
|
||||
}
|
||||
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class, AliveCharacterComponent.class})
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class,
|
||||
AliveCharacterComponent.class})
|
||||
public void onDestroy(final BeforeDeactivateComponent event, final EntityRef entity) {
|
||||
physics.removeCharacterCollider(entity);
|
||||
characterStatesToRemove.add(entity);
|
||||
@ -114,7 +117,8 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
}
|
||||
|
||||
@ReceiveEvent(components = {AliveCharacterComponent.class})
|
||||
public void onSetMovementModeEvent(SetMovementModeEvent event, EntityRef character, CharacterMovementComponent movementComponent) {
|
||||
public void onSetMovementModeEvent(SetMovementModeEvent event, EntityRef character,
|
||||
CharacterMovementComponent movementComponent) {
|
||||
CircularBuffer<CharacterStateEvent> stateBuffer = characterStates.get(character);
|
||||
CharacterStateEvent lastState = stateBuffer.getLast();
|
||||
CharacterStateEvent newState = new CharacterStateEvent(lastState);
|
||||
@ -128,7 +132,8 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
characterMovementSystemUtility.setToState(character, newState);
|
||||
}
|
||||
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class, AliveCharacterComponent.class})
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class,
|
||||
AliveCharacterComponent.class})
|
||||
public void onPlayerInput(CharacterMoveInputEvent input, EntityRef entity) {
|
||||
CharacterCollider characterCollider = physics.getCharacterCollider(entity);
|
||||
if (characterCollider.isPending()) {
|
||||
@ -137,7 +142,7 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
}
|
||||
CircularBuffer<CharacterStateEvent> stateBuffer = characterStates.get(entity);
|
||||
CharacterStateEvent lastState = stateBuffer.getLast();
|
||||
float delta = input.getDeltaMs() + lastState.getTime() - (time.getGameTimeInMs() + MAX_INPUT_OVERFLOW );
|
||||
float delta = input.getDeltaMs() + lastState.getTime() - (time.getGameTimeInMs() + MAX_INPUT_OVERFLOW);
|
||||
if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.REPLAYING) {
|
||||
delta -= MAX_INPUT_OVERFLOW_REPLAY_INCREASE;
|
||||
}
|
||||
@ -145,10 +150,11 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
CharacterStateEvent newState = stepState(input, lastState, entity);
|
||||
stateBuffer.add(newState);
|
||||
|
||||
if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.REPLAYING) {
|
||||
if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.REPLAYING) {
|
||||
characterStateEventPositionMap.updateCharacterStateEvent(newState);
|
||||
} else if (recordAndReplayCurrentStatus.getStatus() == RecordAndReplayStatus.RECORDING) {
|
||||
characterStateEventPositionMap.add(newState.getSequenceNumber(), JomlUtil.from(newState.getPosition()), JomlUtil.from(newState.getVelocity()));
|
||||
characterStateEventPositionMap.add(newState.getSequenceNumber(), newState.getPosition(),
|
||||
newState.getVelocity());
|
||||
}
|
||||
|
||||
characterMovementSystemUtility.setToState(entity, newState);
|
||||
@ -158,7 +164,8 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
}
|
||||
}
|
||||
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class, AliveCharacterComponent.class})
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class,
|
||||
AliveCharacterComponent.class})
|
||||
public void onTeleport(CharacterTeleportEvent event, EntityRef entity) {
|
||||
CircularBuffer<CharacterStateEvent> stateBuffer = characterStates.get(entity);
|
||||
CharacterStateEvent lastState = stateBuffer.getLast();
|
||||
@ -170,7 +177,8 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
|
||||
}
|
||||
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class, AliveCharacterComponent.class})
|
||||
@ReceiveEvent(components = {CharacterMovementComponent.class, LocationComponent.class,
|
||||
AliveCharacterComponent.class})
|
||||
public void onImpulse(CharacterImpulseEvent event, EntityRef entity) {
|
||||
Vector3f impulse = event.getDirection();
|
||||
|
||||
@ -186,10 +194,12 @@ public class ServerCharacterPredictionSystem extends BaseComponentSystem impleme
|
||||
|
||||
private CharacterStateEvent createInitialState(EntityRef entity) {
|
||||
LocationComponent location = entity.getComponent(LocationComponent.class);
|
||||
return new CharacterStateEvent(time.getGameTimeInMs(), 0, location.getWorldPosition(new Vector3f()), location.getWorldRotation(new Quaternionf()), new Vector3f(), 0, 0, MovementMode.WALKING, false);
|
||||
return new CharacterStateEvent(time.getGameTimeInMs(), 0, location.getWorldPosition(new Vector3f()),
|
||||
location.getWorldRotation(new Quaternionf()), new Vector3f(), 0, 0, MovementMode.WALKING, false);
|
||||
}
|
||||
|
||||
private CharacterStateEvent stepState(CharacterMoveInputEvent input, CharacterStateEvent lastState, EntityRef entity) {
|
||||
private CharacterStateEvent stepState(CharacterMoveInputEvent input, CharacterStateEvent lastState,
|
||||
EntityRef entity) {
|
||||
return characterMover.step(lastState, input, entity);
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.terasology.logic.characters.events;
|
||||
|
||||
import org.terasology.entitySystem.event.Event;
|
||||
import org.joml.Vector3f;
|
||||
import org.terasology.entitySystem.event.Event;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.terasology.logic.characters.events;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.entitySystem.event.Event;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.world.block.Block;
|
||||
|
||||
/**
|
||||
|
@ -175,7 +175,12 @@ public class LocalPlayer {
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* @deprecated This is scheduled for removal in an upcoming version method will be replaced with JOML implementation
|
||||
* {@link #getViewPosition(org.joml.Vector3f)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public Vector3f getViewPosition() {
|
||||
return getViewPosition(new Vector3f());
|
||||
}
|
||||
|
@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.terasology.logic.players;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.terasology.entitySystem.Component;
|
||||
import org.terasology.entitySystem.Owns;
|
||||
import org.terasology.entitySystem.entity.EntityRef;
|
||||
import org.terasology.math.geom.Quat4f;
|
||||
import org.terasology.math.geom.Vector3f;
|
||||
|
||||
/**
|
||||
* Only used by the client side so that held items of other players can be positioned in line with them.
|
||||
@ -28,9 +28,9 @@ public class RemotePersonHeldItemMountPointComponent implements Component {
|
||||
|
||||
@Owns
|
||||
public EntityRef mountPointEntity = EntityRef.NULL;
|
||||
public Vector3f rotateDegrees = Vector3f.zero();
|
||||
public Vector3f translate = Vector3f.zero();
|
||||
public Quat4f rotationQuaternion;
|
||||
public Vector3f rotateDegrees = new Vector3f();
|
||||
public Vector3f translate = new Vector3f();
|
||||
public Quaternionf rotationQuaternion;
|
||||
public float scale = 1f;
|
||||
|
||||
}
|
||||
|
@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.terasology.logic.players;
|
||||
|
||||
import org.terasology.math.geom.Vector3f;
|
||||
import org.joml.Vector3f;
|
||||
import org.terasology.rendering.logic.VisualComponent;
|
||||
|
||||
public class RemotePersonHeldItemTransformComponent implements VisualComponent {
|
||||
public Vector3f rotateDegrees = Vector3f.zero();
|
||||
public Vector3f translate = Vector3f.zero();
|
||||
public Vector3f rotateDegrees = new Vector3f();
|
||||
public Vector3f translate = new Vector3f();
|
||||
public float scale = 1f;
|
||||
}
|
||||
|
@ -16,6 +16,9 @@
|
||||
package org.terasology.logic.players;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.joml.Math;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.terasology.engine.Time;
|
||||
@ -36,9 +39,6 @@ import org.terasology.logic.console.commandSystem.annotations.Command;
|
||||
import org.terasology.logic.console.commandSystem.annotations.CommandParam;
|
||||
import org.terasology.logic.location.Location;
|
||||
import org.terasology.logic.location.LocationComponent;
|
||||
import org.terasology.math.TeraMath;
|
||||
import org.terasology.math.geom.Quat4f;
|
||||
import org.terasology.math.geom.Vector3f;
|
||||
import org.terasology.network.ClientComponent;
|
||||
import org.terasology.registry.In;
|
||||
import org.terasology.rendering.logic.VisualComponent;
|
||||
@ -93,10 +93,10 @@ public class ThirdPersonRemoteClientSystem extends BaseComponentSystem implement
|
||||
Location.removeChild(character, remotePersonHeldItemMountPointComponent.mountPointEntity);
|
||||
Location.attachChild(character, remotePersonHeldItemMountPointComponent.mountPointEntity,
|
||||
remotePersonHeldItemMountPointComponent.translate,
|
||||
new Quat4f(
|
||||
TeraMath.DEG_TO_RAD * remotePersonHeldItemMountPointComponent.rotateDegrees.y,
|
||||
TeraMath.DEG_TO_RAD * remotePersonHeldItemMountPointComponent.rotateDegrees.x,
|
||||
TeraMath.DEG_TO_RAD * remotePersonHeldItemMountPointComponent.rotateDegrees.z),
|
||||
new Quaternionf().rotationYXZ(
|
||||
Math.toRadians(remotePersonHeldItemMountPointComponent.rotateDegrees.y),
|
||||
Math.toRadians(remotePersonHeldItemMountPointComponent.rotateDegrees.x),
|
||||
Math.toRadians(remotePersonHeldItemMountPointComponent.rotateDegrees.z)),
|
||||
remotePersonHeldItemMountPointComponent.scale);
|
||||
|
||||
}
|
||||
@ -225,10 +225,10 @@ public class ThirdPersonRemoteClientSystem extends BaseComponentSystem implement
|
||||
|
||||
Location.attachChild(mountPointComponent.mountPointEntity, currentHeldItem,
|
||||
heldItemTransformComponent.translate,
|
||||
new Quat4f(
|
||||
TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.y,
|
||||
TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.x,
|
||||
TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.z),
|
||||
new Quaternionf().rotationYXZ(
|
||||
Math.toRadians(heldItemTransformComponent.rotateDegrees.y),
|
||||
Math.toRadians(heldItemTransformComponent.rotateDegrees.x),
|
||||
Math.toRadians(heldItemTransformComponent.rotateDegrees.z)),
|
||||
heldItemTransformComponent.scale);
|
||||
}
|
||||
} else {
|
||||
@ -298,10 +298,10 @@ public class ThirdPersonRemoteClientSystem extends BaseComponentSystem implement
|
||||
}
|
||||
float addPitch = 15f * animateAmount;
|
||||
float addYaw = 10f * animateAmount;
|
||||
locationComponent.setLocalRotation(new Quat4f(
|
||||
TeraMath.DEG_TO_RAD * (mountPointComponent.rotateDegrees.y + addYaw),
|
||||
TeraMath.DEG_TO_RAD * (mountPointComponent.rotateDegrees.x + addPitch),
|
||||
TeraMath.DEG_TO_RAD * mountPointComponent.rotateDegrees.z));
|
||||
locationComponent.setLocalRotation(new Quaternionf().rotationYXZ(
|
||||
Math.toRadians(mountPointComponent.rotateDegrees.y + addYaw),
|
||||
Math.toRadians(mountPointComponent.rotateDegrees.x + addPitch),
|
||||
Math.toRadians(mountPointComponent.rotateDegrees.z)));
|
||||
Vector3f offset = new Vector3f(0.05f * animateAmount, -0.24f * animateAmount, 0f);
|
||||
offset.add(mountPointComponent.translate);
|
||||
locationComponent.setLocalPosition(offset);
|
||||
|
@ -42,8 +42,12 @@ import org.terasology.math.geom.Quat4f;
|
||||
import org.terasology.math.geom.Rect2f;
|
||||
import org.terasology.math.geom.Rect2i;
|
||||
import org.terasology.math.geom.Vector3f;
|
||||
import org.terasology.world.block.Block;
|
||||
import org.terasology.world.block.BlockRegion;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public final class JomlUtil {
|
||||
private JomlUtil() {
|
||||
|
||||
@ -237,4 +241,8 @@ public final class JomlUtil {
|
||||
public static Rectanglef rectanglefFromMinAndSize(float minX, float minY, float width, float height) {
|
||||
return new Rectanglef(minX, minY, minX + width, minY + height);
|
||||
}
|
||||
|
||||
public static Map<org.terasology.math.geom.Vector3i, Block> blockMap(Map<Vector3i, Block> maps) {
|
||||
return maps.entrySet().stream().collect(Collectors.toMap(k -> JomlUtil.from(k.getKey()), Map.Entry::getValue));
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ import org.joml.Quaternionf;
|
||||
import org.joml.Quaternionfc;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3fc;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.math.Transform;
|
||||
import org.terasology.physics.shapes.CollisionShape;
|
||||
import org.terasology.physics.shapes.CompoundShape;
|
||||
|
||||
|
@ -147,7 +147,7 @@ public class PhysicsSystem extends BaseComponentSystem implements UpdateSubscrib
|
||||
|
||||
@ReceiveEvent(components = {BlockComponent.class})
|
||||
public void onBlockAltered(OnChangedBlock event, EntityRef entity) {
|
||||
physics.awakenArea(new Vector3f(JomlUtil.from(event.getBlockPosition())), 0.6f);
|
||||
physics.awakenArea(new Vector3f(event.getBlockPosition()), 0.6f);
|
||||
}
|
||||
|
||||
@ReceiveEvent
|
||||
|
@ -16,16 +16,17 @@
|
||||
|
||||
package org.terasology.physics.events;
|
||||
|
||||
import org.terasology.entitySystem.event.Event;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3fc;
|
||||
import org.terasology.entitySystem.event.Event;
|
||||
|
||||
public class MovedEvent implements Event {
|
||||
private Vector3fc delta;
|
||||
private Vector3fc finalPosition;
|
||||
private Vector3f delta = new Vector3f();
|
||||
private Vector3f finalPosition = new Vector3f();
|
||||
|
||||
public MovedEvent(Vector3fc delta, Vector3fc finalPosition) {
|
||||
this.delta = delta;
|
||||
this.finalPosition = finalPosition;
|
||||
this.delta.set(delta);
|
||||
this.finalPosition.set(finalPosition);
|
||||
}
|
||||
|
||||
public Vector3fc getDelta() {
|
||||
|
@ -20,8 +20,6 @@ import org.joml.Quaternionf;
|
||||
import org.joml.Quaternionfc;
|
||||
import org.joml.Vector3fc;
|
||||
import org.terasology.math.AABB;
|
||||
import org.terasology.math.Transform;
|
||||
import org.terasology.math.geom.Quat4f;
|
||||
|
||||
/**
|
||||
* The base type representing a collision shape in the physics engine.
|
||||
|
@ -15,9 +15,8 @@
|
||||
*/
|
||||
package org.terasology.recording;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
import org.terasology.logic.characters.CharacterStateEvent;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.math.geom.Vector3f;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -29,7 +28,10 @@ import java.util.Map;
|
||||
*/
|
||||
public class CharacterStateEventPositionMap {
|
||||
|
||||
/** Map in which the key is the "sequenceNumber" of the CharacterStateEvent and the value is an array with the "position" and "velocity" variables. */
|
||||
/**
|
||||
* Map in which the key is the "sequenceNumber" of the CharacterStateEvent and the value is an array with the
|
||||
* "position" and "velocity" variables.
|
||||
*/
|
||||
private Map<Integer, Vector3f[]> idToData;
|
||||
|
||||
public CharacterStateEventPositionMap() {
|
||||
@ -38,6 +40,7 @@ public class CharacterStateEventPositionMap {
|
||||
|
||||
/**
|
||||
* Add a new "position" and "velocity" to the map.
|
||||
*
|
||||
* @param sequenceNumber the sequenceNumber of the CharacterStateEvent.
|
||||
* @param position the position of the event.
|
||||
* @param velocity the velocity of the event.
|
||||
@ -67,11 +70,12 @@ public class CharacterStateEventPositionMap {
|
||||
|
||||
/**
|
||||
* Used in a replay to update a CharacterStateEvent with the correct values of "position" and "velocity".
|
||||
*
|
||||
* @param event the event to be updated.
|
||||
*/
|
||||
public void updateCharacterStateEvent(CharacterStateEvent event) {
|
||||
Vector3f[] data = this.idToData.get(event.getSequenceNumber());
|
||||
event.setPosition(JomlUtil.from(data[0]));
|
||||
event.setVelocity(JomlUtil.from(data[1]));
|
||||
event.setPosition(data[0]);
|
||||
event.setVelocity(data[1]);
|
||||
}
|
||||
}
|
||||
|
@ -21,16 +21,16 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.joml.Vector3f;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.terasology.engine.module.ModuleManager;
|
||||
import org.terasology.engine.paths.PathManager;
|
||||
import org.terasology.entitySystem.entity.EntityManager;
|
||||
import org.terasology.math.geom.Vector3f;
|
||||
import org.terasology.reflection.TypeRegistry;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -80,6 +80,7 @@ public final class RecordAndReplaySerializer {
|
||||
|
||||
/**
|
||||
* Serialize RecordedEvents.
|
||||
*
|
||||
* @param recordingPath path where the data should be saved.
|
||||
*/
|
||||
public void serializeRecordedEvents(String recordingPath) {
|
||||
@ -104,6 +105,7 @@ public final class RecordAndReplaySerializer {
|
||||
|
||||
/**
|
||||
* Deserialize RecordedEvents.
|
||||
*
|
||||
* @param recordingPath path where the data was saved.
|
||||
*/
|
||||
void deserializeRecordedEvents(String recordingPath) {
|
||||
@ -125,10 +127,11 @@ public final class RecordAndReplaySerializer {
|
||||
}
|
||||
|
||||
private void deserializeFileAmount(Gson gson, String recordingPath) {
|
||||
try (FileReader fileReader = new FileReader(recordingPath + FILE_AMOUNT)){
|
||||
try (FileReader fileReader = new FileReader(recordingPath + FILE_AMOUNT)) {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement jsonElement = parser.parse(fileReader);
|
||||
Type typeOfCount = new TypeToken<Integer>() { }.getType();
|
||||
Type typeOfCount = new TypeToken<Integer>() {
|
||||
}.getType();
|
||||
recordAndReplayUtils.setFileAmount(gson.fromJson(jsonElement, typeOfCount));
|
||||
logger.info("File Amount Deserialization completed!");
|
||||
} catch (Exception e) {
|
||||
@ -152,7 +155,8 @@ public final class RecordAndReplaySerializer {
|
||||
try (FileReader fileReader = new FileReader(recordingPath + STATE_EVENT_POSITION)) {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement jsonElement = parser.parse(fileReader);
|
||||
Type typeOfHashMap = new TypeToken<HashMap<Integer, Vector3f[]>>() { }.getType();
|
||||
Type typeOfHashMap = new TypeToken<HashMap<Integer, Vector3f[]>>() {
|
||||
}.getType();
|
||||
Map<Integer, Vector3f[]> previousMap = gson.fromJson(jsonElement, typeOfHashMap);
|
||||
characterStateEventPositionMap.setIdToData(previousMap);
|
||||
logger.info("CharacterStateEvent positions Deserialization completed!");
|
||||
@ -172,12 +176,13 @@ public final class RecordAndReplaySerializer {
|
||||
logger.error("Error while serializing AttackEvent extras:", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void deserializeAttackEventExtraRecorder(Gson gson, String recordingPath) {
|
||||
try (FileReader fileReader = new FileReader(recordingPath + DIRECTION_ORIGIN_LIST)) {
|
||||
JsonParser parser = new JsonParser();
|
||||
JsonElement jsonElement = parser.parse(fileReader);
|
||||
Type type = new TypeToken<ArrayList<DirectionAndOriginPosRecorder>>() {}.getType();
|
||||
Type type = new TypeToken<ArrayList<DirectionAndOriginPosRecorder>>() {
|
||||
}.getType();
|
||||
ArrayList<DirectionAndOriginPosRecorder> list = gson.fromJson(jsonElement, type);
|
||||
directionAndOriginPosRecorderList.setList(list);
|
||||
logger.info("AttackEvent extras deserialization completed!");
|
||||
@ -185,5 +190,4 @@ public final class RecordAndReplaySerializer {
|
||||
logger.error("Error while deserializing AttackEvent extras:", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ import java.util.Optional;
|
||||
*/
|
||||
@RegisterAssetFileFormat
|
||||
public class AtlasFormat extends AbstractAssetFileFormat<AtlasData> {
|
||||
public static final float BORDER_SIZE = 0.0001f;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AtlasFormat.class);
|
||||
|
||||
@ -108,10 +109,10 @@ public class AtlasFormat extends AbstractAssetFileFormat<AtlasData> {
|
||||
Vector2f min = new Vector2f((float) freeform.getMin().x / size.x, (float) freeform.getMin().y / size.y);
|
||||
if (freeform.getSize() != null) {
|
||||
Vector2f itemSize = new Vector2f((float) freeform.getSize().x / size.x, (float) freeform.getSize().y / size.y);
|
||||
out.put(new Name(freeform.getName()), new SubtextureData(texture, Rect2f.createFromMinAndSize(min, itemSize)));
|
||||
out.put(new Name(freeform.getName()), new SubtextureData(texture, shrinkRegion(Rect2f.createFromMinAndSize(min, itemSize))));
|
||||
} else if (freeform.getMax() != null) {
|
||||
Vector2f max = new Vector2f((float) freeform.getMax().x / size.x, (float) freeform.getMax().y / size.y);
|
||||
out.put(new Name(freeform.getName()), new SubtextureData(texture, Rect2f.createFromMinAndMax(min, max)));
|
||||
out.put(new Name(freeform.getName()), new SubtextureData(texture, shrinkRegion(Rect2f.createFromMinAndMax(min, max))));
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ public class AtlasFormat extends AbstractAssetFileFormat<AtlasData> {
|
||||
pos.x += tileX * tileSize.x;
|
||||
pos.y += tileY * tileSize.y;
|
||||
Rect2f tileLocation = Rect2f.createFromMinAndSize(offset.x + tileX * tileSize.x, offset.y + tileY * tileSize.y, tileSize.x, tileSize.y);
|
||||
out.put(new Name(name), new SubtextureData(texture, tileLocation));
|
||||
out.put(new Name(name), new SubtextureData(texture, shrinkRegion(tileLocation)));
|
||||
}
|
||||
|
||||
tileX++;
|
||||
@ -149,4 +150,14 @@ public class AtlasFormat extends AbstractAssetFileFormat<AtlasData> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make the region slightly smaller to make sure the adjacent pixels don't leak in.
|
||||
*/
|
||||
private Rect2f shrinkRegion(Rect2f region) {
|
||||
return Rect2f.createFromMinAndSize(
|
||||
region.minX() + region.width() * BORDER_SIZE,
|
||||
region.minY() + region.height() * BORDER_SIZE,
|
||||
region.width() * (1 - 2 * BORDER_SIZE),
|
||||
region.height() * (1 - 2 * BORDER_SIZE));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
package org.terasology.rendering.cameras;
|
||||
|
||||
import org.joml.AABBf;
|
||||
import org.joml.AxisAngle4f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
@ -246,7 +247,19 @@ public abstract class Camera {
|
||||
return reflected;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aabb
|
||||
* @return
|
||||
* @deprecated This method is scheduled for removal in an upcoming version. Use the JOML implementation instead:
|
||||
* {@link #hasInSight(AABBf)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean hasInSight(AABB aabb) {
|
||||
return viewFrustum.intersects(aabb);
|
||||
}
|
||||
|
||||
public boolean hasInSight(AABBf aabb) {
|
||||
return viewFrustum.intersects(aabb);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ package org.terasology.rendering.logic;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import org.joml.AABBf;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
@ -37,9 +38,7 @@ import org.terasology.entitySystem.systems.RegisterSystem;
|
||||
import org.terasology.entitySystem.systems.RenderSystem;
|
||||
import org.terasology.logic.location.LocationComponent;
|
||||
import org.terasology.logic.players.LocalPlayer;
|
||||
import org.terasology.math.AABB;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.math.Transform;
|
||||
import org.terasology.network.ClientComponent;
|
||||
import org.terasology.network.NetworkSystem;
|
||||
import org.terasology.registry.In;
|
||||
@ -194,26 +193,28 @@ public class MeshRenderer extends BaseComponentSystem implements RenderSystem {
|
||||
for (EntityRef entity : entities) {
|
||||
MeshComponent meshComp = entity.getComponent(MeshComponent.class);
|
||||
LocationComponent location = entity.getComponent(LocationComponent.class);
|
||||
|
||||
if (isHidden(entity, meshComp) || location == null || Float.isNaN(location.getWorldPosition().x) || meshComp.mesh == null || !isRelevant(entity, JomlUtil.from(location.getWorldPosition()))) {
|
||||
if (isHidden(entity, meshComp) || location == null || meshComp.mesh == null) {
|
||||
continue;
|
||||
}
|
||||
Vector3f worldPosition = location.getWorldPosition(new Vector3f());
|
||||
if (!worldPosition.isFinite() && !isRelevant(entity, worldPosition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (meshComp.mesh.isDisposed()) {
|
||||
logger.error("Attempted to render disposed mesh");
|
||||
continue;
|
||||
}
|
||||
|
||||
worldRot.set(JomlUtil.from(location.getWorldRotation()));
|
||||
worldPos.set(JomlUtil.from(location.getWorldPosition()));
|
||||
worldRot.set(location.getWorldRotation(new Quaternionf()));
|
||||
worldPos.set(location.getWorldPosition(new Vector3f()));
|
||||
float worldScale = location.getWorldScale();
|
||||
|
||||
Transform toWorldSpace = new Transform(JomlUtil.from(worldPos), JomlUtil.from(worldRot), worldScale);
|
||||
|
||||
Vector3f offsetFromCamera = worldPos.sub(cameraPosition, new Vector3f());
|
||||
matrixCameraSpace.translationRotateScale(offsetFromCamera, worldRot, worldScale);
|
||||
|
||||
|
||||
AABB aabb = meshComp.mesh.getAABB().transform(toWorldSpace);
|
||||
AABBf aabb = JomlUtil.from(meshComp.mesh.getAABB()).transform(new Matrix4f().translationRotateScale(worldPos, worldRot, worldScale));
|
||||
if (worldRenderer.getActiveCamera().hasInSight(aabb)) {
|
||||
if (meshComp.mesh != lastMesh) {
|
||||
if (lastMesh != null) {
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
package org.terasology.world;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.entitySystem.event.Event;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.world.block.Block;
|
||||
|
||||
/**
|
||||
|
@ -73,6 +73,25 @@ public final class BlockRegions {
|
||||
.setMax(new Vector3i(max, RoundingMode.FLOOR));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new region spanning the smallest axis-aligned bounding box (AABB) containing both, min and max.
|
||||
* <p>
|
||||
* Note that each component of {@code min} should be smaller or equal to the respective component in {@code max}. If
|
||||
* a dimension of {@code min} is greater than the respective dimension of {@code max} the resulting block region
|
||||
* will have a size of 0 along that dimension.
|
||||
* <p>
|
||||
* Consider using {@link #encompassing(Vector3ic...)} as an alternative.
|
||||
*
|
||||
* @return new block region
|
||||
*/
|
||||
public static BlockRegion createFromMinAndSize(Vector3ic min, Vector3ic size) {
|
||||
return new BlockRegion().setMin(min).setMax(
|
||||
min.x() + size.x() - 1,
|
||||
min.y() + size.y() - 1,
|
||||
min.z() + size.z() - 1
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new region spanning the smallest axis-aligned bounding box (AABB) containing all the given positions.
|
||||
*
|
||||
|
@ -16,6 +16,7 @@
|
||||
package org.terasology.world.block.entity.neighbourUpdate;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.joml.Vector3i;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.terasology.entitySystem.entity.EntityRef;
|
||||
@ -24,8 +25,8 @@ import org.terasology.entitySystem.systems.BaseComponentSystem;
|
||||
import org.terasology.entitySystem.systems.RegisterMode;
|
||||
import org.terasology.entitySystem.systems.RegisterSystem;
|
||||
import org.terasology.entitySystem.systems.UpdateSubscriberSystem;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.math.Side;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.registry.In;
|
||||
import org.terasology.world.BlockEntityRegistry;
|
||||
import org.terasology.world.OnChangedBlock;
|
||||
@ -80,7 +81,7 @@ public class NeighbourBlockFamilyUpdateSystem extends BaseComponentSystem implem
|
||||
return;
|
||||
}
|
||||
|
||||
processUpdateForBlockLocation(blockComponent.position);
|
||||
processUpdateForBlockLocation(JomlUtil.from(blockComponent.position));
|
||||
}
|
||||
|
||||
private void notifyNeighboursOfChangedBlocks() {
|
||||
@ -110,7 +111,7 @@ public class NeighbourBlockFamilyUpdateSystem extends BaseComponentSystem implem
|
||||
private void processUpdateForBlockLocation(Vector3i blockLocation) {
|
||||
for (Side side : Side.getAllSides()) {
|
||||
Vector3i neighborLocation = new Vector3i(blockLocation);
|
||||
neighborLocation.add(side.getVector3i());
|
||||
neighborLocation.add(side.direction());
|
||||
if (worldProvider.isBlockRelevant(neighborLocation)) {
|
||||
Block neighborBlock = worldProvider.getBlock(neighborLocation);
|
||||
final BlockFamily blockFamily = neighborBlock.getBlockFamily();
|
||||
|
@ -21,6 +21,7 @@ import org.terasology.entitySystem.event.ReceiveEvent;
|
||||
import org.terasology.entitySystem.systems.BaseComponentSystem;
|
||||
import org.terasology.entitySystem.systems.RegisterMode;
|
||||
import org.terasology.entitySystem.systems.RegisterSystem;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.registry.In;
|
||||
import org.terasology.world.WorldComponent;
|
||||
import org.terasology.world.WorldProvider;
|
||||
@ -34,6 +35,6 @@ public class BlockPlacingSystem extends BaseComponentSystem {
|
||||
|
||||
@ReceiveEvent(components = {WorldComponent.class}, priority = EventPriority.PRIORITY_TRIVIAL)
|
||||
public void placeBlockInWorld(PlaceBlocks event, EntityRef world) {
|
||||
worldProvider.setBlocks(event.getBlocks());
|
||||
worldProvider.setBlocks(JomlUtil.blockMap(event.getBlocks()));
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.terasology.world.block.entity.placement;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.entitySystem.entity.EntityRef;
|
||||
import org.terasology.entitySystem.event.AbstractConsumableEvent;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.world.block.Block;
|
||||
|
||||
import java.util.Collections;
|
||||
|
@ -99,7 +99,7 @@ public class BlockItemSystem extends BaseComponentSystem {
|
||||
if (canPlaceBlock(block, targetBlock, placementPos)) {
|
||||
// TODO: Fix this for changes.
|
||||
if (networkSystem.getMode().isAuthority()) {
|
||||
PlaceBlocks placeBlocks = new PlaceBlocks(JomlUtil.from(placementPos), block, event.getInstigator());
|
||||
PlaceBlocks placeBlocks = new PlaceBlocks(placementPos, block, event.getInstigator());
|
||||
worldProvider.getWorldEntity().send(placeBlocks);
|
||||
if (!placeBlocks.isConsumed()) {
|
||||
item.send(new OnBlockItemPlaced(JomlUtil.from(placementPos), blockEntityRegistry.getBlockEntityAt(placementPos), event.getInstigator()));
|
||||
|
@ -34,9 +34,7 @@ import org.terasology.assets.ResourceUrn;
|
||||
import org.terasology.assets.format.AbstractAssetFileFormat;
|
||||
import org.terasology.assets.format.AssetDataFile;
|
||||
import org.terasology.assets.module.annotations.RegisterAssetFileFormat;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.math.Rotation;
|
||||
import org.terasology.math.Transform;
|
||||
import org.terasology.physics.shapes.CollisionShape;
|
||||
import org.terasology.physics.shapes.CompoundShape;
|
||||
import org.terasology.physics.shapes.ConvexHullShape;
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.terasology.world.block.structure;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.entitySystem.entity.EntityRef;
|
||||
import org.terasology.math.Side;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.registry.CoreRegistry;
|
||||
import org.terasology.world.BlockEntityRegistry;
|
||||
import org.terasology.world.WorldProvider;
|
||||
@ -90,7 +90,7 @@ public class AttachSupportRequired implements BlockStructuralSupport {
|
||||
}
|
||||
|
||||
private boolean hasSupportFromBlockOnSide(Vector3i blockPosition, Side side, Map<Vector3i, Block> blockOverrides) {
|
||||
final Vector3i sideBlockPosition = side.getAdjacentPos(blockPosition);
|
||||
final Vector3i sideBlockPosition = side.getAdjacentPos(blockPosition, new Vector3i());
|
||||
if (!getWorldProvider().isBlockRelevant(sideBlockPosition)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.terasology.world.block.structure;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.math.Side;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.registry.CoreRegistry;
|
||||
import org.terasology.world.WorldProvider;
|
||||
import org.terasology.world.block.Block;
|
||||
@ -34,7 +34,7 @@ public class BlockDefSupportRequired implements BlockStructuralSupport {
|
||||
public boolean isSufficientlySupported(Vector3i location, Map<Vector3i, Block> blockOverrides) {
|
||||
final Block block = getBlockWithOverrides(location, blockOverrides);
|
||||
if (block.isSupportRequired()) {
|
||||
final Vector3i bottomLocation = Side.BOTTOM.getAdjacentPos(location);
|
||||
final Vector3i bottomLocation = Side.BOTTOM.getAdjacentPos(location, new Vector3i());
|
||||
return !getWorldProvider().isBlockRelevant(bottomLocation)
|
||||
|| getBlockWithOverrides(bottomLocation, blockOverrides).isFullSide(Side.TOP);
|
||||
}
|
||||
|
@ -15,8 +15,8 @@
|
||||
*/
|
||||
package org.terasology.world.block.structure;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.math.Side;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.world.block.Block;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -16,6 +16,7 @@
|
||||
package org.terasology.world.block.structure;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.entitySystem.entity.EntityManager;
|
||||
import org.terasology.entitySystem.entity.EntityRef;
|
||||
import org.terasology.entitySystem.event.ReceiveEvent;
|
||||
@ -24,7 +25,6 @@ import org.terasology.entitySystem.systems.BaseComponentSystem;
|
||||
import org.terasology.entitySystem.systems.RegisterSystem;
|
||||
import org.terasology.logic.health.DestroyEvent;
|
||||
import org.terasology.math.Side;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.monitoring.PerformanceMonitor;
|
||||
import org.terasology.registry.In;
|
||||
import org.terasology.registry.Share;
|
||||
@ -104,7 +104,7 @@ public class BlockStructuralSupportSystem extends BaseComponentSystem implements
|
||||
}
|
||||
|
||||
private void validateSupportForBlockOnSide(Vector3i replacedBlockPosition, Side side) {
|
||||
final Vector3i blockPosition = side.getAdjacentPos(replacedBlockPosition);
|
||||
final Vector3i blockPosition = side.getAdjacentPos(replacedBlockPosition, new Vector3i());
|
||||
if (worldProvider.isBlockRelevant(blockPosition)) {
|
||||
final Side sideReverse = side.reverse();
|
||||
|
||||
|
@ -15,14 +15,15 @@
|
||||
*/
|
||||
package org.terasology.world.block.structure;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
import org.terasology.entitySystem.entity.EntityRef;
|
||||
import org.terasology.entitySystem.event.ReceiveEvent;
|
||||
import org.terasology.entitySystem.prefab.PrefabManager;
|
||||
import org.terasology.logic.delay.DelayManager;
|
||||
import org.terasology.logic.delay.DelayedActionTriggeredEvent;
|
||||
import org.terasology.logic.health.DestroyEvent;
|
||||
import org.terasology.math.JomlUtil;
|
||||
import org.terasology.math.Side;
|
||||
import org.terasology.math.geom.Vector3i;
|
||||
import org.terasology.registry.CoreRegistry;
|
||||
import org.terasology.world.BlockEntityRegistry;
|
||||
import org.terasology.world.WorldProvider;
|
||||
@ -63,7 +64,7 @@ public class SideBlockSupportRequired implements BlockStructuralSupport {
|
||||
@ReceiveEvent
|
||||
public void checkForSupport(DelayedActionTriggeredEvent event, EntityRef entity, BlockComponent block, SideBlockSupportRequiredComponent supportRequired) {
|
||||
if (event.getActionId().equals(SUPPORT_CHECK_ACTION_ID)) {
|
||||
if (!isSufficientlySupported(block.position, null, Collections.<Vector3i, Block>emptyMap(), supportRequired)) {
|
||||
if (!isSufficientlySupported(JomlUtil.from(block.position), null, Collections.<Vector3i, Block>emptyMap(), supportRequired)) {
|
||||
PrefabManager prefabManager = CoreRegistry.get(PrefabManager.class);
|
||||
entity.send(new DestroyEvent(entity, EntityRef.NULL, prefabManager.getPrefab("engine:supportRemovedDamage")));
|
||||
}
|
||||
@ -126,7 +127,7 @@ public class SideBlockSupportRequired implements BlockStructuralSupport {
|
||||
}
|
||||
|
||||
private boolean hasSupportFromBlockOnSide(Vector3i blockPosition, Side side, Map<Vector3i, Block> blockOverrides) {
|
||||
final Vector3i sideBlockPosition = side.getAdjacentPos(blockPosition);
|
||||
final Vector3i sideBlockPosition = side.getAdjacentPos(blockPosition, new Vector3i());
|
||||
if (!getWorldProvider().isBlockRelevant(sideBlockPosition)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class EntityAwareWorldProvider extends AbstractWorldProviderDecorator imp
|
||||
updateBlockEntityComponents(blockEntity, oldType, type, retainComponents);
|
||||
}
|
||||
|
||||
OnChangedBlock changedEvent = new OnChangedBlock(pos, type, oldType);
|
||||
OnChangedBlock changedEvent = new OnChangedBlock(JomlUtil.from(pos), type, oldType);
|
||||
EntityRef regionEntity = blockRegionLookup.get(JomlUtil.from(pos));
|
||||
if (regionEntity != null) {
|
||||
regionEntity.send(changedEvent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user