From 38072733214a37a1d42cba7cf9a04e4ed760a8b0 Mon Sep 17 00:00:00 2001 From: Super Hackio Date: Fri, 16 Feb 2024 19:04:55 -0800 Subject: [PATCH] Update path connected renderers --- src/whitehole/editor/GalaxyEditorForm.java | 18 ++++++++++++++++++ src/whitehole/rendering/GLRenderer.java | 1 + .../rendering/GravityShapeRenderer.java | 2 ++ src/whitehole/smg/object/AbstractObj.java | 12 ++++++++++++ 4 files changed, 33 insertions(+) diff --git a/src/whitehole/editor/GalaxyEditorForm.java b/src/whitehole/editor/GalaxyEditorForm.java index 551d843..00d2a30 100644 --- a/src/whitehole/editor/GalaxyEditorForm.java +++ b/src/whitehole/editor/GalaxyEditorForm.java @@ -2438,6 +2438,7 @@ private void offsetSelectionBy(Vec3f delta, boolean isShiftKey) { pnlObjectSettings.repaint(); rerenderTasks.add(String.format("path:%1$d", selectedPathPoint.path.uniqueID)); rerenderTasks.add("zone:"+selectedPathPoint.path.stage.stageName); + rerenderPathOwners(selectedPathPoint.path); } else { //if(selectedObj instanceof StageObj) // return; @@ -4474,4 +4475,21 @@ public int getValidSwitchInGalaxy() { public Set getUniqueSwitchesInZone() { return curZoneArc.getUniqueSwitchesInZone(); } + + public void rerenderPathOwners(PathObj path) + { + for (AbstractObj obj : globalObjList.values()) + { + if (obj.renderer == null) + continue; + + if (!obj.renderer.hasPathConnection()) + continue; + + if (AbstractObj.isUsingPath(obj, path)) + { + addRerenderTask("object:"+Integer.toString(obj.uniqueID)); + } + } + } } diff --git a/src/whitehole/rendering/GLRenderer.java b/src/whitehole/rendering/GLRenderer.java index 9694ac4..dcf7945 100644 --- a/src/whitehole/rendering/GLRenderer.java +++ b/src/whitehole/rendering/GLRenderer.java @@ -72,6 +72,7 @@ public void render(RenderInfo info) throws GLException {} public boolean hasSpecialPosition() { return false; } public boolean hasSpecialRotation() { return false; } public boolean hasSpecialScaling() { return false; } + public boolean hasPathConnection() { return false; } public boolean boundToPathId() { return false; } public boolean boundToObjArg(int arg) { return false; } public boolean boundToProperty() { return false; } diff --git a/src/whitehole/rendering/GravityShapeRenderer.java b/src/whitehole/rendering/GravityShapeRenderer.java index a8bb0ba..f0bb6fe 100644 --- a/src/whitehole/rendering/GravityShapeRenderer.java +++ b/src/whitehole/rendering/GravityShapeRenderer.java @@ -113,6 +113,8 @@ public boolean isScaled() { @Override public boolean hasSpecialScaling() { return true; } @Override + public boolean hasPathConnection() { return shape == Shape.WIRE_RANGE; } + @Override public boolean boundToPathId() { return shape == Shape.WIRE_RANGE; } @Override public boolean boundToObjArg(int arg) { return true; } diff --git a/src/whitehole/smg/object/AbstractObj.java b/src/whitehole/smg/object/AbstractObj.java index 58b8064..3d622aa 100644 --- a/src/whitehole/smg/object/AbstractObj.java +++ b/src/whitehole/smg/object/AbstractObj.java @@ -371,4 +371,16 @@ else if(obj.data.containsKey("CommonPath_ID")) } return null; //Path not found! } + + public static boolean isUsingPath(AbstractObj obj, PathObj path) + { + if (obj == null || path == null) + return false; + if (obj instanceof PathPointObj) + return ((PathPointObj)obj).path == path; //We want a reference comparison + if(!obj.data.containsKey("CommonPath_ID")) + return false; + int pathid = (short)obj.data.get("CommonPath_ID"); + return obj.stage == path.stage && pathid == path.pathID; + } }