public static OBB GetMeshWorldOBB(GameObject gameObject) { AABB modelAABB = CalcMeshModelAABB(gameObject); if (!modelAABB.IsValid) { return(OBB.GetInvalid()); } return(new OBB(modelAABB, gameObject.transform)); }
public static OBB CalcWorldOBB(GameObject gameObject, QueryConfig queryConfig) { AABB modelAABB = CalcModelAABB(gameObject, queryConfig, gameObject.GetGameObjectType()); if (!modelAABB.IsValid) { return(OBB.GetInvalid()); } return(new OBB(modelAABB, gameObject.transform)); }
public static OBB CalcHierarchyWorldOBB(GameObject root, QueryConfig queryConfig) { AABB modelAABB = CalcHierarchyModelAABB(root, queryConfig); if (!modelAABB.IsValid) { return(OBB.GetInvalid()); } return(new OBB(modelAABB, root.transform)); }
public OBB GetWorldSnapAreaBounds(BoxFace boxFace) { if (_gameObject == null) { return(OBB.GetInvalid()); } Transform objectTransform = _gameObject.transform; return(new OBB(_snapAreaBounds[(int)boxFace], objectTransform)); }
public void FitBoxToTargets() { if (NumTargetParents == 0) { _boxSize = Vector3.zero; return; } if (ExtrudeSpace == GizmoSpace.Global) { AABB worldAABB = AABB.GetInvalid(); foreach (var parent in _targetParents) { if (_ignoredParentObjects.Contains(parent)) { continue; } AABB aabb = ObjectBounds.CalcHierarchyWorldAABB(parent, _boundsQConfig); if (aabb.IsValid) { if (worldAABB.IsValid) { worldAABB.Encapsulate(aabb); } else { worldAABB = aabb; } } } SetAABB(worldAABB); UpdateSnapSteps(); } else if (ExtrudeSpace == GizmoSpace.Local) { int firstParentIndex = 0; while (firstParentIndex < NumTargetParents) { if (_ignoredParentObjects.Contains(_targetParents[firstParentIndex])) { ++firstParentIndex; } else { break; } } if (firstParentIndex == NumTargetParents) { SetOBB(OBB.GetInvalid()); UpdateSnapSteps(); return; } OBB worldOBB = ObjectBounds.CalcHierarchyWorldOBB(_targetParents[firstParentIndex], _boundsQConfig); for (int parentIndex = firstParentIndex; parentIndex < NumTargetParents; ++parentIndex) { GameObject parent = _targetParents[parentIndex]; if (_ignoredParentObjects.Contains(parent)) { continue; } OBB obb = ObjectBounds.CalcHierarchyWorldOBB(parent, _boundsQConfig); if (obb.IsValid) { if (worldOBB.IsValid) { worldOBB.Encapsulate(obb); } else { worldOBB = obb; } } } SetOBB(worldOBB); UpdateSnapSteps(); } }