VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
collisionComponent.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2025-2026 Arnis Lektauers
3#pragma once
4
5#include <algorithm>
6#include <string>
7#include <vector>
8
9#include "core/math/vector3.h"
12
13namespace visutwin::canvas
14{
15 class RenderComponent;
16
18 {
19 public:
21 ~CollisionComponent() override;
22
23 void initializeComponentData() override {}
24
25 static const std::vector<CollisionComponent*>& instances() { return _instances; }
26
27 const std::string& type() const { return _type; }
28 void setType(const std::string& type) { _type = type; }
29
30 const Vector3& halfExtents() const { return _halfExtents; }
31 void setHalfExtents(const Vector3& value) { _halfExtents = value; }
32
33 float radius() const { return _radius; }
34 void setRadius(const float value) { _radius = std::max(value, 0.001f); }
35
36 float height() const { return _height; }
37 void setHeight(const float value) { _height = std::max(value, 0.001f); }
38
40
41 private:
42 inline static std::vector<CollisionComponent*> _instances;
43
44 std::string _type = "box";
45 Vector3 _halfExtents = Vector3(0.5f, 0.5f, 0.5f);
46 float _radius = 0.5f;
47 float _height = 1.0f;
48 };
49}
Bounding sphere defined by center and radius for intersection and containment tests.
void setHalfExtents(const Vector3 &value)
void setType(const std::string &type)
static const std::vector< CollisionComponent * > & instances()
CollisionComponent(IComponentSystem *system, Entity *entity)
Entity * entity() const
Definition component.cpp:16
Component(IComponentSystem *system, Entity *entity)
Definition component.cpp:12
IComponentSystem * system() const
Definition component.h:47
ECS entity — a GraphNode that hosts components defining its behavior.
Definition entity.h:32
3D vector for positions, directions, and normals with multi-backend SIMD acceleration.
Definition vector3.h:29