Path: blob/master/thirdparty/jolt_physics/Jolt/Physics/Collision/CollideSphereVsTriangles.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/Shape/Shape.h>7#include <Jolt/Physics/Collision/Shape/SubShapeID.h>8#include <Jolt/Physics/Collision/Shape/SphereShape.h>910JPH_NAMESPACE_BEGIN1112class CollideShapeSettings;1314/// Collision detection helper that collides a sphere vs one or more triangles15class JPH_EXPORT CollideSphereVsTriangles16{17public:18/// Constructor19/// @param inShape1 The sphere to collide against triangles20/// @param inScale1 Local space scale for the sphere (scales relative to its center of mass)21/// @param inScale2 Local space scale for the triangles22/// @param inCenterOfMassTransform1 Transform that takes the center of mass of 1 into world space23/// @param inCenterOfMassTransform2 Transform that takes the center of mass of 2 into world space24/// @param inSubShapeID1 Sub shape ID of the convex object25/// @param inCollideShapeSettings Settings for the collide shape query26/// @param ioCollector The collector that will receive the results27CollideSphereVsTriangles(const SphereShape *inShape1, Vec3Arg inScale1, Vec3Arg inScale2, Mat44Arg inCenterOfMassTransform1, Mat44Arg inCenterOfMassTransform2, const SubShapeID &inSubShapeID1, const CollideShapeSettings &inCollideShapeSettings, CollideShapeCollector &ioCollector);2829/// Collide sphere with a single triangle30/// @param inV0 , inV1 , inV2: CCW triangle vertices31/// @param inActiveEdges bit 0 = edge v0..v1 is active, bit 1 = edge v1..v2 is active, bit 2 = edge v2..v0 is active32/// 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 edge33/// @param inSubShapeID2 The sub shape ID for the triangle34void Collide(Vec3Arg inV0, Vec3Arg inV1, Vec3Arg inV2, uint8 inActiveEdges, const SubShapeID &inSubShapeID2);3536protected:37const CollideShapeSettings & mCollideShapeSettings; ///< Settings for this collision operation38CollideShapeCollector & mCollector; ///< The collector that will receive the results39const SphereShape * mShape1; ///< The shape that we're colliding with40Vec3 mScale2; ///< The scale of the shape (in shape local space) of the shape we're colliding against41Mat44 mTransform2; ///< Transform of the shape we're colliding against42Vec3 mSphereCenterIn2; ///< The center of the sphere in the space of 243SubShapeID mSubShapeID1; ///< Sub shape ID of colliding shape44float mScaleSign2; ///< Sign of the scale of object 2, -1 if object is inside out, 1 if not45float mRadius; ///< Radius of the sphere46float mRadiusPlusMaxSeparationSq; ///< (Radius + Max SeparationDistance)^247};4849JPH_NAMESPACE_END505152