1use crate::custom_rand::{choice, rndtri, rndtri_f};
2
3#[derive(Debug, Clone, Copy)]
4pub struct Params {
5 pub body_curve_type: i64,
6 pub body_curve_amount: f64,
7 pub body_length: f64,
8 pub body_height: f64,
9 pub scale_type: i64,
10 pub scale_scale: f64,
11 pub pattern_type: i64,
12 pub pattern_scale: f64,
13 pub dorsal_texture_type: i64,
14 pub dorsal_type: i64,
15 pub dorsal_length: f64,
16 pub dorsal_start: usize,
17 pub dorsal_end: usize,
18 pub wing_texture_type: i64,
19 pub wing_type: i64,
20 pub wing_start: usize,
21 pub wing_end: usize,
22 pub wing_y: f64,
23 pub wing_length: f64,
24 pub wing_width: f64,
25 pub pelvic_start: usize,
26 pub pelvic_end: usize,
27 pub pelvic_length: f64,
28 pub pelvic_type: i64,
29 pub pelvic_texture_type: i64,
30 pub anal_start: usize,
31 pub anal_end: usize,
32 pub anal_length: f64,
33 pub anal_type: i64,
34 pub anal_texture_type: i64,
35 pub tail_type: i64,
36 pub tail_length: f64,
37 pub finlet_type: i64,
38 pub neck_type: i64,
39 pub nose_height: f64,
40 pub mouth_size: usize,
41 pub head_length: f64,
42 pub head_texture_amount: i64,
43 pub has_moustache: i64,
44 pub moustache_length: usize,
45 pub has_beard: i64,
46 pub has_teeth: i64,
47 pub teeth_length: f64,
48 pub teeth_space: f64,
49 pub beard_length: usize,
50 pub eye_type: i64,
51 pub eye_size: f64,
52 pub jaw_size: f64,
53 pub jaw_open: i64,
54}
55impl Params {
56 pub fn default() -> Self {
57 Params {
58 body_curve_type: 0,
59 body_curve_amount: 0.85,
60 body_length: 350.,
61 body_height: 90.,
62 scale_type: 1,
63 scale_scale: 1.,
64 pattern_type: 3,
65 pattern_scale: 1.,
66 dorsal_texture_type: 1,
67 dorsal_type: 0,
68 dorsal_length: 100.,
69 dorsal_start: 8,
70 dorsal_end: 27,
71 wing_texture_type: 0,
72 wing_type: 0,
73 wing_start: 6,
74 wing_end: 6,
75 wing_y: 0.7,
76 wing_length: 130.,
77 wing_width: 10.,
78 pelvic_start: 9,
79 pelvic_end: 14,
80 pelvic_length: 85.,
81 pelvic_type: 0,
82 pelvic_texture_type: 0,
83 anal_start: 19,
84 anal_end: 29,
85 anal_length: 50.,
86 anal_type: 0,
87 anal_texture_type: 0,
88 tail_type: 0,
89 tail_length: 75.,
90 finlet_type: 0,
91 neck_type: 0,
92 nose_height: 0.,
93 mouth_size: 8,
94 head_length: 30.,
95 head_texture_amount: 60,
96 has_moustache: 1,
97 moustache_length: 10,
98 has_beard: 0,
99 has_teeth: 1,
100 teeth_length: 8.,
101 teeth_space: 3.5,
102 beard_length: 30,
103 eye_type: 1,
104 eye_size: 10.,
105 jaw_size: 1.,
106 jaw_open: 1,
107 }
108 }
109}
110
111pub fn generate_params() -> Params {
112 let mut arg = Params::default();
113 arg.body_curve_type = *choice(&[0, 1], None);
114 arg.body_curve_amount = rndtri_f(0.5, 0.85, 0.98);
115 arg.body_length = rndtri_f(200., 350., 420.);
116 arg.body_height = rndtri_f(45., 90., 150.);
117 arg.scale_type = *choice(&[0, 1, 2, 3], None);
118 arg.scale_scale = rndtri_f(0.8, 1., 1.5);
119 arg.pattern_type = *choice(&[0, 1, 2, 3, 4], None);
120 arg.pattern_scale = rndtri_f(0.5, 1., 2.);
121 arg.dorsal_texture_type = *choice(&[0, 1], None);
122 arg.dorsal_type = *choice(&[0, 1], None);
123 arg.dorsal_length = rndtri_f(30., 90., 180.);
124 if arg.dorsal_type == 0 {
125 arg.dorsal_start = !!rndtri(7, 8, 15) as usize;
126 arg.dorsal_end = !!rndtri(20, 27, 28) as usize;
127 } else {
128 arg.dorsal_start = !!rndtri(11, 12, 16) as usize;
129 arg.dorsal_end = !!rndtri(19, 21, 24) as usize;
130 }
131 arg.wing_texture_type = *choice(&[0, 1], None);
132 arg.wing_type = *choice(&[0, 1], None);
133 if arg.wing_type == 0 {
134 arg.wing_length = rndtri_f(40., 130., 200.);
135 } else {
136 arg.wing_length = rndtri_f(40., 150., 350.);
137 }
138 if arg.wing_texture_type == 0 {
139 arg.wing_width = rndtri_f(7., 10., 20.);
140 arg.wing_y = rndtri_f(0.45, 0.7, 0.85);
141 } else {
142 arg.wing_width = rndtri_f(20., 30., 50.);
143 arg.wing_y = rndtri_f(0.45, 0.65, 0.75);
144 }
145
146 arg.wing_start = !!rndtri(5, 6, 8) as usize;
147 arg.wing_end = !!rndtri(5, 6, 8) as usize;
148
149 arg.pelvic_texture_type = if arg.dorsal_texture_type != 0 {
150 *choice(&[0, 1], None)
151 } else {
152 0
153 };
154 arg.pelvic_type = *choice(&[0, 1], None);
155 arg.pelvic_length = rndtri_f(30., 85., 140.);
156 if arg.pelvic_type == 0 {
157 arg.pelvic_start = !!rndtri(7, 9, 11) as usize;
158 arg.pelvic_end = !!rndtri(13, 14, 15) as usize;
159 } else {
160 arg.pelvic_start = !!rndtri(7, 9, 12) as usize;
161 arg.pelvic_end = arg.pelvic_start + 2;
162 }
163
164 arg.anal_texture_type = if arg.dorsal_texture_type != 0 {
165 *choice(&[0, 1], None)
166 } else {
167 0
168 };
169 arg.anal_type = *choice(&[0, 1], None);
170 arg.anal_length = rndtri_f(20., 50., 80.);
171 arg.anal_start = !!rndtri(16, 19, 23) as usize;
172 arg.anal_end = !!rndtri(25, 29, 31) as usize;
173
174 arg.tail_type = *choice(&[0, 1, 2, 3, 4, 5], None);
175 arg.tail_length = rndtri_f(50., 75., 180.);
176
177 arg.finlet_type = *choice(&[0, 1, 2, 3], None);
178
179 arg.neck_type = *choice(&[0, 1], None);
180 arg.nose_height = rndtri_f(-50., 0., 35.);
181 arg.head_length = rndtri_f(20., 30., 35.);
182 arg.mouth_size = rndtri(6, 8, 11) as usize;
183
184 arg.head_texture_amount = !!rndtri(30, 60, 160);
185 arg.has_moustache = *choice(&[0, 0, 0, 1], None);
186 arg.has_beard = *choice(&[0, 0, 0, 0, 0, 1], None);
187 arg.moustache_length = rndtri(10, 20, 40) as usize;
188 arg.beard_length = rndtri(20, 30, 50) as usize;
189
190 arg.eye_type = *choice(&[0, 1], None);
191 arg.eye_size = rndtri_f(8., 10., 28.); arg.jaw_size = rndtri_f(0.7, 1., 1.4);
194
195 arg.has_teeth = *choice(&[0, 1, 1], None);
196 arg.teeth_length = rndtri_f(5., 8., 15.);
197 arg.teeth_space = rndtri_f(3., 3.5, 6.);
198
199 return arg;
200}