Fixed looping animations for actors

This commit is contained in:
n00b
2024-11-15 22:19:40 -05:00
parent 378c25ffde
commit c085150def
9 changed files with 1448 additions and 1047 deletions

View File

@@ -307,6 +307,9 @@ int rc_createAnimatedActor(int mesh_id)
animation.frame_start_time = SDL_GetTicks();
animation.frame_swap_time = 1000/60;
rc_actor[actor_id].animation.push_back(animation);
rc_actor[actor_id].current_animation = 0;
rc_actor[actor_id].current_animation_loop = 0;
rc_actor[actor_id].num_animation_loops = 0;
rc_animEndCallBack* anim_callback = new rc_animEndCallBack();
anim_callback->ref_actor = &rc_actor[actor_id];
anim_callback->OnAnimationEnd(node);

View File

@@ -583,12 +583,34 @@ class rc_animEndCallBack : public IAnimationEndCallBack
//std::cout << "animating" << std::endl;
irr::scene::IAnimatedMeshSceneNode* node = (irr::scene::IAnimatedMeshSceneNode*) ref_actor->mesh_node;
int animation = ref_actor->current_animation;
if(animation < 0 || animation >= ref_actor->animation.size())
if(animation == RC_ANIMATION_MD2)
{
int start_frame = node->getStartFrame();
int end_frame = node->getEndFrame();
node->setFrameLoop(start_frame, end_frame);
ref_actor->current_animation_loop++;
}
else if(animation == RC_ANIMATION_TRANSITION)
{
//TODO: Transitions are currently broken
}
else if(animation < 0 || animation >= ref_actor->animation.size())
{
return;
int start_frame = ref_actor->animation[animation].start_frame;
int end_frame = ref_actor->animation[animation].end_frame;
node->setFrameLoop(start_frame, end_frame);
ref_actor->current_animation_loop++;
}
else
{
if(!ref_actor->animation[animation].active)
{
ref_actor->isPlaying = false;
ref_actor->current_animation_loop = 0;
return;
}
int start_frame = ref_actor->animation[animation].start_frame;
int end_frame = ref_actor->animation[animation].end_frame;
node->setFrameLoop(start_frame, end_frame);
ref_actor->current_animation_loop++;
}
}
else
{

View File

@@ -1,5 +1,5 @@
# depslib dependency file v1.0
1731681709 source:/home/n00b/Projects/RCBASIC4/rcbasic_runtime/main.cpp
1731722537 source:/home/n00b/Projects/RCBASIC4/rcbasic_runtime/main.cpp
"rc_os_defines.h"
<emscripten.h>
<sys/param.h>
@@ -32,10 +32,10 @@
<irrtheora.h>
"rc_func130_cases.h"
1731717801 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_os_defines.h
1731726964 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_os_defines.h
<TargetConditionals.h>
1731684932 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_defines.h
1731722537 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_defines.h
1730291453 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_stdlib.h
"rc_os_defines.h"
@@ -1247,7 +1247,7 @@
1727545973 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/RealisticWater.h
<irrlicht.h>
1731712885 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx.h
1731722537 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx.h
"SDL.h"
<SDL2/SDL.h>
<irrlicht.h>
@@ -1271,7 +1271,7 @@
"rc_joints.h"
<irrtheora.h>
1731709491 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx_core.h
1731727042 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_gfx_core.h
"SDL.h"
"btBulletDynamicsCommon.h"
"BulletSoftBody/btSoftRigidDynamicsWorld.h"
@@ -2272,7 +2272,7 @@
"rc_gfx_core.h"
<irrtheora.h>
1731711022 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_func130_cases.h
1731722537 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_func130_cases.h
1724469097 source:/home/n00b/Projects/irrBullet/src/irrBullet.cpp
"irrBullet.h"
@@ -2487,7 +2487,7 @@
<irrlicht.h>
<cmath>
1731693546 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_spritelib.h
1731722537 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_spritelib.h
"SDL.h"
<SDL2/SDL.h>
"rc_sprite2D.h"
@@ -2505,7 +2505,7 @@
<irrlicht.h>
<vector>
1731693615 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_sprite_physics.h
1731722537 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_sprite_physics.h
"rc_sprite2D.h"
1730291453 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_joints.h
@@ -2514,14 +2514,14 @@
"rc_sprite2D.h"
"rc_gfx_core.h"
1731695180 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_physics3D_base.h
1731722537 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_physics3D_base.h
"rc_gfx_core.h"
1730291453 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_base_actor.h
1731725236 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_base_actor.h
1731710840 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_actor_material.h
1730291453 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_actor_animation.h
1731727068 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_actor_animation.h
1730291453 /home/n00b/Projects/RCBASIC4/rcbasic_runtime/rc_actor_physics.h