| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "jolt_custom_decorated_shape.h" |
| 34 |
#include "jolt_custom_shape_type.h" |
| 35 |
|
| 36 |
class JoltCustomDoubleSidedShapeSettings final : public JoltCustomDecoratedShapeSettings { |
| 37 |
public: |
| 38 |
bool back_face_collision = false; |
| 39 |
|
| 40 |
JoltCustomDoubleSidedShapeSettings() = default; |
| 41 |
|
| 42 |
JoltCustomDoubleSidedShapeSettings(const ShapeSettings *p_inner_settings, bool p_back_face_collision) : |
| 43 |
JoltCustomDecoratedShapeSettings(p_inner_settings), back_face_collision(p_back_face_collision) {} |
| 44 |
|
| 45 |
JoltCustomDoubleSidedShapeSettings(const JPH::Shape *p_inner_shape, bool p_back_face_collision) : |
| 46 |
JoltCustomDecoratedShapeSettings(p_inner_shape), back_face_collision(p_back_face_collision) {} |
| 47 |
|
| 48 |
virtual JPH::Shape::ShapeResult Create() const override; |
| 49 |
}; |
| 50 |
|
| 51 |
class JoltCustomDoubleSidedShape final : public JoltCustomDecoratedShape { |
| 52 |
bool back_face_collision = false; |
| 53 |
|
| 54 |
public: |
| 55 |
static void register_type(); |
| 56 |
|
| 57 |
JoltCustomDoubleSidedShape() : |
| 58 |
JoltCustomDecoratedShape(JoltCustomShapeSubType::DOUBLE_SIDED) {} |
| 59 |
|
| 60 |
JoltCustomDoubleSidedShape(const JoltCustomDoubleSidedShapeSettings &p_settings, JPH::Shape::ShapeResult &p_result) : |
| 61 |
JoltCustomDecoratedShape(JoltCustomShapeSubType::DOUBLE_SIDED, p_settings, p_result), back_face_collision(p_settings.back_face_collision) { |
| 62 |
if (!p_result.HasError()) { |
| 63 |
p_result.Set(this); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
JoltCustomDoubleSidedShape(const JPH::Shape *p_inner_shape, bool p_back_face_collision) : |
| 68 |
JoltCustomDecoratedShape(JoltCustomShapeSubType::DOUBLE_SIDED, p_inner_shape), back_face_collision(p_back_face_collision) {} |
| 69 |
|
| 70 |
virtual void CastRay(const JPH::RayCast &p_ray, const JPH::RayCastSettings &p_ray_cast_settings, const JPH::SubShapeIDCreator &p_sub_shape_id_creator, JPH::CastRayCollector &p_collector, const JPH::ShapeFilter &p_shape_filter = JPH::ShapeFilter()) const override; |
| 71 |
|
| 72 |
bool should_collide_with_back_faces() const { return back_face_collision; } |
| 73 |
}; |