forked from bartvdbraak/blender
Use the scenes framerate for ipo and action framerate in the game engine, was hard coded to 25.
This commit is contained in:
parent
4c391a0c30
commit
c9d1924ea5
@ -372,6 +372,12 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
|
||||
// start the engine
|
||||
ketsjiengine->StartEngine(true);
|
||||
|
||||
|
||||
// Set the animation playback rate for ipo's and actions
|
||||
// the framerate below should patch with FPS macro defined in blendef.h
|
||||
// Could be in StartEngine set the framerate, we need the scene to do this
|
||||
ketsjiengine->SetAnimFrameRate( (((double) blscene->r.frs_sec) / blscene->r.frs_sec_base) );
|
||||
|
||||
// the mainloop
|
||||
while (!exitrequested)
|
||||
{
|
||||
|
@ -134,14 +134,14 @@ void BL_ActionActuator::SetStartTime(float curtime)
|
||||
float direction = m_startframe < m_endframe ? 1.0 : -1.0;
|
||||
|
||||
if (!(m_flag & ACT_FLAG_REVERSE))
|
||||
m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_FIXED_FRAME_PER_SEC;
|
||||
m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
|
||||
else
|
||||
m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_FIXED_FRAME_PER_SEC;
|
||||
m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
|
||||
}
|
||||
|
||||
void BL_ActionActuator::SetLocalTime(float curtime)
|
||||
{
|
||||
float delta_time = (curtime - m_starttime)*KX_FIXED_FRAME_PER_SEC;
|
||||
float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
|
||||
|
||||
if (m_endframe < m_startframe)
|
||||
delta_time = -delta_time;
|
||||
@ -385,7 +385,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
|
||||
blend_poses(m_pose, m_blendpose, 1.0 - newweight, ACTSTRIPMODE_BLEND);
|
||||
|
||||
/* Increment current blending percentage */
|
||||
m_blendframe = (curtime - m_blendstart)*KX_FIXED_FRAME_PER_SEC;
|
||||
m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
|
||||
if (m_blendframe>m_blendin)
|
||||
m_blendframe = m_blendin;
|
||||
|
||||
|
@ -45,9 +45,8 @@
|
||||
#include "GEN_Map.h"
|
||||
#include "GEN_HashedPtr.h"
|
||||
#include "KX_Scene.h"
|
||||
#include "KX_KetsjiEngine.h" /* for m_anim_framerate */
|
||||
|
||||
#define KX_FIXED_FRAME_PER_SEC 25.0f
|
||||
#define KX_FIXED_SEC_PER_FRAME (1.0f / KX_FIXED_FRAME_PER_SEC)
|
||||
#define KX_OB_DYNAMIC 1
|
||||
|
||||
|
||||
|
@ -164,14 +164,14 @@ void KX_IpoActuator::SetStartTime(float curtime)
|
||||
|
||||
curtime = curtime - KX_KetsjiEngine::GetSuspendedDelta();
|
||||
if (m_direction > 0)
|
||||
m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_FIXED_FRAME_PER_SEC;
|
||||
m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
|
||||
else
|
||||
m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_FIXED_FRAME_PER_SEC;
|
||||
m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
|
||||
}
|
||||
|
||||
void KX_IpoActuator::SetLocalTime(float curtime)
|
||||
{
|
||||
float delta_time = ((curtime - m_starttime) - KX_KetsjiEngine::GetSuspendedDelta())*KX_FIXED_FRAME_PER_SEC;
|
||||
float delta_time = ((curtime - m_starttime) - KX_KetsjiEngine::GetSuspendedDelta())*KX_KetsjiEngine::GetAnimFrameRate();
|
||||
|
||||
// negative delta_time is caused by floating point inaccuracy
|
||||
// perhaps the inaccuracy could be reduced a bit
|
||||
|
@ -71,6 +71,7 @@
|
||||
#include "KX_TimeCategoryLogger.h"
|
||||
|
||||
#include "RAS_FramingManager.h"
|
||||
#include "stdio.h"
|
||||
|
||||
// If define: little test for Nzc: guarded drawing. If the canvas is
|
||||
// not valid, skip rendering this frame.
|
||||
@ -91,7 +92,7 @@ const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
|
||||
};
|
||||
|
||||
double KX_KetsjiEngine::m_ticrate = DEFAULT_LOGIC_TIC_RATE;
|
||||
|
||||
double KX_KetsjiEngine::m_anim_framerate = 25.0;
|
||||
double KX_KetsjiEngine::m_suspendedtime = 0.0;
|
||||
double KX_KetsjiEngine::m_suspendeddelta = 0.0;
|
||||
|
||||
@ -1383,6 +1384,16 @@ void KX_KetsjiEngine::SetTicRate(double ticrate)
|
||||
m_ticrate = ticrate;
|
||||
}
|
||||
|
||||
double KX_KetsjiEngine::GetAnimFrameRate()
|
||||
{
|
||||
return m_anim_framerate;
|
||||
}
|
||||
|
||||
void KX_KetsjiEngine::SetAnimFrameRate(double framerate)
|
||||
{
|
||||
m_anim_framerate = framerate;
|
||||
}
|
||||
|
||||
void KX_KetsjiEngine::SetTimingDisplay(bool frameRate, bool profile, bool properties)
|
||||
{
|
||||
m_show_framerate = frameRate;
|
||||
|
@ -103,6 +103,7 @@ private:
|
||||
double m_remainingTime;
|
||||
|
||||
static double m_ticrate;
|
||||
static double m_anim_framerate; /* for animation playback only - ipo and action */
|
||||
|
||||
static double m_suspendedtime;
|
||||
static double m_suspendeddelta;
|
||||
@ -260,6 +261,15 @@ public:
|
||||
*/
|
||||
static void SetTicRate(double ticrate);
|
||||
|
||||
/**
|
||||
* Gets the framerate for playing animations. (actions and ipos)
|
||||
*/
|
||||
static double GetAnimFrameRate();
|
||||
/**
|
||||
* Sets the framerate for playing animations. (actions and ipos)
|
||||
*/
|
||||
static void SetAnimFrameRate(double framerate);
|
||||
|
||||
/**
|
||||
* Activates or deactivates timing information display.
|
||||
* @param frameRate Display for frame rate on or off.
|
||||
|
Loading…
Reference in New Issue
Block a user