Tweak tile collision function logic

Changelog:
- Remove check for same tag, seems to be the cause for unaligned crates
- Remove dead code: collision event collection
    - Will rethink this if necessary
scene_man
En Yi 2023-06-04 14:54:53 +08:00
parent 0e94e64a6a
commit 0d58ffd79a
1 changed files with 1 additions and 14 deletions

View File

@ -596,8 +596,7 @@ void tile_collision_system(Scene_t* scene)
checked_entities[other_ent_idx] = true;
Entity_t *p_other_ent = get_entity(&scene->ent_manager, other_ent_idx);
if (!p_other_ent->m_alive) continue; // To only allow one way collision check
if (p_other_ent->m_tag < p_ent->m_tag) continue; // To only allow one way collision check
if (!p_other_ent->m_alive) continue; // No need to move if other is dead
CBBox_t *p_other_bbox = get_component(p_other_ent, CBBOX_COMP_T);
if (p_other_bbox == NULL) continue;
@ -634,18 +633,6 @@ void tile_collision_system(Scene_t* scene)
if (p_ctransform->velocity.y > 0) p_ctransform->velocity.y = 0;
}
// TODO: Resolve all collision events
//uint32_t collision_key;
//sc_map_foreach(&data->collision_events, collision_key, collision_value)
//{
// ent_idx = (collision_key >> 16);
// uint other_ent_idx = (collision_key & 0xFFFF);
// Entity_t *p_ent = get_entity(&scene->ent_manager, ent_idx);
// Entity_t *p_other_ent = get_entity(&scene->ent_manager, other_ent_idx);
// if (!p_ent->m_alive || !p_other_ent->m_alive) continue;
//}
//sc_map_clear_32(&data->collision_events);
// Level boundary collision
unsigned int level_width = tilemap.width * TILE_SIZE;
if(p_ctransform->position.x < 0 || p_ctransform->position.x + p_bbox->size.x > level_width)