From afd6cdda1e2f2936867b0eac160aad6edc2a3aa1 Mon Sep 17 00:00:00 2001 From: fgnm Date: Mon, 7 Aug 2023 12:44:18 +0200 Subject: [PATCH] Calculate bounding box for the whole physic object (disabled by default) --- hyperlap2d-runtime-libgdx | 2 +- .../commands/component/UpdatePhysicsDataCommand.java | 2 ++ .../commands/component/UpdateSensorDataCommand.java | 2 ++ .../view/ui/properties/panels/UIPhysicsProperties.java | 8 +++++++- .../ui/properties/panels/UIPhysicsPropertiesMediator.java | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hyperlap2d-runtime-libgdx b/hyperlap2d-runtime-libgdx index 6522edab..e25e4961 160000 --- a/hyperlap2d-runtime-libgdx +++ b/hyperlap2d-runtime-libgdx @@ -1 +1 @@ -Subproject commit 6522edab1b93e13c53310d816f35b5c036afdbc1 +Subproject commit e25e4961df74d9520ea401ac2b9607db5dd1bb42 diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePhysicsDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePhysicsDataCommand.java index 83908bfa..212a95da 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePhysicsDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdatePhysicsDataCommand.java @@ -42,6 +42,7 @@ public class UpdatePhysicsDataCommand extends EntityModifyRevertibleCommand { physicsComponent.awake = vo.awake; physicsComponent.bullet = vo.bullet; physicsComponent.sensor = vo.sensor; + physicsComponent.fineBoundBox = vo.fineBoundBox; physicsComponent.fixedRotation = vo.fixedRotation; physicsComponent.shapeType = vo.shapeType; @@ -74,6 +75,7 @@ public class UpdatePhysicsDataCommand extends EntityModifyRevertibleCommand { physicsComponent.awake = backup.awake; physicsComponent.bullet = backup.bullet; physicsComponent.sensor = backup.sensor; + physicsComponent.fineBoundBox = backup.fineBoundBox; physicsComponent.fixedRotation = backup.fixedRotation; physicsComponent.shapeType = backup.shapeType; diff --git a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSensorDataCommand.java b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSensorDataCommand.java index 7114de0d..8940c8dc 100644 --- a/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSensorDataCommand.java +++ b/src/main/java/games/rednblack/editor/controller/commands/component/UpdateSensorDataCommand.java @@ -49,6 +49,7 @@ public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand { sensorComponent.topHeightPercent = vo.topHeightPercent; Facade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity); + EntityUtils.refreshComponents(entity); } @Override @@ -72,6 +73,7 @@ public class UpdateSensorDataCommand extends EntityModifyRevertibleCommand { sensorComponent.topHeightPercent = backup.topHeightPercent; Facade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, entity); + EntityUtils.refreshComponents(entity); } public static Object payload(int entity, SensorDataVO vo) { diff --git a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIPhysicsProperties.java b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIPhysicsProperties.java index 416ef817..94f1de16 100644 --- a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIPhysicsProperties.java +++ b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIPhysicsProperties.java @@ -41,7 +41,7 @@ public class UIPhysicsProperties extends UIRemovableProperties { private VisCheckBox allowSleepBox; private VisCheckBox awakeBox; private VisCheckBox bulletBox; - private VisCheckBox sensor; + private VisCheckBox sensor, fineBoundBox; private VisCheckBox fixedRotation; public UIPhysicsProperties() { @@ -84,6 +84,7 @@ public class UIPhysicsProperties extends UIRemovableProperties { awakeBox = StandardWidgetsFactory.createCheckBox("Awake"); bulletBox = StandardWidgetsFactory.createCheckBox("Bullet"); sensor = StandardWidgetsFactory.createCheckBox("Sensor"); + fineBoundBox = StandardWidgetsFactory.createCheckBox("Fine Bound Box"); fixedRotation = StandardWidgetsFactory.createCheckBox("Fixed Rotation"); mainTable.add(new VisLabel("Body Type:", Align.right)).padRight(5).colspan(2).fillX(); @@ -144,6 +145,8 @@ public class UIPhysicsProperties extends UIRemovableProperties { bottomTable.add(sensor).padRight(5); bottomTable.add(fixedRotation).colspan(2).left(); + bottomTable.row(); + bottomTable.add(fineBoundBox).colspan(3); mainTable.add(bottomTable).padBottom(5).colspan(4); mainTable.row().padTop(5); @@ -182,6 +185,7 @@ public class UIPhysicsProperties extends UIRemovableProperties { awakeBox.addListener(new CheckBoxChangeListener(getUpdateEventName())); bulletBox.addListener(new CheckBoxChangeListener(getUpdateEventName())); sensor.addListener(new CheckBoxChangeListener(getUpdateEventName())); + fineBoundBox.addListener(new CheckBoxChangeListener(getUpdateEventName())); fixedRotation.addListener(new CheckBoxChangeListener(getUpdateEventName())); } @@ -264,6 +268,8 @@ public class UIPhysicsProperties extends UIRemovableProperties { public VisCheckBox getSensorBox() { return sensor; } + public VisCheckBox getFineBoundBox() { return fineBoundBox; } + public VisCheckBox getFixedRotationBox() { return fixedRotation; } @Override diff --git a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIPhysicsPropertiesMediator.java b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIPhysicsPropertiesMediator.java index 91040180..da2cdf7c 100644 --- a/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIPhysicsPropertiesMediator.java +++ b/src/main/java/games/rednblack/editor/view/ui/properties/panels/UIPhysicsPropertiesMediator.java @@ -60,6 +60,7 @@ public class UIPhysicsPropertiesMediator extends UIItemPropertiesMediator