(vertex_ptr: *const f64, vertex_count: f64, index_ptr: *const f64, index_count: f64)
| 1937 | |
| 1938 | #[no_mangle] |
| 1939 | pub extern "C" fn bloom_create_mesh(vertex_ptr: *const f64, vertex_count: f64, index_ptr: *const f64, index_count: f64) -> f64 { |
| 1940 | // Perry's TS `number[]` is f64-laid-out in memory; Perry passes a |
| 1941 | // pointer to that data. A previous version of this FFI declared |
| 1942 | // *const f32 / *const u32, which silently read the low 4 bytes |
| 1943 | // of each f64 slot as garbage f32/u32 values — meshes registered |
| 1944 | // (non-zero handle) but were unrenderable. |
| 1945 | // |
| 1946 | // Caller must pass `vertex_count` and `index_count` derived from |
| 1947 | // a literal-initialized array OR from values it computed itself. |
| 1948 | // Don't compute these via `arr.length` after `.push()` — Perry's |
| 1949 | // `.length` property currently reflects the literal-init size, |
| 1950 | // not the post-push count (a Perry codegen bug). Workaround on |
| 1951 | // the TS side: track the count manually or use literal arrays. |
| 1952 | if vertex_ptr.is_null() || index_ptr.is_null() { return 0.0; } |
| 1953 | let vcount = vertex_count as usize; |
| 1954 | let icount = index_count as usize; |
| 1955 | let vertex_f64 = unsafe { std::slice::from_raw_parts(vertex_ptr, vcount * 12) }; |
| 1956 | let index_f64 = unsafe { std::slice::from_raw_parts(index_ptr, icount) }; |
| 1957 | let vertex_data: Vec<f32> = vertex_f64.iter().map(|&v| v as f32).collect(); |
| 1958 | let index_data: Vec<u32> = index_f64.iter().map(|&v| v as u32).collect(); |
| 1959 | engine().models.create_mesh(&vertex_data, &index_data) |
| 1960 | } |
| 1961 | |
| 1962 | #[no_mangle] |
| 1963 | pub extern "C" fn bloom_load_model_animation(path_ptr: *const u8) -> f64 { |
nothing calls this directly
no test coverage detected