Calculate bounding box for the whole physic object (disabled by default)

This commit is contained in:
fgnm
2023-08-07 12:44:18 +02:00
parent 9e286b9226
commit afd6cdda1e
5 changed files with 14 additions and 2 deletions
@@ -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;
@@ -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) {
@@ -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
@@ -60,6 +60,7 @@ public class UIPhysicsPropertiesMediator extends UIItemPropertiesMediator<UIPhys
viewComponent.getAwakeBox().setChecked(physicsComponent.awake);
viewComponent.getBulletBox().setChecked(physicsComponent.bullet);
viewComponent.getSensorBox().setChecked(physicsComponent.sensor);
viewComponent.getFineBoundBox().setChecked(physicsComponent.fineBoundBox);
viewComponent.getFixedRotationBox().setChecked(physicsComponent.fixedRotation);
viewComponent.setShapeType(physicsComponent.shapeType);
}
@@ -91,6 +92,7 @@ public class UIPhysicsPropertiesMediator extends UIItemPropertiesMediator<UIPhys
payloadVo.awake = viewComponent.getAwakeBox().isChecked();
payloadVo.bullet = viewComponent.getBulletBox().isChecked();
payloadVo.sensor = viewComponent.getSensorBox().isChecked();
payloadVo.fineBoundBox = viewComponent.getFineBoundBox().isChecked();
payloadVo.fixedRotation = viewComponent.getFixedRotationBox().isChecked();
payloadVo.shapeType = viewComponent.getShapeType();