/** * Sends blueprint particle data to the solver. */ private void LoadBlueprintParticles(ObiActorBlueprint bp) { Matrix4x4 l2sTransform = actorLocalToSolverMatrix; Quaternion l2sRotation = l2sTransform.rotation; for (int i = 0; i < solverIndices.Length; i++) { int k = solverIndices[i]; if (bp.positions != null && i < bp.positions.Length) { m_Solver.startPositions[k] = m_Solver.prevPositions[k] = m_Solver.positions[k] = l2sTransform.MultiplyPoint3x4(bp.positions[i]); m_Solver.renderablePositions[k] = l2sTransform.MultiplyPoint3x4(bp.positions[i]); } if (bp.orientations != null && i < bp.orientations.Length) { m_Solver.startOrientations[k] = m_Solver.prevOrientations[k] = m_Solver.orientations[k] = l2sRotation * bp.orientations[i]; m_Solver.renderableOrientations[k] = l2sRotation * bp.orientations[i]; } if (bp.velocities != null && i < bp.velocities.Length) { m_Solver.velocities[k] = l2sTransform.MultiplyVector(bp.velocities[i]); } if (bp.angularVelocities != null && i < bp.angularVelocities.Length) { m_Solver.angularVelocities[k] = l2sTransform.MultiplyVector(bp.angularVelocities[i]); } if (bp.invMasses != null && i < bp.invMasses.Length) { m_Solver.invMasses[k] = bp.invMasses[i]; } if (bp.invRotationalMasses != null && i < bp.invRotationalMasses.Length) { m_Solver.invRotationalMasses[k] = bp.invRotationalMasses[i]; } if (bp.principalRadii != null && i < bp.principalRadii.Length) { m_Solver.principalRadii[k] = bp.principalRadii[i]; } if (bp.phases != null && i < bp.phases.Length) { m_Solver.phases[k] = Oni.MakePhase(bp.phases[i], 0); } if (bp.restPositions != null && i < bp.restPositions.Length) { m_Solver.restPositions[k] = bp.restPositions[i]; } if (bp.restOrientations != null && i < bp.restOrientations.Length) { m_Solver.restOrientations[k] = bp.restOrientations[i]; } if (bp.colors != null && i < bp.colors.Length) { m_Solver.colors[k] = bp.colors[i]; } } m_ActiveParticleCount = blueprint.activeParticleCount; m_Solver.activeParticleCountChanged = true; // Push active particles to the solver: m_Solver.PushActiveParticles(); // Recalculate inertia tensors (shape matching constraints rest shape need up to date inertia tensors, for instance). Oni.RecalculateInertiaTensors(m_Solver.OniSolver); // Push collision materials: PushCollisionMaterial(); }