diff --git a/zzre/game/systems/effect/MovingPlanes.cs b/zzre/game/systems/effect/MovingPlanes.cs index 0448f5d9..bc0c0b04 100644 --- a/zzre/game/systems/effect/MovingPlanes.cs +++ b/zzre/game/systems/effect/MovingPlanes.cs @@ -21,7 +21,8 @@ protected override void HandleAddedComponent(in DefaultEcs.Entity entity, in zzi { var playback = entity.Get().Entity.Get(); var vertexRange = effectMesh.RentVertices(data.disableSecondPlane ? 4 : 8); - var indexRange = effectMesh.RentQuadIndices(vertexRange); + var isBillboard = !data.circlesAround && !data.useDirection; + var indexRange = effectMesh.RentQuadIndices(vertexRange, doubleSided: !isBillboard); entity.Set(new components.effect.MovingPlanesState( vertexRange, indexRange, @@ -30,13 +31,10 @@ protected override void HandleAddedComponent(in DefaultEcs.Entity entity, in zzi PrevProgress = playback.CurProgress }); Reset(ref entity.Get(), data); - - var billboardMode = data.circlesAround || data.useDirection - ? EffectMaterial.BillboardMode.None - : EffectMaterial.BillboardMode.View; + assetRegistry.LoadEffectMaterial(entity, data.texName, - billboardMode, + isBillboard ? EffectMaterial.BillboardMode.View : EffectMaterial.BillboardMode.None, data.renderMode, playback.DepthTest); entity.Set(new components.effect.RenderIndices(indexRange)); @@ -114,9 +112,8 @@ private static void AddScale( float amount) { var shouldGrow = data.targetSize > data.width; - var curSize = new Vector2(data.width, data.height) * state.CurScale; - if ((shouldGrow && curSize.MaxComponent() < data.targetSize) || - (!shouldGrow && curSize.MinComponent() > data.targetSize)) + if ((shouldGrow && state.CurScale < data.targetSize) || + (!shouldGrow && state.CurScale > data.targetSize)) state.CurScale += amount; } @@ -161,18 +158,17 @@ private void UpdateQuad( else if (data.useDirection) { // what even is this rotation, only used in e5021... - var dir = location.GlobalForward; + var dir = location.InnerForward; var rotUp = Vector3.Cross(dir, Vector3.One * 0.42340001f); var rotRight = Vector3.Cross(dir, rotUp); var rotForward = Vector3.Cross(rotUp, rotRight); - var rotMatrix = new Matrix4x4( + var rotMatrix = Matrix4x4.CreateFromAxisAngle(Vector3.UnitZ, angle) * new Matrix4x4( rotRight.X, rotRight.Y, rotRight.Z, 0f, rotUp.X, rotUp.Y, rotUp.Z, 0f, rotForward.X, rotForward.Y, rotForward.Z, 0f, 0f, 0f, 0f, 1f); - rotMatrix = Matrix4x4.Transform(rotMatrix, Quaternion.CreateFromAxisAngle(Vector3.UnitZ, angle)); - right = Vector3.Transform(Vector3.UnitX * w, rotMatrix); - up = Vector3.Transform(Vector3.UnitY * h, rotMatrix); + right = Vector3.TransformNormal(Vector3.UnitX * w, rotMatrix); + up = Vector3.TransformNormal(Vector3.UnitY * h, rotMatrix); } else { diff --git a/zzre/materials/EffectMaterial.cs b/zzre/materials/EffectMaterial.cs index b3968eb9..faaed6a5 100644 --- a/zzre/materials/EffectMaterial.cs +++ b/zzre/materials/EffectMaterial.cs @@ -96,9 +96,12 @@ public Range RentPatternIndices(Range vertexRange, IReadOnlyList pattern return indexRange; } - private static readonly ushort[] QuadIndexPattern = [0, 2, 1, 0, 3, 2]; - public Range RentQuadIndices(Range vertexRange) => - RentPatternIndices(vertexRange, QuadIndexPattern); + private static readonly ushort[] SingleSidedQuadIndexPattern = [0, 2, 1, 0, 3, 2]; + private static readonly ushort[] DoubleSidedQuadIndexPattern = [0, 2, 1, 0, 3, 2, 0, 1, 2, 0, 2, 3]; + public Range RentQuadIndices(Range vertexRange, bool doubleSided = false) => + RentPatternIndices(vertexRange, doubleSided + ? DoubleSidedQuadIndexPattern + : SingleSidedQuadIndexPattern); public void SetQuad(Range vertexRange, int offset, bool applyCenter, Vector3 center, Vector3 right, Vector3 up, IColor color, Rect texCoords) { diff --git a/zzre/tools/ECSExplorer/ECSExplorer.Standard.cs b/zzre/tools/ECSExplorer/ECSExplorer.Standard.cs index 733bdf3e..fc1d35bf 100644 --- a/zzre/tools/ECSExplorer/ECSExplorer.Standard.cs +++ b/zzre/tools/ECSExplorer/ECSExplorer.Standard.cs @@ -6,9 +6,7 @@ using zzio; using zzio.db; using zzio.scn; -using DefaultEcs.Resource; -using EffectCombinerResource = DefaultEcs.Resource.ManagedResource; using zzre.game.components.effect; namespace zzre.tools; @@ -40,7 +38,7 @@ private static void AddStandardEntityNaming() AddEntityNamerByComponent(Highest, e => $"CollectionFairy \"{e.Get().name}\" {e}"); AddEntityNamerByComponent(Highest, e => $"LensFlare {e}"); - AddEntityNamerByComponent(Highest, (e, c) => $"EffectCombiner {c.Info} {e}"); + AddEntityNamerByComponent(Highest, (e, c) => $"EffectCombiner {c.description} {e}"); AddEntityNamerByComponent(Highest, (e, c) => $"BeamStar {c.Name} {e}"); AddEntityNamerByComponent(Highest, (e, c) => $"ElectricBolt {c.Name} {e}"); AddEntityNamerByComponent(Highest, (e, c) => $"Models {c.Name} {e}"); @@ -67,7 +65,6 @@ private static void AddStandardEntityNaming() AddEntityNamer(High, e => e.Has() || !e.TryGet(out var res) ? null : $"Preload {(res.IsFont ? "font" : "tilesheet")} {res.Name}"); - AddEntityNamer(Def, e => e.Has() || !e.TryGet>(out var res) ? null : $"Preload bitmap {res.Info}"); AddEntityNamerByComponent(High, e => $"Button #{e.TryGet().GetValueOrDefault(default).Value} {e}"); AddEntityNamerByComponent(High, e => $"Tooltip Target {e}"); AddEntityNamerByComponent(High, e => $"Fade {e}"); @@ -101,7 +98,7 @@ private static void AddStandardEntityGrouping() AddEntityGrouperByComponent(1000, Animals); AddEntityGrouperByComponent(1000, Animals); AddEntityGrouperByComponent(1000, Animals); - AddEntityGrouperByComponent(1000, Effects); + AddEntityGrouperByComponent(1000, Effects); AddEntityGrouperByComponent(1000, Effects); AddEntityGrouperByComponent(0, Models); AddEntityGrouperByComponent(-1, Triggers);