Handle stairs better
This commit is contained in:
@@ -51,12 +51,19 @@ void sceneMapGetWorldPosition(const worldpos_t pos, vec3 outPosition) {
|
||||
outPosition[0] = pos.x * TILE_WIDTH;
|
||||
outPosition[1] = pos.y * TILE_HEIGHT;
|
||||
outPosition[2] = pos.z * TILE_DEPTH;
|
||||
|
||||
// Handle stair tiles.
|
||||
tile_t tile = mapGetTile(pos);
|
||||
if(tileIsStairs(tile)) {
|
||||
outPosition[2] += TILE_DEPTH / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void sceneMapEntityGetPosition(const entity_t *entity, vec3 outPosition) {
|
||||
assertNotNull(entity, "Entity cannot be NULL");
|
||||
assertNotNull(outPosition, "Output position cannot be NULL");
|
||||
|
||||
// Get position
|
||||
sceneMapGetWorldPosition(entity->position, outPosition);
|
||||
|
||||
// Add animation offset(s)
|
||||
@@ -64,20 +71,12 @@ void sceneMapEntityGetPosition(const entity_t *entity, vec3 outPosition) {
|
||||
case ENTITY_ANIM_WALK:
|
||||
float_t animPercentage = entity->animTime / ENTITY_ANIM_WALK_DURATION;
|
||||
|
||||
// Get facing rel, we know we moved from the inverse direction.
|
||||
vec3 lastPosition;
|
||||
sceneMapGetWorldPosition(entity->lastPosition, lastPosition);
|
||||
|
||||
// Add tile size times percentage to posMin/max
|
||||
vec3 offset = {
|
||||
(
|
||||
(float_t)entity->position.x - (float_t)entity->lastPosition.x
|
||||
) * TILE_WIDTH * -animPercentage,
|
||||
(
|
||||
(float_t)entity->position.y - (float_t)entity->lastPosition.y
|
||||
) * TILE_HEIGHT * -animPercentage,
|
||||
(
|
||||
(float_t)entity->position.z - (float_t)entity->lastPosition.z
|
||||
) * TILE_DEPTH * -animPercentage
|
||||
};
|
||||
vec3 offset;
|
||||
glm_vec3_sub(outPosition, lastPosition, offset);
|
||||
glm_vec3_scale(offset, -animPercentage, offset);
|
||||
glm_vec3_add(outPosition, offset, outPosition);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user