Beispiel #1
0
 public void ExecuteBoundsChange(ACollider collider, bool IsBounds, bool forceUpdate = false)
 {
     Debug.Log("ExecuteBoundsChange: changing...");
     unsafe
     {
         if (IsBounds)
         {
             //			Debug.Log("ExecuteBoundsChange: changing bounds...");
             if (!Bounds.Update(collider.transform, collider.GetCollider_P(), forceUpdate))
             {
                 Debug.LogWarning("ExecuteBoundsChange: No update was performed");
             }
         }
         else
         {
             //			Debug.Log("ExecuteBoundsChange: changing cropbounds...");
             if (!CropBounds.Update(collider.transform, collider.GetCollider_P(), forceUpdate))
             {
                 Debug.LogWarning("ExecuteBoundsChange: No update was performed");
             }
         }
     }
     CalculateMinMaxA();
     TranslationOffset = float3.zero;
     RotationOffset    = float3.zero;
 }
Beispiel #2
0
        /// <summary>
        /// Call this to calulate and set the new Min and Max values of the of offsets
        /// </summary>
        public void CalculateMinMaxA()
        {
            Debug.Log("Recalculating...");
            if (Bounds != ACollider.Null && CropBounds != ACollider.Null)
            {
                unsafe
                {
                    if (CropBounds.GetCollider_P() != null && Bounds.GetCollider_P() != null)
                    {
                        switch (Bounds.GetCollider_P()->Type)
                        {
                        case Unity.Physics.ColliderType.Box:
                        case Unity.Physics.ColliderType.Sphere:
                        case Unity.Physics.ColliderType.Capsule:
                        case Unity.Physics.ColliderType.Cylinder:
                        case Unity.Physics.ColliderType.Mesh:
                            //	CalculateMinMaxB(Bounds.aabb.Extents, Bounds.GetCollider_P()->Type);
                            float3 s = AColliderProperties.GetSize(Bounds.properties);
                            if (s.x == 0)
                            {
                                s.x = 0.01f;
                            }
                            if (s.y == 0)
                            {
                                s.y = 0.01f;
                            }
                            if (s.z == 0)
                            {
                                s.z = 0.01f;
                            }
                            CalculateMinMaxB(s, Bounds.GetCollider_P()->Type);
                            break;

                        default:
                            Debug.LogWarning("CalculateMinMax: Failed to calculate the min max with the given collider type!");
                            break;
                        }
                    }
                    else
                    {
                        Debug.LogWarning("CalculateMinMax: Either Bounds collider or CropBounds collider is null\n" + Bounds.aabb.Extents + "\t " + CropBounds.aabb.Extents);
                    }
                }
            }
            else
            {
                Debug.LogWarning("CalculateMinMax: Either Bounds or Crop Bounds is Null!\n" + Bounds.ToString() + "\n" + CropBounds.ToString());
            }
        }