luaur_bytecode/methods/
bytecode_builder_add_constant_vector.rs1use crate::enums::r#type::Type;
2use crate::records::bytecode_builder::BytecodeBuilder;
3use crate::records::constant::Constant;
4use crate::records::constant_key::ConstantKey;
5
6impl BytecodeBuilder {
7 pub fn add_constant_vector(&mut self, x: f32, y: f32, z: f32, w: f32) -> i32 {
8 let mut c = Constant {
9 r#type: Type::Type_Vector,
10 value: unsafe { core::mem::zeroed() },
11 };
12 c.value.valueVector = [x, y, z, w];
15
16 let mut k = ConstantKey {
17 r#type: Type::Type_Vector,
18 value: 0,
19 extra: 0,
20 };
21
22 k.value = x.to_bits() as u64;
23 k.value |= (y.to_bits() as u64) << 32;
24
25 k.extra = z.to_bits() as u64;
26 k.extra |= (w.to_bits() as u64) << 32;
27
28 self.add_constant(k, c)
29 }
30}