diff options
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 142 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_ModifierDeformer.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Expressions/Value.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_CameraActuator.cpp | 3 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 26 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.h | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_NavMeshObject.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_ObjectActuator.cpp | 4 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 10 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 5 | ||||
-rw-r--r-- | source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp | 2 |
12 files changed, 125 insertions, 83 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 6262f8e48ce..c5dea5d0b43 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -426,63 +426,74 @@ static void SetDefaultLightMode(Scene* scene) } +static bool GetMaterialUseVColor(Material *ma, const bool glslmat) +{ + if (ma) { + /* glsl uses vertex colors, otherwise use material setting + * defmaterial doesn't have VERTEXCOLP as default [#34505] */ + return (glslmat || ma == &defmaterial || (ma->mode & MA_VERTEXCOLP) != 0); + } + else { + /* no material, use vertex colors */ + return true; + } +} + // -- -static void GetRGB(short type, - MFace* mface, - MCol* mmcol, - Material *mat, - unsigned int c[4]) +static void GetRGB( + const bool use_vcol, + MFace* mface, + MCol* mmcol, + Material *mat, + unsigned int c[4]) { unsigned int color = 0xFFFFFFFFL; - switch (type) { - case 0: // vertex colors - { - if (mmcol) { - c[0] = KX_Mcol2uint_new(mmcol[0]); - c[1] = KX_Mcol2uint_new(mmcol[1]); - c[2] = KX_Mcol2uint_new(mmcol[2]); - if (mface->v4) - c[3] = KX_Mcol2uint_new(mmcol[3]); - } - else { // backup white - c[0] = KX_rgbaint2uint_new(color); - c[1] = KX_rgbaint2uint_new(color); - c[2] = KX_rgbaint2uint_new(color); - if (mface->v4) - c[3] = KX_rgbaint2uint_new( color ); - } - } break; - - - case 1: // material rgba - { - if (mat) { - union { - unsigned char cp[4]; - unsigned int integer; - } col_converter; - col_converter.cp[3] = (unsigned char) (mat->r * 255.0f); - col_converter.cp[2] = (unsigned char) (mat->g * 255.0f); - col_converter.cp[1] = (unsigned char) (mat->b * 255.0f); - col_converter.cp[0] = (unsigned char) (mat->alpha * 255.0f); - color = col_converter.integer; - } - c[0] = KX_rgbaint2uint_new(color); - c[1] = KX_rgbaint2uint_new(color); - c[2] = KX_rgbaint2uint_new(color); + if (use_vcol == true) { + if (mmcol) { + c[0] = KX_Mcol2uint_new(mmcol[0]); + c[1] = KX_Mcol2uint_new(mmcol[1]); + c[2] = KX_Mcol2uint_new(mmcol[2]); if (mface->v4) - c[3] = KX_rgbaint2uint_new(color); - } break; - - default: // white - { + c[3] = KX_Mcol2uint_new(mmcol[3]); + } + else { // backup white c[0] = KX_rgbaint2uint_new(color); c[1] = KX_rgbaint2uint_new(color); c[2] = KX_rgbaint2uint_new(color); if (mface->v4) - c[3] = KX_rgbaint2uint_new(color); - } break; + c[3] = KX_rgbaint2uint_new( color ); + } + } + else { + /* material rgba */ + if (mat) { + union { + unsigned char cp[4]; + unsigned int integer; + } col_converter; + col_converter.cp[3] = (unsigned char) (mat->r * 255.0f); + col_converter.cp[2] = (unsigned char) (mat->g * 255.0f); + col_converter.cp[1] = (unsigned char) (mat->b * 255.0f); + col_converter.cp[0] = (unsigned char) (mat->alpha * 255.0f); + color = col_converter.integer; + } + c[0] = KX_rgbaint2uint_new(color); + c[1] = KX_rgbaint2uint_new(color); + c[2] = KX_rgbaint2uint_new(color); + if (mface->v4) { + c[3] = KX_rgbaint2uint_new(color); + } } + +#if 0 /* white, unused */ + { + c[0] = KX_rgbaint2uint_new(color); + c[1] = KX_rgbaint2uint_new(color); + c[2] = KX_rgbaint2uint_new(color); + if (mface->v4) + c[3] = KX_rgbaint2uint_new(color); + } +#endif } typedef struct MTF_localLayer { @@ -570,24 +581,17 @@ static bool ConvertMaterial( { material->Initialize(); int texalpha = 0; - bool validmat = (mat!=0); - bool validface = (tface!=0); - - short type = 0; - if ( validmat ) - type = 1; // material color + const bool validmat = (mat != NULL); + const bool validface = (tface != NULL); + const bool use_vcol = GetMaterialUseVColor(mat, glslmat); material->IdMode = DEFAULT_BLENDER; - material->glslmat = (validmat)? glslmat: false; + material->glslmat = (validmat) ? glslmat: false; material->materialindex = mface->mat_nr; // -------------------------------- if (validmat) { - // use vertex colors by explicitly setting - if (mat->mode &MA_VERTEXCOLP || glslmat) - type = 0; - // use lighting? material->ras_mode |= ( mat->mode & MA_SHLESS )?0:USE_LIGHT; material->ras_mode |= ( mat->game.flag & GEMAT_BACKCULL )?0:TWOSIDED; @@ -859,10 +863,10 @@ static bool ConvertMaterial( // XXX The RGB values here were meant to be temporary storage for the conversion process, // but fonts now make use of them too, so we leave them in for now. unsigned int rgb[4]; - GetRGB(type,mface,mmcol,mat,rgb); + GetRGB(use_vcol, mface, mmcol, mat, rgb); // swap the material color, so MCol on bitmap font works - if (validmat && type==1 && (mat->game.flag & GEMAT_TEXT)) + if (validmat && (use_vcol == false) && (mat->game.flag & GEMAT_TEXT)) { rgb[0] = KX_rgbaint2uint_new(rgb[0]); rgb[1] = KX_rgbaint2uint_new(rgb[1]); @@ -904,9 +908,8 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace converter->CacheBlenderMaterial(ma, bl_mat); } - - short type = (ma) ? ((ma->mode & MA_VERTEXCOLP || bl_mat->glslmat) ? 0 : 1) : 0; - GetRGB(type,mface,mcol,ma,rgb); + const bool use_vcol = GetMaterialUseVColor(ma, bl_mat->glslmat); + GetRGB(use_vcol, mface, mcol, ma, rgb); GetUVs(bl_mat, layers, mface, tface, uvs); @@ -1021,9 +1024,9 @@ static RAS_MaterialBucket *material_from_mesh(Material *ma, MFace *mface, MTFace } // only zsort alpha + add - bool alpha = ELEM3(alpha_blend, GEMAT_ALPHA, GEMAT_ADD, GEMAT_ALPHA_SORT); - bool zsort = (alpha_blend == GEMAT_ALPHA_SORT); - bool light = (ma)?(ma->mode & MA_SHLESS)==0:default_light_mode; + const bool alpha = ELEM3(alpha_blend, GEMAT_ALPHA, GEMAT_ADD, GEMAT_ALPHA_SORT); + const bool zsort = (alpha_blend == GEMAT_ALPHA_SORT); + const bool light = (ma)?(ma->mode & MA_SHLESS)==0:default_light_mode; // don't need zort anymore, deal as if it it's alpha blend if (alpha_blend == GEMAT_ALPHA_SORT) alpha_blend = GEMAT_ALPHA; @@ -1137,6 +1140,11 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, KX_Scene* scene, tan[i].setValue(zero_vec); } + /* we need to manually initialize the uvs (MoTo doesn't do that) [#34550] */ + for (unsigned int i = 0; i < RAS_TexVert::MAX_UNIT; i++) { + uvs[0][i] = uvs[1][i] = uvs[2][i] = uvs[3][i] = MT_Point2(0.f, 0.f); + } + for (int f=0;f<totface;f++,mface++) { /* get coordinates, normals and tangents */ diff --git a/source/gameengine/Converter/BL_ModifierDeformer.cpp b/source/gameengine/Converter/BL_ModifierDeformer.cpp index 53755deefe1..ec52eaac637 100644 --- a/source/gameengine/Converter/BL_ModifierDeformer.cpp +++ b/source/gameengine/Converter/BL_ModifierDeformer.cpp @@ -67,10 +67,6 @@ extern "C"{ #include "BLI_blenlib.h" #include "BLI_math.h" -#define __NLA_DEFNORMALS -//#undef __NLA_DEFNORMALS - - BL_ModifierDeformer::~BL_ModifierDeformer() { if (m_dm) { diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index bcfb7e92d71..706cfc13ca3 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -18,6 +18,7 @@ * */ #include "Value.h" +#include "BoolValue.h" #include "FloatValue.h" #include "IntValue.h" #include "VectorValue.h" @@ -573,6 +574,11 @@ CValue* CValue::ConvertPythonToValue(PyObject *pyobj, const char *error_prefix) } else #endif + /* note: Boolean check should go before Int check [#34677] */ + if (PyBool_Check(pyobj)) + { + vallie = new CBoolValue( (bool)PyLong_AsLongLong(pyobj) ); + } else if (PyFloat_Check(pyobj)) { vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) ); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 792a0759b59..acf30b4866c 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -36,7 +36,6 @@ #include "BLI_math_vector.h" #include "KX_CameraActuator.h" -#include <iostream> #include <math.h> #include <float.h> #include "KX_GameObject.h" @@ -197,7 +196,7 @@ bool KX_CameraActuator::Update(double curtime, bool frame) MT_Point3 lookat = ((KX_GameObject*)m_ob)->NodeGetWorldPosition(); MT_Matrix3x3 actormat = ((KX_GameObject*)m_ob)->NodeGetWorldOrientation(); - float fp1[3], fp2[3], rc[3]; + float fp1[3]={0}, fp2[3]={0}, rc[3]; float inp, fac; //, factor = 0.0; /* some factor... */ float mindistsq, maxdistsq, distsq; float mat[3][3]; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 23419f11cd5..fab19008b25 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -184,7 +184,10 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) for (int i = tc_first; i < tc_numCategories; i++) m_logger->AddCategory((KX_TimeCategory)i); - + +#ifdef WITH_PYTHON + m_pyprofiledict = PyDict_New(); +#endif } @@ -197,6 +200,10 @@ KX_KetsjiEngine::~KX_KetsjiEngine() delete m_logger; if (m_usedome) delete m_dome; + +#ifdef WITH_PYTHON + Py_CLEAR(m_pyprofiledict); +#endif } @@ -256,6 +263,12 @@ void KX_KetsjiEngine::SetPyNamespace(PyObject *pythondictionary) MT_assert(pythondictionary); m_pythondictionary = pythondictionary; } + +PyObject* KX_KetsjiEngine::GetPyProfileDict() +{ + Py_INCREF(m_pyprofiledict); + return m_pyprofiledict; +} #endif @@ -297,7 +310,7 @@ void KX_KetsjiEngine::RenderDome() return; KX_SceneList::iterator sceneit; - KX_Scene* scene; + KX_Scene* scene = NULL; int n_renders=m_dome->GetNumberRenders();// usually 4 or 6 for (int i=0;i<n_renders;i++) { @@ -1513,6 +1526,15 @@ void KX_KetsjiEngine::RenderDebugProperties() m_rendertools->RenderBox2D(xcoord + (int)(2.2 * profile_indent), ycoord, m_canvas->GetWidth(), m_canvas->GetHeight(), time/tottime); ycoord += const_ysize; + +#ifdef WITH_PYTHON + PyObject *val = PyTuple_New(2); + PyTuple_SetItem(val, 0, PyFloat_FromDouble(time*1000.f)); + PyTuple_SetItem(val, 1, PyFloat_FromDouble(time/tottime * 100.f)); + + PyDict_SetItemString(m_pyprofiledict, m_profileLabels[j], val); + Py_DECREF(val); +#endif } } // Add the ymargin for titles below the other section of debug info diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 92ffaf47aa4..fdfe0551d18 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -81,6 +81,7 @@ private: #ifdef WITH_PYTHON /* borrowed from sys.modules["__main__"], don't manage ref's */ PyObject* m_pythondictionary; + PyObject* m_pyprofiledict; #endif class SCA_IInputDevice* m_keyboarddevice; class SCA_IInputDevice* m_mousedevice; @@ -222,6 +223,7 @@ public: #ifdef WITH_PYTHON void SetPyNamespace(PyObject *pythondictionary); PyObject* GetPyNamespace() { return m_pythondictionary; } + PyObject* GetPyProfileDict(); #endif void SetSceneConverter(KX_ISceneConverter* sceneconverter); void SetAnimRecordMode(bool animation_record, int startFrame); diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index 33656e9fd52..24400398f03 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -96,7 +96,7 @@ CValue* KX_NavMeshObject::GetReplica() void KX_NavMeshObject::ProcessReplica() { KX_GameObject::ProcessReplica(); - + m_navMesh = NULL; /* without this, building frees the navmesh we copied from */ BuildNavMesh(); KX_Scene* scene = KX_GetActiveScene(); KX_ObstacleSimulation* obssimulation = scene->GetObstacleSimulation(); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index b4ee339568c..d02554e185e 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -215,8 +215,8 @@ bool KX_ObjectActuator::Update() m_previous_error = e; m_error_accumulator = I; parent->ApplyForce(m_force,(m_bitLocalFlag.LinearVelocity) != 0); - } else if(m_bitLocalFlag.CharacterMotion) - { + } + else if (m_bitLocalFlag.CharacterMotion) { MT_Vector3 dir = m_dloc; if (m_bitLocalFlag.AddOrSetCharLoc) { diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 66333a061c5..06abc755a9a 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -371,6 +371,15 @@ static PyObject *gPyLoadGlobalDict(PyObject *) Py_RETURN_NONE; } +static char gPyGetProfileInfo_doc[] = +"getProfileInfo()\n" +"returns a dictionary with profiling information"; + +static PyObject *gPyGetProfileInfo(PyObject *) +{ + return gp_KetsjiEngine->GetPyProfileDict(); +} + static char gPySendMessage_doc[] = "sendMessage(subject, [body, to, from])\n\ sends a message in same manner as a message actuator\ @@ -858,6 +867,7 @@ static struct PyMethodDef game_methods[] = { {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"}, {"PrintMemInfo", (PyCFunction)pyPrintStats, METH_NOARGS, (const char *)"Print engine statistics"}, {"NextFrame", (PyCFunction)gPyNextFrame, METH_NOARGS, (const char *)"Render next frame (if Python has control)"}, + {"getProfileInfo", (PyCFunction)gPyGetProfileInfo, METH_NOARGS, gPyGetProfileInfo_doc}, /* library functions */ {"LibLoad", (PyCFunction)gLibLoad, METH_VARARGS|METH_KEYWORDS, (const char *)""}, {"LibNew", (PyCFunction)gLibNew, METH_VARARGS, (const char *)""}, diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index fec275322e9..3e1a81c2f4f 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1172,9 +1172,8 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj, bool use_gfx, bool u ); } newobj->SetDeformer(modifierDeformer); - } - else if (bHasShapeKey) - { + } + else if (bHasShapeKey) { BL_ShapeDeformer* shapeDeformer; if (bHasArmature) { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 9fb86dec569..d5ceba0ec57 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1576,7 +1576,7 @@ struct OcclusionBuffer } } } - else if (width == 1) { + else if (width == 1) { // Degenerated in at least 2 vertical lines // The algorithm below doesn't work when face has a single pixel width // We cannot use general formulas because the plane is degenerated. diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp index d45365dde04..72af3852cf6 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageVA.cpp @@ -119,7 +119,7 @@ void RAS_StorageVA::IndexPrimitives(RAS_MeshSlot& ms) void RAS_StorageVA::IndexPrimitivesMulti(class RAS_MeshSlot& ms) { static const GLsizei stride = sizeof(RAS_TexVert); - bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_color_array; + bool wireframe = m_drawingmode <= RAS_IRasterizer::KX_WIREFRAME, use_color_array = true; RAS_MeshSlot::iterator it; GLenum drawmode; |