Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-10-16 15:41:50 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-10-16 15:41:50 +0400
commit7b2567924b9b86961cd4c07b76653f49939cab1c (patch)
treeadcf1091db6f3f78c05c6b02c567a9b77fc10092 /source/gameengine/Converter
parent063982914038ecd578bab7849a1e94cccbb8d8b9 (diff)
Switch fixed time system. Logic updates should now happen at 30Hz, physics at 60Hz. (By default, use Python to set.) Some actuators still run at framerate (IPO, Action) for nice smooth animation, and an excuse to buy high end hardware.
Keyboard sensors can now hook escape key. Ctrl-Break can be used from within blender if you've forgotten an end game actuator. Fixed a stupid bug preventing some actuators working (like TrackTo).
Diffstat (limited to 'source/gameengine/Converter')
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp41
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h4
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp12
3 files changed, 21 insertions, 36 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index 52b948b18f1..5206f33ccd7 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -30,6 +30,8 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
+#include <cmath>
+
#include "SCA_LogicManager.h"
#include "BL_ActionActuator.h"
#include "BL_ArmatureObject.h"
@@ -95,7 +97,7 @@ CValue* BL_ActionActuator::GetReplica() {
return replica;
};
-bool BL_ActionActuator::Update(double curtime,double deltatime)
+bool BL_ActionActuator::Update(double curtime, bool frame)
{
bool bNegativeEvent = false;
bool bPositiveEvent = false;
@@ -149,6 +151,7 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
m_flag &= ~ACT_FLAG_REVERSE;
m_flag |= ACT_FLAG_LOCKINPUT;
m_localtime = m_starttime;
+ m_startWallTime = curtime;
}
}
if (bNegativeEvent){
@@ -181,6 +184,7 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
if (!(m_flag & ACT_FLAG_LOCKINPUT)){
m_flag &= ~ACT_FLAG_REVERSE;
m_localtime = m_starttime;
+ m_startWallTime = curtime;
m_flag |= ACT_FLAG_LOCKINPUT;
}
}
@@ -204,31 +208,19 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
}
else{
if (m_flag & ACT_FLAG_REVERSE)
- m_localtime -= deltatime* KX_FIXED_FRAME_PER_SEC;
+ m_localtime = m_endtime - (curtime - m_startWallTime) * KX_FIXED_FRAME_PER_SEC;
else
- m_localtime += deltatime* KX_FIXED_FRAME_PER_SEC;
+ m_localtime = m_starttime + (curtime - m_startWallTime) * KX_FIXED_FRAME_PER_SEC;
}
}
/* Check if a wrapping response is needed */
if (length){
- if (m_flag & ACT_FLAG_REVERSE){
- if (m_localtime < m_starttime){
- m_localtime = m_endtime+(
- (int)((m_localtime - m_starttime)/length)
- *(int)length);
- wrap = true;
- }
- }
- else{
- if (m_localtime > m_endtime){
- m_localtime = m_starttime+(
- (int)((m_localtime - m_endtime)/length)
- *(int)length);
- wrap = true;
- }
+ if (m_localtime < m_starttime || m_localtime > m_endtime)
+ {
+ m_localtime = m_starttime + std::fmod(m_localtime, length);
+ wrap = true;
}
-
}
else
m_localtime = m_starttime;
@@ -238,9 +230,8 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
case ACT_ACTION_FROM_PROP:
{
CValue* propval = GetParent()->GetProperty(m_propname);
- if (propval) {
+ if (propval)
m_localtime = propval->GetNumber();
- };
if (bNegativeEvent){
keepgoing=false;
@@ -285,11 +276,8 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
}
- if (bNegativeEvent){
+ if (bNegativeEvent)
m_blendframe=0.0;
-
- }
-
/* Apply the pose if necessary*/
if (apply){
@@ -316,6 +304,7 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
/* If this is the start of a blending sequence... */
if ((m_blendframe==0.0) || (!m_blendpose)){
obj->GetMRDPose(&m_blendpose);
+ m_blendstart = curtime;
}
/* Find percentages */
@@ -323,7 +312,7 @@ bool BL_ActionActuator::Update(double curtime,double deltatime)
blend_poses(m_pose, m_blendpose, 1.0 - newweight, POSE_BLEND);
/* Increment current blending percentage */
- m_blendframe+=(deltatime*KX_FIXED_FRAME_PER_SEC);
+ m_blendframe = (curtime - m_blendstart)*KX_FIXED_FRAME_PER_SEC;
if (m_blendframe>m_blendin)
m_blendframe = m_blendin;
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index ca1f937cbd4..bf030b5861f 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -71,7 +71,7 @@ public:
{
};
virtual ~BL_ActionActuator();
- virtual bool Update(double curtime,double deltatime);
+ virtual bool Update(double curtime, bool frame);
CValue* GetReplica();
void ProcessReplica();
@@ -113,11 +113,13 @@ protected:
MT_Point3 m_lastpos;
int m_flag;
float m_starttime;
+ float m_startWallTime;
float m_endtime;
float m_localtime;
float m_lastUpdate;
short m_playtype;
float m_blendin;
+ float m_blendstart;
short m_priority;
float m_stridelength;
struct bPose* m_pose;
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index ec9a70fccb1..aa57e883f71 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -486,13 +486,7 @@ void BL_ConvertActuators(char* maggiename,
- let the object-with-property report itself to the act when converted
*/
if (propact->ob)
- {
- KX_GameObject* tempObj = converter->FindGameObject(propact->ob);
- if (tempObj)
- {
- destinationObj = tempObj;
- }
- }
+ destinationObj = converter->FindGameObject(propact->ob);
SCA_PropertyActuator* tmppropact = new SCA_PropertyActuator(
gameobj,
@@ -550,7 +544,7 @@ void BL_ConvertActuators(char* maggiename,
{
RAS_MeshObject *tmpmesh = NULL;
if (editobact->me)
- RAS_MeshObject *tmpmesh = BL_ConvertMesh(
+ tmpmesh = BL_ConvertMesh(
editobact->me,
blenderobject,
rendertools,
@@ -572,7 +566,7 @@ void BL_ConvertActuators(char* maggiename,
{
SCA_IObject* originalval = NULL;
if (editobact->ob)
- SCA_IObject* originalval = converter->FindGameObject(editobact->ob);
+ originalval = converter->FindGameObject(editobact->ob);
KX_TrackToActuator* tmptrackact
= new KX_TrackToActuator(gameobj,