Exemplo n.º 1
0
        /// <inheritdoc/>
        protected internal override bool CalculateBounds(out AABox box, out Sphere sphere)
        {
            Bounds bounds = Bounds;

            box    = bounds.Box;
            sphere = bounds.Sphere;

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates bounds of the visible content for this component.
        /// </summary>
        /// <param name="box">Bounds in world space represented as an axis aligned bounding box.</param>
        /// <param name="sphere">Bounds in world space represented as a sphere.</param>
        /// <returns>True if the bounds have non-zero volume, false otherwise.</returns>
        protected internal virtual bool CalculateBounds(out AABox box, out Sphere sphere)
        {
            Vector3 pos = SceneObject.Position;

            box    = new AABox(pos, pos);
            sphere = new Sphere(pos, 0.0f);

            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Performs a sweep into the scene using a box and returns the closest found hit, if any.
        /// </summary>
        /// <param name="box">Box to sweep through the scene.</param>
        /// <param name="rotation">Orientation of the box.</param>
        /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
        /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
        ///                   </param>
        /// <returns>True if something was hit, false otherwise.</returns>
        public static bool BoxCast(AABox box, Quaternion rotation, Vector3 unitDir, out PhysicsQueryHit hit,
            ulong layer = ulong.MaxValue, float max = float.MaxValue)
        {
            ScriptPhysicsQueryHit scriptHit = new ScriptPhysicsQueryHit();
            if(Internal_BoxCast(ref box, ref rotation, ref unitDir, out scriptHit, layer, max))
            {
                ConvertPhysicsQueryHit(ref scriptHit, out hit);
                return true;
            }

            hit = new PhysicsQueryHit();
            return false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Performs a sweep into the scene using a box and returns the closest found hit, if any.
        /// </summary>
        /// <param name="box">Box to sweep through the scene.</param>
        /// <param name="rotation">Orientation of the box.</param>
        /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
        /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
        ///                   </param>
        /// <returns>True if something was hit, false otherwise.</returns>
        public static bool BoxCast(AABox box, Quaternion rotation, Vector3 unitDir, out PhysicsQueryHit hit,
                                   ulong layer = ulong.MaxValue, float max = float.MaxValue)
        {
            ScriptPhysicsQueryHit scriptHit = new ScriptPhysicsQueryHit();

            if (Internal_BoxCast(ref box, ref rotation, ref unitDir, out scriptHit, layer, max))
            {
                ConvertPhysicsQueryHit(ref scriptHit, out hit);
                return(true);
            }

            hit = new PhysicsQueryHit();
            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Re-applies the bounds to the internal animation object, and the relevant renderable object if one exists.
        /// </summary>
        internal void UpdateBounds(bool updateRenderable = true)
        {
            NativeRenderable renderable = null;

            if (updateRenderable && animatedRenderable != null)
            {
                renderable = animatedRenderable.Native;
            }

            if (serializableData.useBounds)
            {
                if (renderable != null)
                {
                    renderable.UseOverrideBounds = true;
                    renderable.OverrideBounds    = serializableData.bounds;
                }

                if (_native != null)
                {
                    AABox bounds = serializableData.bounds;
                    bounds.TransformAffine(SceneObject.WorldTransform);

                    _native.Bounds = bounds;
                }
            }
            else
            {
                if (renderable != null)
                {
                    renderable.UseOverrideBounds = false;
                }

                if (_native != null)
                {
                    AABox bounds = new AABox();
                    if (animatedRenderable != null)
                    {
                        bounds = animatedRenderable.Bounds.Box;
                    }

                    _native.Bounds = bounds;
                }
            }
        }
Exemplo n.º 6
0
 private static extern bool Internal_BoxCastAny(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
Exemplo n.º 7
0
 private static extern bool Internal_BoxCast(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, out ScriptPhysicsQueryHit hit, ulong layer, float max);
Exemplo n.º 8
0
 /// <summary>
 /// Adds a new physics region. Certain physics options require you to set up regions in which physics objects are
 /// allowed to be in, and objects outside of these regions will not be handled by physics.You do not need to set
 /// up these regions by default.
 /// </summary>
 /// <param name="region">Region of space that physics objects are allowed to be in.</param>
 /// <returns>A unique handle to the region.</returns>
 public static int AddPhysicsRegion(AABox region)
 {
     return Internal_AddPhysicsRegion(ref region);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Returns a list of all colliders in the scene that overlap the provided box.
 /// </summary>
 /// <param name="box">Box to check for overlap.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <returns>List of all colliders that overlap the box.</returns>
 public static Collider[] BoxOverlap(AABox box, Quaternion rotation, ulong layer = ulong.MaxValue)
 {
     return ConvertColliders(Internal_BoxOverlap(ref box, ref rotation, layer));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Creates new bounds.
 /// </summary>
 /// <param name="box">Axis aligned box representation of the bounds.</param>
 /// <param name="sphere">Sphere representation of the bounds.</param>
 public Bounds(AABox box, Sphere sphere)
 {
     Box    = box;
     Sphere = sphere;
 }
 private static extern void Internal_getGridVolume(IntPtr thisPtr, out AABox __output);
Exemplo n.º 12
0
 private static extern void Internal_CalculateBoundsArray(SceneObject[] objects, out AABox bounds);
Exemplo n.º 13
0
 private static extern int Internal_AddPhysicsRegion(ref AABox region);
Exemplo n.º 14
0
 /// <summary>
 /// Adds a new physics region. Certain physics options require you to set up regions in which physics objects are
 /// allowed to be in, and objects outside of these regions will not be handled by physics.You do not need to set
 /// up these regions by default.
 /// </summary>
 /// <param name="region">Region of space that physics objects are allowed to be in.</param>
 /// <returns>A unique handle to the region.</returns>
 public static int AddPhysicsRegion(AABox region)
 {
     return(Internal_AddPhysicsRegion(ref region));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Checks if the provided box overlaps any other collider in the scene.
 /// </summary>
 /// <param name="box">Box to check for overlap.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <returns>True if there is overlap with another object, false otherwise.</returns>
 public static bool BoxOverlapAny(AABox box, Quaternion rotation, ulong layer = ulong.MaxValue)
 {
     return(Internal_BoxOverlapAny(ref box, ref rotation, layer));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Returns a list of all colliders in the scene that overlap the provided box.
 /// </summary>
 /// <param name="box">Box to check for overlap.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <returns>List of all colliders that overlap the box.</returns>
 public static Collider[] BoxOverlap(AABox box, Quaternion rotation, ulong layer = ulong.MaxValue)
 {
     return(ConvertColliders(Internal_BoxOverlap(ref box, ref rotation, layer)));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Performs a sweep into the scene using a box and checks if it has hit anything. This can be significantly more
 /// efficient than other types of cast* calls.
 /// </summary>
 /// <param name="box">Box to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
 ///                   </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool BoxCastAny(AABox box, Quaternion rotation, Vector3 unitDir, ulong layer = ulong.MaxValue,
                               float max = float.MaxValue)
 {
     return(Internal_BoxCastAny(ref box, ref rotation, ref unitDir, layer, max));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Performs a sweep into the scene using a box and returns all found hits.
 /// </summary>
 /// <param name="box">Box to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
 ///                   </param>
 /// <returns>List of all detected hits.</returns>
 public static PhysicsQueryHit[] BoxCastAll(AABox box, Quaternion rotation,
                                            Vector3 unitDir, ulong layer = ulong.MaxValue, float max = float.MaxValue)
 {
     return(ConvertPhysicsQueryHits(Internal_BoxCastAll(ref box, ref rotation, ref unitDir, layer, max)));
 }
Exemplo n.º 19
0
 private static extern bool Internal_BoxOverlapAny(ref AABox box, ref Quaternion rotation, ulong layer);
Exemplo n.º 20
0
 /// <summary>
 /// Performs a sweep into the scene using a box and returns all found hits.
 /// </summary>
 /// <param name="box">Box to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
 ///                   </param>
 /// <returns>List of all detected hits.</returns>
 public static PhysicsQueryHit[] BoxCastAll(AABox box, Quaternion rotation,
     Vector3 unitDir, ulong layer = ulong.MaxValue, float max = float.MaxValue)
 {
     return ConvertPhysicsQueryHits(Internal_BoxCastAll(ref box, ref rotation, ref unitDir, layer, max));
 }
Exemplo n.º 21
0
        /// <summary>
        /// Calculates bounds of the visible content for this component.
        /// </summary>
        /// <param name="box">Bounds in world space represented as an axis aligned bounding box.</param>
        /// <param name="sphere">Bounds in world space represented as a sphere.</param>
        /// <returns>True if the bounds have non-zero volume, false otherwise.</returns>
        protected internal virtual bool CalculateBounds(out AABox box, out Sphere sphere)
        {
            Vector3 pos = SceneObject.Position;

            box = new AABox(pos, pos);
            sphere = new Sphere(pos, 0.0f);

            return false;
        }
        /// <summary>
        /// Resizes the light probe grid and inserts new light probes, if the new size is larger than previous size. New probes
        /// are inserted in a grid pattern matching the new size and density parameters.
        ///
        /// Note that shrinking the volume will not remove light probes. In order to remove probes outside of the new volume call
        /// clip().
        ///
        /// Resize will not change the positions of current light probes. If you wish to reset all probes to the currently set
        /// grid position, call reset().
        /// </summary>
        /// <param name="volume">Axis aligned volume to be covered by the light probes.</param>
        public void Resize(AABox volume)
        {
            Vector3I cellCount = new Vector3I(1, 1, 1);

            Internal_resize(mCachedPtr, ref volume, ref cellCount);
        }
Exemplo n.º 23
0
 private static extern void Internal_GetBounds(IntPtr thisPtr, IntPtr parentSO, out AABox box, out Sphere sphere);
Exemplo n.º 24
0
        /// <inheritdoc/>
        protected internal override bool CalculateBounds(out AABox box, out Sphere sphere)
        {
            Bounds bounds = Bounds;

            box = bounds.Box;
            sphere = bounds.Sphere;

            return true;
        }
Exemplo n.º 25
0
 private static extern void Internal_getBounds(IntPtr thisPtr, out AABox __output);
Exemplo n.º 26
0
        /// <summary>
        /// Moves and orients a camera so that the provided bounds end covering the camera's viewport.
        /// </summary>
        /// <param name="bounds">Bounds to frame in camera's view.</param>
        /// <param name="padding">Amount of padding to leave on the borders of the viewport, in percent [0, 1].</param>
        private void FrameBounds(AABox bounds, float padding = 0.0f)
        {
            // TODO - Use AABox bounds directly instead of a sphere to be more accurate
            float worldWidth = bounds.Size.Length;
            float worldHeight = worldWidth;

            if (worldWidth == 0.0f)
                worldWidth = 1.0f;

            if (worldHeight == 0.0f)
                worldHeight = 1.0f;

            float boundsAspect = worldWidth / worldHeight;
            float paddingScale = MathEx.Clamp01(padding) + 1.0f;
            float frustumWidth;

            // If camera has wider aspect than bounds then height will be the limiting dimension
            if (camera.AspectRatio > boundsAspect)
                frustumWidth = worldHeight * camera.AspectRatio * paddingScale;
            else // Otherwise width
                frustumWidth = worldWidth * paddingScale;

            float distance = CalcDistanceForFrustumWidth(frustumWidth);

            Vector3 forward = bounds.Center - SceneObject.Position;
            forward.Normalize();

            CameraState state = new CameraState();
            state.Position = bounds.Center - forward * distance;
            state.Rotation = Quaternion.LookRotation(forward, Vector3.YAxis);
            state.Ortographic = camera.ProjectionType == ProjectionType.Orthographic;
            state.FrustumWidth = frustumWidth;

            SetState(state);
        }
Exemplo n.º 27
0
 private static extern void Internal_setcustomBounds(IntPtr thisPtr, ref AABox value);
Exemplo n.º 28
0
 private static extern void Internal_setBounds(IntPtr thisPtr, ref AABox bounds);
Exemplo n.º 29
0
 /// <summary>Returns a list of all colliders in the scene that overlap the provided box.</summary>
 /// <param name="box">Box to check for overlap.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <returns>List of all colliders that overlap the box.</returns>
 public static Collider[] BoxOverlap(AABox box, Quaternion rotation, ulong layer = 18446744073709551615)
 {
     return(Internal_boxOverlap(ref box, ref rotation, layer));
 }
Exemplo n.º 30
0
 /// <summary>
 /// Performs a sweep into the scene using a box and checks if it has hit anything. This can be significantly more 
 /// efficient than other types of cast* calls.
 /// </summary>
 /// <param name="box">Box to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
 ///                   </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool BoxCastAny(AABox box, Quaternion rotation, Vector3 unitDir, ulong layer = ulong.MaxValue, 
     float max = float.MaxValue)
 {
     return Internal_BoxCastAny(ref box, ref rotation, ref unitDir, layer, max);
 }
Exemplo n.º 31
0
 /// <summary>Checks if the provided box overlaps any other collider in the scene.</summary>
 /// <param name="box">Box to check for overlap.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <returns>True if there is overlap with another object, false otherwise.</returns>
 public static bool BoxOverlapAny(AABox box, Quaternion rotation, ulong layer = 18446744073709551615)
 {
     return(Internal_boxOverlapAny(ref box, ref rotation, layer));
 }
Exemplo n.º 32
0
 /// <summary>
 /// Checks if the provided box overlaps any other collider in the scene.
 /// </summary>
 /// <param name="box">Box to check for overlap.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <returns>True if there is overlap with another object, false otherwise.</returns>
 public static bool BoxOverlapAny(AABox box, Quaternion rotation, ulong layer = ulong.MaxValue)
 {
     return Internal_BoxOverlapAny(ref box, ref rotation, layer);
 }
Exemplo n.º 33
0
 /// <summary>
 /// Adds a new physics region. Certain physics options require you to set up regions in which physics objects are allowed
 /// to be in, and objects outside of these regions will not be handled by physics. You do not need to set up these
 /// regions by default.
 /// </summary>
 public static uint AddPhysicsRegion(AABox region)
 {
     return(Internal_addBroadPhaseRegion(ref region));
 }
Exemplo n.º 34
0
 private static extern int Internal_AddPhysicsRegion(ref AABox region);
Exemplo n.º 35
0
 private static extern bool Internal_boxCast(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
Exemplo n.º 36
0
 private static extern ScriptPhysicsQueryHit[] Internal_BoxCastAll(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
Exemplo n.º 37
0
 private static extern PhysicsQueryHit[] Internal_boxCastAll(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
Exemplo n.º 38
0
 private static extern NativeCollider[] Internal_BoxOverlap(ref AABox box, ref Quaternion rotation, ulong layer);
Exemplo n.º 39
0
 private static extern bool Internal_boxCastAny(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
Exemplo n.º 40
0
 private static extern Collider[] Internal_boxOverlap(ref AABox box, ref Quaternion rotation, ulong layer);
Exemplo n.º 41
0
 private static extern bool Internal_boxOverlapAny(ref AABox box, ref Quaternion rotation, ulong layer);
Exemplo n.º 42
0
 private static extern void Internal_CalculateBounds(SceneObject so, out AABox bounds);
Exemplo n.º 43
0
 private static extern uint Internal_addBroadPhaseRegion(ref AABox region);
 /// <summary>
 /// Resizes the light probe grid and inserts new light probes, if the new size is larger than previous size. New probes
 /// are inserted in a grid pattern matching the new size and density parameters.
 ///
 /// Note that shrinking the volume will not remove light probes. In order to remove probes outside of the new volume call
 /// clip().
 ///
 /// Resize will not change the positions of current light probes. If you wish to reset all probes to the currently set
 /// grid position, call reset().
 /// </summary>
 /// <param name="volume">Axis aligned volume to be covered by the light probes.</param>
 /// <param name="cellCount">
 /// Number of grid cells to split the volume into. Minimum number of 1, in which case each corner of the volume is
 /// represented by a single probe. Higher values subdivide the volume in an uniform way.
 /// </param>
 public void Resize(AABox volume, Vector3I cellCount)
 {
     Internal_resize(mCachedPtr, ref volume, ref cellCount);
 }
Exemplo n.º 45
0
 /// <summary>Performs a sweep into the scene using a box and returns the closest found hit, if any.</summary>
 /// <param name="box">Box to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.</param>
 /// <param name="max">
 /// Maximum distance at which to perform the query. Hits past this distance will not be detected.
 /// </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool BoxCast(AABox box, Quaternion rotation, Vector3 unitDir, out PhysicsQueryHit hit, ulong layer = 18446744073709551615, float max = 3.40282347E+38f)
 {
     return(Internal_boxCast(ref box, ref rotation, ref unitDir, out hit, layer, max));
 }
 private static extern void Internal_resize(IntPtr thisPtr, ref AABox volume, ref Vector3I cellCount);
Exemplo n.º 47
0
 private static extern void Internal_GetBounds(IntPtr thisPtr, IntPtr parentSO, out AABox box, out Sphere sphere);
Exemplo n.º 48
0
 private static extern void Internal_getBounds(IntPtr thisPtr, out AABox box, out Sphere sphere);
Exemplo n.º 49
0
        /// <summary>
        /// Re-applies the bounds to the internal animation object, and the relevant renderable object if one exists.
        /// </summary>
        internal void UpdateBounds(bool updateRenderable = true)
        {
            NativeRenderable renderable = null;
            if (updateRenderable && animatedRenderable != null)
                renderable = animatedRenderable.Native;

            if (serializableData.useBounds)
            {
                if (renderable != null)
                {
                    renderable.UseOverrideBounds = true;
                    renderable.OverrideBounds = serializableData.bounds;
                }

                if (_native != null)
                {
                    AABox bounds = serializableData.bounds;

                    Matrix4 parentTfrm;
                    if (SceneObject.Parent != null)
                        parentTfrm = SceneObject.Parent.WorldTransform;
                    else
                        parentTfrm = Matrix4.Identity;

                    bounds.TransformAffine(parentTfrm);

                    _native.Bounds = bounds;
                }
            }
            else
            {
                if (renderable != null)
                    renderable.UseOverrideBounds = false;

                if (_native != null)
                {
                    AABox bounds = new AABox();
                    if (animatedRenderable != null)
                        bounds = animatedRenderable.Bounds.Box;

                    _native.Bounds = bounds;
                }
            }
        }