Entity model node system#2824
Conversation
also renamed entity.zig -> clientEntity.zig to make it easier to distingues it from the already existing Entity.zig in server/
… into ECS_United7
…ityLoadsComponents
…eLoadingFromAsset
… into ECS_United7
… into ECS_Protocol
|
ready for review |
| .defaultTexture = "cubyz:cubert", | ||
| .height = 2, | ||
| .coordinateSystem = .right_handed_z_up, | ||
| .isPlayerModel = true, |
| .model = "cubyz:snale", | ||
| .defaultTexture = "cubyz:snale", | ||
| .height = 2, | ||
| .isPlayerModel = true, |
There was a problem hiding this comment.
Could you explain what changed here? I see no difference
| normal = inNormal; | ||
|
|
||
| vec4 mvPos = viewMatrix*vec4(inPos, 1); | ||
| vec4 mvPos = viewMatrix * nodeMatrices[inNodeID] * vec4(inPos, 1); |
There was a problem hiding this comment.
Please follow the formatting style
| vec4 mvPos = viewMatrix * nodeMatrices[inNodeID] * vec4(inPos, 1); | |
| vec4 mvPos = viewMatrix*nodeMatrices[inNodeID]*vec4(inPos, 1); |
| const head = model.nodeReverse.get("Head"); | ||
| if (model.nodeReverse.get("Eyestalks")) |eyestalksId| { | ||
| const stalkRot = self.rot[0]*0.25; | ||
| const headRot = self.rot[0]*0.75; |
There was a problem hiding this comment.
Instead of hardcoding it here, could this information be stored in the model somehow? Does it allow to add named variables to the nodes, so you could add to each node how much head rotation it gets?
| pos: [3]f32, | ||
| normal: [3]f32, | ||
| uv: [2]f32, | ||
| nodeID: c_uint, |
There was a problem hiding this comment.
| nodeID: c_uint, | |
| nodeId: c_uint, |
| .{ | ||
| .location = 3, | ||
| .format = c.VK_FORMAT_R32_UINT, | ||
| .offset = @offsetOf(@This(), "nodeID"), |
There was a problem hiding this comment.
| .offset = @offsetOf(@This(), "nodeID"), | |
| .offset = @offsetOf(@This(), "nodeId"), |
| } | ||
|
|
||
| // copied from zmath library (MIT Liscence) : https://github.com/zig-gamedev/zmath/blob/9f7beb0753bd5cf885285dda8b00361c87c5b6b3/src/root.zig#L3570 | ||
| fn sincos32(v: f32) [2]f32 { |
There was a problem hiding this comment.
Please just use @sin and @cos or if you really think we need it, you can use sincos from math.h
I'd rather not have too much foreign code in here.
| } | ||
|
|
||
| // copied from zmath library (MIT Liscence) : https://github.com/zig-gamedev/zmath/blob/9f7beb0753bd5cf885285dda8b00361c87c5b6b3/src/root.zig#L2985 | ||
| pub fn quatFromAxisAngle(axis: Vec3f, angle: f32) Vec4f { |
There was a problem hiding this comment.
Please add a Quat type that contains a vector, so we have at least some type safety.
also add a MARK for it as well.
| vertSlice[v].uv = .{uv[0], 1 - uv[1]}; | ||
| var positionAttr: gltf.cgltf_accessor = undefined; | ||
| var normalAttr: gltf.cgltf_accessor = undefined; | ||
| var uvAttr: gltf.cgltf_accessor = undefined; |
There was a problem hiding this comment.
Could you please make a seperate PR for just the indentation change you did here?
This is just awful to review in github.
tillpp
left a comment
There was a problem hiding this comment.
I appreciate the effort, but request a change:
| modelComp.matrices[headId] = modelComp.nodes[headId].getHierarchyMatrix(modelComp.nodes); | ||
| } else if (head) |headId| { | ||
| modelComp.nodes[headId].rot = vec.quatFromAxisAngle(Vec3f{1, 0, 0}, self.rot[0]); | ||
| modelComp.matrices[headId] = modelComp.nodes[headId].getHierarchyMatrix(modelComp.nodes); |
There was a problem hiding this comment.
Is it possible to move this code somewhere else?
I would prefer the Entity.zig be component agnostic
requires #2762 and #2682
fixes #2419
progress towards #87, #2734 and #726
so far only supports 20 nodes per model
20260405-1250-04.3932246.mp4