public ObiConstraints(ObiActor actor = null, ObiConstraints <T> source = null) { this.actor = actor; this.source = source; if (source != null) { foreach (T batch in source.batches) { AddBatch(batch.Clone(this) as T); } } }
public bool AddToSolver(object info) { if (inSolver || actor == null || !actor.InSolver) { return(false); } // Calculate our constraint offset: constraintOffset = 0; for (int i = 0; i < actor.actorID; i++) { ObiConstraints c = actor.Solver.actors[i].GetComponent(GetType()) as ObiConstraints; if (c != null) { constraintOffset += c.ConstraintCount; } } // custom addition code: OnAddToSolver(info); inSolver = true; // push data to solver: PushDataToSolver(GetParticleDataFlags()); // update constraints if enabled, deactivate all constraints otherwise. if (enabled) { UpdateConstraintActiveStatus(); } else { Oni.DeactivateConstraints(actor.Solver.OniSolver, (int)GetConstraintType(), Enumerable.Range(constraintOffset, constraintOffset + ConstraintCount).ToArray(), ConstraintCount); } return(true); }
public bool RemoveFromSolver(object info) { if (!inSolver || actor == null || !actor.InSolver) { return(false); } // Update other actor's constraint offset: for (int i = actor.actorID + 1; i < actor.Solver.actors.Count; i++) { ObiConstraints c = actor.Solver.actors[i].GetComponent(GetType()) as ObiConstraints; if (c != null) { c.constraintOffset -= ConstraintCount; } } Oni.RemoveConstraints(actor.Solver.OniSolver, (int)GetConstraintType(), ConstraintCount, constraintOffset); inSolver = false; return(true); }