fix bugs
This commit is contained in:
parent
b83fed45df
commit
a49bd2b123
|
@ -3,4 +3,5 @@
|
||||||
# Note: due to how Godot finds paths, this works best if cwd is this directory
|
# Note: due to how Godot finds paths, this works best if cwd is this directory
|
||||||
|
|
||||||
|
|
||||||
./pack_res.gd ++ $@
|
BASENAMES=$(find -name 'VA_*.mdd' | sed s@\./@@ | sed s@\.mdd@@ | tr "\n" " ")
|
||||||
|
./pack_res.gd ++ $BASENAMES
|
||||||
|
|
|
@ -17,6 +17,7 @@ var VertexAnimations = preload("VertexAnimations.gd")
|
||||||
|
|
||||||
func _init():
|
func _init():
|
||||||
var basenames := OS.get_cmdline_user_args()
|
var basenames := OS.get_cmdline_user_args()
|
||||||
|
print(basenames)
|
||||||
|
|
||||||
var animations = VertexAnimations.new()
|
var animations = VertexAnimations.new()
|
||||||
animations.name = "VertexAnimations"
|
animations.name = "VertexAnimations"
|
||||||
|
|
|
@ -122,15 +122,17 @@ fn _write_animation_info(filename: &str, info: AnimationInfo) -> Result<(), Box<
|
||||||
enum PointState {
|
enum PointState {
|
||||||
Unseen,
|
Unseen,
|
||||||
OneValue { point_idx: usize, point: Point },
|
OneValue { point_idx: usize, point: Point },
|
||||||
Varying { new_idx: usize },
|
Varying,
|
||||||
|
Reindexed { new_idx: usize },
|
||||||
}
|
}
|
||||||
use PointState::*;
|
use PointState::*;
|
||||||
impl PointState {
|
impl PointState {
|
||||||
fn mask_value(&self) -> f32 {
|
fn mask_value(&self) -> f32 {
|
||||||
match *self {
|
match *self {
|
||||||
Unseen => panic!("no point should be unseen"),
|
Unseen => panic!("no point should be unseen"),
|
||||||
|
Varying => panic!("no point should be unindexed"),
|
||||||
OneValue { .. } => -1.0,
|
OneValue { .. } => -1.0,
|
||||||
Varying { new_idx, .. } => new_idx as f32,
|
Reindexed { new_idx, .. } => new_idx as f32,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn point_changed(a: &Point, b: &Point) -> bool {
|
fn point_changed(a: &Point, b: &Point) -> bool {
|
||||||
|
@ -138,7 +140,6 @@ impl PointState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let basename = std::env::args()
|
let basename = std::env::args()
|
||||||
.nth(1)
|
.nth(1)
|
||||||
|
@ -152,7 +153,6 @@ fn main() {
|
||||||
|
|
||||||
let mut mask_last: Vec<PointState> = vec![Unseen; info.total_points];
|
let mut mask_last: Vec<PointState> = vec![Unseen; info.total_points];
|
||||||
let pc = MDDSeekableFile::read_frames(mdd_file.try_clone().unwrap()).unwrap();
|
let pc = MDDSeekableFile::read_frames(mdd_file.try_clone().unwrap()).unwrap();
|
||||||
let mut total_varying = 0;
|
|
||||||
for frame in pc {
|
for frame in pc {
|
||||||
let MDDFrame {
|
let MDDFrame {
|
||||||
point, point_idx, ..
|
point, point_idx, ..
|
||||||
|
@ -165,13 +165,34 @@ fn main() {
|
||||||
} => {
|
} => {
|
||||||
assert_eq!(old_point_idx, point_idx);
|
assert_eq!(old_point_idx, point_idx);
|
||||||
if PointState::point_changed(&point, &old_point) {
|
if PointState::point_changed(&point, &old_point) {
|
||||||
mask_last[point_idx] = Varying {
|
mask_last[point_idx] = Varying;
|
||||||
new_idx: total_varying,
|
|
||||||
};
|
|
||||||
total_varying += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Varying { .. } => {}
|
Varying => {}
|
||||||
|
Reindexed { .. } => unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut total_varying = 0;
|
||||||
|
for point in mask_last.iter_mut() {
|
||||||
|
if let Varying = point {
|
||||||
|
*point = Reindexed { new_idx: total_varying };
|
||||||
|
total_varying += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the varing indices are increasing w.r.t. point_idx
|
||||||
|
let mut mask_iter = mask_last.iter().filter_map(|x| {
|
||||||
|
if let &Reindexed { new_idx } = x {
|
||||||
|
Some(new_idx)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if let Some(mut prev_idx) = mask_iter.next() {
|
||||||
|
for next_idx in mask_iter {
|
||||||
|
assert_eq!(prev_idx + 1, next_idx);
|
||||||
|
prev_idx = next_idx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,9 +220,9 @@ fn main() {
|
||||||
point_idx, point, ..
|
point_idx, point, ..
|
||||||
} = frame.unwrap();
|
} = frame.unwrap();
|
||||||
match mask_last[point_idx] {
|
match mask_last[point_idx] {
|
||||||
Unseen => panic!(),
|
Varying | Unseen => panic!(),
|
||||||
OneValue { .. } => None,
|
OneValue { .. } => None,
|
||||||
Varying { .. } => Some(point),
|
Reindexed { .. } => Some(point),
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue