0.2.0-dev Download ZIP
50 lines ·2.8 KB Raw
| 1 | // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics) |
| 2 | // SPDX-FileCopyrightText: 2021 Jorrit Rouwe |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | |
| 5 | #pragma once |
| 6 | |
| 7 | #include <Jolt/Physics/Collision/Shape/Shape.h> |
| 8 | #include <Jolt/Physics/Collision/Shape/SubShapeID.h> |
| 9 | #include <Jolt/Physics/Collision/Shape/SphereShape.h> |
| 10 | |
| 11 | JPH_NAMESPACE_BEGIN |
| 12 | |
| 13 | class CollideShapeSettings; |
| 14 | |
| 15 | /// Collision detection helper that collides a sphere vs one or more triangles |
| 16 | class JPH_EXPORT CollideSphereVsTriangles |
| 17 | { |
| 18 | public: |
| 19 | /// Constructor |
| 20 | /// @param inShape1 The sphere to collide against triangles |
| 21 | /// @param inScale1 Local space scale for the sphere (scales relative to its center of mass) |
| 22 | /// @param inScale2 Local space scale for the triangles |
| 23 | /// @param inCenterOfMassTransform1 Transform that takes the center of mass of 1 into world space |
| 24 | /// @param inCenterOfMassTransform2 Transform that takes the center of mass of 2 into world space |
| 25 | /// @param inSubShapeID1 Sub shape ID of the convex object |
| 26 | /// @param inCollideShapeSettings Settings for the collide shape query |
| 27 | /// @param ioCollector The collector that will receive the results |
| 28 | CollideSphereVsTriangles(const SphereShape *inShape1, Vec3Arg inScale1, Vec3Arg inScale2, Mat44Arg inCenterOfMassTransform1, Mat44Arg inCenterOfMassTransform2, const SubShapeID &inSubShapeID1, const CollideShapeSettings &inCollideShapeSettings, CollideShapeCollector &ioCollector); |
| 29 | |
| 30 | /// Collide sphere with a single triangle |
| 31 | /// @param inV0 , inV1 , inV2: CCW triangle vertices |
| 32 | /// @param inActiveEdges bit 0 = edge v0..v1 is active, bit 1 = edge v1..v2 is active, bit 2 = edge v2..v0 is active |
| 33 | /// An active edge is an edge that is not connected to another triangle in such a way that it is impossible to collide with the edge |
| 34 | /// @param inSubShapeID2 The sub shape ID for the triangle |
| 35 | void Collide(Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2, uint8 inActiveEdges, const SubShapeID &inSubShapeID2); |
| 36 | |
| 37 | protected: |
| 38 | const CollideShapeSettings & mCollideShapeSettings; ///< Settings for this collision operation |
| 39 | CollideShapeCollector & mCollector; ///< The collector that will receive the results |
| 40 | const SphereShape * mShape1; ///< The shape that we're colliding with |
| 41 | Vec3 mScale2; ///< The scale of the shape (in shape local space) of the shape we're colliding against |
| 42 | Mat44 mTransform2; ///< Transform of the shape we're colliding against |
| 43 | Vec3 mSphereCenterIn2; ///< The center of the sphere in the space of 2 |
| 44 | SubShapeID mSubShapeID1; ///< Sub shape ID of colliding shape |
| 45 | float mScaleSign2; ///< Sign of the scale of object 2, -1 if object is inside out, 1 if not |
| 46 | float mRadius; ///< Radius of the sphere |
| 47 | float mRadiusPlusMaxSeparationSq; ///< (Radius + Max SeparationDistance)^2 |
| 48 | }; |
| 49 | |
| 50 | JPH_NAMESPACE_END |