/// <summary> /// Copies values from source instance. /// </summary> /// <param name="source">Source instance to copy values from.</param> public void CopyFrom(MassProperties source) { m_mass.CopyFrom(source.m_mass); m_inertiaDiagonal.CopyFrom(source.m_inertiaDiagonal); m_massCoefficients = source.m_massCoefficients; m_inertiaCoefficients = source.m_inertiaCoefficients; }
/// <summary> /// Updates mass properties script asset with current mass, inertia etc. /// </summary> public void UpdateMassProperties() { PeekTemporaryNativeOrGetNative((rb, isTemp) => { if (!isTemp) { rb.updateMassProperties(); } MassProperties.SetDefaultCalculated(rb); }); }
public void RestoreLocalDataFrom(agx.RigidBody native) { if (native == null) { throw new ArgumentNullException("native", "Native object is null."); } MassProperties.RestoreLocalDataFrom(native.getMassProperties()); enabled = native.getEnable(); MotionControl = native.getMotionControl(); HandleAsParticle = native.getHandleAsParticle(); LinearVelocity = native.getVelocity().ToHandedVector3(); LinearVelocityDamping = native.getLinearVelocityDamping().ToHandedVector3(); AngularVelocity = native.getAngularVelocity().ToHandedVector3(); AngularVelocityDamping = native.getAngularVelocityDamping().ToHandedVector3(); }
public bool PatchMassPropertiesAsComponent() { // Already have mass properties as component - this instance has been patched. if (GetComponent <MassProperties>() != null) { return(false); } MassProperties mp = gameObject.AddComponent <MassProperties>(); if (m_massPropertiesAsAsset != null) { mp.CopyFrom(m_massPropertiesAsAsset); DestroyImmediate(m_massPropertiesAsAsset); m_massPropertiesAsAsset = null; } return(true); }