Преглед изворни кода

Add constant dragpoint scale for dragdogu

dragpoint size is constant regardless of camera distance
habeebweeb пре 4 година
родитељ
комит
a5b5000cec

+ 11 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/DragDogu.cs

@@ -21,15 +21,15 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public bool keepDogu = false;
         public float scaleFactor = 1f;
 
-        public void Initialize(GameObject dogu, bool keepDogu = false)
+        public DragDogu Initialize(GameObject dogu, bool keepDogu = false)
         {
-            Initialize(dogu, keepDogu, GizmoMode.World,
+            return Initialize(dogu, keepDogu, GizmoMode.World,
                 () => this.Dogu.transform.position,
                 () => Vector3.zero
             );
         }
 
-        public void Initialize(GameObject dogu, bool keepDogu, GizmoMode mode,
+        public DragDogu Initialize(GameObject dogu, bool keepDogu, GizmoMode mode,
             Func<Vector3> position, Func<Vector3> rotation
         )
         {
@@ -44,6 +44,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                     OnRotate();
                 }
             };
+            return this;
+        }
+
+        protected override void Update()
+        {
+            float distance = Vector3.Distance(Camera.main.transform.position, transform.position);
+            transform.localScale = Vector3.one * (0.4f * InitialScale.x * DragPointScale * distance);
+            base.Update();
         }
 
         protected override void GetDragType()

+ 1 - 2
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MPSLight.cs

@@ -134,8 +134,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             DragLight = BaseDrag.MakeDragPoint<DragDogu>(
                 PrimitiveType.Cube, Vector3.one * 0.12f, BaseDrag.LightBlue
-            );
-            DragLight.Initialize(this.light.gameObject, this.IsMain, CustomGizmo.GizmoMode.World,
+            ).Initialize(this.light.gameObject, this.IsMain, CustomGizmo.GizmoMode.World,
                 () => this.light.transform.position,
                 () => this.light.transform.eulerAngles
             );

+ 11 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/DragPointManager.cs

@@ -220,6 +220,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             BoneTransform.Clear();
             DragPoint.Clear();
             CubeSmallChange -= OnCubeSmall;
+            CubeActiveChange -= OnCubeSmall;
         }
 
         public void Update()
@@ -277,6 +278,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             this.Active = true;
             this.SetBoneMode(false);
             CubeSmallChange += OnCubeSmall;
+            CubeActiveChange += OnCubeActive;
         }
 
         private void SetBoneMode(bool active)
@@ -379,7 +381,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         private void OnCubeSmall(object sender, EventArgs args)
         {
             DragBody dragPoint = (DragBody)DragPoint[Bone.Cube];
-            dragPoint.DragPointScale = dragPoint.BaseScale * (CubeSmall ? 0.4f : 1f);
+            dragPoint.DragPointScale = CubeSmall ? 0.4f : 1f;
+        }
+
+        private void OnCubeActive(object sender, EventArgs args)
+        {
+            DragPoint[Bone.Cube].SetDragProp(CubeActive, CubeActive, CubeActive);
+            DragPoint[Bone.Cube].gameObject.SetActive(CubeActive);
         }
 
         private void OnSelectFace(object sender, EventArgs args)
@@ -408,7 +416,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 if (kvp.Key == Bone.Cube) continue;
                 BaseDrag dragPoint = kvp.Value;
-                dragPoint.DragPointScale = dragPoint.BaseScale * scale;
+                dragPoint.DragPointScale = scale;
             }
         }
 
@@ -468,7 +476,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 PrimitiveType.Cube, Vector3.one * 0.12f, BaseDrag.Blue
             ).Initialize(meido,
                 () => maid.transform.position,
-                () => maid.transform.eulerAngles
+                () => Vector3.zero
             );
             DragBody dragCube = (DragBody)DragPoint[Bone.Cube];
             dragCube.Scale += OnSetDragPointScale;

+ 3 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/EnvironmentManager.cs

