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:
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObject.h1
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp24
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h17
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp30
-rw-r--r--source/gameengine/Ketsji/KX_Light.h2
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp1
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp7
8 files changed, 85 insertions, 7 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
index 903966b79be..1ed3a998b99 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
@@ -71,6 +71,7 @@ struct KX_ObjectProperties
bool m_ghost;
class KX_GameObject* m_dynamic_parent;
bool m_isactor;
+ bool m_record_animation;
bool m_sensor;
bool m_character;
bool m_concave;
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index bde50588fd3..16513a97d60 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -435,6 +435,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
shapeInfo->Release();
gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
+
+ // record animation for dynamic objects
+ if (isbulletdyna)
+ gameobj->SetRecordAnimation(true);
+
// don't add automatically sensor object, they are added when a collision sensor is registered
if (!isbulletsensor && objprop->m_in_active_layer)
{
@@ -493,6 +498,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
gameobj->getClientInfo()->m_type =
(isbulletsensor) ? ((isActor) ? KX_ClientObjectInfo::OBACTORSENSOR : KX_ClientObjectInfo::OBSENSOR) :
(isActor) ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC;
+
+ // should we record animation for this object?
+ if (objprop->m_record_animation)
+ gameobj->SetRecordAnimation(true);
+
// store materialname in auxinfo, needed for touchsensors
if (meshobj)
{
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 96f76ff21b1..d3b5a987138 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -112,6 +112,7 @@ KX_GameObject::KX_GameObject(
m_pInstanceObjects(NULL),
m_pDupliGroupObject(NULL),
m_actionManager(NULL),
+ m_bRecordAnimation(false),
m_isDeformable(false)
#ifdef WITH_PYTHON
@@ -1791,6 +1792,7 @@ PyAttributeDef KX_GameObject::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMin", KX_GameObject, pyattr_get_lin_vel_min, pyattr_set_lin_vel_min),
KX_PYATTRIBUTE_RW_FUNCTION("linVelocityMax", KX_GameObject, pyattr_get_lin_vel_max, pyattr_set_lin_vel_max),
KX_PYATTRIBUTE_RW_FUNCTION("visible", KX_GameObject, pyattr_get_visible, pyattr_set_visible),
+ KX_PYATTRIBUTE_RW_FUNCTION("record_animation", KX_GameObject, pyattr_get_record_animation, pyattr_set_record_animation),
KX_PYATTRIBUTE_BOOL_RW ("occlusion", KX_GameObject, m_bOccluder),
KX_PYATTRIBUTE_RW_FUNCTION("position", KX_GameObject, pyattr_get_worldPosition, pyattr_set_localPosition),
KX_PYATTRIBUTE_RO_FUNCTION("localInertia", KX_GameObject, pyattr_get_localInertia),
@@ -2258,6 +2260,28 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at
return PY_SET_ATTR_SUCCESS;
}
+PyObject *KX_GameObject::pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+ return PyBool_FromLong(self->IsRecordAnimation());
+}
+
+int KX_GameObject::pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
+ int param = PyObject_IsTrue(value);
+ if (param == -1) {
+ PyErr_SetString(PyExc_AttributeError, "gameOb.record_animation = bool: KX_GameObject, expected boolean");
+ return PY_SET_ATTR_FAIL;
+ }
+
+ self->SetRecordAnimation(param);
+
+ return PY_SET_ATTR_SUCCESS;
+}
+
+
+
PyObject *KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
#ifdef USE_MATHUTILS
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index 55e2b31c5bf..12aac68365b 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -126,6 +126,7 @@ protected:
BL_ActionManager* GetActionManager();
+ bool m_bRecordAnimation;
public:
bool m_isDeformable;
@@ -600,6 +601,20 @@ public:
}
/**
+ * Should we record animation for this object?
+ */
+
+ void SetRecordAnimation(bool recordAnimation)
+ {
+ m_bRecordAnimation = recordAnimation;
+ }
+
+ bool IsRecordAnimation() const
+ {
+ return m_bRecordAnimation;
+ }
+
+ /**
* Check if this object has a vertex parent relationship
*/
bool IsVertexParent( )
@@ -981,6 +996,8 @@ public:
static int pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_record_animation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index 4567c17cc3e..3a8821e8a86 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -51,7 +51,9 @@
#include "BKE_scene.h"
#include "MEM_guardedalloc.h"
-
+
+#include "BLI_math.h"
+
KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
RAS_IRasterizer* rasterizer,
const RAS_LightObject& lightobj,
@@ -158,7 +160,7 @@ bool KX_LightObject::ApplyLight(KX_Scene *kxscene, int oblayer, int slot)
//vec[1] = -base->object->obmat[2][1];
//vec[2] = -base->object->obmat[2][2];
glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPOT_DIRECTION, vec);
- glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, m_lightobj.m_spotsize / 2.0f);
+ glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, RAD2DEGF(m_lightobj.m_spotsize * 0.5f));
glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_EXPONENT, 128.0f * m_lightobj.m_spotblend);
}
else {
@@ -360,7 +362,7 @@ PyAttributeDef KX_LightObject::Attributes[] = {
KX_PYATTRIBUTE_RW_FUNCTION("color", KX_LightObject, pyattr_get_color, pyattr_set_color),
KX_PYATTRIBUTE_FLOAT_RW("lin_attenuation", 0, 1, KX_LightObject, m_lightobj.m_att1),
KX_PYATTRIBUTE_FLOAT_RW("quad_attenuation", 0, 1, KX_LightObject, m_lightobj.m_att2),
- KX_PYATTRIBUTE_FLOAT_RW("spotsize", 1, 180, KX_LightObject, m_lightobj.m_spotsize),
+ KX_PYATTRIBUTE_RW_FUNCTION("spotsize", KX_LightObject, pyattr_get_spotsize, pyattr_set_spotsize),
KX_PYATTRIBUTE_FLOAT_RW("spotblend", 0, 1, KX_LightObject, m_lightobj.m_spotblend),
KX_PYATTRIBUTE_RO_FUNCTION("SPOT", KX_LightObject, pyattr_get_typeconst),
KX_PYATTRIBUTE_RO_FUNCTION("SUN", KX_LightObject, pyattr_get_typeconst),
@@ -390,6 +392,28 @@ int KX_LightObject::pyattr_set_color(void *self_v, const KX_PYATTRIBUTE_DEF *att
return PY_SET_ATTR_FAIL;
}
+PyObject *KX_LightObject::pyattr_get_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
+{
+ KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
+ return Py_BuildValue("f", RAD2DEGF(self->m_lightobj.m_spotsize));
+}
+
+int KX_LightObject::pyattr_set_spotsize(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
+{
+ KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
+
+ float spotsize = (float)PyFloat_AsDouble(value);
+ if (PyErr_Occurred())
+ return PY_SET_ATTR_FAIL;
+
+ if (spotsize < 1.0f)
+ spotsize = 1.0f;
+ else if (spotsize > 180.0f)
+ spotsize = 180.0f;
+ self->m_lightobj.m_spotsize = DEG2RADF(spotsize);
+ return PY_SET_ATTR_SUCCESS;
+}
+
PyObject *KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
{
PyObject *retvalue;
diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h
index 4f11c535cf0..d6892875042 100644
--- a/source/gameengine/Ketsji/KX_Light.h
+++ b/source/gameengine/Ketsji/KX_Light.h
@@ -78,6 +78,8 @@ public:
/* attributes */
static PyObject* pyattr_get_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_color(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
+ static PyObject* pyattr_get_spotsize(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int pyattr_set_spotsize(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
static PyObject* pyattr_get_typeconst(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static PyObject* pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
static int pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 2f23bdaccb7..70924c65519 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -2398,7 +2398,6 @@ PyAttributeDef KX_Scene::Attributes[] = {
KX_PYATTRIBUTE_RO_FUNCTION("objectsInactive", KX_Scene, pyattr_get_objects_inactive),
KX_PYATTRIBUTE_RO_FUNCTION("lights", KX_Scene, pyattr_get_lights),
KX_PYATTRIBUTE_RO_FUNCTION("cameras", KX_Scene, pyattr_get_cameras),
- KX_PYATTRIBUTE_RO_FUNCTION("lights", KX_Scene, pyattr_get_lights),
KX_PYATTRIBUTE_RW_FUNCTION("active_camera", KX_Scene, pyattr_get_active_camera, pyattr_set_active_camera),
KX_PYATTRIBUTE_RW_FUNCTION("pre_draw", KX_Scene, pyattr_get_drawing_callback_pre, pyattr_set_drawing_callback_pre),
KX_PYATTRIBUTE_RW_FUNCTION("post_draw", KX_Scene, pyattr_get_drawing_callback_post, pyattr_set_drawing_callback_post),
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index 3a4b1d82946..4e5cd0ac5e1 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -147,7 +147,7 @@ CValue* KX_SoundActuator::GetReplica()
KX_SoundActuator* replica = new KX_SoundActuator(*this);
replica->ProcessReplica();
return replica;
-};
+}
void KX_SoundActuator::ProcessReplica()
{
@@ -217,11 +217,12 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
// m_posevent==false && m_posevent==false, in this case IsNegativeEvent() returns false
// and assumes this is a positive event.
// check that we actually have a positive event so as not to play sounds when being disabled.
- else if (bPositiveEvent) { // <- added since 2.49
+ else if (bPositiveEvent) /* <- added since 2.49 */
#else
- else { // <- works in most cases except a loop-end sound will never stop unless
+ else // <- works in most cases except a loop-end sound will never stop unless
// the negative pulse is done continuesly
#endif
+ {
if (!m_isplaying)
play();
}