mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
Turns out I missed a deref. get_cell should work now.
This commit is contained in:
parent
6b9b5254f3
commit
985bb6dbe2
1 changed files with 8 additions and 5 deletions
|
@ -7,17 +7,20 @@ pub(crate) struct ParticleWorldState {
|
|||
|
||||
impl ParticleWorldState {
|
||||
pub(crate) unsafe fn get_cell(&self, x: i32, y: i32) -> *const c_void {
|
||||
let x = dbg!(x as isize);
|
||||
let y = dbg!(y as isize);
|
||||
let x = x as isize;
|
||||
let y = y as isize;
|
||||
let chunk_index = (((((y) >> 9) - 256) & 511) * 512 + ((((x) >> 9) - 256) & 511)) * 4;
|
||||
// Deref 1/3
|
||||
let chunk_arr = self.chunk_map_this.offset(8).cast::<*const c_void>().read();
|
||||
// dbg!(chunk_arr);
|
||||
// Deref 2/3
|
||||
let chunk = chunk_arr.offset(chunk_index).cast::<*const c_void>().read();
|
||||
dbg!(chunk);
|
||||
if chunk.is_null() {
|
||||
// TODO this normally returns air material
|
||||
return null();
|
||||
}
|
||||
let pixel = chunk.offset(((y & 511) << 9 | x & 511) * 4);
|
||||
// Deref 3/3
|
||||
let pixel_array = chunk.cast::<*const c_void>().read();
|
||||
let pixel = pixel_array.offset(((y & 511) << 9 | x & 511) * 4);
|
||||
pixel
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue