Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/Collision/CastSphereVsTriangles.h
9912 views
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)1// SPDX-FileCopyrightText: 2021 Jorrit Rouwe2// SPDX-License-Identifier: MIT34#pragma once56#include <Jolt/Physics/Collision/ShapeCast.h>78JPH_NAMESPACE_BEGIN910/// Collision detection helper that casts a sphere vs one or more triangles11class JPH_EXPORT CastSphereVsTriangles12{13public:14/// Constructor15/// @param inShapeCast The sphere to cast against the triangles and its start and direction16/// @param inShapeCastSettings Settings for performing the cast17/// @param inScale Local space scale for the shape to cast against (scales relative to its center of mass).18/// @param inCenterOfMassTransform2 Is the center of mass transform of shape 2 (excluding scale), this is used to provide a transform to the shape cast result so that local quantities can be transformed into world space.19/// @param inSubShapeIDCreator1 Class that tracks the current sub shape ID for the casting shape20/// @param ioCollector The collector that receives the results.21CastSphereVsTriangles(const ShapeCast &inShapeCast, const ShapeCastSettings &inShapeCastSettings, Vec3Arg inScale, Mat44Arg inCenterOfMassTransform2, const SubShapeIDCreator &inSubShapeIDCreator1, CastShapeCollector &ioCollector);2223/// Cast sphere with a single triangle24/// @param inV0 , inV1 , inV2: CCW triangle vertices25/// @param inActiveEdges bit 0 = edge v0..v1 is active, bit 1 = edge v1..v2 is active, bit 2 = edge v2..v0 is active26/// 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 edge27/// @param inSubShapeID2 The sub shape ID for the triangle28void Cast(Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2, uint8 inActiveEdges, const SubShapeID &inSubShapeID2);2930protected:31Vec3 mStart; ///< Starting location of the sphere32Vec3 mDirection; ///< Direction and length of movement of sphere33float mRadius; ///< Scaled radius of sphere34const ShapeCastSettings & mShapeCastSettings;35const Mat44 & mCenterOfMassTransform2;36Vec3 mScale;37SubShapeIDCreator mSubShapeIDCreator1;38CastShapeCollector & mCollector;3940private:41void AddHit(bool inBackFacing, const SubShapeID &inSubShapeID2, float inFraction, Vec3Arg inContactPointA, Vec3Arg inContactPointB, Vec3Arg inContactNormal);42void AddHitWithActiveEdgeDetection(Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2, bool inBackFacing, Vec3Arg inTriangleNormal, uint8 inActiveEdges, const SubShapeID &inSubShapeID2, float inFraction, Vec3Arg inContactPointA, Vec3Arg inContactPointB, Vec3Arg inContactNormal);43float RayCylinder(Vec3Arg inRayDirection, Vec3Arg inCylinderA, Vec3Arg inCylinderB, float inRadius) const;4445float mScaleSign; ///< Sign of the scale, -1 if object is inside out, 1 if not46};4748JPH_NAMESPACE_END495051