Skip to content

Commit 87d020a

Browse files
committed
devlog
1 parent 2fbb843 commit 87d020a

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

Diff for: DEVLOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# devlog
22

3-
## Web May 9, 2024
3+
## Sat May 11, 2024
4+
5+
Skinning is pretty hard! I remember before that it took a good amount of fiddling before
6+
vertex skinning "clicked". I understand the concept and how it should work, but in practice
7+
I feel like there's always a matrix multiplication that is in the wrong order, or that I'm
8+
missing (I've been through it twice now).
9+
10+
![gltf fox debacle](./devlog/Screenshot 2024-05-11 at 10.42.01 AM.png)
11+
12+
## Wed May 9, 2024
413

514
I finished the Memorandum of Understanding for my NLnet grant.
615
The MoU is kinda like a project plan or roadmap that lets NLnet know what the milestones are

Diff for: crates/renderling/src/stage/gltf_support.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ impl GltfNode {
651651
#[derive(Clone, Debug)]
652652
pub struct GltfSkin {
653653
pub index: usize,
654-
// Indices of the skeleton nodes used as joints in this skin
654+
// Indices of the skeleton nodes used as joints in this skin, unused internally
655+
// but possibly useful.
655656
pub joint_nodes: Vec<usize>,
656657
pub joint_transforms: HybridArray<Id<Transform>>,
657658
// Containins the 4x4 inverse-bind matrices.
@@ -662,7 +663,7 @@ pub struct GltfSkin {
662663
// Index of the node used as the skeleton root.
663664
// When None, joints transforms resolve to scene root.
664665
pub skeleton: Option<usize>,
665-
666+
// Skin as seen by shaders, on the GPU
666667
pub skin: Hybrid<Skin>,
667668
}
668669

@@ -734,24 +735,33 @@ impl GltfDocument {
734735
log::debug!("Loading {} nodes", document.nodes().count());
735736
let mut nodes = vec![];
736737
let mut node_transforms = HashMap::<usize, NestedTransform>::new();
738+
737739
fn transform_for_node(
740+
nesting_level: usize,
738741
stage: &mut Stage,
739742
cache: &mut HashMap<usize, NestedTransform>,
740743
node: &gltf::Node,
741744
) -> NestedTransform {
742-
if let Some(nt) = cache.get(&node.index()) {
745+
let padding = std::iter::repeat(" ")
746+
.take(nesting_level * 2)
747+
.collect::<Vec<_>>()
748+
.join("");
749+
log::debug!("{padding}{} {:?}", node.index(), node.name());
750+
let nt = if let Some(nt) = cache.get(&node.index()) {
743751
nt.clone()
744752
} else {
745753
let transform = stage.new_nested_transform();
746754
let mat4 = Mat4::from_cols_array_2d(&node.transform().matrix());
747755
transform.set_local_transform(mat4.into());
748756
for node in node.children() {
749-
let child_transform = transform_for_node(stage, cache, &node);
757+
let child_transform =
758+
transform_for_node(nesting_level + 1, stage, cache, &node);
750759
transform.add_child(&child_transform);
751760
}
752761
cache.insert(node.index(), transform.clone());
753762
transform
754-
}
763+
};
764+
nt
755765
}
756766
let mut camera_index_to_node_index = HashMap::<usize, usize>::new();
757767
let mut light_index_to_node_index = HashMap::<usize, usize>::new();
@@ -772,7 +782,7 @@ impl GltfDocument {
772782
let light = node.light().map(|light| light.index());
773783
let weights = node.weights().map(|w| w.to_vec()).unwrap_or_default();
774784
let weights = stage.new_array(weights);
775-
let transform = transform_for_node(stage, &mut node_transforms, &node);
785+
let transform = transform_for_node(0, stage, &mut node_transforms, &node);
776786
nodes.push(GltfNode {
777787
index: node.index(),
778788
name: node.name().map(String::from),

Diff for: devlog/Screenshot 2024-05-11 at 10.42.01 AM.png

195 KB
Loading

0 commit comments

Comments
 (0)