mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 09:29:44 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
bf59e520a7
109 changed files with 1908 additions and 474 deletions
|
|
@ -328,14 +328,17 @@ void Entities::preparePhysics(float delta) {
|
|||
auto view = registry->view<EntityId, Rigidbody>();
|
||||
for (auto [entity, eid, rigidbody] : view.each()) {
|
||||
auto bodyType = rigidbody.hitbox.type;
|
||||
if (eid.destroyFlag || !rigidbody.enabled || bodyType == BodyType::STATIC) {
|
||||
if (eid.destroyFlag || !rigidbody.enabled) {
|
||||
continue;
|
||||
}
|
||||
rigidbody.hitbox.selectable = rigidbody.selectable;
|
||||
rigidbody.hitbox.mass = bodyType == BodyType::DYNAMIC
|
||||
? rigidbody.mass
|
||||
: std::numeric_limits<float>::infinity();
|
||||
rigidbody.hitbox.elasticity = rigidbody.elasticity;
|
||||
rigidbody.hitbox.selectable = rigidbody.selectable;
|
||||
if (bodyType == BodyType::STATIC) {
|
||||
continue;
|
||||
}
|
||||
hitboxes.emplace_back(&rigidbody.hitbox);
|
||||
if (!eid.def.solid) {
|
||||
continue;
|
||||
|
|
@ -480,15 +483,17 @@ void Entities::render(
|
|||
const Frustum* frustum,
|
||||
entityid_t fpsEntity
|
||||
) {
|
||||
auto view = registry->view<EntityId, Transform, rigging::Skeleton>();
|
||||
for (auto [entity, eid, transform, skeleton] : view.each()) {
|
||||
auto view = registry->view<EntityId, Transform, rigging::Skeleton, Rigidbody>();
|
||||
for (auto [entity, eid, transform, skeleton, rigidbody] : view.each()) {
|
||||
if (eid.uid == fpsEntity) {
|
||||
continue;
|
||||
}
|
||||
const auto& def = eid.def;
|
||||
const auto& pos = transform.pos;
|
||||
const auto& size = transform.size;
|
||||
if (frustum && !frustum->isBoxVisible(pos - size, pos + size)) {
|
||||
const auto& halfSize = rigidbody.hitbox.getHalfSize();
|
||||
// todo: more correct frustum culling
|
||||
if (frustum && !frustum->isBoxVisible(pos - halfSize, pos + halfSize)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue