add 'static' entity body-type

This commit is contained in:
MihailRis
2024-07-29 15:45:28 +03:00
parent d6696b54cb
commit 2b7b68f3c2
7 changed files with 8 additions and 18 deletions
+1 -1
View File
@@ -411,7 +411,7 @@ void Entities::updatePhysics(float delta) {
auto view = registry.view<EntityId, Transform, Rigidbody>();
auto physics = level->physics.get();
for (auto [entity, eid, transform, rigidbody] : view.each()) {
if (!rigidbody.enabled) {
if (!rigidbody.enabled || rigidbody.hitbox.type == BodyType::STATIC) {
continue;
}
auto& hitbox = rigidbody.hitbox;
+3
View File
@@ -7,6 +7,8 @@ std::optional<BodyType> BodyType_from(std::string_view str) {
return BodyType::KINEMATIC;
} else if (str == "dynamic") {
return BodyType::DYNAMIC;
} else if (str == "static") {
return BodyType::STATIC;
}
return std::nullopt;
}
@@ -15,6 +17,7 @@ std::string to_string(BodyType type) {
switch (type) {
case BodyType::KINEMATIC: return "kinematic";
case BodyType::DYNAMIC: return "dynamic";
case BodyType::STATIC: return "static";
default: return "unknown";
}
}
+1 -1
View File
@@ -39,7 +39,7 @@ struct Sensor {
};
enum class BodyType {
KINEMATIC, DYNAMIC
STATIC, KINEMATIC, DYNAMIC
};
std::optional<BodyType> BodyType_from(std::string_view str);