From e03fdd81122edba048882f07bfef09a1764e1682 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 6 Nov 2011 12:12:14 +0000 Subject: [PATCH] Second attempt at getting rid of bsystem_time() Hopefully this fixes Collada. Can't really compile that to check here... --- source/blender/blenkernel/BKE_scene.h | 2 +- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 4 ++-- source/blender/blenkernel/intern/scene.c | 14 +++++--------- source/blender/collada/AnimationExporter.cpp | 4 ++-- source/blender/collada/AnimationExporter.h | 1 + 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index a6bd90c4fd2..ad394f9fb1a 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -86,7 +86,7 @@ void scene_select_base(struct Scene *sce, struct Base *selbase); int scene_check_setscene(struct Main *bmain, struct Scene *sce); float BKE_curframe(struct Scene *scene); -float BKE_nextframe(struct Scene *scene); +float BKE_frame_to_ctime(struct Scene *scene, const float frame); void scene_update_tagged(struct Main *bmain, struct Scene *sce); void scene_clear_tagged(struct Main *bmain, struct Scene *sce); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f8d281c2951..76d08f6fff2 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3427,7 +3427,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->totpart=0; psys->flag = PSYS_ENABLED|PSYS_CURRENT; - psys->cfra = BKE_nextframe(scene); + psys->cfra = BKE_frame_to_ctime(scene, CFRA + 1); DAG_scene_sort(G.main, scene); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 7a8162391d5..ba5b98ee3cd 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2148,8 +2148,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra if(timescale) { time= BKE_curframe(scene); - nexttime= BKE_nextframe(scene); - + nexttime= BKE_frame_to_ctime(scene, CFRA+1); + *timescale= MAX2(nexttime - time, 0.0f); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 2f24b7e735d..66d29b02263 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -914,20 +914,16 @@ int scene_check_setscene(Main *bmain, Scene *sce) */ float BKE_curframe(Scene *scene) { - float ctime = scene->r.cfra; - ctime += scene->r.subframe; - ctime *= scene->r.framelen; - - return ctime; + return BKE_frame_to_ctime(scene, scene->r.cfra); } -/* Similar to BKE_curframe(), but is used by physics sims to get "next time", which is defined as cfra+1 */ -float BKE_nextframe(Scene *scene) +/* This function is used to obtain arbitrary fractional frames */ +float BKE_frame_to_ctime(Scene *scene, const float frame) { - float ctime = (float)(scene->r.cfra + 1); + float ctime = frame; ctime += scene->r.subframe; ctime *= scene->r.framelen; - + return ctime; } diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index b115a96cfa1..7bd70e9f289 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -759,7 +759,7 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames , Ob for (it = frames.begin(); it != frames.end(); it++) { float mat[4][4], ipar[4][4]; - float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + float ctime = BKE_frame_to_ctime(scene, *it); BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); @@ -1265,7 +1265,7 @@ void AnimationExporter::sample_animation(float *v, std::vector &frames, i for (it = frames.begin(); it != frames.end(); it++) { float mat[4][4], ipar[4][4]; - float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + float ctime = BKE_frame_to_ctime(scene, *it); BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 7f6c99b108f..c3a5c7a5383 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -38,6 +38,7 @@ extern "C" #include "BKE_DerivedMesh.h" #include "BKE_fcurve.h" #include "BKE_animsys.h" +#include "BKE_scene.h" #ifdef NAN_BUILDINFO extern char build_rev[]; #endif