Пример #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 IObiConstraints GetConstraintsByType(Oni.ConstraintType type)
        {
            switch (type)
            {
            case Oni.ConstraintType.Distance: return(distanceConstraintsData);

            case Oni.ConstraintType.Bending: return(bendConstraintsData);

            case Oni.ConstraintType.Pin: return(pinConstraintsData);

            case Oni.ConstraintType.Skin: return(skinConstraintsData);

            case Oni.ConstraintType.Tether: return(tetherConstraintsData);

            case Oni.ConstraintType.BendTwist: return(bendTwistConstraintsData);

            case Oni.ConstraintType.StretchShear: return(stretchShearConstraintsData);

            case Oni.ConstraintType.ShapeMatching: return(shapeMatchingConstraintsData);

            case Oni.ConstraintType.Aerodynamics: return(aerodynamicConstraintsData);

            case Oni.ConstraintType.Chain: return(chainConstraintsData);

            case Oni.ConstraintType.Volume: return(volumeConstraintsData);

            default: return(null);
            }
        }
Пример #3
0
 /// <summary>
 /// Marks a given constraint type as dirty.
 /// </summary>
 /// <param name="constraintType"> Type of the constraints that need re-creation.</param>
 /// This will cause the solver to perform a constraint re-creation at the start of the next step. Needed when the constraint data in an actor changes at runtime,
 /// as a result of changing topology (torn cloth or ropes), or changes in internal constraint parameters such as compliance values. This is a relatively expensive operation,
 /// so it's best to amortize as many constraint modification operations as possible in a single step.
 public void SetConstraintsDirty(Oni.ConstraintType constraintType)
 {
     if (m_Solver != null)
     {
         m_Solver.dirtyConstraints |= (1 << (int)constraintType);
     }
 }
Пример #4
0
 public int GetConstraintCount(Oni.ConstraintType type)
 {
     if ((int)type > 0 && (int)type < constraints.Length)
     {
         return(constraints[(int)type].GetConstraintCount());
     }
     return(0);
 }
Пример #5
0
        public IObiConstraints GetConstraintsByType(Oni.ConstraintType type)
        {
            int index = (int)type;

            if (m_Constraints != null && index >= 0 && index < m_Constraints.Length)
            {
                return(m_Constraints[index]);
            }
            return(null);
        }
Пример #6
0
        /**
         * Returns constraints component of a given type. Will cache components if needed (usually upon first call, or if the cache is empty).
         */
        protected ObiBatchedConstraints GetConstraints(Oni.ConstraintType constraintType)
        {
            LazyBuildConstraintComponentCache();

            int index = (int)constraintType;

            if (index >= 0 && index < constraints.Length)
            {
                return(constraints[index]);
            }
            return(null);
        }
Пример #7
0
 public int GetConstraintCount(Oni.ConstraintType type)
 {
     if ((int)type > 0 && (int)type < constraints.Length)
     {
         int count = 0;
         for (int i = 0; i < constraints[(int)type].Count; ++i)
         {
             count += constraints[(int)type][i].GetConstraintCount();
         }
         return(count);
     }
     return(0);
 }
Пример #8
0
        /// <summary>
        /// Returns the data representation of constraints of a given type being simulated by this solver.
        /// </summary>
        /// <param name="type"> Type of the constraints that will be returned by this method.</param>
        /// <returns>
        /// The runtime constraints of the type speficied. Most constraints are stored in the blueprint, with a couple notable exceptions: pin and stitch constraints
        /// are always created at runtime, so they're not stored in the blueprint but in the actor itself.
        /// </returns>
        public IObiConstraints GetConstraintsByType(Oni.ConstraintType type)
        {
            // pin constraints are a special case, because they're not stored in a blueprint. They are created at runtime at stored in the actor itself.
            if (type == Oni.ConstraintType.Pin)
            {
                return(m_PinConstraints);
            }

            if (sharedBlueprint != null)
            {
                return(sharedBlueprint.GetConstraintsByType(type));
            }

            return(null);
        }
Пример #9
0
        private JobHandle ProjectConstraints(JobHandle inputDeps, Oni.ConstraintType type, float deltaTime)
        {
            JobHandle outputDeps = inputDeps;

            // Schedule all groups in parallel:
            var group = constraints[(int)type];

            if (group != null && group.Count > 0)
            {
                NativeArray <JobHandle> deps = new NativeArray <JobHandle>(group.Count, Allocator.TempJob, NativeArrayOptions.UninitializedMemory);

                for (int i = 0; i < group.Count; ++i)
                {
                    deps[i] = group[i].Project(inputDeps, deltaTime);
                }

                outputDeps = JobHandle.CombineDependencies(deps);
                deps.Dispose();
            }

            return(outputDeps);
        }
Пример #10
0
 public IConstraintsBatchImpl CreateConstraintsBatch(Oni.ConstraintType constraintType)
 {
     return(null);
 }
Пример #11
0
 public IConstraintsBatchImpl CreateConstraintsBatch(Oni.ConstraintType type)
 {
     return(constraints[(int)type].CreateConstraintsBatch());
 }
Пример #12
0
 public void SetConstraintGroupParameters(Oni.ConstraintType type, ref Oni.ConstraintParameters parameters)
 {
     // No need to implement. This backend grabs parameters from the abstraction when it needs them.
 }
Пример #13
0
 public void SetConstraintGroupParameters(Oni.ConstraintType type, ref Oni.ConstraintParameters parameters)
 {
 }
Пример #14
0
 public int GetConstraintCount(Oni.ConstraintType type)
 {
     return(0);
 }
Пример #15
0
 public OniConstraintsImpl(OniSolverImpl solver, Oni.ConstraintType constraintType)
 {
     m_ConstraintType = constraintType;
     m_Solver         = solver;
 }
Пример #16
0
 public BurstConstraintsImpl(BurstSolverImpl solver, Oni.ConstraintType constraintType)
 {
     this.m_ConstraintType = constraintType;
     this.m_Solver         = solver;
 }
Пример #17
0
 public void SetConstraintGroupParameters(Oni.ConstraintType type, ref Oni.ConstraintParameters parameters)
 {
     Oni.SetConstraintGroupParameters(m_OniSolver, (int)type, ref parameters);
 }
Пример #18
0
 public int GetConstraintCount(Oni.ConstraintType type)
 {
     return(Oni.GetConstraintCount(m_OniSolver, (int)type));
 }