/// <inheritdoc/> protected internal override bool CalculateBounds(out AABox box, out Sphere sphere) { Bounds bounds = Bounds; box = bounds.Box; sphere = bounds.Sphere; return(true); }
/// <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> /// 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; }
/// <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); }
/// <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; } } }
private static extern bool Internal_BoxCastAny(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
private static extern bool Internal_BoxCast(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, out ScriptPhysicsQueryHit hit, ulong layer, float max);
/// <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); }
/// <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)); }
/// <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);
private static extern void Internal_CalculateBoundsArray(SceneObject[] objects, out AABox bounds);
private static extern int Internal_AddPhysicsRegion(ref AABox region);
/// <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)); }
/// <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)); }
/// <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))); }
/// <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)); }
/// <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))); }
private static extern bool Internal_BoxOverlapAny(ref AABox box, ref Quaternion rotation, ulong layer);
/// <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)); }
/// <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); }
private static extern void Internal_GetBounds(IntPtr thisPtr, IntPtr parentSO, out AABox box, out Sphere sphere);
/// <inheritdoc/> protected internal override bool CalculateBounds(out AABox box, out Sphere sphere) { Bounds bounds = Bounds; box = bounds.Box; sphere = bounds.Sphere; return true; }
private static extern void Internal_getBounds(IntPtr thisPtr, out AABox __output);
/// <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); }
private static extern void Internal_setcustomBounds(IntPtr thisPtr, ref AABox value);
private static extern void Internal_setBounds(IntPtr thisPtr, ref AABox bounds);
/// <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)); }
/// <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); }
/// <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)); }
/// <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); }
/// <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)); }
private static extern bool Internal_boxCast(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
private static extern ScriptPhysicsQueryHit[] Internal_BoxCastAll(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
private static extern PhysicsQueryHit[] Internal_boxCastAll(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
private static extern NativeCollider[] Internal_BoxOverlap(ref AABox box, ref Quaternion rotation, ulong layer);
private static extern bool Internal_boxCastAny(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
private static extern Collider[] Internal_boxOverlap(ref AABox box, ref Quaternion rotation, ulong layer);
private static extern bool Internal_boxOverlapAny(ref AABox box, ref Quaternion rotation, ulong layer);
private static extern void Internal_CalculateBounds(SceneObject so, out AABox bounds);
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); }
/// <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);
private static extern void Internal_getBounds(IntPtr thisPtr, out AABox box, out Sphere sphere);
/// <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; } } }