From b3ae4e889872ca0b9ca76f1d17b2f0b961226729 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 05 Aug 2019 21:48:55 -0400
Subject: [PATCH] Fix physics UI

---
 Mocap.java |   88 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 69 insertions(+), 19 deletions(-)

diff --git a/Mocap.java b/Mocap.java
index 0bbe7d9..aa11165 100644
--- a/Mocap.java
+++ b/Mocap.java
@@ -261,6 +261,8 @@
         
 //    LA.matConcat(toParent, hip.get(0).toParent, toParent);
         
+        CameraPane.CreateSelectedPoint();
+        
         CameraPane.debugpointG.toParent[3][0] = poship.x;
         CameraPane.debugpointG.toParent[3][1] = poship.y;
         CameraPane.debugpointG.toParent[3][2] = poship.z;        
@@ -484,6 +486,12 @@
     {
         Object3D hip = get(0);
         
+        if (toParent == null)
+        {
+            toParent = LA.newMatrix();
+            fromParent = LA.newMatrix();
+        }
+        
         LA.matConcat(toParent, hip.get(0).toParent, matrix);
         
         mocaporigin.x = matrix[3][0];
@@ -495,6 +503,7 @@
         centroid.z = matrix[3][2];
 //        this.getCentroid(centroid, true);
         
+        CameraPane.CreateSelectedPoint();
         CameraPane.debugpointG.name = "";
         CameraPane.debugpointG.toParent[3][0] = mocaporigin.x;
         CameraPane.debugpointG.toParent[3][1] = mocaporigin.y;
@@ -638,6 +647,24 @@
 //    transient // aout 2013
             Object3D skeleton;
     
+    void ExtractBigData(Object3D o)
+    {
+        super.ExtractBigData(o);
+        
+        o.savebvh = this.bvh;
+        o.saveskeleton = this.skeleton;
+        this.bvh = null;
+        this.skeleton = null;
+    }
+
+    void RestoreBigData(Object3D o)
+    {
+        super.RestoreBigData(o);
+        
+        this.bvh = o.savebvh;
+        this.skeleton = o.saveskeleton;
+    }
+    
     boolean smoothed;
     
     //boolean touched;
@@ -664,8 +691,8 @@
     double targetdirx;
     double targetdirz;
     
-    double goalposx = -20;
-    double goalposz = -10;
+    double goalposx = 0; // -20;
+    double goalposz = 0; // -10;
     
     boolean followpath;
     
@@ -921,7 +948,7 @@
 //                    //GetFileRoot();
                   
                     // sept 2014: //
-                    GrafreeD.RENDERME = 3; // patch for Merge objects
+                    Grafreed.RENDERME = 3; // patch for Merge objects
                     float[] thedata = bvh.animation.getBoneData(0);
                     
                     os.x = (float) (path.get(i).toParent[3][0]); // - thedata[frame*6]);
@@ -1566,7 +1593,7 @@
 
                         lastsoundtime = Globals.framecount;
                         
-                        GrafreeD.hassound = true;
+                        Grafreed.hassound = true;
                     }
 //                    else
 //                        System.out.println("skipped");
@@ -2797,7 +2824,8 @@
                 //if (bone._rotationEnabled)
                 if (//frame > 0 &&
                     !bone.skipmocap &&
-                    !bone.name.contains("head") // &&
+                    !bone.name.contains("head") &&
+                    !bone.name.contains("Head") // &&
                  //   !bone.name.contains("rFoot") &&
                  //   !bone.name.contains("lFoot") &&
 //                    !bone.name.contains("Pinky") &&
@@ -3233,8 +3261,8 @@
         
 // aout 2013        endframe = 0; // june 2013
         
-        //ResetZero();
-        setPose(frame);
+        ResetZero();
+        //setPose(frame);
     }
     
     static int mocapsupport = 0;
@@ -3299,23 +3327,40 @@
 //            SetPositionDelta(false, true, false); // ?? false);
             {
                 if (support == null)
-                    ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
+                {
+                    if (bvh == null && new File(fullname).exists())
+                            ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
+                    else
+                    {
+                            SetGlobalTransform();
+                            Rewind();
+                            Fade();
+                    }
+                }
                 else
                 {
-                    try
-                    {
+//                    try
+//                    {
                         bvh = ((Mocap)support.get(mocapsupport++ % support.Size())).bvh;
 
                         // SetPositionDelta(false, true, true, true);
                         LoadData();
                         Rewind();
                         Fade();
-                    }
-                    catch (Exception e)
-                    {
-                        e.printStackTrace();
-                        ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
-                    }
+//                    }
+//                    catch (Exception e)
+//                    {
+//                            System.err.println("An error occured while loading data. Use fallback by loading the file.");
+//                        //e.printStackTrace();
+//                            try
+//                            {
+//                                    ObjEditor.LoadBVHFile(fullname, this, false, beginframe, lastframetest);
+//                            }
+//                            catch (Exception e2)
+//                            {
+//                                    System.err.println("Motion file not found: " + fullname);
+//                            }
+//                    }
                 }
             }
             
@@ -3872,17 +3917,22 @@
      //   if (firstframe)
      //       return;
         
-        if (!restarted && /*display.restartframe &&*/
-                Globals.isLIVE() && live && display.DrawMode() == display.SHADOW) // FUCK
+        if (//!restarted && /*display.restartframe &&*/
+                Globals.isLIVE() && live && (display.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE))
         {
             //display.restartframe = false;
             restarted = true;
+        //System.err.println("restarted = true");
             Step();
         }
         else
         {
-            if (Globals.isLIVE() && live && display.DrawMode() != display.SHADOW)
+        //System.err.println("restarted");
+            if (Globals.isLIVE() && live && display.DrawMode() != iCameraPane.SHADOW)
+            {
                 restarted = false;
+        //System.err.println("restarted = false");
+            }
         }
         
         super.drawSelf(display, root, selected, blocked);

--
Gitblit v1.6.2