Add Capsule collider
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
<prefab name="Player" type="">
|
<prefab name="Player" type="">
|
||||||
<MeshRenderer />
|
<MeshRenderer />
|
||||||
<CubeMeshHost />
|
<CapsuleMeshHost />
|
||||||
<SimpleTexturedMaterial ref="material" />
|
<SimpleTexturedMaterial ref="material" />
|
||||||
<CharacterController2D />
|
<CharacterController2D />
|
||||||
<BoxCollider min="-1, -1" max="1, 1" />
|
<BoxCollider min="-1, -1" max="1, 1" />
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<child position="0, 0, -0.7">
|
<child position="0, 0, -0.7">
|
||||||
<MeshRenderer />
|
<MeshRenderer />
|
||||||
<CubeMeshHost ref="burnout" size="0.4, 0.4, 0.4" />
|
<CubeMeshHost size="0.4, 0.4, 0.4" />
|
||||||
<SimpleTexturedMaterial color="COLOR_RED" />
|
<SimpleTexturedMaterial color="COLOR_RED" />
|
||||||
</child>
|
</child>
|
||||||
</prefab>
|
</prefab>
|
@ -8,5 +8,6 @@ target_sources(${DAWN_TARGET_NAME}
|
|||||||
PRIVATE
|
PRIVATE
|
||||||
MeshRenderer.cpp
|
MeshRenderer.cpp
|
||||||
CubeMeshHost.cpp
|
CubeMeshHost.cpp
|
||||||
|
CapsuleMeshHost.cpp
|
||||||
MeshHost.cpp
|
MeshHost.cpp
|
||||||
)
|
)
|
21
src/dawn/scene/components/display/mesh/CapsuleMeshHost.cpp
Normal file
21
src/dawn/scene/components/display/mesh/CapsuleMeshHost.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright (c) 2023 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#include "CapsuleMeshHost.hpp"
|
||||||
|
|
||||||
|
using namespace Dawn;
|
||||||
|
|
||||||
|
CapsuleMeshHost::CapsuleMeshHost(SceneItem *item) :
|
||||||
|
MeshHost(item),
|
||||||
|
radius(0.5f),
|
||||||
|
height(1.0f)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CapsuleMeshHost::onStart() {
|
||||||
|
useEffect([&]{
|
||||||
|
CapsuleMesh::create(&this->mesh, radius, height);
|
||||||
|
}, { &this->radius, &this->height })();
|
||||||
|
}
|
22
src/dawn/scene/components/display/mesh/CapsuleMeshHost.hpp
Normal file
22
src/dawn/scene/components/display/mesh/CapsuleMeshHost.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright (c) 2023 Dominic Masters
|
||||||
|
//
|
||||||
|
// This software is released under the MIT License.
|
||||||
|
// https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "MeshHost.hpp"
|
||||||
|
#include "display/mesh/CapsuleMesh.hpp"
|
||||||
|
|
||||||
|
namespace Dawn {
|
||||||
|
class CapsuleMeshHost : public MeshHost {
|
||||||
|
public:
|
||||||
|
// @optional
|
||||||
|
StateProperty<float> radius;
|
||||||
|
// @optional
|
||||||
|
StateProperty<float> height;
|
||||||
|
|
||||||
|
CapsuleMeshHost(SceneItem *item);
|
||||||
|
|
||||||
|
void onStart() override;
|
||||||
|
};
|
||||||
|
}
|
Reference in New Issue
Block a user