From 76a03fec88aabb7ee2655e89ff9a281cc572ef9f Mon Sep 17 00:00:00 2001 From: yvain Date: Mon, 12 Aug 2024 12:23:44 +0200 Subject: [PATCH 1/2] Use visibleShadow, get rid of visibleMesh # Veuillez saisir le message de validation pour vos modifications. Les lignes --- Sources/iron/Scene.hx | 1 + Sources/iron/data/SceneFormat.hx | 1 + Sources/iron/object/MeshObject.hx | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/iron/Scene.hx b/Sources/iron/Scene.hx index bd779f7f..2985b4a2 100644 --- a/Sources/iron/Scene.hx +++ b/Sources/iron/Scene.hx @@ -830,6 +830,7 @@ class Scene { if (o.visible != null) object.visible = o.visible; if (o.visible_mesh != null) object.visibleMesh = o.visible_mesh; if (o.visible_shadow != null) object.visibleShadow = o.visible_shadow; + createConstraints(o.constraints, object); generateTransform(o, object.transform); object.setupAnimation(oactions); diff --git a/Sources/iron/data/SceneFormat.hx b/Sources/iron/data/SceneFormat.hx index 11313647..f804647c 100644 --- a/Sources/iron/data/SceneFormat.hx +++ b/Sources/iron/data/SceneFormat.hx @@ -451,6 +451,7 @@ typedef TObj = { @:optional public var visible: Null; @:optional public var visible_mesh: Null; @:optional public var visible_shadow: Null; + @:optional public var only_shadows: Null; @:optional public var mobile: Null; @:optional public var spawn: Null; // Auto add object when creating scene @:optional public var local_only: Null; // Apply parent matrix diff --git a/Sources/iron/object/MeshObject.hx b/Sources/iron/object/MeshObject.hx index 15f1ed26..1ae9d837 100644 --- a/Sources/iron/object/MeshObject.hx +++ b/Sources/iron/object/MeshObject.hx @@ -230,7 +230,8 @@ class MeshObject extends Object { public function render(g: Graphics, context: String, bindParams: Array) { if (data == null || !data.geom.ready) return; // Data not yet streamed - if (!visible) return; // Skip render if object is hidden + if (!visible && !visibleShadow) return; // Skip render if object is hidden + if ((visibleShadow && !visible) && context != "voxel" && context != "shadowmap") return; if (cullMesh(context, Scene.active.camera, RenderPath.active.light)) return; var meshContext = raw != null ? context == "mesh" : false; From 95153bc06573fbdcd8a1661c2061280a4dc9d2db Mon Sep 17 00:00:00 2001 From: yvain Date: Tue, 13 Aug 2024 13:41:31 +0200 Subject: [PATCH 2/2] don't cull meshes on behalf of visibleShadows --- Sources/iron/Scene.hx | 1 - Sources/iron/object/MeshObject.hx | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Sources/iron/Scene.hx b/Sources/iron/Scene.hx index 2985b4a2..2f4a95a2 100644 --- a/Sources/iron/Scene.hx +++ b/Sources/iron/Scene.hx @@ -828,7 +828,6 @@ class Scene { object.raw = o; object.name = o.name; if (o.visible != null) object.visible = o.visible; - if (o.visible_mesh != null) object.visibleMesh = o.visible_mesh; if (o.visible_shadow != null) object.visibleShadow = o.visible_shadow; createConstraints(o.constraints, object); diff --git a/Sources/iron/object/MeshObject.hx b/Sources/iron/object/MeshObject.hx index 1ae9d837..d8729d29 100644 --- a/Sources/iron/object/MeshObject.hx +++ b/Sources/iron/object/MeshObject.hx @@ -161,8 +161,8 @@ class MeshObject extends Object { if (!isLodMaterial() && !validContext(mats, context)) return true; var isShadow = context == "shadowmap"; - if (!visibleMesh && !isShadow) return setCulled(isShadow, true); - if (!visibleShadow && isShadow) return setCulled(isShadow, true); + if (!visible && !isShadow) return setCulled(isShadow, true); + //if (!visibleShadow && isShadow) return setCulled(isShadow, true); if (skip_context == context) return setCulled(isShadow, true); if (force_context != null && force_context != context) return setCulled(isShadow, true);