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

Method draw_cube

native/shared/src/renderer/mod.rs:12520–12542  ·  view source on GitHub ↗
(&mut self, x: f64, y: f64, z: f64, w: f64, h: f64, d: f64, r: f64, g: f64, b: f64, a: f64)

Source from the content-addressed store, hash-verified

12518 }
12519
12520 pub fn draw_cube(&mut self, x: f64, y: f64, z: f64, w: f64, h: f64, d: f64, r: f64, g: f64, b: f64, a: f64) {
12521 self.ensure_draw_state_3d(self.current_texture_3d);
12522 let color = Self::color_to_f32(r, g, b, a);
12523 let (x, y, z) = (x as f32, y as f32, z as f32);
12524 let (hw, hh, hd) = (w as f32 * 0.5, h as f32 * 0.5, d as f32 * 0.5);
12525
12526 let faces: [([f32; 3], [[f32; 3]; 4]); 6] = [
12527 ([0.0, 0.0, -1.0], [[x-hw,y-hh,z-hd],[x+hw,y-hh,z-hd],[x+hw,y+hh,z-hd],[x-hw,y+hh,z-hd]]), // front
12528 ([0.0, 0.0, 1.0], [[x+hw,y-hh,z+hd],[x-hw,y-hh,z+hd],[x-hw,y+hh,z+hd],[x+hw,y+hh,z+hd]]), // back
12529 ([-1.0, 0.0, 0.0], [[x-hw,y-hh,z+hd],[x-hw,y-hh,z-hd],[x-hw,y+hh,z-hd],[x-hw,y+hh,z+hd]]), // left
12530 ([1.0, 0.0, 0.0], [[x+hw,y-hh,z-hd],[x+hw,y-hh,z+hd],[x+hw,y+hh,z+hd],[x+hw,y+hh,z-hd]]), // right
12531 ([0.0, 1.0, 0.0], [[x-hw,y+hh,z-hd],[x+hw,y+hh,z-hd],[x+hw,y+hh,z+hd],[x-hw,y+hh,z+hd]]), // top
12532 ([0.0, -1.0, 0.0], [[x-hw,y-hh,z+hd],[x+hw,y-hh,z+hd],[x+hw,y-hh,z-hd],[x-hw,y-hh,z-hd]]), // bottom
12533 ];
12534
12535 for (normal, verts) in &faces {
12536 let base = self.vertices_3d.len() as u32;
12537 for v in verts {
12538 self.vertices_3d.push(Vertex3D { position: *v, normal: *normal, color, uv: [0.0, 0.0], joints: [0.0; 4], weights: [0.0; 4], tangent: [0.0; 4] });
12539 }
12540 self.indices_3d.extend_from_slice(&[base, base+1, base+2, base, base+2, base+3]);
12541 }
12542 }
12543
12544 pub fn draw_cube_wires(&mut self, x: f64, y: f64, z: f64, w: f64, h: f64, d: f64, r: f64, g: f64, b: f64, a: f64) {
12545 let color = Self::color_to_f32(r, g, b, a);

Callers 7

bloom_draw_cubeFunction · 0.80
bloom_draw_cubeFunction · 0.80
bloom_draw_cubeFunction · 0.80
bloom_draw_cubeFunction · 0.80
bloom_draw_cubeFunction · 0.80
bloom_draw_cubeFunction · 0.80
bloom_draw_cubeFunction · 0.80

Calls 2

ensure_draw_state_3dMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected