Skip to content

Entity model node system#2824

Open
RanPix wants to merge 237 commits intoPixelGuys:masterfrom
RanPix:joints
Open

Entity model node system#2824
RanPix wants to merge 237 commits intoPixelGuys:masterfrom
RanPix:joints

Conversation

@RanPix
Copy link
Copy Markdown
Contributor

@RanPix RanPix commented Apr 5, 2026

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

RanPix and others added 30 commits November 6, 2025 17:45
Co-authored-by: careeoki <122191047+careeoki@users.noreply.github.com>
also renamed entity.zig -> clientEntity.zig to make it easier to distingues it from the already existing Entity.zig in server/
@RanPix RanPix marked this pull request as ready for review May 1, 2026 09:11
@RanPix
Copy link
Copy Markdown
Contributor Author

RanPix commented May 1, 2026

ready for review

@Wunka Wunka moved this from WIP/not ready for review to High Priority in PRs to review May 4, 2026
.defaultTexture = "cubyz:cubert",
.height = 2,
.coordinateSystem = .right_handed_z_up,
.isPlayerModel = true,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unintended change

.model = "cubyz:snale",
.defaultTexture = "cubyz:snale",
.height = 2,
.isPlayerModel = true,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unintended change

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow the formatting style

Suggested change
vec4 mvPos = viewMatrix * nodeMatrices[inNodeID] * vec4(inPos, 1);
vec4 mvPos = viewMatrix*nodeMatrices[inNodeID]*vec4(inPos, 1);

Comment thread src/client/Entity.zig
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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread src/entityModel.zig
pos: [3]f32,
normal: [3]f32,
uv: [2]f32,
nodeID: c_uint,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
nodeID: c_uint,
nodeId: c_uint,

Comment thread src/entityModel.zig
.{
.location = 3,
.format = c.VK_FORMAT_R32_UINT,
.offset = @offsetOf(@This(), "nodeID"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.offset = @offsetOf(@This(), "nodeID"),
.offset = @offsetOf(@This(), "nodeId"),

Comment thread src/vec.zig
}

// copied from zmath library (MIT Liscence) : https://github.com/zig-gamedev/zmath/blob/9f7beb0753bd5cf885285dda8b00361c87c5b6b3/src/root.zig#L3570
fn sincos32(v: f32) [2]f32 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/vec.zig
}

// 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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/entityModel.zig
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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please make a seperate PR for just the indentation change you did here?
This is just awful to review in github.

@IntegratedQuantum IntegratedQuantum moved this from High Priority to In review in PRs to review May 4, 2026
Copy link
Copy Markdown
Contributor

@tillpp tillpp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the effort, but request a change:

Comment thread src/client/Entity.zig
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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to move this code somewhere else?
I would prefer the Entity.zig be component agnostic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

joints and links for entity models

4 participants