diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-06-24 14:29:26 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-06-24 14:29:26 +0400 |
commit | 1f7ae143a29b090ed97cdd7eb47a9c2dbd7f72a2 (patch) | |
tree | fff560080a8bbf37ee087653df1b8a30173537b1 /source/gameengine | |
parent | d38ba6b5d25ca42f76b6d1b746217a565f26228f (diff) | |
parent | 74c9c24d273863319a55c18234e03b7d27a43a87 (diff) |
Merged changes in the trunk up to revision 48227.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_file/filelist.c
Diffstat (limited to 'source/gameengine')
42 files changed, 158 insertions, 118 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 927a0535870..3c9ca77b37e 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -446,8 +446,8 @@ static void GetRGB(short type, c2 = KX_Mcol2uint_new(mmcol[2]); if (mface->v4) c3 = KX_Mcol2uint_new(mmcol[3]); - }else // backup white - { + } + else { // backup white c0 = KX_rgbaint2uint_new(color); c1 = KX_rgbaint2uint_new(color); c2 = KX_rgbaint2uint_new(color); diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 78e5d7b32c2..3961e6554a7 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -42,6 +42,7 @@ #include "KX_PhysicsEngineEnums.h" #include "PHY_IPhysicsEnvironment.h" #include "KX_KetsjiEngine.h" +#include "KX_PythonInit.h" // So we can handle adding new text datablocks for Python to import #include "KX_IPhysicsController.h" #include "BL_Material.h" #include "BL_ActionActuator.h" @@ -173,9 +174,9 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() #endif /* free any data that was dynamically loaded */ - for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++) { - Main *main= *it; - free_main(main); + while (m_DynamicMaggie.size() != 0) + { + FreeBlendFile(m_DynamicMaggie[0]); } m_DynamicMaggie.clear(); @@ -987,6 +988,11 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha load_datablocks(main_newlib, bpy_openlib, path, idcode); + if (idcode==ID_SCE) { + /* assume we want text blocks too */ + load_datablocks(main_newlib, bpy_openlib, path, ID_TXT); + } + /* now do another round of linking for Scenes so all actions are properly loaded */ if (idcode==ID_SCE && options & LIB_LOAD_LOAD_ACTIONS) { load_datablocks(main_newlib, bpy_openlib, path, ID_AC); @@ -1038,6 +1044,10 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha delete other; } + /* Handle any text datablocks */ + + addImportMain(main_newlib); + /* Now handle all the actions */ if (options & LIB_LOAD_LOAD_ACTIONS) { ID *action; @@ -1330,6 +1340,9 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) } } + /* make sure this maggie is removed from the import list if it's there (this operation is safe if it isn't in the list) */ + removeImportMain(maggie); + free_main(maggie); return true; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 07680297b7d..28e34769ab8 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -860,7 +860,7 @@ void BL_ConvertActuators(const char* maggiename, float paraArg1 = 0.0; float paraArg2 = 0.0; - switch (randAct->distribution) { + switch (randAct->distribution) { case ACT_RANDOM_BOOL_CONST: modeArg = SCA_RandomActuator::KX_RANDOMACT_BOOL_CONST; paraArg1 = (float) randAct->int_arg_1; diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index c50e42446a5..124a8e28f57 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -588,7 +588,7 @@ public: /* These static functions are referenced by ALL PyObjectPlus_Proxy types * they take the C++ reference from the PyObjectPlus_Proxy and call - * its own virtual py_repr, py_base_dealloc ,etc. functions. + * its own virtual py_repr, py_base_dealloc, etc. functions. */ static PyObject* py_base_new(PyTypeObject *type, PyObject *args, PyObject *kwds); /* allows subclassing */ diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index 9a23244fa96..b505353c7cd 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -94,7 +94,7 @@ public: void InsertActiveQList(SG_QList& head) { SG_QList::iterator<SCA_ILogicBrick> it(head); - for(it.begin(); !it.end() && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); + for (it.begin(); !it.end() && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); it.add_back(this); } @@ -119,9 +119,8 @@ public: // this element comes before the first *current = this; } - else - { - for(++it; !it.end() && (*it)->m_gameobj == m_gameobj && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); + else { + for (++it; !it.end() && (*it)->m_gameobj == m_gameobj && m_Execute_Priority > (*it)->m_Execute_Priority; ++it); } it.add_back(this); } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index c82e015919d..2c6beb79fd3 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -191,7 +191,8 @@ bool SCA_JoystickSensor::Evaluate() if (( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) { m_istrig = 1; result = true; - }else { + } + else { if (m_istrig) { m_istrig = 0; result = true; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 9c8e6fe99b4..94a8628ca79 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -209,7 +209,7 @@ SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value) else if (PyObject_TypeCheck(value, &SCA_IActuator::Type)) { PyObjectPlus *value_plus= BGE_PROXY_REF(value); for (it = lacts.begin(); it!= lacts.end(); ++it) { - if ( static_cast<SCA_IActuator*>(value_plus) == (*it) ) { + if (static_cast<SCA_IActuator*>(value_plus) == (*it)) { return *it; } } diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index b0fc1431482..c727eebd015 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -34,13 +34,13 @@ #include <stddef.h> +#include <math.h> #include "BoolValue.h" #include "IntValue.h" #include "FloatValue.h" #include "SCA_IActuator.h" #include "SCA_RandomActuator.h" -#include "math.h" #include "MT_Transform.h" /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 15be4c46894..fbeb34b70b4 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -141,6 +141,16 @@ bool BL_Action::Play(const char* name, return false; } + // If we have the same settings, don't play again + // This is to resolve potential issues with pulses on sensors such as the ones + // reported in bug #29412. The fix is here so it works for both logic bricks and Python. + // However, this may eventually lead to issues where a user wants to override an already + // playing action with the same action and settings. If this becomes an issue, + // then this fix may have to be re-evaluated. + if (!IsDone() && m_action == prev_action && m_startframe == start && m_endframe == end + && m_priority == priority && m_speed == playback_speed) + return false; + if (prev_action != m_action) { // First get rid of any old controllers diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 98854115d0a..c0fca88c426 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -835,12 +835,12 @@ KX_PYMETHODDEF_DOC( BL_Shader, isValid, "isValid()" ) return PyLong_FromSsize_t( ( mShader !=0 && mOk ) ); } -KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg ,"getVertexProg( )" ) +KX_PYMETHODDEF_DOC( BL_Shader, getVertexProg, "getVertexProg( )" ) { return PyUnicode_FromString(vertProg?vertProg:""); } -KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" ) +KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg, "getFragmentProg( )" ) { return PyUnicode_FromString(fragProg?fragProg:""); } @@ -941,7 +941,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" ) } -KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)") +KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f, "setUniform2f(name, fx, fy)") { if (mError) { Py_RETURN_NONE; @@ -1038,7 +1038,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" ) } -KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)") +KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i, "setUniform2i(name, ix, iy)") { if (mError) { Py_RETURN_NONE; @@ -1109,7 +1109,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) " return NULL; } -KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )") +KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv, "setUniformfv( float (list2 or list3 or list4) )") { if (mError) { Py_RETURN_NONE; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 939f0693161..79e6c35e6a2 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -176,7 +176,8 @@ void KX_BlenderMaterial::OnConstruction(int layer) mMaterial->matname<< ", image will not be available"); } // If we're using glsl materials, the textures are handled by bf_gpu, so don't load them twice! - else if (!mMaterial->glslmat) { + // However, if we're using a custom shader, then we still need to load the textures ourselves. + else if (!mMaterial->glslmat || mBlenderShader) { if ( mMaterial->img[i] ) { if ( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) spit("unable to initialize image("<<i<<") in "<< @@ -898,8 +899,8 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") mMaterial->SetSharedMaterial(true); mScene->GetBucketManager()->ReleaseDisplayLists(this); return mShader->GetProxy(); - }else - { + } + else { // decref all references to the object // then delete it! // We will then go back to fixed functionality diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 3b3a1f5cbfb..5fcd591d822 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -12,7 +12,7 @@ #include "CcdPhysicsController.h" #endif -class KX_BulletPhysicsController : public KX_IPhysicsController ,public CcdPhysicsController +class KX_BulletPhysicsController : public KX_IPhysicsController, public CcdPhysicsController { private: int m_savedCollisionFlags; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 6d57b6950f1..f149b676aa5 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -105,7 +105,8 @@ KX_Dome::KX_Dome ( CreateMeshDome180(); m_numfaces = 4; - }else if (m_angle > 180) { + } + else if (m_angle > 180) { cubetop.resize(2); cubebottom.resize(2); cubeleft.resize(2); @@ -140,7 +141,8 @@ KX_Dome::KX_Dome ( CreateMeshDome180(); m_numfaces = 4; - }else if (m_angle > 180) { + } + else if (m_angle > 180) { cubetop.resize(2); cubebottom.resize(2); cubeleft.resize(2); @@ -595,7 +597,7 @@ void KX_Dome::CreateMeshDome180(void) /* Left face - two triangles */ cubeleft[0].verts[0][0] = -M_SQRT2 / 2.0; - cubeleft[0].verts[0][1] = .0; + cubeleft[0].verts[0][1] = 0.0; cubeleft[0].verts[0][2] = -0.5; cubeleft[0].u[0] = 0.0; cubeleft[0].v[0] = 0.0; @@ -1547,7 +1549,7 @@ void KX_Dome::CalculateCameraOrientation() m_locRot[1] = MT_Matrix3x3( // Bottom c, s, 0.0, - 0.0 ,0.0, 1.0, + 0.0, 0.0, 1.0, s, -c, 0.0); m_locRot[2] = MT_Matrix3x3( // 45deg - Left diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 836005cf25e..04113607531 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1472,18 +1472,18 @@ void KX_KetsjiEngine::RenderDebugProperties() for (int j = tc_first; j < tc_numCategories; j++) { debugtxt.Format(m_profileLabels[j]); - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, - debugtxt.Ptr(), - xcoord,ycoord, - m_canvas->GetWidth(), - m_canvas->GetHeight()); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord,ycoord, + m_canvas->GetWidth(), + m_canvas->GetHeight()); double time = m_logger->GetAverage((KX_TimeCategory)j); debugtxt.Format("%.3fms (%2.2f %%)", time*1000.f, time/tottime * 100.f); - m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, - debugtxt.Ptr(), - xcoord + 60 ,ycoord, - m_canvas->GetWidth(), - m_canvas->GetHeight()); + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord + 60, ycoord, + m_canvas->GetWidth(), + m_canvas->GetHeight()); ycoord += 14; } } diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index b0000405893..8924567acde 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -104,19 +104,20 @@ bool PyMatTo(PyObject* pymat, T& mat) if (!PyErr_Occurred() && PySequence_Check(pyrow)) { unsigned int cols = PySequence_Size(pyrow); - if (cols != Size(mat)) + if (cols != Size(mat)) { noerror = false; - else - { - for(unsigned int col = 0; col < cols; col++) - { + } + else { + for (unsigned int col = 0; col < cols; col++) { PyObject *item = PySequence_GetItem(pyrow, col); /* new ref */ mat[row][col] = PyFloat_AsDouble(item); Py_DECREF(item); } } - } else + } + else { noerror = false; + } Py_DECREF(pyrow); } } else diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 28c4630c43e..2a648303c52 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1821,6 +1821,16 @@ static void restorePySysObjects(void) // PyObject_Print(sys_path, stderr, 0); } +void addImportMain(struct Main *maggie) +{ + bpy_import_main_extra_add(maggie); +} + +void removeImportMain(struct Main *maggie) +{ + bpy_import_main_extra_remove(maggie); +} + // Copied from bpy_interface.c static struct _inittab bge_internal_modules[]= { {(char *)"mathutils", PyInit_mathutils}, diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index d8346018b55..866681b9da7 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -61,6 +61,9 @@ int saveGamePythonConfig( char **marshal_buffer); int loadGamePythonConfig(char *marshal_buffer, int marshal_length); #endif +void addImportMain(struct Main *maggie); +void removeImportMain(struct Main *maggie); + class KX_KetsjiEngine; class KX_Scene; diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 978944c20e8..74009f51078 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -104,42 +104,42 @@ void KX_RadarSensor::SynchronizeTransform() { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_Y_AXIS: // +Y Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_Z_AXIS: // +Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_X_AXIS: // -X Axis { MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_Y_AXIS: // -Y Axis { //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); //trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; case SENS_RADAR_NEG_Z_AXIS: // -Z Axis { MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90)); trans.rotate(rotquatje); - trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0, 0)); break; }; default: @@ -154,7 +154,7 @@ void KX_RadarSensor::SynchronizeTransform() m_cone_origin[1] = temp[1]; m_cone_origin[2] = temp[2]; - temp = trans(MT_Point3(0, -m_coneheight/2.0 ,0)); + temp = trans(MT_Point3(0, -m_coneheight/2.0, 0)); m_cone_target[0] = temp[0]; m_cone_target[1] = temp[1]; m_cone_target[2] = temp[2]; diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index cd6bb5a1cbc..39b7c44eda9 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -258,7 +258,7 @@ void KX_SCA_AddObjectActuator::InstantAddObject() // Now it needs to be added to the current scene. SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp ); KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica); - game_obj->setLinearVelocity(m_linear_velocity ,m_localLinvFlag); + game_obj->setLinearVelocity(m_linear_velocity, m_localLinvFlag); game_obj->setAngularVelocity(m_angular_velocity,m_localAngvFlag); game_obj->ResolveCombinedVelocities(m_linear_velocity, m_angular_velocity, m_localLinvFlag, m_localAngvFlag); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 343cb549337..47cd4ff8da5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1811,8 +1811,8 @@ bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* user // occlusion culling, the direction of the view is taken from the first plan which MUST be the near plane btDbvt::collideOCL(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); btDbvt::collideOCL(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,planes_n[0],nplanes,dispatcher); - }else - { + } + else { btDbvt::collideKDOP(m_cullingTree->m_sets[1].m_root,planes_n,planes_o,nplanes,dispatcher); btDbvt::collideKDOP(m_cullingTree->m_sets[0].m_root,planes_n,planes_o,nplanes,dispatcher); } diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index dc63a867e30..8609cd73875 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -27,7 +27,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include <sstream> #include <fstream> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include "Exception.h" diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp index 6fa249ff00a..90ea8436ffe 100644 --- a/source/gameengine/VideoTexture/FilterBase.cpp +++ b/source/gameengine/VideoTexture/FilterBase.cpp @@ -27,7 +27,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "FilterBase.h" -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h index cd25a7ea313..63561c25ffa 100644 --- a/source/gameengine/VideoTexture/FilterBase.h +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -29,7 +29,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Common.h" -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include "PyTypeList.h" diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp index fb5a83c7043..02a6a8f0344 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp +++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. * \ingroup bgevideotex */ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterBlueScreen.h" diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp index f3931c7e047..ed75b4f8da8 100644 --- a/source/gameengine/VideoTexture/FilterColor.cpp +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. * \ingroup bgevideotex */ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterColor.h" diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index aacbc87a414..dda1a493291 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. * \ingroup bgevideotex */ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterNormal.h" diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp index c5c164822a5..e5fe4711cff 100644 --- a/source/gameengine/VideoTexture/FilterSource.cpp +++ b/source/gameengine/VideoTexture/FilterSource.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterSource.h" diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index ac92bcc6d41..090b4f6ff4a 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -33,7 +33,7 @@ extern "C" { #include <vector> #include <string.h> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "FilterBase.h" diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h index 91c7dce9637..6c38b107a4d 100644 --- a/source/gameengine/VideoTexture/ImageBase.h +++ b/source/gameengine/VideoTexture/ImageBase.h @@ -30,7 +30,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Common.h" #include <vector> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include "PyTypeList.h" diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index d28babfcc90..9854da0ea86 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "ImageBuff.h" diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index e2409920230..cd8c6683a7f 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -27,7 +27,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "ImageMix.h" diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 98a3dc8f96a..97e52e3af3d 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include <float.h> #include <math.h> diff --git a/source/gameengine/VideoTexture/ImageRender.h b/source/gameengine/VideoTexture/ImageRender.h index 0062175e0af..df6337e1c24 100644 --- a/source/gameengine/VideoTexture/ImageRender.h +++ b/source/gameengine/VideoTexture/ImageRender.h @@ -30,12 +30,12 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Common.h" -#include <KX_Scene.h> -#include <KX_Camera.h> -#include <DNA_screen_types.h> -#include <RAS_ICanvas.h> -#include <RAS_IRasterizer.h> -#include <RAS_IRenderTools.h> +#include "KX_Scene.h" +#include "KX_Camera.h" +#include "DNA_screen_types.h" +#include "RAS_ICanvas.h" +#include "RAS_IRasterizer.h" +#include "RAS_IRenderTools.h" #include "ImageViewport.h" diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 12f1fa0e20c..a780fdcc38c 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> #include "GL/glew.h" diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp index 508ce233def..ed53e8bd1f1 100644 --- a/source/gameengine/VideoTexture/PyTypeList.cpp +++ b/source/gameengine/VideoTexture/PyTypeList.cpp @@ -29,7 +29,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include <memory> #include <vector> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" /// destructor PyTypeList::~PyTypeList() diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h index e0f7480438d..aa1df0ce54b 100644 --- a/source/gameengine/VideoTexture/PyTypeList.h +++ b/source/gameengine/VideoTexture/PyTypeList.h @@ -32,7 +32,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include <memory> #include <vector> -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" // forward declaration class PyTypeListItem; diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 382d3d0bc32..f08a5a4a0b3 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -26,22 +26,22 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> -#include <KX_GameObject.h> -#include <KX_Light.h> -#include <RAS_MeshObject.h> -#include <DNA_mesh_types.h> -#include <DNA_meshdata_types.h> -#include <DNA_image_types.h> -#include <IMB_imbuf_types.h> -#include <KX_PolygonMaterial.h> +#include "KX_GameObject.h" +#include "KX_Light.h" +#include "RAS_MeshObject.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_image_types.h" +#include "IMB_imbuf_types.h" +#include "KX_PolygonMaterial.h" -#include <MEM_guardedalloc.h> +#include "MEM_guardedalloc.h" -#include <KX_BlenderMaterial.h> -#include <BL_Texture.h> +#include "KX_BlenderMaterial.h" +#include "BL_Texture.h" #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index d6e2ba0174f..ad5b7b9fb44 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -27,12 +27,12 @@ http://www.gnu.org/copyleft/lesser.txt. #ifndef __TEXTURE_H__ #define __TEXTURE_H__ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <structmember.h> -#include <DNA_image_types.h> -#include <BL_Texture.h> -#include <KX_BlenderMaterial.h> +#include "DNA_image_types.h" +#include "BL_Texture.h" +#include "KX_BlenderMaterial.h" #include "ImageBase.h" #include "BlendType.h" diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h index 7ad3c6a9c77..3657a20b841 100644 --- a/source/gameengine/VideoTexture/VideoBase.h +++ b/source/gameengine/VideoTexture/VideoBase.h @@ -28,7 +28,7 @@ http://www.gnu.org/copyleft/lesser.txt. #define __VIDEOBASE_H__ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include "ImageBase.h" diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index f4d3fb75223..4586a50e6a9 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -162,14 +162,14 @@ void VideoFFmpeg::initParams (short width, short height, float rate, bool image) } -int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams) +int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams) { - AVFormatContext *formatCtx; + AVFormatContext *formatCtx = NULL; int i, videoStream; AVCodec *codec; AVCodecContext *codecCtx; - if (av_open_input_file(&formatCtx, filename, inputFormat, 0, formatParams)!=0) + if (avformat_open_input(&formatCtx, filename, inputFormat, formatParams)!=0) return -1; if (av_find_stream_info(formatCtx)<0) @@ -545,11 +545,7 @@ void VideoFFmpeg::openFile (char * filename) // but it is really not desirable to seek on http file, so force streaming. // It would be good to find this information from the context but there are no simple indication !strncmp(filename, "http://", 7) || -#ifdef FFMPEG_PB_IS_POINTER - (m_formatCtx->pb && m_formatCtx->pb->is_streamed) -#else - m_formatCtx->pb.is_streamed -#endif + (m_formatCtx->pb && !m_formatCtx->pb->seekable) ) { // the file is in fact a streaming source, treat as cam to prevent seeking @@ -586,14 +582,12 @@ void VideoFFmpeg::openCam (char * file, short camIdx) { // open camera source AVInputFormat *inputFormat; - AVFormatParameters formatParams; - AVRational frameRate; + AVDictionary *formatParams = NULL; char filename[28], rateStr[20]; char *p; do_init_ffmpeg(); - memset(&formatParams, 0, sizeof(formatParams)); #ifdef WIN32 // video capture on windows only through Video For Windows driver inputFormat = av_find_input_format("vfwcap"); @@ -623,7 +617,13 @@ void VideoFFmpeg::openCam (char * file, short camIdx) sprintf(filename, "/dev/dv1394/%d", camIdx); } else { - inputFormat = av_find_input_format("video4linux"); + const char *formats[] = {"video4linux2,v4l2", "video4linux2", "video4linux"}; + int i, formatsCount = sizeof(formats) / sizeof(char*); + for (i = 0; i < formatsCount; i++) { + inputFormat = av_find_input_format(formats[i]); + if (inputFormat) + break; + } sprintf(filename, "/dev/video%d", camIdx); } if (!inputFormat) @@ -637,20 +637,22 @@ void VideoFFmpeg::openCam (char * file, short camIdx) if ((p = strchr(filename, ':')) != 0) *p = 0; } - if (file && (p = strchr(file, ':')) != NULL) - formatParams.standard = p+1; + if (file && (p = strchr(file, ':')) != NULL) { + av_dict_set(&formatParams, "standard", p+1, 0); + } #endif //frame rate if (m_captRate <= 0.f) m_captRate = defFrameRate; sprintf(rateStr, "%f", m_captRate); - av_parse_video_rate(&frameRate, rateStr); - // populate format parameters - // need to specify the time base = inverse of rate - formatParams.time_base.num = frameRate.den; - formatParams.time_base.den = frameRate.num; - formatParams.width = m_captWidth; - formatParams.height = m_captHeight; + + av_dict_set(&formatParams, "framerate", rateStr, 0); + + if (m_captWidth > 0 && m_captHeight > 0) { + char video_size[64]; + BLI_snprintf(video_size, sizeof(video_size), "%dx%d", m_captWidth, m_captHeight); + av_dict_set(&formatParams, "video_size", video_size, 0); + } if (openStream(filename, inputFormat, &formatParams) != 0) return; @@ -665,6 +667,8 @@ void VideoFFmpeg::openCam (char * file, short camIdx) // no need to thread if the system has a single core m_isThreaded = true; } + + av_dict_free(&formatParams); } // play video diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index d3458211949..e63032e0c66 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -46,10 +46,6 @@ extern "C" { # define FFMPEG_CODEC_IS_POINTER 1 #endif -#if LIBAVFORMAT_VERSION_INT >= (52 << 16) -# define FFMPEG_PB_IS_POINTER 1 -#endif - #ifdef FFMPEG_CODEC_IS_POINTER static inline AVCodecContext* get_codec_from_stream(AVStream* stream) { @@ -172,7 +168,7 @@ protected: double actFrameRate (void) { return m_frameRate * m_baseFrameRate; } /// common function to video file and capture - int openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams); + int openStream(const char *filename, AVInputFormat *inputFormat, AVDictionary **formatParams); /// check if a frame is available and load it in pFrame, return true if a frame could be retrieved AVFrame* grabFrame(long frame); diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index a82935c30bf..627da57baac 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. * \ingroup bgevideotex */ -#include <PyObjectPlus.h> +#include "PyObjectPlus.h" #include <RAS_GLExtensionManager.h> |