Fixed raycast sphere.

This commit is contained in:
2023-03-18 22:58:26 -07:00
parent 669b02ca06
commit f8ab4e2abc
9 changed files with 249 additions and 189 deletions

View File

@ -39,12 +39,13 @@ void PlayerController::onStart() {
// tEST
auto collider = item->getComponent<CapsuleCollider>();
auto collider = item->getComponent<Collider3D>();
assertNotNull(collider);
Collider3DRayResult result;
struct Ray3D ray;
ray.origin = glm::vec3(0, 0.5f, 1);
ray.direction = glm::vec3(10, 0, 0);
ray.origin = glm::vec3(0, 0.0f, 5);
ray.direction = glm::vec3(0, 0.0f, -4);
struct Color color = COLOR_MAGENTA;
@ -54,7 +55,7 @@ void PlayerController::onStart() {
getScene()->debugRay({
.start = result.point,
.direction = (result.normal * 100.0f),
.direction = result.normal,
.color = COLOR_GREEN
});
}

View File

@ -7,14 +7,14 @@
#include "scene/Scene.hpp"
#include "scene/components/PlayerController.hpp"
#include "scene/components/GameCamera.hpp"
#include "scene/components/physics/3d/CubeCollider.hpp"
#include "scene/components/physics/3d/CapsuleCollider.hpp"
#include "scene/components/GameCamera.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/MeshHost.hpp"
#include "scene/components/display/material/SimpleTexturedMaterial.hpp"
#include "display/mesh/CapsuleMesh.hpp"
#include "scene/components/example/ExampleSpin.hpp"
#include "scene/components/physics/3d/SphereCollider.hpp"
#include "scene/components/physics/3d/CubeCollider.hpp"
#include "display/mesh/SphereMesh.hpp"
namespace Dawn {
class HelloWorldScene : public Scene {
@ -25,12 +25,11 @@ namespace Dawn {
auto playerItem = this->createSceneItem();
auto player = playerItem->addComponent<PlayerController>();
auto hitbox = playerItem->addComponent<CapsuleCollider>();
playerItem->addComponent<MeshRenderer>();
auto meshHost = playerItem->addComponent<MeshHost>();
playerItem->addComponent<SimpleTexturedMaterial>();
CapsuleMesh::create(&meshHost->mesh, hitbox->radius, hitbox->height);
auto hitbox = playerItem->addComponent<SphereCollider>();
SphereMesh::createSphere(&meshHost->mesh, hitbox->radius, 32, 32);
auto wall = this->createSceneItem();
auto wallHitbox = wall->addComponent<CubeCollider>();