add solid entities (wip)

This commit is contained in:
MihailRis 2026-02-23 17:34:24 +03:00
parent 3cd6ce1df2
commit 0a34f9b767
7 changed files with 158 additions and 116 deletions

View file

@ -278,13 +278,17 @@ void Entities::updateSensors(
}
void Entities::preparePhysics(float delta) {
auto& physics = *level.physics;
auto& solidHitboxes = physics.getSolidHitboxesWriteable();
if (sensorsTickClock.update(delta)) {
auto part = sensorsTickClock.getPart();
auto parts = sensorsTickClock.getParts();
auto& sensors = physics.getSensorsWriteable();
auto view = registry->view<EntityId, Transform, Rigidbody>();
auto physics = level.physics.get();
std::vector<Sensor*> sensors;
for (auto [entity, eid, transform, rigidbody] : view.each()) {
if (!rigidbody.enabled) {
continue;
@ -294,7 +298,16 @@ void Entities::preparePhysics(float delta) {
}
updateSensors(rigidbody, transform, sensors);
}
physics->setSensors(std::move(sensors));
}
solidHitboxes.clear();
auto view = registry->view<EntityId, Rigidbody>();
for (auto [entity, eid, rigidbody] : view.each()) {
if (!eid.def.solid || eid.destroyFlag || !rigidbody.enabled) {
continue;
}
solidHitboxes.emplace_back(&rigidbody.hitbox);
}
}

View file

@ -9,5 +9,7 @@ void EntityDef::cloneTo(EntityDef& dst) {
dst.radialSensors = radialSensors;
dst.skeletonName = skeletonName;
dst.blocking = blocking;
dst.solid = solid;
dst.stepHeight = stepHeight;
dst.save = save;
}

View file

@ -42,6 +42,9 @@ struct EntityDef {
/// @brief Does entity prevent blocks setup
bool blocking = true;
/// @brief Is the entity solid (blocks other entities)
bool solid = false;
/// @brief Max obstacle height that does not require jumping
float stepHeight = 0.5f;