Skip to content

Commit

Permalink
fix(SnapDropZone): prioritise joint removal on highlight object
Browse files Browse the repository at this point in the history
If the interactable object that is being used as the highlight object
template has a joint on it, then it would cause issues due to the
rigidbody attempting to be removed first which would then fail because
a Joint was present. This would cause the snap drop zone highlight
object to keep it's rigidbody and fall will the physics gravity when
the scene started.
  • Loading branch information
virror committed Sep 28, 2017
1 parent 3ee39e1 commit 99f19cd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Assets/VRTK/Prefabs/Internal/Scripts/VRTK_SnapDropZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,14 @@ protected virtual void CleanHighlightObject(GameObject objectToClean)
//determine components that shouldn't be deleted from highlight object
string[] validComponents = new string[] { "Transform", "MeshFilter", "MeshRenderer", "SkinnedMeshRenderer", "VRTK_GameObjectLinker" };

//go through all of the components on the highlighted object and delete any components that aren't in the valid component list
//First clean out the joints cause RigidBodys depends on them.
Joint[] joints = objectToClean.GetComponentsInChildren<Joint>(true);
for (int i = 0; i < joints.Length; i++)
{
ChooseDestroyType(joints[i]);
}

//Go through all of the components on the highlighted object and delete any components that aren't in the valid component list
Component[] components = objectToClean.GetComponentsInChildren<Component>(true);
for (int i = 0; i < components.Length; i++)
{
Expand Down

0 comments on commit 99f19cd

Please sign in to comment.