コード例 #1
0
        public OniConstraintsBatchImpl(IConstraints constraints, Oni.ConstraintType type)
        {
            this.m_Constraints    = constraints;
            this.m_ConstraintType = type;

            m_OniBatch = Oni.CreateBatch((int)type);
        }
コード例 #2
0
        public override void Cook()
        {
            batch = Oni.CreateBatch((int)Oni.ConstraintType.Bending, true);

            // Send initial data to batch:
            Oni.SetBendingConstraints(batch, bendingIndices.ToArray(), restBends.ToArray(), bendingStiffnesses.ToArray(), ConstraintCount);

            // cook the batch and retrieve new sorted data:
            if (Oni.CookBatch(batch))
            {
                constraintCount   = Oni.GetBatchConstraintCount(batch);
                activeConstraints = Enumerable.Range(0, constraintCount).ToList();

                int[]     cookedIndices     = new int[constraintCount * 3];
                float[]   cookedRestLengths = new float[constraintCount];
                Vector2[] cookedStiffnesses = new Vector2[constraintCount];

                Oni.GetBendingConstraints(batch, cookedIndices, cookedRestLengths, cookedStiffnesses);

                bendingIndices     = new List <int>(cookedIndices);
                restBends          = new List <float>(cookedRestLengths);
                bendingStiffnesses = new List <Vector2>(cookedStiffnesses);

                int   phaseCount = Oni.GetBatchPhaseCount(batch);
                int[] phases     = new int[phaseCount];
                Oni.GetBatchPhaseSizes(batch, phases);
                this.phaseSizes = new List <int>(phases);
            }

            Oni.DestroyBatch(batch);
            batch = IntPtr.Zero;
        }
コード例 #3
0
        public void AddToSolver(IObiConstraints constraints)
        {
            // create a constraint batch:
            batch = Oni.CreateBatch((int)constraintType);
            Oni.AddBatch(constraints.GetActor().solver.OniSolver, batch);

            OnAddToSolver(constraints);
        }
コード例 #4
0
        public void AddToSolver(ObiBatchedConstraints constraints)
        {
            // create a constraint batch:
            batch = Oni.CreateBatch((int)GetConstraintType(), cooked);
            Oni.AddBatch(constraints.Actor.Solver.OniSolver, batch, sharesParticles);

            // custom stuff:
            OnAddToSolver(constraints);
        }
コード例 #5
0
        private void AddToSolver()
        {
            // create a constraint batch:
            batch = Oni.CreateBatch((int)Oni.ConstraintType.Stitch);
            Oni.AddBatch(actor1.solver.OniSolver, batch);

            inSolver = true;

            // push current data to solver:
            PushDataToSolver();

            // enable/disable the batch:
            if (isActiveAndEnabled)
            {
                OnEnable();
            }
            else
            {
                OnDisable();
            }
        }
コード例 #6
0
ファイル: ObiStitcher.cs プロジェクト: usernameHed/BackHome
        public bool AddToSolver(object info)
        {
            // create a constraint batch:
            batch = Oni.CreateBatch((int)Oni.ConstraintType.Stitch, false);
            Oni.AddBatch(actor1.Solver.OniSolver, batch, false);

            inSolver = true;

            // push current data to solver:
            PushDataToSolver(ParticleData.NONE);

            // enable/disable the batch:
            if (isActiveAndEnabled)
            {
                OnEnable();
            }
            else
            {
                OnDisable();
            }

            return(true);
        }
コード例 #7
0
        public override void Cook()
        {
            batch = Oni.CreateBatch((int)Oni.ConstraintType.Skin, true);

            // Send initial data to batch:
            Oni.SetSkinConstraints(batch, skinIndices.ToArray(), skinPoints.ToArray(), skinNormals.ToArray(), skinRadiiBackstop.ToArray(), skinStiffnesses.ToArray(), ConstraintCount);

            // cook the batch and retrieve new sorted data:
            if (Oni.CookBatch(batch))
            {
                constraintCount   = Oni.GetBatchConstraintCount(batch);
                activeConstraints = Enumerable.Range(0, constraintCount).ToList();

                int[]     cookedIndices       = new int[constraintCount];
                Vector4[] cookedPoints        = new Vector4[constraintCount];
                Vector4[] cookedNormals       = new Vector4[constraintCount];
                float[]   cookedRadiiBackstop = new float[constraintCount * 3];
                float[]   cookedStiffnesses   = new float[constraintCount];

                Oni.GetSkinConstraints(batch, cookedIndices, cookedPoints, cookedNormals, cookedRadiiBackstop, cookedStiffnesses);

                skinIndices       = new List <int>(cookedIndices);
                skinPoints        = new List <Vector4>(cookedPoints);
                skinNormals       = new List <Vector4>(cookedNormals);
                skinRadiiBackstop = new List <float>(cookedRadiiBackstop);
                skinStiffnesses   = new List <float>(cookedStiffnesses);

                int   phaseCount = Oni.GetBatchPhaseCount(batch);
                int[] phases     = new int[phaseCount];
                Oni.GetBatchPhaseSizes(batch, phases);
                this.phaseSizes = new List <int>(phases);
            }

            Oni.DestroyBatch(batch);
            batch = IntPtr.Zero;
        }