diff --git a/doc/en/entity-properties.md b/doc/en/entity-properties.md index 7aaad78a..f9ff2aa0 100644 --- a/doc/en/entity-properties.md +++ b/doc/en/entity-properties.md @@ -39,6 +39,7 @@ Example: Determines how the physics engine will work with it. +- *static* - static body. No physics calculation, no velocity. - *dynamic* - default type. The physics engine calculates movement and collisions. - *kinematic* - only movement is calculated, without collisions. diff --git a/doc/en/scripting/ecs.md b/doc/en/scripting/ecs.md index 2b339864..db298a42 100644 --- a/doc/en/scripting/ecs.md +++ b/doc/en/scripting/ecs.md @@ -1,12 +1,5 @@ # Entities and components -## Types notation used below - -- vec3 - 3D vector (array of three numbers) -- mat4 - 4x4 matrix (array of 16 numbers) - -Type annotations are added for documentation purposes and are not part of the Lua syntax. - ## Entity The entity object is available in components as a global variable **entity**. @@ -107,7 +100,7 @@ body:is_crouching() -> bool -- Enables/disables the "crouching" state body:set_crouching(enabled: bool) --- Returns the type of physical body (dynamic/kinematic) +-- Returns the type of physical body (static/dynamic/kinematic) body:get_body_type() -> str -- Sets the physical body type body:set_body_type(type: str) diff --git a/doc/ru/entity-properties.md b/doc/ru/entity-properties.md index 9c68c3ab..3a6825ac 100644 --- a/doc/ru/entity-properties.md +++ b/doc/ru/entity-properties.md @@ -39,6 +39,7 @@ Определяет то, как с ним будет работать физический движок. +- *static* (статический) - физический движок не воздействует на тело. - *dynamic* (динамический) - тип по-умолчанию. Физический движок просчитывает движение и столкновения. - *kinematic* (кинематический) - просчитывается только движение, без столкновений. diff --git a/doc/ru/scripting/ecs.md b/doc/ru/scripting/ecs.md index 5090c264..0e9c2524 100644 --- a/doc/ru/scripting/ecs.md +++ b/doc/ru/scripting/ecs.md @@ -1,13 +1,5 @@ # Сущности и компоненты -## Обозначения типов, используемые далее - -- vec3 - 3D вектор (массив из трех чисел) -- mat4 - матрица 4x4 (массив из 16 чисел) - -Аннотации типов добавлены в целях документации и не являются частью синтаксиса -Lua. - ## Сущность Объект сущности доступен в компонентах как глобальная переменная **entity**. diff --git a/src/objects/Entities.cpp b/src/objects/Entities.cpp index 7f2d1347..e2b16aaa 100644 --- a/src/objects/Entities.cpp +++ b/src/objects/Entities.cpp @@ -411,7 +411,7 @@ void Entities::updatePhysics(float delta) { auto view = registry.view(); 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; diff --git a/src/physics/Hitbox.cpp b/src/physics/Hitbox.cpp index e77be865..f80dc0c5 100644 --- a/src/physics/Hitbox.cpp +++ b/src/physics/Hitbox.cpp @@ -7,6 +7,8 @@ std::optional 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"; } } diff --git a/src/physics/Hitbox.hpp b/src/physics/Hitbox.hpp index df0fef29..6d96f3f0 100644 --- a/src/physics/Hitbox.hpp +++ b/src/physics/Hitbox.hpp @@ -39,7 +39,7 @@ struct Sensor { }; enum class BodyType { - KINEMATIC, DYNAMIC + STATIC, KINEMATIC, DYNAMIC }; std::optional BodyType_from(std::string_view str);