MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / bloom_project_to_screen

Function bloom_project_to_screen

native/linux/src/lib.rs:2215–2240  ·  view source on GitHub ↗
(wx: f64, wy: f64, wz: f64)

Source from the content-addressed store, hash-verified

2213
2214#[no_mangle]
2215pub extern "C" fn bloom_project_to_screen(wx: f64, wy: f64, wz: f64) -> f64 {
2216 let eng = engine();
2217 let vp = eng.renderer.vp_matrix();
2218 let w = eng.renderer.width() as f32;
2219 let h = eng.renderer.height() as f32;
2220
2221 let x = wx as f32;
2222 let y = wy as f32;
2223 let z = wz as f32;
2224 let clip_x = vp[0][0]*x + vp[1][0]*y + vp[2][0]*z + vp[3][0];
2225 let clip_y = vp[0][1]*x + vp[1][1]*y + vp[2][1]*z + vp[3][1];
2226 let clip_w = vp[0][3]*x + vp[1][3]*y + vp[2][3]*z + vp[3][3];
2227
2228 if clip_w <= 0.0 {
2229 unsafe { LAST_PROJECT = (-9999.0, -9999.0); }
2230 return -9999.0;
2231 }
2232
2233 let ndc_x = clip_x / clip_w;
2234 let ndc_y = clip_y / clip_w;
2235 let screen_x = ((ndc_x + 1.0) * 0.5 * w) as f64;
2236 let screen_y = ((1.0 - ndc_y) * 0.5 * h) as f64;
2237
2238 unsafe { LAST_PROJECT = (screen_x, screen_y); }
2239 screen_x
2240}
2241
2242#[no_mangle]
2243pub extern "C" fn bloom_project_screen_y() -> f64 {

Callers

nothing calls this directly

Calls 4

vp_matrixMethod · 0.80
engineFunction · 0.70
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected