Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Adding ARM 64-bit support without upgrading API
#3
(19-08-2019, 01:38 PM)josemendez Wrote: Hi there,

Which Obi version are you currently using? we can build a 64 bit arm version of the physics engine for that specific version. Note that copying the 4.0 library directly on a previous version won't work and will result in a DllNotFound exception.

kind regards,

I was on version 3.5 then upgraded to 4.1.

I was recently able to update to 4.1 without losing actor states. How I did this was -

- Firstly closed the Unity project window.
- Backed up, then deleted old Obi folder. Also backed up "ObiClothPicker.cs" and "ObiClothDragger.cs" from old folder, which seemed to be missing from the new version folder.
- Copied and pasted the new Obi folder in the same project location.
- Copied and pasted the two cs files previously backed up.
- This was important, I copied all the .meta files from old Obi folder into the new one, placing them next to their respective files within Obi folder.
- As I was hoping, Unity remembered the states of all previous Obi scripts as it is and hence remembered their settings (Constraints, etc.) for every already initialized actors. Tested the actors and all worked like before.
- Built the game to device and it worked as now we had the 64 bit library as well!

The only issue left now (As the particle system API has changed vastly I presume), is that I am left with about 4 errors in the ObiClothDragger class. This is the script -
Code:
using UnityEngine;

namespace Obi
{
    [RequireComponent(typeof(ObiClothPicker))]
    public class ObiClothDragger : MonoBehaviour
    {
        public float springStiffness = 50;
        public float springDamping = 1;

        private ObiClothPicker picker;
        private ObiClothPicker.ParticlePickEventArgs pickArgs;
       
       public float FingerDepthDurationFactor = 1.5f;

       void OnEnable()
        {
            picker = GetComponent<ObiClothPicker>();
            picker.OnParticlePicked += Picker_OnParticlePicked;
            picker.OnParticleDragged += Picker_OnParticleDragged;
            picker.OnParticleReleased += Picker_OnParticleReleased;
        }

        void OnDisable()
        {
            picker.OnParticlePicked -= Picker_OnParticlePicked;
            picker.OnParticleDragged -= Picker_OnParticleDragged;
            picker.OnParticleReleased -= Picker_OnParticleReleased;
       }

       void FixedUpdate()
       {
           if (pickArgs != null)
           {

               ObiSolver solver = picker.Cloth.Solver;

               // Calculate picking position in solver space:
               Vector3 targetPosition = pickArgs.worldPosition;
               if (solver.simulateInLocalSpace)
                   targetPosition = solver.transform.InverseTransformPoint(targetPosition);

               // Get particle position and velocity:
               Vector4[] positions = new Vector4[1];
               Vector4[] velocities = new Vector4[1];
               int solverIndex = picker.Cloth.particleIndices[pickArgs.particleIndex];
               Oni.GetParticlePositions(solver.OniSolver, positions, 1, solverIndex);
               Oni.GetParticleVelocities(solver.OniSolver, velocities, 1, solverIndex);

               // Calculate effective inverse mass:
               float invMass = picker.Cloth.invMasses[pickArgs.particleIndex] * picker.Cloth.areaContribution[pickArgs.particleIndex];

               if (invMass > 0)
               {
                   // Calculate and apply spring force:
                   Vector4 force = (((new Vector4(targetPosition[0], -targetPosition[1], targetPosition[2], 0) - positions[0]) * springStiffness - velocities[0] * springDamping) / (invMass)) * (picker.durationsTouch / FingerDepthDurationFactor);
                   Oni.AddParticleExternalForce(picker.Cloth.Solver.OniSolver, ref force, new int[] { solverIndex }, 1);
               }

           }
       }

       void Picker_OnParticlePicked(object sender, ObiClothPicker.ParticlePickEventArgs e)
       {
           pickArgs = e;
       }

       void Picker_OnParticleDragged(object sender, ObiClothPicker.ParticlePickEventArgs e)
       {
           pickArgs = e;
       }

       void Update()
       {
           if (Input.GetMouseButton(0))
           {
               if (picker.durationsTouch <= 0.5f)
               {
                   picker.durationsTouch += Time.deltaTime;
               }
           }
       }

       void Picker_OnParticleReleased(object sender, ObiClothPicker.ParticlePickEventArgs e)
       {
           picker.durationsTouch = 0;
           
           Oni.SetParticleVelocities(picker.Cloth.Solver.OniSolver, new Vector4[] { new Vector4(0, 12, 0, 0) }, 1, picker.Cloth.particleIndices[e.particleIndex]);

           pickArgs = null;
       }

   }
}

In the above, Unity throws 4 errors -

1. Assets\Obi\Scripts\Utils\ObiClothDragger.cs(47,21): error CS0117: 'Oni' does not contain a definition for 'GetParticlePositions'
2. Assets\Obi\Scripts\Utils\ObiClothDragger.cs(48,21): error CS0117: 'Oni' does not contain a definition for 'GetParticleVelocities'
3. Assets\Obi\Scripts\Utils\ObiClothDragger.cs(57,25): error CS0117: 'Oni' does not contain a definition for 'AddParticleExternalForce'
4. Assets\Obi\Scripts\Utils\ObiClothDragger.cs(88,17): error CS1501: No overload for method 'SetParticleVelocities' takes 4 arguments

As I am aware, in the new API you can directly access particle properties via the solver. As I am on the clock now, it would be great if I knew how to update these four lines, slightly confused with the new API help. If this script works the project has a green light ahead. 

Again, sorry for the amateur question.

Any reason why the ObiClothPicker and ObiClothDragger classes were removed in the new version?

Also, getting a 64 - bit ARM version of the plugin would be great help Just in case things go haywire with the current hacky setup.
Reply


Messages In This Thread
RE: Adding ARM 64-bit support without upgrading API - by arrnav96 - 21-08-2019, 10:56 AM