@@ -73,9 +73,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             bgDragPoint = BaseDrag.MakeDragPoint<DragDogu>(
                 PrimitiveType.Cube, Vector3.one * 0.12f, BaseDrag.LightBlue
-            );
-            bgDragPoint.Initialize(bgObject, true);
+            ).Initialize(bgObject, true);
             bgDragPoint.SetDragProp(false, false, false);
+            bgDragPoint.DragPointScale = CubeSmall ? 0.4f : 1f;
 
             cameraObject = new GameObject("subCamera");
             subCamera = cameraObject.AddComponent<Camera>();
@@ -216,7 +216,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         private void OnCubeSmall(object sender, EventArgs args)
         {
-            this.bgDragPoint.DragPointScale = this.bgDragPoint.BaseScale * (CubeSmall ? 0.4f : 1f);
+            this.bgDragPoint.DragPointScale = CubeSmall ? 0.4f : 1f;
         }
     }
 

+ 4 - 5
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/PropManager.cs

@@ -153,7 +153,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                     dogu = GameObject.Instantiate(obj);
                     doguPosition = Vector3.zero;
                     doguScale = Vector3.one * 0.1f;
-                    doguName = Translation.Get("bgNames", "assetName");
+                    doguName = Translation.Get("bgNames", assetName);
                 }
 
             }
@@ -278,12 +278,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
                 DragDogu dragDogu = BaseDrag.MakeDragPoint<DragDogu>(
                     PrimitiveType.Cube, Vector3.one * 0.12f, BaseDrag.LightBlue
-                );
-                dragDogu.Initialize(finalDogu);
+                ).Initialize(finalDogu);
                 dragDogu.Delete += DeleteDogu;
                 dragDogu.SetDragProp(showGizmos, false, false);
                 doguList.Add(dragDogu);
-                dragDogu.DragPointScale = dragDogu.BaseScale * (CubeSmall ? 0.4f : 1f);
+                dragDogu.DragPointScale = CubeSmall ? 0.4f : 1f;
                 OnDoguListChange();
             }
             else
@@ -381,7 +380,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             foreach (DragDogu dogu in doguList)
             {
-                dogu.DragPointScale = dogu.BaseScale * (CubeSmall ? 0.4f : 1f);
+                dogu.DragPointScale = CubeSmall ? 0.4f : 1f;
             }
         }
 

+ 7 - 5
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/BaseDrag.cs

@@ -49,13 +49,15 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 }
             }
         }
-        public Vector3 BaseScale { get; private set; }
-        public Vector3 DragPointScale
+        public Vector3 InitialScale { get; private set; }
+        private float dragPointScale = 1f;
+        public float DragPointScale
         {
-            get => transform.localScale;
+            get => dragPointScale;
             set
             {
-                transform.localScale = value;
+                dragPointScale = value;
+                transform.localScale = InitialScale * dragPointScale;
             }
         }
         public bool IsBone { get; set; }
@@ -158,7 +160,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected void InitializeDragPoint(Func<Vector3> position, Func<Vector3> rotation)
         {
-            this.BaseScale = transform.localScale;
+            this.InitialScale = transform.localScale;
             this.position = position;
             this.rotation = rotation;
             this.dragPointRenderer = GetComponent<Renderer>();

+ 2 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragBody.cs

@@ -3,6 +3,7 @@ using UnityEngine;
 
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
+    using static CustomGizmo;
     internal class DragBody : BaseDrag
     {
         private Vector3 off;
@@ -39,6 +40,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 CurrentDragType = DragType.None;
             }
         }
+
         protected override void InitializeDrag()
         {
             if (CurrentDragType == DragType.Select)

+ 1 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/IK/DragHead.cs

@@ -50,6 +50,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 CurrentDragType = DragType.None;
             }
         }
+
         protected override void DoubleClick()
         {
             if (CurrentDragType == DragType.MoveXZ || CurrentDragType == DragType.MoveY)