grid-aligned entity work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
4a2aecf9c8
commit
99dbf13dd1
@ -1779,6 +1779,7 @@ Fix engine not closing when X button is hit on main menu
|
|||||||
Sorting imgui debug windows
|
Sorting imgui debug windows
|
||||||
Grid alignment cursor
|
Grid alignment cursor
|
||||||
Furniture spawner items triggers grid alignment cursor
|
Furniture spawner items triggers grid alignment cursor
|
||||||
|
Grid aligned entity work
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,10 @@ public class ItemActions {
|
|||||||
public static void attemptPrimaryItemAction(){
|
public static void attemptPrimaryItemAction(){
|
||||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
Vector3d cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
Vector3d cursorPos = Globals.cursorState.getCursorPosition();
|
||||||
|
if(cursorPos == null){
|
||||||
|
cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||||
|
}
|
||||||
if(cursorPos == null){
|
if(cursorPos == null){
|
||||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||||
}
|
}
|
||||||
@ -110,7 +113,10 @@ public class ItemActions {
|
|||||||
public static void repeatPrimaryItemAction(){
|
public static void repeatPrimaryItemAction(){
|
||||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
Vector3d cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
Vector3d cursorPos = Globals.cursorState.getCursorPosition();
|
||||||
|
if(cursorPos == null){
|
||||||
|
cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||||
|
}
|
||||||
if(cursorPos == null){
|
if(cursorPos == null){
|
||||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||||
}
|
}
|
||||||
@ -132,7 +138,10 @@ public class ItemActions {
|
|||||||
public static void releasePrimaryItemAction(){
|
public static void releasePrimaryItemAction(){
|
||||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
Vector3d cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
Vector3d cursorPos = Globals.cursorState.getCursorPosition();
|
||||||
|
if(cursorPos == null){
|
||||||
|
cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||||
|
}
|
||||||
if(cursorPos == null){
|
if(cursorPos == null){
|
||||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||||
}
|
}
|
||||||
@ -162,7 +171,10 @@ public class ItemActions {
|
|||||||
public static void attemptSecondaryItemAction(){
|
public static void attemptSecondaryItemAction(){
|
||||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
Vector3d cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
Vector3d cursorPos = Globals.cursorState.getCursorPosition();
|
||||||
|
if(cursorPos == null){
|
||||||
|
cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||||
|
}
|
||||||
if(cursorPos == null){
|
if(cursorPos == null){
|
||||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||||
}
|
}
|
||||||
@ -211,7 +223,10 @@ public class ItemActions {
|
|||||||
public static void repeatSecondaryItemAction(){
|
public static void repeatSecondaryItemAction(){
|
||||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
Vector3d cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
Vector3d cursorPos = Globals.cursorState.getCursorPosition();
|
||||||
|
if(cursorPos == null){
|
||||||
|
cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||||
|
}
|
||||||
if(cursorPos == null){
|
if(cursorPos == null){
|
||||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||||
}
|
}
|
||||||
@ -260,7 +275,10 @@ public class ItemActions {
|
|||||||
public static void releaseSecondaryItemAction(){
|
public static void releaseSecondaryItemAction(){
|
||||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.playerCamera));
|
||||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.playerCamera));
|
||||||
Vector3d cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
Vector3d cursorPos = Globals.cursorState.getCursorPosition();
|
||||||
|
if(cursorPos == null){
|
||||||
|
cursorPos = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||||
|
}
|
||||||
if(cursorPos == null){
|
if(cursorPos == null){
|
||||||
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -346,7 +346,7 @@ public class CursorState {
|
|||||||
* @param position The position
|
* @param position The position
|
||||||
* @param data The data
|
* @param data The data
|
||||||
*/
|
*/
|
||||||
private static void nudgeGridAlignment(Vector3d position, GridAlignedData data){
|
public static void nudgeGridAlignment(Vector3d position, GridAlignedData data){
|
||||||
if(data.getWidth() / 2 == 1){
|
if(data.getWidth() / 2 == 1){
|
||||||
position.x = position.x + BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0f;
|
position.x = position.x + BlockChunkData.BLOCK_SIZE_MULTIPLIER / 2.0f;
|
||||||
}
|
}
|
||||||
@ -602,4 +602,27 @@ public class CursorState {
|
|||||||
this.gridAlignmentData = gridAlignedData;
|
this.gridAlignmentData = gridAlignedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the position of the currently visible cursor
|
||||||
|
* @return The position if a cursor is visible, null otherwise
|
||||||
|
*/
|
||||||
|
public Vector3d getCursorPosition(){
|
||||||
|
if(Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerCursor)){
|
||||||
|
return EntityUtils.getPosition(Globals.playerCursor);
|
||||||
|
}
|
||||||
|
if(Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerBlockCursor)){
|
||||||
|
return EntityUtils.getPosition(Globals.playerBlockCursor);
|
||||||
|
}
|
||||||
|
if(Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(Globals.playerAreaCursor)){
|
||||||
|
return EntityUtils.getPosition(Globals.playerAreaCursor);
|
||||||
|
}
|
||||||
|
if(Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(CursorState.playerFabCursor)){
|
||||||
|
return EntityUtils.getPosition(CursorState.playerFabCursor);
|
||||||
|
}
|
||||||
|
if(Globals.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE).contains(CursorState.playerGridAlignedCursor)){
|
||||||
|
return EntityUtils.getPosition(CursorState.playerGridAlignedCursor);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import org.ode4j.ode.DBody;
|
|||||||
import electrosphere.client.interact.ClientInteractionEngine;
|
import electrosphere.client.interact.ClientInteractionEngine;
|
||||||
import electrosphere.collision.PhysicsEntityUtils;
|
import electrosphere.collision.PhysicsEntityUtils;
|
||||||
import electrosphere.collision.collidable.Collidable;
|
import electrosphere.collision.collidable.Collidable;
|
||||||
|
import electrosphere.controls.cursor.CursorState;
|
||||||
import electrosphere.data.collidable.CollidableTemplate;
|
import electrosphere.data.collidable.CollidableTemplate;
|
||||||
import electrosphere.data.common.CommonEntityType;
|
import electrosphere.data.common.CommonEntityType;
|
||||||
import electrosphere.data.creature.CreatureData;
|
import electrosphere.data.creature.CreatureData;
|
||||||
@ -744,7 +745,9 @@ public class CommonEntityUtils {
|
|||||||
|
|
||||||
//grid alignment
|
//grid alignment
|
||||||
if(rawType.getGridAlignedData() != null){
|
if(rawType.getGridAlignedData() != null){
|
||||||
position.set(realm.getServerWorldData().clampRealToBlock(position));
|
Vector3d placementPos = realm.getServerWorldData().clampRealToBlock(position);
|
||||||
|
CursorState.nudgeGridAlignment(placementPos,rawType.getGridAlignedData());
|
||||||
|
position.set(placementPos);
|
||||||
Globals.clientScene.registerEntityToTag(entity, EntityTags.BLOCK_OCCUPANT);
|
Globals.clientScene.registerEntityToTag(entity, EntityTags.BLOCK_OCCUPANT);
|
||||||
//TODO: must register with all nearby scenes as well because it could possibly occupy other chunks
|
//TODO: must register with all nearby scenes as well because it could possibly occupy other chunks
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user