From c73275f2d3201253ad9e0af0f2bcbec195298c1b Mon Sep 17 00:00:00 2001 From: Diren D Bharwani Date: Fri, 3 Feb 2023 16:11:30 +0800 Subject: [PATCH] Added temporary use of collision layers to C# and fixed raycast drawing --- Assets/Application.SHConfig | 2 +- Assets/Editor/Editor.SHConfig | 2 +- Assets/Editor/Layouts/UserLayout.ini | 68 ++++++------ Assets/Scenes/PhysicsTest.shade | 6 +- Assets/Scenes/Test.shade | 42 -------- Assets/Scenes/Test.shade.shmeta | 3 - Assets/Scenes/x.shade | 100 ------------------ Assets/Scenes/x.shade.shmeta | 3 - .../Implemented/LeafNodes/LeafSearch.cs | 2 +- .../Gameplay/Player/SC_PickAndThrow.cs | 6 +- Assets/Scripts/Tests/PhysicsTestObj.cs | 2 +- .../Routines/SHPhysicsDebugDrawRoutine.cpp | 24 ++--- SHADE_Managed/src/Physics/Physics.cxx | 27 +++-- SHADE_Managed/src/Physics/Physics.hxx | 21 ++-- 14 files changed, 87 insertions(+), 221 deletions(-) delete mode 100644 Assets/Scenes/Test.shade delete mode 100644 Assets/Scenes/Test.shade.shmeta delete mode 100644 Assets/Scenes/x.shade delete mode 100644 Assets/Scenes/x.shade.shmeta diff --git a/Assets/Application.SHConfig b/Assets/Application.SHConfig index 5673556d..61857f68 100644 --- a/Assets/Application.SHConfig +++ b/Assets/Application.SHConfig @@ -1,4 +1,4 @@ Start in Fullscreen: false -Starting Scene ID: 97158628 +Starting Scene ID: 97086054 Window Size: {x: 1920, y: 1080} Window Title: SHADE Engine \ No newline at end of file diff --git a/Assets/Editor/Editor.SHConfig b/Assets/Editor/Editor.SHConfig index 09efea23..7a7c92f8 100644 --- a/Assets/Editor/Editor.SHConfig +++ b/Assets/Editor/Editor.SHConfig @@ -1,4 +1,4 @@ Start Maximized: true -Working Scene ID: 84373000 +Working Scene ID: 97086054 Window Size: {x: 1920, y: 1013} Style: 0 \ No newline at end of file diff --git a/Assets/Editor/Layouts/UserLayout.ini b/Assets/Editor/Layouts/UserLayout.ini index 7c2df9e0..9a8687ca 100644 --- a/Assets/Editor/Layouts/UserLayout.ini +++ b/Assets/Editor/Layouts/UserLayout.ini @@ -20,8 +20,8 @@ Size=400,400 Collapsed=0 [Window][Inspector] -Pos=1604,48 -Size=316,941 +Pos=1434,48 +Size=486,941 Collapsed=0 DockId=0x00000006,0 @@ -76,7 +76,7 @@ DockId=0x0000000B,0 [Window][ Viewport] Pos=302,48 -Size=1300,836 +Size=1130,705 Collapsed=0 DockId=0x0000000B,0 @@ -93,14 +93,14 @@ Collapsed=0 DockId=0x0000000A,0 [Window][ Asset Browser] -Pos=302,886 -Size=1300,103 +Pos=302,755 +Size=1130,234 Collapsed=0 DockId=0x0000000C,0 [Window][Material Inspector] -Pos=1604,48 -Size=316,941 +Pos=1434,48 +Size=486,941 Collapsed=0 DockId=0x00000006,1 @@ -115,14 +115,16 @@ Size=464,144 Collapsed=0 [Window][Collider Tag Panel] -Pos=60,60 -Size=625,744 +Pos=302,48 +Size=1130,705 Collapsed=0 +DockId=0x0000000B,1 [Window][Input Bindings Panel] -Pos=60,60 -Size=154,204 +Pos=1434,48 +Size=486,941 Collapsed=0 +DockId=0x00000006,2 [Window][Save Scene As] Pos=877,444 @@ -130,36 +132,36 @@ Size=165,120 Collapsed=0 [Table][0x9D40AE32,17] -Column 0 Weight=1.0000 -Column 1 Weight=1.0000 -Column 2 Weight=1.0000 -Column 3 Weight=1.0000 -Column 4 Weight=1.0000 -Column 5 Weight=1.0000 -Column 6 Weight=1.0000 -Column 7 Weight=1.0000 -Column 8 Weight=1.0000 -Column 9 Weight=1.0000 -Column 10 Weight=1.0000 -Column 11 Weight=1.0000 -Column 12 Weight=1.0000 -Column 13 Weight=1.0000 -Column 14 Weight=1.0000 -Column 15 Weight=1.0000 -Column 16 Weight=1.0000 +Column 0 Weight=0.9945 +Column 1 Weight=0.9945 +Column 2 Weight=0.9945 +Column 3 Weight=0.9945 +Column 4 Weight=0.9945 +Column 5 Weight=0.9945 +Column 6 Weight=0.9945 +Column 7 Weight=0.9945 +Column 8 Weight=0.9945 +Column 9 Weight=0.9945 +Column 10 Weight=0.9945 +Column 11 Weight=0.9945 +Column 12 Weight=1.0132 +Column 13 Weight=0.8444 +Column 14 Weight=0.9945 +Column 15 Weight=1.2009 +Column 16 Weight=1.0132 [Docking][Data] DockSpace ID=0xC5C9B8AB Window=0xBE4044E9 Pos=0,71 Size=1920,941 Split=X - DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1602,1036 Split=X + DockNode ID=0x00000005 Parent=0xC5C9B8AB SizeRef=1432,1036 Split=X DockNode ID=0x00000001 Parent=0x00000005 SizeRef=300,1036 Split=Y Selected=0x1E6EB881 DockNode ID=0x00000003 Parent=0x00000001 SizeRef=225,147 Selected=0x1E6EB881 DockNode ID=0x00000004 Parent=0x00000001 SizeRef=225,863 Selected=0xE096E5AE - DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1300,1036 Split=Y Selected=0xB41284E7 + DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1130,1036 Split=Y Selected=0xB41284E7 DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1501,672 Split=Y Selected=0xB41284E7 DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1501,700 Split=Y Selected=0xB41284E7 - DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,836 CentralNode=1 Selected=0xB41284E7 - DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,103 Selected=0xB128252A + DockNode ID=0x0000000B Parent=0x00000009 SizeRef=1501,705 CentralNode=1 Selected=0xB41284E7 + DockNode ID=0x0000000C Parent=0x00000009 SizeRef=1501,234 Selected=0xB128252A DockNode ID=0x0000000A Parent=0x00000007 SizeRef=1501,310 Selected=0xD446F7B6 DockNode ID=0x00000008 Parent=0x00000002 SizeRef=1501,338 Selected=0xD9F31532 - DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=316,1036 Selected=0xE7039252 + DockNode ID=0x00000006 Parent=0xC5C9B8AB SizeRef=486,1036 Selected=0xE7039252 diff --git a/Assets/Scenes/PhysicsTest.shade b/Assets/Scenes/PhysicsTest.shade index 77953a18..5e3a2986 100644 --- a/Assets/Scenes/PhysicsTest.shade +++ b/Assets/Scenes/PhysicsTest.shade @@ -4,15 +4,15 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 7, z: -0.5} - Rotate: {x: 0, y: 0, z: 0.785398185} + Translate: {x: 0, y: 7, z: 0} + Rotate: {x: 0, y: 0, z: 0} Scale: {x: 0.999999344, y: 0.999999821, z: 0.999999523} IsActive: true RigidBody Component: Type: Dynamic Drag: 0.00999999978 Angular Drag: 0.100000001 - Use Gravity: true + Use Gravity: false Interpolate: true Sleeping Enabled: true Freeze Position X: false diff --git a/Assets/Scenes/Test.shade b/Assets/Scenes/Test.shade deleted file mode 100644 index 4b831802..00000000 --- a/Assets/Scenes/Test.shade +++ /dev/null @@ -1,42 +0,0 @@ -- EID: 0 - Name: Default - IsActive: true - NumberOfChildren: 0 - Components: - Camera Component: - Position: {x: 0, y: 0, z: 0} - Pitch: 0 - Yaw: 0 - Roll: 0 - Width: 1920 - Height: 1080 - Near: 0.00999999978 - Far: 10000 - Perspective: true - IsActive: true - Scripts: ~ -- EID: 1 - Name: Default - IsActive: true - NumberOfChildren: 0 - Components: - Transform Component: - Translate: {x: 0, y: 0, z: 0} - Rotate: {x: 0, y: 0, z: 0} - Scale: {x: 1, y: 1, z: 1} - IsActive: true - RigidBody Component: - Type: Dynamic - Drag: 0.00999999978 - Angular Drag: 0.100000001 - Use Gravity: false - Interpolate: true - Sleeping Enabled: true - Freeze Position X: false - Freeze Position Y: false - Freeze Position Z: false - Freeze Rotation X: false - Freeze Rotation Y: false - Freeze Rotation Z: false - IsActive: true - Scripts: ~ \ No newline at end of file diff --git a/Assets/Scenes/Test.shade.shmeta b/Assets/Scenes/Test.shade.shmeta deleted file mode 100644 index d5ded40c..00000000 --- a/Assets/Scenes/Test.shade.shmeta +++ /dev/null @@ -1,3 +0,0 @@ -Name: Test -ID: 97979840 -Type: 5 diff --git a/Assets/Scenes/x.shade b/Assets/Scenes/x.shade deleted file mode 100644 index 959e4982..00000000 --- a/Assets/Scenes/x.shade +++ /dev/null @@ -1,100 +0,0 @@ -- EID: 0 - Name: Default - IsActive: true - NumberOfChildren: 0 - Components: - Transform Component: - Translate: {x: 2, y: 2, z: 0} - Rotate: {x: -0, y: 0, z: -0} - Scale: {x: 1, y: 1, z: 1} - IsActive: true - RigidBody Component: - Type: Dynamic - Drag: 0.00999999978 - Angular Drag: 0.100000001 - Use Gravity: true - Interpolate: true - Sleeping Enabled: false - Freeze Position X: false - Freeze Position Y: false - Freeze Position Z: false - Freeze Rotation X: false - Freeze Rotation Y: false - Freeze Rotation Z: false - IsActive: true - Collider Component: - Colliders: - - Is Trigger: false - Collision Tag: 1 - Type: Sphere - Radius: 1 - Friction: 0.400000006 - Bounciness: 0 - Density: 1 - Position Offset: {x: 0, y: 0, z: 0} - Rotation Offset: {x: 0, y: 0, z: 0} - IsActive: true - Scripts: ~ -- EID: 1 - Name: Default - IsActive: true - NumberOfChildren: 0 - Components: - Camera Component: - Position: {x: 0, y: 0, z: 5} - Pitch: 0 - Yaw: 0 - Roll: 0 - Width: 1920 - Height: 1080 - Near: 0.00999999978 - Far: 10000 - Perspective: true - IsActive: true - Scripts: ~ -- EID: 2 - Name: Default - IsActive: true - NumberOfChildren: 0 - Components: - Transform Component: - Translate: {x: 0, y: 0, z: 0} - Rotate: {x: -0, y: 0, z: -0} - Scale: {x: 1, y: 1, z: 1} - IsActive: true - RigidBody Component: - Type: Dynamic - Drag: 0.00999999978 - Angular Drag: 0.100000001 - Use Gravity: false - Interpolate: true - Sleeping Enabled: false - Freeze Position X: true - Freeze Position Y: true - Freeze Position Z: true - Freeze Rotation X: false - Freeze Rotation Y: false - Freeze Rotation Z: false - IsActive: true - Collider Component: - Colliders: - - Is Trigger: false - Collision Tag: 3 - Type: Sphere - Radius: 1 - Friction: 0.400000006 - Bounciness: 0 - Density: 1 - Position Offset: {x: 0, y: 0, z: 0} - Rotation Offset: {x: 0, y: 0, z: 0} - - Is Trigger: false - Collision Tag: 2 - Type: Box - Half Extents: {x: 1, y: 1, z: 1} - Friction: 0.400000006 - Bounciness: 0 - Density: 1 - Position Offset: {x: 2, y: 0, z: 0} - Rotation Offset: {x: 0, y: 0, z: 0} - IsActive: true - Scripts: ~ \ No newline at end of file diff --git a/Assets/Scenes/x.shade.shmeta b/Assets/Scenes/x.shade.shmeta deleted file mode 100644 index 06a5e721..00000000 --- a/Assets/Scenes/x.shade.shmeta +++ /dev/null @@ -1,3 +0,0 @@ -Name: x -ID: 84373000 -Type: 5 diff --git a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafSearch.cs b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafSearch.cs index b5b03629..a48ffcf7 100644 --- a/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafSearch.cs +++ b/Assets/Scripts/Gameplay/AIBehaviour/Implemented/LeafNodes/LeafSearch.cs @@ -159,7 +159,7 @@ public partial class LeafSearch : BehaviourTreeNode //Since transform position is often the raccoon's base and the ray needs to hit somewhere higher to be more reliable Vector3 rayDestination = plrT.GlobalPosition + plrT.GlobalScale * playerCollider.PositionOffset; Ray sightRay = new Ray(eyePosition, rayDestination - eyePosition); - RaycastHit sightRayHit = Physics.Raycast(sightRay, false)[0]; + RaycastHit sightRayHit = Physics.Raycast(sightRay, false, (ushort)65535)[0]; //As of November 2022, RaycastHit contains only the FIRST object hit by //the ray in the Other GameObject data member //Diren may likely add ALL objects hit by the ray over December diff --git a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs index 2c5e95ac..f933f9bc 100644 --- a/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs +++ b/Assets/Scripts/Gameplay/Player/SC_PickAndThrow.cs @@ -204,9 +204,9 @@ public class PickAndThrow : Script Vector3 playerRayPos = pc.tranform.GlobalPosition; playerRayPos.y += 0.05f; dirNor.Normalise(); - List rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false); - List rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false); - List rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false); + List rayList1 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(22.5f))), rayDistance, false, (ushort)65535); + List rayList2 = Physics.Raycast(new Ray(playerRayPos, Vector3.RotateY(dirNor, SHADE.Math.DegreesToRadians(-22.5f))), rayDistance, false, (ushort)65535); + List rayList3 = Physics.Raycast(new Ray(playerRayPos, dirNor), rayDistance * 0.75f, false, (ushort)65535); if (rayList1.Count > 0 && rayList2.Count > 0 && rayList3.Count > 0) { diff --git a/Assets/Scripts/Tests/PhysicsTestObj.cs b/Assets/Scripts/Tests/PhysicsTestObj.cs index 781d0b11..82929888 100644 --- a/Assets/Scripts/Tests/PhysicsTestObj.cs +++ b/Assets/Scripts/Tests/PhysicsTestObj.cs @@ -82,7 +82,7 @@ public class PhysicsTestObj : Script { Ray colliderRay = new Ray(); colliderRay.Direction = Vector3.Right; - Physics.ColliderRaycast(collider.Owner, colliderRay, false); + Physics.ColliderRaycast(collider.Owner, colliderRay, false, 8); for (int i = 0; i < 6; ++i) { diff --git a/SHADE_Engine/src/Physics/System/Routines/SHPhysicsDebugDrawRoutine.cpp b/SHADE_Engine/src/Physics/System/Routines/SHPhysicsDebugDrawRoutine.cpp index 469e835d..0d61a494 100644 --- a/SHADE_Engine/src/Physics/System/Routines/SHPhysicsDebugDrawRoutine.cpp +++ b/SHADE_Engine/src/Physics/System/Routines/SHPhysicsDebugDrawRoutine.cpp @@ -65,6 +65,18 @@ namespace SHADE if (!physicsSystem) return; + if (DRAW_RAYCASTS) + { + const SHColour& RAY_COLOUR = physicsDebugDrawSystem->DEBUG_DRAW_COLOURS[SHUtilities::ConvertEnum(Colours::RAYCAST)]; + + const auto& RAYS = physicsSystem->raycastHits; + for (const auto& hit : RAYS) + debugDrawSystem->DrawLine(hit.start, hit.end, RAY_COLOUR, true); + + // Clear rays for the physics system + physicsSystem->raycastHits.clear(); + } + rp3d::DebugRenderer* rp3dRenderer = nullptr; if (physicsSystem->worldState.world) rp3dRenderer = &physicsSystem->worldState.world->getDebugRenderer(); @@ -96,18 +108,6 @@ namespace SHADE for (int i = 0; i < NUM_LINES; ++i) debugDrawSystem->DrawLine(LINE_ARRAY[i].point1, LINE_ARRAY[i].point2, CONTACT_COLOUR, true); } - - if (DRAW_RAYCASTS) - { - const SHColour& RAY_COLOUR = physicsDebugDrawSystem->DEBUG_DRAW_COLOURS[SHUtilities::ConvertEnum(Colours::RAYCAST)]; - - const auto& RAYS = physicsSystem->raycastHits; - for (const auto& hit : RAYS) - debugDrawSystem->DrawLine(hit.start, hit.end, RAY_COLOUR, true); - - // Clear rays for the physics system - physicsSystem->raycastHits.clear(); - } } } // namespace SHADE \ No newline at end of file diff --git a/SHADE_Managed/src/Physics/Physics.cxx b/SHADE_Managed/src/Physics/Physics.cxx index e5c376d2..7b2349a6 100644 --- a/SHADE_Managed/src/Physics/Physics.cxx +++ b/SHADE_Managed/src/Physics/Physics.cxx @@ -45,7 +45,7 @@ namespace SHADE /* Raycast Function Member Definitions */ /*-----------------------------------------------------------------------------------*/ - List^ Physics::Raycast(Ray ray, bool continuous) + List^ Physics::Raycast(Ray ray, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -53,6 +53,7 @@ namespace SHADE SHPhysicsSystemInterface::RaycastInfo raycastInfo; raycastInfo.ray = Convert::ToNative(ray); raycastInfo.continuous = continuous; + raycastInfo.layers = layer; const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); if (!NATIVE_RESULTS.empty()) @@ -64,7 +65,7 @@ namespace SHADE return results; } - List^ Physics::Raycast(Ray ray, float distance, bool continuous) + List^ Physics::Raycast(Ray ray, float distance, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -73,6 +74,7 @@ namespace SHADE raycastInfo.ray = Convert::ToNative(ray); raycastInfo.distance = distance; raycastInfo.continuous = continuous; + raycastInfo.layers = layer; const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); if (!NATIVE_RESULTS.empty()) @@ -84,7 +86,7 @@ namespace SHADE return results; } - List^ Physics::Linecast(Vector3 start, Vector3 end, bool continuous) + List^ Physics::Linecast(Vector3 start, Vector3 end, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -97,6 +99,7 @@ namespace SHADE raycastInfo.ray = Convert::ToNative(CLI_RAY); raycastInfo.distance = (end - start).GetMagnitude(); raycastInfo.continuous = continuous; + raycastInfo.layers = layer; const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); if (!NATIVE_RESULTS.empty()) @@ -108,7 +111,7 @@ namespace SHADE return results; } - List^ Physics::ColliderRaycast(GameObject object, Ray ray, bool continuous) + List^ Physics::ColliderRaycast(GameObject object, Ray ray, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -123,6 +126,7 @@ namespace SHADE SHPhysicsSystemInterface::RaycastInfo raycastInfo; raycastInfo.ray = Convert::ToNative(ray); raycastInfo.continuous = continuous; + raycastInfo.layers = layer; raycastInfo.SetColliderID(object.EntityId); const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); @@ -135,7 +139,7 @@ namespace SHADE return results; } - List^ Physics::ColliderRaycast(GameObject object, Ray ray, float distance, bool continuous) + List^ Physics::ColliderRaycast(GameObject object, Ray ray, float distance, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -151,6 +155,7 @@ namespace SHADE raycastInfo.ray = Convert::ToNative(ray); raycastInfo.distance = distance; raycastInfo.continuous = continuous; + raycastInfo.layers = layer; raycastInfo.SetColliderID(object.EntityId); const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); @@ -163,7 +168,7 @@ namespace SHADE return results; } - List^ Physics::ColliderRaycast(GameObject object, int shapeIndex, Ray ray, bool continuous) + List^ Physics::ColliderRaycast(GameObject object, int shapeIndex, Ray ray, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -185,6 +190,7 @@ namespace SHADE SHPhysicsSystemInterface::RaycastInfo raycastInfo; raycastInfo.ray = Convert::ToNative(ray); raycastInfo.continuous = continuous; + raycastInfo.layers = layer; raycastInfo.SetColliderID(object.EntityId); const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); @@ -197,7 +203,7 @@ namespace SHADE return results; } - List^ Physics::ColliderRaycast(GameObject object, int shapeIndex, Ray ray, float distance, bool continuous) + List^ Physics::ColliderRaycast(GameObject object, int shapeIndex, Ray ray, float distance, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -220,6 +226,7 @@ namespace SHADE raycastInfo.ray = Convert::ToNative(ray); raycastInfo.continuous = continuous; raycastInfo.distance = distance; + raycastInfo.layers = layer; raycastInfo.SetColliderID(object.EntityId); const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); @@ -232,7 +239,7 @@ namespace SHADE return results; } - List^ Physics::ColliderLineCast(GameObject object, Vector3 start, Vector3 end, bool continuous) + List^ Physics::ColliderLineCast(GameObject object, Vector3 start, Vector3 end, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -252,6 +259,7 @@ namespace SHADE raycastInfo.ray = Convert::ToNative(CLI_RAY); raycastInfo.distance = (end - start).GetMagnitude(); raycastInfo.continuous = continuous; + raycastInfo.layers = layer; raycastInfo.SetColliderID(object.EntityId); const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); @@ -264,7 +272,7 @@ namespace SHADE return results; } - List^ Physics::ColliderLineCast(GameObject object, int shapeIndex, Vector3 start, Vector3 end, bool continuous) + List^ Physics::ColliderLineCast(GameObject object, int shapeIndex, Vector3 start, Vector3 end, bool continuous, unsigned short layer) { List^ results = gcnew List(); @@ -291,6 +299,7 @@ namespace SHADE raycastInfo.ray = Convert::ToNative(CLI_RAY); raycastInfo.continuous = continuous; raycastInfo.distance = (end - start).GetMagnitude(); + raycastInfo.layers = layer; raycastInfo.SetColliderID(object.EntityId); const auto& NATIVE_RESULTS = SHPhysicsSystemInterface::Raycast(raycastInfo); diff --git a/SHADE_Managed/src/Physics/Physics.hxx b/SHADE_Managed/src/Physics/Physics.hxx index 573d8cad..7f5e1609 100644 --- a/SHADE_Managed/src/Physics/Physics.hxx +++ b/SHADE_Managed/src/Physics/Physics.hxx @@ -47,10 +47,13 @@ namespace SHADE /// /// Whether or not the raycast should stop at the first object hit. /// + /// + /// The layers to cast the ray on. + /// /// /// The results of the raycast. If nothing was hit, an empty list is returned. /// - static System::Collections::Generic::List^ Raycast (Ray ray, bool continuous); + static System::Collections::Generic::List^ Raycast (Ray ray, bool continuous, unsigned short layer); /// /// Casts a ray for a given distance into the world. @@ -63,7 +66,7 @@ namespace SHADE /// /// The results of the raycast. If nothing was hit, an empty list is returned. /// - static System::Collections::Generic::List^ Raycast (Ray ray, float distance, bool continuous); + static System::Collections::Generic::List^ Raycast (Ray ray, float distance, bool continuous, unsigned short layer); /// /// Casts a bounded ray into the world. @@ -76,7 +79,7 @@ namespace SHADE /// /// The results of the raycast. If nothing was hit, an empty list is returned. /// - static System::Collections::Generic::List^ Linecast (Vector3 start, Vector3 end, bool continuous); + static System::Collections::Generic::List^ Linecast (Vector3 start, Vector3 end, bool continuous, unsigned short layer); /// /// Casts an infinite ray w.r.t a GameObject. @@ -92,7 +95,7 @@ namespace SHADE /// /// The results of the raycast. If nothing was hit, an empty list is returned. /// - static System::Collections::Generic::List^ ColliderRaycast (GameObject object, Ray ray, bool continuous); + static System::Collections::Generic::List^ ColliderRaycast (GameObject object, Ray ray, bool continuous, unsigned short layer); /// /// Casts a ray for a given distance w.r.t a GameObject. @@ -109,7 +112,7 @@ namespace SHADE /// /// The results of the raycast. If nothing was hit, an empty list is returned. /// - static System::Collections::Generic::List^ ColliderRaycast (GameObject object, Ray ray, float distance, bool continuous); + static System::Collections::Generic::List^ ColliderRaycast (GameObject object, Ray ray, float distance, bool continuous, unsigned short layer); /// /// Casts an infinite ray w.r.t a specific collider on a GameObject. @@ -126,7 +129,7 @@ namespace SHADE /// /// The results of the raycast. If nothing was hit, an empty list is returned. /// - static System::Collections::Generic::List^ ColliderRaycast (GameObject object, int shapeIndex, Ray ray, bool continuous); + static System::Collections::Generic::List^ ColliderRaycast (GameObject object, int shapeIndex, Ray ray, bool continuous, unsigned short layer); /// /// Casts a ray for a given distance w.r.t a specific collider on a GameObject. @@ -144,7 +147,7 @@ namespace SHADE /// /// The results of the raycast. If nothing was hit, an empty list is returned. /// - static System::Collections::Generic::List^ ColliderRaycast (GameObject object, int shapeIndex, Ray ray, float distance, bool continuous); + static System::Collections::Generic::List^ ColliderRaycast (GameObject object, int shapeIndex, Ray ray, float distance, bool continuous, unsigned short layer); /// /// Casts a bounded ray w.r.t a GameObject. @@ -160,7 +163,7 @@ namespace SHADE /// /// The results of the raycast. If nothing was hit, an empty list is returned. /// - static System::Collections::Generic::List^ ColliderLineCast (GameObject object, Vector3 start, Vector3 end, bool continuous); + static System::Collections::Generic::List^ ColliderLineCast (GameObject object, Vector3 start, Vector3 end, bool continuous, unsigned short layer); /// /// Casts a bounded ray w.r.t a specific collider on a GameObject. @@ -176,7 +179,7 @@ namespace SHADE /// /// /// The results of the raycast. If nothing was hit, an empty list is returned./// - static System::Collections::Generic::List^ ColliderLineCast (GameObject object, int shapeIndex, Vector3 start, Vector3 end, bool continuous); + static System::Collections::Generic::List^ ColliderLineCast (GameObject object, int shapeIndex, Vector3 start, Vector3 end, bool continuous, unsigned short layer); private: /*---------------------------------------------------------------------------------*/