35 lines
783 B
C++
35 lines
783 B
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "CapsuleCollider.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
CapsuleCollider::CapsuleCollider(std::weak_ptr<SceneItem> item) : Collider3D(item) {
|
|
|
|
}
|
|
|
|
bool_t CapsuleCollider::performRaycast(
|
|
struct Collider3DRayResult *result,
|
|
struct Ray3D ray
|
|
) {
|
|
assertNotNull(result, "CapsuleCollider::performRaycast: Result cannot be null");
|
|
|
|
return raytestCapsule(
|
|
ray,
|
|
{
|
|
.height = this->height,
|
|
.radius = this->radius,
|
|
.origin = item.lock()->getWorldPosition()
|
|
},
|
|
&result->point,
|
|
&result->normal,
|
|
&result->distance
|
|
);
|
|
}
|
|
|
|
enum Collider3DType CapsuleCollider::getColliderType() {
|
|
return COLLIDER3D_TYPE_CAPSULE;
|
|
} |