Fix examples

This commit is contained in:
Nikolas 2026-04-03 20:58:36 +02:00
parent 01869ab291
commit 9d9daa7127
Failed to generate hash of commit
2 changed files with 7 additions and 10 deletions

View file

@ -38,7 +38,7 @@ pub fn main() anyerror!void {
// Load gltf model animations
var animIndex: usize = 0;
var animCurrentFrame: i32 = 0;
var animCurrentFrame: f32 = 0;
const modelAnimations = try rl.loadModelAnimations("examples/models/resources/models/gltf/greenman.glb");
const animsCount = modelAnimations.len;
defer rl.unloadModelAnimations(modelAnimations);
@ -47,8 +47,8 @@ pub fn main() anyerror!void {
var boneSocketIndex: [BONE_SOCKETS]usize = undefined;
// search bones for sockets
for (0..@as(usize, @intCast(characterModel.boneCount))) |i| {
const boneName: [:0]const u8 = @ptrCast(&characterModel.bones[i].name);
for (0..@as(usize, @intCast(characterModel.skeleton.boneCount))) |i| {
const boneName: [:0]const u8 = @ptrCast(&characterModel.skeleton.bones[i].name);
if (rl.textIsEqual(boneName, "socket_hat")) {
boneSocketIndex[BONE_SOCKET_HAT] = i;
continue;
@ -96,7 +96,7 @@ pub fn main() anyerror!void {
// Update model animation
const anim = modelAnimations[animIndex];
animCurrentFrame = @mod(animCurrentFrame + 1, anim.frameCount);
animCurrentFrame = @mod(animCurrentFrame + 1, @as(f32, @floatFromInt(anim.keyframeCount)));
rl.updateModelAnimation(characterModel, anim, animCurrentFrame);
//----------------------------------------------------------------------------------
@ -120,8 +120,8 @@ pub fn main() anyerror!void {
for (0..BONE_SOCKETS) |i| {
if (!showEquip[i]) continue;
const transform = &anim.framePoses[@intCast(animCurrentFrame)][boneSocketIndex[i]];
const inRotation = characterModel.bindPose[boneSocketIndex[i]].rotation;
const transform = &anim.keyframePoses[@as(usize, @intFromFloat(animCurrentFrame))][boneSocketIndex[i]];
const inRotation = characterModel.skeleton.bindPose[boneSocketIndex[i]].rotation;
const outRotation = transform.rotation;
// Calculate socket rotation (angle between bone in initial pose and same bone in current animation frame)

View file

@ -41,10 +41,7 @@ const Light = extern struct {
type: Type = .directional,
enabled: bool = false,
_enabled_pad1: u8 = 0,
_enabled_pad2: @Type(.{.int = .{
.signedness = .unsigned,
.bits = @bitSizeOf(c_uint) - 16,
}}) = 0,
_enabled_pad2: @Int(.unsigned, @bitSizeOf(c_uint) - 16) = 0,
position: rl.Vector3 = .init(0, 0, 0),
target: rl.Vector3 = .init(0, 0, 0),
color: [4]f32 = .{ 0, 0, 0, 0 },