add query to get orientation and trile at point in chunk
This commit is contained in:
parent
c55f26178f
commit
75b1752dba
@ -500,8 +500,7 @@ add_trile :: (name: string, x: s32, y: s32, z: s32, orientation: u8 = 0) {
|
|||||||
invalidate_buried_around(*curworld.world, x, y, z);
|
invalidate_buried_around(*curworld.world, x, y, z);
|
||||||
trile, ok := get_trile(name);
|
trile, ok := get_trile(name);
|
||||||
if !ok || trile.skip_collision then return;
|
if !ok || trile.skip_collision then return;
|
||||||
new_state : Occupancy_State = ifx trile.is_stairs then .OCCUPIED_STAIRS else .OCCUPIED;
|
chunk_set_occupancy_mask_at(chunk, lx, ly, lz, occupancy_state_for(trile, orientation));
|
||||||
chunk_set_occupancy_mask_at(chunk, lx, ly, lz, new_state);
|
|
||||||
} @Command
|
} @Command
|
||||||
|
|
||||||
remove_trile :: (x: s32, y: s32, z: s32) {
|
remove_trile :: (x: s32, y: s32, z: s32) {
|
||||||
|
|||||||
@ -144,16 +144,21 @@ World :: struct {
|
|||||||
rdm_lookup : [..]Rdm_Atlas_Entry; // populated by bake (Step 5) and by loader (Step 6)
|
rdm_lookup : [..]Rdm_Atlas_Entry; // populated by bake (Step 5) and by loader (Step 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The mask state a colliding trile instance contributes. Stairs only count as
|
||||||
|
// stairs when upright.
|
||||||
|
occupancy_state_for :: inline (trile: *Trile, orientation: u8) -> Occupancy_State {
|
||||||
|
if trile.is_stairs && orientation < 4 return .OCCUPIED_STAIRS;
|
||||||
|
return .OCCUPIED;
|
||||||
|
}
|
||||||
|
|
||||||
calculate_and_set_chunk_occupancy_mask :: (chunk: *Chunk) {
|
calculate_and_set_chunk_occupancy_mask :: (chunk: *Chunk) {
|
||||||
chunk_clear_full_occupancy_mask(chunk);
|
chunk_clear_full_occupancy_mask(chunk);
|
||||||
|
|
||||||
for group: chunk.groups {
|
for group: chunk.groups {
|
||||||
trile, ok := get_trile(group.trile_name);
|
trile, ok := get_trile(group.trile_name);
|
||||||
if !ok || trile.skip_collision then continue;
|
if !ok || trile.skip_collision then continue;
|
||||||
new_state : Occupancy_State = ifx trile.is_stairs then .OCCUPIED_STAIRS else .OCCUPIED;
|
|
||||||
|
|
||||||
for instance : group.instances {
|
for instance : group.instances {
|
||||||
chunk_set_occupancy_mask_at(chunk, instance.x, instance.y, instance.z, new_state);
|
chunk_set_occupancy_mask_at(chunk, instance.x, instance.y, instance.z, occupancy_state_for(trile, instance.orientation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -436,6 +441,22 @@ get_note_locations :: (note : string) -> []Vector3 {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trile_instance_at_chunk :: (chunk: *Chunk, lx: s32, ly: s32, lz: s32) -> (bool, Trile_Instance, *Trile) {
|
||||||
|
for group : chunk.groups {
|
||||||
|
for instance : group.instances {
|
||||||
|
if instance.x == lx && instance.y == ly && instance.z == lz {
|
||||||
|
trile, ok := get_trile(group.trile_name);
|
||||||
|
if !ok {
|
||||||
|
print("Error: did not find matching trile for group %\n", group.trile_name);
|
||||||
|
return false, .{}, null;
|
||||||
|
}
|
||||||
|
return true, instance, trile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false, .{}, null;
|
||||||
|
}
|
||||||
|
|
||||||
invalidate_buried_around :: (world: *World, wx: s32, wy: s32, wz: s32) {
|
invalidate_buried_around :: (world: *World, wx: s32, wy: s32, wz: s32) {
|
||||||
recompute_buried_at_cell(world, wx, wy, wz);
|
recompute_buried_at_cell(world, wx, wy, wz);
|
||||||
for axis: 0..5 {
|
for axis: 0..5 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user