rive_rs/bones/
cubic_weight.rs
1use std::cell::Cell;
6
7use crate::bones::Weight;
8use crate::core::{Core, ObjectRef, OnAdded, Property};
9use crate::math;
10
11#[derive(Debug)]
12pub struct CubicWeight {
13 weight: Weight,
14 in_values: Property<u64>,
15 in_indices: Property<u64>,
16 out_values: Property<u64>,
17 out_indices: Property<u64>,
18 in_translation: Cell<math::Vec>,
19 out_translation: Cell<math::Vec>,
20}
21
22impl ObjectRef<'_, CubicWeight> {
23 pub fn in_values(&self) -> u64 {
24 self.in_values.get()
25 }
26
27 pub fn set_in_values(&self, in_values: u64) {
28 self.in_values.set(in_values);
29 }
30
31 pub fn in_indices(&self) -> u64 {
32 self.in_indices.get()
33 }
34
35 pub fn set_in_indices(&self, in_indices: u64) {
36 self.in_indices.set(in_indices);
37 }
38
39 pub fn out_values(&self) -> u64 {
40 self.out_values.get()
41 }
42
43 pub fn set_out_values(&self, out_values: u64) {
44 self.out_values.set(out_values);
45 }
46
47 pub fn out_indices(&self) -> u64 {
48 self.out_indices.get()
49 }
50
51 pub fn set_out_indices(&self, out_indices: u64) {
52 self.out_indices.set(out_indices);
53 }
54}
55
56impl ObjectRef<'_, CubicWeight> {
57 pub fn in_translation(&self) -> math::Vec {
58 self.in_translation.get()
59 }
60
61 pub fn set_in_translation(&self, in_translation: math::Vec) {
62 self.in_translation.set(in_translation);
63 }
64
65 pub fn out_translation(&self) -> math::Vec {
66 self.out_translation.get()
67 }
68
69 pub fn set_out_translation(&self, out_translation: math::Vec) {
70 self.out_translation.set(out_translation);
71 }
72}
73
74impl Core for CubicWeight {
75 parent_types![(weight, Weight)];
76
77 properties![
78 (110, in_values, set_in_values),
79 (111, in_indices, set_in_indices),
80 (112, out_values, set_out_values),
81 (113, out_indices, set_out_indices),
82 weight,
83 ];
84}
85
86impl OnAdded for ObjectRef<'_, CubicWeight> {
87 on_added!(Weight);
88}
89
90impl Default for CubicWeight {
91 fn default() -> Self {
92 Self {
93 weight: Weight::default(),
94 in_values: Property::new(255),
95 in_indices: Property::new(1),
96 out_values: Property::new(255),
97 out_indices: Property::new(1),
98 in_translation: Cell::new(math::Vec::default()),
99 out_translation: Cell::new(math::Vec::default()),
100 }
101 }
102}