Ejemplo n.º 1
0
 /// <summary>
 /// Adds this actor to its solver, if any. Automatically called by <see cref="ObiSolver"/>.
 /// </summary>
 public void AddToSolver()
 {
     if (m_Solver != null)
     {
         if (!m_Solver.AddActor(this))
         {
             m_Solver = null;
         }
         else if (sourceBlueprint != null)
         {
             sourceBlueprint.OnBlueprintGenerate += OnBlueprintRegenerate;
         }
     }
 }
Ejemplo n.º 2
0
 public void AddToSolver()
 {
     if (m_Solver != null)
     {
         m_Solver.Initialize();
         if (!m_Solver.AddActor(this))
         {
             m_Solver = null;
         }
         else if (blueprint != null)
         {
             blueprint.OnBlueprintGenerate += OnBlueprintRegenerate;
         }
     }
 }
Ejemplo n.º 3
0
        /**
         * Adds this actor to a solver. No simulation will take place for this actor
         * unless it has been added to a solver. Returns true if the actor was succesfully added,
         * false if it was already added or couldn't add it for any other reason.
         */
        public virtual bool AddToSolver(object info)
        {
            if (solver != null && Initialized && !InSolver)
            {
                // Allocate particles in the solver:
                if (!solver.AddActor(this, positions.Length))
                {
                    Debug.LogWarning("Obi: Solver could not allocate enough particles for this actor. Please increase max particles.");
                    return(false);
                }

                inSolver = true;

                // Update particle phases before sending data to the solver, as layers/flags settings might have changed.
                UpdateParticlePhases();

                // find our offset in the deformable triangles array.
                trianglesOffset = Oni.GetDeformableTriangleCount(solver.OniSolver);

                // Send deformable triangle indices to the solver:
                UpdateDeformableTriangles();

                // Send our particle data to the solver:
                PushDataToSolver(ParticleData.ALL);

                // Add constraints to solver:
                LazyBuildConstraintComponentCache();
                foreach (ObiBatchedConstraints c in constraints)
                {
                    if (c != null)
                    {
                        c.AddToSolver(null);
                    }
                }

                if (OnAddedToSolver != null)
                {
                    OnAddedToSolver(this, new ObiActorSolverArgs(solver));
                }

                return(true);
            }

            return(false);
        }