From 21eb3e11e0d4d42d23de6c27a5cdf83d36ac0774 Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Mon, 22 Oct 2007 20:24:26 +0000 Subject: 2d-Filters feature and actuators. --- .../BlenderRoutines/KX_BlenderRenderTools.cpp | 10 + .../BlenderRoutines/KX_BlenderRenderTools.h | 7 + .../gameengine/Converter/KX_ConvertActuators.cpp | 58 +++++ source/gameengine/GameLogic/CMakeLists.txt | 1 + .../gameengine/GameLogic/SCA_2DFilterActuator.cpp | 115 +++++++++ source/gameengine/GameLogic/SCA_2DFilterActuator.h | 43 ++++ source/gameengine/GameLogic/SConscript | 1 + .../GamePlayer/common/GPC_RenderTools.cpp | 10 + .../gameengine/GamePlayer/common/GPC_RenderTools.h | 6 + source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 12 +- source/gameengine/Ketsji/KX_KetsjiEngine.h | 4 + .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 285 +++++++++++++++++++++ source/gameengine/Rasterizer/RAS_2DFilterManager.h | 59 +++++ source/gameengine/Rasterizer/RAS_IRenderTools.h | 16 +- .../RAS_OpenGLFilters/RAS_Blur2DFilter.h | 24 ++ .../RAS_OpenGLFilters/RAS_Dilation2DFilter.h | 24 ++ .../RAS_OpenGLFilters/RAS_Erosion2DFilter.h | 23 ++ .../RAS_OpenGLFilters/RAS_GrayScale2DFilter.h | 14 + .../RAS_OpenGLFilters/RAS_Invert2DFilter.h | 15 ++ .../RAS_OpenGLFilters/RAS_Laplacian2DFilter.h | 26 ++ .../RAS_OpenGLFilters/RAS_Prewitt2DFilter.h | 31 +++ .../RAS_OpenGLFilters/RAS_Sepia2DFilter.h | 15 ++ .../RAS_OpenGLFilters/RAS_Sharpen2DFilter.h | 25 ++ .../RAS_OpenGLFilters/RAS_Sobel2DFilter.h | 30 +++ 24 files changed, 849 insertions(+), 5 deletions(-) create mode 100644 source/gameengine/GameLogic/SCA_2DFilterActuator.cpp create mode 100644 source/gameengine/GameLogic/SCA_2DFilterActuator.h create mode 100644 source/gameengine/Rasterizer/RAS_2DFilterManager.cpp create mode 100644 source/gameengine/Rasterizer/RAS_2DFilterManager.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h create mode 100644 source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 463f06869d6..06d869a9396 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -475,4 +475,14 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } +void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass) +{ + m_filtermanager.EnableFilter(filtermode, pass); +} + +void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas) +{ + m_filtermanager.RenderFilters(canvas); +} + unsigned int KX_BlenderRenderTools::m_numgllights; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index a79302a283e..b67b7c8161f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -55,6 +55,7 @@ class KX_BlenderRenderTools : public RAS_IRenderTools bool m_lastlighting; static unsigned int m_numgllights; + public: KX_BlenderRenderTools(); @@ -102,8 +103,14 @@ public: bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); virtual void MotionBlur(RAS_IRasterizer* rasterizer); + + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass); + + virtual void Render2DFilters(RAS_ICanvas* canvas); + }; #endif //__KX_BLENDERRENDERTOOLS + diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a6baa04b045..e29a1729fc3 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -45,6 +45,7 @@ #include "SCA_PropertyActuator.h" #include "SCA_LogicManager.h" #include "SCA_RandomActuator.h" +#include "SCA_2DFilterActuator.h" // Ketsji specific logicbricks @@ -836,7 +837,63 @@ void BL_ConvertActuators(char* maggiename, baseact = tmp_vis_act; } break; + + case ACT_2DFILTER: + { + bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data; + SCA_2DFilterActuator *tmp = NULL; + RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode; + switch(_2dfilter->type) + { + case ACT_2DFILTER_MOTIONBLUR: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR; + break; + case ACT_2DFILTER_BLUR: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_BLUR; + break; + case ACT_2DFILTER_SHARPEN: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_SHARPEN; + break; + case ACT_2DFILTER_DILATION: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_DILATION; + break; + case ACT_2DFILTER_EROSION: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_EROSION; + break; + case ACT_2DFILTER_LAPLACIAN: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN; + break; + case ACT_2DFILTER_SOBEL: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_SOBEL; + break; + case ACT_2DFILTER_PREWITT: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_PREWITT; + break; + case ACT_2DFILTER_GRAYSCALE: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE; + break; + case ACT_2DFILTER_SEPIA: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_SEPIA; + break; + case ACT_2DFILTER_INVERT: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT; + break; + case ACT_2DFILTER_NOFILTER: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; + break; + default: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; + break; + } + + tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, + _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools); + + baseact = tmp; + + } + break; default: ; /* generate some error */ } @@ -860,3 +917,4 @@ void BL_ConvertActuators(char* maggiename, } } + diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 127edfc151d..4f40fa22b9e 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -35,6 +35,7 @@ SET(INC ../../../intern/string ../../../source/gameengine/Expressions ../../../intern/moto/include + ../../../source/gameengine/Rasterizer ${PYTHON_INC} ${SDL_INC} ) diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp new file mode 100644 index 00000000000..7033ae30ac5 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -0,0 +1,115 @@ +#include "SCA_IActuator.h" + +#include "SCA_2DFilterActuator.h" + +#ifdef HAVE_CONFIG_H +#include +#endif +#include + + + +SCA_2DFilterActuator::SCA_2DFilterActuator( + SCA_IObject *gameobj, + RAS_2DFilterManager::RAS_2DFILTER_MODE type, + short flag, + float float_arg, + int int_arg, + RAS_IRasterizer* rasterizer, + RAS_IRenderTools* rendertools, + PyTypeObject* T) + : SCA_IActuator(gameobj, T), + m_type(type), + m_flag(flag), + m_int_arg(int_arg), + m_float_arg(float_arg), + m_rasterizer(rasterizer), + m_rendertools(rendertools) +{ +} + + +SCA_2DFilterActuator::~SCA_2DFilterActuator() +{ + +} + + +CValue* SCA_2DFilterActuator::GetReplica() +{ + SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this); + replica->ProcessReplica(); + CValue::AddDataToReplica(replica); + + return replica; +} + + +bool SCA_2DFilterActuator::Update() +{ + bool result = false; + + bool bNegativeEvent = IsNegativeEvent(); + RemoveAllEvents(); + + + if (bNegativeEvent) + return false; // do nothing on negative events + + if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR ) + { + if(!m_flag) + { + m_rasterizer->EnableMotionBlur(m_float_arg); + } + else + { + m_rasterizer->DisableMotionBlur(); + } + } + else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) + { + m_rendertools->Update2DFilter(m_type, m_int_arg); + } + return true; +} + + +PyTypeObject SCA_2DFilterActuator::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_2DFilterActuator", + sizeof(SCA_2DFilterActuator), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, + __repr, + 0, + 0, + 0, + 0, + 0 +}; + + +PyParentObject SCA_2DFilterActuator::Parents[] = { + &SCA_2DFilterActuator::Type, + &SCA_IActuator::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + + +PyMethodDef SCA_2DFilterActuator::Methods[] = { + /* add python functions to deal with m_msg... */ + {NULL,NULL} +}; + + +PyObject* SCA_2DFilterActuator::_getattr(const STR_String& attr) { + _getattr_up(SCA_IActuator); +} diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h new file mode 100644 index 00000000000..f1871c8f093 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -0,0 +1,43 @@ +#ifndef __SCA_2DFILETRACTUATOR_H__ +#define __SCA_2DFILETRACTUATOR_H__ + +#include "RAS_IRasterizer.h" +#include "RAS_IRenderTools.h" +#include "SCA_IActuator.h" + + +class SCA_2DFilterActuator : public SCA_IActuator +{ + Py_Header; + +private: + + RAS_2DFilterManager::RAS_2DFILTER_MODE m_type; + short m_flag; + float m_float_arg; + int m_int_arg; + RAS_IRasterizer* m_rasterizer; + RAS_IRenderTools* m_rendertools; + +public: + + SCA_2DFilterActuator( + class SCA_IObject* gameobj, + RAS_2DFilterManager::RAS_2DFILTER_MODE type, + short flag, + float float_arg, + int int_arg, + RAS_IRasterizer* rasterizer, + RAS_IRenderTools* rendertools, + PyTypeObject* T=&Type + ); + + + virtual ~SCA_2DFilterActuator(); + virtual bool Update(); + + virtual CValue* GetReplica(); + virtual PyObject* _getattr(const STR_String& attr); + +}; +#endif diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index 7a2c3d91e72..1ca884f6dec 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -5,6 +5,7 @@ sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp') incs = '. #/source/kernel/gen_system #/intern/string' incs += ' #/source/gameengine/Expressions #/intern/moto/include' +incs += ' #/source/gameengine/Rasterizer' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_SDL_INC'] diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index cc5c392d51a..ffa8bdb32e7 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -593,4 +593,14 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } +void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass) +{ + m_filtermanager.EnableFilter(filtermode, pass); +} + +void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas) +{ + m_filtermanager.RenderFilters( canvas); +} + unsigned int GPC_RenderTools::m_numgllights; diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index e1f2a869c22..4b1e990b717 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -151,6 +151,11 @@ public: bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); virtual void MotionBlur(RAS_IRasterizer* rasterizer); + + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass); + + virtual void Render2DFilters(RAS_ICanvas* canvas); + protected: /** * Copied from KX_BlenderGL.cpp in KX_blenderhook @@ -176,3 +181,4 @@ protected: #endif // __GPC_RENDERTOOLS_H + diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index f8826245aab..e0a826b8d5d 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -966,13 +966,18 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) scene->CalculateVisibleMeshes(m_rasterizer,cam); scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools); + + PostRenderFrame(); +} +void KX_KetsjiEngine::PostRenderFrame() +{ + m_rendertools->PushMatrix(); + m_rendertools->Render2DFilters(m_canvas); m_rendertools->MotionBlur(m_rasterizer); - + m_rendertools->PopMatrix(); } - - void KX_KetsjiEngine::StopEngine() { if (m_bInitialized) @@ -1467,3 +1472,4 @@ void KX_KetsjiEngine::GetOverrideFrameColor(float& r, float& g, float& b) const } + diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 16b53b6b688..fcb4d0a0790 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -179,6 +179,7 @@ private: void SetupRenderFrame(KX_Scene *scene, KX_Camera* cam); void RenderFrame(KX_Scene* scene, KX_Camera* cam); + void PostRenderFrame(); void RenderDebugProperties(); void SetBackGround(KX_WorldInfo* worldinfo); void SetWorldSettings(KX_WorldInfo* worldinfo); @@ -201,6 +202,8 @@ public: void SetSceneConverter(KX_ISceneConverter* sceneconverter); void SetGame2IpoMode(bool game2ipo,int startFrame); + RAS_IRasterizer* GetRasterizer(){return m_rasterizer;}; + ///returns true if an update happened to indicate -> Render bool NextFrame(); void Render(); @@ -342,3 +345,4 @@ protected: #endif //__KX_KETSJI_ENGINE + diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp new file mode 100644 index 00000000000..740a4d7a6b3 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -0,0 +1,285 @@ + +#define STRINGIFY(A) #A + +#include "RAS_OpenGLFilters/RAS_Blur2DFilter.h" +#include "RAS_OpenGLFilters/RAS_Sharpen2DFilter.h" +#include "RAS_OpenGLFilters/RAS_Dilation2DFilter.h" +#include "RAS_OpenGLFilters/RAS_Erosion2DFilter.h" +#include "RAS_OpenGLFilters/RAS_Laplacian2DFilter.h" +#include "RAS_OpenGLFilters/RAS_Sobel2DFilter.h" +#include "RAS_OpenGLFilters/RAS_Prewitt2DFilter.h" +#include "RAS_OpenGLFilters/RAS_GrayScale2DFilter.h" +#include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h" +#include "RAS_OpenGLFilters/RAS_Invert2DFilter.h" + +#include "RAS_ICanvas.h" +#include "RAS_2DFilterManager.h" +#include + +#ifdef WIN32 +// OpenGL gl.h needs 'windows.h' on windows platforms +#include +#endif //WIN32 +#ifdef __APPLE__ +#define GL_GLEXT_LEGACY 1 +#include +#else +#include +#endif + +#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + + +RAS_2DFilterManager::RAS_2DFilterManager(): +texturewidth(-1), textureheight(-1), +canvaswidth(-1), canvasheight(-1), +numberoffilters(0),texname(-1) +{ + isshadersupported = bgl::QueryVersion(2,0); + if(!isshadersupported) + { + std::cout<<"shaders not supported!" << std::endl; + return; + } + + int passindex; + for(passindex =0; passindexGetWidth() || canvasheight != canvas->GetHeight()) + { + UpdateOffsetMatrix(canvas->GetWidth(), canvas->GetHeight()); + } + GLuint viewport[4]={0}; + + int passindex; + bool first = true; + for(passindex =0; passindex #include @@ -41,6 +42,7 @@ class RAS_IPolyMaterial; struct RAS_LightObject; + class RAS_IRenderTools { @@ -52,7 +54,8 @@ protected: bool m_modified; std::vector m_lights; - + + RAS_2DFilterManager m_filtermanager; public: enum RAS_TEXT_RENDER_MODE { @@ -61,7 +64,7 @@ public: RAS_TEXT_PADDED, RAS_TEXT_MAX }; - + RAS_IRenderTools( ) : m_clientobject(NULL), @@ -178,6 +181,14 @@ public: void MotionBlur(RAS_IRasterizer* rasterizer)=0; + virtual + void + Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass)=0; + + virtual + void + Render2DFilters(RAS_ICanvas* canvas)=0; + virtual class RAS_IPolyMaterial* CreateBlenderPolyMaterial( @@ -200,3 +211,4 @@ public: #endif //__RAS_IRENDERTOOLS + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h new file mode 100644 index 00000000000..ae7f56174e6 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h @@ -0,0 +1,24 @@ +#ifndef __RAS_BLUR2DFILTER +#define __RAS_BLUR2DFILTER + +char * BlurFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 tc_offset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(sampler0, + gl_TexCoord[0].st + tc_offset[i]); + } + + gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + + (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + + sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; +} +); +#endif + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h new file mode 100644 index 00000000000..6fd7f867d10 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h @@ -0,0 +1,24 @@ +#ifndef __RAS_DILATION2DFILTER +#define __RAS_DILATION2DFILTER + +char * DilationFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 tc_offset[9]; + +void main(void) +{ + vec4 sample[9]; + vec4 maxValue = vec4(0.0); + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(sampler0, + gl_TexCoord[0].st + tc_offset[i]); + maxValue = max(sample[i], maxValue); + } + + gl_FragColor = maxValue; +} +); +#endif + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h new file mode 100644 index 00000000000..a0fc7486447 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h @@ -0,0 +1,23 @@ +#ifndef __RAS_EROSION2DFILTER +#define __RAS_EROSION2DFILTER + +char * ErosionFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 tc_offset[9]; + +void main(void) +{ + vec4 sample[9]; + vec4 minValue = vec4(1.0); + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(sampler0, + gl_TexCoord[0].st + tc_offset[i]); + minValue = min(sample[i], minValue); + } + + gl_FragColor = minValue; +} +); +#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h new file mode 100644 index 00000000000..c6fc4a0214d --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h @@ -0,0 +1,14 @@ +#ifndef __RAS_GRAYSCALE2DFILTER +#define __RAS_GRAYSCALE2DFILTER + +char * GrayScaleFragmentShader=STRINGIFY( +uniform sampler2D sampler0; + +void main(void) +{ + vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114)); + gl_FragColor = vec4(gray, gray, gray, texcolor.a); +} +); +#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h new file mode 100644 index 00000000000..34e6fe29cd3 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h @@ -0,0 +1,15 @@ +#ifndef __RAS_INVERT2DFILTER +#define __RAS_INVERT2DFILTER + +char * InvertFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 offset[9]; + +void main(void) +{ + vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + gl_FragColor.rgb = 1.0 - texcolor.rgb; + gl_FragColor.a = texcolor.a; +} +); +#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h new file mode 100644 index 00000000000..f5b44a69c13 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h @@ -0,0 +1,26 @@ +#ifndef __RAS_LAPLACION2DFILTER +#define __RAS_LAPLACION2DFILTER + +char * LaplacionFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 tc_offset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(sampler0, + gl_TexCoord[0].st + tc_offset[i]); + } + + gl_FragColor = (sample[4] * 8.0) - + (sample[0] + sample[1] + sample[2] + + sample[3] + sample[5] + + sample[6] + sample[7] + sample[8]); + gl_FragColor = vec4(gl_FragColor.rgb, 1.0); +} +); +#endif + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h new file mode 100644 index 00000000000..a6897bd33d4 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h @@ -0,0 +1,31 @@ +#ifndef __RAS_PREWITT2DFILTER +#define __RAS_PREWITT2DFILTER + +char * PrewittFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 tc_offset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(sampler0, + gl_TexCoord[0].st + tc_offset[i]); + } + + vec4 horizEdge = sample[2] + sample[5] + sample[8] - + (sample[0] + sample[3] + sample[6]); + + vec4 vertEdge = sample[0] + sample[1] + sample[2] - + (sample[6] + sample[7] + sample[8]); + + gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + + (vertEdge.rgb * vertEdge.rgb)); + gl_FragColor.a = 1.0; +} + +); +#endif + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h new file mode 100644 index 00000000000..cfff00e1287 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h @@ -0,0 +1,15 @@ +#ifndef __RAS_SEPIA2DFILTER +#define __RAS_SEPIA2DFILTER + +char * SepiaFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 offset[9]; + +void main(void) +{ + vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114)); + gl_FragColor = vec4(gray * vec3(1.2, 1.0, 0.8), texcolor.a); +} +); +#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h new file mode 100644 index 00000000000..640983482a9 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h @@ -0,0 +1,25 @@ +#ifndef __RAS_SHARPEN2DFILTER +#define __RAS_SHARPEN2DFILTER + +char * SharpenFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 tc_offset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(sampler0, + gl_TexCoord[0].st + tc_offset[i]); + } + + gl_FragColor = (sample[4] * 9.0) - + (sample[0] + sample[1] + sample[2] + + sample[3] + sample[5] + + sample[6] + sample[7] + sample[8]); +} +); +#endif + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h new file mode 100644 index 00000000000..da1d34713c9 --- /dev/null +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h @@ -0,0 +1,30 @@ +#ifndef __RAS_SOBEL2DFILTER +#define __RAS_SOBEL2DFILTER + +char * SobelFragmentShader=STRINGIFY( +uniform sampler2D sampler0; +uniform vec2 tc_offset[9]; + +void main(void) +{ + vec4 sample[9]; + + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(sampler0, + gl_TexCoord[0].st + tc_offset[i]); + } + + vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - + (sample[0] + (2.0*sample[3]) + sample[6]); + + vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] - + (sample[6] + (2.0*sample[7]) + sample[8]); + + gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + + (vertEdge.rgb * vertEdge.rgb)); + gl_FragColor.a = 1.0; +} +); +#endif + -- cgit v1.2.3 From aa774427f64916ef5713c01c5d23657b61a80003 Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Sun, 4 Nov 2007 05:31:20 +0000 Subject: GE Patch(#7684) by Ovidiu Sabou, Speedup patch for GE in OpenGL Display Lists. --- .../gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index 7270a6d2a99..ed4cfb2ae42 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -62,7 +62,7 @@ void RAS_ListSlot::DrawList() } } if(m_list != 0) - glNewList((GLuint)m_list, GL_COMPILE_AND_EXECUTE); + glNewList((GLuint)m_list, GL_COMPILE); m_flag |= LIST_BEGIN; return; @@ -76,6 +76,7 @@ void RAS_ListSlot::EndList() glEndList(); m_flag = m_flag &~(LIST_BEGIN|LIST_MODIFY); m_flag |= LIST_END; + glCallList(m_list); } } -- cgit v1.2.3 From af169b41fda5fe05d62655b782674eda2bc565e7 Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Tue, 6 Nov 2007 12:16:12 +0000 Subject: 2d Filters updated, now you can use custom filter and write your own GLSL shader program to filter rendering result. --- .../BlenderRoutines/KX_BlenderRenderTools.cpp | 4 +- .../BlenderRoutines/KX_BlenderRenderTools.h | 2 +- .../gameengine/Converter/KX_ConvertActuators.cpp | 25 +++++- .../gameengine/GameLogic/SCA_2DFilterActuator.cpp | 11 ++- source/gameengine/GameLogic/SCA_2DFilterActuator.h | 3 +- .../GamePlayer/common/GPC_RenderTools.cpp | 4 +- .../gameengine/GamePlayer/common/GPC_RenderTools.h | 2 +- .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 90 ++++++++++++++-------- source/gameengine/Rasterizer/RAS_2DFilterManager.h | 12 +-- source/gameengine/Rasterizer/RAS_IRenderTools.h | 2 +- .../RAS_OpenGLFilters/RAS_Blur2DFilter.h | 8 +- .../RAS_OpenGLFilters/RAS_Dilation2DFilter.h | 8 +- .../RAS_OpenGLFilters/RAS_Erosion2DFilter.h | 8 +- .../RAS_OpenGLFilters/RAS_GrayScale2DFilter.h | 4 +- .../RAS_OpenGLFilters/RAS_Invert2DFilter.h | 5 +- .../RAS_OpenGLFilters/RAS_Laplacian2DFilter.h | 8 +- .../RAS_OpenGLFilters/RAS_Prewitt2DFilter.h | 8 +- .../RAS_OpenGLFilters/RAS_Sepia2DFilter.h | 5 +- .../RAS_OpenGLFilters/RAS_Sharpen2DFilter.h | 8 +- .../RAS_OpenGLFilters/RAS_Sobel2DFilter.h | 8 +- 20 files changed, 139 insertions(+), 86 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 06d869a9396..7e32ade37f2 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -475,9 +475,9 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass) +void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) { - m_filtermanager.EnableFilter(filtermode, pass); + m_filtermanager.EnableFilter(filtermode, pass, text); } void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index b67b7c8161f..3c2d4ac8e35 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -104,7 +104,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass); + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index e29a1729fc3..89a07abe21d 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -37,6 +37,8 @@ #define BLENDER_HACK_DTIME 0.02 +#include "MEM_guardedalloc.h" + #include "KX_BlenderSceneConverter.h" #include "KX_ConvertActuators.h" @@ -70,7 +72,7 @@ #include "KX_GameObject.h" /* This little block needed for linking to Blender... */ - +#include "BKE_text.h" #include "BLI_blenlib.h" #include "KX_NetworkMessageActuator.h" @@ -879,9 +881,18 @@ void BL_ConvertActuators(char* maggiename, case ACT_2DFILTER_INVERT: filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT; break; + case ACT_2DFILTER_CUSTOMFILTER: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER; + break; case ACT_2DFILTER_NOFILTER: filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; break; + case ACT_2DFILTER_DISABLED: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED; + break; + case ACT_2DFILTER_ENABLED: + filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED; + break; default: filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; break; @@ -890,6 +901,18 @@ void BL_ConvertActuators(char* maggiename, tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools); + if (_2dfilter->text) + { + char *buf; + // this is some blender specific code + buf = txt_to_buf(_2dfilter->text); + if (buf) + { + tmp->SetShaderText(STR_String(buf)); + MEM_freeN(buf); + } + } + baseact = tmp; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 7033ae30ac5..9627ad92c4c 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -8,6 +8,9 @@ #include +SCA_2DFilterActuator::~SCA_2DFilterActuator() +{ +} SCA_2DFilterActuator::SCA_2DFilterActuator( SCA_IObject *gameobj, @@ -28,13 +31,13 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( { } - -SCA_2DFilterActuator::~SCA_2DFilterActuator() +void SCA_2DFilterActuator::SetShaderText(STR_String& text) { - + m_shaderText = text; } + CValue* SCA_2DFilterActuator::GetReplica() { SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this); @@ -69,7 +72,7 @@ bool SCA_2DFilterActuator::Update() } else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) { - m_rendertools->Update2DFilter(m_type, m_int_arg); + m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText); } return true; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index f1871c8f093..76df95ac399 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -16,6 +16,7 @@ private: short m_flag; float m_float_arg; int m_int_arg; + STR_String m_shaderText; RAS_IRasterizer* m_rasterizer; RAS_IRenderTools* m_rendertools; @@ -32,7 +33,7 @@ public: PyTypeObject* T=&Type ); - + void SetShaderText(STR_String& text); virtual ~SCA_2DFilterActuator(); virtual bool Update(); diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index ffa8bdb32e7..388882e67e4 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -593,9 +593,9 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass) +void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) { - m_filtermanager.EnableFilter(filtermode, pass); + m_filtermanager.EnableFilter(filtermode, pass, text); } void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index 4b1e990b717..d90f0e5da45 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -152,7 +152,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass); + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 740a4d7a6b3..8576ea1487c 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -12,6 +12,7 @@ #include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h" #include "RAS_OpenGLFilters/RAS_Invert2DFilter.h" +#include "STR_String.h" #include "RAS_ICanvas.h" #include "RAS_2DFilterManager.h" #include @@ -48,12 +49,11 @@ numberoffilters(0),texname(-1) int passindex; for(passindex =0; passindexGetWidth() || canvasheight != canvas->GetHeight()) @@ -213,7 +224,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) bool first = true; for(passindex =0; passindex=MAX_RENDER_PASS) + return; + + if(mode == RAS_2DFILTER_DISABLED) { - if(m_programs[mode] == 0) - m_programs[mode] = CreateShaderProgram(mode); + m_enabled[pass] = 0; + return; } - else if( pass < MAX_RENDER_PASS ) + + if(mode == RAS_2DFILTER_ENABLED) { - if(mode == RAS_2DFILTER_NOFILTER ) - { - if(m_filters[pass] != 0) - numberoffilters--; - m_filters[pass] = 0; - } - else - { - if(!m_programs[mode]) - m_programs[mode] = CreateShaderProgram(mode); - if(m_programs[mode]) - { - if(m_filters[pass] == 0) - numberoffilters++; - m_filters[pass] = mode; - } - } + m_enabled[pass] = 1; + return; + } + + if(mode == RAS_2DFILTER_NOFILTER) + { + if(m_filters[pass]) + bgl::blDeleteObjectARB(m_filters[pass]); + m_enabled[pass] = 0; + m_filters[pass] = 0; + return; + } + + if(mode == RAS_2DFILTER_CUSTOMFILTER) + { + if(m_filters[pass]) + bgl::blDeleteObjectARB(m_filters[pass]); + m_filters[pass] = CreateShaderProgram(text.Ptr()); + m_enabled[pass] = 1; + return; + } + + if(mode>=RAS_2DFILTER_MOTIONBLUR && mode<=RAS_2DFILTER_INVERT) + { + if(m_filters[pass]) + bgl::blDeleteObjectARB(m_filters[pass]); + m_filters[pass] = CreateShaderProgram(mode); + m_enabled[pass] = 1; } } diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index e2d9dce170e..45e33db8d2e 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -10,7 +10,7 @@ class RAS_2DFilterManager private: unsigned int CreateShaderProgram(char* shadersource); unsigned int CreateShaderProgram(int filtermode); - void StartShaderProgram(int filtermode); + void StartShaderProgram(unsigned int shaderprogram); void EndShaderProgram(); float textureoffsets[18]; @@ -25,6 +25,8 @@ private: bool isshadersupported; public: enum RAS_2DFILTER_MODE { + RAS_2DFILTER_ENABLED = -2, + RAS_2DFILTER_DISABLED = -1, RAS_2DFILTER_NOFILTER = 0, RAS_2DFILTER_MOTIONBLUR, RAS_2DFILTER_BLUR, @@ -37,13 +39,13 @@ public: RAS_2DFILTER_GRAYSCALE, RAS_2DFILTER_SEPIA, RAS_2DFILTER_INVERT, + RAS_2DFILTER_CUSTOMFILTER, RAS_2DFILTER_NUMBER_OF_FILTERS }; - int m_filters[MAX_RENDER_PASS]; + unsigned int m_filters[MAX_RENDER_PASS]; + short m_enabled[MAX_RENDER_PASS]; - unsigned int m_programs[RAS_2DFILTER_NUMBER_OF_FILTERS]; - RAS_2DFilterManager(); ~RAS_2DFilterManager(); @@ -54,6 +56,6 @@ public: void RenderFilters(RAS_ICanvas* canvas); - void EnableFilter(RAS_2DFILTER_MODE mode, int pass); + void EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text); }; #endif diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index e7cb1c9176f..771c34a595f 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -183,7 +183,7 @@ public: virtual void - Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass)=0; + Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0; virtual void diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h index ae7f56174e6..2b0bdbc4351 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_BLUR2DFILTER char * BlurFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h index 6fd7f867d10..9cf233d549a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_DILATION2DFILTER char * DilationFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -12,8 +12,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); maxValue = max(sample[i], maxValue); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h index a0fc7486447..667da14c10e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_EROSION2DFILTER char * ErosionFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -12,8 +12,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); minValue = min(sample[i], minValue); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h index c6fc4a0214d..09f58c0a350 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h @@ -2,11 +2,11 @@ #define __RAS_GRAYSCALE2DFILTER char * GrayScaleFragmentShader=STRINGIFY( -uniform sampler2D sampler0; +uniform sampler2D bgl_RenderedTexture; void main(void) { - vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st); float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114)); gl_FragColor = vec4(gray, gray, gray, texcolor.a); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h index 34e6fe29cd3..c3b9ee117c0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h @@ -2,12 +2,11 @@ #define __RAS_INVERT2DFILTER char * InvertFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 offset[9]; +uniform sampler2D bgl_RenderedTexture; void main(void) { - vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st); gl_FragColor.rgb = 1.0 - texcolor.rgb; gl_FragColor.a = texcolor.a; } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h index f5b44a69c13..684ac4399fa 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_LAPLACION2DFILTER char * LaplacionFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } gl_FragColor = (sample[4] * 8.0) - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h index a6897bd33d4..c4b344b2ded 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_PREWITT2DFILTER char * PrewittFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } vec4 horizEdge = sample[2] + sample[5] + sample[8] - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h index cfff00e1287..4ba91b85784 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h @@ -2,12 +2,11 @@ #define __RAS_SEPIA2DFILTER char * SepiaFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 offset[9]; +uniform sampler2D bgl_RenderedTexture; void main(void) { - vec4 texcolor = texture2D(sampler0, gl_TexCoord[0].st); + vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st); float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114)); gl_FragColor = vec4(gray * vec3(1.2, 1.0, 0.8), texcolor.a); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h index 640983482a9..685471aab07 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_SHARPEN2DFILTER char * SharpenFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } gl_FragColor = (sample[4] * 9.0) - diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h index da1d34713c9..93480afb250 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h @@ -2,8 +2,8 @@ #define __RAS_SOBEL2DFILTER char * SobelFragmentShader=STRINGIFY( -uniform sampler2D sampler0; -uniform vec2 tc_offset[9]; +uniform sampler2D bgl_RenderedTexture; +uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { @@ -11,8 +11,8 @@ void main(void) for (int i = 0; i < 9; i++) { - sample[i] = texture2D(sampler0, - gl_TexCoord[0].st + tc_offset[i]); + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); } vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - -- cgit v1.2.3 From bf4d79c47b9865a75ab0d6bb5649a8edce53a57d Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Tue, 6 Nov 2007 18:39:16 +0000 Subject: Patch [#7743] Enable display lists when vertex arrays are enabled, by Ovidiu Sabou. this patch enable GE two use both vertex array and display lists. and speed up the engine a little, by the way thanks ovidiu. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 12 ++-- .../GamePlayer/ghost/GPG_Application.cpp | 6 +- .../RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp | 77 +++++++++++++++++----- .../RAS_OpenGLRasterizer/RAS_ListRasterizer.h | 12 +++- 4 files changed, 84 insertions(+), 23 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 80db437bcd9..4ae5ab67270 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -176,9 +176,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, bool lock_arrays = (displaylists && useVertexArrays); - if(displaylists && !useVertexArrays) - rasterizer = new RAS_ListRasterizer(canvas); - else if (useVertexArrays && bgl::QueryVersion(1, 1)) + if(displaylists){ + if (useVertexArrays) { + rasterizer = new RAS_ListRasterizer(canvas, true, lock_arrays); + } else { + rasterizer = new RAS_ListRasterizer(canvas); + } + } else if (useVertexArrays && bgl::QueryVersion(1, 1)) rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays); else rasterizer = new RAS_OpenGLRasterizer(canvas); @@ -663,4 +667,4 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); if (bfd) BLO_blendfiledata_free(bfd); -} \ No newline at end of file +} diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 0d2aa774394..daded7a1d25 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -533,7 +533,11 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) goto initFailed; if(useLists) - m_rasterizer = new RAS_ListRasterizer(m_canvas); + if (useVertexArrays) { + m_rasterizer = new RAS_ListRasterizer(m_canvas, true); + } else { + m_rasterizer = new RAS_ListRasterizer(m_canvas); + } else if (useVertexArrays && bgl::QueryVersion(1, 1)) m_rasterizer = new RAS_VAOpenGLRasterizer(m_canvas); else diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index ed4cfb2ae42..7baa6c49656 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -96,8 +96,9 @@ bool RAS_ListSlot::End() -RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas) -: RAS_OpenGLRasterizer(canvas) +RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays, bool lock) +: RAS_VAOpenGLRasterizer(canvas, lock), + mUseVertexArrays(useVertexArrays) { // -- } @@ -159,13 +160,22 @@ void RAS_ListRasterizer::IndexPrimitives( if(localSlot->End()) return; } - - RAS_OpenGLRasterizer::IndexPrimitives( - vertexarrays, indexarrays, - mode, polymat, - rendertools, useObjectColor, - rgbacolor,slot - ); + + if (mUseVertexArrays) { + RAS_VAOpenGLRasterizer::IndexPrimitives( + vertexarrays, indexarrays, + mode, polymat, + rendertools, useObjectColor, + rgbacolor,slot + ); + } else { + RAS_OpenGLRasterizer::IndexPrimitives( + vertexarrays, indexarrays, + mode, polymat, + rendertools, useObjectColor, + rgbacolor,slot + ); + } if(!useObjectColor) { localSlot->EndList(); @@ -195,16 +205,53 @@ void RAS_ListRasterizer::IndexPrimitivesMulti( return; } - RAS_OpenGLRasterizer::IndexPrimitivesMulti( - vertexarrays, indexarrays, - mode, polymat, - rendertools, useObjectColor, - rgbacolor,slot - ); + if (mUseVertexArrays) { + RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( + vertexarrays, indexarrays, + mode, polymat, + rendertools, useObjectColor, + rgbacolor,slot + ); + } else { + RAS_OpenGLRasterizer::IndexPrimitivesMulti( + vertexarrays, indexarrays, + mode, polymat, + rendertools, useObjectColor, + rgbacolor,slot + ); + } + if(!useObjectColor) { localSlot->EndList(); *slot = localSlot; } } +bool RAS_ListRasterizer::Init(void) +{ + if (mUseVertexArrays) { + return RAS_VAOpenGLRasterizer::Init(); + } else { + return RAS_OpenGLRasterizer::Init(); + } +} + +void RAS_ListRasterizer::SetDrawingMode(int drawingmode) +{ + if (mUseVertexArrays) { + RAS_VAOpenGLRasterizer::SetDrawingMode(drawingmode); + } else { + RAS_OpenGLRasterizer::SetDrawingMode(drawingmode); + } +} + +void RAS_ListRasterizer::Exit() +{ + if (mUseVertexArrays) { + RAS_VAOpenGLRasterizer::Exit(); + } else { + RAS_OpenGLRasterizer::Exit(); + } +} + // eof diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h index 82840cd1399..f25f621f70c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h @@ -2,7 +2,7 @@ #define __RAS_LISTRASTERIZER_H__ #include "RAS_MaterialBucket.h" -#include "RAS_OpenGLRasterizer.h" +#include "RAS_VAOpenGLRasterizer.h" #include class RAS_ListSlot : public KX_ListSlot @@ -33,15 +33,16 @@ enum RAS_ListSlotFlags { typedef std::map RAS_Lists; -class RAS_ListRasterizer : public RAS_OpenGLRasterizer +class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer { + bool mUseVertexArrays; RAS_Lists mLists; RAS_ListSlot* FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot); void ReleaseAlloc(); public: - RAS_ListRasterizer(RAS_ICanvas* canvas); + RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays=false, bool lock=false); virtual ~RAS_ListRasterizer(); virtual void IndexPrimitives( @@ -66,6 +67,11 @@ public: class KX_ListSlot** slot ); + virtual bool Init(); + virtual void Exit(); + + virtual void SetDrawingMode(int drawingmode); + virtual bool QueryLists(){return true;} }; -- cgit v1.2.3 From 5faa2e63a1b19a4ed539364e4a4f35ba500361f5 Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Mon, 4 Feb 2008 03:48:46 +0000 Subject: bugfix 8183, Ray sensor with material/property filter always triggers when hitting object without the required characteristic fixed by Benoit Blosee(ben2610), and some minor changes for 2d-filters. --- source/gameengine/GameLogic/SCA_2DFilterActuator.cpp | 2 +- source/gameengine/GameLogic/SCA_2DFilterActuator.h | 2 +- source/gameengine/Ketsji/KX_RaySensor.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 9627ad92c4c..f3b5b1fdda2 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -31,7 +31,7 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( { } -void SCA_2DFilterActuator::SetShaderText(STR_String& text) +void SCA_2DFilterActuator::SetShaderText(STR_String text) { m_shaderText = text; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 76df95ac399..7b0cfff951e 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -33,7 +33,7 @@ public: PyTypeObject* T=&Type ); - void SetShaderText(STR_String& text); + void SetShaderText(STR_String text); virtual ~SCA_2DFilterActuator(); virtual bool Update(); diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index ef3ec3e0be3..5c56f8f62b1 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -143,7 +143,7 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_ } - return true; + return bFound; } -- cgit v1.2.3 From 43bfcd70a3039bbb8501f96e2cb6c67505919e55 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 4 Feb 2008 15:52:47 +0000 Subject: Added missing include dir so it builds again. Kent --- source/gameengine/GameLogic/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/Makefile b/source/gameengine/GameLogic/Makefile index eab4e7faa7e..aea1e463146 100644 --- a/source/gameengine/GameLogic/Makefile +++ b/source/gameengine/GameLogic/Makefile @@ -42,6 +42,7 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I../Expressions +CPPFLAGS += -I../Rasterizer CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -- cgit v1.2.3 From fd7c729bd17d8c1d8e98003d27e47a58c1c258ec Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 4 Feb 2008 21:52:03 +0000 Subject: This is patch: [#8216] Make blender compile with gcc 4.3 minus one small include file that was commented out, I'm not sure why it was commented out but I'm pretty sure its needed. If there are still problems later we can sort it out, everything else is pretty simple. Kent --- source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp index dbe875957b0..8bbac10f7ca 100644 --- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp +++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp @@ -32,6 +32,8 @@ #include "GPC_KeyboardDevice.h" +#include + /** * NextFrame toggles currentTable with previousTable, * and copies relevant event information from previous to current table -- cgit v1.2.3 From e04d7128cdbcaf05bb3e0b6127eb142e525ac377 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Tue, 5 Feb 2008 17:37:52 +0000 Subject: This is patch [#8232] Memory leak in KX_Scene destructor fixed Submitted By: Benoit Bolsee (ben2610) Fixes a loop so that it removes objects properly from the scene. Kent --- source/gameengine/Ketsji/KX_Scene.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 996c605df21..1ed429ea490 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -171,12 +171,9 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, KX_Scene::~KX_Scene() { -// int numobj = m_objectlist->GetCount(); - - //int numrootobjects = GetRootParentList()->GetCount(); - for (int i = 0; i < GetRootParentList()->GetCount(); i++) + while (GetRootParentList()->GetCount() > 0) { - KX_GameObject* parentobj = (KX_GameObject*) GetRootParentList()->GetValue(i); + KX_GameObject* parentobj = (KX_GameObject*) GetRootParentList()->GetValue(0); this->RemoveObject(parentobj); } -- cgit v1.2.3 From 33f3f852353a12a58bd2ed7c87b01754e4f4a130 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Feb 2008 21:09:38 +0000 Subject: Reverting some other changes zaghaghi made --- source/gameengine/GameLogic/SCA_ISensor.cpp | 14 ++++++++++++++ source/gameengine/GameLogic/SCA_ISensor.h | 1 + 2 files changed, 15 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 43dd6bef83e..cca303c6266 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -160,6 +160,8 @@ PyMethodDef SCA_ISensor::Methods[] = { METH_VARARGS, GetInvert_doc}, {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert, METH_VARARGS, SetInvert_doc}, + {"evaluate", (PyCFunction) SCA_ISensor::sPyEvaluate, + METH_VARARGS, Evaluate_doc}, {NULL,NULL} //Sentinel }; @@ -331,4 +333,16 @@ PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyOb Py_Return; } +char SCA_ISensor::Evaluate_doc[] = +"evaluate()\n" +"\tRe-evaluate the sensor so that isPositive() and other methods are up to date\n" +"\twith current game conditions. BGE does it automatically on each frame so it's\n" +"\tnot usually needed.\n" +"\tReturns True or False if the sensor evaluates positively or negatively\n"; +PyObject* SCA_ISensor::PyEvaluate(PyObject* self, PyObject* args, PyObject* kwds) +{ + return BoolToPyArg(Evaluate(NULL)); +} + + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index fb2dca97d06..469ea3995b8 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -122,6 +122,7 @@ public: KX_PYMETHOD_DOC(SCA_ISensor,SetUseNegPulseMode); KX_PYMETHOD_DOC(SCA_ISensor,GetInvert); KX_PYMETHOD_DOC(SCA_ISensor,SetInvert); + KX_PYMETHOD_DOC(SCA_ISensor,Evaluate); }; -- cgit v1.2.3 From 8a91b29b0f7e6a4639074a9c8632f9281a32d09c Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 10 Feb 2008 20:00:25 +0000 Subject: * make some explicit casts to make some compilers happy --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 7b895258c1e..8454cbb0a27 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -194,9 +194,9 @@ void RAS_2DFilterManager::SetupTexture() { if(texname!=-1) { - glDeleteTextures(1,&texname); + glDeleteTextures(1,(const GLuint *)&texname); } - glGenTextures(1, &texname); + glGenTextures(1, (const GLuint *)&texname); glBindTexture(GL_TEXTURE_2D, texname); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); @@ -257,7 +257,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) { if(first) { - glGetIntegerv(GL_VIEWPORT,(int*)viewport); + glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); glViewport(0, 0, texturewidth, textureheight); glDisable(GL_DEPTH_TEST); -- cgit v1.2.3 From f6dcb285600e36234637231fe75948a559c890cf Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 10 Feb 2008 20:41:59 +0000 Subject: * remove constness. --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 8454cbb0a27..d5a870a0040 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -196,7 +196,7 @@ void RAS_2DFilterManager::SetupTexture() { glDeleteTextures(1,(const GLuint *)&texname); } - glGenTextures(1, (const GLuint *)&texname); + glGenTextures(1, (GLuint *)&texname); glBindTexture(GL_TEXTURE_2D, texname); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); -- cgit v1.2.3 From bc9848f7e67c3e695403179f8bcdb78b0e5764a3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Feb 2008 13:55:22 +0000 Subject: Added a global string to be used for the tempdir. since the user preference is not loaded in background mode and the user preference is not validated and has no fallback. 'btempdir' is set with BLI_where_is_temp() - This tries to use U.tempdir but falls back to $TEMP or /tmp/ --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 23447d36401..0993446c77b 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -304,7 +304,6 @@ int main(int argc, char** argv) #endif /* __alpha__ */ #endif /* __linux__ */ BLI_where_am_i(bprogname, argv[0]); - #ifdef __APPLE__ // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) /* -- cgit v1.2.3 From 13aa413361bf75c89b7c878f7720373cf464c9d8 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 15 Feb 2008 23:12:03 +0000 Subject: patch 8235 8218 8211 added: various gameengine improvements, fixed windows project files --- source/gameengine/Converter/KX_ConvertSensors.cpp | 5 +- source/gameengine/GameLogic/SCA_ISensor.cpp | 2 - .../Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 6 ++- source/gameengine/Ketsji/KX_Camera.cpp | 16 ++++++- source/gameengine/Ketsji/KX_Camera.h | 1 + source/gameengine/Ketsji/KX_IpoActuator.cpp | 53 ++++++++++++---------- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 4 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 5 ++ source/gameengine/Ketsji/KX_PythonInit.h | 1 + source/gameengine/Ketsji/KX_RayCast.cpp | 8 ++++ source/gameengine/Ketsji/KX_Scene.cpp | 20 ++++++-- source/gameengine/Ketsji/KX_Scene.h | 14 +++++- 12 files changed, 96 insertions(+), 39 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 40c15302553..d9c49217042 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -386,8 +386,9 @@ void BL_ConvertSensors(struct Object* blenderobject, bool bFindMaterial = false; PHY_IPhysicsController* physCtrl = kxscene->GetPhysicsEnvironment()->CreateSphereController(radius,pos); - if (isInActiveLayer) - kxscene->GetPhysicsEnvironment()->addSensor(physCtrl); + //will be done in KX_TouchEventManager::RegisterSensor() + //if (isInActiveLayer) + // kxscene->GetPhysicsEnvironment()->addSensor(physCtrl); diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index cca303c6266..1a65f8311ed 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -343,6 +343,4 @@ PyObject* SCA_ISensor::PyEvaluate(PyObject* self, PyObject* args, PyObject* kwds { return BoolToPyArg(Evaluate(NULL)); } - - /* eof */ diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 86f114b2f51..51cfe30179c 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -142,7 +142,11 @@ bool KX_NetworkMessageSensor::Evaluate(CValue* event) result = (WasUp != m_IsUp); - // Return true if the message received state has changed. + // Return always true if a message was received otherwise we can loose messages + if (m_IsUp) + return true; + // Is it usefull to return also true when the first frame without a message?? + // This will cause a fast on/off cycle that seems useless! return result; } diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 011443054a7..bb8ea7f23b3 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -32,7 +32,8 @@ */ #include "KX_Camera.h" - +#include "KX_Scene.h" +#include "KX_PythonInit.h" #include "KX_Python.h" #include "KX_PyMath.h" #ifdef HAVE_CONFIG_H @@ -391,6 +392,7 @@ PyMethodDef KX_Camera::Methods[] = { KX_PYMETHODTABLE(KX_Camera, setProjectionMatrix), KX_PYMETHODTABLE(KX_Camera, enableViewport), KX_PYMETHODTABLE(KX_Camera, setViewport), + KX_PYMETHODTABLE(KX_Camera, setOnTop), {NULL,NULL} //Sentinel }; @@ -759,3 +761,15 @@ KX_PYMETHODDEF_DOC(KX_Camera, setViewport, } Py_Return; } + +KX_PYMETHODDEF_DOC(KX_Camera, setOnTop, +"setOnTop()\n" +"Sets this camera's viewport on top\n") +{ + class KX_Scene* scene; + + scene = PHY_GetActiveScene(); + MT_assert(scene); + scene->SetCameraOnTop(this); + Py_Return; +} diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index 60f0b107940..34a3d2f2653 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -251,6 +251,7 @@ public: KX_PYMETHOD_DOC(KX_Camera, enableViewport); KX_PYMETHOD_DOC(KX_Camera, setViewport); + KX_PYMETHOD_DOC(KX_Camera, setOnTop); virtual PyObject* _getattr(const STR_String& attr); /* lens, near, far, projection_matrix */ virtual int _setattr(const STR_String& attr, PyObject *pyvalue); diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index e7f1dea7bbf..287634fc7ec 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -211,12 +211,6 @@ bool KX_IpoActuator::Update(double curtime, bool frame) (*i)->Release(); } m_events.clear(); - - if (m_type != KX_ACT_IPO_PLAY) - { - if (bNegativeEvent) - RemoveAllEvents(); - } } double start_smaller_then_end = ( m_startframe < m_endframe ? 1.0 : -1.0); @@ -226,6 +220,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) { if (m_starttime < -2.0*start_smaller_then_end*(m_endframe - m_startframe)) { + // start for all Ipo, initial start for LOOP_STOP m_starttime = curtime - KX_KetsjiEngine::GetSuspendedDelta(); m_bIpoPlaying = true; } @@ -238,17 +233,10 @@ bool KX_IpoActuator::Update(double curtime, bool frame) { // Check if playing forwards. result = ! finished - if (!bNegativeEvent) - { - if (start_smaller_then_end > 0.0) - result = (m_localtime < m_endframe && !(m_localtime == m_startframe && bNegativeEvent)); - else - result = (m_localtime > m_endframe && !(m_localtime == m_startframe && bNegativeEvent)); - } + if (start_smaller_then_end > 0.0) + result = (m_localtime < m_endframe && m_bIpoPlaying); else - { - result = (m_bIpoPlaying && (m_localtime < m_endframe)); - } + result = (m_localtime > m_endframe && m_bIpoPlaying); if (result) { @@ -267,7 +255,6 @@ bool KX_IpoActuator::Update(double curtime, bool frame) } else { m_localtime=m_startframe; - SetStartTime(curtime); m_direction=1; } break; @@ -275,7 +262,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) case KX_ACT_IPO_PINGPONG: { result = true; - if (bNegativeEvent && ((m_localtime == m_startframe )|| (m_localtime == m_endframe))) + if (bNegativeEvent && !m_bIpoPlaying) result = false; else SetLocalTime(curtime); @@ -297,14 +284,18 @@ bool KX_IpoActuator::Update(double curtime, bool frame) } case KX_ACT_IPO_FLIPPER: { - result = !(bNegativeEvent && (m_localtime == m_startframe)); + if (bNegativeEvent && !m_bIpoPlaying) + result = false; if (numevents) { + float oldDirection = m_direction; if (bNegativeEvent) m_direction = -1; else m_direction = 1; - SetStartTime(curtime); + if (m_direction != oldDirection) + // changing direction, reset start time + SetStartTime(curtime); } SetLocalTime(curtime); @@ -332,18 +323,26 @@ bool KX_IpoActuator::Update(double curtime, bool frame) m_bNegativeEvent = false; numevents = 0; } - SetStartTime(curtime); + if (!m_bIpoPlaying) + { + // Ipo was stopped, make sure we will restart from where it stopped + SetStartTime(curtime); + if (!bNegativeEvent) + // positive signal will restart the Ipo + m_bIpoPlaying = true; + } + } // fall through to loopend, and quit the ipo animation immediatly } case KX_ACT_IPO_LOOPEND: { if (numevents){ - if (bNegativeEvent){ + if (bNegativeEvent && m_bIpoPlaying){ m_bNegativeEvent = true; } } - if (bNegativeEvent && m_localtime == m_startframe){ + if (bNegativeEvent && !m_bIpoPlaying){ result = false; } else @@ -414,8 +413,12 @@ bool KX_IpoActuator::Update(double curtime, bool frame) result = false; } - if (!result && m_type != KX_ACT_IPO_LOOPSTOP) - m_starttime = -2.0*start_smaller_then_end*(m_endframe - m_startframe) - 1.0; + if (!result) + { + if (m_type != KX_ACT_IPO_LOOPSTOP) + m_starttime = -2.0*start_smaller_then_end*(m_endframe - m_startframe) - 1.0; + m_bIpoPlaying = false; + } return result; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index e0a826b8d5d..8febc0e10cd 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -631,10 +631,10 @@ void KX_KetsjiEngine::Render() RenderFrame(scene, cam); } - set* cameras = scene->GetCameras(); + list* cameras = scene->GetCameras(); // Draw the scene once for each camera with an enabled viewport - set::iterator it = cameras->begin(); + list::iterator it = cameras->begin(); while(it != cameras->end()) { if((*it)->GetViewport()) diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 1a6aafafabf..58369ddcab6 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1159,3 +1159,8 @@ void PHY_SetActiveScene(class KX_Scene* scene) { gp_KetsjiScene = scene; } + +class KX_Scene* PHY_GetActiveScene() +{ + return gp_KetsjiScene; +} diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index a4c2d1453a6..edb7cfe4a3f 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -53,6 +53,7 @@ void exitGamePythonScripting(); void dictionaryClearByHand(PyObject *dict); void PHY_SetActiveScene(class KX_Scene* scene); +class KX_Scene* PHY_GetActiveScene(); #include "MT_Vector3.h" void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color); diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index 7b13cb1fd7d..ea17e0b3dd6 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -77,6 +77,14 @@ bool KX_RayCast::RayTest(KX_IPhysicsController* ignore_controller, PHY_IPhysicsE if (callback.RayHit(info, result_point, result_normal)) return true; + // There is a bug in the code below: the delta is computed with the wrong + // sign on the face opposite to the center, resulting in infinite looping. + // In Blender 2.45 this code was never executed because callback.RayHit() always + // returned true, causing the ray sensor to stop on the first object. + // To avoid changing the behaviour will simply return false here. + // It should be discussed if we want the ray sensor to "see" through objects + // that don't have the required property/material (condition to get here) + return false; // skip past the object and keep tracing /* We add 0.01 of fudge, so that if the margin && radius == 0., we don't endless loop. */ diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 1ed429ea490..f9c2f8e571b 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -263,7 +263,7 @@ SCA_TimeEventManager* KX_Scene::GetTimeEventManager() -set* KX_Scene::GetCameras() +list* KX_Scene::GetCameras() { return &m_cameras; } @@ -847,7 +847,7 @@ MT_CmMatrix4x4& KX_Scene::GetProjectionMatrix() KX_Camera* KX_Scene::FindCamera(KX_Camera* cam) { - set::iterator it = m_cameras.begin(); + list::iterator it = m_cameras.begin(); while ( (it != m_cameras.end()) && ((*it) != cam) ) { @@ -860,7 +860,7 @@ KX_Camera* KX_Scene::FindCamera(KX_Camera* cam) KX_Camera* KX_Scene::FindCamera(STR_String& name) { - set::iterator it = m_cameras.begin(); + list::iterator it = m_cameras.begin(); while ( (it != m_cameras.end()) && ((*it)->GetName() != name) ) { @@ -872,7 +872,8 @@ KX_Camera* KX_Scene::FindCamera(STR_String& name) void KX_Scene::AddCamera(KX_Camera* cam) { - m_cameras.insert(cam); + if (!FindCamera(cam)) + m_cameras.push_back(cam); } KX_Camera* KX_Scene::GetActiveCamera() @@ -893,6 +894,17 @@ void KX_Scene::SetActiveCamera(KX_Camera* cam) m_active_camera = cam; } +void KX_Scene::SetCameraOnTop(KX_Camera* cam) +{ + if (!FindCamera(cam)){ + // adding is always done at the back, so that's all that needs to be done + AddCamera(cam); + if (cam) std::cout << "Added cam " << cam->GetName() << std::endl; + } else { + m_cameras.remove(cam); + m_cameras.push_back(cam); + } +} void KX_Scene::UpdateMeshTransformations() diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index ba479c5e543..50fcf1a3c40 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -39,6 +39,7 @@ #include #include +#include #include "GEN_Map.h" #include "GEN_HashedPtr.h" @@ -119,7 +120,7 @@ protected: /** * The set of cameras for this scene */ - set m_cameras; + list m_cameras; /** * Various SCA managers used by the scene @@ -330,7 +331,7 @@ public: GetTimeEventManager( ); - set* + list* GetCameras( ); @@ -368,6 +369,15 @@ public: class KX_Camera* ); + /** + * Move this camera to the end of the list so that it is rendered last. + * If the camera is not on the list, it will be added + */ + void + SetCameraOnTop( + class KX_Camera* + ); + /** Return the viewmatrix as used by the last frame. */ MT_CmMatrix4x4& GetViewMatrix( -- cgit v1.2.3 From 012f0a336c84b22c3e20716e4820f3342afef5d3 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sat, 23 Feb 2008 12:05:28 +0000 Subject: === PyNodes === * Make PyNodes work with threaded renderer. This patch is by Willian. He has worked hard on getting this sorted out - now you should be able to render with PyNodes AND multiple threads. --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index e89c78614cc..e412fcdf748 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -135,6 +135,10 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, STR_String exitstring = ""; BlendFileData *bfd= NULL; + // Acquire Python's GIL (global interpreter lock) + // so we can safely run Python code and API calls + PyGILState_STATE gilstate = PyGILState_Ensure(); + bgl::InitExtensions(1); do @@ -464,6 +468,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); if (bfd) BLO_blendfiledata_free(bfd); + + // Release Python's GIL + PyGILState_Release(gilstate); } extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, @@ -482,6 +489,10 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, STR_String exitstring = ""; BlendFileData *bfd= NULL; + // Acquire Python's GIL (global interpreter lock) + // so we can safely run Python code and API calls + PyGILState_STATE gilstate = PyGILState_Ensure(); + bgl::InitExtensions(1); do @@ -669,4 +680,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); if (bfd) BLO_blendfiledata_free(bfd); + + // Release Python's GIL + PyGILState_Release(gilstate); } -- cgit v1.2.3 From 8d81e154f60744b49c89ef79ec2f4b0325b1effe Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Mar 2008 18:46:23 +0000 Subject: random sensor fixed (patch 8414) --- source/gameengine/GameLogic/SCA_RandomSensor.cpp | 34 +++++++++++++++--------- source/gameengine/GameLogic/SCA_RandomSensor.h | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index f747504a697..56c7ed538b8 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -54,11 +54,15 @@ SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr, : SCA_ISensor(gameobj,eventmgr, T) { m_iteration = 0; + m_interval = 0; m_lastdraw = false; + // m_basegenerator is never deleted => memory leak m_basegenerator = new SCA_RandomNumberGenerator(startseed); m_currentDraw = m_basegenerator->Draw(); - RegisterToManager(); + //registration is done globally, don't do it here + //Note: it was probably done to work around a bug in Evaluate(). It is now fixed + //RegisterToManager(); } @@ -73,6 +77,7 @@ SCA_RandomSensor::~SCA_RandomSensor() CValue* SCA_RandomSensor::GetReplica() { CValue* replica = new SCA_RandomSensor(*this); + // replication copies m_basegenerator pointer => share same generator // this will copy properties and so on... CValue::AddDataToReplica(replica); @@ -98,20 +103,25 @@ bool SCA_RandomSensor::Evaluate(CValue* event) /* this is a reasonable way of generating bools. Check Knuth. */ /* Furthermore, we only draw each -eth frame. */ - bool drawResult = false; - - if (m_iteration > 31) { - m_currentDraw = m_basegenerator->Draw(); - drawResult = (m_currentDraw & 0x1) == 0; - m_iteration = 1; - } else { - drawResult = ((m_currentDraw >> m_iteration) & 0x1) == 0; - m_iteration++; + bool evaluateResult = false; + + if (++m_interval > m_pulse_frequency) { + bool drawResult = false; + m_interval = 0; + if (m_iteration > 31) { + m_currentDraw = m_basegenerator->Draw(); + drawResult = (m_currentDraw & 0x1) == 0; + m_iteration = 1; + } else { + drawResult = ((m_currentDraw >> m_iteration) & 0x1) == 0; + m_iteration++; + } + evaluateResult = drawResult != m_lastdraw; + m_lastdraw = drawResult; } /* now pass this result to some controller */ - m_lastdraw = drawResult; - return drawResult; + return evaluateResult; } /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h index 1a3c0402e31..08bb5226be1 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.h +++ b/source/gameengine/GameLogic/SCA_RandomSensor.h @@ -45,6 +45,7 @@ class SCA_RandomSensor : public SCA_ISensor unsigned int m_currentDraw; int m_iteration; + int m_interval; SCA_RandomNumberGenerator *m_basegenerator; bool m_lastdraw; public: -- cgit v1.2.3 From 407b2d334d2facab83f847045aca45cc9ab49cde Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Mar 2008 19:05:41 +0000 Subject: unknown property fixed in sensor/actuators --- source/gameengine/GameLogic/SCA_IObject.cpp | 4 ++- source/gameengine/GameLogic/SCA_ISensor.h | 5 ++++ source/gameengine/GameLogic/SCA_PropertySensor.cpp | 34 +++++++++++++++------- source/gameengine/GameLogic/SCA_PropertySensor.h | 1 + source/gameengine/GameLogic/SCA_RandomActuator.cpp | 6 ++-- source/gameengine/Ketsji/KX_TouchSensor.cpp | 4 +-- 6 files changed, 38 insertions(+), 16 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index b1d210fd1c1..8971135ecda 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -55,7 +55,9 @@ SCA_IObject::~SCA_IObject() SCA_SensorList::iterator its; for (its = m_sensors.begin(); !(its == m_sensors.end()); ++its) { - ((CValue*)(*its))->Release(); + //Use Delete for sensor to ensure proper cleaning + (*its)->Delete(); + //((CValue*)(*its))->Release(); } SCA_ControllerList::iterator itc; for (itc = m_controllers.begin(); !(itc == m_controllers.end()); ++itc) diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 469ea3995b8..8de4480cf2e 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -97,6 +97,11 @@ public: bool negmode, int freq); + /** Release sensor + * For property sensor, it is used to release the pre-calculated expression + * so that self references are removed before the sensor itself is released + */ + virtual void Delete() { Release(); } /** Set inversion of pulses on or off. */ void SetInvert(bool inv); diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index 09332b870c9..cdd0666947e 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -66,11 +66,11 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, //CValue* resultval = m_rightexpr->Calculate(); CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); - if (orgprop) + if (!orgprop->IsError()) { m_previoustext = orgprop->GetText(); - orgprop->Release(); } + orgprop->Release(); if (m_checktype==KX_PROPSENSOR_INTERVAL) { @@ -82,16 +82,28 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, void SCA_PropertySensor::PrecalculateRangeExpression() { CParser pars; + //The context is needed to retrieve the property at runtime but it creates + //loop of references pars.SetContext(this->AddRef()); STR_String checkstr = "(" + m_checkpropval + " <= " + m_checkpropname + ") && ( " + m_checkpropname + " <= " - + m_checkpropmaxval; + + m_checkpropmaxval + ")"; m_range_expr = pars.ProcessText(checkstr); } - +// Forced deletion of precalculated range expression to break reference loop +// Use this function when you know that you won't use the sensor anymore +void SCA_PropertySensor::Delete() +{ + if (m_range_expr) + { + m_range_expr->Release(); + m_range_expr = NULL; + } + Release(); +} CValue* SCA_PropertySensor::GetReplica() { @@ -164,7 +176,7 @@ bool SCA_PropertySensor::CheckPropertyCondition() case KX_PROPSENSOR_EQUAL: { CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); - if (orgprop) + if (!orgprop->IsError()) { STR_String testprop = orgprop->GetText(); // Force strings to upper case, to avoid confusion in @@ -177,9 +189,8 @@ bool SCA_PropertySensor::CheckPropertyCondition() } else { result = (orgprop->GetText() == m_checkpropval); } - orgprop->Release(); - } + orgprop->Release(); if (reverse) result = !result; @@ -244,15 +255,15 @@ bool SCA_PropertySensor::CheckPropertyCondition() { CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); - if (orgprop) + if (!orgprop->IsError()) { if (m_previoustext != orgprop->GetText()) { m_previoustext = orgprop->GetText(); result = true; } - orgprop->Release(); } + orgprop->Release(); //cout << " \nSens:Prop:changed!"; /* need implementation here!!! */ break; @@ -388,12 +399,13 @@ PyObject* SCA_PropertySensor::PySetProperty(PyObject* self, PyObject* args, PyOb return NULL; } - if (FindIdentifier(STR_String(propNameArg))) { + CValue *prop = FindIdentifier(STR_String(propNameArg)); + if (!prop->IsError()) { m_checkpropname = propNameArg; } else { ; /* error: bad property name */ } - + prop->Release(); Py_Return; } diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index 0ebcacdb21a..77cc3dc8a5c 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -77,6 +77,7 @@ public: KX_PROPSENSOR_TYPE checktype, PyTypeObject* T=&Type ); + virtual void Delete(); virtual ~SCA_PropertySensor(); virtual CValue* GetReplica(); void PrecalculateRangeExpression(); diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 474ad08eee3..b0e69076a3e 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -61,6 +61,7 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj, m_parameter2(para2), m_distribution(mode) { + // m_base is never deleted, probably a memory leak! m_base = new SCA_RandomNumberGenerator(seed); m_counter = 0; enforceConstraints(); @@ -78,6 +79,7 @@ SCA_RandomActuator::~SCA_RandomActuator() CValue* SCA_RandomActuator::GetReplica() { SCA_RandomActuator* replica = new SCA_RandomActuator(*this); + // replication just copy the m_base pointer => common random generator replica->ProcessReplica(); CValue::AddDataToReplica(replica); @@ -432,12 +434,12 @@ PyObject* SCA_RandomActuator::PySetProperty(PyObject* self, PyObject* args, PyOb CValue* prop = GetParent()->FindIdentifier(nameArg); - if (prop) { + if (!prop->IsError()) { m_propname = nameArg; - prop->Release(); } else { ; /* not found ... */ } + prop->Release(); Py_Return; } diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 5b013e75e4e..7e3904113ab 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -274,10 +274,10 @@ PyObject* KX_TouchSensor::PySetProperty(PyObject* self, if (!prop->IsError()) { m_touchedpropname = nameArg; - prop->Release(); } else { ; /* not found ... */ } + prop->Release(); Py_Return; } @@ -351,8 +351,8 @@ PyObject* KX_TouchSensor::PyGetHitObjectList(PyObject* self, CValue* val = m_colliders->GetValue(i)->FindIdentifier(m_touchedpropname); if (!val->IsError()) { newList->Add(m_colliders->GetValue(i)->AddRef()); - val->Release(); } + val->Release(); } i++; -- cgit v1.2.3 From 3cf5b1d6fb87f0eac94893dbe8b9fff688eac54e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Mar 2008 19:17:37 +0000 Subject: Radar/Near sensor performance problem fixed --- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 4 +- source/gameengine/Ketsji/KX_NearSensor.cpp | 47 +++++++-- source/gameengine/Ketsji/KX_NearSensor.h | 1 + source/gameengine/Ketsji/KX_TouchEventManager.cpp | 21 ++++ source/gameengine/Ketsji/KX_TouchEventManager.h | 7 +- source/gameengine/Ketsji/KX_TouchSensor.h | 8 +- .../Physics/Bullet/CcdPhysicsController.cpp | 16 ++- .../Physics/Bullet/CcdPhysicsController.h | 18 ++-- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 114 ++++++++++++++++++--- .../Physics/Bullet/CcdPhysicsEnvironment.h | 20 +++- .../Physics/Sumo/SumoPhysicsEnvironment.cpp | 2 + .../gameengine/Physics/common/PHY_DynamicTypes.h | 4 +- .../Physics/common/PHY_IPhysicsController.h | 1 - .../Physics/common/PHY_IPhysicsEnvironment.h | 1 + 14 files changed, 221 insertions(+), 43 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 6ea13f3a5e3..5de2ab1b2dc 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1123,7 +1123,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_angularDamping = 1.f - shapeprops->m_ang_drag; //need a bit of damping, else system doesn't behave well ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour - + ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter); + ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); + KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); if (objprop->m_in_active_layer) diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 34561045cab..8f85a889d21 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -191,7 +191,36 @@ bool KX_NearSensor::Evaluate(CValue* event) return result; } +// this function is called at broad phase stage to check if the two controller +// need to interact at all. It is used for Near/Radar sensor that don't need to +// check collision with object not included in filter +bool KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2) +{ + KX_GameObject* parent = static_cast(GetParent()); + + // need the mapping from PHY_IPhysicsController to gameobjects now + assert(obj1==m_physCtrl && obj2); + KX_ClientObjectInfo* client_info = static_cast((static_cast(obj2))->getNewClientInfo()); + KX_GameObject* gameobj = ( client_info ? + client_info->m_gameobject : + NULL); + + if (gameobj && (gameobj != parent)) + { + // only take valid colliders + if (client_info->m_type == KX_ClientObjectInfo::ACTOR) + { + if ((m_touchedpropname.Length() == 0) || + (gameobj->GetProperty(m_touchedpropname))) + { + return true; + } + } + } + + return false; +} bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData * coll_data) { @@ -208,20 +237,22 @@ bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData client_info->m_gameobject : NULL); - if (gameobj && (gameobj != parent)) + // these checks are done already in BroadPhaseFilterCollision() + if (gameobj /*&& (gameobj != parent)*/) { if (!m_colliders->SearchValue(gameobj)) m_colliders->Add(gameobj->AddRef()); // only take valid colliders - if (client_info->m_type == KX_ClientObjectInfo::ACTOR) - { - if ((m_touchedpropname.Length() == 0) || - (gameobj->GetProperty(m_touchedpropname))) - { + // These checks are done already in BroadPhaseFilterCollision() + //if (client_info->m_type == KX_ClientObjectInfo::ACTOR) + //{ + // if ((m_touchedpropname.Length() == 0) || + // (gameobj->GetProperty(m_touchedpropname))) + // { m_bTriggered = true; m_hitObject = gameobj; - } - } + // } + //} } return DT_CONTINUE; diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index d1b8984b91b..599d6cce918 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -77,6 +77,7 @@ public: virtual void ReParent(SCA_IObject* parent); virtual bool NewHandleCollision(void* obj1,void* obj2, const PHY_CollData * coll_data); + virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2); virtual void RegisterSumo(KX_TouchEventManager *touchman); virtual PyObject* _getattr(const STR_String& attr); diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index 4c999b0ed69..8e546b896bc 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -54,6 +54,7 @@ KX_TouchEventManager::KX_TouchEventManager(class SCA_LogicManager* logicmgr, m_physEnv->addTouchCallback(PHY_OBJECT_RESPONSE, KX_TouchEventManager::newCollisionResponse, this); m_physEnv->addTouchCallback(PHY_SENSOR_RESPONSE, KX_TouchEventManager::newCollisionResponse, this); + m_physEnv->addTouchCallback(PHY_BROADPH_RESPONSE, KX_TouchEventManager::newBroadphaseResponse, this); } @@ -79,6 +80,26 @@ bool KX_TouchEventManager::newCollisionResponse(void *client_data, return false; } +bool KX_TouchEventManager::newBroadphaseResponse(void *client_data, + void *object1, + void *object2, + const PHY_CollData *coll_data) +{ + PHY_IPhysicsController* ctrl = static_cast(object1); + KX_ClientObjectInfo* info = (ctrl) ? static_cast(ctrl->getNewClientInfo()) : NULL; + // This call back should only be called for controllers of Near and Radar sensor + if (info && + info->m_sensors.size() == 1 && + (info->m_type == KX_ClientObjectInfo::NEAR || + info->m_type == KX_ClientObjectInfo::RADAR)) + { + // only one sensor for this type of object + KX_TouchSensor* touchsensor = static_cast(*info->m_sensors.begin()); + return touchsensor->BroadPhaseFilterCollision(object1,object2); + } + return true; +} + void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor) { KX_TouchSensor* touchsensor = static_cast(sensor); diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h index 21faceef799..73b868278db 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.h +++ b/source/gameengine/Ketsji/KX_TouchEventManager.h @@ -56,7 +56,12 @@ class KX_TouchEventManager : public SCA_EventManager void *object1, void *object2, const PHY_CollData *coll_data); - + + static bool newBroadphaseResponse(void *client_data, + void *object1, + void *object2, + const PHY_CollData *coll_data); + virtual bool NewHandleCollision(void* obj1,void* obj2, const PHY_CollData * coll_data); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index f1a2a26e822..9781bdb3769 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -57,8 +57,6 @@ protected: class SCA_EventManager* m_eventmgr; class PHY_IPhysicsController* m_physCtrl; - class PHY_ResponseTable* m_responstTable; - class PHY_PhysicsController* m_responsObject; bool m_bCollision; bool m_bTriggered; @@ -86,7 +84,11 @@ public: virtual bool NewHandleCollision(void*obj1,void*obj2,const PHY_CollData* colldata); - PHY_PhysicsController* GetPhysicsController() { return m_responsObject;} + // Allows to do pre-filtering and save computation time + // obj1 = sensor physical controller, obj2 = physical controller of second object + // return value = true if collision should be checked on pair of object + virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2) { return true; } + virtual bool IsPositiveTrigger() { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 5a45ce020cc..963dda10873 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -36,6 +36,7 @@ float gAngularSleepingTreshold = 1.0f; btVector3 startVel(0,0,0);//-10000); + CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) :m_cci(ci) { @@ -119,17 +120,20 @@ void CcdPhysicsController::CreateRigidbody() m_cci.m_linearDamping,m_cci.m_angularDamping, m_cci.m_friction,m_cci.m_restitution); - - // // init the rigidbody properly // //setMassProps this also sets collisionFlags //convert collision flags! - + //special case: a near/radar sensor controller should not be defined static or it will + //generate loads of static-static collision messages on the console + if ((m_cci.m_collisionFilterGroup & CcdConstructionInfo::SensorFilter) != 0) + { + // reset the flags that have been set so far + m_body->setCollisionFlags(0); + } m_body->setCollisionFlags(m_body->getCollisionFlags() | m_cci.m_collisionFlags); - m_body->setGravity( m_cci.m_gravity); m_body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping); @@ -141,12 +145,14 @@ CcdPhysicsController::~CcdPhysicsController() if (m_cci.m_physicsEnv) m_cci.m_physicsEnv->removeCcdPhysicsController(this); - delete m_MotionState; + if (m_MotionState) + delete m_MotionState; if (m_bulletMotionState) delete m_bulletMotionState; delete m_body; } + /** SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding') */ diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 11fef56401f..54b4bcc40ee 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -46,7 +46,8 @@ struct CcdConstructionInfo StaticFilter = 2, KinematicFilter = 4, DebrisFilter = 8, - AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter, + SensorFilter = 16, + AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter, }; @@ -61,6 +62,7 @@ struct CcdConstructionInfo m_collisionFlags(0), m_collisionFilterGroup(DefaultFilter), m_collisionFilterMask(AllFilter), + m_collisionShape(0), m_MotionState(0), m_physicsEnv(0), m_inertiaFactor(1.f) @@ -85,9 +87,8 @@ struct CcdConstructionInfo short int m_collisionFilterGroup; short int m_collisionFilterMask; - - btCollisionShape* m_collisionShape; - class PHY_IMotionState* m_MotionState; + class btCollisionShape* m_collisionShape; + class PHY_IMotionState* m_MotionState; CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication float m_inertiaFactor;//tweak the inertia (hooked up to Blender 'formfactor' @@ -96,11 +97,12 @@ struct CcdConstructionInfo class btRigidBody; + ///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution. class CcdPhysicsController : public PHY_IPhysicsController { btRigidBody* m_body; - class PHY_IMotionState* m_MotionState; + class PHY_IMotionState* m_MotionState; btMotionState* m_bulletMotionState; @@ -215,7 +217,11 @@ class CcdPhysicsController : public PHY_IPhysicsController return m_MotionState; } - + class CcdPhysicsEnvironment* GetPhysicsEnvironment() + { + return m_cci.m_physicsEnv; + } + }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 99c3e5f77c7..25defbd5587 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -251,6 +251,22 @@ public: }; #endif //NEW_BULLET_VEHICLE_SUPPORT +class CcdOverlapFilterCallBack : public btOverlapFilterCallback +{ +private: + class CcdPhysicsEnvironment* m_physEnv; +public: + CcdOverlapFilterCallBack(CcdPhysicsEnvironment* env) : + m_physEnv(env) + { + } + virtual ~CcdOverlapFilterCallBack() + { + } + // return true when pairs need collision + virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const; +}; + void CcdPhysicsEnvironment::setDebugDrawer(btIDebugDraw* debugDrawer) { @@ -302,7 +318,11 @@ m_numTimeSubSteps(1), m_ccdMode(0), m_solverType(-1), m_profileTimings(0), -m_enableSatCollisionDetection(false) +m_enableSatCollisionDetection(false), +m_solver(NULL), +m_ownPairCache(NULL), +m_ownDispatcher(NULL), +m_filterCallback(NULL) { for (int i=0;isetOverlapFilterCallback(m_filterCallback); setSolverType(1);//issues with quickstep and memory allocations - - m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,new btSequentialImpulseConstraintSolver()); + m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,m_solver); m_debugDrawer = 0; m_gravity = btVector3(0.f,-10.f,0.f); m_dynamicsWorld->setGravity(m_gravity); @@ -346,7 +370,8 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) body->setGravity( m_gravity ); m_controllers.push_back(ctrl); - m_dynamicsWorld->addRigidBody(body); + //use explicit group/filter for finer control over collision in bullet => near/radar sensor + m_dynamicsWorld->addRigidBody(body, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask()); if (body->isStaticOrKinematicObject()) { body->setActivationState(ISLAND_SLEEPING); @@ -778,7 +803,20 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment() delete m_dynamicsWorld; + if (NULL != m_ownPairCache) + delete m_ownPairCache; + + if (NULL != m_ownDispatcher) + delete m_ownDispatcher; + + if (NULL != m_solver) + delete m_solver; + + if (NULL != m_debugDrawer) + delete m_debugDrawer; + if (NULL != m_filterCallback) + delete m_filterCallback; } @@ -841,9 +879,10 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl) { addCcdPhysicsController(ctrl1); } + //Collision filter/mask is now set at the time of the creation of the controller //force collision detection with everything, including static objects (might hurt performance!) - ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask = btBroadphaseProxy::AllFilter; - ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterGroup = btBroadphaseProxy::AllFilter; + //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask = btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::SensorTrigger; + //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterGroup = btBroadphaseProxy::SensorTrigger; //todo: make this 'sensor'! requestCollisionCallback(ctrl); @@ -962,9 +1001,47 @@ void CcdPhysicsEnvironment::CallbackTriggers() } - - - +// This call back is called before a pair is added in the cache +// Handy to remove objects that must be ignored by sensors +bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const +{ + btCollisionObject *colObj0, *colObj1; + CcdPhysicsController *sensorCtrl, *objCtrl; + bool collides; + // first check the filters + collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0; + collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask); + if (!collides) + return false; + + // additional check for sensor object + if (proxy0->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger) + { + // this is a sensor object, the other one can't be a sensor object because + // they exclude each other in the above test + assert(!(proxy1->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger)); + colObj0 = (btCollisionObject*)proxy0->m_clientObject; + colObj1 = (btCollisionObject*)proxy1->m_clientObject; + } + else if (proxy1->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger) + { + colObj0 = (btCollisionObject*)proxy1->m_clientObject; + colObj1 = (btCollisionObject*)proxy0->m_clientObject; + } + else + { + return true; + } + if (!colObj0 || !colObj1) + return false; + sensorCtrl = static_cast(colObj0->getUserPointer()); + objCtrl = static_cast(colObj1->getUserPointer()); + if (m_physEnv->m_triggerCallbacks[PHY_BROADPH_RESPONSE]) + { + return m_physEnv->m_triggerCallbacks[PHY_BROADPH_RESPONSE](m_physEnv->m_triggerCallbacksUserPtrs[PHY_BROADPH_RESPONSE], sensorCtrl, objCtrl, 0); + } + return true; +} #ifdef NEW_BULLET_VEHICLE_SUPPORT @@ -998,12 +1075,19 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi { CcdConstructionInfo cinfo; + // memory leak! The shape is not deleted by Bullet and we cannot add it to the KX_Scene.m_shapes list cinfo.m_collisionShape = new btSphereShape(radius); cinfo.m_MotionState = 0; cinfo.m_physicsEnv = this; - cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_KINEMATIC_OBJECT; + // declare this object as Dyamic rather then static!! + // The reason as it is designed to detect all type of object, including static object + // It would cause static-static message to be printed on the console otherwise + cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE/* | btCollisionObject::CF_KINEMATIC_OBJECT*/; DefaultMotionState* motionState = new DefaultMotionState(); cinfo.m_MotionState = motionState; + // we will add later the possibility to select the filter from option + cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter; + cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter; motionState->m_worldTransform.setIdentity(); motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2])); @@ -1275,12 +1359,18 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float coneradius,float coneheight) { CcdConstructionInfo cinfo; + //This is a memory leak: Bullet does not delete the shape and it cannot be added to + //the KX_Scene.m_shapes list -- too bad but that's not a lot of data cinfo.m_collisionShape = new btConeShape(coneradius,coneheight); cinfo.m_MotionState = 0; cinfo.m_physicsEnv = this; cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE; DefaultMotionState* motionState = new DefaultMotionState(); cinfo.m_MotionState = motionState; + + // we will add later the possibility to select the filter from option + cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter; + cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter; motionState->m_worldTransform.setIdentity(); // motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2])); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 66a6ed59c17..6d17c9af20a 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -42,6 +42,7 @@ class btBroadphaseInterface; class btOverlappingPairCache; class btIDebugDraw; class PHY_IVehicle; +class CcdOverlapFilterCallBack; /// CcdPhysicsEnvironment is an experimental mainloop for physics simulation using optional continuous collision detection. /// Physics Environment takes care of stepping the simulation and is a container for physics entities. @@ -49,9 +50,8 @@ class PHY_IVehicle; /// A derived class may be able to 'construct' entities by loading and/or converting class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment { + friend CcdOverlapFilterCallBack; btVector3 m_gravity; - - protected: btIDebugDraw* m_debugDrawer; @@ -166,7 +166,7 @@ protected: virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user); virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl); virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl); - + //These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position); virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight); @@ -229,10 +229,22 @@ protected: std::vector m_wrapperVehicles; - class btDynamicsWorld* m_dynamicsWorld; + //use explicit btDiscreteDynamicsWorld* so that we have access to + //btDiscreteDynamicsWorld::addRigidBody(body,filter,group) + //so that we can set the body collision filter/group at the time of creation + //and not afterwards (breaks the collision system for radar/near sensor) + //Ideally we would like to have access to this function from the btDynamicsWorld interface + //class btDynamicsWorld* m_dynamicsWorld; + class btDiscreteDynamicsWorld* m_dynamicsWorld; class btConstraintSolver* m_solver; + class btOverlappingPairCache* m_ownPairCache; + + class CcdOverlapFilterCallBack* m_filterCallback; + + class btDispatcher* m_ownDispatcher; + bool m_scalingPropagated; diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp index 6cdf1d41dc1..67a74d11564 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp @@ -206,6 +206,8 @@ void SumoPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCa case PHY_STATIC_RESPONSE: sumoRespClass = PHY_STATIC_RESPONSE; break; + case PHY_BROADPH_RESPONSE: + return; default: assert(0); return; diff --git a/source/gameengine/Physics/common/PHY_DynamicTypes.h b/source/gameengine/Physics/common/PHY_DynamicTypes.h index 68b60192fbc..c289b9d8bcb 100644 --- a/source/gameengine/Physics/common/PHY_DynamicTypes.h +++ b/source/gameengine/Physics/common/PHY_DynamicTypes.h @@ -19,7 +19,6 @@ subject to the following restrictions: -class PHY_ResponseTable; class PHY_Shape; @@ -40,10 +39,11 @@ struct PHY__Vector3 typedef enum { PHY_FH_RESPONSE, - PHY_SENSOR_RESPONSE, /* Touch Sensors */ + PHY_SENSOR_RESPONSE, /* Touch Sensors */ PHY_CAMERA_RESPONSE, /* Visibility Culling */ PHY_OBJECT_RESPONSE, /* Object Dynamic Geometry Response */ PHY_STATIC_RESPONSE, /* Static Geometry Response */ + PHY_BROADPH_RESPONSE, /* broadphase Response */ PHY_NUM_RESPONSE }; diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h index 931dc0e988c..ba1fb8473d3 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsController.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h @@ -85,7 +85,6 @@ class PHY_IPhysicsController // dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted virtual void setRigidBody(bool rigid)=0; - // clientinfo for raycasts for example virtual void* getNewClientInfo()=0; virtual void setNewClientInfo(void* clientinfo)=0; diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index 5e4fd681914..d90b3d82e6b 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -107,6 +107,7 @@ class PHY_IPhysicsEnvironment virtual void removeSensor(PHY_IPhysicsController* ctrl)=0; virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0; virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl)=0; + //These two methods are *solely* used to create controllers for sensor! Don't use for anything else virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) =0; virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0; -- cgit v1.2.3 From 44314581dc934dc99c9504edf671118a9f988b68 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Mar 2008 19:29:01 +0000 Subject: Mem leak fixed in sound buffer & parent invert node --- source/gameengine/SceneGraph/SG_IObject.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp index 232ceb06958..4787847da0d 100644 --- a/source/gameengine/SceneGraph/SG_IObject.cpp +++ b/source/gameengine/SceneGraph/SG_IObject.cpp @@ -128,6 +128,11 @@ ActivateDestructionCallback( // Call client provided destruction function on this! m_callbacks.m_destructionfunc(this,m_SGclientObject,m_SGclientInfo); } + else + { + // no callback but must still destroy the node to avoid memory leak + delete this; + } } void -- cgit v1.2.3 From 0db0f5734d358676b11eccc702cf02adb3174b7e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Mar 2008 19:46:50 +0000 Subject: Various mem leaks related to CValue reference count fixed --- .../Converter/BL_BlenderDataConversion.cpp | 29 ++++++-- .../gameengine/Converter/KX_ConvertActuators.cpp | 2 + .../gameengine/Converter/KX_ConvertControllers.cpp | 2 + .../gameengine/Converter/KX_ConvertProperties.cpp | 7 +- source/gameengine/Converter/KX_ConvertSensors.cpp | 2 + source/gameengine/Expressions/Expression.cpp | 4 +- source/gameengine/Expressions/Value.cpp | 86 +++++++++++++++++----- source/gameengine/GameLogic/SCA_IObject.cpp | 3 + source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 3 + source/gameengine/GameLogic/SCA_LogicManager.cpp | 9 ++- .../gameengine/GameLogic/SCA_PropertyActuator.cpp | 10 ++- source/gameengine/Ketsji/KX_Camera.cpp | 4 +- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 20 +++-- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 2 + .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 2 + source/gameengine/Ketsji/KX_Scene.cpp | 75 ++++++++++++++++--- source/gameengine/Ketsji/KX_Scene.h | 13 +++- 17 files changed, 224 insertions(+), 49 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index fde54025fc7..271385bb144 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1514,7 +1514,8 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, default: break; } - + delete shapeprops; + delete smmaterial; } @@ -1599,7 +1600,8 @@ static KX_GameObject *gameobject_from_blenderobject( KX_Camera* gamecamera = gamecamera_from_bcamera(static_cast(ob->data), kxscene, converter); gameobj = gamecamera; - gamecamera->AddRef(); + //don't add a reference: the camera list in kxscene->m_cameras is not released at the end + //gamecamera->AddRef(); kxscene->AddCamera(gamecamera); break; @@ -1845,6 +1847,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, vector vec_parent_child; CListValue* objectlist = kxscene->GetObjectList(); + CListValue* inactivelist = kxscene->GetInactiveList(); CListValue* parentlist = kxscene->GetRootParentList(); SCA_LogicManager* logicmgr = kxscene->GetLogicManager(); @@ -1852,7 +1855,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, CListValue* logicbrick_conversionlist = new CListValue(); - SG_TreeFactory tf; + //SG_TreeFactory tf; // Convert actions to actionmap bAction *curAct; @@ -1990,19 +1993,35 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (isInActiveLayer) { objectlist->Add(gameobj->AddRef()); - tf.Add(gameobj->GetSGNode()); + //tf.Add(gameobj->GetSGNode()); gameobj->NodeUpdateGS(0,true); gameobj->Bucketize(); } + else + { + //we must store this object otherwise it will be deleted + //at the end of this function if it is not a root object + inactivelist->Add(gameobj->AddRef()); + } if (converter->addInitFromFrame){ gameobj->NodeSetLocalPosition(posPrev); gameobj->NodeSetLocalOrientation(angor); } } - + /* Note about memory leak issues: + When a CValue derived class is created, m_refcount is initialized to 1 + so the class must be released after being used to make sure that it won't + hang in memory. If the object needs to be stored for a long time, + use AddRef() so that this Release() does not free the object. + Make sure that for any AddRef() there is a Release()!!!! + Do the same for any object derived from CValue, CExpression and NG_NetworkMessage + */ + if (gameobj) + gameobj->Release(); + base = base->next; } diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 89a07abe21d..f76a0fb82e5 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -934,6 +934,8 @@ void BL_ConvertActuators(char* maggiename, gameobj->AddActuator(baseact); converter->RegisterGameActuator(baseact, bact); + // done with baseact, release it + baseact->Release(); } bact = bact->next; diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 5b30f5a4a2e..b277af7dbc2 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -174,6 +174,8 @@ void BL_ConvertControllers( gameobj->AddController(gamecontroller); converter->RegisterGameController(gamecontroller, bcontr); + //done with gamecontroller + gamecontroller->Release(); } bcontr = bcontr->next; diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index a1807732416..ebfb45066b7 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -105,8 +105,9 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan // set a subproperty called 'timer' so that // we can register the replica of this property // at the time a game object is replicated (AddObjectActuator triggers this) - - timeval->SetProperty("timer",new CBoolValue(true)); + CValue *bval = new CBoolValue(true); + timeval->SetProperty("timer",bval); + bval->Release(); if (isInActiveLayer) { timemgr->AddTimeProperty(timeval); @@ -128,6 +129,8 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan { scene->AddDebugProperty(gameobj,STR_String(prop->name)); } + // done with propval, release it + propval->Release(); } prop = prop->next; diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index d9c49217042..61759ddf654 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -733,6 +733,8 @@ void BL_ConvertSensors(struct Object* blenderobject, logicmgr->RegisterToSensor(gamecont,gamesensor); } } + // done with gamesensor + gamesensor->Release(); } sens=sens->next; diff --git a/source/gameengine/Expressions/Expression.cpp b/source/gameengine/Expressions/Expression.cpp index 5c5e1abea34..f16f572c322 100644 --- a/source/gameengine/Expressions/Expression.cpp +++ b/source/gameengine/Expressions/Expression.cpp @@ -22,7 +22,9 @@ ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// - +#ifdef _DEBUG +//int gRefCountExpr; +#endif CExpression::CExpression()// : m_cached_calculate(NULL) { m_refcount = 1; diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 48898dfc1f5..56208ab4ad5 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -169,7 +169,28 @@ PyObject* CValue::PyGetName(PyObject* self,PyObject* args,PyObject* kwds) return pyname; } +/*#define CVALUE_DEBUG*/ +#ifdef CVALUE_DEBUG +int gRefCount; +struct SmartCValueRef +{ + CValue *m_ref; + int m_count; + SmartCValueRef(CValue *ref) + { + m_ref = ref; + m_count = gRefCount++; + } +}; +#include + +std::vector gRefList; +#endif + +#ifdef _DEBUG +//int gRefCountValue; +#endif CValue::CValue(PyTypeObject *T) : PyObjectPlus(T), @@ -186,6 +207,12 @@ effect: constucts a CValue */ { //debug(gRefCountValue++) // debugging +#ifdef _DEBUG + //gRefCountValue++; +#ifdef CVALUE_DEBUG + gRefList.push_back(SmartCValueRef(this)); +#endif +#endif } @@ -199,6 +226,18 @@ effect: deletes the object ClearProperties(); assertd (m_refcount==0); +#ifdef CVALUE_DEBUG + std::vector::iterator it; + for (it=gRefList.begin(); it!=gRefList.end(); it++) + { + if (it->m_ref == this) + { + *it = gRefList.back(); + gRefList.pop_back(); + break; + } + } +#endif } @@ -293,7 +332,7 @@ void CValue::SetProperty(const STR_String & name,CValue* ioProperty) } // Add property at end of array - (*m_pNamedPropertyArray)[name] = ioProperty;//->Add(ioProperty); + (*m_pNamedPropertyArray)[name] = ioProperty->AddRef();//->Add(ioProperty); } @@ -356,10 +395,13 @@ bool CValue::RemoveProperty(const STR_String & inName) if (m_pNamedPropertyArray == NULL) return false; - // Scan all properties, as soon as we find one with -> Remove it -// CValue* val = (*m_pNamedPropertyArray)[inName]; - if (m_pNamedPropertyArray->erase(inName)) return true; - + CValue* val = GetProperty(inName); + if (NULL != val) + { + val->Release(); + m_pNamedPropertyArray->erase(inName); + return true; + } return false; } @@ -379,7 +421,7 @@ void CValue::ClearProperties() !(it == m_pNamedPropertyArray->end());it++) { CValue* tmpval = (*it).second; - STR_String name = (*it).first; + //STR_String name = (*it).first; tmpval->Release(); } @@ -469,8 +511,9 @@ void CValue::CloneProperties(CValue *replica) for ( std::map::iterator it = m_pNamedPropertyArray->begin(); !(it == m_pNamedPropertyArray->end());it++) { - - replica->SetProperty((*it).first,(*it).second->GetReplica()); + CValue *val = (*it).second->GetReplica(); + replica->SetProperty((*it).first,val); + val->Release(); } } @@ -489,10 +532,6 @@ double* CValue::GetVector3(bool bGetTransformedVec) } - - - - /*--------------------------------------------------------------------------------------------------------------------- Reference Counting ---------------------------------------------------------------------------------------------------------------------*/ @@ -504,6 +543,9 @@ CValue *CValue::AddRef() // Increase global reference count, used to see at the end of the program // if all CValue-derived classes have been dereferenced to 0 //debug(gRefCountValue++); +#ifdef _DEBUG + //gRefCountValue++; +#endif m_refcount++; return this; } @@ -518,7 +560,9 @@ int CValue::Release() // Decrease global reference count, used to see at the end of the program // if all CValue-derived classes have been dereferenced to 0 //debug(gRefCountValue--); - +#ifdef _DEBUG + //gRefCountValue--; +#endif // Decrease local reference count, if it reaches 0 the object should be freed if (--m_refcount > 0) { @@ -546,6 +590,9 @@ void CValue::DisableRefCount() m_refcount--; //debug(gRefCountValue--); +#ifdef _DEBUG + //gRefCountValue--; +#endif m_ValFlags.RefCountDisabled=true; } @@ -590,11 +637,14 @@ CValue* CValue::FindIdentifier(const STR_String& identifiername) } else { result = GetProperty(identifiername); + if (result) + return result->AddRef(); + } + if (!result) + { + // warning here !!! + result = new CErrorValue(identifiername+" not found"); } - if (result) - return result->AddRef(); - // warning here !!! - result = new CErrorValue(identifiername+" not found"); return result; } @@ -717,7 +767,7 @@ int CValue::_setattr(const STR_String& attr,PyObject* pyobj) oldprop->SetValue(vallie); } else { - SetProperty(attr,vallie->AddRef()); + SetProperty(attr,vallie); } vallie->Release(); } diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 8971135ecda..fae1b5dfa6b 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -101,6 +101,7 @@ SCA_ActuatorList& SCA_IObject::GetActuators() void SCA_IObject::AddSensor(SCA_ISensor* act) { + act->AddRef(); m_sensors.push_back(act); } @@ -108,6 +109,7 @@ void SCA_IObject::AddSensor(SCA_ISensor* act) void SCA_IObject::AddController(SCA_IController* act) { + act->AddRef(); m_controllers.push_back(act); } @@ -115,6 +117,7 @@ void SCA_IObject::AddController(SCA_IController* act) void SCA_IObject::AddActuator(SCA_IActuator* act) { + act->AddRef(); m_actuators.push_back(act); } diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index fb8c340b09e..4898dbed95f 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -212,6 +212,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex) newprop.SetLength(oldlength - 1); CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); GetParent()->SetProperty(m_targetprop, newstringprop); + newstringprop->Release(); } } else { /* append */ @@ -219,6 +220,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex) STR_String newprop = tprop->GetText() + pchar; CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); GetParent()->SetProperty(m_targetprop, newstringprop); + newstringprop->Release(); } } else { if (!IsDelete(keyIndex)) { @@ -227,6 +229,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex) STR_String newprop = pchar; CStringValue * newstringprop = new CStringValue(newprop, m_targetprop); GetParent()->SetProperty(m_targetprop, newstringprop); + newstringprop->Release(); } } } diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 8b79703a6fc..048d6992c73 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -51,6 +51,10 @@ SCA_LogicManager::SCA_LogicManager() SCA_LogicManager::~SCA_LogicManager() { + /* AddRef() is not used when the objects are added to m_mapStringToGameObjects + so Release() should not be used either. The memory leak big is fixed + in BL_ConvertBlenderObjects() + int numgameobj = m_mapStringToGameObjects.size(); for (int i = 0; i < numgameobj; i++) { @@ -58,8 +62,9 @@ SCA_LogicManager::~SCA_LogicManager() assert(gameobjptr); if (gameobjptr) (*gameobjptr)->Release(); - + } + */ /*for (int i=0;i* controllerarray = *(m_sensorcontrollermap[i]); @@ -72,6 +77,8 @@ SCA_LogicManager::~SCA_LogicManager() } m_eventmanagers.clear(); m_sensorcontrollermapje.clear(); + m_removedActuators.clear(); + m_activeActuators.clear(); } diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index c3e2066fc65..c798503ae8a 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -90,12 +90,11 @@ bool SCA_PropertyActuator::Update() if (oldprop) { oldprop->SetValue(newval); - newval->Release(); } else { propowner->SetProperty(m_propname,newval); } - + newval->Release(); break; } case KX_ACT_PROP_ADD: @@ -123,9 +122,11 @@ bool SCA_PropertyActuator::Update() CValue* copyprop = m_sourceObj->GetProperty(m_exprtxt); if (copyprop) { + CValue *val = copyprop->GetReplica(); GetParent()->SetProperty( m_propname, - copyprop->GetReplica()); + val); + val->Release(); } } @@ -239,11 +240,12 @@ PyObject* SCA_PropertyActuator::PySetProperty(PyObject* self, PyObject* args, Py CValue* prop = GetParent()->FindIdentifier(nameArg); - if (prop) { + if (!prop->IsError()) { m_propname = nameArg; } else { ; /* not found ... */ } + prop->Release(); Py_Return; } diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index bb8ea7f23b3..b75662f01c9 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -58,7 +58,9 @@ KX_Camera::KX_Camera(void* sgReplicationInfo, m_name = "cam"; m_projection_matrix.setIdentity(); m_modelview_matrix.setIdentity(); - SetProperty("camera",new CIntValue(1)); + CValue* val = new CIntValue(1); + SetProperty("camera",val); + val->Release(); } diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 5de2ab1b2dc..7b2c514db8a 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -858,6 +858,8 @@ static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool //concaveShape = new btTriangleMeshShape( collisionMeshData ); concaveShape->recalcLocalAabb(); + if (collisionMeshShape) + delete collisionMeshShape; collisionMeshShape = concaveShape; } @@ -866,8 +868,10 @@ static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool return collisionMeshShape; } - - delete collisionMeshShape; + if (collisionMeshShape) + delete collisionMeshShape; + if (collisionMeshData) + delete collisionMeshData; return NULL; } @@ -1021,7 +1025,10 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, // ci.m_localInertiaTensor.setValue(0.1f,0.1f,0.1f); if (!bm) + { + delete motionstate; return; + } bm->setMargin(0.06); @@ -1057,6 +1064,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, compoundShape->addChildShape(childTrans,bm); + kxscene->AddShape(bm); //do some recalc? //recalc inertia for rigidbody if (!rigidbody->isStaticOrKinematicObject()) @@ -1076,6 +1084,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, btTransform identTrans; identTrans.setIdentity(); compoundShape->addChildShape(identTrans,bm); + //note abount compoundShape: Bullet does not delete the child shapes when + //the compound shape is deleted, so insert also the child shapes + kxscene->AddShape(bm); bm = compoundShape; } @@ -1112,9 +1123,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_collisionShape = bm; - - - ci.m_friction = smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice ci.m_restitution = smmaterial->m_restitution; ci.m_physicsEnv = env; @@ -1127,6 +1135,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); + //remember that we created a shape so that we can delete it when the scene is removed (bullet will not delete it) + kxscene->AddShape(bm); if (objprop->m_in_active_layer) { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 8febc0e10cd..9e5efad803b 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1047,6 +1047,8 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene) scene->SetActiveCamera(activecam); scene->GetObjectList()->Add(activecam->AddRef()); scene->GetRootParentList()->Add(activecam->AddRef()); + //done with activecam + activecam->Release(); } scene->UpdateParents(0.0); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 45b2db10b33..7366e374a10 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -326,6 +326,8 @@ void KX_SCA_AddObjectActuator::InstantAddObject() m_lastCreatedObject = replica; m_lastCreatedObject->AddRef(); + // finished using replica? then release it + replica->Release(); } } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index f9c2f8e571b..f9fc503f406 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -35,6 +35,7 @@ #pragma warning (disable : 4786) #endif //WIN32 + #include "KX_Scene.h" #include "MT_assert.h" @@ -78,6 +79,13 @@ #include "BL_SkinDeformer.h" #include "BL_DeformableGameObject.h" +// to get USE_BULLET! +#include "KX_ConvertPhysicsObject.h" + +#ifdef USE_BULLET +#include "CcdPhysicsEnvironment.h" +#include "CcdPhysicsController.h" +#endif void* KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene) { @@ -124,6 +132,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_objectlist = new CListValue(); m_parentlist = new CListValue(); m_lightlist= new CListValue(); + m_inactivelist = new CListValue(); m_euthanasyobjects = new CListValue(); m_delayReleaseObjects = new CListValue(); @@ -183,6 +192,9 @@ KX_Scene::~KX_Scene() if (m_parentlist) m_parentlist->Release(); + if (m_inactivelist) + m_inactivelist->Release(); + if (m_lightlist) m_lightlist->Release(); @@ -210,11 +222,38 @@ KX_Scene::~KX_Scene() { delete m_bucketmanager; } - +#ifdef USE_BULLET + // This is a fix for memory leaks in bullet: the collision shapes is not destroyed + // when the physical controllers are destroyed. The reason is that shapes are shared + // between replicas of an object. There is no reference count in Bullet so the + // only workaround that does not involve changes in Bullet is to save in this array + // the list of shapes that are created when the scene is created (see KX_ConvertPhysicsObjects.cpp) + class btCollisionShape* shape; + class btTriangleMeshShape* meshShape; + vector::iterator it = m_shapes.begin(); + while (it != m_shapes.end()) { + shape = *it; + if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) + { + meshShape = static_cast(shape); + // shapes based on meshes use an interface that contains the vertices. + // Again the idea is to be able to share the interface between shapes but + // this is not used in Blender: each base object will have its own interface + btStridingMeshInterface* meshInterface = meshShape->getMeshInterface(); + if (meshInterface) + delete meshInterface; + } + delete shape; + it++; + } +#endif //Py_DECREF(m_attrlist); } - +void KX_Scene::AddShape(class btCollisionShape*shape) +{ + m_shapes.push_back(shape); +} void KX_Scene::SetProjectionMatrix(MT_CmMatrix4x4& pmat) @@ -243,6 +282,11 @@ CListValue* KX_Scene::GetRootParentList() return m_parentlist; } +CListValue* KX_Scene::GetInactiveList() +{ + return m_inactivelist; +} + CListValue* KX_Scene::GetLightList() @@ -415,7 +459,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal replicanode->SetSGClientObject(newobj); // this is the list of object that are send to the graphics pipeline - m_objectlist->Add(newobj); + m_objectlist->Add(newobj->AddRef()); newobj->Bucketize(); // logic cannot be replicated, until the whole hierarchy is replicated. @@ -571,7 +615,9 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, // add a timebomb to this object // for now, convert between so called frames and realtime m_tempObjectList->Add(replica->AddRef()); - replica->SetProperty("::timebomb",new CFloatValue(lifespan*0.02)); + CValue *fval = new CFloatValue(lifespan*0.02); + replica->SetProperty("::timebomb",fval); + fval->Release(); } // add to 'rootparent' list (this is the list of top hierarchy objects, updated each frame) @@ -634,7 +680,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, replica->GetSGNode()->UpdateWorldData(0); replica->GetSGNode()->SetBBox(originalobj->GetSGNode()->BBox()); replica->GetSGNode()->SetRadius(originalobj->GetSGNode()->Radius()); - + // don't release replica here because we are returning it, not done with it... return replica; } @@ -654,7 +700,8 @@ void KX_Scene::RemoveObject(class CValue* gameobj) // recursively destruct node->Destruct(); } - newobj->SetSGNode(0); + //no need to do that: the object is destroyed and memory released + //newobj->SetSGNode(0); } void KX_Scene::DelayedReleaseObject(CValue* gameobj) @@ -704,6 +751,7 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj) { m_logicmgr->RemoveDestroyedActuator(*ita); } + // the sensors/controllers/actuators must also be released, this is done in ~SCA_IObject // now remove the timer properties from the time manager int numprops = newobj->GetPropertyCount(); @@ -724,12 +772,15 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj) newobj->Release(); if (m_parentlist->RemoveValue(newobj)) newobj->Release(); + if (m_inactivelist->RemoveValue(newobj)) + newobj->Release(); if (m_euthanasyobjects->RemoveValue(newobj)) newobj->Release(); if (newobj == m_active_camera) { - m_active_camera->Release(); + //no AddRef done on m_active_camera so no Release + //m_active_camera->Release(); m_active_camera = NULL; } } @@ -1108,6 +1159,8 @@ void KX_Scene::LogicEndFrame() for (i = numobj - 1; i >= 0; i--) { KX_GameObject* gameobj = (KX_GameObject*)m_euthanasyobjects->GetValue(i); + // KX_Scene::RemoveObject will also remove the object from this list + // that's why we start from the end this->RemoveObject(gameobj); } @@ -1115,11 +1168,11 @@ void KX_Scene::LogicEndFrame() for (i = numobj-1;i>=0;i--) { KX_GameObject* gameobj = (KX_GameObject*)m_delayReleaseObjects->GetValue(i); - m_delayReleaseObjects->RemoveValue(gameobj); - + // This list is not for object removal, but just object release + gameobj->Release(); } - - + // empty the list as we have removed all references + m_delayReleaseObjects->Resize(0); } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 50fcf1a3c40..b857f4f591e 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -85,6 +85,7 @@ class RAS_IPolyMaterial; class RAS_IRasterizer; class RAS_IRenderTools; class SCA_JoystickManager; +class btCollisionShape; /** * The KX_Scene holds all data for an independent scene. It relates * KX_Objects to the specific objects in the modules. @@ -111,6 +112,7 @@ protected: CListValue* m_objectlist; CListValue* m_parentlist; // all 'root' parents CListValue* m_lightlist; + CListValue* m_inactivelist; // all objects that are not in the active layer /** * The tree of objects in the scene. @@ -121,7 +123,11 @@ protected: * The set of cameras for this scene */ list m_cameras; - + /** + * The set of bullet shapes that must be deleted at the end of the scene + * to avoid memory leak (not deleted by bullet because shape are shared between replicas) + */ + vector m_shapes; /** * Various SCA managers used by the scene */ @@ -300,6 +306,7 @@ public: void NewRemoveObject(CValue* gameobj); void ReplaceMesh(CValue* gameobj, void* meshobj); + void AddShape(class btCollisionShape* shape); /** * @section Logic stuff * Initiate an update of the logic system. @@ -313,6 +320,10 @@ public: CListValue* GetObjectList( + ); + + CListValue* + GetInactiveList( ); CListValue* -- cgit v1.2.3 From cc2b922d012ec2d11566882d4afe9cf2104ad0bc Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 2 Mar 2008 09:39:14 +0000 Subject: * to be able to properly compile this, the friend needs 'class' too: friend class CcdOverlapFilterCallBack --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 6d17c9af20a..9f14cf6cbef 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -50,7 +50,7 @@ class CcdOverlapFilterCallBack; /// A derived class may be able to 'construct' entities by loading and/or converting class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment { - friend CcdOverlapFilterCallBack; + friend class CcdOverlapFilterCallBack; btVector3 m_gravity; protected: -- cgit v1.2.3 From ce7a21047f50c0e26ce55134ba434543c247d894 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 9 Mar 2008 21:37:01 +0000 Subject: BGE memleak fixed: game actuator does not release file buffer --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index e412fcdf748..0e0d8982527 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -105,11 +105,16 @@ static BlendFileData *load_game_data(char *filename) { fseek(file, 0L, SEEK_SET); char* filebuffer= new char[len];//MEM_mallocN(len, "text_buffer"); int sizeread = fread(filebuffer,len,1,file); - if (sizeread==1) - { + if (sizeread==1){ bfd = BLO_read_from_memory(filebuffer, len, &error); + } else { + error = BRE_UNABLE_TO_READ; } fclose(file); + // the memory is not released in BLO_read_from_memory, must do it here + delete filebuffer; + } else { + error = BRE_UNABLE_TO_OPEN; } if (!bfd) { @@ -348,7 +353,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, initGameKeys(); initPythonConstraintBinding(); - + if (sceneconverter) { // convert and add scene -- cgit v1.2.3 From 822e51bd2d663f82d360d474192718660cc9a35c Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 9 Mar 2008 21:42:03 +0000 Subject: BGE memleak fixed: mesh/material not deleted when switching scene --- .../Converter/KX_BlenderSceneConverter.cpp | 112 ++++++++++++++++++--- .../Converter/KX_BlenderSceneConverter.h | 14 ++- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 22 ---- source/gameengine/Ketsji/KX_ISceneConverter.h | 2 + source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 6 +- source/gameengine/Ketsji/KX_Scene.cpp | 11 +- source/gameengine/Ketsji/KX_Scene.h | 7 +- 7 files changed, 128 insertions(+), 46 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 804241ac9b9..7fbec8679fb 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -123,29 +123,29 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter() delete (ipoList); } - vector::iterator itw = m_worldinfos.begin(); + vector >::iterator itw = m_worldinfos.begin(); while (itw != m_worldinfos.end()) { - delete (*itw); + delete (*itw).second; itw++; } - vector::iterator itp = m_polymaterials.begin(); + vector >::iterator itp = m_polymaterials.begin(); while (itp != m_polymaterials.end()) { - delete (*itp); + delete (*itp).second; itp++; } // delete after RAS_IPolyMaterial - vector::iterator itmat = m_materials.begin(); + vector >::iterator itmat = m_materials.begin(); while (itmat != m_materials.end()) { - delete (*itmat); + delete (*itmat).second; itmat++; } - vector::iterator itm = m_meshobjects.begin(); + vector >::iterator itm = m_meshobjects.begin(); while (itm != m_meshobjects.end()) { - delete (*itm); + delete (*itm).second; itm++; } @@ -263,6 +263,9 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename, Scene *blenderscene = GetSceneForName2(m_maggie, scenename); e_PhysicsEngine physics_engine = UseBullet; + // hook for registration function during conversion. + m_currentScene = destinationscene; + destinationscene->SetSceneConverter(this); if (blenderscene) { @@ -360,16 +363,90 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename, m_alwaysUseExpandFraming ); + //These lookup are not needed during game m_map_blender_to_gameactuator.clear(); m_map_blender_to_gamecontroller.clear(); - m_map_blender_to_gameobject.clear(); - m_map_mesh_to_gamemesh.clear(); - //don't clear it yet, it is needed for the baking physics into ipo animation + //Clearing this lookup table has the effect of disabling the cache of meshes + //between scenes, even if they are shared in the blend file. + //This cache mecanism is buggy so I leave it disable and the memory leak + //that would result from this is fixed in RemoveScene() + m_map_mesh_to_gamemesh.clear(); + //Don't clear this lookup, it is needed for the baking physics into ipo animation + //To avoid it's infinite grows, object will be unregister when they are deleted + //see KX_Scene::NewRemoveObject //m_map_gameobject_to_blender.clear(); } +// This function removes all entities stored in the converter for that scene +// It should be used instead of direct delete scene +// Note that there was some provision for sharing entities (meshes...) between +// scenes but that is now disabled so all scene will have their own copy +// and we can delete them here. If the sharing is reactivated, change this code too.. +// (see KX_BlenderSceneConverter::ConvertScene) +void KX_BlenderSceneConverter::RemoveScene(KX_Scene *scene) +{ + int i, size; + // delete the scene first as it will stop the use of entities + delete scene; + // delete the entities of this scene + vector >::iterator worldit; + size = m_worldinfos.size(); + for (i=0, worldit=m_worldinfos.begin(); i >::iterator polymit; + size = m_polymaterials.size(); + for (i=0, polymit=m_polymaterials.begin(); i >::iterator matit; + size = m_materials.size(); + for (i=0, matit=m_materials.begin(); i >::iterator meshit; + size = m_meshobjects.size(); + for (i=0, meshit=m_meshobjects.begin(); i(m_currentScene,mat)); } @@ -406,6 +483,11 @@ void KX_BlenderSceneConverter::RegisterGameObject( m_map_blender_to_gameobject.insert(CHashedPtr(for_blenderobject),gameobject); } +void KX_BlenderSceneConverter::UnregisterGameObject( + KX_GameObject *gameobject) +{ + m_map_gameobject_to_blender.remove(CHashedPtr(gameobject)); +} KX_GameObject *KX_BlenderSceneConverter::FindGameObject( @@ -433,7 +515,7 @@ void KX_BlenderSceneConverter::RegisterGameMesh( struct Mesh *for_blendermesh) { m_map_mesh_to_gamemesh.insert(CHashedPtr(for_blendermesh),gamemesh); - m_meshobjects.push_back(gamemesh); + m_meshobjects.push_back(pair(m_currentScene,gamemesh)); } @@ -458,7 +540,7 @@ RAS_MeshObject *KX_BlenderSceneConverter::FindGameMesh( void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat) { - m_polymaterials.push_back(polymat); + m_polymaterials.push_back(pair(m_currentScene,polymat)); } @@ -523,7 +605,7 @@ SCA_IController *KX_BlenderSceneConverter::FindGameController( void KX_BlenderSceneConverter::RegisterWorldInfo( KX_WorldInfo *worldinfo) { - m_worldinfos.push_back(worldinfo); + m_worldinfos.push_back(pair(m_currentScene,worldinfo)); } /* diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index a897922d51b..8ac5386d442 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -51,10 +51,13 @@ struct SpaceIpo; class KX_BlenderSceneConverter : public KX_ISceneConverter { - vector m_worldinfos; - vector m_polymaterials; - vector m_meshobjects; - vector m_materials; + // Use vector of pairs to allow removal of entities between scene switch + vector > m_worldinfos; + vector > m_polymaterials; + vector > m_meshobjects; + vector > m_materials; + // Should also have a list of collision shapes. + // For the time being this is held in KX_Scene::m_shapes GEN_Map m_map_gameobject_to_blender; GEN_Map m_map_blender_to_gameobject; @@ -72,6 +75,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter STR_String m_newfilename; class KX_KetsjiEngine* m_ketsjiEngine; + class KX_Scene* m_currentScene; // Scene being converted bool m_alwaysUseExpandFraming; bool m_usemat; @@ -99,6 +103,7 @@ public: class RAS_IRenderTools* rendertools, class RAS_ICanvas* canvas ); + virtual void RemoveScene(class KX_Scene *scene); void SetNewFileName(const STR_String& filename); bool TryAndLoadNewFile(); @@ -106,6 +111,7 @@ public: void SetAlwaysUseExpandFraming(bool to_what); void RegisterGameObject(KX_GameObject *gameobject, struct Object *for_blenderobject); + void UnregisterGameObject(KX_GameObject *gameobject); KX_GameObject *FindGameObject(struct Object *for_blenderobject); struct Object *FindBlenderObject(KX_GameObject *for_gameobject); diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 7b2c514db8a..465a021cd43 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -682,8 +682,6 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, #endif //WIN32 -static GEN_Map map_gamemesh_to_bulletshape; - // forward declarations static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool polytope) { @@ -701,14 +699,6 @@ static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool int numPoints = 0; btVector3* points = 0; - btCollisionShape** shapeptr = map_gamemesh_to_bulletshape[GEN_HashedPtr(meshobj)]; - - // Mesh has already been converted: reuse - if (shapeptr) - { - //return *shapeptr; - } - // Mesh has no polygons! int numpolys = meshobj->NumPolygons(); if (!numpolys) @@ -850,7 +840,6 @@ static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool if (numvalidpolys > 0) { - //map_gamemesh_to_bulletshape.insert(GEN_HashedPtr(meshobj),collisionMeshShape); if (!polytope) { bool useQuantization = true; @@ -1200,17 +1189,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, void KX_ClearBulletSharedShapes() { - int numshapes = map_gamemesh_to_bulletshape.size(); - int i; - btCollisionShape*shape=0; - for (i=0;iRemoveScene(scene); } m_scenes.clear(); @@ -1217,7 +1217,7 @@ void KX_KetsjiEngine::RemoveScheduledScenes() KX_Scene* scene = *sceneit; if (scene->GetName()==scenename) { - delete scene; + m_sceneconverter->RemoveScene(scene); m_scenes.erase(sceneit); break; } @@ -1315,7 +1315,7 @@ void KX_KetsjiEngine::ReplaceScheduledScenes() KX_Scene* scene = *sceneit; if (scene->GetName() == oldscenename) { - delete scene; + m_sceneconverter->RemoveScene(scene); KX_Scene* tmpscene = CreateScene(newscenename); m_scenes[i]=tmpscene; PostProcessScene(tmpscene); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index f9fc503f406..633b57ef209 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -75,6 +75,7 @@ #include "NG_NetworkScene.h" #include "PHY_IPhysicsEnvironment.h" #include "KX_IPhysicsController.h" +#include "KX_BlenderSceneConverter.h" #include "BL_SkinDeformer.h" #include "BL_DeformableGameObject.h" @@ -120,7 +121,8 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_adi(adi), m_networkDeviceInterface(ndi), m_active_camera(NULL), - m_ueberExecutionPriority(0) + m_ueberExecutionPriority(0), + m_sceneConverter(NULL) { m_suspendedtime = 0.0; m_suspendeddelta = 0.0; @@ -783,6 +785,8 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj) //m_active_camera->Release(); m_active_camera = NULL; } + if (m_sceneConverter) + m_sceneConverter->UnregisterGameObject(newobj); } @@ -1277,6 +1281,11 @@ void KX_Scene::SetNodeTree(SG_Tree* root) m_objecttree = root; } +void KX_Scene::SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter) +{ + m_sceneConverter = sceneConverter; +} + void KX_Scene::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv) { m_physicsEnvironment = physEnv; diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index b857f4f591e..4c3b1d2e558 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -86,6 +86,7 @@ class RAS_IRasterizer; class RAS_IRenderTools; class SCA_JoystickManager; class btCollisionShape; +class KX_BlenderSceneConverter; /** * The KX_Scene holds all data for an independent scene. It relates * KX_Objects to the specific objects in the modules. @@ -136,10 +137,12 @@ protected: SCA_MouseManager* m_mousemgr; SCA_TimeEventManager* m_timemgr; + // Scene converter where many scene entities are registered + // Used to deregister objects that are deleted + class KX_BlenderSceneConverter* m_sceneConverter; /** * physics engine abstraction */ - //e_PhysicsEngine m_physicsEngine; //who needs this ? class PHY_IPhysicsEnvironment* m_physicsEnvironment; @@ -517,6 +520,8 @@ public: bool IsClearingZBuffer(); void EnableZBufferClearing(bool isclearingZbuffer); + void SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter); + class PHY_IPhysicsEnvironment* GetPhysicsEnvironment() { return m_physicsEnvironment; -- cgit v1.2.3 From 52293831b26f34547acf100603c87296deba7a60 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 9 Mar 2008 21:51:38 +0000 Subject: BGE fix: game object to controller links consistancy maintained regardless of order of deletion AddObject actuator forces last created object to hang in memory even after object is removed from scene => bad link between object and physic controller that causes Blender to crash in case a python script tries to use it (bad programming anyway). This patch avoids the crash by maintaining consistent links at all time. --- .../Ketsji/KX_BulletPhysicsController.cpp | 14 ++++++++++- source/gameengine/Ketsji/KX_GameObject.cpp | 14 ++++++++++- source/gameengine/Ketsji/KX_Scene.cpp | 27 +++++++++++++++------- source/gameengine/Ketsji/KX_Scene.h | 2 +- 4 files changed, 46 insertions(+), 11 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index aa5d1f1cec1..aa7c75e9633 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -24,7 +24,18 @@ CcdPhysicsController(ci) KX_BulletPhysicsController::~KX_BulletPhysicsController () { - + // The game object has a direct link to + if (m_pObject) + { + // If we cheat in SetObject, we must also cheat here otherwise the + // object will still things it has a physical controller + // Note that it requires that m_pObject is reset in case the object is deleted + // before the controller (usual case, see KX_Scene::RemoveNodeDestructObjec) + // The non usual case is when the object is not deleted because its reference is hanging + // in a AddObject actuator but the node is deleted. This case is covered here. + KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject(); + gameobj->SetPhysicsController(NULL,false); + } } void KX_BulletPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) @@ -58,6 +69,7 @@ void KX_BulletPhysicsController::SetObject (SG_IObject* object) } + void KX_BulletPhysicsController::setMargin (float collisionMargin) { CcdPhysicsController::SetMargin(collisionMargin); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 67c82ee2082..bc608d26c50 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -105,7 +105,19 @@ KX_GameObject::~KX_GameObject() delete m_pClient_info; //if (m_pSGNode) // delete m_pSGNode; - + if (m_pSGNode) + { + // must go through controllers and make sure they will not use us anymore + // This is important for KX_BulletPhysicsControllers that unregister themselves + // from the object when they are deleted. + SGControllerList::iterator contit; + SGControllerList& controllers = m_pSGNode->GetSGControllerList(); + for (contit = controllers.begin();contit!=controllers.end();++contit) + { + (*contit)->ClearObject(); + } + m_pSGNode->SetSGClientObject(NULL); + } } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 633b57ef209..526f893df5a 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -410,8 +410,15 @@ void KX_Scene::EnableZBufferClearing(bool isclearingZbuffer) void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gameobj) { KX_GameObject* orgobj = (KX_GameObject*)gameobj; - NewRemoveObject(orgobj); - + if (NewRemoveObject(orgobj) != 0) + { + // object is not yet deleted (this can happen when it hangs in an add object actuator + // last object created reference. It's a bad situation, don't know how to fix it exactly + // The least I can do, is remove the reference to the node in the object as the node + // will in any case be deleted. This ensures that the object will not try to use the node + // when it is finally deleted (see KX_GameObject destructor) + orgobj->SetSGNode(NULL); + } if (node) delete node; } @@ -723,8 +730,9 @@ void KX_Scene::DelayedRemoveObject(class CValue* gameobj) -void KX_Scene::NewRemoveObject(class CValue* gameobj) +int KX_Scene::NewRemoveObject(class CValue* gameobj) { + int ret; KX_GameObject* newobj = (KX_GameObject*) gameobj; //todo: look at this @@ -768,16 +776,17 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj) } newobj->RemoveMeshes(); + ret = 1; if (m_objectlist->RemoveValue(newobj)) - newobj->Release(); + ret = newobj->Release(); if (m_tempObjectList->RemoveValue(newobj)) - newobj->Release(); + ret = newobj->Release(); if (m_parentlist->RemoveValue(newobj)) - newobj->Release(); + ret = newobj->Release(); if (m_inactivelist->RemoveValue(newobj)) - newobj->Release(); + ret = newobj->Release(); if (m_euthanasyobjects->RemoveValue(newobj)) - newobj->Release(); + ret = newobj->Release(); if (newobj == m_active_camera) { @@ -787,6 +796,8 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj) } if (m_sceneConverter) m_sceneConverter->UnregisterGameObject(newobj); + // return value will be 0 if the object is actually deleted (all reference gone) + return ret; } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 4c3b1d2e558..58120d49dc4 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -306,7 +306,7 @@ public: void DelayedReleaseObject(CValue* gameobj); - void NewRemoveObject(CValue* gameobj); + int NewRemoveObject(CValue* gameobj); void ReplaceMesh(CValue* gameobj, void* meshobj); void AddShape(class btCollisionShape* shape); -- cgit v1.2.3 From 1f0ae739cb952165488f13499f141ac3d20378e0 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 9 Mar 2008 22:02:32 +0000 Subject: BGE memleak fix: OpenGL Display Lists not deleted when switching scene This fix also improves performance of Display List for replica objects: Display List ID caching is now enabled for replica objects which avoids a tree search on each frame and for each replica. --- .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 5 +++ source/gameengine/Rasterizer/RAS_MaterialBucket.h | 19 +++++++--- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 2 ++ .../RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp | 42 ++++++++++++++++++---- .../RAS_OpenGLRasterizer/RAS_ListRasterizer.h | 6 +++- 5 files changed, 63 insertions(+), 11 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 689772f51c4..757784be87f 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -69,6 +69,11 @@ bool KX_MeshSlot::Less(const KX_MeshSlot& lhs) const return result; } +KX_MeshSlot::~KX_MeshSlot() +{ + if (m_DisplayList) + m_DisplayList->Release(); +} RAS_MaterialBucket::RAS_MaterialBucket(RAS_IPolyMaterial* mat) diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index 7d875242c2e..ded6af999c4 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -69,10 +69,21 @@ public: */ class KX_ListSlot { +protected: + int m_refcount; public: - KX_ListSlot(){} - virtual ~KX_ListSlot(){} - + KX_ListSlot(){ m_refcount=1; } + virtual ~KX_ListSlot() {} + virtual int Release() { + if (--m_refcount > 0) + return m_refcount; + delete this; + return 0; + } + virtual KX_ListSlot* AddRef() { + m_refcount++; + return this; + } virtual void SetModified(bool mod)=0; }; @@ -96,7 +107,7 @@ public: m_DisplayList(0) { } - ~KX_MeshSlot(){} + ~KX_MeshSlot(); bool Less(const KX_MeshSlot& lhs) const; }; diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 4219b641b5c..b7147ea6c42 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -474,7 +474,9 @@ void RAS_MeshObject::ClearArrayData() { KX_ArrayOptimizer** ao = m_matVertexArrayS.at(i); if (ao) + { delete *ao; + } } } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index 7baa6c49656..afa98fdb274 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -25,13 +25,23 @@ #define spit(x) //#endif -RAS_ListSlot::RAS_ListSlot() +RAS_ListSlot::RAS_ListSlot(RAS_ListRasterizer* rasty) : KX_ListSlot(), m_flag(LIST_MODIFY|LIST_CREATE), - m_list(0) + m_list(0), + m_rasty(rasty) { } +int RAS_ListSlot::Release() +{ + if (--m_refcount > 0) + return m_refcount; + m_rasty->RemoveListSlot(this); + delete this; + return 0; +} + RAS_ListSlot::~RAS_ListSlot() { RemoveList(); @@ -108,6 +118,18 @@ RAS_ListRasterizer::~RAS_ListRasterizer() ReleaseAlloc(); } +void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list) +{ + RAS_Lists::iterator it = mLists.begin(); + while(it != mLists.end()) { + if (it->second == list) { + mLists.erase(it); + break; + } + it++; + } +} + RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot) { /* @@ -120,10 +142,10 @@ RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(const vecVertexArray& vertexarrays, if(!localSlot) { RAS_Lists::iterator it = mLists.find(vertexarrays); if(it == mLists.end()) { - localSlot = new RAS_ListSlot(); + localSlot = new RAS_ListSlot(this); mLists.insert(std::pair(vertexarrays, localSlot)); } else { - localSlot = it->second; + localSlot = static_cast(it->second->AddRef()); } } MT_assert(localSlot); @@ -157,8 +179,12 @@ void RAS_ListRasterizer::IndexPrimitives( if(!useObjectColor) { localSlot = FindOrAdd(vertexarrays, slot); localSlot->DrawList(); - if(localSlot->End()) + if(localSlot->End()) { + // save slot here too, needed for replicas and object using same mesh + // => they have the same vertexarray but different mesh slot + *slot = localSlot; return; + } } if (mUseVertexArrays) { @@ -201,8 +227,12 @@ void RAS_ListRasterizer::IndexPrimitivesMulti( localSlot = FindOrAdd(vertexarrays, slot); localSlot->DrawList(); - if(localSlot->End()) + if(localSlot->End()) { + // save slot here too, needed for replicas and object using same mesh + // => they have the same vertexarray but different mesh slot + *slot = localSlot; return; + } } if (mUseVertexArrays) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h index f25f621f70c..4b3304d7396 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h @@ -5,14 +5,17 @@ #include "RAS_VAOpenGLRasterizer.h" #include +class RAS_ListRasterizer; class RAS_ListSlot : public KX_ListSlot { unsigned int m_list; unsigned int m_flag; + RAS_ListRasterizer* m_rasty; public: - RAS_ListSlot(); + RAS_ListSlot(RAS_ListRasterizer* rasty); virtual ~RAS_ListSlot(); virtual void SetModified(bool mod); + virtual int Release(); void RemoveList(); void DrawList(); @@ -42,6 +45,7 @@ class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer void ReleaseAlloc(); public: + void RemoveListSlot(RAS_ListSlot* list); RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays=false, bool lock=false); virtual ~RAS_ListRasterizer(); -- cgit v1.2.3 From b1ef25663a2d33a6ff558920ff1dbdd386409b9d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 10 Mar 2008 21:30:35 +0000 Subject: BGE crash when using angV & linV actuator on static objects The error was causing by the KINEMATIC flag not set automatically when the linear or angular velocity was set on static objects. Note that these actuators still won't work on static objects: the crash is fixed but not the actuator; linV and angV only work on dynamic objects. Fixing the linV and angV actuators on static object requires a bit more reflexion. For the time being, use dRot and dLoc on static objects. Cleaned the code a bit: added systematic check on the physic controller presence before taking action. --- .../Physics/Bullet/CcdPhysicsController.cpp | 126 ++++++++++++--------- 1 file changed, 74 insertions(+), 52 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 963dda10873..fe9aa4419e4 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -282,7 +282,7 @@ void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dloc void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) { - if (m_body ) + if (m_body) { m_body->activate(true); if (m_body->isStaticObject()) @@ -326,33 +326,39 @@ void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,flo } void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal) { - m_body->activate(true); - if (m_body->isStaticObject()) + if (m_body) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); - } + m_body->activate(true); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } - m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); - btTransform xform = m_body->getCenterOfMassTransform(); - xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal)); - m_body->setCenterOfMassTransform(xform); - m_bulletMotionState->setWorldTransform(xform); + m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); + btTransform xform = m_body->getCenterOfMassTransform(); + xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal)); + m_body->setCenterOfMassTransform(xform); + m_bulletMotionState->setWorldTransform(xform); + } } void CcdPhysicsController::setPosition(float posX,float posY,float posZ) { - m_body->activate(true); - if (m_body->isStaticObject()) + if (m_body) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_body->activate(true); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } + + m_MotionState->setWorldPosition(posX,posY,posZ); + btTransform xform = m_body->getCenterOfMassTransform(); + xform.setOrigin(btVector3(posX,posY,posZ)); + m_body->setCenterOfMassTransform(xform); + m_bulletMotionState->setWorldTransform(xform); } - - m_MotionState->setWorldPosition(posX,posY,posZ); - btTransform xform = m_body->getCenterOfMassTransform(); - xform.setOrigin(btVector3(posX,posY,posZ)); - m_body->setCenterOfMassTransform(xform); - m_bulletMotionState->setWorldTransform(xform); } @@ -396,49 +402,59 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque { btVector3 torque(torqueX,torqueY,torqueZ); btTransform xform = m_body->getCenterOfMassTransform(); - if (torque.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_body && torque.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_body->activate(); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } + if (local) + { + torque = xform.getBasis()*torque; + } + m_body->applyTorque(torque); } - if (local) - { - torque = xform.getBasis()*torque; - } - m_body->applyTorque(torque); } void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local) { btVector3 force(forceX,forceY,forceZ); - if (force.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_body && force.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_body->activate(); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } + { + btTransform xform = m_body->getCenterOfMassTransform(); + if (local) + { + force = xform.getBasis()*force; + } + } + m_body->applyCentralForce(force); } - - - btTransform xform = m_body->getCenterOfMassTransform(); - if (local) - { - force = xform.getBasis()*force; - } - m_body->applyCentralForce(force); } void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local) { btVector3 angvel(ang_velX,ang_velY,ang_velZ); - if (angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_body && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_body->activate(true); - } - - { - btTransform xform = m_body->getCenterOfMassTransform(); - if (local) + if (m_body->isStaticObject()) { - angvel = xform.getBasis()*angvel; + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } + { + btTransform xform = m_body->getCenterOfMassTransform(); + if (local) + { + angvel = xform.getBasis()*angvel; + } } - m_body->setAngularVelocity(angvel); } @@ -447,16 +463,20 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa { btVector3 linVel(lin_velX,lin_velY,lin_velZ); - if (linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_body && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_body->activate(true); - } - - { - btTransform xform = m_body->getCenterOfMassTransform(); - if (local) + if (m_body->isStaticObject()) { - linVel = xform.getBasis()*linVel; + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } + + { + btTransform xform = m_body->getCenterOfMassTransform(); + if (local) + { + linVel = xform.getBasis()*linVel; + } } m_body->setLinearVelocity(linVel); } @@ -465,14 +485,16 @@ void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac { btVector3 impulse(impulseX,impulseY,impulseZ); - if (impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_body && impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { m_body->activate(); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } btVector3 pos(attachX,attachY,attachZ); - m_body->activate(); - m_body->applyImpulse(impulse,pos); } -- cgit v1.2.3 From 3444d6612a525b879857c60d49165efb01f77529 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 12 Mar 2008 21:33:24 +0000 Subject: Delta Loc/Rot/Scale Ipo curve are now supporting in the BGE with the following limitations: 1. All Ipo channels are now independent. In Blender 2.45, all 3 Loc Ipo channels were automatically set together. For example, having just a LocX Ipo channel was sufficient to fix the X, Y and Z coordinates, with the Y and Z value taken from the object original Y and Z location in Blender. The same was true for the 3 Rot and the 3 Scale Ipo channels: the missing channels were assumed to have constant value taken from the object original orientation/scale in Blender. With this patch, all Ipo channels are now independent. THIS WILL CREATE BACKWARD COMPATIBILITY PROBLEM if you omit to define the 3 channels of a same type together in your Blend file: the undefined Loc, Rot, Scale coordinates of the object will be influenced by the parent/spawner Loc/Rot/Scale in case the object is a child or dynamically created. 2. Delta Loc, Rot, Scale are now supported with the following limitations: - The delta Loc/Rot Ipo modify the object global (NOT local) location/orientation - The delta Scale change the object local scale - The delta Ipo curves are relative to the object starting Loc/Rot/Scale when the Ipo was first activated; after that, the delta Ipo becomes global. This means that the object will return to this initial Loc/Rot/Scale when you later restart the Ipo curve, even if you had changed the object Loc/Rot/Scale in the meantime. Of course this applies only to the specific Loc/Rot/Scale coordinate that are defined in the Ipo channels as the channels are now independent. 3. When the objects are converted from Blender to the BGE, the delta Loc/Rot/Scale that might result from initial non-zero values in delta Ipo Curves will be ignored. However, as soon as the delta Ipo curve is activated, the non-zero values will be taken into account and the object will jump to the same Loc/Rot/Scale situation as in Blender. Note that delta Ipo curves with initial non-zero values is bad practice; logically, a delta Ipo curver should always start from 0. 4. If you define both a global and delta channel of the same type (LocX and DLocX), the result will be a global channel equivalent to the sum of the two channels (LocX+DLocX). --- source/gameengine/Converter/KX_IpoConvert.cpp | 42 +++---- source/gameengine/Ketsji/KX_IPO_SGController.cpp | 134 ++++++++++++++++++++--- source/gameengine/Ketsji/KX_IPO_SGController.h | 36 +++--- 3 files changed, 160 insertions(+), 52 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index defcdffb6fc..2cf29e9dd62 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -100,9 +100,9 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend ipocontr->GetIPOTransform().SetPosition( MT_Point3( - blenderobject->loc[0]+blenderobject->dloc[0], - blenderobject->loc[1]+blenderobject->dloc[1], - blenderobject->loc[2]+blenderobject->dloc[2] + blenderobject->loc[0]/*+blenderobject->dloc[0]*/, + blenderobject->loc[1]/*+blenderobject->dloc[1]*/, + blenderobject->loc[2]/*+blenderobject->dloc[2]*/ ) ); ipocontr->GetIPOTransform().SetEulerAngles( @@ -134,7 +134,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetPosition()[0]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyPosition(true); + ipocontr->SetIPOChannelActive(OB_LOC_X, true); } @@ -145,7 +145,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetPosition()[1]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyPosition(true); + ipocontr->SetIPOChannelActive(OB_LOC_Y, true); } ipo = ipoList->GetScalarInterpolator(OB_LOC_Z); @@ -155,7 +155,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetPosition()[2]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyPosition(true); + ipocontr->SetIPOChannelActive(OB_LOC_Z, true); } // Master the art of cut & paste programming... @@ -167,7 +167,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaPosition()[0]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyPosition(true); + ipocontr->SetIPOChannelActive(OB_DLOC_X, true); } ipo = ipoList->GetScalarInterpolator(OB_DLOC_Y); @@ -177,7 +177,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaPosition()[1]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyPosition(true); + ipocontr->SetIPOChannelActive(OB_DLOC_Y, true); } ipo = ipoList->GetScalarInterpolator(OB_DLOC_Z); @@ -187,7 +187,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaPosition()[2]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyPosition(true); + ipocontr->SetIPOChannelActive(OB_DLOC_Z, true); } // Explore the finesse of reuse and slight modification @@ -199,7 +199,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetEulerAngles()[0]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyOrientation(true); + ipocontr->SetIPOChannelActive(OB_ROT_X, true); } ipo = ipoList->GetScalarInterpolator(OB_ROT_Y); if (ipo) { @@ -208,7 +208,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetEulerAngles()[1]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyOrientation(true); + ipocontr->SetIPOChannelActive(OB_ROT_Y, true); } ipo = ipoList->GetScalarInterpolator(OB_ROT_Z); if (ipo) { @@ -217,7 +217,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetEulerAngles()[2]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyOrientation(true); + ipocontr->SetIPOChannelActive(OB_ROT_Z, true); } // Hmmm, the need for a macro comes to mind... @@ -229,7 +229,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[0]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyOrientation(true); + ipocontr->SetIPOChannelActive(OB_DROT_X, true); } ipo = ipoList->GetScalarInterpolator(OB_DROT_Y); if (ipo) { @@ -238,7 +238,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[1]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyOrientation(true); + ipocontr->SetIPOChannelActive(OB_DROT_Y, true); } ipo = ipoList->GetScalarInterpolator(OB_DROT_Z); if (ipo) { @@ -247,7 +247,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[2]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyOrientation(true); + ipocontr->SetIPOChannelActive(OB_DROT_Z, true); } // Hang on, almost there... @@ -259,7 +259,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetScaling()[0]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyScaling(true); + ipocontr->SetIPOChannelActive(OB_SIZE_X, true); } ipo = ipoList->GetScalarInterpolator(OB_SIZE_Y); if (ipo) { @@ -268,7 +268,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetScaling()[1]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyScaling(true); + ipocontr->SetIPOChannelActive(OB_SIZE_Y, true); } ipo = ipoList->GetScalarInterpolator(OB_SIZE_Z); if (ipo) { @@ -277,7 +277,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetScaling()[2]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyScaling(true); + ipocontr->SetIPOChannelActive(OB_SIZE_Z, true); } // The last few... @@ -289,7 +289,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaScaling()[0]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyScaling(true); + ipocontr->SetIPOChannelActive(OB_DSIZE_X, true); } ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Y); if (ipo) { @@ -298,7 +298,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaScaling()[1]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyScaling(true); + ipocontr->SetIPOChannelActive(OB_DSIZE_Y, true); } ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Z); if (ipo) { @@ -307,7 +307,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend &(ipocontr->GetIPOTransform().GetDeltaScaling()[2]), ipo); ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyScaling(true); + ipocontr->SetIPOChannelActive(OB_DSIZE_Z, true); } { diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index 920a65be0fb..a4cb9970492 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -51,20 +51,21 @@ typedef unsigned long uint_ptr; #include "KX_ScalarInterpolator.h" #include "KX_GameObject.h" #include "KX_IPhysicsController.h" +#include "DNA_ipo_types.h" +#include "BLI_arithb.h" // All objects should start on frame 1! Will we ever need an object to // start on another frame, the 1.0 should change. KX_IpoSGController::KX_IpoSGController() -: m_modify_position(false), - m_modify_orientation(false), - m_modify_scaling(false), - m_ipo_as_force(false), +: m_ipo_as_force(false), m_force_ipo_acts_local(false), m_modified(true), + m_ipo_start_initialized(false), m_ipotime(1.0) { m_game_object = NULL; - + for (int i=0; i < KX_MAX_IPO_CHANNELS; i++) + m_ipo_channels_active[i] = false; } @@ -115,21 +116,60 @@ bool KX_IpoSGController::Update(double currentTime) } SG_Spatial* ob = (SG_Spatial*)m_pObject; - - if (m_modify_position) { - if (m_ipo_as_force) { - - if (m_game_object && ob) { + + //initialization on the first frame of the IPO + if (! m_ipo_start_initialized && currentTime > 0.0) { + m_ipo_start_point = ob->GetLocalPosition(); + m_ipo_start_orient = ob->GetLocalOrientation(); + m_ipo_start_scale = ob->GetLocalScale(); + m_ipo_start_initialized = true; + } + + //modifies position? + if (m_ipo_channels_active[OB_LOC_X] || m_ipo_channels_active[OB_LOC_Y] || m_ipo_channels_active[OB_LOC_Z] || m_ipo_channels_active[OB_DLOC_X] || m_ipo_channels_active[OB_DLOC_Y] || m_ipo_channels_active[OB_DLOC_Z]) + { + if (m_ipo_as_force == true) + { + if (m_game_object && ob) + { m_game_object->GetPhysicsController()->ApplyForce(m_force_ipo_acts_local ? ob->GetWorldOrientation() * m_ipo_xform.GetPosition() : m_ipo_xform.GetPosition(), false); } - - } else { - ob->SetLocalPosition(m_ipo_xform.GetPosition()); + } + else + { + //by default, leave object as it stands + MT_Point3 newPosition = ob->GetLocalPosition(); + //apply separate IPO channels if there is any data in them + //Loc and dLoc act by themselves or are additive + //LocX and dLocX + if (m_ipo_channels_active[OB_LOC_X]) { + newPosition[0] = (m_ipo_channels_active[OB_DLOC_X] ? m_ipo_xform.GetPosition()[0] + m_ipo_xform.GetDeltaPosition()[0] : m_ipo_xform.GetPosition()[0]); + } + else if (m_ipo_channels_active[OB_DLOC_X] && m_ipo_start_initialized) { + newPosition[0] = (m_ipo_start_point[0] + m_ipo_xform.GetDeltaPosition()[0]); + } + //LocY and dLocY + if (m_ipo_channels_active[OB_LOC_Y]) { + newPosition[1] = (m_ipo_channels_active[OB_DLOC_Y] ? m_ipo_xform.GetPosition()[1] + m_ipo_xform.GetDeltaPosition()[1] : m_ipo_xform.GetPosition()[1]); + } + else if (m_ipo_channels_active[OB_DLOC_Y] && m_ipo_start_initialized) { + newPosition[1] = (m_ipo_start_point[1] + m_ipo_xform.GetDeltaPosition()[1]); + } + //LocZ and dLocZ + if (m_ipo_channels_active[OB_LOC_Z]) { + newPosition[2] = (m_ipo_channels_active[OB_DLOC_Z] ? m_ipo_xform.GetPosition()[2] + m_ipo_xform.GetDeltaPosition()[2] : m_ipo_xform.GetPosition()[2]); + } + else if (m_ipo_channels_active[OB_DLOC_Z] && m_ipo_start_initialized) { + newPosition[2] = (m_ipo_start_point[2] + m_ipo_xform.GetDeltaPosition()[2]); + } + + ob->SetLocalPosition(newPosition); } } - if (m_modify_orientation) { + //modifies orientation? + if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z] || m_ipo_channels_active[OB_DROT_X] || m_ipo_channels_active[OB_DROT_Y] || m_ipo_channels_active[OB_DROT_Z]) { if (m_ipo_as_force) { if (m_game_object && ob) { @@ -137,13 +177,71 @@ bool KX_IpoSGController::Update(double currentTime) ob->GetWorldOrientation() * m_ipo_xform.GetEulerAngles() : m_ipo_xform.GetEulerAngles(), false); } - } else { - ob->SetLocalOrientation(MT_Matrix3x3(m_ipo_xform.GetEulerAngles())); + double yaw, pitch, roll; //final Euler angles + double tempYaw=0, tempPitch=0, tempRoll=0; //temp holders + ob->GetLocalOrientation().getEuler(yaw, pitch, roll); + + //RotX and dRotX + if (m_ipo_channels_active[OB_ROT_X]) { + yaw = (m_ipo_channels_active[OB_DROT_X] ? (m_ipo_xform.GetEulerAngles()[0] + m_ipo_xform.GetDeltaEulerAngles()[0]) : m_ipo_xform.GetEulerAngles()[0] ); + } + else if (m_ipo_channels_active[OB_DROT_X] && m_ipo_start_initialized) { + m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); + yaw = tempYaw + m_ipo_xform.GetDeltaEulerAngles()[0]; + } + + //RotY dRotY + if (m_ipo_channels_active[OB_ROT_Y]) { + pitch = (m_ipo_channels_active[OB_DROT_Y] ? (m_ipo_xform.GetEulerAngles()[1] + m_ipo_xform.GetDeltaEulerAngles()[1]) : m_ipo_xform.GetEulerAngles()[1] ); + } + else if (m_ipo_channels_active[OB_DROT_Y] && m_ipo_start_initialized) { + m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); + pitch = tempPitch + m_ipo_xform.GetDeltaEulerAngles()[1]; + } + + //RotZ and dRotZ + if (m_ipo_channels_active[OB_ROT_Z]) { + roll = (m_ipo_channels_active[OB_DROT_Z] ? (m_ipo_xform.GetEulerAngles()[2] + m_ipo_xform.GetDeltaEulerAngles()[2]) : m_ipo_xform.GetEulerAngles()[2] ); + } + else if (m_ipo_channels_active[OB_DROT_Z] && m_ipo_start_initialized) { + m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); + roll = tempRoll + m_ipo_xform.GetDeltaEulerAngles()[2]; + } + + ob->SetLocalOrientation(MT_Vector3(yaw, pitch, roll)); } } - if (m_modify_scaling) - ob->SetLocalScale(m_ipo_xform.GetScaling()); + //modifies scale? + if (m_ipo_channels_active[OB_SIZE_X] || m_ipo_channels_active[OB_SIZE_Y] || m_ipo_channels_active[OB_SIZE_Z] || m_ipo_channels_active[OB_DSIZE_X] || m_ipo_channels_active[OB_DSIZE_Y] || m_ipo_channels_active[OB_DSIZE_Z]) { + //default is no scale change + MT_Vector3 newScale = ob->GetLocalScale(); + + if (m_ipo_channels_active[OB_SIZE_X]) { + newScale[0] = (m_ipo_channels_active[OB_DSIZE_X] ? (m_ipo_xform.GetScaling()[0] + m_ipo_xform.GetDeltaScaling()[0]) : m_ipo_xform.GetScaling()[0]); + } + else if (m_ipo_channels_active[OB_DSIZE_X] && m_ipo_start_initialized) { + newScale[0] = (m_ipo_xform.GetDeltaScaling()[0] + m_ipo_start_scale[0]); + } + + //RotY dRotY + if (m_ipo_channels_active[OB_SIZE_Y]) { + newScale[1] = (m_ipo_channels_active[OB_DSIZE_Y] ? (m_ipo_xform.GetScaling()[1] + m_ipo_xform.GetDeltaScaling()[1]): m_ipo_xform.GetScaling()[1]); + } + else if (m_ipo_channels_active[OB_DSIZE_Y] && m_ipo_start_initialized) { + newScale[1] = (m_ipo_xform.GetDeltaScaling()[1] + m_ipo_start_scale[1]); + } + + //RotZ and dRotZ + if (m_ipo_channels_active[OB_SIZE_Z]) { + newScale[2] = (m_ipo_channels_active[OB_DSIZE_Z] ? (m_ipo_xform.GetScaling()[2] + m_ipo_xform.GetDeltaScaling()[2]) : m_ipo_xform.GetScaling()[2]); + } + else if (m_ipo_channels_active[OB_DSIZE_Z] && m_ipo_start_initialized) { + newScale[2] = (m_ipo_xform.GetDeltaScaling()[2] + m_ipo_start_scale[2]); + } + + ob->SetLocalScale(newScale); + } m_modified=false; } diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h index 3b20f47f5fc..1ebd6900741 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.h +++ b/source/gameengine/Ketsji/KX_IPO_SGController.h @@ -38,27 +38,40 @@ #include "KX_IPOTransform.h" #include "KX_IInterpolator.h" +#define KX_MAX_IPO_CHANNELS 19 //note- [0] is not used + class KX_IpoSGController : public SG_Controller { KX_IPOTransform m_ipo_xform; T_InterpolatorList m_interpolators; - /* Why not bools? */ - short m_modify_position : 1; - short m_modify_orientation : 1; - short m_modify_scaling : 1; + + /** Flag for each IPO channel that can be applied to a game object */ + bool m_ipo_channels_active[KX_MAX_IPO_CHANNELS]; /** Interpret the ipo as a force rather than a displacement? */ bool m_ipo_as_force; /** Ipo-as-force acts in local rather than in global coordinates? */ bool m_force_ipo_acts_local; - + /** Were settings altered since the last update? */ bool m_modified; /** Local time of this ipo.*/ double m_ipotime; + /** Location of the object when the IPO is first fired (for local transformations) */ + class MT_Point3 m_ipo_start_point; + + /** Orientation of the object when the IPO is first fired (for local transformations) */ + class MT_Matrix3x3 m_ipo_start_orient; + + /** Scale of the object when the IPO is first fired (for local transformations) */ + class MT_Vector3 m_ipo_start_scale; + + /** if IPO initial position has been set for local normal IPO */ + bool m_ipo_start_initialized; + /** A reference to the original game object. */ class KX_GameObject* m_game_object; @@ -80,16 +93,12 @@ public: /** Set reference to the corresponding game object. */ void SetGameObject(class KX_GameObject*); - void SetModifyPosition(bool modifypos) { - m_modify_position=modifypos; - } - void SetModifyOrientation(bool modifyorient) { - m_modify_orientation=modifyorient; - } - void SetModifyScaling(bool modifyscale) { - m_modify_scaling=modifyscale; + void SetIPOChannelActive(int index, bool value) { + //indexes found in makesdna\DNA_ipo_types.h + m_ipo_channels_active[index] = value; } + KX_IPOTransform& GetIPOTransform() { return m_ipo_xform; @@ -105,3 +114,4 @@ public: #endif //__IPO_SGCONTROLLER_H + -- cgit v1.2.3 From 435a49dfe7c5f6933c7e07cb06154dfcabeaf09e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 15 Mar 2008 17:08:58 +0000 Subject: New rayCastTo() python method for KX_GameObject: rayCastTo(other,dist,prop) Look towards another point/KX_GameObject and return first object hit within dist with a property that match prop, None if no object found or if it does not match prop. Parameters: other = 3-tuple (xyz coordinates) or object reference (target=center of object) (type = list [x,y,z] or object reference) dist = max distance of detection (can be negative => look behind) If 0 or omitted => detect up to other (type=float) prop = property name that object must have If empty or omitted => detect any object (type=string) --- .../Converter/BL_BlenderDataConversion.cpp | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 83 +++++++++++++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 22 ++++++ 3 files changed, 105 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 271385bb144..5a7423e00b1 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1670,7 +1670,7 @@ static KX_GameObject *gameobject_from_blenderobject( break; } } - + gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment()); return gameobj; } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index bc608d26c50..6f172a11005 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -61,6 +61,7 @@ typedef unsigned long uint_ptr; #include "SG_Controller.h" #include "KX_ClientObjectInfo.h" #include "RAS_BucketManager.h" +#include "KX_RayCast.h" #include "KX_PyMath.h" @@ -80,7 +81,9 @@ KX_GameObject::KX_GameObject( m_bUseObjectColor(false), m_bVisible(true), m_pPhysicsController1(NULL), - m_isDeformable(false) + m_pPhysicsEnvironment(NULL), + m_isDeformable(false), + m_pHitObject(NULL) { m_ignore_activity_culling = false; m_pClient_info = new KX_ClientObjectInfo(this, KX_ClientObjectInfo::ACTOR); @@ -657,6 +660,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS}, KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), + KX_PYMETHODTABLE(KX_GameObject, rayCastTo), {NULL,NULL} //Sentinel }; @@ -1176,6 +1180,83 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo, return NULL; } +bool KX_GameObject::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) +{ + + KX_GameObject* hitKXObj = client->m_gameobject; + + if (client->m_type > KX_ClientObjectInfo::ACTOR) + { + // false hit + return false; + } + + if (m_testPropName.Length() == 0 || hitKXObj->GetProperty(m_testPropName) != NULL) + { + m_pHitObject = hitKXObj; + return true; + } + + return false; + +} + +KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, +"rayCastTo(other,dist,prop): look towards another point/KX_GameObject and return first object hit within dist that match prop\n" +" prop = property name that object must have; can be omitted => detect any object\n" +" dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to other\n" +" other = 3-tuple or object reference") +{ + MT_Point3 toPoint; + PyObject* pyarg; + float dist = 0.0f; + char *propName = NULL; + + if (!PyArg_ParseTuple(args,"O|fs", &pyarg, &dist, &propName)) + return NULL; + + if (!PyVecTo(pyarg, toPoint)) + { + KX_GameObject *other; + PyErr_Clear(); + if (!PyType_IsSubtype(pyarg->ob_type, &KX_GameObject::Type)) + return NULL; + other = static_cast(pyarg); + toPoint = other->NodeGetWorldPosition(); + } + MT_Point3 fromPoint = NodeGetWorldPosition(); + if (dist != 0.0f) + { + MT_Vector3 toDir = toPoint-fromPoint; + toDir.normalize(); + toPoint = fromPoint + (dist) * toDir; + } + + MT_Point3 resultPoint; + MT_Vector3 resultNormal; + PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); + KX_IPhysicsController *spc = GetPhysicsController(); + KX_GameObject *parent = GetParent(); + if (!spc && parent) + spc = parent->GetPhysicsController(); + if (parent) + parent->Release(); + + m_pHitObject = NULL; + if (propName) + m_testPropName = propName; + else + m_testPropName.SetLength(0); + KX_RayCast::RayTest(spc, pe, fromPoint, toPoint, resultPoint, resultNormal, KX_RayCast::Callback(this)); + + if (m_pHitObject) + { + m_pHitObject->AddRef(); + return m_pHitObject; + } + Py_Return; +} + /* --------------------------------------------------------------------- * Some stuff taken from the header * --------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index db910a46a81..945b769d8be 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -57,6 +57,7 @@ struct KX_ClientObjectInfo; class RAS_MeshObject; class KX_IPhysicsController; +class PHY_IPhysicsEnvironment; /** @@ -82,6 +83,11 @@ protected: bool m_bVisible; KX_IPhysicsController* m_pPhysicsController1; + // used for ray casting + PHY_IPhysicsEnvironment* m_pPhysicsEnvironment; + STR_String m_testPropName; + KX_GameObject* m_pHitObject; + SG_Node* m_pSGNode; MT_CmMatrix4x4 m_OpenGL_4x4Matrix; @@ -261,6 +267,19 @@ public: ); + /** + * @return a pointer to the physics environment in use during the game, for rayCasting + */ + PHY_IPhysicsEnvironment* GetPhysicsEnvironment() + { + return m_pPhysicsEnvironment; + } + + void SetPhysicsEnvironment(PHY_IPhysicsEnvironment* physicsEnvironment) + { + m_pPhysicsEnvironment = physicsEnvironment; + } + /** * @return a pointer to the physics controller owned by this class. */ @@ -341,6 +360,8 @@ public: return m_bDyna; } + bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); + /** * @section Physics accessors for this node. @@ -608,6 +629,7 @@ public: KX_PYMETHOD(KX_GameObject,GetMesh); KX_PYMETHOD(KX_GameObject,GetParent); KX_PYMETHOD(KX_GameObject,GetPhysicsId); + KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); private : -- cgit v1.2.3 From b194059b7f41fded2451590f3b74eb602c5adae1 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 15 Mar 2008 20:52:03 +0000 Subject: BGE fix: ghost objects created with AddObject actuator will retain their ghost property --- source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 465a021cd43..ebbca137c5a 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -888,6 +888,10 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, { ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT; } + if (objprop->m_ghost) + { + ci.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE; + } ci.m_MotionState = motionstate; ci.m_gravity = btVector3(0,0,0); @@ -1141,10 +1145,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, if (objprop->m_disableSleeping) rbody->setActivationState(DISABLE_DEACTIVATION); - if (objprop->m_ghost) - { - rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); - } + //Now done directly in ci.m_collisionFlags so that it propagates to replica + //if (objprop->m_ghost) + //{ + // rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); + //} if (objprop->m_dyna && !objprop->m_angular_rigidbody) { /* -- cgit v1.2.3 From 7e031b7a39f8cf1b8bf9d415449f177e7991e9bd Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 21 Mar 2008 22:44:12 +0000 Subject: Correction on BGE fixes: - check that an object has been created before setting the physics environment - check that there is an active camera before using it - when a camera is deleted, remove it from m_cameras list --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 3 ++- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 5 ++++- source/gameengine/Ketsji/KX_Scene.cpp | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 5a7423e00b1..743aabcd821 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1670,7 +1670,8 @@ static KX_GameObject *gameobject_from_blenderobject( break; } } - gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment()); + if (gameobj) + gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment()); return gameobj; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index b879dd2ebee..03ad5109adc 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -617,7 +617,7 @@ void KX_KetsjiEngine::Render() SetWorldSettings(scene->GetWorldInfo()); // Avoid drawing the scene with the active camera twice when it's viewport is enabled - if(!cam->GetViewport()) + if(cam && !cam->GetViewport()) { if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); @@ -854,6 +854,9 @@ void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam) RAS_Rect viewport; + if (!cam) + return; + if (cam->GetViewport()) { viewport.SetLeft(cam->GetViewportLeft()); viewport.SetBottom(cam->GetViewportBottom()); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 526f893df5a..2d86e23f5ce 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -794,6 +794,9 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) //m_active_camera->Release(); m_active_camera = NULL; } + // in case this is a camera + m_cameras.remove((KX_Camera*)newobj); + if (m_sceneConverter) m_sceneConverter->UnregisterGameObject(newobj); // return value will be 0 if the object is actually deleted (all reference gone) @@ -942,6 +945,7 @@ void KX_Scene::AddCamera(KX_Camera* cam) m_cameras.push_back(cam); } + KX_Camera* KX_Scene::GetActiveCamera() { // NULL if not defined -- cgit v1.2.3 From 6615f8b74f5f959ccae5a33aeae90b37b3cd511b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 22 Mar 2008 14:47:42 +0000 Subject: BGE correction: AddRef() on source object of property actuator to protect against crash if the source object is deleted (bad game design anyway) --- source/gameengine/GameLogic/SCA_PropertyActuator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index c798503ae8a..29642cd5a7b 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -52,10 +52,16 @@ SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,CValue* sourceOb m_exprtxt(expr), m_sourceObj(sourceObj) { + // protect ourselves against someone else deleting the source object + // don't protect against ourselves: it would create a dead lock + if (m_sourceObj && m_sourceObj != GetParent()) + m_sourceObj->AddRef(); } SCA_PropertyActuator::~SCA_PropertyActuator() { + if (m_sourceObj && m_sourceObj != GetParent()) + m_sourceObj->Release(); } bool SCA_PropertyActuator::Update() -- cgit v1.2.3 From b20f6e27ff24f60bfa39b2311be3cc2f4130ac09 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 23 Mar 2008 23:12:40 +0000 Subject: Commit patch #8724: This patch modifies the BL_ConvertMesh method from the data conversion module in order to reduce the number of polygon material objects that are created. Normally, there should be only one material object for each material bucket(the group of meshes that are rendered together with a single material). However, the number of materials that are created right now in the converter is much higher and eats a lot of memory in scenes with large polygon counts. This patch deletes those material objects(KX_BlenderMaterial) that are used only temporarily in the converter(and are now deleted only when the converter is destroyed, at the end of the game). For a cube that's subdivided 7 times(90+ k polygons) I get 200 MB usage in the game engine in 2.45 and 44 MB with a svn build with this patch applied if the "Use Blender Materials" option is activated in the Game menu. --- .../Converter/BL_BlenderDataConversion.cpp | 27 ++++++++++++++++------ source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 17 +++++++++----- source/gameengine/Ketsji/KX_Scene.cpp | 4 ++-- source/gameengine/Ketsji/KX_Scene.h | 2 +- source/gameengine/Rasterizer/RAS_BucketManager.cpp | 4 +++- source/gameengine/Rasterizer/RAS_BucketManager.h | 2 +- 6 files changed, 38 insertions(+), 18 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 743aabcd821..8ae287a494c 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -883,6 +883,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* Material* ma = 0; bool polyvisible = true; RAS_IPolyMaterial* polymat = NULL; + BL_Material *bl_mat; if(converter->GetMaterials()) { @@ -891,7 +892,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* else ma = give_current_material(blenderobj, 1); - BL_Material *bl_mat = ConvertMaterial(mesh, ma, tface, mface, mmcol, lightlayer, blenderobj, layers); + bl_mat = ConvertMaterial(mesh, ma, tface, mface, mmcol, lightlayer, blenderobj, layers); // set the index were dealing with bl_mat->material_index = (int)mface->mat_nr; @@ -899,7 +900,6 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* collider = ((bl_mat->ras_mode & COLLIDER)!=0); polymat = new KX_BlenderMaterial(scene, bl_mat, skinMesh, lightlayer, blenderobj ); - converter->RegisterBlenderMaterial(bl_mat); unsigned int rgb[4]; bl_mat->GetConversionRGB(rgb); @@ -921,8 +921,6 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* if (mface->v4) tan3 = tangent[mface->v4]; } - // this is needed to free up memory afterwards - converter->RegisterPolyMaterial(polymat); } else { @@ -1029,12 +1027,27 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* polymat->m_specular = MT_Vector3(0.0f,0.0f,0.0f); polymat->m_shininess = 35.0; } + } + + // see if a bucket was reused or a new one was created + // this way only one KX_BlenderMaterial object has to exist per bucket + bool bucketCreated; + RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated); + if (bucketCreated) { // this is needed to free up memory afterwards converter->RegisterPolyMaterial(polymat); - + if(converter->GetMaterials()) { + converter->RegisterBlenderMaterial(bl_mat); + } + } else { + // delete the material objects since they are no longer needed + // from now on, use the polygon material from the material bucket + delete polymat; + if(converter->GetMaterials()) { + delete bl_mat; + } + polymat = bucket->GetPolyMaterial(); } - - RAS_MaterialBucket* bucket = scene->FindBucket(polymat); int nverts = mface->v4?4:3; int vtxarray = meshobj->FindVertexArray(nverts,polymat); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 4898dbed95f..c276f42e0ff 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -137,17 +137,22 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { bool justactivated = false; bool justreleased = false; + bool active = false; for (int i=SCA_IInputDevice::KX_BEGINKEY ; i< SCA_IInputDevice::KX_ENDKEY;i++) { const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i); - if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED) - { + switch (inevent.m_status) + { + case SCA_InputEvent::KX_JUSTACTIVATED: justactivated = true; - } - if (inevent.m_status == SCA_InputEvent::KX_JUSTRELEASED) - { + break; + case SCA_InputEvent::KX_JUSTRELEASED: justreleased = true; + break; + case SCA_InputEvent::KX_ACTIVE: + active = true; + break; } } @@ -159,7 +164,7 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (justreleased) { - m_val=0; + m_val=(active)?1:0; result = true; } } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 2d86e23f5ce..b2557a69527 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1212,9 +1212,9 @@ void KX_Scene::UpdateParents(double curtime) -RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat) +RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool &bucketCreated) { - return m_bucketmanager->RAS_BucketManagerFindBucket(polymat); + return m_bucketmanager->RAS_BucketManagerFindBucket(polymat, bucketCreated); } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 58120d49dc4..b5de483e8f0 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -286,7 +286,7 @@ public: ~KX_Scene(); RAS_BucketManager* GetBucketManager(); - RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial* polymat); + RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial* polymat, bool &bucketCreated); void RenderBuckets(const MT_Transform& cameratransform, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 999a79546a1..9c28aedd994 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -156,8 +156,9 @@ void RAS_BucketManager::Renderbuckets( RAS_MaterialBucket::EndFrame(); } -RAS_MaterialBucket* RAS_BucketManager::RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material) +RAS_MaterialBucket* RAS_BucketManager::RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material, bool &bucketCreated) { + bucketCreated = false; BucketList::iterator it; for (it = m_MaterialBuckets.begin(); it != m_MaterialBuckets.end(); it++) { @@ -172,6 +173,7 @@ RAS_MaterialBucket* RAS_BucketManager::RAS_BucketManagerFindBucket(RAS_IPolyMate } RAS_MaterialBucket *bucket = new RAS_MaterialBucket(material); + bucketCreated = true; if (bucket->IsTransparant()) m_AlphaBuckets.push_back(bucket); else diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index 59144f1e175..11633f555ea 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -61,7 +61,7 @@ public: RAS_IRasterizer* rasty, class RAS_IRenderTools* rendertools); - RAS_MaterialBucket* RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material); + RAS_MaterialBucket* RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material, bool &bucketCreated); private: -- cgit v1.2.3 From d9de141077873c9379d0bd6ea745b60f5180c4d2 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sun, 30 Mar 2008 16:18:01 +0000 Subject: == bugfix == fix for [#6950] Blender crashes when .blog file top line is 160 characters or more - made sure BLI_convertstringcode doesn't return more than 240 chars - went through all callers and fixed places where string passed to BLI_convertstringcode was too short - TODO: look into increasing sample->name and sound->name too, I prevented crashes, but filename might get shortened. --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 4 ++-- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 0e0d8982527..3b7f610b783 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -258,7 +258,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, exitrequested = KX_EXIT_REQUEST_NO_REQUEST; if (bfd) BLO_blendfiledata_free(bfd); - char basedpath[160]; + char basedpath[240]; // base the actuator filename with respect // to the original file working directory if (exitstring != "") @@ -271,7 +271,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, if (!bfd) { // just add "//" in front of it - char temppath[162]; + char temppath[242]; strcpy(temppath, "//"); strcat(temppath, basedpath); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 0993446c77b..cf45c513098 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -577,7 +577,7 @@ int main(int argc, char** argv) // if we got an exitcode 3 (KX_EXIT_REQUEST_START_OTHER_GAME) load a different file if (exitcode == KX_EXIT_REQUEST_START_OTHER_GAME) { - char basedpath[160]; + char basedpath[240]; // base the actuator filename with respect // to the original file working directory -- cgit v1.2.3 From 51ea7645e253d50dd8936ab89c5c40dc5c952b81 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 1 Apr 2008 20:46:20 +0000 Subject: Fix BGE bug: BGE will crash if objects with display debug property is deleted (bad practice anyway). The actual deletion is now postponed until end of scene --- source/gameengine/GameLogic/SCA_IScene.cpp | 12 ++++++++++++ source/gameengine/GameLogic/SCA_IScene.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_IScene.cpp b/source/gameengine/GameLogic/SCA_IScene.cpp index d4463196379..a2f0693b475 100644 --- a/source/gameengine/GameLogic/SCA_IScene.cpp +++ b/source/gameengine/GameLogic/SCA_IScene.cpp @@ -30,11 +30,22 @@ */ #include "SCA_IScene.h" +#include "Value.h" #ifdef HAVE_CONFIG_H #include #endif +SCA_DebugProp::SCA_DebugProp(): m_obj(NULL) +{ +} + +SCA_DebugProp::~SCA_DebugProp() +{ + if (m_obj) + m_obj->Release(); +} + SCA_IScene::SCA_IScene() { } @@ -64,6 +75,7 @@ void SCA_IScene::AddDebugProperty(class CValue* debugprop, { SCA_DebugProp* dprop = new SCA_DebugProp(); dprop->m_obj = debugprop; + debugprop->AddRef(); dprop->m_name = name; m_debugList.push_back(dprop); } diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h index 3c62ec91515..5aa631f6b4d 100644 --- a/source/gameengine/GameLogic/SCA_IScene.h +++ b/source/gameengine/GameLogic/SCA_IScene.h @@ -40,6 +40,8 @@ struct SCA_DebugProp { class CValue* m_obj; STR_String m_name; + SCA_DebugProp(); + ~SCA_DebugProp(); }; class SCA_IScene -- cgit v1.2.3 From b73ba9c1812d90ecdd9d76d3347843cbd26327bb Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Wed, 2 Apr 2008 15:03:03 +0000 Subject: This commit reverts the #include stuff used for peach to the standard the mesa stuff was needed for the machines for peach but its not the stanard location of the headers, now that its not needed were switching it back. Kent --- source/gameengine/Ketsji/BL_Shader.cpp | 5 +++-- source/gameengine/Ketsji/BL_Texture.cpp | 6 +++--- source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 5 +++-- source/gameengine/Ketsji/KX_PythonInit.cpp | 6 +++--- 4 files changed, 12 insertions(+), 10 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 3b74b74727a..3bd5146f28f 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -9,11 +9,12 @@ #include #else #include -#if defined(__sun__) && !defined(__sparc__) +/* #if defined(__sun__) && !defined(__sparc__) #include #else +*/ #include -#endif +/* #endif */ #endif #include diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 53e1af46e4e..f6fb990fd4c 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -8,11 +8,11 @@ #include #else #include -#if defined(__sun__) && !defined(__sparc__) +/* #if defined(__sun__) && !defined(__sparc__) #include -#else +#else */ #include -#endif +/* #endif */ #endif #include diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index c3aa83bec69..cfdcba8a5d6 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -15,11 +15,12 @@ #include #else #include -#if defined(__sun__) && !defined(__sparc__) +/* #if defined(__sun__) && !defined(__sparc__) #include #else +*/ #include -#endif +/* #endif */ #endif #include "KX_BlenderMaterial.h" diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 58369ddcab6..f3f10ea78b4 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -44,11 +44,11 @@ #include #else #include -#if defined(__sun__) && !defined(__sparc__) +/* #if defined(__sun__) && !defined(__sparc__) #include -#else +#else */ #include -#endif +/* #endif */ #endif #ifdef WIN32 -- cgit v1.2.3 From 1bdc909555f3065a7a79b9c75e2fd828e2fc1e8c Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 4 Apr 2008 20:39:31 +0000 Subject: BGE bug [#4839] fixed: joystick keeps working after an overlay scene is removed --- .../gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 28 ++++++++++++++++++++++ .../gameengine/GameLogic/Joystick/SCA_Joystick.h | 20 ++++++++++------ .../gameengine/GameLogic/SCA_JoystickManager.cpp | 6 ++--- 3 files changed, 43 insertions(+), 11 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 071301514fb..79da15721f3 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -55,6 +55,34 @@ SCA_Joystick::~SCA_Joystick() delete m_private; } +SCA_Joystick *SCA_Joystick::m_instance = NULL; +int SCA_Joystick::m_refCount = 0; + +SCA_Joystick *SCA_Joystick::GetInstance() +{ + if (m_instance == 0) + { + m_instance = new SCA_Joystick(); + m_instance->CreateJoystickDevice(); + m_refCount = 1; + } + else + { + m_refCount++; + } + return m_instance; +} + +void SCA_Joystick::ReleaseInstance() +{ + if (--m_refCount == 0) + { + DestroyJoystickDevice(); + delete m_instance; + m_instance = NULL; + } +} + bool SCA_Joystick::CreateJoystickDevice() { diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index 2d2a713fe00..997e76615d3 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -71,12 +71,16 @@ /* * Basic Joystick class - + * I will make this class a singleton because there should be only one joystick + * even if there are more than one scene using it and count how many scene are using it. + * The underlying joystick should only be removed when the last scene is removed */ class SCA_Joystick { + static SCA_Joystick *m_instance; + static int m_refCount; class PrivateData; @@ -258,20 +262,22 @@ class SCA_Joystick int pGetHat(int direction); - - -public: - SCA_Joystick(); ~SCA_Joystick(); - - bool CreateJoystickDevice(void); void DestroyJoystickDevice(void); + +public: + + static SCA_Joystick *GetInstance(); + + void ReleaseInstance(); + + void HandleEvents(); /* diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp index cf182a0503e..ca2d5459386 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp @@ -43,15 +43,13 @@ SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr) : SCA_EventManager(JOY_EVENTMGR), m_logicmgr(logicmgr) { - m_joystick = new SCA_Joystick(); - m_joystick->CreateJoystickDevice(); + m_joystick = SCA_Joystick::GetInstance(); } SCA_JoystickManager::~SCA_JoystickManager() { - m_joystick->DestroyJoystickDevice(); - delete m_joystick; + m_joystick->ReleaseInstance(); } -- cgit v1.2.3 From cc33fcfe7b76aa8370cace83859d085b42304d48 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 5 Apr 2008 13:33:08 +0000 Subject: Commit patch #2439: Mesh replacement in BGE will react properly to armature deform Changing the mesh of an object that has a deform controller (armature) is now properly handled. The new mesh must have vertex groups matching the armature bones. In simple terms, the new mesh must deform correctly when you assign it to the object in Blender and you test the action. It will deform the same when you replace the object mesh during the game. --- source/gameengine/Converter/BL_SkinDeformer.cpp | 26 ++++++++++++++++++++++++- source/gameengine/Converter/BL_SkinDeformer.h | 15 +++++--------- 2 files changed, 30 insertions(+), 11 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index e9ec6f9116b..6bc623b645c 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -60,11 +60,35 @@ extern "C"{ #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS + +BL_SkinDeformer::BL_SkinDeformer( + struct Object *bmeshobj_old, // Blender object that owns the new mesh + struct Object *bmeshobj_new, // Blender object that owns the original mesh + class BL_SkinMeshObject *mesh, + bool release_object, + BL_ArmatureObject* arma) : + BL_MeshDeformer(bmeshobj_old, mesh), + m_armobj(arma), + m_lastUpdate(-1), + m_defbase(&bmeshobj_old->defbase), + m_releaseobject(release_object) + { + Mat4CpyMat4(m_obmat, bmeshobj_old->obmat); + m_restoremat = true; + // this is needed to ensure correct deformation of mesh: + // the deformation is done with Blender's armature_deform_verts() function + // that takes an object as parameter and not a mesh. The object matrice is used + // in the calculation, so we must force the same matrice to simulate a pure replacement of mesh + Mat4CpyMat4(bmeshobj_old->obmat, bmeshobj_new->obmat); + } + BL_SkinDeformer::~BL_SkinDeformer() { if(m_releaseobject && m_armobj) m_armobj->Release(); -}; + if (m_restoremat) + Mat4CpyMat4(m_objMesh->obmat, m_obmat); +} /* XXX note, this __NLA_OLDDEFORM define seems to be obsolete */ diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index 74adc6c2943..b4e55018604 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -72,7 +72,8 @@ public: m_armobj(arma), m_lastUpdate(-1), m_defbase(&bmeshobj->defbase), - m_releaseobject(false) + m_releaseobject(false), + m_restoremat(false) { }; @@ -81,15 +82,7 @@ public: struct Object *bmeshobj_new, class BL_SkinMeshObject *mesh, bool release_object, - BL_ArmatureObject* arma = NULL) - : // - BL_MeshDeformer(bmeshobj_old, mesh), - m_armobj(arma), - m_lastUpdate(-1), - m_defbase(&bmeshobj_old->defbase), - m_releaseobject(release_object) - { - }; + BL_ArmatureObject* arma = NULL); virtual void ProcessReplica(); virtual RAS_Deformer *GetReplica(); @@ -102,6 +95,8 @@ protected: float m_time; double m_lastUpdate; ListBase* m_defbase; + float m_obmat[4][4]; // the original object matrice in case of dynamic mesh replacement + bool m_restoremat; bool m_releaseobject; }; -- cgit v1.2.3 From 9edb6c7510742fb9461be179549552374b8aabc9 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 5 Apr 2008 22:08:15 +0000 Subject: Patch #8740: enable negative axis radar sensor --- source/gameengine/Ketsji/KX_RadarSensor.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 5d56eaabb5a..45379f93b54 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -127,27 +127,48 @@ void KX_RadarSensor::SynchronizeTransform() // depends on the radar 'axis' switch (m_axis) { - case 0: // X Axis + case 0: // +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)); break; }; - case 1: // Y Axis + case 1: // +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)); break; }; - case 2: // Z Axis + case 2: // +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)); break; }; + case 3: // -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)); + break; + }; + case 4: // -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)); + break; + }; + case 5: // -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)); + break; + }; default: { } -- cgit v1.2.3 From e7384c9dd2d93e3814e8df51eea64f1dc687c338 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 6 Apr 2008 18:30:52 +0000 Subject: Commit patch #8799: Realtime SetParent function in the BGE This patch consists in new KX_GameObject::SetParent() and KX_GameObject::RemoveParent() functions to create and destroy parent relation during game. These functions are accessible through python and through a new actuator KX_ParentActuator. Function documentation in PyDoc. The object keeps its orientation, position and scale when it is parented but will further rotate, move and scale with its parent from that point on. When the parent relation is broken, the object keeps the orientation, position and scale it had at that time. The function has no effect if any of the X/Y/Z scale of the object or its new parent are below Epsilon. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 28 +++- source/gameengine/Ketsji/KX_GameObject.cpp | 94 ++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 12 ++ source/gameengine/Ketsji/KX_ParentActuator.cpp | 172 +++++++++++++++++++++ source/gameengine/Ketsji/KX_ParentActuator.h | 86 +++++++++++ source/gameengine/PyDoc/KX_GameObject.py | 8 + source/gameengine/PyDoc/KX_ParentActuator.py | 22 +++ 7 files changed, 419 insertions(+), 3 deletions(-) create mode 100644 source/gameengine/Ketsji/KX_ParentActuator.cpp create mode 100644 source/gameengine/Ketsji/KX_ParentActuator.h create mode 100644 source/gameengine/PyDoc/KX_ParentActuator.py (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index f76a0fb82e5..68024100719 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -49,7 +49,6 @@ #include "SCA_RandomActuator.h" #include "SCA_2DFilterActuator.h" - // Ketsji specific logicbricks #include "KX_SceneActuator.h" #include "KX_IpoActuator.h" @@ -64,6 +63,7 @@ #include "KX_SCA_AddObjectActuator.h" #include "KX_SCA_EndObjectActuator.h" #include "KX_SCA_ReplaceMeshActuator.h" +#include "KX_ParentActuator.h" #include "KX_Scene.h" #include "KX_KetsjiEngine.h" @@ -917,6 +917,32 @@ void BL_ConvertActuators(char* maggiename, } break; + case ACT_PARENT: + { + bParentActuator *parAct = (bParentActuator *) bact->data; + int mode = KX_ParentActuator::KX_PARENT_NODEF; + KX_GameObject *tmpgob; + + switch(parAct->type) + { + case ACT_PARENT_SET: + mode = KX_ParentActuator::KX_PARENT_SET; + tmpgob = converter->FindGameObject(parAct->ob); + break; + case ACT_PARENT_REMOVE: + mode = KX_ParentActuator::KX_PARENT_REMOVE; + tmpgob = NULL; + break; + } + + KX_ParentActuator *tmpparact + = new KX_ParentActuator(gameobj, + mode, + tmpgob); + baseact = tmpparact; + break; + } + default: ; /* generate some error */ } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6f172a11005..7ffac9a82f1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -62,7 +62,7 @@ typedef unsigned long uint_ptr; #include "KX_ClientObjectInfo.h" #include "RAS_BucketManager.h" #include "KX_RayCast.h" - +#include "KX_PythonInit.h" #include "KX_PyMath.h" // This file defines relationships between parents and children @@ -88,7 +88,7 @@ KX_GameObject::KX_GameObject( m_ignore_activity_culling = false; m_pClient_info = new KX_ClientObjectInfo(this, KX_ClientObjectInfo::ACTOR); m_pSGNode = new SG_Node(this,sgReplicationInfo,callbacks); - + // define the relationship between this node and it's parent. KX_NormalParentRelation * parent_relation = @@ -204,7 +204,62 @@ KX_GameObject* KX_GameObject::GetParent() } +void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) +{ + if (obj && GetSGNode()->GetSGParent() != obj->GetSGNode()) + { + // Make sure the objects have some scale + MT_Vector3 scale1 = NodeGetWorldScaling(); + MT_Vector3 scale2 = obj->NodeGetWorldScaling(); + if (fabs(scale2[0]) < FLT_EPSILON || + fabs(scale2[1]) < FLT_EPSILON || + fabs(scale2[2]) < FLT_EPSILON || + fabs(scale1[0]) < FLT_EPSILON || + fabs(scale1[1]) < FLT_EPSILON || + fabs(scale1[2]) < FLT_EPSILON) { return; } + + // Remove us from our old parent and set our new parent + RemoveParent(scene); + obj->GetSGNode()->AddChild(GetSGNode()); + + // Set us to our new scale, position, and orientation + scale1[0] = scale1[0]/scale2[0]; + scale1[1] = scale1[1]/scale2[1]; + scale1[2] = scale1[2]/scale2[2]; + MT_Matrix3x3 invori = obj->NodeGetWorldOrientation().inverse(); + MT_Vector3 newpos = invori*(NodeGetWorldPosition()-obj->NodeGetWorldPosition())*scale1; + + NodeSetLocalScale(scale1); + NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2])); + NodeSetLocalOrientation(NodeGetWorldOrientation()*invori); + NodeUpdateGS(0.f,true); + // object will now be a child, it must be removed from the parent list + CListValue* rootlist = scene->GetRootParentList(); + if (rootlist->RemoveValue(this)) + // the object was in parent list, decrement ref count as it's now removed + Release(); + } +} + +void KX_GameObject::RemoveParent(KX_Scene *scene) +{ + if (GetSGNode()->GetSGParent()) + { + // Set us to the right spot + GetSGNode()->SetLocalScale(GetSGNode()->GetWorldScaling()); + GetSGNode()->SetLocalOrientation(GetSGNode()->GetWorldOrientation()); + GetSGNode()->SetLocalPosition(GetSGNode()->GetWorldPosition()); + // Remove us from our parent + GetSGNode()->DisconnectFromParent(); + NodeUpdateGS(0.f,true); + // the object is now a root object, add it to the parentlist + CListValue* rootlist = scene->GetRootParentList(); + if (!rootlist->SearchValue(this)) + // object was not in root list, add it now and increment ref count + rootlist->Add(AddRef()); + } +} void KX_GameObject::ProcessReplica(KX_GameObject* replica) { @@ -657,6 +712,8 @@ PyMethodDef KX_GameObject::Methods[] = { {"enableRigidBody", (PyCFunction)KX_GameObject::sPyEnableRigidBody,METH_VARARGS}, {"disableRigidBody", (PyCFunction)KX_GameObject::sPyDisableRigidBody,METH_VARARGS}, {"getParent", (PyCFunction)KX_GameObject::sPyGetParent,METH_VARARGS}, + {"setParent", (PyCFunction)KX_GameObject::sPySetParent,METH_VARARGS}, + {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_VARARGS}, {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS}, KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), @@ -797,6 +854,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr if (PyMatTo(value, rot)) { NodeSetLocalOrientation(rot); + NodeUpdateGS(0.f,true); return 0; } return 1; @@ -809,6 +867,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr { rot.setRotation(qrot); NodeSetLocalOrientation(rot); + NodeUpdateGS(0.f,true); return 0; } return 1; @@ -821,6 +880,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr { rot.setEuler(erot); NodeSetLocalOrientation(rot); + NodeUpdateGS(0.f,true); return 0; } return 1; @@ -835,6 +895,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr if (PyVecTo(value, pos)) { NodeSetLocalPosition(pos); + NodeUpdateGS(0.f,true); return 0; } return 1; @@ -846,6 +907,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr if (PyVecTo(value, scale)) { NodeSetLocalScale(scale); + NodeUpdateGS(0.f,true); return 0; } return 1; @@ -861,6 +923,8 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr } } + /* Need to have parent settable here too */ + return SCA_IObject::_setattr(attr, value); } @@ -985,7 +1049,31 @@ PyObject* KX_GameObject::PyGetParent(PyObject* self, Py_Return; } +PyObject* KX_GameObject::PySetParent(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + PyObject* gameobj; + if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) + { + // The object we want to set as parent + CValue *m_ob = (CValue*)gameobj; + KX_GameObject *obj = ((KX_GameObject*)m_ob); + KX_Scene *scene = PHY_GetActiveScene(); + + this->SetParent(scene, obj); + } + Py_Return; +} +PyObject* KX_GameObject::PyRemoveParent(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + KX_Scene *scene = PHY_GetActiveScene(); + this->RemoveParent(scene); + Py_Return; +} PyObject* KX_GameObject::PyGetMesh(PyObject* self, PyObject* args, @@ -1116,6 +1204,7 @@ PyObject* KX_GameObject::PySetOrientation(PyObject* self, if (PyObject_IsMT_Matrix(pylist, 3) && PyMatTo(pylist, matrix)) { NodeSetLocalOrientation(matrix); + NodeUpdateGS(0.f,true); Py_Return; } @@ -1124,6 +1213,7 @@ PyObject* KX_GameObject::PySetOrientation(PyObject* self, { matrix.setRotation(quat); NodeSetLocalOrientation(matrix); + NodeUpdateGS(0.f,true); Py_Return; } } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 945b769d8be..b97e7d33f6b 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -47,6 +47,7 @@ #include "MT_CmMatrix4x4.h" #include "GEN_Map.h" #include "GEN_HashedPtr.h" +#include "KX_Scene.h" #define KX_FIXED_FRAME_PER_SEC 25.0f #define KX_FIXED_SEC_PER_FRAME (1.0f / KX_FIXED_FRAME_PER_SEC) @@ -134,6 +135,15 @@ public: GetParent( ); + /** + * Sets the parent of this object to a game object + */ + void SetParent(KX_Scene *scene, KX_GameObject *obj); + + /** + * Removes the parent of this object to a game object + */ + void RemoveParent(KX_Scene *scene); /** * Construct a game object. This class also inherits the @@ -628,6 +638,8 @@ public: KX_PYMETHOD(KX_GameObject,SetCollisionMargin); KX_PYMETHOD(KX_GameObject,GetMesh); KX_PYMETHOD(KX_GameObject,GetParent); + KX_PYMETHOD(KX_GameObject,SetParent); + KX_PYMETHOD(KX_GameObject,RemoveParent); KX_PYMETHOD(KX_GameObject,GetPhysicsId); KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp new file mode 100644 index 00000000000..288791eb994 --- /dev/null +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -0,0 +1,172 @@ +/** + * Set or remove an objects parent + * + * $Id: SCA_ParentActuator.cpp 13932 2008-03-01 19:05:41Z ben2610 $ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include "KX_ParentActuator.h" +#include "KX_GameObject.h" +#include "KX_PythonInit.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj, + int mode, + CValue *ob, + PyTypeObject* T) + : SCA_IActuator(gameobj, T), + m_mode(mode), + m_ob(ob) +{ +} + + + +KX_ParentActuator::~KX_ParentActuator() +{ + /* intentionally empty */ +} + + + +CValue* KX_ParentActuator::GetReplica() +{ + KX_ParentActuator* replica = new KX_ParentActuator(*this); + // replication just copy the m_base pointer => common random generator + replica->ProcessReplica(); + CValue::AddDataToReplica(replica); + + return replica; +} + + + +bool KX_ParentActuator::Update() +{ + KX_GameObject *obj = (KX_GameObject*) GetParent(); + KX_Scene *scene = PHY_GetActiveScene(); + switch (m_mode) { + case KX_PARENT_SET: + obj->SetParent(scene, (KX_GameObject*)m_ob); + break; + case KX_PARENT_REMOVE: + obj->RemoveParent(scene); + break; + }; + + return false; +} + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject KX_ParentActuator::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "KX_ParentActuator", + sizeof(KX_ParentActuator), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject KX_ParentActuator::Parents[] = { + &KX_ParentActuator::Type, + &SCA_IActuator::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef KX_ParentActuator::Methods[] = { + {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_VARARGS, SetObject_doc}, + {"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, + {NULL,NULL} //Sentinel +}; + +PyObject* KX_ParentActuator::_getattr(const STR_String& attr) { + _getattr_up(SCA_IActuator); +} + +/* 1. setObject */ +char KX_ParentActuator::SetObject_doc[] = +"setObject(object)\n" +"\tSet the object to set as parent.\n" +"\tCan be an object name or an object\n"; +PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* args, PyObject* kwds) { + PyObject* gameobj; + if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) + { + m_ob = (CValue*)gameobj; + Py_Return; + } + PyErr_Clear(); + + char* objectname; + if (PyArg_ParseTuple(args, "s", &objectname)) + { + CValue *object = (CValue*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)); + if(object) + { + m_ob = object; + Py_Return; + } + } + + return NULL; +} + +/* 2. getObject */ +char KX_ParentActuator::GetObject_doc[] = +"getObject()\n" +"\tReturns the object that is set to.\n"; +PyObject* KX_ParentActuator::PyGetObject(PyObject* self, PyObject* args, PyObject* kwds) { + return PyString_FromString(m_ob->GetName()); +} + +/* eof */ diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h new file mode 100644 index 00000000000..1bceacc9078 --- /dev/null +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -0,0 +1,86 @@ +/** + * Set or remove an objects parent + * + * + * $Id: KX_ParentActuator.h 3271 2004-10-16 11:41:50Z kester $ + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#ifndef __KX_PARENTACTUATOR +#define __KX_PARENTACTUATOR + +#include "SCA_IActuator.h" +#include "SCA_LogicManager.h" + +class KX_ParentActuator : public SCA_IActuator +{ + Py_Header; + + /** Mode */ + int m_mode; + + /** Object to set as parent */ + CValue *m_ob; + + + + public: + enum KX_PARENTACT_MODE + { + KX_PARENT_NODEF = 0, + KX_PARENT_SET, + KX_PARENT_REMOVE, + + }; + + KX_ParentActuator(class SCA_IObject* gameobj, + int mode, + CValue *ob, + PyTypeObject* T=&Type); + virtual ~KX_ParentActuator(); + virtual bool Update(); + + virtual CValue* GetReplica(); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + + /* 1. setObject */ + KX_PYMETHOD_DOC(KX_ParentActuator,SetObject); + /* 2. getObject */ + KX_PYMETHOD_DOC(KX_ParentActuator,GetObject); + +}; /* end of class KX_ParentActuator : public SCA_PropertyActuator */ + +#endif + diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index d3428915f25..7ed4b59629c 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -135,6 +135,14 @@ class KX_GameObject: @rtype: L{KX_GameObject} @return: this object's parent object, or None if this object has no parent. """ + def setParent(parent): + """ + Sets this object's parent. + """ + def removeParent(): + """ + Removes this objects parent. + """ def getMesh(mesh): """ Gets the mesh object for this object. diff --git a/source/gameengine/PyDoc/KX_ParentActuator.py b/source/gameengine/PyDoc/KX_ParentActuator.py new file mode 100644 index 00000000000..f45bb5d20b1 --- /dev/null +++ b/source/gameengine/PyDoc/KX_ParentActuator.py @@ -0,0 +1,22 @@ +# $Id: KX_ParentActuator.py 2615 2004-06-02 12:43:27Z kester $ +# Documentation for KX_ParentActuator +from SCA_IActuator import * + +class KX_ParentActuator(SCA_IActuator): + """ + The parent actuator can set or remove an objects parent object. + """ + def setObject(object): + """ + Sets the object to set as parent. + + Object can be either a L{KX_GameObject} or the name of the object. + + @type object: L{KX_GameObject} or string + """ + def getObject(): + """ + Returns the name of the object to change to. + + @rtype: string + """ -- cgit v1.2.3 From 88ce1c063839cb47c4dfe131910dd25faed09e88 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 6 Apr 2008 19:14:04 +0000 Subject: Removed my own patch #8208: export SCA_ISensor::Evaluate() to Python. It was only useful for the ray sensor and the new rayCastTo() function provides better functionality --- source/gameengine/GameLogic/SCA_ISensor.cpp | 12 ------------ source/gameengine/GameLogic/SCA_ISensor.h | 1 - 2 files changed, 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 1a65f8311ed..43dd6bef83e 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -160,8 +160,6 @@ PyMethodDef SCA_ISensor::Methods[] = { METH_VARARGS, GetInvert_doc}, {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert, METH_VARARGS, SetInvert_doc}, - {"evaluate", (PyCFunction) SCA_ISensor::sPyEvaluate, - METH_VARARGS, Evaluate_doc}, {NULL,NULL} //Sentinel }; @@ -333,14 +331,4 @@ PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyOb Py_Return; } -char SCA_ISensor::Evaluate_doc[] = -"evaluate()\n" -"\tRe-evaluate the sensor so that isPositive() and other methods are up to date\n" -"\twith current game conditions. BGE does it automatically on each frame so it's\n" -"\tnot usually needed.\n" -"\tReturns True or False if the sensor evaluates positively or negatively\n"; -PyObject* SCA_ISensor::PyEvaluate(PyObject* self, PyObject* args, PyObject* kwds) -{ - return BoolToPyArg(Evaluate(NULL)); -} /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 8de4480cf2e..1c5ee7a39bb 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -127,7 +127,6 @@ public: KX_PYMETHOD_DOC(SCA_ISensor,SetUseNegPulseMode); KX_PYMETHOD_DOC(SCA_ISensor,GetInvert); KX_PYMETHOD_DOC(SCA_ISensor,SetInvert); - KX_PYMETHOD_DOC(SCA_ISensor,Evaluate); }; -- cgit v1.2.3 From 34771ef40519529e14d4a06cc318b63554ebbe58 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 6 Apr 2008 20:02:41 +0000 Subject: add KX_GameObject::rayCastTo() PyDoc --- source/gameengine/PyDoc/KX_GameObject.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 7ed4b59629c..31c9993e194 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -164,3 +164,20 @@ class KX_GameObject: @type other: L{KX_GameObject} or list [x, y, z] @rtype: float """ + def rayCastTo(other,dist,prop): + """ + Look towards another point/object and find first object hit within dist that matches prop. + + The ray is always casted from the center of the object, ignoring the object itself. + The ray is casted towards the center of another object or an explicit [x,y,z] point. + + @param other: [x,y,z] or object towards which the ray is casted + @type other: L{KX_GameObject} or string + @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other + @type dist: float + @param prop: property name that object must have; can be omitted => detect any object + @type prop: string + @rtype: L{KX_GameObject} + @return: the first object hit or None if no object or object does not match prop + """ + \ No newline at end of file -- cgit v1.2.3 From 539ff570159a0426355264260cae937564360010 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 10 Apr 2008 20:17:12 +0000 Subject: fix BGE bug #8813: new rayCastTo() function hits near sensor collision box --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 25defbd5587..5771e7f1dc7 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -739,8 +739,8 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i PHY_IPhysicsController* nearestHit = 0; - - m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback); + // don't collision with sensor object + m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback, CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter); if (rayCallback.HasHit()) { nearestHit = static_cast(rayCallback.m_collisionObject->getUserPointer()); -- cgit v1.2.3 From 4bab327c1b16f9e27fe53935ea9d1d5dda6718d2 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 11 Apr 2008 21:19:00 +0000 Subject: fix BGE patch #7892: dRot motion is reversed on non-dynamic objects Positive dRot motion actuator will now make the dynamic and non-dynamic objects rotate counter-clock wise. --- source/gameengine/Ketsji/KX_GameObject.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 7ffac9a82f1..347caa3f9e6 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -314,12 +314,13 @@ void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local) void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local) { MT_Matrix3x3 rotmat(drot); - rotmat.transpose(); - - if (m_pPhysicsController1) // (IsDynamic()) - m_pPhysicsController1->RelativeRotate(rotmat,local); - // in worldspace + GetSGNode()->RelativeRotate(rotmat,local); + + if (m_pPhysicsController1) { // (IsDynamic()) + rotmat.transpose(); + m_pPhysicsController1->RelativeRotate(rotmat,local); + } } -- cgit v1.2.3 From dfd7387641c28f2a80f7647f26c981911d4a8cfe Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 12 Apr 2008 21:18:58 +0000 Subject: fix BGE bug #8880: blenderplayer closing when esc is pressed ESC now quits the game by default in all modes unless a keyboard sensor is set on ESC. In this case, the game designer must arrange for an alternative way to quit the game. --- source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h | 2 +- source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h index da3dc2398dd..c5c900d276a 100644 --- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h +++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h @@ -58,9 +58,9 @@ protected: * System dependent keyboard codes are stored as ints. */ std::map m_reverseKeyTranslateTable; - bool m_hookesc; public: + bool m_hookesc; GPC_KeyboardDevice() : m_hookesc(false) { diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 5ef20514390..dcc70db9eed 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -845,11 +845,12 @@ bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown) { GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData(); GHOST_TEventKeyData* keyData = static_cast(eventData); - if (fSystem->getFullScreen()) { - if (keyData->key == GHOST_kKeyEsc) { + //no need for this test + //if (fSystem->getFullScreen()) { + if (keyData->key == GHOST_kKeyEsc && !m_keyboard->m_hookesc) { m_exitRequested = KX_EXIT_REQUEST_OUTSIDE; } - } + //} m_keyboard->ConvertEvent(keyData->key, isDown); handled = true; } -- cgit v1.2.3 From 566053319a47119bf718154f800659f9f0b86472 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 14 Apr 2008 20:54:20 +0000 Subject: fix BGE bug #8309: After Parent Object added to the visual layer, Child Camera won't follow. This bug fix is made of two parts: 1) It's now possible to dynamically add a camera. 2) Empty camera name on a SetCamera actuator now points to the actuator's parent object if this object is a camera. This trick is useful to make current a dynamically created camera: just add a SetCamera actuator on the camera itself and leave the name empty. Later, when the camera is added in the scene with an AddObject actuator, either directly or via a parent object, you just need to activate the actuator to make the newly created camera current. If you set a name on a SetCamera actuator, it will always point to the original camera, even after replication. --- source/gameengine/Converter/KX_ConvertActuators.cpp | 6 +----- source/gameengine/Ketsji/KX_Camera.cpp | 15 +++++++++++++++ source/gameengine/Ketsji/KX_Camera.h | 18 ++++++++++++++++++ source/gameengine/Ketsji/KX_SceneActuator.cpp | 9 +++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 68024100719..a9b84e8f51f 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -684,15 +684,11 @@ void BL_ConvertActuators(char* maggiename, break; } case ACT_SCENE_CAMERA: + mode = KX_SceneActuator::KX_SCENE_SET_CAMERA; if (sceneact->camera) { - mode = KX_SceneActuator::KX_SCENE_SET_CAMERA; cam = (KX_Camera*) converter->FindGameObject(sceneact->camera); } - else - { - // TODO:warn user - } break; case ACT_SCENE_RESTART: { diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index b75662f01c9..aa15199b816 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -69,7 +69,22 @@ KX_Camera::~KX_Camera() } +CValue* KX_Camera::GetReplica() +{ + KX_Camera* replica = new KX_Camera(*this); + + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + ProcessReplica(replica); + + return replica; +} +void KX_Camera::ProcessReplica(KX_Camera* replica) +{ + KX_GameObject::ProcessReplica(replica); +} + MT_Transform KX_Camera::GetWorldToCamera() const { MT_Transform camtrans; diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index 34a3d2f2653..08f2bf3d1c1 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -134,6 +134,24 @@ public: KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, PyTypeObject *T = &Type); virtual ~KX_Camera(); + /** + * Inherited from CValue -- return a new copy of this + * instance allocated on the heap. Ownership of the new + * object belongs with the caller. + */ + virtual CValue* + GetReplica( + ); + + /** + * Inherited from CValue -- Makes sure any internal + * data owned by this class is deep copied. Called internally + */ + virtual void + ProcessReplica( + KX_Camera* replica + ); + MT_Transform GetWorldToCamera() const; MT_Transform GetCameraToWorld() const; diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index a37fce434be..7a9d144e92f 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -105,6 +105,15 @@ bool KX_SceneActuator::Update() { m_scene->SetActiveCamera(m_camera); } + else + { + // if no camera is set and the parent object is a camera, use it as the camera + SCA_IObject* parent = GetParent(); + if (parent->isA(&KX_Camera::Type)) + { + m_scene->SetActiveCamera((KX_Camera*)parent); + } + } break; default: break; -- cgit v1.2.3 From 6bb327badc63d65afe459e092059bf1d9c20b075 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 14 Apr 2008 22:45:28 +0000 Subject: BGE fix: keep reference count consist on source object when replicating property copy actuator --- source/gameengine/GameLogic/SCA_PropertyActuator.cpp | 8 ++++++++ source/gameengine/GameLogic/SCA_PropertyActuator.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 29642cd5a7b..24b040db1bc 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -183,6 +183,14 @@ GetReplica() { }; +void SCA_PropertyActuator::ProcessReplica() +{ + // no need to check for self reference like in the constructor: + // the replica will always have a different parent + if (m_sourceObj) + m_sourceObj->AddRef(); + SCA_IActuator::ProcessReplica(); +} diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index cdcda7a84e0..fc993c9fce2 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -77,6 +77,8 @@ public: GetReplica( ); + void ProcessReplica(); + virtual bool Update(); -- cgit v1.2.3 From 83c540189691afce0557b1588121564f615e4275 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 16 Apr 2008 08:48:49 +0000 Subject: replace magic numbers with constants for (G.vd->persp), view naming was also using persp as a flag which worked but isnt correct. --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 3b7f610b783..6bc91fcaa61 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -321,10 +321,10 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME) { - if (v3d->persp != 2) + if (v3d->persp != V3D_CAMOB) { ketsjiengine->EnableCameraOverride(startscenename); - ketsjiengine->SetCameraOverrideUseOrtho((v3d->persp == 0)); + ketsjiengine->SetCameraOverrideUseOrtho((v3d->persp == V3D_ORTHO)); ketsjiengine->SetCameraOverrideProjectionMatrix(projmat); ketsjiengine->SetCameraOverrideViewMatrix(viewmat); } -- cgit v1.2.3 From 867e12836b746b174743d0500e39343e1adb1b7f Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Wed, 16 Apr 2008 17:40:59 +0000 Subject: This patch spawns from this game engine issue: [#7113] GE crash pressing as soon as P on 64 bit Note: glext.h has been removed from the source If you get errors compiling with it you have 2 options download/install glext.h (preferred method) or set WITH_BF_GLEXT=false If your a user and having problems with game engine try setting the env var: WITHOUT_GLEXT 1 Kent --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 21 +- source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 28 +- source/gameengine/BlenderRoutines/Makefile | 4 + source/gameengine/BlenderRoutines/SConscript | 3 + source/gameengine/GamePlayer/common/Makefile | 4 + .../GamePlayer/ghost/GPG_Application.cpp | 28 +- source/gameengine/GamePlayer/ghost/Makefile | 3 + source/gameengine/GamePlayer/ghost/SConscript | 4 + source/gameengine/Ketsji/BL_Texture.cpp | 107 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 24 +- source/gameengine/Ketsji/Makefile | 5 + source/gameengine/Ketsji/SConscript | 3 + source/gameengine/Rasterizer/Makefile | 5 + .../Rasterizer/RAS_OpenGLRasterizer/Makefile | 4 + .../RAS_GLExtensionManager.cpp | 159 +- .../RAS_OpenGLRasterizer/RAS_GLExtensionManager.h | 14 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 879 +-- .../RAS_VAOpenGLRasterizer.cpp | 76 +- .../Rasterizer/RAS_OpenGLRasterizer/SConscript | 3 + .../Rasterizer/RAS_OpenGLRasterizer/glext.h | 6495 -------------------- source/gameengine/Rasterizer/SConscript | 4 + 21 files changed, 730 insertions(+), 7143 deletions(-) delete mode 100644 source/gameengine/Rasterizer/RAS_OpenGLRasterizer/glext.h (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 6bc91fcaa61..4f282b6c8cb 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -36,6 +36,7 @@ #endif #include +#include #ifdef WIN32 // don't show stl-warnings @@ -160,15 +161,17 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0); bool usemat = false; - #ifdef GL_ARB_multitexture - if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) { - usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 0) != 0); - int unitmax=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax); - bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX; - //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl; - } else { - bgl::max_texture_units = 0; + #if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) { + usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 0) != 0); + int unitmax=0; + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax); + bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX; + //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl; + } else { + bgl::max_texture_units = 0; + } } #endif diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 413b16bc300..54ceec306e2 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -186,28 +186,30 @@ void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface void DisableForText() { - if(glIsEnabled(GL_BLEND)) - glDisable(GL_BLEND); + if(glIsEnabled(GL_BLEND)) glDisable(GL_BLEND); if(glIsEnabled(GL_LIGHTING)) { glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); } -#ifdef GL_ARB_multitexture - for(int i=0; i #include +#include /********************************** * Begin Blender include block @@ -509,20 +510,25 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); bool useVertexArrays = SYS_GetCommandLineInt(syshandle,"vertexarrays",1) != 0; bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DIAPLAY_LISTS) != 0); -#ifdef GL_ARB_multitexture - int gameflag =(G.fileflags & G_FILE_GAME_MAT); - // ---------------------------------- - if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) { - m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0); - int unitmax=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax); - bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX; - //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl; + +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + int gameflag =(G.fileflags & G_FILE_GAME_MAT); + + if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) { + m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0); + int unitmax=0; + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax); + bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX; + //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl; + } else { + bgl::max_texture_units = 0; + } } else { - bgl::max_texture_units = 0; + m_blendermat=0; } #else - m_blendermat=0; + m_blendermat=0; #endif//GL_ARB_multitexture // ---------------------------------- diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index 857b274cbae..3c32079c652 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -80,4 +80,7 @@ CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_GHOST)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) +ifeq ($(WITH_BF_GLEXT),true) + CPPFLAGS += -DWITH_GLEXT +endif diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index f76e926e6d4..cc2d7de8002 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -46,4 +46,8 @@ cflags = [] if env['OURPLATFORM']=='win32-vc': cflags = ['/GR'] +if env['WITH_BF_GLEXT'] == 1: + env['CPPFLAGS'].append('-DWITH_GLEXT') + + env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = [], libtype='player',priority=0, compileflags=cflags) diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index f6fb990fd4c..687b1af957d 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "BL_Material.h" #include "BL_Texture.h" @@ -360,10 +361,13 @@ unsigned int BL_Texture::GetTextureType() const int BL_Texture::GetMaxUnits() { GLint unit=0; -#ifdef GL_ARB_multitexture - if(RAS_EXT_support._ARB_multitexture) { - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &unit); - return (MAXTEX>=unit?unit:MAXTEX); + +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + if(RAS_EXT_support._ARB_multitexture) { + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &unit); + return (MAXTEX>=unit?unit:MAXTEX); + } } #endif return 0; @@ -371,28 +375,33 @@ int BL_Texture::GetMaxUnits() void BL_Texture::ActivateFirst() { -#ifdef GL_ARB_multitexture - if(RAS_EXT_support._ARB_multitexture) - bgl::blActiveTextureARB(GL_TEXTURE0_ARB); +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + if(RAS_EXT_support._ARB_multitexture) + bgl::blActiveTextureARB(GL_TEXTURE0_ARB); + } #endif } void BL_Texture::ActivateUnit(int unit) { -#ifdef GL_ARB_multitexture - if(RAS_EXT_support._ARB_multitexture) - if(unit <= MAXTEX) - bgl::blActiveTextureARB(GL_TEXTURE0_ARB+unit); +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + if(RAS_EXT_support._ARB_multitexture) + if(unit <= MAXTEX) + bgl::blActiveTextureARB(GL_TEXTURE0_ARB+unit); + } #endif } void BL_Texture::DisableUnit() { -#ifdef GL_ARB_multitexture - if(RAS_EXT_support._ARB_multitexture) - bgl::blActiveTextureARB(GL_TEXTURE0_ARB+mUnit); - +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + if(RAS_EXT_support._ARB_multitexture) + bgl::blActiveTextureARB(GL_TEXTURE0_ARB+mUnit); + } #endif @@ -420,52 +429,54 @@ void BL_Texture::DisableUnit() void BL_Texture::DisableAllTextures() { -#ifdef GL_ARB_multitexture - glDisable(GL_BLEND); - for(int i=0; i + #ifdef WIN32 #pragma warning (disable : 4786) #endif //WIN32 @@ -335,16 +337,18 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) pprint(""); } #endif -#ifdef GL_ARB_multitexture - support = ext._ARB_multitexture; - count = 1; - pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no.")); - if(support){ - pprint(" ----------Details----------"); - int units=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units); - pprint(" Max texture units available. " << units); - pprint(""); +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + support = ext._ARB_multitexture; + count = 1; + pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no.")); + if(support){ + pprint(" ----------Details----------"); + int units=0; + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units); + pprint(" Max texture units available. " << units); + pprint(""); + } } #endif #ifdef GL_ARB_texture_env_combine diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index f7813c80a59..502e8949e7a 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -65,6 +65,11 @@ CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I../../blender/imbuf CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include +ifeq ($(WITH_BF_GLEXT),true) + CPPFLAGS += -DWITH_GLEXT +endif + + ########################### SOURCEDIR = source/gameengine/Ketsji diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index cb213522f1d..c7c80345796 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -25,6 +25,9 @@ if env['OURPLATFORM'] == 'win32-vc': cflags.append('/GR') cflags.append('/Ox') +if env['WITH_BF_GLEXT'] == 1: + env['CPPFLAGS'].append('-DWITH_GLEXT') + incs += ' ' + env['BF_SOLID_INC'] incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_SDL_INC'] diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile index 5f8eace8adb..7cda8ae5376 100644 --- a/source/gameengine/Rasterizer/Makefile +++ b/source/gameengine/Rasterizer/Makefile @@ -45,6 +45,11 @@ CPPFLAGS += -I../../kernel/gen_system ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings endif + +ifeq ($(WITH_BF_GLEXT),true) + CPPFLAGS += -DWITH_GLEXT +endif + ############### SOURCEDIR = source/gameengine/Rasterizer diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile index 40f3fc50005..a63ac28f432 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile @@ -47,3 +47,7 @@ CPPFLAGS += -I.. ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings endif + +ifeq ($(WITH_BF_GLEXT),true) + CPPFLAGS += -DWITH_GLEXT +endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp index 26b00f02e7d..77a72c064ee 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include "STR_String.h" @@ -333,43 +334,42 @@ PFNGLPNTRIANGLESFATIPROC glPNTrianglesfATI; BL_EXTInfo RAS_EXT_support; - #ifdef GL_ARB_multitexture int max_texture_units = 2; - PFNGLACTIVETEXTUREARBPROC blActiveTextureARB; - PFNGLCLIENTACTIVETEXTUREARBPROC blClientActiveTextureARB; - PFNGLMULTITEXCOORD1DARBPROC blMultiTexCoord1dARB; - PFNGLMULTITEXCOORD1DVARBPROC blMultiTexCoord1dvARB; - PFNGLMULTITEXCOORD1FARBPROC blMultiTexCoord1fARB; - PFNGLMULTITEXCOORD1FVARBPROC blMultiTexCoord1fvARB; - PFNGLMULTITEXCOORD1IARBPROC blMultiTexCoord1iARB; - PFNGLMULTITEXCOORD1IVARBPROC blMultiTexCoord1ivARB; - PFNGLMULTITEXCOORD1SARBPROC blMultiTexCoord1sARB; - PFNGLMULTITEXCOORD1SVARBPROC blMultiTexCoord1svARB; - PFNGLMULTITEXCOORD2DARBPROC blMultiTexCoord2dARB; - PFNGLMULTITEXCOORD2DVARBPROC blMultiTexCoord2dvARB; - PFNGLMULTITEXCOORD2FARBPROC blMultiTexCoord2fARB; - PFNGLMULTITEXCOORD2FVARBPROC blMultiTexCoord2fvARB; - PFNGLMULTITEXCOORD2IARBPROC blMultiTexCoord2iARB; - PFNGLMULTITEXCOORD2IVARBPROC blMultiTexCoord2ivARB; - PFNGLMULTITEXCOORD2SARBPROC blMultiTexCoord2sARB; - PFNGLMULTITEXCOORD2SVARBPROC blMultiTexCoord2svARB; - PFNGLMULTITEXCOORD3DARBPROC blMultiTexCoord3dARB; - PFNGLMULTITEXCOORD3DVARBPROC blMultiTexCoord3dvARB; - PFNGLMULTITEXCOORD3FARBPROC blMultiTexCoord3fARB; - PFNGLMULTITEXCOORD3FVARBPROC blMultiTexCoord3fvARB; - PFNGLMULTITEXCOORD3IARBPROC blMultiTexCoord3iARB; - PFNGLMULTITEXCOORD3IVARBPROC blMultiTexCoord3ivARB; - PFNGLMULTITEXCOORD3SARBPROC blMultiTexCoord3sARB; - PFNGLMULTITEXCOORD3SVARBPROC blMultiTexCoord3svARB; - PFNGLMULTITEXCOORD4DARBPROC blMultiTexCoord4dARB; - PFNGLMULTITEXCOORD4DVARBPROC blMultiTexCoord4dvARB; - PFNGLMULTITEXCOORD4FARBPROC blMultiTexCoord4fARB; - PFNGLMULTITEXCOORD4FVARBPROC blMultiTexCoord4fvARB; - PFNGLMULTITEXCOORD4IARBPROC blMultiTexCoord4iARB; - PFNGLMULTITEXCOORD4IVARBPROC blMultiTexCoord4ivARB; - PFNGLMULTITEXCOORD4SARBPROC blMultiTexCoord4sARB; - PFNGLMULTITEXCOORD4SVARBPROC blMultiTexCoord4svARB; +PFNGLACTIVETEXTUREARBPROC blActiveTextureARB; +PFNGLCLIENTACTIVETEXTUREARBPROC blClientActiveTextureARB; +PFNGLMULTITEXCOORD1DARBPROC blMultiTexCoord1dARB; +PFNGLMULTITEXCOORD1DVARBPROC blMultiTexCoord1dvARB; +PFNGLMULTITEXCOORD1FARBPROC blMultiTexCoord1fARB; +PFNGLMULTITEXCOORD1FVARBPROC blMultiTexCoord1fvARB; +PFNGLMULTITEXCOORD1IARBPROC blMultiTexCoord1iARB; +PFNGLMULTITEXCOORD1IVARBPROC blMultiTexCoord1ivARB; +PFNGLMULTITEXCOORD1SARBPROC blMultiTexCoord1sARB; +PFNGLMULTITEXCOORD1SVARBPROC blMultiTexCoord1svARB; +PFNGLMULTITEXCOORD2DARBPROC blMultiTexCoord2dARB; +PFNGLMULTITEXCOORD2DVARBPROC blMultiTexCoord2dvARB; +PFNGLMULTITEXCOORD2FARBPROC blMultiTexCoord2fARB; +PFNGLMULTITEXCOORD2FVARBPROC blMultiTexCoord2fvARB; +PFNGLMULTITEXCOORD2IARBPROC blMultiTexCoord2iARB; +PFNGLMULTITEXCOORD2IVARBPROC blMultiTexCoord2ivARB; +PFNGLMULTITEXCOORD2SARBPROC blMultiTexCoord2sARB; +PFNGLMULTITEXCOORD2SVARBPROC blMultiTexCoord2svARB; +PFNGLMULTITEXCOORD3DARBPROC blMultiTexCoord3dARB; +PFNGLMULTITEXCOORD3DVARBPROC blMultiTexCoord3dvARB; +PFNGLMULTITEXCOORD3FARBPROC blMultiTexCoord3fARB; +PFNGLMULTITEXCOORD3FVARBPROC blMultiTexCoord3fvARB; +PFNGLMULTITEXCOORD3IARBPROC blMultiTexCoord3iARB; +PFNGLMULTITEXCOORD3IVARBPROC blMultiTexCoord3ivARB; +PFNGLMULTITEXCOORD3SARBPROC blMultiTexCoord3sARB; +PFNGLMULTITEXCOORD3SVARBPROC blMultiTexCoord3svARB; +PFNGLMULTITEXCOORD4DARBPROC blMultiTexCoord4dARB; +PFNGLMULTITEXCOORD4DVARBPROC blMultiTexCoord4dvARB; +PFNGLMULTITEXCOORD4FARBPROC blMultiTexCoord4fARB; +PFNGLMULTITEXCOORD4FVARBPROC blMultiTexCoord4fvARB; +PFNGLMULTITEXCOORD4IARBPROC blMultiTexCoord4iARB; +PFNGLMULTITEXCOORD4IVARBPROC blMultiTexCoord4ivARB; +PFNGLMULTITEXCOORD4SARBPROC blMultiTexCoord4sARB; +PFNGLMULTITEXCOORD4SVARBPROC blMultiTexCoord4svARB; #endif #ifdef GL_ARB_shader_objects @@ -497,50 +497,51 @@ static void LinkExtensions() } #endif -#ifdef GL_ARB_multitexture - if (QueryExtension("GL_ARB_multitexture")) - { - bgl::blActiveTextureARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glActiveTextureARB")); - bgl::blClientActiveTextureARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glClientActiveTextureARB")); - bgl::blMultiTexCoord1dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dARB")); - bgl::blMultiTexCoord1dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dvARB")); - bgl::blMultiTexCoord1fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fARB")); - bgl::blMultiTexCoord1fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fvARB")); - bgl::blMultiTexCoord1iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1iARB")); - bgl::blMultiTexCoord1ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1ivARB")); - bgl::blMultiTexCoord1sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1sARB")); - bgl::blMultiTexCoord1svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1svARB")); - bgl::blMultiTexCoord2dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dARB")); - bgl::blMultiTexCoord2dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dvARB")); - bgl::blMultiTexCoord2fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fARB")); - bgl::blMultiTexCoord2fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fvARB")); - bgl::blMultiTexCoord2iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2iARB")); - bgl::blMultiTexCoord2ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2ivARB")); - bgl::blMultiTexCoord2sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2sARB")); - bgl::blMultiTexCoord2svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2svARB")); - bgl::blMultiTexCoord3dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dARB")); - bgl::blMultiTexCoord3dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dvARB")); - bgl::blMultiTexCoord3fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fARB")); - bgl::blMultiTexCoord3fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fvARB")); - bgl::blMultiTexCoord3iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3iARB")); - bgl::blMultiTexCoord3ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3ivARB")); - bgl::blMultiTexCoord3sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3sARB")); - bgl::blMultiTexCoord3svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3svARB")); - bgl::blMultiTexCoord4dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dARB")); - bgl::blMultiTexCoord4dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dvARB")); - bgl::blMultiTexCoord4fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fARB")); - bgl::blMultiTexCoord4fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fvARB")); - bgl::blMultiTexCoord4iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4iARB")); - bgl::blMultiTexCoord4ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4ivARB")); - bgl::blMultiTexCoord4sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4sARB")); - bgl::blMultiTexCoord4svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4svARB")); - if (bgl::blActiveTextureARB && bgl::blClientActiveTextureARB && bgl::blMultiTexCoord1dARB && bgl::blMultiTexCoord1dvARB && bgl::blMultiTexCoord1fARB && bgl::blMultiTexCoord1fvARB && bgl::blMultiTexCoord1iARB && bgl::blMultiTexCoord1ivARB && bgl::blMultiTexCoord1sARB && bgl::blMultiTexCoord1svARB && bgl::blMultiTexCoord2dARB && bgl::blMultiTexCoord2dvARB && bgl::blMultiTexCoord2fARB && bgl::blMultiTexCoord2fvARB && bgl::blMultiTexCoord2iARB && bgl::blMultiTexCoord2ivARB && bgl::blMultiTexCoord2sARB && bgl::blMultiTexCoord2svARB && bgl::blMultiTexCoord3dARB && bgl::blMultiTexCoord3dvARB && bgl::blMultiTexCoord3fARB && bgl::blMultiTexCoord3fvARB && bgl::blMultiTexCoord3iARB && bgl::blMultiTexCoord3ivARB && bgl::blMultiTexCoord3sARB && bgl::blMultiTexCoord3svARB && bgl::blMultiTexCoord4dARB && bgl::blMultiTexCoord4dvARB && bgl::blMultiTexCoord4fARB && bgl::blMultiTexCoord4fvARB && bgl::blMultiTexCoord4iARB && bgl::blMultiTexCoord4ivARB && bgl::blMultiTexCoord4sARB && bgl::blMultiTexCoord4svARB) { - EnableExtension(_GL_ARB_multitexture); - RAS_EXT_support._ARB_multitexture = 1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_multitexture" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_multitexture implementation is broken!" << std::endl; +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + if (QueryExtension("GL_ARB_multitexture")) { + bgl::blActiveTextureARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glActiveTextureARB")); + bgl::blClientActiveTextureARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glClientActiveTextureARB")); + bgl::blMultiTexCoord1dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dARB")); + bgl::blMultiTexCoord1dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dvARB")); + bgl::blMultiTexCoord1fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fARB")); + bgl::blMultiTexCoord1fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fvARB")); + bgl::blMultiTexCoord1iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1iARB")); + bgl::blMultiTexCoord1ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1ivARB")); + bgl::blMultiTexCoord1sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1sARB")); + bgl::blMultiTexCoord1svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1svARB")); + bgl::blMultiTexCoord2dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dARB")); + bgl::blMultiTexCoord2dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dvARB")); + bgl::blMultiTexCoord2fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fARB")); + bgl::blMultiTexCoord2fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fvARB")); + bgl::blMultiTexCoord2iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2iARB")); + bgl::blMultiTexCoord2ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2ivARB")); + bgl::blMultiTexCoord2sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2sARB")); + bgl::blMultiTexCoord2svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2svARB")); + bgl::blMultiTexCoord3dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dARB")); + bgl::blMultiTexCoord3dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dvARB")); + bgl::blMultiTexCoord3fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fARB")); + bgl::blMultiTexCoord3fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fvARB")); + bgl::blMultiTexCoord3iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3iARB")); + bgl::blMultiTexCoord3ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3ivARB")); + bgl::blMultiTexCoord3sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3sARB")); + bgl::blMultiTexCoord3svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3svARB")); + bgl::blMultiTexCoord4dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dARB")); + bgl::blMultiTexCoord4dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dvARB")); + bgl::blMultiTexCoord4fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fARB")); + bgl::blMultiTexCoord4fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fvARB")); + bgl::blMultiTexCoord4iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4iARB")); + bgl::blMultiTexCoord4ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4ivARB")); + bgl::blMultiTexCoord4sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4sARB")); + bgl::blMultiTexCoord4svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4svARB")); + if (bgl::blActiveTextureARB && bgl::blClientActiveTextureARB && bgl::blMultiTexCoord1dARB && bgl::blMultiTexCoord1dvARB && bgl::blMultiTexCoord1fARB && bgl::blMultiTexCoord1fvARB && bgl::blMultiTexCoord1iARB && bgl::blMultiTexCoord1ivARB && bgl::blMultiTexCoord1sARB && bgl::blMultiTexCoord1svARB && bgl::blMultiTexCoord2dARB && bgl::blMultiTexCoord2dvARB && bgl::blMultiTexCoord2fARB && bgl::blMultiTexCoord2fvARB && bgl::blMultiTexCoord2iARB && bgl::blMultiTexCoord2ivARB && bgl::blMultiTexCoord2sARB && bgl::blMultiTexCoord2svARB && bgl::blMultiTexCoord3dARB && bgl::blMultiTexCoord3dvARB && bgl::blMultiTexCoord3fARB && bgl::blMultiTexCoord3fvARB && bgl::blMultiTexCoord3iARB && bgl::blMultiTexCoord3ivARB && bgl::blMultiTexCoord3sARB && bgl::blMultiTexCoord3svARB && bgl::blMultiTexCoord4dARB && bgl::blMultiTexCoord4dvARB && bgl::blMultiTexCoord4fARB && bgl::blMultiTexCoord4fvARB && bgl::blMultiTexCoord4iARB && bgl::blMultiTexCoord4ivARB && bgl::blMultiTexCoord4sARB && bgl::blMultiTexCoord4svARB) { + EnableExtension(_GL_ARB_multitexture); + RAS_EXT_support._ARB_multitexture = 1; + if (doDebugMessages) + std::cout << "Enabled GL_ARB_multitexture" << std::endl; + } else { + std::cout << "ERROR: GL_ARB_multitexture implementation is broken!" << std::endl; + } } } #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h index 7b1c745832f..ae57ae77fb8 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h @@ -42,7 +42,6 @@ # define GL_GLEXT_LEGACY 1 # include # include -# undef __glext_h_ #else /* UNIX */ # define __glext_h_ @@ -52,12 +51,21 @@ # undef __glext_h_ #endif +#ifdef WITH_GLEXT +#ifdef WIN32 +# include +#elif defined(__APPLE__) +# include +# undef __glext_h_ +# else +# include +# endif +#endif + #ifdef __sgi # undef GL_ARB_vertex_program #endif -#include "glext.h" - #include "EXT_separate_specular_color.h" #include "ARB_multitexture.h" namespace bgl diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 4f9c3a1bfb3..40252e7aff9 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -30,6 +30,7 @@ */ #include +#include #include "RAS_OpenGLRasterizer.h" @@ -1222,37 +1223,36 @@ void RAS_OpenGLRasterizer::SetAttrib(int type) void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv, int enabled) { -#ifdef GL_ARB_multitexture - if(bgl::RAS_EXT_support._ARB_multitexture) - { - for(int unit=0; unitGetEnabled(); - - if (!numindices) - break; - - int vindex=0; +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + if (!getenv("WITHOUT_GLEXT")) { + GLenum drawmode; switch (mode) { + case 0: + drawmode = GL_TRIANGLES; + break; case 1: - { - glBegin(GL_LINES); - vindex=0; - for (unsigned int i=0;iGetEnabled(); + + if (!numindices) + break; + + int vindex=0; + switch (mode) { - glBegin(GL_QUADS); - vindex=0; - if (useObjectColor) + case 1: { - for (unsigned int i=0;iGetEnabled(); + for (vt=0;vtGetEnabled(); - if (!numindices) - continue; + if (!numindices) + continue; - int vindex=0; - switch (mode) - { - case 1: + int vindex=0; + switch (mode) { - glBegin(GL_LINES); - vindex=0; - for (unsigned int i=0;i #ifdef WIN32 #include @@ -294,50 +295,51 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv, int enabled) { -#ifdef GL_ARB_multitexture - if(bgl::RAS_EXT_support._ARB_multitexture) - { - for(int unit=0; unitgetFlag() & TV_2NDUV && tv->getUnit() == unit ) { - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2()); - continue; - } - switch(m_texco[unit]) + for(int unit=0; unitgetLocalXYZ()); - break; - case RAS_TEXCO_UV1: - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV1()); - break; - case RAS_TEXCO_NORM: - glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getNormal()); - break; - case RAS_TEXTANGENT: - glTexCoordPointer(4, GL_FLOAT, sizeof(RAS_TexVert),tv->getTangent()); - break; - case RAS_TEXCO_UV2: - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV2()); - break; + bgl::blClientActiveTextureARB(GL_TEXTURE0_ARB+unit); + + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if( tv->getFlag() & TV_2NDUV && tv->getUnit() == unit ) { + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2()); + continue; + } + switch(m_texco[unit]) + { + case RAS_TEXCO_DISABLE: + case RAS_TEXCO_OBJECT: + case RAS_TEXCO_GEN: + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + break; + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getLocalXYZ()); + break; + case RAS_TEXCO_UV1: + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV1()); + break; + case RAS_TEXCO_NORM: + glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getNormal()); + break; + case RAS_TEXTANGENT: + glTexCoordPointer(4, GL_FLOAT, sizeof(RAS_TexVert),tv->getTangent()); + break; + case RAS_TEXCO_UV2: + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV2()); + break; + } } } - } #ifdef GL_ARB_vertex_program - if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program) - bgl::blVertexAttrib4fvARB(1/*tangent*/, tv->getTangent()); + if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program) + bgl::blVertexAttrib4fvARB(1/*tangent*/, tv->getTangent()); #endif - + } #endif } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index 039bc3db8df..b4d5b8b71de 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -1,6 +1,9 @@ #!/usr/bin/python Import ('env') +if env['WITH_BF_GLEXT'] == 1: + env['CPPFLAGS'].append('-DWITH_GLEXT') + sources = env.Glob('*.cpp') #'RAS_GLExtensionManager.cpp RAS_ListRasterizer.cpp RAS_OpenGLRasterizer.cpp RAS_VAOpenGLRasterizer.cpp' incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer' diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/glext.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/glext.h deleted file mode 100644 index 7bb8e6e7cc7..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/glext.h +++ /dev/null @@ -1,6495 +0,0 @@ -#ifndef __glext_h_ -#define __glext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2005/06/20 */ -/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define GL_GLEXT_VERSION 29 - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; /* native character */ -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and program/shader text */ -typedef char GLcharARB; /* native character */ -typedef unsigned int GLhandleARB; /* shader object handle */ -#endif - -/* GL types for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -GLAPI void APIENTRY glBlendEquation (GLenum); -GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogram (GLenum); -GLAPI void APIENTRY glResetMinmax (GLenum); -GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum); -GLAPI void APIENTRY glClientActiveTexture (GLenum); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glFogCoordf (GLfloat); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *); -GLAPI void APIENTRY glFogCoordd (GLdouble); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); -GLAPI void APIENTRY glPointParameteri (GLenum, GLint); -GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); -GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos2i (GLint, GLint); -GLAPI void APIENTRY glWindowPos2iv (const GLint *); -GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *); -GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3iv (const GLint *); -GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQuery (GLuint); -GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); -GLAPI void APIENTRY glEndQuery (GLenum); -GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint); -GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); -GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); -GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); -GLAPI void APIENTRY glAttachShader (GLuint, GLuint); -GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); -GLAPI void APIENTRY glCompileShader (GLuint); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum); -GLAPI void APIENTRY glDeleteProgram (GLuint); -GLAPI void APIENTRY glDeleteShader (GLuint); -GLAPI void APIENTRY glDetachShader (GLuint, GLuint); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); -GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgram (GLuint); -GLAPI GLboolean APIENTRY glIsShader (GLuint); -GLAPI void APIENTRY glLinkProgram (GLuint); -GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); -GLAPI void APIENTRY glUseProgram (GLuint); -GLAPI void APIENTRY glUniform1f (GLint, GLfloat); -GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1i (GLint, GLint); -GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glValidateProgram (GLuint); -GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); -GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); -GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); -GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); -GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); -GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexBlendARB (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); -GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); -GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); -GLAPI void APIENTRY glEndQueryARB (GLenum); -GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); -GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); -GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1iARB (GLint, GLint); -GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogramEXT (GLenum); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_EXT_color_matrix -#define GL_EXT_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint); -GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -GLAPI void APIENTRY glDeformSGIX (GLbitfield); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum); -GLAPI void APIENTRY glTextureLightEXT (GLenum); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); -GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); -GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); -GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *); -GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); -GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); -GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); -GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); -GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFinishFenceNV (GLuint); -GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); -GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); -GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); -GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); -GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); -GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); -GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); -GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); -GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#endif - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index 2097540ed7e..c71e371fedc 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -3,6 +3,10 @@ Import ('env') sources = env.Glob('*.cpp') +if env['WITH_BF_GLEXT'] == 1: + env['CPPFLAGS'].append('-DWITH_GLEXT') + + incs = '. #source/kernel/gen_system #intern/string #intern/moto/include' if env['OURPLATFORM']=='win32-vc': -- cgit v1.2.3 From 35e655cd5ac4c4dcaaf10af7636926770af353d6 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 16 Apr 2008 18:47:36 +0000 Subject: BGE: Fix restitution: object will now bounce according to material restitution setting --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 5771e7f1dc7..c9d346e316d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -581,7 +581,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType) { m_solver = new btSequentialImpulseConstraintSolver(); - + ((btSequentialImpulseConstraintSolver*)m_solver)->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); break; } } -- cgit v1.2.3 From 5d0a207ecb843c4c73be897cfccbf3a0d2db574b Mon Sep 17 00:00:00 2001 From: Chris Want Date: Wed, 16 Apr 2008 22:40:48 +0000 Subject: Patch from GSR that a) fixes a whole bunch of GPL/BL license blocks that were previously missed; and b) greatly increase my ohloh stats! --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderCanvas.h | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderGL.h | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp | 9 +++------ source/gameengine/BlenderRoutines/KX_BlenderSystem.h | 9 +++------ source/gameengine/BlenderRoutines/Makefile | 9 +++------ source/gameengine/CMakeLists.txt | 9 +++------ source/gameengine/Converter/BL_ActionActuator.cpp | 9 +++------ source/gameengine/Converter/BL_ActionActuator.h | 9 +++------ source/gameengine/Converter/BL_ArmatureObject.cpp | 9 +++------ source/gameengine/Converter/BL_ArmatureObject.h | 9 +++------ source/gameengine/Converter/BL_BlenderDataConversion.cpp | 9 +++------ source/gameengine/Converter/BL_BlenderDataConversion.h | 9 +++------ source/gameengine/Converter/BL_DeformableGameObject.cpp | 9 +++------ source/gameengine/Converter/BL_DeformableGameObject.h | 9 +++------ source/gameengine/Converter/BL_MeshDeformer.cpp | 9 +++------ source/gameengine/Converter/BL_MeshDeformer.h | 9 +++------ source/gameengine/Converter/BL_SkinDeformer.cpp | 9 +++------ source/gameengine/Converter/BL_SkinDeformer.h | 9 +++------ source/gameengine/Converter/BL_SkinMeshObject.cpp | 9 +++------ source/gameengine/Converter/BL_SkinMeshObject.h | 9 +++------ source/gameengine/Converter/BlenderWorldInfo.cpp | 9 +++------ source/gameengine/Converter/BlenderWorldInfo.h | 9 +++------ source/gameengine/Converter/CMakeLists.txt | 9 +++------ source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp | 9 +++------ source/gameengine/Converter/KX_BlenderScalarInterpolator.h | 9 +++------ source/gameengine/Converter/KX_BlenderSceneConverter.cpp | 9 +++------ source/gameengine/Converter/KX_BlenderSceneConverter.h | 9 +++------ source/gameengine/Converter/KX_ConvertActuators.cpp | 9 +++------ source/gameengine/Converter/KX_ConvertActuators.h | 9 +++------ source/gameengine/Converter/KX_ConvertControllers.cpp | 9 +++------ source/gameengine/Converter/KX_ConvertControllers.h | 9 +++------ source/gameengine/Converter/KX_ConvertProperties.cpp | 9 +++------ source/gameengine/Converter/KX_ConvertProperties.h | 9 +++------ source/gameengine/Converter/KX_ConvertSensors.cpp | 9 +++------ source/gameengine/Converter/KX_ConvertSensors.h | 9 +++------ source/gameengine/Converter/KX_IpoConvert.cpp | 9 +++------ source/gameengine/Converter/KX_IpoConvert.h | 9 +++------ source/gameengine/Converter/Makefile | 9 +++------ source/gameengine/Expressions/CMakeLists.txt | 9 +++------ source/gameengine/Expressions/EXP_C-Api.cpp | 9 +++------ source/gameengine/Expressions/EXP_C-Api.h | 9 +++------ source/gameengine/Expressions/IdentifierExpr.cpp | 9 +++------ source/gameengine/Expressions/IdentifierExpr.h | 9 +++------ source/gameengine/Expressions/KX_HashedPtr.cpp | 9 +++------ source/gameengine/Expressions/KX_HashedPtr.h | 9 +++------ source/gameengine/Expressions/KX_Python.h | 9 +++------ source/gameengine/Expressions/KX_Python_dynamic.h | 9 +++------ source/gameengine/Expressions/KX_Python_static.h | 9 +++------ source/gameengine/Expressions/Makefile | 9 +++------ source/gameengine/Expressions/PyObjectPlus.cpp | 9 +++------ source/gameengine/Expressions/PyObjectPlus.h | 9 +++------ source/gameengine/Expressions/VoidValue.h | 9 +++------ source/gameengine/GameLogic/CMakeLists.txt | 9 +++------ source/gameengine/GameLogic/Joystick/Makefile | 9 +++------ source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 9 +++------ source/gameengine/GameLogic/Joystick/SCA_Joystick.h | 9 +++------ source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h | 9 +++------ source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp | 9 +++------ source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h | 9 +++------ source/gameengine/GameLogic/Makefile | 9 +++------ source/gameengine/GameLogic/SCA_ANDController.cpp | 9 +++------ source/gameengine/GameLogic/SCA_ANDController.h | 9 +++------ source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_AlwaysEventManager.h | 9 +++------ source/gameengine/GameLogic/SCA_AlwaysSensor.cpp | 9 +++------ source/gameengine/GameLogic/SCA_AlwaysSensor.h | 9 +++------ source/gameengine/GameLogic/SCA_EventManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_EventManager.h | 9 +++------ source/gameengine/GameLogic/SCA_ExpressionController.cpp | 9 +++------ source/gameengine/GameLogic/SCA_ExpressionController.h | 9 +++------ source/gameengine/GameLogic/SCA_IActuator.cpp | 9 +++------ source/gameengine/GameLogic/SCA_IActuator.h | 9 +++------ source/gameengine/GameLogic/SCA_IController.cpp | 9 +++------ source/gameengine/GameLogic/SCA_IController.h | 9 +++------ source/gameengine/GameLogic/SCA_IInputDevice.cpp | 9 +++------ source/gameengine/GameLogic/SCA_IInputDevice.h | 9 +++------ source/gameengine/GameLogic/SCA_ILogicBrick.cpp | 9 +++------ source/gameengine/GameLogic/SCA_ILogicBrick.h | 9 +++------ source/gameengine/GameLogic/SCA_IObject.cpp | 9 +++------ source/gameengine/GameLogic/SCA_IObject.h | 9 +++------ source/gameengine/GameLogic/SCA_IScene.cpp | 9 +++------ source/gameengine/GameLogic/SCA_IScene.h | 9 +++------ source/gameengine/GameLogic/SCA_ISensor.cpp | 9 +++------ source/gameengine/GameLogic/SCA_ISensor.h | 9 +++------ source/gameengine/GameLogic/SCA_JoystickManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_JoystickManager.h | 9 +++------ source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 9 +++------ source/gameengine/GameLogic/SCA_JoystickSensor.h | 9 +++------ source/gameengine/GameLogic/SCA_KeyboardManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_KeyboardManager.h | 9 +++------ source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 9 +++------ source/gameengine/GameLogic/SCA_KeyboardSensor.h | 9 +++------ source/gameengine/GameLogic/SCA_LogicManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_LogicManager.h | 9 +++------ source/gameengine/GameLogic/SCA_MouseManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_MouseManager.h | 9 +++------ source/gameengine/GameLogic/SCA_MouseSensor.cpp | 9 +++------ source/gameengine/GameLogic/SCA_MouseSensor.h | 9 +++------ source/gameengine/GameLogic/SCA_ORController.cpp | 9 +++------ source/gameengine/GameLogic/SCA_ORController.h | 9 +++------ source/gameengine/GameLogic/SCA_PropertyActuator.cpp | 9 +++------ source/gameengine/GameLogic/SCA_PropertyActuator.h | 9 +++------ source/gameengine/GameLogic/SCA_PropertyEventManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_PropertyEventManager.h | 9 +++------ source/gameengine/GameLogic/SCA_PropertySensor.cpp | 9 +++------ source/gameengine/GameLogic/SCA_PropertySensor.h | 9 +++------ source/gameengine/GameLogic/SCA_PythonController.cpp | 9 +++------ source/gameengine/GameLogic/SCA_PythonController.h | 9 +++------ source/gameengine/GameLogic/SCA_RandomActuator.cpp | 9 +++------ source/gameengine/GameLogic/SCA_RandomActuator.h | 9 +++------ source/gameengine/GameLogic/SCA_RandomEventManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_RandomEventManager.h | 9 +++------ source/gameengine/GameLogic/SCA_RandomNumberGenerator.h | 9 +++------ source/gameengine/GameLogic/SCA_RandomSensor.cpp | 9 +++------ source/gameengine/GameLogic/SCA_RandomSensor.h | 9 +++------ source/gameengine/GameLogic/SCA_TimeEventManager.cpp | 9 +++------ source/gameengine/GameLogic/SCA_TimeEventManager.h | 9 +++------ source/gameengine/GamePlayer/CMakeLists.txt | 9 +++------ source/gameengine/GamePlayer/Makefile | 9 +++------ source/gameengine/GamePlayer/common/CMakeLists.txt | 9 +++------ source/gameengine/GamePlayer/common/GPC_Canvas.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_Canvas.h | 9 +++------ source/gameengine/GamePlayer/common/GPC_Engine.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_Engine.h | 9 +++------ source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h | 9 +++------ source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_MouseDevice.h | 9 +++------ source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h | 9 +++------ source/gameengine/GamePlayer/common/GPC_RawImage.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_RawImage.h | 9 +++------ .../gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.h | 9 +++------ source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_RawLogoArrays.h | 9 +++------ source/gameengine/GamePlayer/common/GPC_RenderTools.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_RenderTools.h | 9 +++------ source/gameengine/GamePlayer/common/GPC_System.cpp | 9 +++------ source/gameengine/GamePlayer/common/GPC_System.h | 9 +++------ source/gameengine/GamePlayer/common/Makefile | 9 +++------ source/gameengine/GamePlayer/common/bmfont.cpp | 9 +++------ source/gameengine/GamePlayer/common/unix/GPU_Canvas.cpp | 9 +++------ source/gameengine/GamePlayer/common/unix/GPU_Canvas.h | 9 +++------ source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp | 9 +++------ source/gameengine/GamePlayer/common/unix/GPU_Engine.h | 9 +++------ .../gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.cpp | 9 +++------ source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.h | 9 +++------ source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h | 9 +++------ source/gameengine/GamePlayer/common/unix/GPU_System.cpp | 9 +++------ source/gameengine/GamePlayer/common/unix/GPU_System.h | 9 +++------ source/gameengine/GamePlayer/common/unix/Makefile | 9 +++------ source/gameengine/GamePlayer/common/windows/GPW_Canvas.cpp | 9 +++------ source/gameengine/GamePlayer/common/windows/GPW_Canvas.h | 9 +++------ source/gameengine/GamePlayer/common/windows/GPW_Engine.cpp | 9 +++------ source/gameengine/GamePlayer/common/windows/GPW_Engine.h | 9 +++------ .../GamePlayer/common/windows/GPW_KeyboardDevice.cpp | 9 +++------ .../gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.h | 9 +++------ source/gameengine/GamePlayer/common/windows/GPW_System.cpp | 9 +++------ source/gameengine/GamePlayer/common/windows/GPW_System.h | 9 +++------ source/gameengine/GamePlayer/common/windows/Makefile | 9 +++------ source/gameengine/GamePlayer/ghost/CMakeLists.txt | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_Application.h | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_Canvas.h | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_System.cpp | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_System.h | 9 +++------ source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 9 +++------ source/gameengine/GamePlayer/ghost/Makefile | 9 +++------ source/gameengine/Ketsji/CMakeLists.txt | 9 +++------ source/gameengine/Ketsji/KXNetwork/CMakeLists.txt | 9 +++------ source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp | 9 +++------ source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h | 9 +++------ .../gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp | 9 +++------ source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h | 9 +++------ source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 9 +++------ source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h | 9 +++------ .../gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp | 9 +++------ source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h | 9 +++------ source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp | 9 +++------ source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h | 9 +++------ source/gameengine/Ketsji/KXNetwork/Makefile | 9 +++------ source/gameengine/Ketsji/KX_CDActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_CDActuator.h | 9 +++------ source/gameengine/Ketsji/KX_Camera.cpp | 9 +++------ source/gameengine/Ketsji/KX_Camera.h | 9 +++------ source/gameengine/Ketsji/KX_CameraActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_CameraActuator.h | 9 +++------ source/gameengine/Ketsji/KX_CameraIpoSGController.cpp | 9 +++------ source/gameengine/Ketsji/KX_CameraIpoSGController.h | 9 +++------ source/gameengine/Ketsji/KX_ClientObjectInfo.h | 9 +++------ source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_ConstraintActuator.h | 9 +++------ source/gameengine/Ketsji/KX_ConstraintWrapper.cpp | 9 +++------ source/gameengine/Ketsji/KX_ConstraintWrapper.h | 9 +++------ source/gameengine/Ketsji/KX_ConvertPhysicsObject.h | 9 +++------ source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 9 +++------ source/gameengine/Ketsji/KX_EmptyObject.cpp | 9 +++------ source/gameengine/Ketsji/KX_EmptyObject.h | 9 +++------ source/gameengine/Ketsji/KX_GameActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_GameActuator.h | 9 +++------ source/gameengine/Ketsji/KX_GameObject.cpp | 9 +++------ source/gameengine/Ketsji/KX_GameObject.h | 9 +++------ source/gameengine/Ketsji/KX_IInterpolator.h | 9 +++------ source/gameengine/Ketsji/KX_IPOTransform.h | 9 +++------ source/gameengine/Ketsji/KX_IPO_SGController.cpp | 9 +++------ source/gameengine/Ketsji/KX_IPO_SGController.h | 9 +++------ source/gameengine/Ketsji/KX_IPhysicsController.cpp | 9 +++------ source/gameengine/Ketsji/KX_IPhysicsController.h | 9 +++------ source/gameengine/Ketsji/KX_IScalarInterpolator.h | 9 +++------ source/gameengine/Ketsji/KX_ISceneConverter.h | 9 +++------ source/gameengine/Ketsji/KX_ISystem.h | 9 +++------ source/gameengine/Ketsji/KX_IpoActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_IpoActuator.h | 9 +++------ source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 9 +++------ source/gameengine/Ketsji/KX_KetsjiEngine.h | 9 +++------ source/gameengine/Ketsji/KX_Light.cpp | 9 +++------ source/gameengine/Ketsji/KX_Light.h | 9 +++------ source/gameengine/Ketsji/KX_LightIpoSGController.cpp | 9 +++------ source/gameengine/Ketsji/KX_LightIpoSGController.h | 9 +++------ source/gameengine/Ketsji/KX_MeshProxy.cpp | 9 +++------ source/gameengine/Ketsji/KX_MeshProxy.h | 9 +++------ source/gameengine/Ketsji/KX_MotionState.cpp | 9 +++------ source/gameengine/Ketsji/KX_MotionState.h | 9 +++------ source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 9 +++------ source/gameengine/Ketsji/KX_MouseFocusSensor.h | 9 +++------ source/gameengine/Ketsji/KX_NearSensor.cpp | 9 +++------ source/gameengine/Ketsji/KX_NearSensor.h | 9 +++------ source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp | 9 +++------ source/gameengine/Ketsji/KX_ObColorIpoSGController.h | 9 +++------ source/gameengine/Ketsji/KX_ObjectActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_ObjectActuator.h | 9 +++------ source/gameengine/Ketsji/KX_OdePhysicsController.cpp | 4 ++-- source/gameengine/Ketsji/KX_OdePhysicsController.h | 4 ++-- source/gameengine/Ketsji/KX_OrientationInterpolator.cpp | 9 +++------ source/gameengine/Ketsji/KX_OrientationInterpolator.h | 9 +++------ source/gameengine/Ketsji/KX_ParentActuator.cpp | 4 ++-- source/gameengine/Ketsji/KX_ParentActuator.h | 4 ++-- source/gameengine/Ketsji/KX_PhysicsEngineEnums.h | 9 +++------ source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp | 9 +++------ source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h | 9 +++------ source/gameengine/Ketsji/KX_PhysicsPropertiesobsolete.h | 9 +++------ source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 9 +++------ source/gameengine/Ketsji/KX_PolygonMaterial.h | 9 +++------ source/gameengine/Ketsji/KX_PositionInterpolator.cpp | 9 +++------ source/gameengine/Ketsji/KX_PositionInterpolator.h | 9 +++------ source/gameengine/Ketsji/KX_PyConstraintBinding.cpp | 9 +++------ source/gameengine/Ketsji/KX_PyConstraintBinding.h | 9 +++------ source/gameengine/Ketsji/KX_PyMath.cpp | 9 +++------ source/gameengine/Ketsji/KX_PyMath.h | 9 +++------ source/gameengine/Ketsji/KX_PythonInit.cpp | 9 +++------ source/gameengine/Ketsji/KX_PythonInit.h | 9 +++------ source/gameengine/Ketsji/KX_RadarSensor.cpp | 9 +++------ source/gameengine/Ketsji/KX_RadarSensor.h | 9 +++------ source/gameengine/Ketsji/KX_RayCast.cpp | 9 +++------ source/gameengine/Ketsji/KX_RayCast.h | 9 +++------ source/gameengine/Ketsji/KX_RayEventManager.cpp | 9 +++------ source/gameengine/Ketsji/KX_RayEventManager.h | 9 +++------ source/gameengine/Ketsji/KX_RaySensor.cpp | 9 +++------ source/gameengine/Ketsji/KX_RaySensor.h | 9 +++------ source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h | 9 +++------ source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h | 9 +++------ source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h | 9 +++------ source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp | 9 +++------ source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h | 10 +++------- source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp | 9 +++------ source/gameengine/Ketsji/KX_SG_NodeRelationships.h | 10 +++------- source/gameengine/Ketsji/KX_ScalarInterpolator.cpp | 9 +++------ source/gameengine/Ketsji/KX_ScalarInterpolator.h | 9 +++------ source/gameengine/Ketsji/KX_ScalingInterpolator.cpp | 9 +++------ source/gameengine/Ketsji/KX_ScalingInterpolator.h | 9 +++------ source/gameengine/Ketsji/KX_Scene.cpp | 9 +++------ source/gameengine/Ketsji/KX_Scene.h | 9 +++------ source/gameengine/Ketsji/KX_SceneActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_SceneActuator.h | 9 +++------ source/gameengine/Ketsji/KX_SoundActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_SoundActuator.h | 9 +++------ source/gameengine/Ketsji/KX_SumoPhysicsController.h | 9 +++------ source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp | 9 +++------ source/gameengine/Ketsji/KX_TimeCategoryLogger.h | 9 +++------ source/gameengine/Ketsji/KX_TimeLogger.cpp | 9 +++------ source/gameengine/Ketsji/KX_TimeLogger.h | 9 +++------ source/gameengine/Ketsji/KX_TouchEventManager.cpp | 9 +++------ source/gameengine/Ketsji/KX_TouchEventManager.h | 9 +++------ source/gameengine/Ketsji/KX_TouchSensor.cpp | 9 +++------ source/gameengine/Ketsji/KX_TouchSensor.h | 9 +++------ source/gameengine/Ketsji/KX_TrackToActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_TrackToActuator.h | 9 +++------ source/gameengine/Ketsji/KX_VertexProxy.cpp | 9 +++------ source/gameengine/Ketsji/KX_VertexProxy.h | 9 +++------ source/gameengine/Ketsji/KX_VisibilityActuator.cpp | 9 +++------ source/gameengine/Ketsji/KX_VisibilityActuator.h | 9 +++------ source/gameengine/Ketsji/KX_WorldInfo.cpp | 9 +++------ source/gameengine/Ketsji/KX_WorldInfo.h | 9 +++------ source/gameengine/Ketsji/KX_WorldIpoController.cpp | 9 +++------ source/gameengine/Ketsji/KX_WorldIpoController.h | 9 +++------ source/gameengine/Ketsji/Makefile | 9 +++------ source/gameengine/Makefile | 9 +++------ source/gameengine/Network/CMakeLists.txt | 9 +++------ source/gameengine/Network/LoopBackNetwork/CMakeLists.txt | 9 +++------ source/gameengine/Network/LoopBackNetwork/Makefile | 9 +++------ .../LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp | 9 +++------ .../LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h | 9 +++------ source/gameengine/Network/Makefile | 9 +++------ source/gameengine/Network/NG_NetworkDeviceInterface.h | 9 +++------ source/gameengine/Network/NG_NetworkMessage.cpp | 9 +++------ source/gameengine/Network/NG_NetworkMessage.h | 9 +++------ source/gameengine/Network/NG_NetworkObject.cpp | 9 +++------ source/gameengine/Network/NG_NetworkObject.h | 9 +++------ source/gameengine/Network/NG_NetworkScene.cpp | 9 +++------ source/gameengine/Network/NG_NetworkScene.h | 9 +++------ source/gameengine/Network/TerraplayNetwork/Makefile | 9 +++------ .../TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.cpp | 9 +++------ .../TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.h | 9 +++------ source/gameengine/Physics/BlOde/Makefile | 9 +++------ source/gameengine/Physics/BlOde/OdePhysicsController.cpp | 4 ++-- source/gameengine/Physics/BlOde/OdePhysicsController.h | 4 ++-- source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp | 4 ++-- source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h | 4 ++-- source/gameengine/Physics/Bullet/CMakeLists.txt | 9 +++------ source/gameengine/Physics/Bullet/Makefile | 9 +++------ source/gameengine/Physics/Dummy/CMakeLists.txt | 9 +++------ source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp | 9 +++------ source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h | 9 +++------ source/gameengine/Physics/Dummy/Makefile | 9 +++------ source/gameengine/Physics/Makefile | 9 +++------ source/gameengine/Physics/Sumo/CMakeLists.txt | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/Makefile | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h | 9 +++------ .../gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp | 9 +++------ source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp | 9 +++------ source/gameengine/Physics/Sumo/Makefile | 9 +++------ source/gameengine/Physics/Sumo/SumoPhysicsController.cpp | 9 +++------ source/gameengine/Physics/Sumo/SumoPhysicsController.h | 9 +++------ source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp | 9 +++------ source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h | 9 +++------ source/gameengine/Physics/common/CMakeLists.txt | 9 +++------ source/gameengine/Physics/common/Makefile | 9 +++------ source/gameengine/Physics/common/PHY_IMotionState.cpp | 9 +++------ source/gameengine/Physics/common/PHY_IMotionState.h | 9 +++------ source/gameengine/Physics/common/PHY_IPhysicsController.cpp | 9 +++------ source/gameengine/Physics/common/PHY_IPhysicsController.h | 9 +++------ source/gameengine/Physics/common/PHY_IPhysicsEnvironment.cpp | 9 +++------ source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h | 9 +++------ source/gameengine/Physics/common/PHY_Pro.h | 9 +++------ source/gameengine/Rasterizer/CMakeLists.txt | 9 +++------ source/gameengine/Rasterizer/Makefile | 9 +++------ source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 4 ++-- source/gameengine/Rasterizer/RAS_2DFilterManager.h | 9 +++------ source/gameengine/Rasterizer/RAS_BucketManager.cpp | 9 +++------ source/gameengine/Rasterizer/RAS_BucketManager.h | 9 +++------ source/gameengine/Rasterizer/RAS_CameraData.h | 9 +++------ source/gameengine/Rasterizer/RAS_Deformer.h | 9 +++------ source/gameengine/Rasterizer/RAS_FramingManager.cpp | 9 +++------ source/gameengine/Rasterizer/RAS_FramingManager.h | 9 +++------ source/gameengine/Rasterizer/RAS_ICanvas.h | 9 +++------ source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 9 +++------ source/gameengine/Rasterizer/RAS_IPolygonMaterial.h | 9 +++------ source/gameengine/Rasterizer/RAS_IRasterizer.h | 9 +++------ source/gameengine/Rasterizer/RAS_IRenderTools.cpp | 9 +++------ source/gameengine/Rasterizer/RAS_IRenderTools.h | 9 +++------ source/gameengine/Rasterizer/RAS_LightObject.h | 9 +++------ source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | 9 +++------ source/gameengine/Rasterizer/RAS_MaterialBucket.h | 9 +++------ source/gameengine/Rasterizer/RAS_MeshObject.cpp | 9 +++------ source/gameengine/Rasterizer/RAS_MeshObject.h | 9 +++------ source/gameengine/Rasterizer/RAS_ObjectColor.h | 9 +++------ .../gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h | 9 +++------ .../Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h | 9 +++------ .../gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt | 9 +++------ source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile | 9 +++------ .../Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp | 9 +++------ .../Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h | 9 +++------ .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 9 +++------ .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 9 +++------ .../Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp | 9 +++------ .../Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h | 9 +++------ source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py | 9 +++------ source/gameengine/Rasterizer/RAS_Polygon.cpp | 9 +++------ source/gameengine/Rasterizer/RAS_Polygon.h | 9 +++------ source/gameengine/Rasterizer/RAS_Rect.h | 9 +++------ source/gameengine/Rasterizer/RAS_TexMatrix.h | 9 +++------ source/gameengine/Rasterizer/RAS_TexVert.cpp | 9 +++------ source/gameengine/Rasterizer/RAS_TexVert.h | 9 +++------ source/gameengine/Rasterizer/RAS_texmatrix.cpp | 9 +++------ source/gameengine/SceneGraph/CMakeLists.txt | 9 +++------ source/gameengine/SceneGraph/Makefile | 9 +++------ source/gameengine/SceneGraph/SG_BBox.cpp | 9 +++------ source/gameengine/SceneGraph/SG_BBox.h | 9 +++------ source/gameengine/SceneGraph/SG_Controller.cpp | 9 +++------ source/gameengine/SceneGraph/SG_Controller.h | 9 +++------ source/gameengine/SceneGraph/SG_IObject.cpp | 9 +++------ source/gameengine/SceneGraph/SG_IObject.h | 9 +++------ source/gameengine/SceneGraph/SG_Node.cpp | 9 +++------ source/gameengine/SceneGraph/SG_Node.h | 9 +++------ source/gameengine/SceneGraph/SG_ParentRelation.h | 9 +++------ source/gameengine/SceneGraph/SG_Spatial.cpp | 9 +++------ source/gameengine/SceneGraph/SG_Spatial.h | 9 +++------ source/gameengine/SceneGraph/SG_Tree.cpp | 9 +++------ source/gameengine/SceneGraph/SG_Tree.h | 9 +++------ 433 files changed, 1290 insertions(+), 2564 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 4f282b6c8cb..200c04bbfd3 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Blender's Ketsji startpoint */ diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 03f78c4b145..5f37de24ed6 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "BIF_scrarea.h" diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index 23258f5ea81..0b3519efdbd 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_BLENDERCANVAS #define __KX_BLENDERCANVAS diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 54ceec306e2..7c9dbcdaab2 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_BlenderGL.h" diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h index b0f97f1a76c..c8e0d47afb6 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __BLENDERGL #define __BLENDERGL diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp index 1423418924c..ef7c6172529 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_BlenderInputDevice.h" diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h index ed4eb65a769..8e5d508f8cb 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_BLENDERINPUTDEVICE #define __KX_BLENDERINPUTDEVICE diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp index c6ae91ae282..4b794380610 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h index 932751c37eb..5bf37acf236 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_BLENDERKEYBOARDDEVICE #define __KX_BLENDERKEYBOARDDEVICE diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp index 92e0a6113bb..b2e965a35f6 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h index a4a1d27b2ee..2f9e956a1d8 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderMouseDevice.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_BLENDERMOUSEDEVICE #define __KX_BLENDERMOUSEDEVICE diff --git a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp index cdb6ce5b829..d173b1c66d9 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_BlenderPolyMaterial.h" diff --git a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h index 1dab77cb901..35823b2125b 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_BLENDERPOLYMATERIAL #define __KX_BLENDERPOLYMATERIAL diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 7e32ade37f2..6b0df44cb16 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_BlenderRenderTools.h" diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 3c2d4ac8e35..662f5bd9af1 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_BLENDERRENDERTOOLS #define __KX_BLENDERRENDERTOOLS diff --git a/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp b/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp index 290f1d71777..4066bbc3db1 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderSystem.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_ISystem.h" diff --git a/source/gameengine/BlenderRoutines/KX_BlenderSystem.h b/source/gameengine/BlenderRoutines/KX_BlenderSystem.h index 829668b4192..d99bb9b14a8 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderSystem.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderSystem.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_BLENDERSYSTEM #define __KX_BLENDERSYSTEM diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile index 73f51c464a5..2339b840679 100644 --- a/source/gameengine/BlenderRoutines/Makefile +++ b/source/gameengine/BlenderRoutines/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt index b42d1d70e43..93de588ba00 100644 --- a/source/gameengine/CMakeLists.txt +++ b/source/gameengine/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SUBDIRS( BlenderRoutines diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index b38599685af..1055c8771ef 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #if defined (__sgi) diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index f96855408b7..62edcc7fad7 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef BL_ACTIONACTUATOR diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 4bf13a09fb4..ff9c6a75aa9 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "BL_ArmatureObject.h" diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index aafc8271dd6..752bd5eb365 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef BL_ARMATUREOBJECT diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 8ae287a494c..3e83ed20840 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Convert blender data to ketsji */ diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.h b/source/gameengine/Converter/BL_BlenderDataConversion.h index 56dc5bfa8b2..48f08fb357b 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.h +++ b/source/gameengine/Converter/BL_BlenderDataConversion.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __BLENDER_CONVERT #define __BLENDER_CONVERT diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp index a17ca6a7c19..68a2e41ca47 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.cpp +++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "BL_DeformableGameObject.h" diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index 720a152575a..d943cc7388a 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef BL_DEFORMABLEGAMEOBJECT diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index 4555e81254a..ab31179b047 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Simple deformation controller that restores a mesh to its rest position */ diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index adeffd632e7..a6be11d786e 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef BL_MESHDEFORMER diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 6bc623b645c..14faa3317d0 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef WIN32 diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index b4e55018604..e130dc15dbf 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef BL_SKINDEFORMER diff --git a/source/gameengine/Converter/BL_SkinMeshObject.cpp b/source/gameengine/Converter/BL_SkinMeshObject.cpp index 364fd76776f..8bc78c7f757 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.cpp +++ b/source/gameengine/Converter/BL_SkinMeshObject.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Deformer that supports armature skinning */ diff --git a/source/gameengine/Converter/BL_SkinMeshObject.h b/source/gameengine/Converter/BL_SkinMeshObject.h index 1d02dd1ceb4..0ca7428c0f0 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.h +++ b/source/gameengine/Converter/BL_SkinMeshObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __BL_SKINMESHOBJECT diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index eb03a3c2a38..bb9bb161f32 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include // printf() diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index 35e47bbf9b8..fd6bb0212b7 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __BLENDERWORLDINFO_H #define __BLENDERWORLDINFO_H diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index db516b20df2..adb7304b10e 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp index 8722f90f456..f58d60b026a 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_BlenderScalarInterpolator.h" diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h index fd9cfcb04ce..94d15aff6be 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.h +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_SCALARINTERPOLATOR_H #define __KX_SCALARINTERPOLATOR_H diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 7fbec8679fb..8640e69102b 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef WIN32 diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index 8ac5386d442..a45d7396875 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_BLENDERSCENECONVERTER_H #define __KX_BLENDERSCENECONVERTER_H diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a9b84e8f51f..a575415ab05 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Convert Blender actuators for use in the GameEngine */ diff --git a/source/gameengine/Converter/KX_ConvertActuators.h b/source/gameengine/Converter/KX_ConvertActuators.h index 1e6e96e2e7c..03ea0db99b9 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.h +++ b/source/gameengine/Converter/KX_ConvertActuators.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_CONVERTACTUATORS_H #define __KX_CONVERTACTUATORS_H diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index b277af7dbc2..a26cfa95b6d 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "MEM_guardedalloc.h" diff --git a/source/gameengine/Converter/KX_ConvertControllers.h b/source/gameengine/Converter/KX_ConvertControllers.h index 3c2b45bddd0..3e8a87fc90b 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.h +++ b/source/gameengine/Converter/KX_ConvertControllers.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_CONVERTCONTROLLERS_H #define __KX_CONVERTCONTROLLERS_H diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index ebfb45066b7..aae8752671f 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_ConvertProperties.h" diff --git a/source/gameengine/Converter/KX_ConvertProperties.h b/source/gameengine/Converter/KX_ConvertProperties.h index eb44f7b7d35..327284d63ce 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.h +++ b/source/gameengine/Converter/KX_ConvertProperties.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_CONVERTPROPERTIES #define __KX_CONVERTPROPERTIES diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 61759ddf654..80fa3838d60 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Conversion of Blender data blocks to KX sensor system */ diff --git a/source/gameengine/Converter/KX_ConvertSensors.h b/source/gameengine/Converter/KX_ConvertSensors.h index 9878d4a7a09..73da51f47f0 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.h +++ b/source/gameengine/Converter/KX_ConvertSensors.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_CONVERTSENSOR_H #define __KX_CONVERTSENSOR_H diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 2cf29e9dd62..75ca59d01e7 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Converter/KX_IpoConvert.h b/source/gameengine/Converter/KX_IpoConvert.h index e901ae9b3e7..afcb1b22821 100644 --- a/source/gameengine/Converter/KX_IpoConvert.h +++ b/source/gameengine/Converter/KX_IpoConvert.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_IPOCONVERT_H #define __KX_IPOCONVERT_H diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile index 4ba34952d40..f312fc13221 100644 --- a/source/gameengine/Converter/Makefile +++ b/source/gameengine/Converter/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Expressions/CMakeLists.txt b/source/gameengine/Expressions/CMakeLists.txt index cc99be1b9ee..6b2a835d648 100644 --- a/source/gameengine/Expressions/CMakeLists.txt +++ b/source/gameengine/Expressions/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) diff --git a/source/gameengine/Expressions/EXP_C-Api.cpp b/source/gameengine/Expressions/EXP_C-Api.cpp index c5576e99e7d..016d4e6fba9 100644 --- a/source/gameengine/Expressions/EXP_C-Api.cpp +++ b/source/gameengine/Expressions/EXP_C-Api.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "EXP_C-Api.h" #include "IntValue.h" diff --git a/source/gameengine/Expressions/EXP_C-Api.h b/source/gameengine/Expressions/EXP_C-Api.h index e9ee526cd6e..d259a8d6d99 100644 --- a/source/gameengine/Expressions/EXP_C-Api.h +++ b/source/gameengine/Expressions/EXP_C-Api.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __EXPRESSION_INCLUDE #define __EXPRESSION_INCLUDE diff --git a/source/gameengine/Expressions/IdentifierExpr.cpp b/source/gameengine/Expressions/IdentifierExpr.cpp index cd7a9b0f186..398e1b2aa0e 100644 --- a/source/gameengine/Expressions/IdentifierExpr.cpp +++ b/source/gameengine/Expressions/IdentifierExpr.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "IdentifierExpr.h" diff --git a/source/gameengine/Expressions/IdentifierExpr.h b/source/gameengine/Expressions/IdentifierExpr.h index dbffe7c02bc..b307228c8b9 100644 --- a/source/gameengine/Expressions/IdentifierExpr.h +++ b/source/gameengine/Expressions/IdentifierExpr.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __IDENTIFIER_EXPR #define __IDENTIFIER_EXPR diff --git a/source/gameengine/Expressions/KX_HashedPtr.cpp b/source/gameengine/Expressions/KX_HashedPtr.cpp index b1eeff20766..b75e15bd375 100644 --- a/source/gameengine/Expressions/KX_HashedPtr.cpp +++ b/source/gameengine/Expressions/KX_HashedPtr.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_HashedPtr.h" diff --git a/source/gameengine/Expressions/KX_HashedPtr.h b/source/gameengine/Expressions/KX_HashedPtr.h index 06e86854d82..b11efb99d68 100644 --- a/source/gameengine/Expressions/KX_HashedPtr.h +++ b/source/gameengine/Expressions/KX_HashedPtr.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_HASHEDPTR #define __KX_HASHEDPTR diff --git a/source/gameengine/Expressions/KX_Python.h b/source/gameengine/Expressions/KX_Python.h index 76c104390db..b8006fdf0ed 100644 --- a/source/gameengine/Expressions/KX_Python.h +++ b/source/gameengine/Expressions/KX_Python.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_PYTHON_H #define KX_PYTHON_H diff --git a/source/gameengine/Expressions/KX_Python_dynamic.h b/source/gameengine/Expressions/KX_Python_dynamic.h index 6ba31796e4f..eb435bdf1c3 100644 --- a/source/gameengine/Expressions/KX_Python_dynamic.h +++ b/source/gameengine/Expressions/KX_Python_dynamic.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_PYTHON_H #define KX_PYTHON_H diff --git a/source/gameengine/Expressions/KX_Python_static.h b/source/gameengine/Expressions/KX_Python_static.h index 1a9682c8ef4..f4f31f9b058 100644 --- a/source/gameengine/Expressions/KX_Python_static.h +++ b/source/gameengine/Expressions/KX_Python_static.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_PYTHON_H #define KX_PYTHON_H diff --git a/source/gameengine/Expressions/Makefile b/source/gameengine/Expressions/Makefile index 18dca9a1c68..e9c02eedcf2 100644 --- a/source/gameengine/Expressions/Makefile +++ b/source/gameengine/Expressions/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 1b343088446..aabcd6cb71d 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 026a58cdbca..de89ed9b5c8 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef NO_EXP_PYTHON_EMBEDDING diff --git a/source/gameengine/Expressions/VoidValue.h b/source/gameengine/Expressions/VoidValue.h index 53fbd8b4f01..4bde0254787 100644 --- a/source/gameengine/Expressions/VoidValue.h +++ b/source/gameengine/Expressions/VoidValue.h @@ -2,15 +2,12 @@ * VoidValue.h: interface for the CVoidValue class. * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -28,7 +25,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __VOIDVALUE_H__ #define __VOIDVALUE_H__ diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 4f40fa22b9e..a7519196d50 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp Joystick/*.cpp) diff --git a/source/gameengine/GameLogic/Joystick/Makefile b/source/gameengine/GameLogic/Joystick/Makefile index 4de5f168ceb..7016f1ed16f 100644 --- a/source/gameengine/GameLogic/Joystick/Makefile +++ b/source/gameengine/GameLogic/Joystick/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 79da15721f3..18d7b6ffcd0 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): snailrose. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index 997e76615d3..1e853070b09 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -1,6 +1,6 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -10,13 +10,10 @@ * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender + * of the License, or (at your option) any later version. - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. * @@ -52,7 +49,7 @@ * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h index c4ddd5b9c40..15a421188b9 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): snailrose. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _SCA_JOYSTICKDEFINES_H_ #define _SCA_JOYSTICKDEFINES_H_ diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp index 5fd8510d566..ab523470e21 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): snailrose. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include #include "SCA_Joystick.h" diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h index 08435749cfe..23fad3cd55d 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): snailrose. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __SCA_JOYSTICKPRIVATE_H__ diff --git a/source/gameengine/GameLogic/Makefile b/source/gameengine/GameLogic/Makefile index aea1e463146..b3eae5d67dc 100644 --- a/source/gameengine/GameLogic/Makefile +++ b/source/gameengine/GameLogic/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp index 0daba011c71..cfc2d25e0ae 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.cpp +++ b/source/gameengine/GameLogic/SCA_ANDController.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_ANDController.h" diff --git a/source/gameengine/GameLogic/SCA_ANDController.h b/source/gameengine/GameLogic/SCA_ANDController.h index d32bfd2aa48..376f4a9a876 100644 --- a/source/gameengine/GameLogic/SCA_ANDController.h +++ b/source/gameengine/GameLogic/SCA_ANDController.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ANDCONTROLLER diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp index c4b5b8197a7..ab3bc2cc4ee 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp @@ -4,15 +4,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,7 +27,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_AlwaysEventManager.h" diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h index bffd21da74c..28c71512875 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h +++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ALWAYSEVENTMGR #define __KX_ALWAYSEVENTMGR diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp index a0bb7311eb9..67df5d091ab 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.h b/source/gameengine/GameLogic/SCA_AlwaysSensor.h index 456516fa989..474ed025432 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ALWAYSSENSOR diff --git a/source/gameengine/GameLogic/SCA_EventManager.cpp b/source/gameengine/GameLogic/SCA_EventManager.cpp index 9c39b332d40..1ca88182ddc 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.cpp +++ b/source/gameengine/GameLogic/SCA_EventManager.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h index e15e19b239b..89731497f6f 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.h +++ b/source/gameengine/GameLogic/SCA_EventManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_EVENTMANAGER #define __KX_EVENTMANAGER diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp index 36e83f2a98c..e9a543c9f31 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp +++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_ExpressionController.h" diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h index e77f2b9938b..f1db45a19e0 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.h +++ b/source/gameengine/GameLogic/SCA_ExpressionController.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_EXPRESSIONCONTROLLER diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp index 322936c7819..568d0eb4a89 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.cpp +++ b/source/gameengine/GameLogic/SCA_IActuator.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_IActuator.h" diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h index e58ac74dacf..bff32dcebaa 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.h +++ b/source/gameengine/GameLogic/SCA_IActuator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_IACTUATOR #define __KX_IACTUATOR diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index bd70e4aa44b..5cb62678c6b 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_IController.h" diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h index 31bbca2480a..79e956dec4e 100644 --- a/source/gameengine/GameLogic/SCA_IController.h +++ b/source/gameengine/GameLogic/SCA_IController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ICONTROLLER #define __KX_ICONTROLLER diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.cpp b/source/gameengine/GameLogic/SCA_IInputDevice.cpp index c6858cdb75a..d6c5376d090 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.cpp +++ b/source/gameengine/GameLogic/SCA_IInputDevice.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h index 6dee608a568..66ad457aa03 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.h +++ b/source/gameengine/GameLogic/SCA_IInputDevice.h @@ -4,15 +4,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,7 +27,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_INPUTDEVICE_H diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index 1780458ba45..8423d06dfcd 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_ILogicBrick.h" diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index 588c5ca7aba..f359ee0911b 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ILOGICBRICK #define __KX_ILOGICBRICK diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index fae1b5dfa6b..465dd981406 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index aed1d87b929..8f3e25afa03 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * An abstract object that has some logic, python scripting and * reference counting Note: transformation stuff has been moved to * SceneGraph diff --git a/source/gameengine/GameLogic/SCA_IScene.cpp b/source/gameengine/GameLogic/SCA_IScene.cpp index a2f0693b475..9a17d1f384f 100644 --- a/source/gameengine/GameLogic/SCA_IScene.cpp +++ b/source/gameengine/GameLogic/SCA_IScene.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_IScene.h" diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h index 5aa631f6b4d..23c9c37fd6e 100644 --- a/source/gameengine/GameLogic/SCA_IScene.h +++ b/source/gameengine/GameLogic/SCA_IScene.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ISCENE_H #define __KX_ISCENE_H diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 43dd6bef83e..9fdee0c19da 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_ISensor.h" diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 1c5ee7a39bb..e14fb34241a 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Interface Class for all logic Sensors. Implements * pulsemode and pulsefrequency, and event suppression. */ diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp index ca2d5459386..7bf2049e56e 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_JoystickSensor.h" #include "SCA_JoystickManager.h" diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h index 5c892d71f6c..3c4df64677e 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.h +++ b/source/gameengine/GameLogic/SCA_JoystickManager.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __JOYSTICKMANAGER_H_ diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 40942dd296f..b0e7fee130d 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -1,13 +1,10 @@ /* - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_JoystickManager.h" #include "SCA_JoystickSensor.h" diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index 08af4b84b42..2fbe1edf1e7 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp index 25a366352cc..259b06134d7 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "BoolValue.h" diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h index 562f28417ad..b4a50f56025 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.h +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_KEYBOARDMANAGER diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index c276f42e0ff..f8fc256b371 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Sensor for keyboard input */ #include "SCA_KeyboardSensor.h" diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index f4a3d7e47b5..e87eddecd32 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Sensor for keyboard input */ diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 048d6992c73..bd1c44fb91e 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Regulates the top-level logic behaviour for one scene. */ #include "Value.h" diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index 2eee2129665..39d8b865977 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Regulates the top-level logic behaviour for one scene. */ #ifndef __KX_LOGICMANAGER diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp index e4d54c94395..b4251d8ab53 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.cpp +++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp @@ -4,15 +4,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,7 +27,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h index e98405b1b7d..bc8254486ad 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.h +++ b/source/gameengine/GameLogic/SCA_MouseManager.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index fda641cfc96..a91cf3e0439 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -4,15 +4,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,7 +27,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_MouseSensor.h" diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h index e8a0d0db78b..86c9d96a800 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.h +++ b/source/gameengine/GameLogic/SCA_MouseSensor.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_MOUSESENSOR diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp index 29f62b4e6a7..2d4eb31f241 100644 --- a/source/gameengine/GameLogic/SCA_ORController.cpp +++ b/source/gameengine/GameLogic/SCA_ORController.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_ORController.h" diff --git a/source/gameengine/GameLogic/SCA_ORController.h b/source/gameengine/GameLogic/SCA_ORController.h index d8b844d9063..beb69aa2af9 100644 --- a/source/gameengine/GameLogic/SCA_ORController.h +++ b/source/gameengine/GameLogic/SCA_ORController.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ORCONTROLLER diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 24b040db1bc..ebe1cd51863 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_PropertyActuator.h" diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index fc993c9fce2..f8305901c51 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_PROPERTYACTUATOR diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp index 4ac3d162229..fc56d101728 100644 --- a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_ISensor.h" diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h index 664beb68695..aaa303a52c8 100644 --- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h +++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_PROPERTYEVENTMANAGER #define __KX_PROPERTYEVENTMANAGER diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index cdd0666947e..f1fcb18d32e 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index 77cc3dc8a5c..81c9b958f25 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_PROPERTYSENSOR diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index c44971d7028..44cdc0a7de5 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_PythonController.h" diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index da2cd4b0bcd..63975234da9 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_PYTHONCONTROLLER_H diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index b0e69076a3e..0a1ac2d0668 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "BoolValue.h" diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h index 4be7f2dbe9e..f6da0595d1a 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.h +++ b/source/gameengine/GameLogic/SCA_RandomActuator.h @@ -4,15 +4,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,7 +27,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_RANDOMACTUATOR diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp index 6bf10a83f55..02020a52a17 100644 --- a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_RandomEventManager.h" #include "SCA_LogicManager.h" diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h index 17b2894434d..8c75ef665fa 100644 --- a/source/gameengine/GameLogic/SCA_RandomEventManager.h +++ b/source/gameengine/GameLogic/SCA_RandomEventManager.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_RANDOMEVENTMGR diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h index b6272a09c9f..b9311d31af6 100644 --- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h +++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h @@ -5,15 +5,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -31,7 +28,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_RANDOMNUMBERGENERATOR diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 56c7ed538b8..0e856e0d6bb 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_RandomSensor.h" diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h index 08bb5226be1..cc54179aa4e 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.h +++ b/source/gameengine/GameLogic/SCA_RandomSensor.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_RANDOMSENSOR diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp index d97727d2a33..643f1247a52 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h index 388d9ce53bd..2fd39661a2d 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.h +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_TIMEEVENTMANAGER #define __KX_TIMEEVENTMANAGER diff --git a/source/gameengine/GamePlayer/CMakeLists.txt b/source/gameengine/GamePlayer/CMakeLists.txt index dbcdb64a0a4..ff1040bfb40 100644 --- a/source/gameengine/GamePlayer/CMakeLists.txt +++ b/source/gameengine/GamePlayer/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,6 +22,6 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SUBDIRS(common ghost) diff --git a/source/gameengine/GamePlayer/Makefile b/source/gameengine/GamePlayer/Makefile index c9a568f708d..747a82fc333 100644 --- a/source/gameengine/GamePlayer/Makefile +++ b/source/gameengine/GamePlayer/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # Bounces make to subdirectories. diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index f56fa512ab6..29cdcd640f5 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SET(SRC bmfont.cpp diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp index 506b2fc423c..494f43a7863 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index 42e2d882e9a..bd66c865988 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _GPC_CANVAS_H_ diff --git a/source/gameengine/GamePlayer/common/GPC_Engine.cpp b/source/gameengine/GamePlayer/common/GPC_Engine.cpp index 0986b8cee55..868dddb901c 100644 --- a/source/gameengine/GamePlayer/common/GPC_Engine.cpp +++ b/source/gameengine/GamePlayer/common/GPC_Engine.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/GamePlayer/common/GPC_Engine.h b/source/gameengine/GamePlayer/common/GPC_Engine.h index a1403839e16..b7121599c6e 100644 --- a/source/gameengine/GamePlayer/common/GPC_Engine.h +++ b/source/gameengine/GamePlayer/common/GPC_Engine.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_ENGINE_H diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp index 8bbac10f7ca..474df9276a7 100644 --- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp +++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "GPC_KeyboardDevice.h" diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h index c5c900d276a..891589dd118 100644 --- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h +++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_KEYBOARDDEVICE_H diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp index 7e57aa1ee40..1771e3d40c6 100644 --- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp +++ b/source/gameengine/GamePlayer/common/GPC_MouseDevice.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "GPC_MouseDevice.h" diff --git a/source/gameengine/GamePlayer/common/GPC_MouseDevice.h b/source/gameengine/GamePlayer/common/GPC_MouseDevice.h index da5098b06d6..91dbd90a53c 100644 --- a/source/gameengine/GamePlayer/common/GPC_MouseDevice.h +++ b/source/gameengine/GamePlayer/common/GPC_MouseDevice.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_MOUSE_DEVICE_H diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp index 840230902f8..46fe24d8b87 100644 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp +++ b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h index d9aa3ca4b7e..212decd078c 100644 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h +++ b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_POLYGONMATERIAL diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp index 7d0886a292b..a9cfb0a9366 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.h b/source/gameengine/GamePlayer/common/GPC_RawImage.h index ff4c532dd4d..17c00d2fcc3 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawImage.h +++ b/source/gameengine/GamePlayer/common/GPC_RawImage.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_RAWIMAGE_H__ diff --git a/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp b/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp index 2ccd98b368a..4e70c1f7b8b 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ // This file is automatically generated. Do not edit by hand! diff --git a/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.h b/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.h index 05b7e3d9c3a..02f616f1339 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.h +++ b/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_RAWLOADDOTBLENDARRAY_H diff --git a/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp b/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp index 955a644513a..135c5641a2c 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ // This file is automatically generated. Do not edit by hand! diff --git a/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.h b/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.h index b6caf3a875a..f74a0012d5c 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.h +++ b/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_RAWLOGOARRAYS_H diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 388882e67e4..a5b8d8aacdf 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index d90f0e5da45..9b86869af73 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_RENDERTOOLS_H diff --git a/source/gameengine/GamePlayer/common/GPC_System.cpp b/source/gameengine/GamePlayer/common/GPC_System.cpp index 31393505796..e83afcca511 100644 --- a/source/gameengine/GamePlayer/common/GPC_System.cpp +++ b/source/gameengine/GamePlayer/common/GPC_System.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "GPC_System.h" diff --git a/source/gameengine/GamePlayer/common/GPC_System.h b/source/gameengine/GamePlayer/common/GPC_System.h index e102341749d..512a0b94ade 100644 --- a/source/gameengine/GamePlayer/common/GPC_System.h +++ b/source/gameengine/GamePlayer/common/GPC_System.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPC_SYSTEM_H diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile index 10d7543b624..254896e60e5 100644 --- a/source/gameengine/GamePlayer/common/Makefile +++ b/source/gameengine/GamePlayer/common/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/GamePlayer/common/bmfont.cpp b/source/gameengine/GamePlayer/common/bmfont.cpp index c98c85bc272..c2c112c9286 100644 --- a/source/gameengine/GamePlayer/common/bmfont.cpp +++ b/source/gameengine/GamePlayer/common/bmfont.cpp @@ -5,15 +5,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -31,7 +28,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * */ diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Canvas.cpp b/source/gameengine/GamePlayer/common/unix/GPU_Canvas.cpp index d393f4196aa..6af9b392d28 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/unix/GPU_Canvas.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ //#include diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Canvas.h b/source/gameengine/GamePlayer/common/unix/GPU_Canvas.h index 6ff1935d9c1..ee9115ec6dc 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_Canvas.h +++ b/source/gameengine/GamePlayer/common/unix/GPU_Canvas.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPU_CANVAS_H diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp b/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp index 41186a590f5..a5dec02c753 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp +++ b/source/gameengine/GamePlayer/common/unix/GPU_Engine.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GamePlayer/common/unix/GPU_Engine.h b/source/gameengine/GamePlayer/common/unix/GPU_Engine.h index c34c737da2a..3f5b81c9886 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_Engine.h +++ b/source/gameengine/GamePlayer/common/unix/GPU_Engine.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPU_ENGINE_H diff --git a/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.cpp index b1b05d9a978..952e7fecd31 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.cpp +++ b/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "GPU_KeyboardDevice.h" diff --git a/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.h b/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.h index eb1a5a11cf6..5c72e43507e 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.h +++ b/source/gameengine/GamePlayer/common/unix/GPU_KeyboardDevice.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPU_KEYBOARDDEVICE_H diff --git a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h index 62feb394441..fee729a84ac 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h +++ b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPU_POLYGONMATERIAL_H diff --git a/source/gameengine/GamePlayer/common/unix/GPU_System.cpp b/source/gameengine/GamePlayer/common/unix/GPU_System.cpp index eb2163f08bc..cf8ddda1359 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_System.cpp +++ b/source/gameengine/GamePlayer/common/unix/GPU_System.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/GamePlayer/common/unix/GPU_System.h b/source/gameengine/GamePlayer/common/unix/GPU_System.h index efb637dba95..292dc2cad81 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_System.h +++ b/source/gameengine/GamePlayer/common/unix/GPU_System.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPU_SYSTEM_H diff --git a/source/gameengine/GamePlayer/common/unix/Makefile b/source/gameengine/GamePlayer/common/unix/Makefile index 9073bf02d11..a2bdb7225a0 100644 --- a/source/gameengine/GamePlayer/common/unix/Makefile +++ b/source/gameengine/GamePlayer/common/unix/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.cpp b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.cpp index 372ab927118..e679522470c 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.cpp +++ b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "GPW_Canvas.h" diff --git a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h index d08ec3c4fa5..bb1abd71505 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h +++ b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _GPW_CANVAS_H_ diff --git a/source/gameengine/GamePlayer/common/windows/GPW_Engine.cpp b/source/gameengine/GamePlayer/common/windows/GPW_Engine.cpp index 43d2ca9bb6e..71f40d03eb3 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_Engine.cpp +++ b/source/gameengine/GamePlayer/common/windows/GPW_Engine.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #pragma warning (disable : 4786) diff --git a/source/gameengine/GamePlayer/common/windows/GPW_Engine.h b/source/gameengine/GamePlayer/common/windows/GPW_Engine.h index 8f357358d68..0b4cf4743db 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_Engine.h +++ b/source/gameengine/GamePlayer/common/windows/GPW_Engine.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __GPW_ENGINE_H diff --git a/source/gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.cpp index e9d70722336..18724783307 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.cpp +++ b/source/gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "GPW_KeyboardDevice.h" diff --git a/source/gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.h b/source/gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.h index 0e683943701..cae7488c70d 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.h +++ b/source/gameengine/GamePlayer/common/windows/GPW_KeyboardDevice.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _GPW_KEYBOARDDEVICE_H_ diff --git a/source/gameengine/GamePlayer/common/windows/GPW_System.cpp b/source/gameengine/GamePlayer/common/windows/GPW_System.cpp index 9dbd704daed..cb53f8ea6ad 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_System.cpp +++ b/source/gameengine/GamePlayer/common/windows/GPW_System.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Timing routine taken and modified from KX_BlenderSystem.cpp */ diff --git a/source/gameengine/GamePlayer/common/windows/GPW_System.h b/source/gameengine/GamePlayer/common/windows/GPW_System.h index e7dbe99cd1c..41b2bff72b0 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_System.h +++ b/source/gameengine/GamePlayer/common/windows/GPW_System.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Timing routine taken and modified from KX_BlenderSystem.cpp */ diff --git a/source/gameengine/GamePlayer/common/windows/Makefile b/source/gameengine/GamePlayer/common/windows/Makefile index 6ad97c1677c..b0fb25f35b8 100644 --- a/source/gameengine/GamePlayer/common/windows/Makefile +++ b/source/gameengine/GamePlayer/common/windows/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # # ATTENTION: this Makefile is only used for win builds! diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index da7abcaf0c5..3d17cd2cfdd 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SET(SRC GPG_Application.cpp diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 0fd1812cb3c..dfd15227501 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * GHOST Blender Player application implementation file. */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 11ede4d51ca..024ca1dbf32 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * GHOST Blender Player application declaration file. */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp index 2d378473619..de8342fb15b 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "GPG_Canvas.h" diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h index 8da8983bf8c..6ab3e918943 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _GPG_CANVAS_H_ diff --git a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp b/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp index 0e474827ad5..0fa940c07a1 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * GHOST Blender Player keyboard device implementation. */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h b/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h index b8e578bcd8f..dce16985bb7 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h +++ b/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * GHOST Blender Player keyboard device. */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_System.cpp b/source/gameengine/GamePlayer/ghost/GPG_System.cpp index d9f59f8b36a..56482ac46bc 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_System.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_System.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Blender Player system on GHOST. */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_System.h b/source/gameengine/GamePlayer/ghost/GPG_System.h index d283c683f1d..e4ac4777763 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_System.h +++ b/source/gameengine/GamePlayer/ghost/GPG_System.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Blender Player system on GHOST. */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index cf45c513098..1496f7c6ad3 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Start up of the Blender Player on GHOST. */ diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index 3c32079c652..8a3d194cbd7 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # Makefile for GHOST game player diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index ca21869c007..a10b07ff491 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) diff --git a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt index 5a02c5ddb0e..fa0ca378c6b 100644 --- a/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt +++ b/source/gameengine/Ketsji/KXNetwork/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp index 93c7ab37edb..7b5b7fdf78c 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Ketsji Logic Extenstion: Network Event Manager generic implementation */ diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h index 9c0d14674c1..0b097ba2ef6 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Ketsji Logic Extenstion: Network Event Manager class */ #ifndef KX_NETWORK_EVENTMANAGER_H diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index e142d2a1a1b..3ade810c394 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Ketsji Logic Extenstion: Network Message Actuator generic implementation */ diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h index c81437dbd91..653107699c7 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Ketsji Logic Extenstion: Network Message Actuator class */ #ifndef __KX_NETWORKMESSAGEACTUATOR_H diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 51cfe30179c..e320453b7aa 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Ketsji Logic Extenstion: Network Message Sensor generic implementation */ diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index 82f83787645..d051b715aab 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Ketsji Logic Extenstion: Network Message Sensor class */ #ifndef __KX_NETWORKMESSAGE_SENSOR_H diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp index a27ac01d5c4..be15c02f62d 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h index 39910963161..17b4adee6cb 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectActuator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,6 +24,6 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp index 9da25bcb70b..56021f0b417 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h index 39910963161..17b4adee6cb 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkObjectSensor.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,6 +24,6 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/gameengine/Ketsji/KXNetwork/Makefile b/source/gameengine/Ketsji/KXNetwork/Makefile index ee8ddc45c3b..ddcb03600d5 100644 --- a/source/gameengine/Ketsji/KXNetwork/Makefile +++ b/source/gameengine/Ketsji/KXNetwork/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Ketsji/KX_CDActuator.cpp b/source/gameengine/Ketsji/KX_CDActuator.cpp index b4a7763763a..a5d7f6d799a 100644 --- a/source/gameengine/Ketsji/KX_CDActuator.cpp +++ b/source/gameengine/Ketsji/KX_CDActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * */ diff --git a/source/gameengine/Ketsji/KX_CDActuator.h b/source/gameengine/Ketsji/KX_CDActuator.h index db6dc1e3475..f46dd99b6dc 100644 --- a/source/gameengine/Ketsji/KX_CDActuator.h +++ b/source/gameengine/Ketsji/KX_CDActuator.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_CDACTUATOR diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index aa15199b816..09eb2053bfe 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Camera in the gameengine. Cameras are also used for views. */ diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index 08f2bf3d1c1..4cc8c049f91 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Camera in the gameengine. Cameras are also used for views. */ diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 9454e21132a..cb3180cb05e 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * */ diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index 27d8a77b28d..eb007e403ec 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_CAMERAACTUATOR diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp b/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp index 38064739ff0..24b57b63655 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_CameraIpoSGController.h" diff --git a/source/gameengine/Ketsji/KX_CameraIpoSGController.h b/source/gameengine/Ketsji/KX_CameraIpoSGController.h index d80847fa5fb..33245e79c23 100644 --- a/source/gameengine/Ketsji/KX_CameraIpoSGController.h +++ b/source/gameengine/Ketsji/KX_CameraIpoSGController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_CAMERAIPOSGCONTROLLER_H #define KX_CAMERAIPOSGCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h index 237ec137a1c..5e8af0f040c 100644 --- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h +++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_CLIENTOBJECT_INFO_H #define __KX_CLIENTOBJECT_INFO_H diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index c53749131c0..bd843d97199 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_IActuator.h" diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index dfd39f1455c..a21a5f30de6 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_CONSTRAINTACTUATOR diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index 9ca9517c035..987125ca9ba 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include #include "KX_ConstraintWrapper.h" diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.h b/source/gameengine/Ketsji/KX_ConstraintWrapper.h index 12fd7fbe292..79fb3dc21aa 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.h +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_CONSTRAINT_WRAPPER #define KX_CONSTRAINT_WRAPPER diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h index 684e052323d..6653026f28a 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_CONVERTPHYSICSOBJECTS #define KX_CONVERTPHYSICSOBJECTS diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index ebbca137c5a..4a61c37be06 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef WIN32 #pragma warning (disable : 4786) diff --git a/source/gameengine/Ketsji/KX_EmptyObject.cpp b/source/gameengine/Ketsji/KX_EmptyObject.cpp index 4636f2f0a3e..25a6acd1ae4 100644 --- a/source/gameengine/Ketsji/KX_EmptyObject.cpp +++ b/source/gameengine/Ketsji/KX_EmptyObject.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_EmptyObject.h" diff --git a/source/gameengine/Ketsji/KX_EmptyObject.h b/source/gameengine/Ketsji/KX_EmptyObject.h index 46858b5c46d..62aa7fcd017 100644 --- a/source/gameengine/Ketsji/KX_EmptyObject.h +++ b/source/gameengine/Ketsji/KX_EmptyObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_EMPTYOBJECT #define __KX_EMPTYOBJECT diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index 1340a9c8497..fcd32d5f4fe 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_IActuator.h" diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index 5da10576dde..8565dc46caa 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -4,15 +4,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,7 +27,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // #ifndef __KX_GAMEACTUATOR diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 347caa3f9e6..1c508baca96 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Game object wrapper */ diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index b97e7d33f6b..87775e81216 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * General KX game object. */ diff --git a/source/gameengine/Ketsji/KX_IInterpolator.h b/source/gameengine/Ketsji/KX_IInterpolator.h index 6a59f537c8d..8c899a4db0b 100644 --- a/source/gameengine/Ketsji/KX_IInterpolator.h +++ b/source/gameengine/Ketsji/KX_IInterpolator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_IINTERPOLATOR_H #define KX_IINTERPOLATOR_H diff --git a/source/gameengine/Ketsji/KX_IPOTransform.h b/source/gameengine/Ketsji/KX_IPOTransform.h index 45c6d0d9459..f98cc1b2a75 100644 --- a/source/gameengine/Ketsji/KX_IPOTransform.h +++ b/source/gameengine/Ketsji/KX_IPOTransform.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_IPOTRANSFORM_H diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index a4cb9970492..5303e9a9e85 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Scenegraph controller for ipos. */ diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h index 1ebd6900741..7b5a151b41c 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.h +++ b/source/gameengine/Ketsji/KX_IPO_SGController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __IPO_SGCONTROLLER_H #define __IPO_SGCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.cpp b/source/gameengine/Ketsji/KX_IPhysicsController.cpp index c2328e45435..5cd66efd965 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_IPhysicsController.cpp @@ -2,15 +2,12 @@ * @file KX_IPhysicsController.cpp * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -28,7 +25,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_IPhysicsController.h" diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h index faf32bccbcd..009db40d3e8 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ b/source/gameengine/Ketsji/KX_IPhysicsController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_IPHYSICSCONTROLLER_H #define __KX_IPHYSICSCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_IScalarInterpolator.h b/source/gameengine/Ketsji/KX_IScalarInterpolator.h index f5d23d3e4e0..6ba685885e9 100644 --- a/source/gameengine/Ketsji/KX_IScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_IScalarInterpolator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_ISCALARINTERPOLATOR_H #define KX_ISCALARINTERPOLATOR_H diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index b2ec49b31ac..bba289bf891 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ISCENECONVERTER_H #define __KX_ISCENECONVERTER_H diff --git a/source/gameengine/Ketsji/KX_ISystem.h b/source/gameengine/Ketsji/KX_ISystem.h index bf404bd3af7..204e116e822 100644 --- a/source/gameengine/Ketsji/KX_ISystem.h +++ b/source/gameengine/Ketsji/KX_ISystem.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ISYSTEM diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 287634fc7ec..0f9caa456d9 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #if defined (__sgi) diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index 9a7d1a92751..79e8daa3f87 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_IPOACTUATOR diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 03ad5109adc..c098f37efa8 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * The engine ties all game modules together. */ diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index fcb4d0a0790..bc2e3864be8 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * */ #ifndef __KX_KETSJI_ENGINE diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 4a92ea4ac13..3ae09c01270 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 11fe7155c82..236d3e4e12e 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_LIGHT #define __KX_LIGHT diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.cpp b/source/gameengine/Ketsji/KX_LightIpoSGController.cpp index 45865b7a682..8aefd959134 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_LightIpoSGController.h" diff --git a/source/gameengine/Ketsji/KX_LightIpoSGController.h b/source/gameengine/Ketsji/KX_LightIpoSGController.h index deba37540d5..98870cf5b3f 100644 --- a/source/gameengine/Ketsji/KX_LightIpoSGController.h +++ b/source/gameengine/Ketsji/KX_LightIpoSGController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_LIGHTIPOSGCONTROLLER_H #define KX_LIGHTIPOSGCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index ebca3e13d7f..5c8fef1fca0 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index 9a8aa2a6f33..7c6202c15a4 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_MESHPROXY #define __KX_MESHPROXY diff --git a/source/gameengine/Ketsji/KX_MotionState.cpp b/source/gameengine/Ketsji/KX_MotionState.cpp index cd01c0466cd..15f100af915 100644 --- a/source/gameengine/Ketsji/KX_MotionState.cpp +++ b/source/gameengine/Ketsji/KX_MotionState.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_MotionState.h" #include "SG_Spatial.h" diff --git a/source/gameengine/Ketsji/KX_MotionState.h b/source/gameengine/Ketsji/KX_MotionState.h index d62dc1ed097..c83af664817 100644 --- a/source/gameengine/Ketsji/KX_MotionState.h +++ b/source/gameengine/Ketsji/KX_MotionState.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_MOTIONSTATE #define __KX_MOTIONSTATE diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 431efa07e0a..60b90138abe 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * KX_MouseFocusSensor determines mouse in/out/over events. */ diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index cf7af709c48..86f32fbf4be 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * KX_MouseFocusSensor determines mouse in/out/over events. */ diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 8f85a889d21..e646e8ef84f 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_NearSensor.h" diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index 599d6cce918..994090eea8c 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_NEARSENSOR_H diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp b/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp index b6d385da8ca..2b2f5d1b1ab 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_ObColorIpoSGController.h" diff --git a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h index 02a58ffd95a..6d63dd77683 100644 --- a/source/gameengine/Ketsji/KX_ObColorIpoSGController.h +++ b/source/gameengine/Ketsji/KX_ObColorIpoSGController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_OBCOLORIPOSGCONTROLLER_H #define KX_OBCOLORIPOSGCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 74f3dd1ef3b..22a406792f9 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_ObjectActuator.h" diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index 1ef3e34625a..edbae154b8b 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_OBJECTACTUATOR diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp index 58c04d34149..4e45ce484e3 100644 --- a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp @@ -1,7 +1,7 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * The contents of this file may be used under the terms of either the GNU * General Public License Version 2 or later (the "GPL", see @@ -17,7 +17,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_ConvertPhysicsObject.h" diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h index f5bc7dee165..07a0bee9775 100644 --- a/source/gameengine/Ketsji/KX_OdePhysicsController.h +++ b/source/gameengine/Ketsji/KX_OdePhysicsController.h @@ -1,7 +1,7 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * The contents of this file may be used under the terms of either the GNU * General Public License Version 2 or later (the "GPL", see @@ -17,7 +17,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_ODEPHYSICSCONTROLLER_H #define __KX_ODEPHYSICSCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp index 3d65e18a7d0..4b9f7d6e817 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_OrientationInterpolator.h" diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.h b/source/gameengine/Ketsji/KX_OrientationInterpolator.h index 1fb91ef785d..2bd9f69d824 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.h +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_ORIENTATIONINTERPOLATOR #define KX_ORIENTATIONINTERPOLATOR diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 288791eb994..5c433cb68b1 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -3,7 +3,7 @@ * * $Id: SCA_ParentActuator.cpp 13932 2008-03-01 19:05:41Z ben2610 $ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -29,7 +29,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_ParentActuator.h" diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 1bceacc9078..86dcd4e6c12 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -4,7 +4,7 @@ * * $Id: KX_ParentActuator.h 3271 2004-10-16 11:41:50Z kester $ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -30,7 +30,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_PARENTACTUATOR diff --git a/source/gameengine/Ketsji/KX_PhysicsEngineEnums.h b/source/gameengine/Ketsji/KX_PhysicsEngineEnums.h index bafc8620dfd..33e562eba57 100644 --- a/source/gameengine/Ketsji/KX_PhysicsEngineEnums.h +++ b/source/gameengine/Ketsji/KX_PhysicsEngineEnums.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_PHYSICSENGINEENUMS #define __KX_PHYSICSENGINEENUMS diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index 1bd5a0b3d42..27cfaefc076 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include #include "KX_PhysicsObjectWrapper.h" diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h index 3de94795b16..3dbd1be9323 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef PHYP_PHYSICSOBJECT_WRAPPER #define PHYP_PHYSICSOBJECT_WRAPPER diff --git a/source/gameengine/Ketsji/KX_PhysicsPropertiesobsolete.h b/source/gameengine/Ketsji/KX_PhysicsPropertiesobsolete.h index 09d9cffce98..0f30c18999f 100644 --- a/source/gameengine/Ketsji/KX_PhysicsPropertiesobsolete.h +++ b/source/gameengine/Ketsji/KX_PhysicsPropertiesobsolete.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_PROPSH #define KX_PROPSH diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 5a15a0375dc..93d6d5bb70d 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index a9bcba98a78..19015494e06 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_POLYGONMATERIAL_H__ #define __KX_POLYGONMATERIAL_H__ diff --git a/source/gameengine/Ketsji/KX_PositionInterpolator.cpp b/source/gameengine/Ketsji/KX_PositionInterpolator.cpp index eb8edcdca94..353c35a2f5a 100644 --- a/source/gameengine/Ketsji/KX_PositionInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_PositionInterpolator.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_PositionInterpolator.h" diff --git a/source/gameengine/Ketsji/KX_PositionInterpolator.h b/source/gameengine/Ketsji/KX_PositionInterpolator.h index 71f5b354088..bff0b4201c2 100644 --- a/source/gameengine/Ketsji/KX_PositionInterpolator.h +++ b/source/gameengine/Ketsji/KX_PositionInterpolator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_POSITIONINTERPOLATOR #define KX_POSITIONINTERPOLATOR diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 6fbf2888bd9..172882ff18d 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_PyConstraintBinding.h" #include "PHY_IPhysicsEnvironment.h" diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.h b/source/gameengine/Ketsji/KX_PyConstraintBinding.h index a8651a175c2..b898cba3796 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.h +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef PHY_PYTHON_CONSTRAINTBINDING #define PHY_PYTHON_CONSTRAINTBINDING diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index 1eee4e7043c..afb20acec2d 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Initialize Python thingies. */ diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index 96a3431fe07..e1715c9275f 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Initialize Python thingies. */ diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index b2e744dce4d..a2aff54d385 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Initialize Python thingies. */ diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index edb7cfe4a3f..c7d8f1b78bc 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_PYTHON_INIT #define __KX_PYTHON_INIT diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 45379f93b54..31fffffa3c1 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_RadarSensor.h" diff --git a/source/gameengine/Ketsji/KX_RadarSensor.h b/source/gameengine/Ketsji/KX_RadarSensor.h index 4f5ff994b40..7272b219e37 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.h +++ b/source/gameengine/Ketsji/KX_RadarSensor.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_RADAR_SENSOR_H #define __KX_RADAR_SENSOR_H diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index ea17e0b3dd6..ce7ed984985 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * KX_MouseFocusSensor determines mouse in/out/over events. */ diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h index 8bb21e28aca..607dabd8afc 100644 --- a/source/gameengine/Ketsji/KX_RayCast.h +++ b/source/gameengine/Ketsji/KX_RayCast.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_RAYCAST_H__ diff --git a/source/gameengine/Ketsji/KX_RayEventManager.cpp b/source/gameengine/Ketsji/KX_RayEventManager.cpp index 0fb1cee6446..4101c6b547e 100644 --- a/source/gameengine/Ketsji/KX_RayEventManager.cpp +++ b/source/gameengine/Ketsji/KX_RayEventManager.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_RayEventManager.h" #include "SCA_LogicManager.h" diff --git a/source/gameengine/Ketsji/KX_RayEventManager.h b/source/gameengine/Ketsji/KX_RayEventManager.h index 8aa1ed990cd..3630f9682b9 100644 --- a/source/gameengine/Ketsji/KX_RayEventManager.h +++ b/source/gameengine/Ketsji/KX_RayEventManager.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_RAYEVENTMGR diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 5c56f8f62b1..a85dc61cac8 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_RaySensor.h" diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index 0e05c6021c0..8a317ffaa07 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_RAYSENSOR_H diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 7366e374a10..76ce086ab97 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -3,15 +3,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // Previously existed as: // \source\gameengine\GameLogic\SCA_AddObjectActuator.cpp diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 60adcb27b12..2126a646303 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -5,15 +5,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -31,7 +28,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // // Previously existed as: // \source\gameengine\GameLogic\SCA_AddObjectActuator.h diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index 1df1ad1f27a..ec29448907f 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ // diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h index ca77d80027d..add9c05b000 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.h @@ -3,15 +3,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // // Previously existed as: // \source\gameengine\GameLogic\SCA_EndObjectActuator.h diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 221d531a1c2..630df2d21d9 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -3,15 +3,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // // Previously existed as: diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index 339fce54c49..5ba0a099b14 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -3,15 +3,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // // Previously existed as: // \source\gameengine\GameLogic\SCA_ReplaceMeshActuator.h diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp index 632cb753240..f085ff435dc 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h index 1f816726264..2a19d8a1784 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.h @@ -12,20 +12,16 @@ * KX_VertexParentRelation only location information is * inherited by the child. * - * @see SG_ParentRelation for more information about this * interface * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -43,7 +39,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * */ diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp index 540e14d06ea..0c8e7e28771 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_SG_NodeRelationships.h" diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h index f434cb5b648..d83fb79ee25 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h @@ -12,20 +12,16 @@ * KX_VertexParentRelation only location information is * inherited by the child. * - * @see SG_ParentRelation for more information about this * interface * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -43,7 +39,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * */ diff --git a/source/gameengine/Ketsji/KX_ScalarInterpolator.cpp b/source/gameengine/Ketsji/KX_ScalarInterpolator.cpp index 5e036600119..fa73aa9478b 100644 --- a/source/gameengine/Ketsji/KX_ScalarInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_ScalarInterpolator.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_ScalarInterpolator.h" diff --git a/source/gameengine/Ketsji/KX_ScalarInterpolator.h b/source/gameengine/Ketsji/KX_ScalarInterpolator.h index 72e8203d3c4..8835c98c184 100644 --- a/source/gameengine/Ketsji/KX_ScalarInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalarInterpolator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_SCALARINTERPOLATOR #define KX_SCALARINTERPOLATOR diff --git a/source/gameengine/Ketsji/KX_ScalingInterpolator.cpp b/source/gameengine/Ketsji/KX_ScalingInterpolator.cpp index c645eb6a3ea..8813cbd44d6 100644 --- a/source/gameengine/Ketsji/KX_ScalingInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_ScalingInterpolator.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_ScalingInterpolator.h" diff --git a/source/gameengine/Ketsji/KX_ScalingInterpolator.h b/source/gameengine/Ketsji/KX_ScalingInterpolator.h index 25c5cc87d83..a7b5d7e559a 100644 --- a/source/gameengine/Ketsji/KX_ScalingInterpolator.h +++ b/source/gameengine/Ketsji/KX_ScalingInterpolator.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_SCALINGINTERPOLATOR #define KX_SCALINGINTERPOLATOR diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index b2557a69527..1758b3bb955 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Ketsji scene. Holds references to all scene data. */ diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index b5de483e8f0..733df2f69a1 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_SCENE_H #define __KX_SCENE_H diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 7a9d144e92f..8f7cffd506f 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SCA_IActuator.h" diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index 6416e0f48d0..cfc79b93f8e 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -4,15 +4,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,7 +27,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // #ifndef __KX_SCENEACTUATOR diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index f7a2001fcdf..949156571a7 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * */ diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index 796e202df70..5a9edbc4c5e 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_SOUNDACTUATOR diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h index d214091a8c6..868465c8f10 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_SUMOPHYSICSCONTROLLER_H #define __KX_SUMOPHYSICSCONTROLLER_H diff --git a/source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp b/source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp index 61bd0385972..b75a213fa3b 100644 --- a/source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp +++ b/source/gameengine/Ketsji/KX_TimeCategoryLogger.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_TimeCategoryLogger.h" diff --git a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h index b96b1202f4c..0cc34b53736 100644 --- a/source/gameengine/Ketsji/KX_TimeCategoryLogger.h +++ b/source/gameengine/Ketsji/KX_TimeCategoryLogger.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_TIME_CATEGORY_LOGGER_H diff --git a/source/gameengine/Ketsji/KX_TimeLogger.cpp b/source/gameengine/Ketsji/KX_TimeLogger.cpp index 766c541b4fc..db4a67aa766 100644 --- a/source/gameengine/Ketsji/KX_TimeLogger.cpp +++ b/source/gameengine/Ketsji/KX_TimeLogger.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_TimeLogger.h" diff --git a/source/gameengine/Ketsji/KX_TimeLogger.h b/source/gameengine/Ketsji/KX_TimeLogger.h index ab3d721e7d2..0962f02a877 100644 --- a/source/gameengine/Ketsji/KX_TimeLogger.h +++ b/source/gameengine/Ketsji/KX_TimeLogger.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_TIME_LOGGER_H diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index 8e546b896bc..80ee15a9475 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_TouchEventManager.h" diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h index 73b868278db..20ed6126bd0 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.h +++ b/source/gameengine/Ketsji/KX_TouchEventManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_TOUCHEVENTMANAGER #define __KX_TOUCHEVENTMANAGER diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 7e3904113ab..c4a01d5918c 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_TouchSensor.h" diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index 9781bdb3769..f594196628a 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_TOUCHSENSOR diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 36f0d3c3b99..dc637bf0837 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -3,15 +3,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // todo: not all trackflags / upflags are implemented/tested ! // m_trackflag is used to determine the forward tracking direction diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index 1d257da3f53..944eaadf025 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -3,15 +3,12 @@ // // $Id$ // -// ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +// ***** BEGIN GPL LICENSE BLOCK ***** // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. The Blender -// Foundation also sells licenses for use in proprietary software under -// the Blender License. See http://www.blender.org/BL/ for information -// about this. +// of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ // // Contributor(s): none yet. // -// ***** END GPL/BL DUAL LICENSE BLOCK ***** +// ***** END GPL LICENSE BLOCK ***** // #ifndef __KX_TrackToActuator diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 9c5f3f611b6..5cec65dff1c 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Ketsji/KX_VertexProxy.h b/source/gameengine/Ketsji/KX_VertexProxy.h index acae9cf5a34..e154ea11b40 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.h +++ b/source/gameengine/Ketsji/KX_VertexProxy.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_VERTEXPROXY #define __KX_VERTEXPROXY diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 8ec3e05e303..b4693a7a7db 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Actuator to toggle visibility/invisibility of objects */ diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h index 9a78eb1cc07..9b4753033fb 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.h +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Actuator to toggle visibility/invisibility of objects */ diff --git a/source/gameengine/Ketsji/KX_WorldInfo.cpp b/source/gameengine/Ketsji/KX_WorldInfo.cpp index c2e696f856e..9b9ed174085 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.cpp +++ b/source/gameengine/Ketsji/KX_WorldInfo.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_WorldInfo.h" diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h index ecc0c04a17b..fe4e0c51b24 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.h +++ b/source/gameengine/Ketsji/KX_WorldInfo.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_WORLDINFO_H #define __KX_WORLDINFO_H diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.cpp b/source/gameengine/Ketsji/KX_WorldIpoController.cpp index ded251f391e..e69c9b46ffd 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.cpp +++ b/source/gameengine/Ketsji/KX_WorldIpoController.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "KX_WorldIpoController.h" diff --git a/source/gameengine/Ketsji/KX_WorldIpoController.h b/source/gameengine/Ketsji/KX_WorldIpoController.h index 562a2769807..d90c03d09ee 100644 --- a/source/gameengine/Ketsji/KX_WorldIpoController.h +++ b/source/gameengine/Ketsji/KX_WorldIpoController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef KX_WORLDIPOCONTROLLER_H #define KX_WORLDIPOCONTROLLER_H diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index 502e8949e7a..e6e541d0931 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Makefile b/source/gameengine/Makefile index 00503e9f8b4..1d3bc8c2058 100644 --- a/source/gameengine/Makefile +++ b/source/gameengine/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # Bounces make to subdirectories. diff --git a/source/gameengine/Network/CMakeLists.txt b/source/gameengine/Network/CMakeLists.txt index df002ca00b7..933f0550d0b 100644 --- a/source/gameengine/Network/CMakeLists.txt +++ b/source/gameengine/Network/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) diff --git a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt index 2ced70eab5a..0b958920dc5 100644 --- a/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt +++ b/source/gameengine/Network/LoopBackNetwork/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SET(SRC NG_LoopBackNetworkDeviceInterface.cpp) diff --git a/source/gameengine/Network/LoopBackNetwork/Makefile b/source/gameengine/Network/LoopBackNetwork/Makefile index 19fe362b8f7..690fd644094 100644 --- a/source/gameengine/Network/LoopBackNetwork/Makefile +++ b/source/gameengine/Network/LoopBackNetwork/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp index e36aa4750af..60b1201d45e 100644 --- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp +++ b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * LoopbackNetworkDeviceInterface derived from NG_NetworkDeviceInterface */ diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h index bedf27b292b..62913c7f911 100644 --- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h +++ b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * LoopbackNetworkDeviceInterface derived from NG_NetworkDeviceInterface */ #ifndef NG_LOOPBACKNETWORKDEVICEINTERFACE_H diff --git a/source/gameengine/Network/Makefile b/source/gameengine/Network/Makefile index dd4819f46e5..c6b22276113 100644 --- a/source/gameengine/Network/Makefile +++ b/source/gameengine/Network/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Network/NG_NetworkDeviceInterface.h b/source/gameengine/Network/NG_NetworkDeviceInterface.h index 7975fee540c..4a47774a762 100644 --- a/source/gameengine/Network/NG_NetworkDeviceInterface.h +++ b/source/gameengine/Network/NG_NetworkDeviceInterface.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * NetworkGameengine_NetworkDeviceInterface * Functions like (de)initialize network, get library version * To be derived by loopback and network libraries diff --git a/source/gameengine/Network/NG_NetworkMessage.cpp b/source/gameengine/Network/NG_NetworkMessage.cpp index 44f13ae40c4..bc85c9bc353 100644 --- a/source/gameengine/Network/NG_NetworkMessage.cpp +++ b/source/gameengine/Network/NG_NetworkMessage.cpp @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * generic Network Message implementation */ #include "NG_NetworkMessage.h" diff --git a/source/gameengine/Network/NG_NetworkMessage.h b/source/gameengine/Network/NG_NetworkMessage.h index b3efea402b2..687c8120eca 100644 --- a/source/gameengine/Network/NG_NetworkMessage.h +++ b/source/gameengine/Network/NG_NetworkMessage.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * NetworkGame_NetworkMessage generic Network Message class */ #ifndef NG_NETWORKMESSAGE_H diff --git a/source/gameengine/Network/NG_NetworkObject.cpp b/source/gameengine/Network/NG_NetworkObject.cpp index 02805a9f91a..b6a3d93894c 100644 --- a/source/gameengine/Network/NG_NetworkObject.cpp +++ b/source/gameengine/Network/NG_NetworkObject.cpp @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * NetworkGame_NetworkObject generic Network Object implementation */ #include "NG_NetworkObject.h" diff --git a/source/gameengine/Network/NG_NetworkObject.h b/source/gameengine/Network/NG_NetworkObject.h index b5499010512..c01d76a47fc 100644 --- a/source/gameengine/Network/NG_NetworkObject.h +++ b/source/gameengine/Network/NG_NetworkObject.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * NetworkGame_NetworkObject generic Network Object class */ #ifndef NG_NETWORKOBJECT_H diff --git a/source/gameengine/Network/NG_NetworkScene.cpp b/source/gameengine/Network/NG_NetworkScene.cpp index c66eb3730ac..22263a2bdda 100644 --- a/source/gameengine/Network/NG_NetworkScene.cpp +++ b/source/gameengine/Network/NG_NetworkScene.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * NetworkSceneManagement generic implementation */ #include diff --git a/source/gameengine/Network/NG_NetworkScene.h b/source/gameengine/Network/NG_NetworkScene.h index da3855d08bb..58de9cf6af2 100644 --- a/source/gameengine/Network/NG_NetworkScene.h +++ b/source/gameengine/Network/NG_NetworkScene.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * NetworkSceneManagement generic class */ #ifndef __NG_NETWORKSCENE_H diff --git a/source/gameengine/Network/TerraplayNetwork/Makefile b/source/gameengine/Network/TerraplayNetwork/Makefile index 6fad0e0ca43..d987263d433 100644 --- a/source/gameengine/Network/TerraplayNetwork/Makefile +++ b/source/gameengine/Network/TerraplayNetwork/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Network/TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.cpp b/source/gameengine/Network/TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.cpp index 44a7e571b03..40446ca1232 100644 --- a/source/gameengine/Network/TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.cpp +++ b/source/gameengine/Network/TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.cpp @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * TerraplayNetworkDeviceInterface derived from NG_NetworkDeviceInterface */ diff --git a/source/gameengine/Network/TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.h b/source/gameengine/Network/TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.h index 384d70838a2..499362b6f8d 100644 --- a/source/gameengine/Network/TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.h +++ b/source/gameengine/Network/TerraplayNetwork/NG_TerraplayNetworkDeviceInterface.h @@ -1,15 +1,12 @@ /* * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * TerraplayNetworkDeviceInterface derived from NG_NetworkDeviceInterface */ #ifndef NG_TERRAPLAYNETWORKDEVICEINTERFACE_H diff --git a/source/gameengine/Physics/BlOde/Makefile b/source/gameengine/Physics/BlOde/Makefile index b85c8b13bc4..1fbbf198377 100644 --- a/source/gameengine/Physics/BlOde/Makefile +++ b/source/gameengine/Physics/BlOde/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp index a0fe068ab5c..efe4554d970 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsController.cpp +++ b/source/gameengine/Physics/BlOde/OdePhysicsController.cpp @@ -1,7 +1,7 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * The contents of this file may be used under the terms of either the GNU * General Public License Version 2 or later (the "GPL", see @@ -17,7 +17,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #define USE_ODE diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.h b/source/gameengine/Physics/BlOde/OdePhysicsController.h index 4f4acb5cd18..d3eb443ed3a 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsController.h +++ b/source/gameengine/Physics/BlOde/OdePhysicsController.h @@ -1,7 +1,7 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * The contents of this file may be used under the terms of either the GNU * General Public License Version 2 or later (the "GPL", see @@ -17,7 +17,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __ODE_PHYSICSCONTROLLER_H #define __ODE_PHYSICSCONTROLLER_H diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp index f6382ec775c..a04560aaf09 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp +++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp @@ -1,7 +1,7 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * The contents of this file may be used under the terms of either the GNU * General Public License Version 2 or later (the "GPL", see @@ -17,7 +17,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "OdePhysicsEnvironment.h" #include "PHY_IMotionState.h" diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h index bddc1e03be1..ec1b7702ffd 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h +++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h @@ -1,7 +1,7 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * The contents of this file may be used under the terms of either the GNU * General Public License Version 2 or later (the "GPL", see @@ -17,7 +17,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _ODEPHYSICSENVIRONMENT #define _ODEPHYSICSENVIRONMENT diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index af67d4b126d..b610fd1bbb0 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SET(SRC CcdPhysicsEnvironment.cpp CcdPhysicsController.cpp) diff --git a/source/gameengine/Physics/Bullet/Makefile b/source/gameengine/Physics/Bullet/Makefile index a5643b60c94..49259d0a67c 100644 --- a/source/gameengine/Physics/Bullet/Makefile +++ b/source/gameengine/Physics/Bullet/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Physics/Dummy/CMakeLists.txt b/source/gameengine/Physics/Dummy/CMakeLists.txt index 4db44a5d42c..4bd29e7779b 100644 --- a/source/gameengine/Physics/Dummy/CMakeLists.txt +++ b/source/gameengine/Physics/Dummy/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SET(SRC DummyPhysicsEnvironment.cpp) diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp index b40d1b430bb..f512d44c9f2 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "DummyPhysicsEnvironment.h" #include "PHY_IMotionState.h" diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 4fc970da699..f0761618e4e 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _DUMMYPHYSICSENVIRONMENT #define _DUMMYPHYSICSENVIRONMENT diff --git a/source/gameengine/Physics/Dummy/Makefile b/source/gameengine/Physics/Dummy/Makefile index 0ecb3fa786a..b0c1b855322 100644 --- a/source/gameengine/Physics/Dummy/Makefile +++ b/source/gameengine/Physics/Dummy/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Physics/Makefile b/source/gameengine/Physics/Makefile index 62e433cb72c..b192e497f35 100644 --- a/source/gameengine/Physics/Makefile +++ b/source/gameengine/Physics/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # Bounces make to subdirectories. diff --git a/source/gameengine/Physics/Sumo/CMakeLists.txt b/source/gameengine/Physics/Sumo/CMakeLists.txt index d552a9a821c..c57a4af6706 100644 --- a/source/gameengine/Physics/Sumo/CMakeLists.txt +++ b/source/gameengine/Physics/Sumo/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SET(SRC SumoPHYCallbackBridge.cpp diff --git a/source/gameengine/Physics/Sumo/Fuzzics/Makefile b/source/gameengine/Physics/Sumo/Fuzzics/Makefile index 557be7a1bd4..5ed2c31a1d0 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/Makefile +++ b/source/gameengine/Physics/Sumo/Fuzzics/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # Bounces make to subdirectories. diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h index 4db531d945d..b03612ed15e 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h +++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_FhObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef SM_FHOBJECT_H #define SM_FHOBJECT_H diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h index 08e29265d0c..fdc45af5225 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h +++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_MotionState.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef SM_MOTIONSTATE_H #define SM_MOTIONSTATE_H diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h index 8b70bbc5779..2d748a0f251 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h +++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Object.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef SM_OBJECT_H #define SM_OBJECT_H diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h index fb3f13c7b96..81b4cb55b45 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h +++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Props.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef SM_PROPSH #define SM_PROPSH diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h index a0d5c983031..2326bdee523 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h +++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Scene.h @@ -3,15 +3,12 @@ * Copyright (C) 2001 NaN Technologies B.V. * The physics scene. * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef SM_SCENE_H #define SM_SCENE_H diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp index e905459ce21..d866cdb4922 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_FhObject.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SM_FhObject.h" #include "MT_MinMax.h" diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp index 1fadbdadfa0..b8f4e0c591c 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_MotionState.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include #include diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp index c8a191cad0d..4b2c7cae008 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp @@ -3,15 +3,12 @@ * Copyright (C) 2001 NaN Technologies B.V. * The basic physics object. * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp index 656051be4f5..b5bf67b14ea 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp @@ -3,15 +3,12 @@ * Copyright (C) 2001 NaN Technologies B.V. * The physics scene. * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Physics/Sumo/Makefile b/source/gameengine/Physics/Sumo/Makefile index bc1300c1994..69efc4d84eb 100644 --- a/source/gameengine/Physics/Sumo/Makefile +++ b/source/gameengine/Physics/Sumo/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp index 57922e856c4..3451e6c3ec8 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp +++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp @@ -1,15 +1,12 @@ /** * @file $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SumoPhysicsController.h" diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.h b/source/gameengine/Physics/Sumo/SumoPhysicsController.h index 349c8cc24a6..95f01b45f2b 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsController.h +++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.h @@ -1,15 +1,12 @@ /** * @file $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __SUMO_PHYSICSCONTROLLER_H #define __SUMO_PHYSICSCONTROLLER_H diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp index 67a74d11564..16ba45a0be5 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SumoPhysicsEnvironment.h" #include "PHY_IMotionState.h" diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h index 4d17d0c21fd..ce5cd70e8cc 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _SUMOPhysicsEnvironment #define _SUMOPhysicsEnvironment diff --git a/source/gameengine/Physics/common/CMakeLists.txt b/source/gameengine/Physics/common/CMakeLists.txt index 57e835bb4c2..a28fabe0c3a 100644 --- a/source/gameengine/Physics/common/CMakeLists.txt +++ b/source/gameengine/Physics/common/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** SET(SRC PHY_IMotionState.cpp PHY_IPhysicsController.cpp PHY_IPhysicsEnvironment.cpp PHY_IVehicle.cpp) diff --git a/source/gameengine/Physics/common/Makefile b/source/gameengine/Physics/common/Makefile index e0f72571c96..e3edd426c36 100644 --- a/source/gameengine/Physics/common/Makefile +++ b/source/gameengine/Physics/common/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Physics/common/PHY_IMotionState.cpp b/source/gameengine/Physics/common/PHY_IMotionState.cpp index 355f1910dc1..e25eb21b22e 100644 --- a/source/gameengine/Physics/common/PHY_IMotionState.cpp +++ b/source/gameengine/Physics/common/PHY_IMotionState.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "PHY_IMotionState.h" diff --git a/source/gameengine/Physics/common/PHY_IMotionState.h b/source/gameengine/Physics/common/PHY_IMotionState.h index 3dc319e040e..d759b0aeff4 100644 --- a/source/gameengine/Physics/common/PHY_IMotionState.h +++ b/source/gameengine/Physics/common/PHY_IMotionState.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef PHY__MOTIONSTATE_H #define PHY__MOTIONSTATE_H diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.cpp b/source/gameengine/Physics/common/PHY_IPhysicsController.cpp index 34849a55817..f321001215a 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsController.cpp +++ b/source/gameengine/Physics/common/PHY_IPhysicsController.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "PHY_IPhysicsController.h" diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h index ba1fb8473d3..ca8edea114a 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsController.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef PHY_IPHYSICSCONTROLLER_H #define PHY_IPHYSICSCONTROLLER_H diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.cpp b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.cpp index 2ba982b4442..d5ec436ba0e 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "PHY_IPhysicsEnvironment.h" diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index d90b3d82e6b..c148210903f 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _IPHYSICSENVIRONMENT diff --git a/source/gameengine/Physics/common/PHY_Pro.h b/source/gameengine/Physics/common/PHY_Pro.h index dddd93df7b4..32e63ac2f6d 100644 --- a/source/gameengine/Physics/common/PHY_Pro.h +++ b/source/gameengine/Physics/common/PHY_Pro.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef PHY_PROPSH #define PHY_PROPSH diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 9fe43a5bef7..e604fe0e133 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile index 7cda8ae5376..9cde6069167 100644 --- a/source/gameengine/Rasterizer/Makefile +++ b/source/gameengine/Rasterizer/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index d5a870a0040..39f81bd1156 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -1,5 +1,5 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,7 +25,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #define STRINGIFY(A) #A diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index 227d2a26d41..cff868556e0 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_I2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 9c28aedd994..6c3e89fa69d 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index 11633f555ea..010478b1d5b 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ // this will be put in a class later on diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index 69a43dd64e9..99c0c412cf7 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_CAMERADATA_H #define __RAS_CAMERADATA_H diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 9aeb85c5740..bea68e203a9 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef RAS_DEFORMER diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.cpp b/source/gameengine/Rasterizer/RAS_FramingManager.cpp index 131893bd79f..e2bbca48bb5 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.cpp +++ b/source/gameengine/Rasterizer/RAS_FramingManager.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "RAS_FramingManager.h" diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h index 8b3cc1b2f19..dcb48c1c2a0 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.h +++ b/source/gameengine/Rasterizer/RAS_FramingManager.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef RAS_FRAMINGMANAGER_H #define RAS_FRAMINGMANAGER_H diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index f1f2a8bcf62..d799dc9c9bb 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_ICANVAS #define __RAS_ICANVAS diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index b5882bd48c4..61860c4c405 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "RAS_IPolygonMaterial.h" diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index c02ff7c3566..3284ddb7ddd 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_IPOLYGONMATERIAL #define __RAS_IPOLYGONMATERIAL diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 560c6741260..5e8b5ad8276 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_IRASTERIZER #define __RAS_IRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp b/source/gameengine/Rasterizer/RAS_IRenderTools.cpp index aa0053f3d1d..2be9bb75ebf 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "RAS_IRenderTools.h" diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index 771c34a595f..30c96d02847 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_IRENDERTOOLS #define __RAS_IRENDERTOOLS diff --git a/source/gameengine/Rasterizer/RAS_LightObject.h b/source/gameengine/Rasterizer/RAS_LightObject.h index 2c22a588d76..4c54857dc39 100644 --- a/source/gameengine/Rasterizer/RAS_LightObject.h +++ b/source/gameengine/Rasterizer/RAS_LightObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_LIGHTOBJECT_H #define __RAS_LIGHTOBJECT_H diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 757784be87f..4642ffbaeb8 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "RAS_MaterialBucket.h" diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index ded6af999c4..5ad0c173a56 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_MATERIALBUCKET #define __RAS_MATERIALBUCKET diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index b7147ea6c42..e4b654343e7 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index bf7d47061ef..89c472cd0d4 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_MESHOBJECT #define __RAS_MESHOBJECT diff --git a/source/gameengine/Rasterizer/RAS_ObjectColor.h b/source/gameengine/Rasterizer/RAS_ObjectColor.h index 1592fc57e77..d7fb8b210f4 100644 --- a/source/gameengine/Rasterizer/RAS_ObjectColor.h +++ b/source/gameengine/Rasterizer/RAS_ObjectColor.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_OBJECTCOLOR_H #define __RAS_OBJECTCOLOR_H diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h index ac4c2456573..33c4b3faab0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_BLUR2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h index 44f67af3d75..c41e5ac06af 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_DILATION2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h index 80b6f184c36..2bb357c958a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_EROSION2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h index 29cc91814ce..7324edd4e92 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_GRAYSCALE2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h index a3482f9647f..5d90fe3475b 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_INVERT2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h index 636ecdb68aa..cbe926976df 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_LAPLACION2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h index 8046aacfbb1..7cd1082e5e3 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_PREWITT2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h index b56911a48b4..d1c16f39823 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_SEPIA2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h index e5f942a535c..14e0be6df9d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_SHARPEN2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h index 545e76601e8..40c17c285ce 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h @@ -1,13 +1,10 @@ /** - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_SOBEL2DFILTER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index d96df751b85..5153834899b 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile index a63ac28f432..b0d79dcc897 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # Bounce make to subdirectories. # diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp index 77a72c064ee..81a7ccb7a5d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ /* The extension manager's job is to link at runtime OpenGL extension diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h index ae57ae77fb8..05eb73b315f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_GLEXTENSIONMANAGER_H__ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 40252e7aff9..ea41b2f7d13 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 6728905aa57..c63a7b80b7c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_OPENGLRASTERIZER #define __RAS_OPENGLRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index 0a4557d12a4..ddfcc3f3f9d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h index 06a6fb4bb3a..4d478b0171f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __KX_VERTEXARRAYOPENGLRASTERIZER #define __KX_VERTEXARRAYOPENGLRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py index 8e64ecd1741..8f4065b3d6a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py @@ -1,15 +1,12 @@ #!/usr/bin/python # # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # mkglext.py generates code for linking extensions. diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp index 310c58882c9..852c94def3f 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.cpp +++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifdef HAVE_CONFIG_H diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h index 253faec6e95..7ce7926a816 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.h +++ b/source/gameengine/Rasterizer/RAS_Polygon.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_POLYGON #define __RAS_POLYGON diff --git a/source/gameengine/Rasterizer/RAS_Rect.h b/source/gameengine/Rasterizer/RAS_Rect.h index 51d8e2cc465..4cd0c636cfd 100644 --- a/source/gameengine/Rasterizer/RAS_Rect.h +++ b/source/gameengine/Rasterizer/RAS_Rect.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef _RAS_RECT diff --git a/source/gameengine/Rasterizer/RAS_TexMatrix.h b/source/gameengine/Rasterizer/RAS_TexMatrix.h index 2aceca4e1ce..9b8be562a0c 100644 --- a/source/gameengine/Rasterizer/RAS_TexMatrix.h +++ b/source/gameengine/Rasterizer/RAS_TexMatrix.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RASTEXMATRIX #define __RASTEXMATRIX diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp index 79e6cbdb7db..61ac456b2bc 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.cpp +++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "RAS_TexVert.h" diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h index b177f096dbc..84135db918f 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.h +++ b/source/gameengine/Rasterizer/RAS_TexVert.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __RAS_TEXVERT #define __RAS_TEXVERT diff --git a/source/gameengine/Rasterizer/RAS_texmatrix.cpp b/source/gameengine/Rasterizer/RAS_texmatrix.cpp index 791d6e3dc7d..b9bb6fa923f 100644 --- a/source/gameengine/Rasterizer/RAS_texmatrix.cpp +++ b/source/gameengine/Rasterizer/RAS_texmatrix.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "RAS_TexMatrix.h" diff --git a/source/gameengine/SceneGraph/CMakeLists.txt b/source/gameengine/SceneGraph/CMakeLists.txt index 1cc9d7b7acf..0409b8c0ac4 100644 --- a/source/gameengine/SceneGraph/CMakeLists.txt +++ b/source/gameengine/SceneGraph/CMakeLists.txt @@ -1,13 +1,10 @@ # $Id$ -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -25,7 +22,7 @@ # # Contributor(s): Jacques Beaurain. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) diff --git a/source/gameengine/SceneGraph/Makefile b/source/gameengine/SceneGraph/Makefile index bc184c8faba..acec1b729e8 100644 --- a/source/gameengine/SceneGraph/Makefile +++ b/source/gameengine/SceneGraph/Makefile @@ -1,15 +1,12 @@ # # $Id$ # -# ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** +# ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. The Blender -# Foundation also sells licenses for use in proprietary software under -# the Blender License. See http://www.blender.org/BL/ for information -# about this. +# of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ # # Contributor(s): none yet. # -# ***** END GPL/BL DUAL LICENSE BLOCK ***** +# ***** END GPL LICENSE BLOCK ***** # # diff --git a/source/gameengine/SceneGraph/SG_BBox.cpp b/source/gameengine/SceneGraph/SG_BBox.cpp index 6f06e9b0424..4bd2805978e 100644 --- a/source/gameengine/SceneGraph/SG_BBox.cpp +++ b/source/gameengine/SceneGraph/SG_BBox.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Bounding Box */ diff --git a/source/gameengine/SceneGraph/SG_BBox.h b/source/gameengine/SceneGraph/SG_BBox.h index 5a4d396faf1..b7e8ff65865 100644 --- a/source/gameengine/SceneGraph/SG_BBox.h +++ b/source/gameengine/SceneGraph/SG_BBox.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Bounding Box */ diff --git a/source/gameengine/SceneGraph/SG_Controller.cpp b/source/gameengine/SceneGraph/SG_Controller.cpp index 86dbc7c2c42..4b644297f06 100644 --- a/source/gameengine/SceneGraph/SG_Controller.cpp +++ b/source/gameengine/SceneGraph/SG_Controller.cpp @@ -1,15 +1,12 @@ /** * @file SG_Controller.cpp * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SG_Controller.h" diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h index b5bb6943479..d65a2f0c256 100644 --- a/source/gameengine/SceneGraph/SG_Controller.h +++ b/source/gameengine/SceneGraph/SG_Controller.h @@ -3,15 +3,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,7 +26,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __SG_CONTROLLER_H diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp index 4787847da0d..c347bbc6d9a 100644 --- a/source/gameengine/SceneGraph/SG_IObject.cpp +++ b/source/gameengine/SceneGraph/SG_IObject.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SG_IObject.h" diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index b0c1d64cf69..438ab48c556 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __SG_IOBJECT #define __SG_IOBJECT diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index aaacd43646b..73e16863173 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -1,14 +1,11 @@ /** * $Id$ - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -26,7 +23,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SG_Node.h" diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 7ba13cc0a87..4808f6f7d94 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __SG_NODE_H #define __SG_NODE_H diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index d4a8e7e8cb3..1d211a9f39f 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -20,15 +20,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -46,7 +43,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * */ diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index 6ad5cf9912a..18049592977 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include "SG_Node.h" diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h index 1f1e97a5b56..a70784472a7 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.h +++ b/source/gameengine/SceneGraph/SG_Spatial.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #ifndef __SG_SPATIAL_H diff --git a/source/gameengine/SceneGraph/SG_Tree.cpp b/source/gameengine/SceneGraph/SG_Tree.cpp index 0bad621ff07..2704ab36179 100644 --- a/source/gameengine/SceneGraph/SG_Tree.cpp +++ b/source/gameengine/SceneGraph/SG_Tree.cpp @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Bounding Box */ diff --git a/source/gameengine/SceneGraph/SG_Tree.h b/source/gameengine/SceneGraph/SG_Tree.h index 0877668c53d..4741af83aae 100644 --- a/source/gameengine/SceneGraph/SG_Tree.h +++ b/source/gameengine/SceneGraph/SG_Tree.h @@ -1,15 +1,12 @@ /** * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. The Blender - * Foundation also sells licenses for use in proprietary software under - * the Blender License. See http://www.blender.org/BL/ for information - * about this. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,7 +24,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** * Bounding Box */ -- cgit v1.2.3 From 1fc1fb117ea56765267a74a93ab3cc09f6d89abd Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 18 Apr 2008 22:22:50 +0000 Subject: BGE: fix compilation error with 2D filters on System without GL extenstion: add conditional compile statements --- source/gameengine/Ketsji/BL_Shader.cpp | 2 +- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 3bd5146f28f..105a87e767b 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -1428,8 +1428,8 @@ KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) bgl::blBindAttribLocationARB(mShader, mAttr, "Tangent"); Py_Return; } - return NULL; #endif + return NULL; } diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 39f81bd1156..e03133b9031 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -91,7 +91,8 @@ RAS_2DFilterManager::~RAS_2DFilterManager() unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) { - GLuint program; + GLuint program = 0; +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) GLuint fShader = bgl::blCreateShaderObjectARB(GL_FRAGMENT_SHADER); GLint success; @@ -127,6 +128,7 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) std::cout << "2dFilters - Shader program validation error" << std::endl; return 0; } +#endif return program; } @@ -160,7 +162,8 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) { - GLint uniformLoc; +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) + GLint uniformLoc; bgl::blUseProgramObjectARB(shaderprogram); uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); if (uniformLoc != -1) @@ -182,12 +185,14 @@ void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) { bgl::blUniform1fARB(uniformLoc,textureheight); } - +#endif } void RAS_2DFilterManager::EndShaderProgram() { +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) bgl::blUseProgramObjectARB(0); +#endif } void RAS_2DFilterManager::SetupTexture() @@ -297,6 +302,7 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str { if(!isshadersupported) return; +#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) if(pass<0 || pass>=MAX_RENDER_PASS) return; @@ -337,4 +343,5 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str m_filters[pass] = CreateShaderProgram(mode); m_enabled[pass] = 1; } +#endif } -- cgit v1.2.3 From b0049e608859bd129bb5c13fecdd161811741185 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 19 Apr 2008 21:09:40 +0000 Subject: fix BGE bug #8094: Collision sensor on child object makes the object rotate or move very fast. Collision sensor can now be set on child object without side effect. --- source/gameengine/Ketsji/KX_NearSensor.cpp | 15 +++++++++++++++ source/gameengine/Ketsji/KX_NearSensor.h | 1 + source/gameengine/Ketsji/KX_TouchSensor.cpp | 14 ++------------ 3 files changed, 18 insertions(+), 12 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index e646e8ef84f..4086ac53f2a 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -75,6 +75,21 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr, SynchronizeTransform(); } +void KX_NearSensor::SynchronizeTransform() +{ + // The near and radar sensors are using a different physical object which is + // not linked to the parent object, must synchronize it. + if (m_physCtrl) + { + KX_GameObject* parent = ((KX_GameObject*)GetParent()); + MT_Vector3 pos = parent->NodeGetWorldPosition(); + MT_Quaternion orn = parent->NodeGetWorldOrientation().getRotation(); + m_physCtrl->setPosition(pos.x(),pos.y(),pos.z()); + m_physCtrl->setOrientation(orn.x(),orn.y(),orn.z(),orn.w()); + m_physCtrl->calcXform(); + } +} + void KX_NearSensor::RegisterSumo(KX_TouchEventManager *touchman) { if (m_physCtrl) diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index 994090eea8c..c6724caccc3 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -68,6 +68,7 @@ public: PyTypeObject* T=&Type); */ virtual ~KX_NearSensor(); + virtual void SynchronizeTransform(); virtual CValue* GetReplica(); virtual bool Evaluate(CValue* event); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index c4a01d5918c..3f185359de0 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -48,18 +48,8 @@ void KX_TouchSensor::SynchronizeTransform() { - - if (m_physCtrl) - { - - KX_GameObject* parent = ((KX_GameObject*)GetParent()); - MT_Vector3 pos = parent->NodeGetWorldPosition(); - MT_Quaternion orn = parent->NodeGetWorldOrientation().getRotation(); - m_physCtrl->setPosition(pos.x(),pos.y(),pos.z()); - m_physCtrl->setOrientation(orn.x(),orn.y(),orn.z(),orn.w()); - m_physCtrl->calcXform(); - } - + // the touch sensor does not require any synchronization: it uses + // the same physical object which is already synchronized by Blender } -- cgit v1.2.3 From bdf5c0689b1617118cd7f327139a928ec04c47bf Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 19 Apr 2008 21:15:37 +0000 Subject: BGE bug fix: crash at exit when object with Radar/Near sensor has debug properties --- source/gameengine/GameLogic/SCA_IScene.cpp | 12 ++++++++---- source/gameengine/GameLogic/SCA_IScene.h | 1 + source/gameengine/Ketsji/KX_Scene.cpp | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_IScene.cpp b/source/gameengine/GameLogic/SCA_IScene.cpp index 9a17d1f384f..9fbeb706910 100644 --- a/source/gameengine/GameLogic/SCA_IScene.cpp +++ b/source/gameengine/GameLogic/SCA_IScene.cpp @@ -47,16 +47,20 @@ SCA_IScene::SCA_IScene() { } - - -SCA_IScene::~SCA_IScene() +void SCA_IScene::RemoveAllDebugProperties() { - // release debugprop list for (std::vector::iterator it = m_debugList.begin(); !(it==m_debugList.end());it++) { delete (*it); } + m_debugList.clear(); +} + + +SCA_IScene::~SCA_IScene() +{ + RemoveAllDebugProperties(); } diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h index 23c9c37fd6e..d18778a37c2 100644 --- a/source/gameengine/GameLogic/SCA_IScene.h +++ b/source/gameengine/GameLogic/SCA_IScene.h @@ -59,6 +59,7 @@ public: std::vector& GetDebugProperties(); void AddDebugProperty(class CValue* debugprop, const STR_String &name); + void RemoveAllDebugProperties(); }; #endif //__KX_ISCENE_H diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 1758b3bb955..0fbabe8d6a2 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -178,7 +178,11 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, KX_Scene::~KX_Scene() { - + // The release of debug properties used to be in SCA_IScene::~SCA_IScene + // It's still there but we remove all properties here otherwise some + // reference might be hanging and causing late release of objects + RemoveAllDebugProperties(); + while (GetRootParentList()->GetCount() > 0) { KX_GameObject* parentobj = (KX_GameObject*) GetRootParentList()->GetValue(0); -- cgit v1.2.3 From 9098de447952f52babb10a339c00c934076b1bca Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 20 Apr 2008 21:01:13 +0000 Subject: second attempt to fix compilation problem with 2D shaders on systems without GLExt or without shader support: use GL_ARB_shader_objects to conditionally compile the 2D shader code --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index e03133b9031..9454edfacfe 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -92,7 +92,7 @@ RAS_2DFilterManager::~RAS_2DFilterManager() unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) { GLuint program = 0; -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) +#if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) GLuint fShader = bgl::blCreateShaderObjectARB(GL_FRAGMENT_SHADER); GLint success; @@ -162,7 +162,7 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) +#if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) GLint uniformLoc; bgl::blUseProgramObjectARB(shaderprogram); uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); @@ -190,7 +190,7 @@ void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) void RAS_2DFilterManager::EndShaderProgram() { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) +#if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) bgl::blUseProgramObjectARB(0); #endif } @@ -302,7 +302,7 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str { if(!isshadersupported) return; -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) +#if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) if(pass<0 || pass>=MAX_RENDER_PASS) return; -- cgit v1.2.3 From f4cc03b0f1323fbf41730851716cb90e27e4c89e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 23 Apr 2008 21:48:17 +0000 Subject: Better fix for BGE bug #7892: dRot is reversed on dynamic objects. Make sure that graphic, Bullet and Sumo(deprecated) objects rotate the same way. This fix reverses the rotation of non-dynamic objects compared to 2.45: you will need to change the sign of dRot in 2.45 games for them to work correctly in 2.46 --- source/gameengine/Ketsji/KX_GameObject.cpp | 1 - source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 1c508baca96..cf621e04f99 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -315,7 +315,6 @@ void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local) GetSGNode()->RelativeRotate(rotmat,local); if (m_pPhysicsController1) { // (IsDynamic()) - rotmat.transpose(); m_pPhysicsController1->RelativeRotate(rotmat,local); } } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index fe9aa4419e4..d99b75482b9 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -290,9 +290,9 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } - btMatrix3x3 drotmat( rotval[0],rotval[1],rotval[2], - rotval[4],rotval[5],rotval[6], - rotval[8],rotval[9],rotval[10]); + btMatrix3x3 drotmat( rotval[0],rotval[4],rotval[8], + rotval[1],rotval[5],rotval[9], + rotval[2],rotval[6],rotval[10]); btMatrix3x3 currentOrn; -- cgit v1.2.3 From 9b9359120fdac93b822cfaacf98d0d498cef3887 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 24 Apr 2008 21:26:39 +0000 Subject: BGE bug: fix a crash at game exit caused by inconsistent controller map after object deletion. The bug became apparent since the memory leaks have been fixed. --- source/gameengine/GameLogic/SCA_LogicManager.cpp | 8 ++++++++ source/gameengine/Ketsji/KX_Scene.cpp | 1 + 2 files changed, 9 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index bd1c44fb91e..49f01d643e5 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -174,6 +174,14 @@ void SCA_LogicManager::RemoveSensor(SCA_ISensor* sensor) } } +void SCA_LogicManager::RemoveController(SCA_IController* controller) +{ + std::map::iterator sit; + for (sit = m_sensorcontrollermapje.begin();!(sit==m_sensorcontrollermapje.end());++sit) + { + (*sit).second.remove(controller); + } +} void SCA_LogicManager::RemoveDestroyedActuator(SCA_IActuator* actuator) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 0fbabe8d6a2..54003284e03 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -754,6 +754,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) { (*itc)->UnlinkAllSensors(); (*itc)->UnlinkAllActuators(); + m_logicmgr->RemoveController(*itc); } SCA_ActuatorList& actuators = newobj->GetActuators(); -- cgit v1.2.3 From bc059cb8b2b8b09553e4d02b4bcccd67ff73d8fd Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 26 Apr 2008 20:41:25 +0000 Subject: BGE bug: crash when an object being tracked-to is deleted (bad practice anyway). Fix by creating a generic cross reference between actuators (only TrackTo uses it at the moment) and objects so that the actuator is informed when the target object is deleted --- source/gameengine/GameLogic/SCA_IActuator.h | 9 +++++++ source/gameengine/GameLogic/SCA_IObject.cpp | 23 +++++++++++++++++ source/gameengine/GameLogic/SCA_IObject.h | 3 +++ source/gameengine/Ketsji/KX_TrackToActuator.cpp | 34 ++++++++++++++++++++++--- source/gameengine/Ketsji/KX_TrackToActuator.h | 2 ++ 5 files changed, 67 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h index bff32dcebaa..b802aa4b298 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.h +++ b/source/gameengine/GameLogic/SCA_IActuator.h @@ -46,6 +46,15 @@ public: SCA_IActuator(SCA_IObject* gameobj, PyTypeObject* T =&Type); + /** + * UnlinkObject(...) + * Certain actuator use gameobject pointers (like TractTo actuator) + * This function can be called when an object is removed to make + * sure that the actuator will not use it anymore. + */ + + virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; } + /** * Update(...) * Update the actuator based upon the events received since diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 465dd981406..6df9e23f3fa 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -62,6 +62,10 @@ SCA_IObject::~SCA_IObject() ((CValue*)(*itc))->Release(); } SCA_ActuatorList::iterator ita; + for (ita = m_registeredActuators.begin(); !(ita==m_registeredActuators.end()); ++ita) + { + (*ita)->UnlinkObject(this); + } for (ita = m_actuators.begin(); !(ita==m_actuators.end()); ++ita) { ((CValue*)(*ita))->Release(); @@ -118,7 +122,24 @@ void SCA_IObject::AddActuator(SCA_IActuator* act) m_actuators.push_back(act); } +void SCA_IObject::RegisterActuator(SCA_IActuator* act) +{ + // don't increase ref count, it would create dead lock + m_registeredActuators.push_back(act); +} +void SCA_IObject::UnregisterActuator(SCA_IActuator* act) +{ + SCA_ActuatorList::iterator ita; + for (ita = m_registeredActuators.begin(); ita != m_registeredActuators.end(); ita++) + { + if ((*ita) == act) { + (*ita) = m_registeredActuators.back(); + m_registeredActuators.pop_back(); + break; + } + } +} void SCA_IObject::SetIgnoreActivityCulling(bool b) { @@ -168,6 +189,8 @@ void SCA_IObject::ReParentLogic() newactuator->SetActive(false); oldactuators[act++] = newactuator; } + // a new object cannot be client of any actuator + m_registeredActuators.clear(); } diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index 8f3e25afa03..4b0fc741b8f 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -55,6 +55,7 @@ protected: SCA_SensorList m_sensors; SCA_ControllerList m_controllers; SCA_ActuatorList m_actuators; + SCA_ActuatorList m_registeredActuators; // actuators that use a pointer to this object static class MT_Point3 m_sDummy; /** @@ -79,6 +80,8 @@ public: void AddSensor(SCA_ISensor* act); void AddController(SCA_IController* act); void AddActuator(SCA_IActuator* act); + void RegisterActuator(SCA_IActuator* act); + void UnregisterActuator(SCA_IActuator* act); SCA_ISensor* FindSensor(const STR_String& sensorname); SCA_IActuator* FindActuator(const STR_String& actuatorname); diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index dc637bf0837..58b87367258 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -70,6 +70,7 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj, m_parentobj = 0; if (m_object){ + m_object->RegisterActuator(this); KX_GameObject* curobj = (KX_GameObject*) GetParent(); m_parentobj = curobj->GetParent(); // check if the object is parented @@ -176,12 +177,31 @@ MT_Matrix3x3 matrix3x3_interpol(MT_Matrix3x3 oldmat, MT_Matrix3x3 mat, int m_tim KX_TrackToActuator::~KX_TrackToActuator() -{ - // there's nothing to be done here, really.... +{ + if (m_object) + m_object->UnregisterActuator(this); } /* end of destructor */ +void KX_TrackToActuator::ProcessReplica() +{ + // the replica is tracking the same object => register it + if (m_object) + m_object->RegisterActuator(this); + SCA_IActuator::ProcessReplica(); +} +bool KX_TrackToActuator::UnlinkObject(SCA_IObject* clientobj) +{ + if (clientobj == m_object) + { + // this object is being deleted, we cannot continue to track it. + m_object = NULL; + return true; + } + return false; +} + bool KX_TrackToActuator::Update(double curtime, bool frame) { bool result = false; @@ -430,8 +450,11 @@ PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* args, PyObje PyObject* gameobj; if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) { + if (m_object != NULL) + m_object->UnregisterActuator(this); m_object = (SCA_IObject*)gameobj; - + if (m_object) + m_object->RegisterActuator(this); Py_Return; } PyErr_Clear(); @@ -439,8 +462,11 @@ PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* args, PyObje char* objectname; if (PyArg_ParseTuple(args, "s", &objectname)) { + if (m_object != NULL) + m_object->UnregisterActuator(this); m_object= static_cast(SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname))); - + if (m_object) + m_object->RegisterActuator(this); Py_Return; } diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index 944eaadf025..a03aa115baa 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -66,6 +66,8 @@ class KX_TrackToActuator : public SCA_IActuator return replica; }; + virtual void ProcessReplica(); + virtual bool UnlinkObject(SCA_IObject* clientobj); virtual bool Update(double curtime, bool frame); /* Python part */ -- cgit v1.2.3 From 2740bbc89ce5638872963dac5ea2810915b7f49d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 27 Apr 2008 15:02:37 +0000 Subject: Update MSVC project files to support ffmpeg. Make sure you do svn update in lib/windows to link with latest ffmpeg libraries --- source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h index a43ddbec483..42b5ab48ab6 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h +++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h @@ -4,6 +4,7 @@ class SM_Callback { public: virtual void do_me() = 0; + virtual ~SM_Callback() {} }; #endif -- cgit v1.2.3 From b6a6507ddfac721f6184f6b0889089d975f35210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Luc=20Peuri=C3=A8re?= Date: Tue, 29 Apr 2008 16:22:13 +0000 Subject: getting ARB shaders working again in GE. This is is a kludge, and only to get a release working. later solution is to use glew --- .../gameengine/BlenderRoutines/KX_BlenderCanvas.h | 1 + .../gameengine/BlenderRoutines/mac_compat_glext.h | 132 +++++++++++++++++++++ source/gameengine/GamePlayer/common/SConscript | 1 + source/gameengine/GamePlayer/ghost/SConscript | 1 + .../RAS_OpenGLRasterizer/RAS_GLExtensionManager.h | 3 +- .../Rasterizer/RAS_OpenGLRasterizer/SConscript | 2 +- source/gameengine/Rasterizer/SConscript | 2 +- 7 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 source/gameengine/BlenderRoutines/mac_compat_glext.h (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index 0b3519efdbd..f9ff8f61b97 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -33,6 +33,7 @@ #include #endif #ifdef __APPLE__ +# define GL_GLEXT_LEGACY 1 #include #else #include diff --git a/source/gameengine/BlenderRoutines/mac_compat_glext.h b/source/gameengine/BlenderRoutines/mac_compat_glext.h new file mode 100644 index 00000000000..0ec676963b1 --- /dev/null +++ b/source/gameengine/BlenderRoutines/mac_compat_glext.h @@ -0,0 +1,132 @@ +#ifndef __mac_compat_glext_h_ +#define __mac_compat_glext_h_ + + +#ifdef __cplusplus +extern "C" { +#endif + +#define APIENTRYP * +# define GL_GLEXT_LEGACY 1 +# include + +//#if GL_ARB_shader_objects +typedef char GLcharARB; +typedef void *GLhandleARB; +//#endif + +//#if GL_ARB_vertex_buffer_object +typedef long GLintptrARB; +typedef long GLsizeiptrARB; +//#endif + + +// GL_ARB_multitexture +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); + +//GL_ARB_shader_objects +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (unsigned int obj); +typedef unsigned int (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (unsigned int containerObj, unsigned int attachedObj); +typedef unsigned int (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (unsigned int shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (unsigned int shaderObj); +typedef unsigned int (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (unsigned int containerObj, unsigned int obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (unsigned int programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (unsigned int programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (unsigned int programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (unsigned int obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (unsigned int obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (unsigned int obj, GLsizei maxLength, GLsizei *length, void *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (unsigned int containerObj, GLsizei maxCount, GLsizei *count, unsigned int *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (unsigned int programObj, const void *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (unsigned int programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (unsigned int programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (unsigned int programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (unsigned int obj, GLsizei maxLength, GLsizei *length, void *source); + + +//GL_ARB_vertex_shader +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (unsigned int programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (unsigned int programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (unsigned int programObj, const GLcharARB *name); + + +//GL_ARB_vertex_program +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); + +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index 944fcea3a51..6ff3ae10735 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -33,6 +33,7 @@ incs = ['.', '#source/blender', '#source/blender/include', '#source/blender/makesdna', + '#source/gameengine/BlenderRoutines', '#source/gameengine/Rasterizer', '#source/gameengine/GameLogic', '#source/gameengine/Expressions', diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index cc2d7de8002..bd37777031e 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -27,6 +27,7 @@ incs = ['.', '#source/blender', '#source/blender/include', '#source/blender/makesdna', + '#source/gameengine/BlenderRoutines', '#source/gameengine/Rasterizer', '#source/gameengine/GameLogic', '#source/gameengine/Expressions', diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h index 05eb73b315f..a18ed038f35 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h @@ -35,7 +35,6 @@ # include #elif defined(__APPLE__) -# define __glext_h_ # define GL_GLEXT_LEGACY 1 # include # include @@ -52,8 +51,8 @@ #ifdef WIN32 # include #elif defined(__APPLE__) +# include "mac_compat_glext.h" # include -# undef __glext_h_ # else # include # endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index b4d5b8b71de..f2d2e977668 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -6,7 +6,7 @@ if env['WITH_BF_GLEXT'] == 1: sources = env.Glob('*.cpp') #'RAS_GLExtensionManager.cpp RAS_ListRasterizer.cpp RAS_OpenGLRasterizer.cpp RAS_VAOpenGLRasterizer.cpp' -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer' +incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines' incs += ' ' + env['BF_OPENGL_INC'] env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), [], libtype=['game','player'], priority=[40, 120] ) diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index c71e371fedc..ff79a5d97b8 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -7,7 +7,7 @@ if env['WITH_BF_GLEXT'] == 1: env['CPPFLAGS'].append('-DWITH_GLEXT') -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include' +incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines' if env['OURPLATFORM']=='win32-vc': cflags = [] -- cgit v1.2.3 From 3a430c33d22d659ab3d73709f0dbc60a029e0893 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 30 Apr 2008 19:58:44 +0000 Subject: fix BGE bug #8869: Added objects are not lit correctly The current layer information is now stored in KX_GameObject and inherited from the parent object when dynamically added. This information is used during the rendering the select the lamps. As the selected lamps are always coming from active layers, their position and orientation are correct. --- .../BlenderRoutines/KX_BlenderRenderTools.cpp | 4 ++++ .../gameengine/Converter/BL_BlenderDataConversion.cpp | 5 ++++- source/gameengine/GamePlayer/common/GPC_RenderTools.cpp | 4 ++++ source/gameengine/Ketsji/KX_GameObject.cpp | 17 +++++++++++++++++ source/gameengine/Ketsji/KX_GameObject.h | 17 +++++++++++++++++ source/gameengine/Ketsji/KX_Scene.cpp | 2 ++ source/gameengine/Rasterizer/RAS_IRenderTools.h | 4 ++++ source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | 8 ++------ 8 files changed, 54 insertions(+), 7 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 6b0df44cb16..a656c5e5523 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -91,6 +91,10 @@ int KX_BlenderRenderTools::ProcessLighting(int layer) { if (m_clientobject) { + if (layer == RAS_LIGHT_OBJECT_LAYER) + { + layer = static_cast(m_clientobject)->GetLayer(); + } if (applyLights(layer)) { EnableOpenGLLights(); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 3e83ed20840..08e9e36c048 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1680,8 +1680,11 @@ static KX_GameObject *gameobject_from_blenderobject( break; } } - if (gameobj) + if (gameobj) + { gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment()); + gameobj->SetLayer(ob->lay); + } return gameobj; } diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index a5b8d8aacdf..edda7657ef9 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -137,6 +137,10 @@ int GPC_RenderTools::ProcessLighting(int layer) { if (m_clientobject) { + if (layer == RAS_LIGHT_OBJECT_LAYER) + { + layer = static_cast(m_clientobject)->GetLayer(); + } if (applyLights(layer)) { EnableOpenGLLights(); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index cf621e04f99..301a1413bcd 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -74,6 +74,7 @@ KX_GameObject::KX_GameObject( ) : SCA_IObject(T), m_bDyna(false), + m_layer(0), m_bSuspendDynamics(false), m_bUseObjectColor(false), m_bVisible(true), @@ -479,6 +480,22 @@ KX_GameObject::SetVisible( m_bVisible = v; } +void +KX_GameObject::SetLayer( + int l + ) +{ + m_layer = l; +} + +int +KX_GameObject::GetLayer( + void + ) +{ + return m_layer; +} + // used by Python, and the actuatorshould _not_ be misused by the // scene! void diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 87775e81216..da0cd69e129 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -70,6 +70,7 @@ protected: KX_ClientObjectInfo* m_pClient_info; STR_String m_name; STR_String m_text; + int m_layer; std::vector m_meshes; bool m_bSuspendDynamics; @@ -571,6 +572,22 @@ public: bool b ); + /** + * Change the layer of the object (when it is added in another layer + * than the original layer) + */ + void + SetLayer( + int l + ); + + /** + * Get the object layer + */ + int + GetLayer( + void + ); /** * @section Logic bubbling methods. diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 54003284e03..e4054e07475 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -650,6 +650,8 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { (*git)->Relink(&m_map_gameobject_to_replica); + // add the object in the layer of the parent + (*git)->SetLayer(parentobj->GetLayer()); } // now replicate logic diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index 30c96d02847..16e15653c82 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -61,6 +61,10 @@ public: RAS_TEXT_PADDED, RAS_TEXT_MAX }; + enum RAS_LIGHT_MODE { + RAS_LIGHT_NONE = -1, + RAS_LIGHT_OBJECT_LAYER = 0 + }; RAS_IRenderTools( ) : diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 4642ffbaeb8..02e84f8a243 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -189,7 +189,7 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I } else { - rendertools->ProcessLighting(m_material->GetLightLayer()); + rendertools->ProcessLighting(RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER/*m_material->GetLightLayer()*/); } drawmode = (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID ? @@ -204,7 +204,6 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa if (!ms.m_bVisible) return; - rendertools->SetClientObject(ms.m_clientObj); m_material->ActivateMeshSlot(ms, rasty); /* __NLA Do the deformation */ @@ -317,15 +316,12 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans, //rasty->SetMaterial(*m_material); - if (m_meshSlots.size() >0) - { - rendertools->SetClientObject((*m_meshSlots.begin()).m_clientObj); - } int drawmode; for (T_MeshSlotList::const_iterator it = m_meshSlots.begin(); ! (it == m_meshSlots.end()); ++it) { + rendertools->SetClientObject((*it).m_clientObj); while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode)) RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode); } -- cgit v1.2.3 From eef2b7e1254bd02bbb4a08cd2ff49746b869a181 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 1 May 2008 12:35:21 +0000 Subject: Complement to bug fix #8869: crash with alpha mesh --- source/gameengine/Rasterizer/RAS_BucketManager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 6c3e89fa69d..50df1a1e2ea 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -113,6 +113,7 @@ void RAS_BucketManager::RenderAlphaBuckets( std::multiset< alphamesh, backtofront>::iterator msit = alphameshset.begin(); for (; msit != alphameshset.end(); ++msit) { + rendertools->SetClientObject((*(*msit).m_ms).m_clientObj); while ((*msit).m_bucket->ActivateMaterial(cameratrans, rasty, rendertools, drawingmode)) (*msit).m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(*msit).m_ms, drawingmode); } -- cgit v1.2.3 From 31adad5b4d8dd7728a1a4d21ede7b34e6ff01a89 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 1 May 2008 16:00:59 +0000 Subject: Fix BGE bug: dynamic-but-not-rigid objects are added as rigid body during the game. --- source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 9 ++++++--- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 4 ++++ source/gameengine/Physics/Bullet/CcdPhysicsController.h | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 4a61c37be06..e0cd5a3bc9e 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1123,7 +1123,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter); ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); - + ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody; KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); //remember that we created a shape so that we can delete it when the scene is removed (bullet will not delete it) kxscene->AddShape(bm); @@ -1147,6 +1147,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, //{ // rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); //} + if (objprop->m_dyna && !objprop->m_angular_rigidbody) { /* @@ -1161,8 +1162,10 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, */ //env->createConstraint(physicscontroller,0,PHY_ANGULAR_CONSTRAINT,0,0,0,0,0,1); - physicscontroller->GetRigidBody()->setAngularFactor(0.f); - + + //Now done directly in ci.m_bRigid so that it propagates to replica + //physicscontroller->GetRigidBody()->setAngularFactor(0.f); + ; } bool isActor = objprop->m_isactor; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index d99b75482b9..e444c4c73be 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -137,6 +137,10 @@ void CcdPhysicsController::CreateRigidbody() m_body->setGravity( m_cci.m_gravity); m_body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping); + if (!m_cci.m_bRigid) + { + m_body->setAngularFactor(0.f); + } } CcdPhysicsController::~CcdPhysicsController() diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 54b4bcc40ee..37fa465351f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -60,6 +60,7 @@ struct CcdConstructionInfo m_linearDamping(0.1f), m_angularDamping(0.1f), m_collisionFlags(0), + m_bRigid(false), m_collisionFilterGroup(DefaultFilter), m_collisionFilterMask(AllFilter), m_collisionShape(0), @@ -78,6 +79,7 @@ struct CcdConstructionInfo btScalar m_linearDamping; btScalar m_angularDamping; int m_collisionFlags; + bool m_bRigid; ///optional use of collision group/mask: ///only collision with object goups that match the collision mask. -- cgit v1.2.3 From d99ddc5cf8c308bf7c0a61c1c266776a313936fa Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 1 May 2008 20:43:18 +0000 Subject: Fix BGE bug #8863: Keyboard Sensor does not send negative pulse if key released while scene suspended. The fix covers keyboard and mouse sensor --- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 36 ++++++++++++++++++++++ source/gameengine/GameLogic/SCA_MouseSensor.cpp | 24 +++++++++++++++ 2 files changed, 60 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index f8fc256b371..8a12bd298c2 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -163,6 +163,23 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { m_val=(active)?1:0; result = true; + } else + { + if (active) + { + if (m_val == 0) + { + m_val = 1; + result = true; + } + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } + } } } @@ -178,6 +195,13 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS) { + if (m_val == 1) + { + // this situation may occur after a scene suspend: the keyboard release + // event was not captured, produce now the event off + m_val = 0; + result = true; + } } else { if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED) @@ -190,6 +214,18 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { m_val = 0; result = true; + } else + { + if (inevent.m_status == SCA_InputEvent::KX_ACTIVE) + { + if (m_val == 0) + { + // this may occur during a scene suspend, the keyboard + // press was not captured, do it now + m_val = 1; + result = true; + } + } } } } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index a91cf3e0439..d8894ff593c 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -158,6 +158,23 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { m_val = 0; result = true; + } else + { + if (event.m_status == SCA_InputEvent::KX_ACTIVE) + { + if (m_val == 0) + { + m_val = 1; + result = true; + } + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } + } } } break; @@ -183,6 +200,13 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { m_val = 0; result = true; + } else + { + if (m_val == 1) + { + m_val = 0; + result = true; + } } } break; -- cgit v1.2.3 From f0a41d9d976f84db5c2c7cd6f2b38f7ce09642bd Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 2 May 2008 15:47:08 +0000 Subject: Partially revert BGE bug fix #8863: don't send keyboard sensor positive pulse on level, this would badly interfere with keyboard sensors controlling set scene/restart scene actuators. Only send negative pulse on level to stop actuators after scene suspend --- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 19 +++++++++++++------ source/gameengine/GameLogic/SCA_MouseSensor.cpp | 6 ++++-- 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 8a12bd298c2..f13b1bcf4c9 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -169,8 +169,10 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (m_val == 0) { - m_val = 1; - result = true; + //see comment below + //m_val = 1; + //result = true; + ; } } else { @@ -220,10 +222,15 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (m_val == 0) { - // this may occur during a scene suspend, the keyboard - // press was not captured, do it now - m_val = 1; - result = true; + //hmm, this abnormal situation may occur in the following cases: + //- the key was pressed while the scene was suspended + //- this is a new scene and the key is active from the start + //In the second case, it's dangerous to activate the sensor + //(think of a key to go to next scene) + //What we really need is a edge/level flag in the key sensor + //m_val = 1; + //result = true; + ; } } } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index d8894ff593c..8810b7470ed 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -164,8 +164,10 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { if (m_val == 0) { - m_val = 1; - result = true; + //dangerous + //m_val = 1; + //result = true; + ; } } else { -- cgit v1.2.3 From e7a106625c5c7d7d51ae9349055ca656d48c6f54 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 2 May 2008 17:22:28 +0000 Subject: BGE bug fix: set parent actuator change the orientation of object --- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 301a1413bcd..4c6ba448ebf 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -229,7 +229,7 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) NodeSetLocalScale(scale1); NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2])); - NodeSetLocalOrientation(NodeGetWorldOrientation()*invori); + NodeSetLocalOrientation(invori*NodeGetWorldOrientation()); NodeUpdateGS(0.f,true); // object will now be a child, it must be removed from the parent list CListValue* rootlist = scene->GetRootParentList(); -- cgit v1.2.3 From e6be4547878a11839a6eb6a200d565b217483975 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 4 May 2008 11:09:30 +0000 Subject: More compiler fixes for BLI_convertstringcode calls --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 200c04bbfd3..fa8409b123e 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -264,7 +264,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, if (exitstring != "") strcpy(basedpath, exitstring.Ptr()); - BLI_convertstringcode(basedpath, pathname, 0); + BLI_convertstringcode(basedpath, pathname); bfd = load_game_data(basedpath); // if it wasn't loaded, try it forced relative @@ -275,7 +275,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, strcpy(temppath, "//"); strcat(temppath, basedpath); - BLI_convertstringcode(temppath, pathname, 0); + BLI_convertstringcode(temppath, pathname); bfd = load_game_data(temppath); } -- cgit v1.2.3 From 7aa6833499b87d51143f7e5cbc4bd33bd300b05e Mon Sep 17 00:00:00 2001 From: Ken Hughes Date: Sun, 4 May 2008 14:14:09 +0000 Subject: More compiler fixes for BLI_convertstringcode calls --- source/gameengine/Converter/KX_ConvertActuators.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a575415ab05..6b594e2e70b 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -351,7 +351,7 @@ void BL_ConvertActuators(char* maggiename, else { /* but we need to convert the samplename into absolute pathname first */ - BLI_convertstringcode(soundact->sound->name, maggiename, 0); + BLI_convertstringcode(soundact->sound->name, maggiename); samplename = soundact->sound->name; /* and now we can load it */ -- cgit v1.2.3 From 6c05a92fe189baf82b7de4813d63b7bacf36cab2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 4 May 2008 15:02:48 +0000 Subject: missed out on some BLI_convertstringcode's, also found that playing relative quicktime paths from the python api never worked, was using the 'Scene' type cast to a char. --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 1496f7c6ad3..8817bc98886 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -579,7 +579,7 @@ int main(int argc, char** argv) // base the actuator filename with respect // to the original file working directory strcpy(basedpath, exitstring.Ptr()); - BLI_convertstringcode(basedpath, pathname, 0); + BLI_convertstringcode(basedpath, pathname); bfd = load_game_data(basedpath); } -- cgit v1.2.3 From cf654b44b6d1a59be7007fd5e3891e9a0bd78eeb Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 4 May 2008 21:14:38 +0000 Subject: Fix BGE bug in patch #8724 (memory optimization): serious problem with alpha texture when Use Blender Material is active and several objects have same texture. This bug messes up greatly with OpenGL texture. The GE is not usable without this fix. --- source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 14 +++++++++++--- source/gameengine/Ketsji/KX_BlenderMaterial.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index cfdcba8a5d6..44727588106 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -84,6 +84,7 @@ KX_BlenderMaterial::KX_BlenderMaterial( mScene(scene), mUserDefBlend(0), mModified(0), + mConstructed(false), mPass(0) { @@ -119,7 +120,9 @@ KX_BlenderMaterial::KX_BlenderMaterial( KX_BlenderMaterial::~KX_BlenderMaterial() { // cleanup work - OnExit(); + if (mConstructed) + // clean only if material was actually used + OnExit(); } @@ -138,6 +141,10 @@ unsigned int* KX_BlenderMaterial::GetMCol(void) const void KX_BlenderMaterial::OnConstruction() { + if (mConstructed) + // when material are reused between objects + return; + // for each unique material... int i; for(i=0; inum_enabled; i++) { @@ -148,19 +155,20 @@ void KX_BlenderMaterial::OnConstruction() } if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) ) spit("unable to initialize image("<matname<< ", image will not be available"); + mMaterial->matname<< ", image will not be available"); } else { if( mMaterial->img[i] ) { if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) spit("unable to initialize image("<matname<< ", image will not be available"); + mMaterial->matname<< ", image will not be available"); } } } mBlendFunc[0] =0; mBlendFunc[1] =0; + mConstructed = true; } void KX_BlenderMaterial::OnExit() diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 2b1264154d0..b9d48199520 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -93,6 +93,7 @@ private: bool mUserDefBlend; unsigned int mBlendFunc[2]; bool mModified; + bool mConstructed; // if false, don't clean on exit void ActivatGLMaterials( RAS_IRasterizer* rasty )const; void ActivateTexGen( RAS_IRasterizer *ras ) const; -- cgit v1.2.3 From b36fe51c7d85b5ea761d4ba9121001efb75b5c30 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 5 May 2008 17:29:11 +0000 Subject: Fixed some indentation, I stumbled across (spaces vs tabs) and also removed return 0 from a void stub. Kent --- .../Converter/BL_BlenderDataConversion.cpp | 103 +++++++++++---------- 1 file changed, 52 insertions(+), 51 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 08e9e36c048..089af9a68e7 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2176,70 +2176,71 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); struct Object* blenderobject = converter->FindBlenderObject(gameobj); - int nummeshes = gameobj->GetMeshCount(); - RAS_MeshObject* meshobj = 0; - ListBase *conlist; - bConstraint *curcon; - conlist = get_active_constraints2(blenderobject); - if (conlist) { - for (curcon = (bConstraint *)conlist->first; curcon; curcon=(bConstraint *)curcon->next) { - if (curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT){ - bRigidBodyJointConstraint *dat=(bRigidBodyJointConstraint *)curcon->data; - //if (dat->tar) - if (!dat->child){ - PHY_IPhysicsController* physctr2 = 0; - if (dat->tar) - { - KX_GameObject *gotar=getGameOb(dat->tar->id.name,sumolist); - if (gotar && gotar->GetPhysicsController()) - physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData(); - } + ListBase *conlist; + bConstraint *curcon; + conlist = get_active_constraints2(blenderobject); - if (gameobj->GetPhysicsController()) - { - float radsPerDeg = 6.283185307179586232f / 360.f; + if (conlist) { + for (curcon = (bConstraint *)conlist->first; curcon; curcon=(bConstraint *)curcon->next) { + if (curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT){ + + bRigidBodyJointConstraint *dat=(bRigidBodyJointConstraint *)curcon->data; + + if (!dat->child){ + + PHY_IPhysicsController* physctr2 = 0; + + if (dat->tar) + { + KX_GameObject *gotar=getGameOb(dat->tar->id.name,sumolist); + if (gotar && gotar->GetPhysicsController()) + physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData(); + } - PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); - //we need to pass a full constraint frame, not just axis + if (gameobj->GetPhysicsController()) + { + float radsPerDeg = 6.283185307179586232f / 360.f; + + PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); + //we need to pass a full constraint frame, not just axis - //localConstraintFrameBasis - MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ)); - MT_Vector3 axis0 = localCFrame.getColumn(0); - MT_Vector3 axis1 = localCFrame.getColumn(1); - MT_Vector3 axis2 = localCFrame.getColumn(2); + //localConstraintFrameBasis + MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ)); + MT_Vector3 axis0 = localCFrame.getColumn(0); + MT_Vector3 axis1 = localCFrame.getColumn(1); + MT_Vector3 axis2 = localCFrame.getColumn(2); - int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,(float)dat->pivY,(float)dat->pivZ, + int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX, + (float)dat->pivY,(float)dat->pivZ, (float)axis0.x(),(float)axis0.y(),(float)axis0.z(), (float)axis1.x(),(float)axis1.y(),(float)axis1.z(), - (float)axis2.x(),(float)axis2.y(),(float)axis2.z() - ); - if (constraintId) + (float)axis2.x(),(float)axis2.y(),(float)axis2.z()); + if (constraintId) + { + //if it is a generic 6DOF constraint, set all the limits accordingly + if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT) { - //if it is a generic 6DOF constraint, set all the limits accordingly - if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT) + int dof; + int dofbit=1; + for (dof=0;dof<6;dof++) { - int dof; - int dofbit=1; - for (dof=0;dof<6;dof++) + if (dat->flag & dofbit) { - if (dat->flag & dofbit) - { - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); - } else - { - //minLimit > maxLimit means free(disabled limit) for this degree of freedom - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); - } - dofbit<<=1; + kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); + } else + { + //minLimit > maxLimit means free(disabled limit) for this degree of freedom + kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); } + dofbit<<=1; } } } - } - } - } - } - + } + } + } + } + } } templist->Release(); -- cgit v1.2.3 From 3ba9069c040d6d3682d1421f89a061236ed8cd88 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Tue, 6 May 2008 09:43:28 +0000 Subject: Fixes Makefiles for mac_compat_glext.h by updating some include paths. Kent --- source/gameengine/BlenderRoutines/Makefile | 1 + source/gameengine/GamePlayer/common/Makefile | 1 + source/gameengine/GamePlayer/ghost/Makefile | 2 ++ source/gameengine/Rasterizer/Makefile | 2 ++ source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile | 1 + 5 files changed, 7 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile index 2339b840679..64a17f44a84 100644 --- a/source/gameengine/BlenderRoutines/Makefile +++ b/source/gameengine/BlenderRoutines/Makefile @@ -65,6 +65,7 @@ CPPFLAGS += -I../Network CPPFLAGS += -I../Network/LoopBackNetwork CPPFLAGS += -I../Physics/common CPPFLAGS += -I../Physics/Sumo +CPPFLAGS += -I. ifeq ($(OS),windows) CPPFLAGS += -I../../blender diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile index 254896e60e5..508dee18755 100644 --- a/source/gameengine/GamePlayer/common/Makefile +++ b/source/gameengine/GamePlayer/common/Makefile @@ -60,6 +60,7 @@ CPPFLAGS += -I../../../gameengine/Converter CPPFLAGS += -I../../../gameengine/Expressions CPPFLAGS += -I../../../gameengine/GameLogic CPPFLAGS += -I../../../gameengine/Converter +CPPFLAGS += -I../../../gameengine/BlenderRoutines CPPFLAGS += -I../../../gameengine/Ketsji CPPFLAGS += -I../../../gameengine/Ketsji/KXNetwork CPPFLAGS += -I../../../gameengine/Network diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index 8a3d194cbd7..d5aae181396 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -69,6 +69,8 @@ CPPFLAGS += -I../../../blender/imbuf CPPFLAGS += -I../../../blender/makesdna CPPFLAGS += -I../../../blender/readblenfile +CPPFLAGS += -I../../../gameengine/BlenderRoutines + # kernel? GEN? stuff CPPFLAGS += -I../../../kernel/gen_system CPPFLAGS += -I../../../kernel/gen_messaging diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile index 9cde6069167..d544056e8ae 100644 --- a/source/gameengine/Rasterizer/Makefile +++ b/source/gameengine/Rasterizer/Makefile @@ -39,6 +39,8 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../kernel/gen_system +CPPFLAGS += -I../BlenderRoutines + ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile index b0d79dcc897..1a88c51dc25 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile @@ -40,6 +40,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../../kernel/gen_system +CPPFLAGS += -I../../BlenderRoutines CPPFLAGS += -I.. ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings -- cgit v1.2.3 From 881802d8a385228a3b8af3b1b7ccb8512c96490b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 6 May 2008 20:55:55 +0000 Subject: BGE patch #10492 approved: getLinearVelocity() now can provide local velocity as well. This patch is harmless and backward compatible; it can go safely into 2.46 release --- source/gameengine/Ketsji/KX_GameObject.cpp | 29 ++++++++++++++++++++++++----- source/gameengine/Ketsji/KX_GameObject.h | 3 ++- source/gameengine/PyDoc/KX_GameObject.py | 10 +++++++--- 3 files changed, 33 insertions(+), 9 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 4c6ba448ebf..fb636b23082 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -581,16 +581,27 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec) -MT_Vector3 KX_GameObject::GetLinearVelocity() +MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { MT_Vector3 velocity(0.0,0.0,0.0); - + MT_Matrix3x3 ori, locvel; + int i, j; if (m_pPhysicsController1) { velocity = m_pPhysicsController1->GetLinearVelocity(); + + if (local) + { + ori = GetSGNode()->GetWorldOrientation(); + + for(i=0; i < 3; i++) + for(j=0; j < 3; j++) + locvel[i][j]= velocity[i]*ori[i][j]; + for(i=0; i < 3; i++) + velocity[i] = locvel[0][i] + locvel[1][i] + locvel[2][i]; + } } - return velocity; - + return velocity; } @@ -948,7 +959,15 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, PyObject* kwds) { // only can get the velocity if we have a physics object connected to us... - return PyObjectFrom(GetLinearVelocity()); + int local = 0; + if (PyArg_ParseTuple(args,"|i",&local)) + { + return PyObjectFrom(GetLinearVelocity((local!=0))); + } + else + { + return NULL; + } } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index da0cd69e129..b83d63e26bf 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -252,8 +252,9 @@ public: /** * Return the linear velocity of the game object. */ - MT_Vector3 + MT_Vector3 GetLinearVelocity( + bool local=false ); /** diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 31c9993e194..8ef82b4943b 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -58,15 +58,16 @@ class KX_GameObject: @rtype: 3x3 rotation matrix @return: The game object's rotation matrix """ - def getLinearVelocity(): + def getLinearVelocity(local): """ Gets the game object's linear velocity. This method returns the game object's velocity through it's centre of mass, ie no angular velocity component. - cf getVelocity() - + @type local: boolean + @param local: - False: you get the "global" velocity ie: relative to world orientation. + - True: you get the "local" velocity ie: relative to object orientation. @rtype: list [vx, vy, vz] @return: the object's linear velocity. """ @@ -138,6 +139,9 @@ class KX_GameObject: def setParent(parent): """ Sets this object's parent. + + @type parent: L{KX_GameObject} + @param parent: new parent object. """ def removeParent(): """ -- cgit v1.2.3 From 44cdc480de4e54a07da751625adc4aa9d67c3f48 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 7 May 2008 22:32:45 +0000 Subject: Fix BGE bug #6054: Camera actuator crashes Blender. The crash occurs when min,max << height (bad practice anyway). --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index cb3180cb05e..27f4870de10 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -155,14 +155,25 @@ static void Kx_VecUpMat3(float *vec, float mat[][3], short axis) mat[coz][0]= vec[0]; mat[coz][1]= vec[1]; mat[coz][2]= vec[2]; - Kx_Normalize((float *)mat[coz]); + if (Kx_Normalize((float *)mat[coz]) == 0.f) { + /* this is a very abnormal situation: the camera has reach the object center exactly + We will choose a completely arbitrary direction */ + mat[coz][0] = 1.0f; + mat[coz][1] = 0.0f; + mat[coz][2] = 0.0f; + } inp= mat[coz][2]; mat[coy][0]= - inp*mat[coz][0]; mat[coy][1]= - inp*mat[coz][1]; mat[coy][2]= 1.0 - inp*mat[coz][2]; - Kx_Normalize((float *)mat[coy]); + if (Kx_Normalize((float *)mat[coy]) == 0.f) { + /* the camera is vertical, chose the y axis arbitrary */ + mat[coy][0] = 0.f; + mat[coy][1] = 1.f; + mat[coy][2] = 0.f; + } Kx_Crossf(mat[cox], mat[coy], mat[coz]); -- cgit v1.2.3 From 106974a9d2d5caa5188322507980e3d57d2e3517 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Thu, 8 May 2008 18:38:21 +0000 Subject: Fixing up the webplugin defines for the Makefiles. Now you can do one of the following to disable it: export NAN_NO_PLUGIN=true export WITH_BF_WEBPLUGIN=false or export WITH_BF_WEBPLUGIN=true to enable building it. (Its set to false by default) Kent --- source/gameengine/GamePlayer/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/Makefile b/source/gameengine/GamePlayer/Makefile index 747a82fc333..c4f78f23117 100644 --- a/source/gameengine/GamePlayer/Makefile +++ b/source/gameengine/GamePlayer/Makefile @@ -34,7 +34,7 @@ SOURCEDIR = source/gameengine/GamePlayer DIR = $(OCGDIR)/gameengine/GamePlayer DIRS = common ghost -ifneq ($(NAN_NO_PLUGIN),true) +ifeq ($(WITH_BF_WEBPLUGIN),true) ifeq ($(OS),$(findstring $(OS), "freebsd irix windows")) ifneq ($(FREE_WINDOWS),true) DIRS += netscape -- cgit v1.2.3 From 96486b356f7d035a7abc835adbef850c3f314264 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 11 May 2008 18:45:30 +0000 Subject: fix BGE bug #8668: Behavior of os.getcwd() is not consistent between operating systems Add a function GameLogic.expandPath() that works like Blender.sys.expandpath() and is also available in the BlenderPlayer. Fix the game actuator in the BlenderPlayer to work like in Blender: - try first to load the .blend from the current working directory - if not found, try to load from the startup .blend or runtime base directory --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 25 +++++++++++++++---- source/gameengine/Ketsji/KX_PythonInit.cpp | 31 ++++++++++++++++++++++++ source/gameengine/PyDoc/GameLogic.py | 15 ++++++++++++ 3 files changed, 66 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 8817bc98886..bc80c0a7612 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -562,13 +562,13 @@ int main(int argc, char** argv) STR_String exitstring = ""; GPG_Application app(system, NULL, exitstring); bool firstTimeRunning = true; + char *filename = get_filename(argc, argv); + char *titlename; + char pathname[160]; do { // Read the Blender file - char *filename = get_filename(argc, argv); - char *titlename; - char pathname[160]; BlendFileData *bfd; // if we got an exitcode 3 (KX_EXIT_REQUEST_START_OTHER_GAME) load a different file @@ -582,6 +582,17 @@ int main(int argc, char** argv) BLI_convertstringcode(basedpath, pathname); bfd = load_game_data(basedpath); + + if (!bfd) + { + // just add "//" in front of it + char temppath[242]; + strcpy(temppath, "//"); + strcat(temppath, basedpath); + + BLI_convertstringcode(temppath, pathname); + bfd = load_game_data(temppath); + } } else { @@ -607,7 +618,6 @@ int main(int argc, char** argv) #endif // WIN32 Main *maggie = bfd->main; Scene *scene = bfd->curscene; - strcpy (pathname, maggie->name); char *startscenename = scene->id.name + 2; G.fileflags = bfd->fileflags; @@ -651,7 +661,12 @@ int main(int argc, char** argv) if (firstTimeRunning) { firstTimeRunning = false; - + + // set the filename only the first time as in KetsjiEmbedded + strcpy (pathname, maggie->name); + // also copy here (used by GameLogic.getBaseDirectory) + strcpy (G.sce, maggie->name); + if (fullScreen) { #ifdef WIN32 diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index a2aff54d385..a80a7f04e8f 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -88,6 +88,10 @@ //#include "BPY_extern.h" #endif +#include "BKE_utildefines.h" +#include "BKE_global.h" +#include "BLI_blenlib.h" + static void setSandbox(TPythonSecurityLevel level); @@ -140,6 +144,32 @@ static PyObject* gPySetGravity(PyObject*, return NULL; } +static char gPyExpandPath_doc[] = +"(path) - Converts a blender internal path into a proper file system path.\n\ +path - the string path to convert.\n\n\ +Use / as directory separator in path\n\ +You can use '//' at the start of the string to define a relative path;\n\ +Blender replaces that string by the directory of the startup .blend or runtime\n\ +file to make a full path name (doesn't change during the game, even if you load\n\ +other .blend).\n\ +The function also converts the directory separator to the local file system format."; + +static PyObject* gPyExpandPath(PyObject*, + PyObject* args, + PyObject*) +{ + char expanded[FILE_MAXDIR + FILE_MAXFILE]; + char* filename; + + if (PyArg_ParseTuple(args,"s",&filename)) + { + BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE); + BLI_convertstringcode(expanded, G.sce); + return PyString_FromString(expanded); + } + return NULL; +} + static bool usedsp = false; @@ -361,6 +391,7 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) static struct PyMethodDef game_methods[] = { + {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, gPyExpandPath_doc}, {"getCurrentController", (PyCFunction) SCA_PythonController::sPyGetCurrentController, METH_VARARGS, SCA_PythonController::sPyGetCurrentController__doc__}, diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index fcfd8bfc4eb..965c0522bd7 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -221,3 +221,18 @@ def setPhysicsTicRate(ticrate): @type ticrate: float """ +def expandPath(path): + """ + Converts a blender internal path into a proper file system path. + + Use / as directory separator in path + You can use '//' at the start of the string to define a relative path; + Blender replaces that string by the directory of the startup .blend or runtime file + to make a full path name (doesn't change during the game, even if you load other .blend). + The function also converts the directory separator to the local file system format. + + @param path: The path string to be converted/expanded. + @type path: string + @return: The converted string + @rtype: string + """ -- cgit v1.2.3 From ac71783e8dccdb42afb8e68ae077902185bb42c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 12 May 2008 21:12:10 +0000 Subject: last commit had a typo, also adjusted teh and colour instances --- source/gameengine/Ketsji/KX_Light.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 3ae09c01270..7decc5bc769 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -223,7 +223,7 @@ char KX_LightObject::doc[] = "Module KX_LightObject\n\n" "\t\tThe effect radius of the light.\n" "\tcolour -> list [r, g, b].\n" "\tcolor -> list [r, g, b].\n" -"\t\tThe colour of the light.\n" +"\t\tThe color of the light.\n" "\tlin_attenuation -> float.\n" "\t\tThe attenuation factor for the light.\n" "\tspotsize -> float.\n" -- cgit v1.2.3 From a6a4b78417c3f6c74ccba6379365e16d165e2dc5 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 14 May 2008 20:22:57 +0000 Subject: Fix BGE bug #7532: TrackTo Actuator does not work correctly if it has a Vertex Parent. This is only a partial fix: the user must put the parent vertex at the center of the parent object and disable the physics on the tracking object (use empty or collision free object). --- source/gameengine/Ketsji/KX_GameObject.h | 10 +++++++++- source/gameengine/Ketsji/KX_SG_NodeRelationships.h | 6 ++++++ source/gameengine/Ketsji/KX_TrackToActuator.cpp | 18 +++++++++++++----- source/gameengine/SceneGraph/SG_Node.cpp | 10 ++++++++++ source/gameengine/SceneGraph/SG_Node.h | 8 ++++++++ source/gameengine/SceneGraph/SG_ParentRelation.h | 9 +++++++++ 6 files changed, 55 insertions(+), 6 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index b83d63e26bf..5dae59d1d63 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -368,7 +368,15 @@ public: { return m_bDyna; } - + + /** + * Check if this object has a vertex parent relationship + */ + bool IsVertexParent( ) + { + return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent()); + } + bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h index d83fb79ee25..e53af22408e 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h @@ -129,6 +129,12 @@ public : ~KX_VertexParentRelation( ); + bool + IsVertexRelation( + ) { + return true; + } + private : KX_VertexParentRelation( diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 58b87367258..b9792303565 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -69,13 +69,19 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj, m_upflag = upflag; m_parentobj = 0; - if (m_object){ + if (m_object) m_object->RegisterActuator(this); - KX_GameObject* curobj = (KX_GameObject*) GetParent(); - m_parentobj = curobj->GetParent(); // check if the object is parented - if (m_parentobj) { // if so, store the initial local rotation - m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation(); + if (gameobj->isA(&KX_GameObject::Type)) + { + // if the object is vertex parented, don't check parent orientation as the link is broken + if (!((KX_GameObject*)gameobj)->IsVertexParent()){ + m_parentobj = ((KX_GameObject*)gameobj)->GetParent(); // check if the object is parented + if (m_parentobj) { + // if so, store the initial local rotation + // this is needed to revert the effect of the parent inverse node (TBC) + m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation(); + } } } @@ -180,6 +186,8 @@ KX_TrackToActuator::~KX_TrackToActuator() { if (m_object) m_object->UnregisterActuator(this); + if (m_parentobj) + m_parentobj->Release(); } /* end of destructor */ void KX_TrackToActuator::ProcessReplica() diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index 73e16863173..ff9a9f7f371 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -148,6 +148,16 @@ GetRootSGParent( return (m_SGparent ? (const SG_Node*) m_SGparent->GetRootSGParent() : (const SG_Node*) this); } + bool +SG_Node:: +IsVertexParent() +{ + if (m_parent_relation) + { + return m_parent_relation->IsVertexRelation(); + } + return false; +} void SG_Node:: diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 4808f6f7d94..5cf24de68f3 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -152,6 +152,14 @@ public: ) ; + /** + * Return vertex parent status. + */ + + bool + IsVertexParent( + ) ; + /** * Update the spatial data of this node. Iterate through * the children of this node and update their world data. diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 1d211a9f39f..9d360d1c274 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -90,6 +90,15 @@ public : NewCopy( ) = 0; + /** + * Vertex Parent Relation are special: they don't propagate rotation + */ + virtual + bool + IsVertexRelation( + ) { + return false; + } protected : /** -- cgit v1.2.3 From 92c9ae280cd13415a40f8fc0b68ba53309350666 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 May 2008 05:55:12 +0000 Subject: replacing epydoc generation script with one copied from bpy docs --- source/gameengine/PyDoc/Makefile | 13 ------------- source/gameengine/PyDoc/epy_docgen.sh | 11 +++++++++++ 2 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 source/gameengine/PyDoc/Makefile create mode 100644 source/gameengine/PyDoc/epy_docgen.sh (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/Makefile b/source/gameengine/PyDoc/Makefile deleted file mode 100644 index 7861894ddec..00000000000 --- a/source/gameengine/PyDoc/Makefile +++ /dev/null @@ -1,13 +0,0 @@ - - -SOURCES=$(shell ls *.py) -TARGETS:=$(SOURCES:.py=.html) -PYDOC=/usr/lib/python2.2/pydoc.py - -all: $(SOURCES) - epydoc -o BPY_GE_236 --url "http://www.blender.org" -t GameLogic.py \ - -n "Blender GameEngine" --no-private --no-frames \ - $(shell ls *.py ) - -clean: - rm *.html diff --git a/source/gameengine/PyDoc/epy_docgen.sh b/source/gameengine/PyDoc/epy_docgen.sh new file mode 100644 index 00000000000..7fb5e49c996 --- /dev/null +++ b/source/gameengine/PyDoc/epy_docgen.sh @@ -0,0 +1,11 @@ +# epy_docgen.sh +# generates blender python doc using epydoc +# requires epydoc in your PATH. +# run from the doc directory containing the .py files +# usage: sh epy_docgen.sh + +# set posix locale so regex works properly for [A-Z]*.py +LC_ALL=POSIX + +epydoc -v -o BPY_GE --url "http://www.blender.org" --top GameLogic \ + --name "Blender GameEngine" --no-private --no-frames *.py -- cgit v1.2.3 From 7f10f5f66f6b29a7a4e508da7b3c80a50d00618d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 24 May 2008 08:34:04 +0000 Subject: fix BGE bug #8646: unusable anaglyph settings The best rules for stereo rendering are now applied to Blender. Here is the new situation: 1) The focal distance is now settable through the GUI: select the camera (each camera can have a different setting) and go to the camera data (F9): the "Dof Dist" and "Dof Ob" can be used to set the focal distance for that camera. The "Dof Ob" is interesting because it sets the focal distance so that the center this object will appear at the surface of the screen when running the game. 2) The eye separation is automatically set to focal_distance/30, which is considered to be a reasonable value. If you need a different value, you can always use Python scripting. Notes: - If you switch camera during the game, the focal distance will also change unless you have set the focal distance by scripting, in which case it overwrites the focal distance setting of all cameras. - If you don't set the focal distance in the camera data or by scripting, the default value will be used. The default value corresponds more of less to the near clipping plane which means that all the objects will be very far with little 3D effect. - If you don't set the eye separation by scripting, it is automatically computed as focal_distance/30, regardless on how the focal distance was set. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 8 +++++--- source/gameengine/Ketsji/KX_Camera.cpp | 5 +++++ source/gameengine/Ketsji/KX_Camera.h | 4 +++- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 5 +++-- source/gameengine/Rasterizer/RAS_CameraData.h | 5 ++++- source/gameengine/Rasterizer/RAS_IRasterizer.h | 1 + .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 6 ++++-- .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 1 + 8 files changed, 26 insertions(+), 9 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 089af9a68e7..82d16ffa181 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -87,6 +87,7 @@ #include "DNA_action_types.h" #include "BKE_main.h" #include "BKE_global.h" +#include "BKE_object.h" #include "BL_SkinMeshObject.h" #include "BL_SkinDeformer.h" #include "BL_MeshDeformer.h" @@ -1571,8 +1572,9 @@ static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX return gamelight; } -static KX_Camera *gamecamera_from_bcamera(Camera *ca, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) { - RAS_CameraData camdata(ca->lens, ca->clipsta, ca->clipend, ca->type == CAM_PERSP); +static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) { + Camera* ca = static_cast(ob->data); + RAS_CameraData camdata(ca->lens, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, dof_camera(ob)); KX_Camera *gamecamera; gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata); @@ -1607,7 +1609,7 @@ static KX_GameObject *gameobject_from_blenderobject( case OB_CAMERA: { - KX_Camera* gamecamera = gamecamera_from_bcamera(static_cast(ob->data), kxscene, converter); + KX_Camera* gamecamera = gamecamera_from_bcamera(ob, kxscene, converter); gameobj = gamecamera; //don't add a reference: the camera list in kxscene->m_cameras is not released at the end diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 09eb2053bfe..27e47d72bbe 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -204,6 +204,11 @@ float KX_Camera::GetCameraFar() const return m_camdata.m_clipend; } +float KX_Camera::GetFocalLength() const +{ + return m_camdata.m_focallength; +} + RAS_CameraData* KX_Camera::GetCameraData() diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h index 4cc8c049f91..75d574cd697 100644 --- a/source/gameengine/Ketsji/KX_Camera.h +++ b/source/gameengine/Ketsji/KX_Camera.h @@ -184,12 +184,14 @@ public: */ const MT_Matrix4x4& GetModelviewMatrix() const; - /** Gets the focal length. */ + /** Gets the aperture. */ float GetLens() const; /** Gets the near clip distance. */ float GetCameraNear() const; /** Gets the far clip distance. */ float GetCameraFar() const; + /** Gets the focal length (only used for stereo rendering) */ + float GetFocalLength() const; /** Gets all camera data. */ RAS_CameraData* GetCameraData(); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index c098f37efa8..1e3393d59a8 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -890,7 +890,7 @@ void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam) // update graphics void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) { - float left, right, bottom, top, nearfrust, farfrust; + float left, right, bottom, top, nearfrust, farfrust, focallength; const float ortho = 100.0; // KX_Camera* cam = scene->GetActiveCamera(); @@ -913,6 +913,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) float lens = cam->GetLens(); nearfrust = cam->GetCameraNear(); farfrust = cam->GetCameraFar(); + focallength = cam->GetFocalLength(); if (!cam->GetCameraData()->m_perspective) { @@ -939,7 +940,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) farfrust = frustum.camfar; MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix( - left, right, bottom, top, nearfrust, farfrust); + left, right, bottom, top, nearfrust, farfrust, focallength); cam->SetProjectionMatrix(projmat); diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index 99c0c412cf7..6aa9b34962b 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -40,13 +40,16 @@ struct RAS_CameraData int m_viewportbottom; int m_viewportright; int m_viewporttop; + float m_focallength; RAS_CameraData(float lens = 35., float clipstart = 0.1, float clipend = 100., bool perspective = true, - bool viewport = false, int viewportleft = 0, int viewportbottom = 0, int viewportright = 0, int viewporttop = 0) : + float focallength = 0.0f, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, + int viewportright = 0, int viewporttop = 0) : m_lens(lens), m_clipstart(clipstart), m_clipend(clipend), m_perspective(perspective), + m_focallength(focallength), m_viewport(viewport), m_viewportleft(viewportleft), m_viewportbottom(viewportbottom), diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 5e8b5ad8276..18a7f261c94 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -344,6 +344,7 @@ public: float top, float frustnear, float frustfar, + float focallength = 0.0f, bool perspective = true )=0; /** diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index ea41b2f7d13..f99121e5b7c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -1802,6 +1802,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( float top, float frustnear, float frustfar, + float focallength, bool ){ MT_Matrix4x4 result; @@ -1813,9 +1814,10 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( float near_div_focallength; // next 2 params should be specified on command line and in Blender publisher if (!m_setfocallength) - m_focallength = 1.5 * right; // derived from example + m_focallength = (focallength == 0.f) ? 1.5 * right // derived from example + : focallength; if (!m_seteyesep) - m_eyeseparation = 0.18 * right; // just a guess... + m_eyeseparation = m_focallength/30; // reasonable value... near_div_focallength = frustnear / m_focallength; switch(m_curreye) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index c63a7b80b7c..23714a12151 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -246,6 +246,7 @@ public: float top, float frustnear, float frustfar, + float focallength, bool perspective ); -- cgit v1.2.3 From cc6dac8c425bf0914df1cf3422577c28c617fbc4 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 24 May 2008 18:06:58 +0000 Subject: BGE patch: add rayCastToEx(), an extended version of rayCastTo() for use in game script --- source/gameengine/Ketsji/KX_GameObject.cpp | 86 +++++++++++++++++++++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 1 + source/gameengine/PyDoc/KX_GameObject.py | 31 ++++++++++- 3 files changed, 116 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index fb636b23082..6b4fd565495 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -743,6 +743,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS}, KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), KX_PYMETHODTABLE(KX_GameObject, rayCastTo), + KX_PYMETHODTABLE(KX_GameObject, rayCastToEx), {NULL,NULL} //Sentinel }; @@ -1325,7 +1326,7 @@ bool KX_GameObject::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT } KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, -"rayCastTo(other,dist,prop): look towards another point/KX_GameObject and return first object hit within dist that match prop\n" +"rayCastTo(other,dist,prop): look towards another point/KX_GameObject and return first object hit within dist that matches prop\n" " prop = property name that object must have; can be omitted => detect any object\n" " dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to other\n" " other = 3-tuple or object reference") @@ -1380,6 +1381,89 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, Py_Return; } +KX_PYMETHODDEF_DOC(KX_GameObject, rayCastToEx, +"rayCastToEx(to,from,dist,prop): cast a ray and return tuple (object,hit,normal) of contact point with object within dist that matches prop or None if no hit\n" +" prop = property name that object must have; can be omitted => detect any object\n" +" dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to to\n" +" from = 3-tuple or object reference for origin of ray (if object, use center of object)\n" +" Can None or omitted => start from self object center\n" +" to = 3-tuple or object reference for destination of ray (if object, use center of object)\n" +"Note: the object on which you call this method matters: the ray will ignore it if it goes through it\n") +{ + MT_Point3 toPoint; + MT_Point3 fromPoint; + PyObject* pyto; + PyObject* pyfrom = NULL; + float dist = 0.0f; + char *propName = NULL; + KX_GameObject *other; + + if (!PyArg_ParseTuple(args,"O|Ofs", &pyto, &pyfrom, &dist, &propName)) + return NULL; + + if (!PyVecTo(pyto, toPoint)) + { + PyErr_Clear(); + if (!PyType_IsSubtype(pyto->ob_type, &KX_GameObject::Type)) + return NULL; + other = static_cast(pyto); + toPoint = other->NodeGetWorldPosition(); + } + if (!pyfrom || pyfrom == Py_None) + { + fromPoint = NodeGetWorldPosition(); + } + else if (!PyVecTo(pyfrom, fromPoint)) + { + PyErr_Clear(); + if (!PyType_IsSubtype(pyfrom->ob_type, &KX_GameObject::Type)) + return NULL; + other = static_cast(pyfrom); + fromPoint = other->NodeGetWorldPosition(); + } + + if (dist != 0.0f) + { + MT_Vector3 toDir = toPoint-fromPoint; + toDir.normalize(); + toPoint = fromPoint + (dist) * toDir; + } + + MT_Point3 resultPoint; + MT_Vector3 resultNormal; + PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); + KX_IPhysicsController *spc = GetPhysicsController(); + KX_GameObject *parent = GetParent(); + if (!spc && parent) + spc = parent->GetPhysicsController(); + if (parent) + parent->Release(); + + m_pHitObject = NULL; + if (propName) + m_testPropName = propName; + else + m_testPropName.SetLength(0); + KX_RayCast::RayTest(spc, pe, fromPoint, toPoint, resultPoint, resultNormal, KX_RayCast::Callback(this)); + + if (m_pHitObject) + { + PyObject* returnValue = PyTuple_New(3); + if (!returnValue) + return NULL; + PyTuple_SET_ITEM(returnValue, 0, m_pHitObject->AddRef()); + PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(resultPoint)); + PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(resultNormal)); + return returnValue; + //return Py_BuildValue("(O,(fff),(fff))", + // m_pHitObject->AddRef(), // trick: KX_GameObject are not true Python object, they use a difference reference count system + // resultPoint[0], resultPoint[1], resultPoint[2], + // resultNormal[0], resultNormal[1], resultNormal[2]); + } + return Py_BuildValue("OOO", Py_None, Py_None, Py_None); + //Py_Return; +} + /* --------------------------------------------------------------------- * Some stuff taken from the header * --------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 5dae59d1d63..9e35e45270c 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -665,6 +665,7 @@ public: KX_PYMETHOD(KX_GameObject,RemoveParent); KX_PYMETHOD(KX_GameObject,GetPhysicsId); KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); + KX_PYMETHOD_DOC(KX_GameObject,rayCastToEx); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); private : diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 8ef82b4943b..b0f55b4ad7a 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -174,9 +174,10 @@ class KX_GameObject: The ray is always casted from the center of the object, ignoring the object itself. The ray is casted towards the center of another object or an explicit [x,y,z] point. + Use rayCastToEx() if you need to retrieve the hit point @param other: [x,y,z] or object towards which the ray is casted - @type other: L{KX_GameObject} or string + @type other: L{KX_GameObject} or 3-tuple @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other @type dist: float @param prop: property name that object must have; can be omitted => detect any object @@ -184,4 +185,32 @@ class KX_GameObject: @rtype: L{KX_GameObject} @return: the first object hit or None if no object or object does not match prop """ + def rayCastToEx(to,from,dist,prop): + """ + Look from a point/object to another point/object and find first object hit within dist that matches prop. + Returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no object hit. + Ex: + # shoot along the axis gun-gunAim (gunAim should be collision-free) + ob,point,normal = gun.rayCastToEx(gunAim,None,50) + if ob: + # hit something + + Notes: + The ray ignores the object on which the method is called. + If is casted from/to object center or explicit [x,y,z] points. + The ray does not have X-Ray capability: the first object hit (other than self object) stops the ray + If a property was specified and the first object hit does not have that property, there is no hit + The ray ignores collision-free objects + + @param to: [x,y,z] or object to which the ray is casted + @type to: L{KX_GameObject} or 3-tuple + @param from: [x,y,z] or object from which the ray is casted; None or omitted => use self object center + @type from: L{KX_GameObject} or 3-tuple or None + @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to + @type dist: float + @param prop: property name that object must have; can be omitted => detect any object + @type prop: string + @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz)) + @return: (object,hitpoint,hitnormal) or (None,None,None) + """ \ No newline at end of file -- cgit v1.2.3 From e2a9590a15c807c391ec7eff05c7168a8025ab7a Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 24 May 2008 22:50:31 +0000 Subject: BGE patch: rename rayCastToEx() to rayCast() - better name --- source/gameengine/Ketsji/KX_GameObject.cpp | 6 +++--- source/gameengine/Ketsji/KX_GameObject.h | 2 +- source/gameengine/PyDoc/KX_GameObject.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6b4fd565495..5fd5d2d5492 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -743,7 +743,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS}, KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), KX_PYMETHODTABLE(KX_GameObject, rayCastTo), - KX_PYMETHODTABLE(KX_GameObject, rayCastToEx), + KX_PYMETHODTABLE(KX_GameObject, rayCast), {NULL,NULL} //Sentinel }; @@ -1381,8 +1381,8 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, Py_Return; } -KX_PYMETHODDEF_DOC(KX_GameObject, rayCastToEx, -"rayCastToEx(to,from,dist,prop): cast a ray and return tuple (object,hit,normal) of contact point with object within dist that matches prop or None if no hit\n" +KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, +"rayCast(to,from,dist,prop): cast a ray and return tuple (object,hit,normal) of contact point with object within dist that matches prop or None if no hit\n" " prop = property name that object must have; can be omitted => detect any object\n" " dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to to\n" " from = 3-tuple or object reference for origin of ray (if object, use center of object)\n" diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 9e35e45270c..6e765978821 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -665,7 +665,7 @@ public: KX_PYMETHOD(KX_GameObject,RemoveParent); KX_PYMETHOD(KX_GameObject,GetPhysicsId); KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); - KX_PYMETHOD_DOC(KX_GameObject,rayCastToEx); + KX_PYMETHOD_DOC(KX_GameObject,rayCast); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); private : diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index b0f55b4ad7a..fbd896a55d1 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -174,7 +174,7 @@ class KX_GameObject: The ray is always casted from the center of the object, ignoring the object itself. The ray is casted towards the center of another object or an explicit [x,y,z] point. - Use rayCastToEx() if you need to retrieve the hit point + Use rayCast() if you need to retrieve the hit point @param other: [x,y,z] or object towards which the ray is casted @type other: L{KX_GameObject} or 3-tuple @@ -185,13 +185,13 @@ class KX_GameObject: @rtype: L{KX_GameObject} @return: the first object hit or None if no object or object does not match prop """ - def rayCastToEx(to,from,dist,prop): + def rayCast(to,from,dist,prop): """ Look from a point/object to another point/object and find first object hit within dist that matches prop. - Returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no object hit. + Returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit. Ex: # shoot along the axis gun-gunAim (gunAim should be collision-free) - ob,point,normal = gun.rayCastToEx(gunAim,None,50) + ob,point,normal = gun.rayCast(gunAim,None,50) if ob: # hit something -- cgit v1.2.3 From da1f38f99d3b8a07ed4ddd905f8e7d7c6e25f945 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 25 May 2008 14:37:39 +0000 Subject: Apply BGE patch 11137: Render objects with negative scaling correctly (as in Blender) --- .../gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp | 16 ++++++++++++++++ .../gameengine/BlenderRoutines/KX_BlenderRenderTools.h | 2 ++ source/gameengine/GamePlayer/common/GPC_RenderTools.cpp | 16 ++++++++++++++++ source/gameengine/GamePlayer/common/GPC_RenderTools.h | 2 ++ source/gameengine/Ketsji/KX_GameObject.cpp | 3 ++- source/gameengine/Ketsji/KX_GameObject.h | 9 +++++++++ source/gameengine/Rasterizer/RAS_IRenderTools.h | 1 + source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | 2 ++ 8 files changed, 50 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index a656c5e5523..ffd66655069 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -125,6 +125,22 @@ void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty) } +void KX_BlenderRenderTools::SetClientObject(void* obj) +{ + if (m_clientobject != obj) + { + if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()) + { + glFrontFace(GL_CCW); + } else + { + glFrontFace(GL_CW); + } + m_clientobject = obj; + m_modified = true; + } +} + bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) { double* const oglmatrix = (double* const) data; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 662f5bd9af1..31eaa14d66b 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -105,6 +105,8 @@ public: virtual void Render2DFilters(RAS_ICanvas* canvas); + virtual void SetClientObject(void* obj); + }; #endif //__KX_BLENDERRENDERTOOLS diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index edda7657ef9..885981a2898 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -462,6 +462,22 @@ int GPC_RenderTools::applyLights(int objectlayer) } +void GPC_RenderTools::SetClientObject(void* obj) +{ + if (m_clientobject != obj) + { + if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()) + { + glFrontFace(GL_CCW); + } else + { + glFrontFace(GL_CW); + } + m_clientobject = obj; + m_modified = true; + } +} + bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) { double* const oglmatrix = (double* const) data; diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index 9b86869af73..ee0212da643 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -153,6 +153,8 @@ public: virtual void Render2DFilters(RAS_ICanvas* canvas); + virtual void SetClientObject(void* obj); + protected: /** * Copied from KX_BlenderGL.cpp in KX_blenderhook diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 5fd5d2d5492..dada47e2fa4 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -77,6 +77,7 @@ KX_GameObject::KX_GameObject( m_layer(0), m_bSuspendDynamics(false), m_bUseObjectColor(false), + m_bIsNegativeScaling(false), m_bVisible(true), m_pPhysicsController1(NULL), m_pPhysicsEnvironment(NULL), @@ -335,7 +336,7 @@ double* KX_GameObject::GetOpenGLMatrix() trans.setBasis(GetSGNode()->GetWorldOrientation()); MT_Vector3 scaling = GetSGNode()->GetWorldScaling(); - + m_bIsNegativeScaling = ((scaling[0] < 0.0) ^ (scaling[1] < 0.0) ^ (scaling[2] < 0.0)) ? true : false; trans.scale(scaling[0], scaling[1], scaling[2]); trans.getValue(fl); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 6e765978821..3758651f53d 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -75,6 +75,7 @@ protected: bool m_bSuspendDynamics; bool m_bUseObjectColor; + bool m_bIsNegativeScaling; MT_Vector4 m_objectColor; // Is this object set to be visible? Only useful for the @@ -598,6 +599,14 @@ public: void ); + /** + * Get the negative scaling state + */ + bool + IsNegativeScaling( + void + ) { return m_bIsNegativeScaling; } + /** * @section Logic bubbling methods. */ diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index 16e15653c82..bcbf907741b 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -146,6 +146,7 @@ public: int layer )=0; + virtual void SetClientObject( void* obj diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 02e84f8a243..96ce220ae4d 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -325,6 +325,8 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans, while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode)) RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode); } + // to reset the eventual GL_CW mode + rendertools->SetClientObject(NULL); } -- cgit v1.2.3 From 1cc61f633fb16a4aca576bccef365f8e515c5a3d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 2 Jun 2008 17:31:05 +0000 Subject: Patch #11000 approved: [new function] KX_GameObject::alignAxisToVect() Align an object's axis to a given vector --- source/gameengine/Ketsji/KX_GameObject.cpp | 81 +++++++++++++++++++++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 10 ++++ source/gameengine/PyDoc/KX_GameObject.py | 15 +++++- 3 files changed, 104 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index dada47e2fa4..c192cd01261 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -580,7 +580,68 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec) m_objectColor = rgbavec; } +void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis) +{ + MT_Matrix3x3 orimat; + MT_Vector3 vect,ori,z,x,y; + MT_Scalar len; + vect = dir; + len = vect.length(); + if (MT_fuzzyZero(len)) + { + cout << "alignAxisToVect() Error: Null vector!\n"; + return; + } + // normalize + vect /= len; + orimat = GetSGNode()->GetWorldOrientation(); + switch (axis) + { + case 0: //x axis + ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis + if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector paralell to the pivot? + ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot! + x = vect; + y = ori.cross(x); + z = x.cross(y); + break; + case 1: //y axis + ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]); + if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) + ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]); + y = vect; + z = ori.cross(y); + x = y.cross(z); + break; + case 2: //z axis + ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]); + if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) + ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]); + z = vect; + x = ori.cross(z); + y = z.cross(x); + break; + default: //wrong input? + cout << "alignAxisToVect(): Wrong axis '" << axis <<"'\n"; + return; + } + x.normalize(); //normalize the vectors + y.normalize(); + z.normalize(); + orimat = MT_Matrix3x3( x[0],y[0],z[0], + x[1],y[1],z[1], + x[2],y[2],z[2]); + if (GetSGNode()->GetSGParent() != NULL) + { + // the object is a child, adapt its local orientation so that + // the global orientation is aligned as we want. + MT_Matrix3x3 invori = GetSGNode()->GetSGParent()->GetWorldOrientation().inverse(); + NodeSetLocalOrientation(invori*orimat); + } + else + NodeSetLocalOrientation(orimat); +} MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { @@ -723,6 +784,7 @@ void KX_GameObject::Suspend(void) PyMethodDef KX_GameObject::Methods[] = { {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS}, + {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS}, {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_VARARGS}, {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_VARARGS}, {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_VARARGS}, @@ -1255,7 +1317,24 @@ PyObject* KX_GameObject::PySetOrientation(PyObject* self, return NULL; } - +PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + PyObject* pyvect; + int axis = 2; //z axis is the default + + if (PyArg_ParseTuple(args,"O|i",&pyvect,&axis)) + { + MT_Vector3 vect; + if (PyVecTo(pyvect, vect)) + { + AlignAxisToVect(vect,axis); + Py_Return; + } + } + return NULL; +} PyObject* KX_GameObject::PySetPosition(PyObject* self, PyObject* args, diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 3758651f53d..56b9f3f6375 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -258,6 +258,15 @@ public: bool local=false ); + /** + * Align the object to a given normal. + */ + void + AlignAxisToVect( + const MT_Vector3& vect, + int axis = 2 + ); + /** * Quick'n'dirty obcolor ipo stuff */ @@ -662,6 +671,7 @@ public: KX_PYMETHOD(KX_GameObject,GetOrientation); KX_PYMETHOD(KX_GameObject,SetOrientation); KX_PYMETHOD(KX_GameObject,SetVisible); + KX_PYMETHOD(KX_GameObject,AlignAxisToVect); KX_PYMETHOD(KX_GameObject,SuspendDynamics); KX_PYMETHOD(KX_GameObject,RestoreDynamics); KX_PYMETHOD(KX_GameObject,EnableRigidBody); diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index fbd896a55d1..8d29a704380 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -51,6 +51,18 @@ class KX_GameObject: @type orn: 3x3 rotation matrix, or Quaternion. @param orn: a rotation matrix specifying the new rotation. """ + def alignAxisToVect(vect, axis): + """ + Aligns any of the game object's axis along the given vector. + + @type vect: 3d vector. + @param vect: a vector to align the axis. + @type axis: integer. + @param axis:The axis you want to align + - 0: X axis + - 1: Y axis + - 2: Z axis (default) + """ def getOrientation(): """ Gets the game object's orientation. @@ -213,4 +225,5 @@ class KX_GameObject: @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz)) @return: (object,hitpoint,hitnormal) or (None,None,None) """ - \ No newline at end of file + + -- cgit v1.2.3 From 772d241582a8d396425cd7f53438871858669a99 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 3 Jun 2008 22:54:24 +0000 Subject: Fix BGE bug #13605: GameEngine corrupts Pose data --- source/gameengine/Converter/BL_ArmatureObject.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index ff9c6a75aa9..08567dde840 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -153,9 +153,12 @@ void BL_ArmatureObject::GetPose(bPose **pose) int copy_constraint_channels_hack = 1; copy_pose(pose, m_pose, copy_constraint_channels_hack); } - else + else { + if (*pose == m_pose) + // no need to copy if the pointers are the same + return; extract_pose_from_pose(*pose, m_pose); - + } } void BL_ArmatureObject::GetMRDPose(bPose **pose) @@ -169,7 +172,11 @@ void BL_ArmatureObject::GetMRDPose(bPose **pose) //} if (!*pose) - copy_pose(pose, m_objArma->pose, 0); + // must duplicate the constraints too otherwise we have corruption in free_pose_channels() + // because it will free the blender constraints. + // Ideally, blender should rememeber that the constraints were not copied so that + // free_pose_channels() would not free them. + copy_pose(pose, m_objArma->pose, 1); else extract_pose_from_pose(*pose, m_objArma->pose); -- cgit v1.2.3 From d565e8a02f94e61fbebcfbcdcef1f547b4e6b65b Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Wed, 4 Jun 2008 02:54:42 +0000 Subject: bugfix #13618 - 2d filters + GLSL python scripts --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 9454edfacfe..e8562c54539 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -166,6 +166,9 @@ void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) GLint uniformLoc; bgl::blUseProgramObjectARB(shaderprogram); uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texname); + if (uniformLoc != -1) { bgl::blUniform1iARB(uniformLoc, 0); -- cgit v1.2.3 From fbb56ee99731bb788e89ce7c54706654a998e7ea Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Wed, 4 Jun 2008 18:11:48 +0000 Subject: Issue jms was having with # else on msvc. Seems odd but easy to fix. Kent --- .../Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h index a18ed038f35..3e24ee204a1 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h @@ -53,9 +53,9 @@ #elif defined(__APPLE__) # include "mac_compat_glext.h" # include -# else +#else # include -# endif +#endif #endif #ifdef __sgi -- cgit v1.2.3 From 6ffadbfb103f498b7400ae6d7d960c98404a9bdc Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Fri, 6 Jun 2008 01:28:51 +0000 Subject: fix 2dfilter problem on AMD64, Patches item #13626 --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index e8562c54539..80d6d55df25 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -166,7 +166,8 @@ void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) GLint uniformLoc; bgl::blUseProgramObjectARB(shaderprogram); uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); - glActiveTexture(GL_TEXTURE0); + bgl::blActiveTextureARB(GL_TEXTURE0); + //glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texname); if (uniformLoc != -1) -- cgit v1.2.3 From 71573cbd55a9088f4f3011da473ad6101fc2b531 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 8 Jun 2008 10:48:37 +0000 Subject: Bugfix #13666: Missing #include in source/gameengine/Ketsji/KX_RayCast.cpp --- source/gameengine/Ketsji/KX_RayCast.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index ce7ed984985..b88741625b6 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -29,6 +29,7 @@ */ #include +#include #include "KX_RayCast.h" -- cgit v1.2.3 From f39758cddca1d6eeec299e8cd3eef9a2a1852e32 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jun 2008 15:45:46 +0000 Subject: adding clip alpha (binary alpha) to the 3D view and game engine. --- source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp | 11 +++++++++-- source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp index 46fe24d8b87..09dd14172c8 100644 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp +++ b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp @@ -154,16 +154,23 @@ int set_tpage(MTFace *tface) fAlphamode= tface->transp; if(fAlphamode) { - glEnable(GL_BLEND); - if(fAlphamode==TF_ADD) { + glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); + glDisable ( GL_ALPHA_TEST ); /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */ } else if(fAlphamode==TF_ALPHA) { + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable ( GL_ALPHA_TEST ); /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */ } + else if (alphamode==TF_CLIP){ + glDisable(GL_BLEND); + glEnable ( GL_ALPHA_TEST ); + glAlphaFunc(GL_GREATER, 0.5f); + } /* else { */ /* glBlendFunc(GL_ONE, GL_ONE); */ /* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */ diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 44727588106..5efe1ad26ca 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -478,16 +478,23 @@ bool KX_BlenderMaterial::setDefaultBlending() if( mMaterial->transp &TF_ADD) { glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); + glDisable ( GL_ALPHA_TEST ); return true; } if( mMaterial->transp & TF_ALPHA ) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable ( GL_ALPHA_TEST ); return true; } - glDisable(GL_BLEND); + if( mMaterial->transp & TF_CLIP ) { + glDisable(GL_BLEND); + glEnable ( GL_ALPHA_TEST ); + glAlphaFunc(GL_GREATER, 0.5f); + return true; + } return false; } -- cgit v1.2.3 From 192037960d0b0f104aee6a8652bf1f410d880b1f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 9 Jun 2008 22:54:56 +0000 Subject: error in variable name, not sure how this even compiled --- source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp index 09dd14172c8..c2f15aefe16 100644 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp +++ b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp @@ -166,7 +166,7 @@ int set_tpage(MTFace *tface) glDisable ( GL_ALPHA_TEST ); /* glBlendEquationEXT(GL_FUNC_ADD_EXT); */ } - else if (alphamode==TF_CLIP){ + else if (fAlphamode==TF_CLIP){ glDisable(GL_BLEND); glEnable ( GL_ALPHA_TEST ); glAlphaFunc(GL_GREATER, 0.5f); -- cgit v1.2.3 From 8bd82d4e3645a1e1e141522f6a127bb73759096b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Jun 2008 02:20:09 +0000 Subject: Some pose action ipo corruptions when using BGE, added some debug printf's when copying to/from the same pose since it should never happen. --- source/gameengine/Converter/BL_ArmatureObject.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 08567dde840..d4712efda9e 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -92,9 +92,10 @@ BL_ArmatureObject::~BL_ArmatureObject() /* there is only 1 unique Pose per Armature */ void BL_ArmatureObject::ApplyPose() { - if (m_pose){ + if (m_pose) { // copy to armature object - extract_pose_from_pose(m_objArma->pose, m_pose); + if (m_objArma->pose != m_pose)/* This should never happen but it does - Campbell */ + extract_pose_from_pose(m_objArma->pose, m_pose); // is this needed anymore? //if (!m_mrdPose) -- cgit v1.2.3 From fc7a83b458811883b01e948a37e6177ae96602db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Jun 2008 17:12:49 +0000 Subject: Added access for adjusting timeOffset value at runtime, used for apricot (Franky climbing walls) --- source/gameengine/Ketsji/KX_GameObject.cpp | 21 +++++++++++++++++++++ source/gameengine/Ketsji/KX_SG_NodeRelationships.h | 15 +++++++++++++++ source/gameengine/PyDoc/KX_GameObject.py | 2 ++ source/gameengine/SceneGraph/SG_Node.cpp | 11 +++++++++++ source/gameengine/SceneGraph/SG_Node.h | 8 ++++++++ source/gameengine/SceneGraph/SG_ParentRelation.h | 10 ++++++++++ source/gameengine/SceneGraph/SG_Spatial.cpp | 7 +++++++ source/gameengine/SceneGraph/SG_Spatial.h | 4 ++++ 8 files changed, 78 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index c192cd01261..6fde94fec53 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -911,6 +911,14 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr) if (attr == "name") return PyString_FromString(m_name.ReadPtr()); + if (attr == "timeOffset") { + if (m_pSGNode->GetSGParent()->IsSlowParent()) { + return PyFloat_FromDouble(static_cast(m_pSGNode->GetSGParent()->GetParentRelation())->GetTimeOffset()); + } else { + return PyFloat_FromDouble(0.0); + } + } + _getattr_up(SCA_IObject); } @@ -932,6 +940,19 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr return 0; } } + + if (PyFloat_Check(value)) + { + MT_Scalar val = PyFloat_AsDouble(value); + if (attr == "timeOffset") { + if (m_pSGNode->GetSGParent()->IsSlowParent()) { + static_cast(m_pSGNode->GetSGParent()->GetParentRelation())->SetTimeOffset(val); + return 0; + } else { + return 0; + } + } + } if (PySequence_Check(value)) { diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h index e53af22408e..faa650106c8 100644 --- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h +++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h @@ -177,8 +177,23 @@ public : NewCopy( ); + MT_Scalar + GetTimeOffset( + ) { return m_relax; } + + void + SetTimeOffset( + MT_Scalar relaxation + ) { m_relax = relaxation; } + ~KX_SlowParentRelation( ); + + bool + IsSlowRelation( + ) { + return true; + } private : diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 8d29a704380..678df59e4a9 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -22,6 +22,8 @@ class KX_GameObject: @type orientation: 3x3 Matrix [[float]] @ivar scaling: The object's scaling factor. list [sx, sy, sz] @type scaling: list [sx, sy, sz] + @ivar timeOffset: adjust the slowparent delay at runtime. + @type timeOffset: float """ def setVisible(visible): diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index ff9a9f7f371..4e90d7c4653 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -159,6 +159,17 @@ IsVertexParent() return false; } + bool +SG_Node:: +IsSlowParent() +{ + if (m_parent_relation) + { + return m_parent_relation->IsSlowRelation(); + } + return false; +} + void SG_Node:: DisconnectFromParent( diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index 5cf24de68f3..f86e3046d93 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -159,6 +159,14 @@ public: bool IsVertexParent( ) ; + + /** + * Return slow parent status. + */ + + bool + IsSlowParent( + ) ; /** * Update the spatial data of this node. Iterate through diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h index 9d360d1c274..6507cb98519 100644 --- a/source/gameengine/SceneGraph/SG_ParentRelation.h +++ b/source/gameengine/SceneGraph/SG_ParentRelation.h @@ -99,6 +99,16 @@ public : ) { return false; } + + /** + * Need this to see if we are able to adjust time-offset from the python api + */ + virtual + bool + IsSlowRelation( + ) { + return false; + } protected : /** diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index 18049592977..5ba116e59db 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -87,6 +87,13 @@ SG_Spatial:: delete (m_parent_relation); } + SG_ParentRelation * +SG_Spatial:: +GetParentRelation( +){ + return m_parent_relation; +} + void SG_Spatial:: SetParentRelation( diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h index a70784472a7..28848b0f933 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.h +++ b/source/gameengine/SceneGraph/SG_Spatial.h @@ -83,6 +83,10 @@ public: SetParentRelation( SG_ParentRelation *relation ); + + SG_ParentRelation * + GetParentRelation( + ); /** -- cgit v1.2.3 From 89c1875bc9a761b52f2f2041203bfcf3ef34030e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 14 Jun 2008 20:42:15 +0000 Subject: BGE patch: support Set Scene in BGE. Linked Set Scene should have no name conflict in Object, Object data and Action of the main scene to avoid confusion in Python scripting. Nested Set Scene are supported. You will need Python scripting to create cross references between objects in the main scene and the Set (e.g TrackTo actuator) --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 82d16ffa181..5a9cda67941 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -88,6 +88,7 @@ #include "BKE_main.h" #include "BKE_global.h" #include "BKE_object.h" +#include "BKE_scene.h" #include "BL_SkinMeshObject.h" #include "BL_SkinDeformer.h" #include "BL_MeshDeformer.h" @@ -1808,6 +1809,9 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { Scene *blenderscene = GetSceneForName(maggie, scenename); + // for SETLOOPER + Scene *sce; + Base *base; // Get the frame settings of the canvas. // Get the aspect ratio of the canvas as designed by the user. @@ -1881,9 +1885,11 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } SetDefaultFaceType(blenderscene); - - Base *base = static_cast(blenderscene->base.first); - while(base) + // Let's support scene set. + // Beware of name conflict in linked data, it will not crash but will create confusion + // in Python scripting and in certain actuators (replace mesh). Linked scene *should* have + // no conflicting name for Object, Object data and Action. + for (SETLOOPER(blenderscene, base)) { Object* blenderobject = base->object; KX_GameObject* gameobj = gameobject_from_blenderobject( @@ -2038,7 +2044,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (gameobj) gameobj->Release(); - base = base->next; } if (blenderscene->camera) { @@ -2048,7 +2053,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } // Set up armatures - for (base = static_cast(blenderscene->base.first); base; base=base->next){ + for(SETLOOPER(blenderscene, base)){ if (base->object->type==OB_MESH){ Mesh *me = (Mesh*)base->object->data; -- cgit v1.2.3 From f63b70635c91062a8ef71b2a1f82ac8d4bb06372 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jun 2008 09:43:24 +0000 Subject: bugfix, clip alpha wasn't working in the GE, not happy with these functions, they probably need bigger changes not to assume all alpha requires face sorting with a disabled depth buffer, --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 6 +++--- source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 5a9cda67941..cb981f55c5a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -542,7 +542,7 @@ BL_Material* ConvertMaterial( material->amb = mat->amb; // set alpha testing without z-sorting - if( ( validface && (!tface->transp)) && mat->mode & MA_ZTRA) { + if( ( validface && (!(tface->transp &~ TF_CLIP))) && mat->mode & MA_ZTRA) { // sets the RAS_IPolyMaterial::m_flag |RAS_FORCEALPHA // this is so we don't have the overhead of the z-sorting code material->ras_mode|=ALPHA_TEST; @@ -598,7 +598,7 @@ BL_Material* ConvertMaterial( material->ras_mode |= ( (tface->mode & TF_DYNAMIC)!= 0 )?COLLIDER:0; material->transp = tface->transp; - if(tface->transp) + if(tface->transp&~TF_CLIP) material->ras_mode |= TRANSP; material->tile = tface->tile; @@ -947,7 +947,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* // Use texface colors if available //TF_DYNAMIC means the polygon is a collision face collider = ((tface->mode & TF_DYNAMIC) != 0); - transp = tface->transp; + transp = tface->transp &~ TF_CLIP; tile = tface->tile; mode = tface->mode; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 5efe1ad26ca..cc978760da7 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -493,7 +493,7 @@ bool KX_BlenderMaterial::setDefaultBlending() glDisable(GL_BLEND); glEnable ( GL_ALPHA_TEST ); glAlphaFunc(GL_GREATER, 0.5f); - return true; + return false; } return false; } -- cgit v1.2.3 From 9b69c569178e118e1e2486f167164673a4201be0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 16 Jun 2008 09:16:04 +0000 Subject: Material color was always overriding OBCOL for blender text. --- source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 7c9dbcdaab2..2a5cc14018f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -133,7 +133,12 @@ void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface characters = 0; } - if(!col) glColor3f(1.0f, 1.0f, 1.0f); + /* When OBCOL flag is on the color is set in IndexPrimitives_3DText */ + if (tface->mode & TF_OBCOL) { /* Color has been set */ + col= NULL; + } else { + if(!col) glColor3f(1.0f, 1.0f, 1.0f); + } glPushMatrix(); for (index = 0; index < characters; index++) { -- cgit v1.2.3 From c9d1924ea5575ae2a4ce2cc7fd16e63e6ef14d84 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 17 Jun 2008 10:06:38 +0000 Subject: Use the scenes framerate for ipo and action framerate in the game engine, was hard coded to 25. --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 6 ++++++ source/gameengine/Converter/BL_ActionActuator.cpp | 8 ++++---- source/gameengine/Ketsji/KX_GameObject.h | 3 +-- source/gameengine/Ketsji/KX_IpoActuator.cpp | 6 +++--- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 13 ++++++++++++- source/gameengine/Ketsji/KX_KetsjiEngine.h | 10 ++++++++++ 6 files changed, 36 insertions(+), 10 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index fa8409b123e..eb575c70ad7 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -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) { diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 1055c8771ef..ad126ebf123 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -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; diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 56b9f3f6375..8a90ec1463a 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -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 diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 0f9caa456d9..cf246342cf9 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -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 diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 1e3393d59a8..56a06786679 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -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; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index bc2e3864be8..4c09bc3fcd5 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -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. -- cgit v1.2.3 From 272a91f754fd215f2ad9b48ba80fe56ee0564d7a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 17 Jun 2008 10:27:34 +0000 Subject: Merge of apricot branch game engine changes into trunk, excluding GLSL. GLEW ==== Added the GLEW opengl extension library into extern/, always compiled into Blender now. This is much nicer than doing this kind of extension management manually, and will be used in the game engine, for GLSL, and other opengl extensions. * According to the GLEW website it works on Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris. There might still be platform specific issues due to this commit, so let me know and I'll look into it. * This means also that all extensions will now always be compiled in, regardless of the glext.h on the platform where compilation happens. Game Engine =========== Refactoring of the use of opengl extensions and other drawing code in the game engine, and cleaning up some hacks related to GLSL integration. These changes will be merged into trunk too after this. The game engine graphics demos & apricot level survived my tests, but this could use some good testing of course. For users: please test with the options "Generate Display Lists" and "Vertex Arrays" enabled, these should be the fastest and are supposed to be "unreliable", but if that's the case that's probably due to bugs that can be fixed. * The game engine now also uses GLEW for extensions, replacing the custom opengl extensions code that was there. Removes a lot of #ifdef's, but the runtime checks stay of course. * Removed the WITHOUT_GLEXT environment variable. This was added to work around a specific bug and only disabled multitexturing anyway. It might also have caused a slowdown since it was retrieving the environment variable for every vertex in immediate mode (bug #13680). * Refactored the code to allow drawing skinned meshes with vertex arrays too, removing some specific immediate mode drawing functions for this that only did extra normal calculation. Now it always splits vertices of flat faces instead. * Refactored normal recalculation with some minor optimizations, required for the above change. * Removed some outdated code behind the __NLA_OLDDEFORM #ifdef. * Fixed various bugs in setting of multitexture coordinates and vertex attributes for vertex arrays. These were not being enabled/disabled correct according to the opengl spec, leading to crashes. Also tangent attributes used an immediate mode call for vertex arrays, which can't work. * Fixed use of uninitialized variable in RAS_TexVert. * Exporting skinned meshes was doing O(n^2) lookups for vertices and deform weights, now uses same trick as regular meshes. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 44 +- source/gameengine/BlenderRoutines/CMakeLists.txt | 1 + .../gameengine/BlenderRoutines/KX_BlenderCanvas.h | 8 +- source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 52 +- .../BlenderRoutines/KX_BlenderRenderTools.cpp | 13 +- source/gameengine/BlenderRoutines/Makefile | 3 +- source/gameengine/BlenderRoutines/SConscript | 1 + .../gameengine/BlenderRoutines/mac_compat_glext.h | 132 --- source/gameengine/Converter/BL_ArmatureObject.cpp | 2 +- .../Converter/BL_BlenderDataConversion.cpp | 33 +- source/gameengine/Converter/BL_MeshDeformer.cpp | 160 ++- source/gameengine/Converter/BL_MeshDeformer.h | 7 +- source/gameengine/Converter/BL_SkinDeformer.cpp | 43 +- source/gameengine/Converter/BL_SkinDeformer.h | 4 +- source/gameengine/Converter/BL_SkinMeshObject.cpp | 24 +- source/gameengine/Converter/BL_SkinMeshObject.h | 43 +- .../Converter/KX_BlenderSceneConverter.cpp | 14 +- .../Converter/KX_BlenderSceneConverter.h | 5 + source/gameengine/GamePlayer/common/CMakeLists.txt | 1 + source/gameengine/GamePlayer/common/GPC_Canvas.h | 18 +- .../GamePlayer/common/GPC_PolygonMaterial.cpp | 19 +- .../GamePlayer/common/GPC_RenderTools.cpp | 14 +- .../gameengine/GamePlayer/common/GPC_RenderTools.h | 15 +- source/gameengine/GamePlayer/common/Makefile | 1 + source/gameengine/GamePlayer/common/SConscript | 3 +- source/gameengine/GamePlayer/ghost/CMakeLists.txt | 1 + .../GamePlayer/ghost/GPG_Application.cpp | 43 +- .../gameengine/GamePlayer/ghost/GPG_Application.h | 1 + source/gameengine/GamePlayer/ghost/Makefile | 1 + source/gameengine/GamePlayer/ghost/SConscript | 3 +- source/gameengine/Ketsji/BL_BlenderShader.cpp | 149 +++ source/gameengine/Ketsji/BL_BlenderShader.h | 44 + source/gameengine/Ketsji/BL_Material.cpp | 1 + source/gameengine/Ketsji/BL_Material.h | 3 +- source/gameengine/Ketsji/BL_Shader.cpp | 306 +++--- source/gameengine/Ketsji/BL_Texture.cpp | 161 +-- source/gameengine/Ketsji/CMakeLists.txt | 1 + source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 289 ++++-- source/gameengine/Ketsji/KX_BlenderMaterial.h | 13 +- source/gameengine/Ketsji/KX_GameObject.cpp | 4 +- source/gameengine/Ketsji/KX_ISceneConverter.h | 3 + source/gameengine/Ketsji/KX_PythonInit.cpp | 68 +- source/gameengine/Ketsji/Makefile | 1 + source/gameengine/Ketsji/SConscript | 2 +- source/gameengine/Rasterizer/CMakeLists.txt | 1 + source/gameengine/Rasterizer/Makefile | 1 + .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 63 +- source/gameengine/Rasterizer/RAS_CameraData.h | 4 +- .../gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 6 - .../gameengine/Rasterizer/RAS_IPolygonMaterial.h | 2 - source/gameengine/Rasterizer/RAS_IRasterizer.h | 29 +- .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 39 +- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 27 +- source/gameengine/Rasterizer/RAS_MeshObject.h | 1 + .../RAS_OpenGLRasterizer/ARB_multitexture.h | 150 --- .../Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt | 1 + .../EXT_separate_specular_color.h | 12 - .../Rasterizer/RAS_OpenGLRasterizer/Makefile | 1 + .../RAS_GLExtensionManager.cpp | 676 +------------ .../RAS_OpenGLRasterizer/RAS_GLExtensionManager.h | 507 +--------- .../RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp | 19 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 1055 +++++--------------- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 37 +- .../RAS_VAOpenGLRasterizer.cpp | 298 +++--- .../RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h | 7 +- .../Rasterizer/RAS_OpenGLRasterizer/SConscript | 6 +- .../Rasterizer/RAS_OpenGLRasterizer/mkglext.py | 627 ------------ source/gameengine/Rasterizer/SConscript | 2 +- 68 files changed, 1374 insertions(+), 3951 deletions(-) delete mode 100644 source/gameengine/BlenderRoutines/mac_compat_glext.h create mode 100644 source/gameengine/Ketsji/BL_BlenderShader.cpp create mode 100644 source/gameengine/Ketsji/BL_BlenderShader.h delete mode 100644 source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h delete mode 100644 source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h delete mode 100644 source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index eb575c70ad7..06aa0609ad9 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -40,9 +40,7 @@ #pragma warning (disable:4786) #endif -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#endif +#include "GL/glew.h" #include "KX_BlenderGL.h" #include "KX_BlenderCanvas.h" @@ -57,10 +55,10 @@ #include "KX_PythonInit.h" #include "KX_PyConstraintBinding.h" +#include "RAS_GLExtensionManager.h" #include "RAS_OpenGLRasterizer.h" #include "RAS_VAOpenGLRasterizer.h" #include "RAS_ListRasterizer.h" -#include "RAS_GLExtensionManager.h" #include "NG_LoopBackNetworkDeviceInterface.h" #include "SND_DeviceManager.h" @@ -142,12 +140,12 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, // so we can safely run Python code and API calls PyGILState_STATE gilstate = PyGILState_Ensure(); - bgl::InitExtensions(1); - + bgl::InitExtensions(true); + do { View3D *v3d= (View3D*) area->spacedata.first; - + // get some preferences SYS_SystemHandle syshandle = SYS_GetSystem(); bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0); @@ -156,22 +154,10 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); bool game2ipo = (SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0); bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0); - bool usemat = false; - - #if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) { - usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 0) != 0); - int unitmax=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax); - bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX; - //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl; - } else { - bgl::max_texture_units = 0; - } - } - #endif + bool usemat = false, useglslmat = false; + if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) + usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 0) != 0); // create the canvas, rasterizer and rendertools RAS_ICanvas* canvas = new KX_BlenderCanvas(area); @@ -186,12 +172,12 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, bool lock_arrays = (displaylists && useVertexArrays); if(displaylists){ - if (useVertexArrays) { + if (useVertexArrays) rasterizer = new RAS_ListRasterizer(canvas, true, lock_arrays); - } else { + else rasterizer = new RAS_ListRasterizer(canvas); - } - } else if (useVertexArrays && bgl::QueryVersion(1, 1)) + } + else if (useVertexArrays && GLEW_VERSION_1_1) rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays); else rasterizer = new RAS_OpenGLRasterizer(canvas); @@ -338,6 +324,8 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, if(usemat) sceneconverter->SetMaterials(true); + if(useglslmat) + sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(keyboarddevice, mousedevice, @@ -504,7 +492,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, // so we can safely run Python code and API calls PyGILState_STATE gilstate = PyGILState_Ensure(); - bgl::InitExtensions(1); + bgl::InitExtensions(true); do { @@ -533,7 +521,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, if(displaylists && !useVertexArrays) rasterizer = new RAS_ListRasterizer(canvas); - else if (useVertexArrays && bgl::QueryVersion(1, 1)) + else if (useVertexArrays && GLEW_VERSION_1_1) rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays); else rasterizer = new RAS_OpenGLRasterizer(canvas); diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index 764be732343..1d72fb9cde1 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -33,6 +33,7 @@ SET(INC ../../../source/blender/blenloader ../../../extern/bullet2/src ../../../extern/solid + ../../../extern/glew/include ${PYTHON_INC} ) diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index f9ff8f61b97..b155d39e149 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -32,12 +32,8 @@ #ifdef WIN32 #include #endif -#ifdef __APPLE__ -# define GL_GLEXT_LEGACY 1 -#include -#else -#include -#endif + +#include "GL/glew.h" #include "RAS_ICanvas.h" #include "RAS_Rect.h" diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 2a5cc14018f..230d6b262c6 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -44,21 +44,9 @@ #include "BMF_Api.h" +#include "GL/glew.h" +#include "BIF_gl.h" -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#include -#else -#include -#if defined(__sun__) && !defined(__sparc__) -#include -#else -#include -#endif -#endif -#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" -#include "RAS_OpenGLRasterizer/ARB_multitexture.h" #include "BL_Material.h" // MAXTEX /* Data types encoding the game world: */ @@ -77,7 +65,6 @@ #include "BKE_bmfont.h" #include "BKE_image.h" -#include "BIF_gl.h" extern "C" { #include "BDR_drawmesh.h" #include "BIF_mywindow.h" @@ -88,12 +75,6 @@ extern "C" { /* end of blender block */ -#ifdef __APPLE__ -#include -#else -#include -#endif - /* was in drawmesh.c */ void spack(unsigned int ucol) { @@ -194,27 +175,18 @@ void DisableForText() glDisable(GL_LIGHTING); glDisable(GL_COLOR_MATERIAL); } -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - for(int i=0; i -#endif //WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#else -#include -#endif +#include "GL/glew.h" #include "RAS_IRenderTools.h" #include "RAS_IRasterizer.h" @@ -317,7 +308,7 @@ void KX_BlenderRenderTools::EnableOpenGLLights() glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true); - if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2)) + if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); } diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile index 64a17f44a84..a7394158a20 100644 --- a/source/gameengine/BlenderRoutines/Makefile +++ b/source/gameengine/BlenderRoutines/Makefile @@ -35,7 +35,6 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) -CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_SUMO)/include -I$(NAN_SOLID)/include CPPFLAGS += -I$(NAN_SOLID) CPPFLAGS += -I$(NAN_STRING)/include @@ -43,6 +42,8 @@ CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_BMFONT)/include CPPFLAGS += -I$(NAN_FUZZICS)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include +CPPFLAGS += -I$(NAN_GLEW)/include +CPPFLAGS += -I$(OPENGL_HEADERS) # because of kernel dependency on makesdna CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I../../blender/include diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index 95e1da2d470..327f4798e04 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -15,6 +15,7 @@ incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common' incs += ' #source/gameengine/Physics/Bullet #source/gameengine/Physics/Sumo' incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork' incs += ' #intern/SoundSystem #source/blender/misc #source/blender/blenloader' +incs += ' #extern/glew/include' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_SOLID_INC'] diff --git a/source/gameengine/BlenderRoutines/mac_compat_glext.h b/source/gameengine/BlenderRoutines/mac_compat_glext.h deleted file mode 100644 index 0ec676963b1..00000000000 --- a/source/gameengine/BlenderRoutines/mac_compat_glext.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef __mac_compat_glext_h_ -#define __mac_compat_glext_h_ - - -#ifdef __cplusplus -extern "C" { -#endif - -#define APIENTRYP * -# define GL_GLEXT_LEGACY 1 -# include - -//#if GL_ARB_shader_objects -typedef char GLcharARB; -typedef void *GLhandleARB; -//#endif - -//#if GL_ARB_vertex_buffer_object -typedef long GLintptrARB; -typedef long GLsizeiptrARB; -//#endif - - -// GL_ARB_multitexture -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); - -//GL_ARB_shader_objects -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (unsigned int obj); -typedef unsigned int (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (unsigned int containerObj, unsigned int attachedObj); -typedef unsigned int (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (unsigned int shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (unsigned int shaderObj); -typedef unsigned int (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (unsigned int containerObj, unsigned int obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (unsigned int programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (unsigned int programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (unsigned int programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (unsigned int obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (unsigned int obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (unsigned int obj, GLsizei maxLength, GLsizei *length, void *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (unsigned int containerObj, GLsizei maxCount, GLsizei *count, unsigned int *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (unsigned int programObj, const void *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (unsigned int programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (unsigned int programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (unsigned int programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (unsigned int obj, GLsizei maxLength, GLsizei *length, void *source); - - -//GL_ARB_vertex_shader -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (unsigned int programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (unsigned int programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (unsigned int programObj, const GLcharARB *name); - - -//GL_ARB_vertex_program -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); - -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index d4712efda9e..f73d5b42a01 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -144,7 +144,7 @@ void BL_ArmatureObject::GetPose(bPose **pose) { /* If the caller supplies a null pose, create a new one. */ /* Otherwise, copy the armature's pose channels into the caller-supplied pose */ - + if (!*pose) { /* probably not to good of an idea to duplicate everying, but it clears up diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index cb981f55c5a..0ad9258bcc0 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -510,6 +510,7 @@ BL_Material* ConvertMaterial( } } } + // above one tex the switches here // are not used switch(valid_index) { @@ -588,6 +589,9 @@ BL_Material* ConvertMaterial( MT_Point2 uv[4]; MT_Point2 uv2[4]; + uv[0]= uv[1]= uv[2]= uv[3]= MT_Point2(0.0f, 0.0f); + uv2[0]= uv2[1]= uv2[2]= uv2[3]= MT_Point2(0.0f, 0.0f); + if( validface ) { material->ras_mode |= !( @@ -731,14 +735,14 @@ static MT_Vector4* BL_ComputeMeshTangentSpace(Mesh* mesh) MT_Vector3 *tan1 = new MT_Vector3[mesh->totvert]; MT_Vector3 *tan2 = new MT_Vector3[mesh->totvert]; - unsigned int v; + int v; for (v = 0; v < mesh->totvert; v++) { tan1[v] = MT_Vector3(0.0, 0.0, 0.0); tan2[v] = MT_Vector3(0.0, 0.0, 0.0); } - for (unsigned int p = 0; p < mesh->totface; p++, mface++, tface++) + for (int p = 0; p < mesh->totface; p++, mface++, tface++) { MT_Vector3 v1(mesh->mvert[mface->v1].co), v2(mesh->mvert[mface->v2].co), @@ -830,9 +834,10 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* } } - meshobj->SetName(mesh->id.name); meshobj->m_xyz_index_to_vertex_index_mapping.resize(mesh->totvert); + if(skinMesh) + ((BL_SkinMeshObject*)meshobj)->m_mvert_to_dvert_mapping.resize(mesh->totvert); for (int f=0;ftotface;f++,mface++) { @@ -882,7 +887,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* Material* ma = 0; bool polyvisible = true; RAS_IPolyMaterial* polymat = NULL; - BL_Material *bl_mat; + BL_Material *bl_mat = NULL; if(converter->GetMaterials()) { @@ -892,6 +897,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* ma = give_current_material(blenderobj, 1); bl_mat = ConvertMaterial(mesh, ma, tface, mface, mmcol, lightlayer, blenderobj, layers); + bl_mat->glslmat = converter->GetGLSLMaterials(); // set the index were dealing with bl_mat->material_index = (int)mface->mat_nr; @@ -1066,19 +1072,19 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* d3=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v3, &mesh->dvert[mface->v3], polymat); if (nverts==4) d4=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v4, &mesh->dvert[mface->v4], polymat); - poly->SetVertex(0,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,d1,flat, polymat)); - poly->SetVertex(1,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,d2,flat, polymat)); - poly->SetVertex(2,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,d3,flat, polymat)); + poly->SetVertex(0,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,d1,flat,polymat,mface->v1)); + poly->SetVertex(1,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,d2,flat,polymat,mface->v2)); + poly->SetVertex(2,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,d3,flat,polymat,mface->v3)); if (nverts==4) - poly->SetVertex(3,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,d4, flat,polymat)); + poly->SetVertex(3,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,d4,flat,polymat,mface->v4)); } else { - poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,polymat,mface->v1)); - poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,polymat,mface->v2)); - poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,polymat,mface->v3)); + poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,false,polymat,mface->v1)); + poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,false,polymat,mface->v2)); + poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,false,polymat,mface->v3)); if (nverts==4) - poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,polymat,mface->v4)); + poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,false,polymat,mface->v4)); } meshobj->AddPolygon(poly); if (poly->IsCollider()) @@ -1116,6 +1122,9 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* layer.face++; } } + meshobj->m_xyz_index_to_vertex_index_mapping.clear(); + if(skinMesh) + ((BL_SkinMeshObject*)meshobj)->m_mvert_to_dvert_mapping.clear(); meshobj->UpdateMaterialList(); // pre calculate texture generation diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index ab31179b047..85ba894f9a5 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -43,27 +43,25 @@ #include "BL_SkinMeshObject.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "BLI_arithb.h" #include "GEN_Map.h" #include "STR_HashedString.h" - bool BL_MeshDeformer::Apply(RAS_IPolyMaterial *mat) { size_t i, j, index; vecVertexArray array; vecIndexArrays mvarray; vecIndexArrays diarray; - + RAS_TexVert *tv; MVert *mvert; - + // For each material array = m_pMeshObject->GetVertexCache(mat); mvarray = m_pMeshObject->GetMVertCache(mat); diarray = m_pMeshObject->GetDIndexCache(mat); - + // For each array for (i=0; itotvert; v++){ - m_transnors[v]=MT_Point3(0,0,0); - } - - /* Find the face normals */ - for (f = 0; ftotface; f++){ - // Make new face normal based on the transverts - MFace *mf= &((MFace*)m_bmesh->mface)[f]; - - if (mf->v3) { - for (int vl=0; vl<3; vl++){ - co1[vl]=m_transverts[mf->v1][vl]; - co2[vl]=m_transverts[mf->v2][vl]; - co3[vl]=m_transverts[mf->v3][vl]; - if (mf->v4) - co4[vl]=m_transverts[mf->v4][vl]; + vecIndexArrays indexarrays; + vecIndexArrays mvarrays; + vecIndexArrays diarrays; + vecVertexArray vertexarrays; + size_t i, j; + + /* set vertex normals to zero */ + for (i=0; i<(size_t)m_bmesh->totvert; i++) + m_transnors[i] = MT_Vector3(0.0f, 0.0f, 0.0f); + + /* add face normals to vertices. */ + for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); + mit != m_pMeshObject->GetLastMaterial(); ++ mit) { + RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); + + indexarrays = m_pMeshObject->GetIndexCache(mat); + vertexarrays = m_pMeshObject->GetVertexCache(mat); + diarrays = m_pMeshObject->GetDIndexCache(mat); + mvarrays = m_pMeshObject->GetMVertCache(mat); + + for (i=0; iUsesTriangles()? 3: 4; + + for(j=0; jv4) - CalcNormFloat4(co1, co2, co3, co4, fnor); - else - CalcNormFloat(co1, co2, co3, fnor); - - /* Decide which normals are affected by this face's normal */ - m_transnors[mf->v1]+=MT_Point3(fnor); - m_transnors[mf->v2]+=MT_Point3(fnor); - m_transnors[mf->v3]+=MT_Point3(fnor); - if (mf->v4) - m_transnors[mf->v4]+=MT_Point3(fnor); + /* assign smooth vertex normals */ + for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); + mit != m_pMeshObject->GetLastMaterial(); ++ mit) { + RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); + + vertexarrays = m_pMeshObject->GetVertexCache(mat); + diarrays = m_pMeshObject->GetDIndexCache(mat); + mvarrays = m_pMeshObject->GetMVertCache(mat); + + for (i=0; itotvert; v++){ -// float nor[3]; - - m_transnors[v]=m_transnors[v].safe_normalized(); -// nor[0]=m_transnors[v][0]; -// nor[1]=m_transnors[v][1]; -// nor[2]=m_transnors[v][2]; - - }; } void BL_MeshDeformer::VerifyStorage() { /* Ensure that we have the right number of verts assigned */ - if (m_tvtot!=m_bmesh->totvert+m_bmesh->totface){ + if (m_tvtot!=m_bmesh->totvert+m_bmesh->totface) { if (m_transverts) - delete []m_transverts; + delete [] m_transverts; if (m_transnors) - delete []m_transnors; + delete [] m_transnors; - m_transnors =new MT_Point3[m_bmesh->totvert+m_bmesh->totface]; m_transverts=new float[(sizeof(*m_transverts)*m_bmesh->totvert)][3]; + m_transnors=new MT_Vector3[m_bmesh->totvert]; m_tvtot = m_bmesh->totvert; } } diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index a6be11d786e..88dc2500859 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -48,9 +48,9 @@ public: BL_MeshDeformer(struct Object* obj, class BL_SkinMeshObject *meshobj ): m_pMeshObject(meshobj), m_bmesh((struct Mesh*)(obj->data)), + m_transverts(0), + m_transnors(0), m_objMesh(obj), - m_transnors(NULL), - m_transverts(NULL), m_tvtot(0) {}; virtual ~BL_MeshDeformer(); @@ -62,12 +62,11 @@ public: protected: class BL_SkinMeshObject* m_pMeshObject; struct Mesh* m_bmesh; - MT_Point3* m_transnors; - //MT_Point3* m_transverts; // this is so m_transverts doesn't need to be converted // before deformation float (*m_transverts)[3]; + MT_Vector3* m_transnors; struct Object* m_objMesh; // -- int m_tvtot; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 14faa3317d0..0f884674c09 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -57,7 +57,6 @@ extern "C"{ #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS - BL_SkinDeformer::BL_SkinDeformer( struct Object *bmeshobj_old, // Blender object that owns the new mesh struct Object *bmeshobj_new, // Blender object that owns the original mesh @@ -87,25 +86,15 @@ BL_SkinDeformer::~BL_SkinDeformer() Mat4CpyMat4(m_objMesh->obmat, m_obmat); } -/* XXX note, this __NLA_OLDDEFORM define seems to be obsolete */ - bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) { size_t i, j, index; vecVertexArray array; -#ifdef __NLA_OLDDEFORM - vecMVertArray mvarray; -#else vecIndexArrays mvarray; -#endif vecMDVertArray dvarray; vecIndexArrays diarray; RAS_TexVert *tv; -#ifdef __NLA_OLDDEFORM - MVert *mvert; - MDeformVert *dvert; -#endif MT_Point3 pt; // float co[3]; @@ -115,48 +104,24 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) Update(); array = m_pMeshObject->GetVertexCache(mat); -#ifdef __NLA_OLDDEFORM - dvarray = m_pMeshObject->GetDVertCache(mat); -#endif mvarray = m_pMeshObject->GetMVertCache(mat); diarray = m_pMeshObject->GetDIndexCache(mat); - // For each array - for (i=0; isize(); j++){ + for (j=0; jsize(); j++) { tv = &((*array[i])[j]); index = ((*diarray[i])[j]); -#ifdef __NLA_OLDDEFORM - pt = tv->xyz(); - mvert = ((*mvarray[i])[index]); - dvert = ((*dvarray[i])[index]); -#endif // Copy the untransformed data from the original mvert -#ifdef __NLA_OLDDEFORM - co[0]=mvert->co[0]; - co[1]=mvert->co[1]; - co[2]=mvert->co[2]; - - // Do the deformation -/* XXX note, doesnt exist anymore */ -// GB_calc_armature_deform(co, dvert); - tv->SetXYZ(co); -#else // Set the data tv->SetXYZ(m_transverts[((*mvarray[i])[index])]); -#ifdef __NLA_DEFNORMALS - - tv->SetNormal(m_transnors[((*mvarray[i])[index])]); -#endif -#endif } } - + return true; } @@ -197,7 +162,9 @@ void BL_SkinDeformer::Update(void) VECCOPY(m_transverts[v], m_bmesh->mvert[v].co); armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, ARM_DEF_VGROUP, NULL, NULL ); +#ifdef __NLA_DEFNORMALS RecalcNormals(); +#endif /* Update the current frame */ m_lastUpdate=m_armobj->GetLastFrame(); diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index e130dc15dbf..79f6453a25d 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -69,8 +69,8 @@ public: m_armobj(arma), m_lastUpdate(-1), m_defbase(&bmeshobj->defbase), - m_releaseobject(false), - m_restoremat(false) + m_restoremat(false), + m_releaseobject(false) { }; diff --git a/source/gameengine/Converter/BL_SkinMeshObject.cpp b/source/gameengine/Converter/BL_SkinMeshObject.cpp index 8bc78c7f757..69feb72f5dc 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.cpp +++ b/source/gameengine/Converter/BL_SkinMeshObject.cpp @@ -53,23 +53,27 @@ void BL_SkinMeshObject::AddPolygon(RAS_Polygon* poly) RAS_MeshObject::AddPolygon(poly); } -#ifdef __NLA_OLDDEFORM -int BL_SkinMeshObject::FindOrAddDeform(int vtxarray, struct MVert *mv, struct MDeformVert *dv, RAS_IPolyMaterial* mat) -#else int BL_SkinMeshObject::FindOrAddDeform(unsigned int vtxarray, unsigned int mv, struct MDeformVert *dv, RAS_IPolyMaterial* mat) -#endif { BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); int numvert = ao->m_MvertArrayCache1[vtxarray]->size(); - + /* Check to see if this has already been pushed */ - for (unsigned int i=0; im_MvertArrayCache1[vtxarray]->size(); i++){ - if (mv == (*ao->m_MvertArrayCache1[vtxarray])[i]) - return i; + for (vector::iterator it = m_mvert_to_dvert_mapping[mv].begin(); + it != m_mvert_to_dvert_mapping[mv].end(); + it++) + { + if(it->mat == mat) + return it->index; } ao->m_MvertArrayCache1[vtxarray]->push_back(mv); ao->m_DvertArrayCache1[vtxarray]->push_back(dv); + + BL_MDVertMap mdmap; + mdmap.mat = mat; + mdmap.index = numvert; + m_mvert_to_dvert_mapping[mv].push_back(mdmap); return numvert; }; @@ -105,11 +109,7 @@ int BL_SkinMeshObject::FindVertexArray(int numverts,RAS_IPolyMaterial* polymat) KX_IndexArray *ia = new KX_IndexArray(); ao->m_IndexArrayCache1.push_back(ia); -#ifdef __NLA_OLDDEFORM - BL_MVertArray *bva = new BL_MVertArray(); -#else KX_IndexArray *bva = new KX_IndexArray(); -#endif ao->m_MvertArrayCache1.push_back(bva); BL_DeformVertArray *dva = new BL_DeformVertArray(); diff --git a/source/gameengine/Converter/BL_SkinMeshObject.h b/source/gameengine/Converter/BL_SkinMeshObject.h index 0ca7428c0f0..2422d4cd4c9 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.h +++ b/source/gameengine/Converter/BL_SkinMeshObject.h @@ -106,6 +106,9 @@ class BL_SkinMeshObject : public RAS_MeshObject protected: public: + struct BL_MDVertMap { RAS_IPolyMaterial *mat; int index; }; + vector > m_mvert_to_dvert_mapping; + void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec); // void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,class RAS_BucketManager* bucketmgr); @@ -139,37 +142,17 @@ public: const MT_Point2& uv2, const MT_Vector4& tangent, const unsigned int rgbacolor, - const MT_Vector3& normal, int defnr, bool flat, RAS_IPolyMaterial* mat) + const MT_Vector3& normal, int defnr, bool flat, RAS_IPolyMaterial* mat, int origindex) { - RAS_TexVert tempvert(xyz,uv,uv2, tangent,rgbacolor,normal,flat ? TV_CALCFACENORMAL : 0); - - // KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); - BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); - - int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray]; - - int index=-1; - - for (int i=0;im_VertexArrayCache1[vtxarray])[i]; - if (tempvert.closeTo(&vtx)) - { - index = i; - break; - } - - } - if (index >= 0) - return index; - - // no vertex found, add one - ao->m_VertexArrayCache1[vtxarray]->push_back(tempvert); - ao->m_DIndexArrayCache1[vtxarray]->push_back(defnr); - - return numverts; - - + BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat); + int numverts = ao->m_VertexArrayCache1[vtxarray]->size(); + int index = RAS_MeshObject::FindOrAddVertex(vtxarray, xyz, uv, uv2, tangent, rgbacolor, normal, flat, mat, origindex); + + /* this means a new vertex was added, so we add the defnr too */ + if(index == numverts) + ao->m_DIndexArrayCache1[vtxarray]->push_back(defnr); + + return index; } }; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 8640e69102b..de91bce2ab1 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -100,7 +100,8 @@ KX_BlenderSceneConverter::KX_BlenderSceneConverter( m_sipo(sipo), m_ketsjiEngine(engine), m_alwaysUseExpandFraming(false), - m_usemat(false) + m_usemat(false), + m_useglslmat(false) { m_newfilename = ""; } @@ -449,6 +450,13 @@ void KX_BlenderSceneConverter::RemoveScene(KX_Scene *scene) void KX_BlenderSceneConverter::SetMaterials(bool val) { m_usemat = val; + m_useglslmat = false; +} + +void KX_BlenderSceneConverter::SetGLSLMaterials(bool val) +{ + m_usemat = val; + m_useglslmat = val; } bool KX_BlenderSceneConverter::GetMaterials() @@ -456,6 +464,10 @@ bool KX_BlenderSceneConverter::GetMaterials() return m_usemat; } +bool KX_BlenderSceneConverter::GetGLSLMaterials() +{ + return m_useglslmat; +} void KX_BlenderSceneConverter::RegisterBlenderMaterial(BL_Material *mat) { diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index a45d7396875..e5d6ccc5caf 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -75,6 +75,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter class KX_Scene* m_currentScene; // Scene being converted bool m_alwaysUseExpandFraming; bool m_usemat; + bool m_useglslmat; void localDel_ipoCurve ( IpoCurve * icu ,struct SpaceIpo* sipo); // struct Ipo* findIpoForName(char* objName); @@ -146,6 +147,10 @@ public: virtual void SetMaterials(bool val); virtual bool GetMaterials(); + // use blender glsl materials + virtual void SetGLSLMaterials(bool val); + virtual bool GetGLSLMaterials(); + }; #endif //__KX_BLENDERSCENECONVERTER_H diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index 29cdcd640f5..e26f8b9d69a 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -69,6 +69,7 @@ SET(INC ../../../../source/gameengine/GamePlayer/ghost ../../../../source/blender/misc ../../../../source/blender/blenloader + ../../../../extern/glew/include ${PYTHON_INC} ${SOLID_INC} ${PNG_INC} diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index bd66c865988..f82166dfa88 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -33,18 +33,12 @@ #include "RAS_ICanvas.h" #include "RAS_Rect.h" -#if defined(WIN32) || defined(__APPLE__) - #ifdef WIN32 - #pragma warning (disable:4786) // suppress stl-MSVC debug info warning - #include - #include - #else // WIN32 - // __APPLE__ is defined - #include - #endif // WIN32 -#else //defined(WIN32) || defined(__APPLE__) - #include -#endif //defined(WIN32) || defined(__APPLE__) +#ifdef WIN32 + #pragma warning (disable:4786) // suppress stl-MSVC debug info warning + #include +#endif // WIN32 + +#include "GL/glew.h" #include diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp index c2f15aefe16..b1e2b5af0e6 100644 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp +++ b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp @@ -31,23 +31,7 @@ #include #endif -#ifdef WIN32 -#include -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#include -#else -#include -#if defined(__sun__) && !defined(__sparc__) -#include -#else -#include -#endif -#endif - - +#include "GL/glew.h" #include "GPC_PolygonMaterial.h" #include "MT_Vector3.h" @@ -88,7 +72,6 @@ static int fDoMipMap = 1; static int fLinearMipMap=1; static int fAlphamode= -1; -using namespace bgl; /* (n&(n-1)) zeros the least significant bit of n */ static int is_pow2(int num) { return ((num)&(num-1))==0; diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 885981a2898..44eeccedbd1 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -34,12 +34,8 @@ #include #endif -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#else -#include -#endif +#include "GL/glew.h" + #include #include "GPC_RenderTools.h" @@ -137,10 +133,6 @@ int GPC_RenderTools::ProcessLighting(int layer) { if (m_clientobject) { - if (layer == RAS_LIGHT_OBJECT_LAYER) - { - layer = static_cast(m_clientobject)->GetLayer(); - } if (applyLights(layer)) { EnableOpenGLLights(); @@ -160,7 +152,7 @@ void GPC_RenderTools::EnableOpenGLLights() glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); - if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2)) + if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); } diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index ee0212da643..f7230cb0865 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -30,18 +30,11 @@ #ifndef __GPC_RENDERTOOLS_H #define __GPC_RENDERTOOLS_H -#if defined(WIN32) || defined(__APPLE__) - #ifdef WIN32 - #include - #include - #else // WIN32 - // __APPLE__ is defined - #include - #endif // WIN32 -#else //defined(WIN32) || defined(__APPLE__) - #include -#endif //defined(WIN32) || defined(__APPLE__) +#ifdef WIN32 + #include +#endif // WIN32 +#include "GL/glew.h" #include "RAS_IRenderTools.h" diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile index 508dee18755..19d792ddbdb 100644 --- a/source/gameengine/GamePlayer/common/Makefile +++ b/source/gameengine/GamePlayer/common/Makefile @@ -35,6 +35,7 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I../../../blender/blenkernel diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index 6ff3ae10735..3b2367d2592 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -45,7 +45,8 @@ incs = ['.', '#source/gameengine/Network/LoopBackNetwork', '#source/gameengine/GamePlayer/ghost', '#source/blender/misc', - '#source/blender/blenloader'] + '#source/blender/blenloader', + '#extern/glew/include'] #This is all plugin stuff! #if sys.platform=='win32': diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index 3d17cd2cfdd..d9f0675001f 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -65,6 +65,7 @@ SET(INC ../../../../source/blender/misc ../../../../source/blender/blenloader ../../../../extern/solid + ../../../../extern/glew/include ${PYTHON_INC} ) diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index dfd15227501..c4cf698d5ee 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -37,18 +37,7 @@ #include #endif -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#include -#else -#include -#if defined(__sun__) && !defined(__sparc__) -#include -#else -#include -#endif -#endif +#include "GL/glew.h" #include "GPG_Application.h" @@ -134,7 +123,8 @@ GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR m_sceneconverter(0), m_networkdevice(0), m_audiodevice(0), - m_blendermat(0) + m_blendermat(0), + m_blenderglslmat(0) { fSystem = system; } @@ -487,7 +477,8 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) { if (!m_engineInitialized) { - bgl::InitExtensions(1); + glewInit(); + bgl::InitExtensions(true); // get and set the preferences SYS_SystemHandle syshandle = SYS_GetSystem(); @@ -508,26 +499,10 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool useVertexArrays = SYS_GetCommandLineInt(syshandle,"vertexarrays",1) != 0; bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DIAPLAY_LISTS) != 0); -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { + if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) { int gameflag =(G.fileflags & G_FILE_GAME_MAT); - - if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) { - m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0); - int unitmax=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax); - bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX; - //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl; - } else { - bgl::max_texture_units = 0; - } - } else { - m_blendermat=0; + m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0); } -#else - m_blendermat=0; -#endif//GL_ARB_multitexture - // ---------------------------------- // create the canvas, rasterizer and rendertools m_canvas = new GPG_Canvas(window); @@ -545,7 +520,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) } else { m_rasterizer = new RAS_ListRasterizer(m_canvas); } - else if (useVertexArrays && bgl::QueryVersion(1, 1)) + else if (useVertexArrays && GLEW_VERSION_1_1) m_rasterizer = new RAS_VAOpenGLRasterizer(m_canvas); else m_rasterizer = new RAS_OpenGLRasterizer(m_canvas); @@ -655,6 +630,8 @@ bool GPG_Application::startEngine(void) // sceneconverter->SetAlwaysUseExpandFraming(true); if(m_blendermat) m_sceneconverter->SetMaterials(true); + if(m_blenderglslmat) + m_sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(m_keyboard, m_mouse, diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 024ca1dbf32..17f5add8b19 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -141,6 +141,7 @@ protected: SND_IAudioDevice* m_audiodevice; bool m_blendermat; + bool m_blenderglslmat; }; diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index d5aae181396..13940ac3fc8 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -36,6 +36,7 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) # OpenGL header files +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_BMFONT)/include diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index bd37777031e..f3cce6c7443 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -39,7 +39,8 @@ incs = ['.', '#source/gameengine/Network/LoopBackNetwork', '#source/gameengine/GamePlayer/common', '#source/blender/misc', - '#source/blender/blenloader'] + '#source/blender/blenloader', + '#extern/glew/include'] incs += Split(env['BF_PYTHON_INC']) incs += Split(env['BF_SOLID_INC']) diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp new file mode 100644 index 00000000000..06e012123b1 --- /dev/null +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -0,0 +1,149 @@ + +#include "DNA_customdata_types.h" + +#include "BL_BlenderShader.h" + +#if 0 +#include "GPU_extensions.h" +#include "GPU_material.h" +#endif + +#include "RAS_MeshObject.h" +#include "RAS_IRasterizer.h" + +const bool BL_BlenderShader::Ok()const +{ +#if 0 + return (mGPUMat != 0); +#endif + + return false; +} + +BL_BlenderShader::BL_BlenderShader(struct Material *ma) +: +#if 0 + mGPUMat(0), +#endif + mBound(false) +{ +#if 0 + if(ma) + mGPUMat = GPU_material_from_blender(ma, GPU_PROFILE_DERIVEDMESH); +#endif +} + +BL_BlenderShader::~BL_BlenderShader() +{ +#if 0 + if(mGPUMat) { + GPU_material_unbind(mGPUMat); + mGPUMat = 0; + } +#endif +} + +void BL_BlenderShader::ApplyShader() +{ +} + +void BL_BlenderShader::SetProg(bool enable) +{ +#if 0 + if(mGPUMat) { + if(enable) { + GPU_material_bind(mGPUMat); + mBound = true; + } + else { + GPU_material_unbind(mGPUMat); + mBound = false; + } + } +#endif +} + +int BL_BlenderShader::GetAttribNum() +{ +#if 0 + GPUVertexAttribs attribs; + int i, enabled = 0; + + if(!mGPUMat) + return enabled; + + GPU_material_vertex_attributes(mGPUMat, &attribs); + + for(i = 0; i < attribs.totlayer; i++) + if(attribs.layer[i].glindex+1 > enabled) + enabled= attribs.layer[i].glindex+1; + + if(enabled > BL_MAX_ATTRIB) + enabled = BL_MAX_ATTRIB; + + return enabled; +#endif + + return 0; +} + +void BL_BlenderShader::SetTexCoords(RAS_IRasterizer* ras) +{ +#if 0 + GPUVertexAttribs attribs; + int i, attrib_num; + + if(!mGPUMat) + return; + + if(ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) { + GPU_material_vertex_attributes(mGPUMat, &attribs); + attrib_num = GetAttribNum(); + + ras->SetTexCoordNum(0); + ras->SetAttribNum(attrib_num); + for(i=0; iSetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, i); + + for(i = 0; i < attribs.totlayer; i++) { + if(attribs.layer[i].glindex > attrib_num) + continue; + + if(attribs.layer[i].type == CD_MTFACE) + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex); + else if(attribs.layer[i].type == CD_TANGENT) + ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, attribs.layer[i].glindex); + else if(attribs.layer[i].type == CD_ORCO) + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_ORCO, attribs.layer[i].glindex); + else if(attribs.layer[i].type == CD_NORMAL) + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_NORM, attribs.layer[i].glindex); + } + + ras->EnableTextures(true); + } + else + ras->EnableTextures(false); +#endif +} + +void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) +{ +#if 0 + float obmat[4][4], viewmat[4][4]; + + if(!mGPUMat || !mBound) + return; + + MT_Matrix4x4 model; + model.setValue(ms.m_OpenGLMatrix); + MT_Matrix4x4 view; + rasty->GetViewMatrix(view); + + model.getValue((float*)obmat); + view.getValue((float*)viewmat); + + GPU_material_bind_uniforms(mGPUMat, obmat, viewmat); +#endif +} + +// eof diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h new file mode 100644 index 00000000000..4cab0e644c3 --- /dev/null +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -0,0 +1,44 @@ + +#ifndef __BL_GPUSHADER_H__ +#define __BL_GPUSHADER_H__ + +#if 0 +#include "GPU_material.h" +#endif + +#include "MT_Matrix4x4.h" +#include "MT_Matrix3x3.h" +#include "MT_Tuple2.h" +#include "MT_Tuple3.h" +#include "MT_Tuple4.h" + +struct Material; + +#define BL_MAX_ATTRIB 16 + +/** + * BL_BlenderShader + * Blender GPU shader material + */ +class BL_BlenderShader +{ +private: +#if 0 + GPUMaterial *mGPUMat; +#endif + bool mBound; + +public: + BL_BlenderShader(struct Material *ma); + virtual ~BL_BlenderShader(); + + const bool Ok()const; + void SetProg(bool enable); + + void ApplyShader(); + void SetTexCoords(class RAS_IRasterizer* ras); + int GetAttribNum(); + void Update(const class KX_MeshSlot & ms, class RAS_IRasterizer* rasty); +}; + +#endif//__BL_GPUSHADER_H__ diff --git a/source/gameengine/Ketsji/BL_Material.cpp b/source/gameengine/Ketsji/BL_Material.cpp index 7ed2da590a9..f5312ccd023 100644 --- a/source/gameengine/Ketsji/BL_Material.cpp +++ b/source/gameengine/Ketsji/BL_Material.cpp @@ -34,6 +34,7 @@ BL_Material::BL_Material() rgb[3] = 0; IdMode = 0; ras_mode = 0; + glslmat = 0; tile = 0; matname = "NoMaterial"; matcolor[0] = 0.5f; diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index 8be91316237..ddb6662830a 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -20,7 +20,7 @@ struct EnvMap; although the more you add the slower the search time will be. we will go for three, which should be enough */ -#define MAXTEX 3//match in RAS_TexVert & RAS_OpenGLRasterizer +#define MAXTEX 3 //match in RAS_TexVert & RAS_OpenGLRasterizer // different mapping modes class BL_Mapping @@ -47,6 +47,7 @@ public: int IdMode; unsigned int ras_mode; + bool glslmat; STR_String texname[MAXTEX]; unsigned int flag[MAXTEX]; diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 105a87e767b..15350db6650 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -1,21 +1,5 @@ - -#ifdef WIN32 -#include -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#include -#else -#include -/* #if defined(__sun__) && !defined(__sparc__) -#include -#else -*/ -#include -/* #endif */ -#endif +#include "GL/glew.h" #include #include "BL_Shader.h" @@ -31,7 +15,6 @@ #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" -//using namespace bgl; #define spit(x) std::cout << x << std::endl; #define SORT_UNIFORMS 1 @@ -46,7 +29,7 @@ BL_Uniform::BL_Uniform(int data_size) mDataLen(data_size) { #ifdef SORT_UNIFORMS - MT_assert(mDataLen <= UNIFORM_MAX_LEN); + MT_assert((int)mDataLen <= UNIFORM_MAX_LEN); mData = (void*)MEM_mallocN(mDataLen, "shader-uniform-alloc"); #endif } @@ -63,7 +46,6 @@ BL_Uniform::~BL_Uniform() void BL_Uniform::Apply(class BL_Shader *shader) { -#ifdef GL_ARB_shader_objects #ifdef SORT_UNIFORMS MT_assert(mType > UNI_NONE && mType < UNI_MAX && mData); @@ -74,48 +56,47 @@ void BL_Uniform::Apply(class BL_Shader *shader) { case UNI_FLOAT: { float *f = (float*)mData; - bgl::blUniform1fARB(mLoc,(GLfloat)*f); + glUniform1fARB(mLoc,(GLfloat)*f); }break; case UNI_INT: { int *f = (int*)mData; - bgl::blUniform1iARB(mLoc, (GLint)*f); + glUniform1iARB(mLoc, (GLint)*f); }break; case UNI_FLOAT2: { float *f = (float*)mData; - bgl::blUniform2fvARB(mLoc,1, (GLfloat*)f); + glUniform2fvARB(mLoc,1, (GLfloat*)f); }break; case UNI_FLOAT3: { float *f = (float*)mData; - bgl::blUniform3fvARB(mLoc,1,(GLfloat*)f); + glUniform3fvARB(mLoc,1,(GLfloat*)f); }break; case UNI_FLOAT4: { float *f = (float*)mData; - bgl::blUniform4fvARB(mLoc,1,(GLfloat*)f); + glUniform4fvARB(mLoc,1,(GLfloat*)f); }break; case UNI_INT2: { int *f = (int*)mData; - bgl::blUniform2ivARB(mLoc,1,(GLint*)f); + glUniform2ivARB(mLoc,1,(GLint*)f); }break; case UNI_INT3: { int *f = (int*)mData; - bgl::blUniform3ivARB(mLoc,1,(GLint*)f); + glUniform3ivARB(mLoc,1,(GLint*)f); }break; case UNI_INT4: { int *f = (int*)mData; - bgl::blUniform4ivARB(mLoc,1,(GLint*)f); + glUniform4ivARB(mLoc,1,(GLint*)f); }break; case UNI_MAT4: { float *f = (float*)mData; - bgl::blUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); + glUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); }break; case UNI_MAT3: { float *f = (float*)mData; - bgl::blUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); + glUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); }break; } mDirty = false; #endif -#endif } void BL_Uniform::SetData(int location, int type,bool transpose) @@ -144,17 +125,14 @@ BL_Shader::BL_Shader(PyTypeObject *T) mError(0), mDirty(true) { - // if !RAS_EXT_support._ARB_shader_objects this class will not be used + // if !GLEW_ARB_shader_objects this class will not be used //for (int i=0; i 0 && vertlen < MAX_LOG_LEN){ logInf = (char*)MEM_mallocN(vertlen, "vert-log"); - bgl::blGetInfoLogARB(tmpVert, vertlen, (GLsizei*)&char_len, logInf); + glGetInfoLogARB(tmpVert, vertlen, (GLsizei*)&char_len, logInf); if(char_len >0) { spit("---- Vertex Shader Error ----"); spit(logInf); @@ -308,20 +283,20 @@ bool BL_Shader::LinkProgram() logInf=0; } // check for compile errors - bgl::blGetObjectParameterivARB(tmpVert, GL_OBJECT_COMPILE_STATUS_ARB,(GLint*)&vertstatus); + glGetObjectParameterivARB(tmpVert, GL_OBJECT_COMPILE_STATUS_ARB,(GLint*)&vertstatus); if(!vertstatus) { spit("---- Vertex shader failed to compile ----"); goto programError; } // -- fragment shader ---------------- - tmpFrag = bgl::blCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); - bgl::blShaderSourceARB(tmpFrag, 1,(const char**)&fragProg, 0); - bgl::blCompileShaderARB(tmpFrag); - bgl::blGetObjectParameterivARB(tmpFrag, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &fraglen); + tmpFrag = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); + glShaderSourceARB(tmpFrag, 1,(const char**)&fragProg, 0); + glCompileShaderARB(tmpFrag); + glGetObjectParameterivARB(tmpFrag, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &fraglen); if(fraglen >0 && fraglen < MAX_LOG_LEN){ logInf = (char*)MEM_mallocN(fraglen, "frag-log"); - bgl::blGetInfoLogARB(tmpFrag, fraglen,(GLsizei*) &char_len, logInf); + glGetInfoLogARB(tmpFrag, fraglen,(GLsizei*) &char_len, logInf); if(char_len >0) { spit("---- Fragment Shader Error ----"); spit(logInf); @@ -330,7 +305,7 @@ bool BL_Shader::LinkProgram() logInf=0; } - bgl::blGetObjectParameterivARB(tmpFrag, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*) &fragstatus); + glGetObjectParameterivARB(tmpFrag, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*) &fragstatus); if(!fragstatus){ spit("---- Fragment shader failed to compile ----"); goto programError; @@ -339,17 +314,17 @@ bool BL_Shader::LinkProgram() // -- program ------------------------ // set compiled vert/frag shader & link - tmpProg = bgl::blCreateProgramObjectARB(); - bgl::blAttachObjectARB(tmpProg, tmpVert); - bgl::blAttachObjectARB(tmpProg, tmpFrag); - bgl::blLinkProgramARB(tmpProg); - bgl::blGetObjectParameterivARB(tmpProg, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &proglen); - bgl::blGetObjectParameterivARB(tmpProg, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &progstatus); + tmpProg = glCreateProgramObjectARB(); + glAttachObjectARB(tmpProg, tmpVert); + glAttachObjectARB(tmpProg, tmpFrag); + glLinkProgramARB(tmpProg); + glGetObjectParameterivARB(tmpProg, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &proglen); + glGetObjectParameterivARB(tmpProg, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &progstatus); if(proglen > 0 && proglen < MAX_LOG_LEN) { logInf = (char*)MEM_mallocN(proglen, "prog-log"); - bgl::blGetInfoLogARB(tmpProg, proglen, (GLsizei*)&char_len, logInf); + glGetInfoLogARB(tmpProg, proglen, (GLsizei*)&char_len, logInf); if(char_len >0) { spit("---- GLSL Program ----"); spit(logInf); @@ -365,24 +340,24 @@ bool BL_Shader::LinkProgram() // set mShader = tmpProg; - bgl::blDeleteObjectARB(tmpVert); - bgl::blDeleteObjectARB(tmpFrag); + glDeleteObjectARB(tmpVert); + glDeleteObjectARB(tmpFrag); mOk = 1; mError = 0; return true; programError: if(tmpVert) { - bgl::blDeleteObjectARB(tmpVert); + glDeleteObjectARB(tmpVert); tmpVert=0; } if(tmpFrag) { - bgl::blDeleteObjectARB(tmpFrag); + glDeleteObjectARB(tmpFrag); tmpFrag=0; } if(tmpProg) { - bgl::blDeleteObjectARB(tmpProg); + glDeleteObjectARB(tmpProg); tmpProg=0; } @@ -390,9 +365,6 @@ programError: mUse = 0; mError = 1; return false; -#else - return false; -#endif//GL_ARB_shader_objects } const char *BL_Shader::GetVertPtr() @@ -428,15 +400,13 @@ unsigned int BL_Shader::GetProg() void BL_Shader::SetSampler(int loc, int unit) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blUniform1iARB(loc, unit); + glUniform1iARB(loc, unit); } -#endif } // //void BL_Shader::InitializeSampler(int unit, BL_Texture* texture) @@ -449,31 +419,28 @@ void BL_Shader::SetSampler(int loc, int unit) void BL_Shader::SetProg(bool enable) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { if( mShader != 0 && mOk && enable) { - bgl::blUseProgramObjectARB(mShader); + glUseProgramObjectARB(mShader); } else { - bgl::blUseProgramObjectARB(0); + glUseProgramObjectARB(0); } } -#endif } void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) { -#ifdef GL_ARB_shader_objects if(!Ok() || !mPreDef.size()) return; - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { MT_Matrix4x4 model; @@ -578,210 +545,185 @@ void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) } } } -#endif } int BL_Shader::GetAttribLocation(const STR_String& name) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - return bgl::blGetAttribLocationARB(mShader, name.ReadPtr()); + return glGetAttribLocationARB(mShader, name.ReadPtr()); } -#endif + return -1; } void BL_Shader::BindAttribute(const STR_String& attr, int loc) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blBindAttribLocationARB(mShader, loc, attr.ReadPtr()); + glBindAttribLocationARB(mShader, loc, attr.ReadPtr()); } -#endif } int BL_Shader::GetUniformLocation(const STR_String& name) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { MT_assert(mShader!=0); - int location = bgl::blGetUniformLocationARB(mShader, name.ReadPtr()); + int location = glGetUniformLocationARB(mShader, name.ReadPtr()); if(location == -1) spit("Invalid uniform value: " << name.ReadPtr() << "."); return location; } -#endif + return -1; } void BL_Shader::SetUniform(int uniform, const MT_Tuple2& vec) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[2]; vec.getValue(value); - bgl::blUniform2fvARB(uniform, 1, value); + glUniform2fvARB(uniform, 1, value); } -#endif } void BL_Shader::SetUniform(int uniform, const MT_Tuple3& vec) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[3]; vec.getValue(value); - bgl::blUniform3fvARB(uniform, 1, value); + glUniform3fvARB(uniform, 1, value); } -#endif } void BL_Shader::SetUniform(int uniform, const MT_Tuple4& vec) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[4]; vec.getValue(value); - bgl::blUniform4fvARB(uniform, 1, value); + glUniform4fvARB(uniform, 1, value); } -#endif } void BL_Shader::SetUniform(int uniform, const unsigned int& val) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blUniform1iARB(uniform, val); + glUniform1iARB(uniform, val); } -#endif } void BL_Shader::SetUniform(int uniform, const int val) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blUniform1iARB(uniform, val); + glUniform1iARB(uniform, val); } -#endif } void BL_Shader::SetUniform(int uniform, const float& val) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { - bgl::blUniform1fARB(uniform, val); + glUniform1fARB(uniform, val); } -#endif } void BL_Shader::SetUniform(int uniform, const MT_Matrix4x4& vec, bool transpose) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[16]; vec.getValue(value); - bgl::blUniformMatrix4fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); + glUniformMatrix4fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); } -#endif } void BL_Shader::SetUniform(int uniform, const MT_Matrix3x3& vec, bool transpose) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { float value[9]; value[0] = (float)vec[0][0]; value[1] = (float)vec[1][0]; value[2] = (float)vec[2][0]; value[3] = (float)vec[0][1]; value[4] = (float)vec[1][1]; value[5] = (float)vec[2][1]; value[6] = (float)vec[0][2]; value[7] = (float)vec[1][2]; value[7] = (float)vec[2][2]; - bgl::blUniformMatrix3fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); + glUniformMatrix3fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); } -#endif } void BL_Shader::SetUniform(int uniform, const float* val, int len) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { if(len == 2) - bgl::blUniform2fvARB(uniform, 1,(GLfloat*)val); + glUniform2fvARB(uniform, 1,(GLfloat*)val); else if (len == 3) - bgl::blUniform3fvARB(uniform, 1,(GLfloat*)val); + glUniform3fvARB(uniform, 1,(GLfloat*)val); else if (len == 4) - bgl::blUniform4fvARB(uniform, 1,(GLfloat*)val); + glUniform4fvARB(uniform, 1,(GLfloat*)val); else MT_assert(0); } -#endif } void BL_Shader::SetUniform(int uniform, const int* val, int len) { -#ifdef GL_ARB_shader_objects - if( RAS_EXT_support._ARB_fragment_shader && - RAS_EXT_support._ARB_vertex_shader && - RAS_EXT_support._ARB_shader_objects + if( GLEW_ARB_fragment_shader && + GLEW_ARB_vertex_shader && + GLEW_ARB_shader_objects ) { if(len == 2) - bgl::blUniform2ivARB(uniform, 1, (GLint*)val); + glUniform2ivARB(uniform, 1, (GLint*)val); else if (len == 3) - bgl::blUniform3ivARB(uniform, 1, (GLint*)val); + glUniform3ivARB(uniform, 1, (GLint*)val); else if (len == 4) - bgl::blUniform4ivARB(uniform, 1, (GLint*)val); + glUniform4ivARB(uniform, 1, (GLint*)val); else MT_assert(0); } -#endif } @@ -849,7 +791,6 @@ PyParentObject BL_Shader::Parents[] = { KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProgram)" ) { -#ifdef GL_ARB_shader_objects if(mShader !=0 && mOk ) { // already set... @@ -862,7 +803,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProg vertProg = v; fragProg = f; if( LinkProgram() ) { - bgl::blUseProgramObjectARB( mShader ); + glUseProgramObjectARB( mShader ); mUse = apply!=0; Py_Return; } @@ -871,24 +812,19 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProg mUse = 0; Py_Return; } - return NULL; -#else Py_Return; -#endif } KX_PYMETHODDEF_DOC( BL_Shader, delSource, "delSource( )" ) { -#ifdef GL_ARB_shader_objects ClearUniforms(); - bgl::blUseProgramObjectARB(0); + glUseProgramObjectARB(0); - bgl::blDeleteObjectARB(mShader); + glDeleteObjectARB(mShader); mShader = 0; mOk = 0; mUse = 0; -#endif Py_Return; } @@ -909,7 +845,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" ) KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") { -#ifdef GL_ARB_shader_objects if(mError) { Py_INCREF(Py_None); return Py_None; @@ -919,15 +854,15 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") return NULL; } int stat = 0; - bgl::blValidateProgramARB(mShader); - bgl::blGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB,(GLint*) &stat); + glValidateProgramARB(mShader); + glGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB,(GLint*) &stat); if(stat > 0 && stat < MAX_LOG_LEN) { int char_len=0; char *logInf = (char*)MEM_mallocN(stat, "validate-log"); - bgl::blGetInfoLogARB(mShader, stat,(GLsizei*) &char_len, logInf); + glGetInfoLogARB(mShader, stat,(GLsizei*) &char_len, logInf); if(char_len >0) { spit("---- GLSL Validation ----"); spit(logInf); @@ -935,7 +870,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") MEM_freeN(logInf); logInf=0; } -#endif//GL_ARB_shader_objects Py_Return; } @@ -1412,7 +1346,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3, KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) { -#ifdef GL_ARB_shader_objects if(mError) { Py_INCREF(Py_None); return Py_None; @@ -1424,11 +1357,10 @@ KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) return NULL; } mAttr=SHD_TANGENT; - bgl::blUseProgramObjectARB(mShader); - bgl::blBindAttribLocationARB(mShader, mAttr, "Tangent"); + glUseProgramObjectARB(mShader); + glBindAttribLocationARB(mShader, mAttr, "Tangent"); Py_Return; } -#endif return NULL; } diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 687b1af957d..f24ef4322f0 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -1,19 +1,6 @@ // ------------------------------------ -#ifdef WIN32 -#include -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#include -#else -#include -/* #if defined(__sun__) && !defined(__sparc__) -#include -#else */ -#include -/* #endif */ -#endif + +#include "GL/glew.h" #include #include @@ -30,15 +17,11 @@ #include "BLI_blenlib.h" #include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" -#include "RAS_OpenGLRasterizer/ARB_multitexture.h" #include "RAS_ICanvas.h" #include "RAS_Rect.h" #include "KX_GameObject.h" - -using namespace bgl; - #define spit(x) std::cout << x << std::endl; #include "MEM_guardedalloc.h" @@ -220,9 +203,7 @@ void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap) bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) { -#ifdef GL_ARB_texture_cube_map - - if (!RAS_EXT_support._ARB_texture_cube_map) + if (!GLEW_ARB_texture_cube_map) { spit("cubemaps not supported"); mOk = false; @@ -312,9 +293,8 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - #ifdef GL_VERSION_1_2 - glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); - #endif + if(GLEW_VERSION_1_2) + glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); if (needs_split) my_free_envmapdata(cubemap); @@ -326,13 +306,6 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap) mOk = IsValid(); return mOk; - -#else - - mOk = false; - return mOk; - -#endif//GL_ARB_texture_cube_map } bool BL_Texture::IsValid() @@ -362,58 +335,40 @@ int BL_Texture::GetMaxUnits() { GLint unit=0; -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(RAS_EXT_support._ARB_multitexture) { - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &unit); - return (MAXTEX>=unit?unit:MAXTEX); - } + if(GLEW_ARB_multitexture) { + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &unit); + return (MAXTEX>=unit?unit:MAXTEX); } -#endif + return 0; } void BL_Texture::ActivateFirst() { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(RAS_EXT_support._ARB_multitexture) - bgl::blActiveTextureARB(GL_TEXTURE0_ARB); - } -#endif + if(GLEW_ARB_multitexture) + glActiveTextureARB(GL_TEXTURE0_ARB); } void BL_Texture::ActivateUnit(int unit) { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(RAS_EXT_support._ARB_multitexture) - if(unit <= MAXTEX) - bgl::blActiveTextureARB(GL_TEXTURE0_ARB+unit); - } -#endif + if(GLEW_ARB_multitexture) + if(unit <= MAXTEX) + glActiveTextureARB(GL_TEXTURE0_ARB+unit); } void BL_Texture::DisableUnit() { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(RAS_EXT_support._ARB_multitexture) - bgl::blActiveTextureARB(GL_TEXTURE0_ARB+mUnit); - } -#endif - + if(GLEW_ARB_multitexture) + glActiveTextureARB(GL_TEXTURE0_ARB+mUnit); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); - #ifdef GL_ARB_texture_cube_map - if(RAS_EXT_support._ARB_texture_cube_map && glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB)) + if(GLEW_ARB_texture_cube_map && glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB)) glDisable(GL_TEXTURE_CUBE_MAP_ARB); else - #endif { if (glIsEnabled(GL_TEXTURE_2D)) glDisable(GL_TEXTURE_2D); @@ -429,56 +384,45 @@ void BL_Texture::DisableUnit() void BL_Texture::DisableAllTextures() { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - glDisable(GL_BLEND); - for(int i=0; i #endif -#ifdef WIN32 -#include -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#include -#else -#include -/* #if defined(__sun__) && !defined(__sparc__) -#include -#else -*/ -#include -/* #endif */ -#endif +#include "GL/glew.h" #include "KX_BlenderMaterial.h" #include "BL_Material.h" @@ -37,7 +22,6 @@ #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" #include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" -#include "RAS_OpenGLRasterizer/ARB_multitexture.h" extern "C" { #include "BDR_drawmesh.h" @@ -52,7 +36,6 @@ extern "C" { #include "DNA_meshdata_types.h" #include "BKE_mesh.h" // ------------------------------------ -using namespace bgl; #define spit(x) std::cout << x << std::endl; //static PyObject *gTextureDict = 0; @@ -81,6 +64,7 @@ KX_BlenderMaterial::KX_BlenderMaterial( ), mMaterial(data), mShader(0), + mBlenderShader(0), mScene(scene), mUserDefBlend(0), mModified(0), @@ -100,9 +84,6 @@ KX_BlenderMaterial::KX_BlenderMaterial( int max = BL_Texture::GetMaxUnits(); mMaterial->num_enabled = enabled>=max?max:enabled; - // base class - m_enabled = mMaterial->num_enabled; - // test the sum of the various modes for equality // so we can ether accept or reject this material // as being equal, this is rather important to @@ -144,25 +125,30 @@ void KX_BlenderMaterial::OnConstruction() if (mConstructed) // when material are reused between objects return; - - // for each unique material... - int i; - for(i=0; inum_enabled; i++) { - if( mMaterial->mapping[i].mapping & USEENV ) { - if(!RAS_EXT_support._ARB_texture_cube_map) { - spit("CubeMap textures not supported"); - continue; - } - if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) ) - spit("unable to initialize image("<matname<< ", image will not be available"); - } - else { - if( mMaterial->img[i] ) { - if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) + if(mMaterial->glslmat) { + SetBlenderGLSLShader(); + } + else { + // for each unique material... + int i; + for(i=0; inum_enabled; i++) { + if( mMaterial->mapping[i].mapping & USEENV ) { + if(!GLEW_ARB_texture_cube_map) { + spit("CubeMap textures not supported"); + continue; + } + if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) ) spit("unable to initialize image("<matname<< ", image will not be available"); + mMaterial->matname<< ", image will not be available"); + } + + else { + if( mMaterial->img[i] ) { + if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) + spit("unable to initialize image("<matname<< ", image will not be available"); + } } } } @@ -176,11 +162,17 @@ void KX_BlenderMaterial::OnExit() if( mShader ) { //note, the shader here is allocated, per unique material //and this function is called per face - mShader->SetProg(0); + mShader->SetProg(false); delete mShader; mShader = 0; } + if( mBlenderShader ) { + mBlenderShader->SetProg(false); + delete mBlenderShader; + mBlenderShader = 0; + } + BL_Texture::ActivateFirst(); for(int i=0; inum_enabled; i++) { BL_Texture::ActivateUnit(i); @@ -195,7 +187,7 @@ void KX_BlenderMaterial::OnExit() void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras) { - MT_assert(RAS_EXT_support._ARB_shader_objects && mShader); + MT_assert(GLEW_ARB_shader_objects && mShader); int i; if( !enable || !mShader->Ok() ) { @@ -229,10 +221,23 @@ void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras) } } +void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras) +{ + if( !enable || !mBlenderShader->Ok() ) { + // frame cleanup. + mBlenderShader->SetProg(false); + BL_Texture::DisableAllTextures(); + return; + } + + BL_Texture::DisableAllTextures(); + mBlenderShader->SetProg(true); + mBlenderShader->ApplyShader(); +} void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) { - if(RAS_EXT_support._ARB_shader_objects && mShader) + if(GLEW_ARB_shader_objects && mShader) mShader->SetProg(false); BL_Texture::DisableAllTextures(); @@ -301,12 +306,53 @@ KX_BlenderMaterial::ActivatShaders( cachingInfo = GetCachingInfo(); - if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED ) { + if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) tmp->setShaderData( true, rasty); + else + tmp->setShaderData( false, rasty); + + if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE) + rasty->SetCullFace(false); + else + rasty->SetCullFace(true); + + if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES) + { + if((mMaterial->ras_mode &WIRE)!=0) + rasty->SetCullFace(false); + rasty->SetLines(true); + } + else + rasty->SetLines(false); + } + + ActivatGLMaterials(rasty); + ActivateTexGen(rasty); +} + +void +KX_BlenderMaterial::ActivateBlenderShaders( + RAS_IRasterizer* rasty, + TCachingInfo& cachingInfo)const +{ + KX_BlenderMaterial *tmp = const_cast(this); + + // reset... + if(tmp->mMaterial->IsShared()) + cachingInfo =0; + + if (GetCachingInfo() != cachingInfo) { + if (!cachingInfo) + tmp->setBlenderShaderData(false, rasty); + + cachingInfo = GetCachingInfo(); + + if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) { + tmp->setBlenderShaderData(true, rasty); rasty->EnableTextures(true); } else { - tmp->setShaderData( false, rasty); + tmp->setBlenderShaderData(false, rasty); rasty->EnableTextures(false); } @@ -326,7 +372,7 @@ KX_BlenderMaterial::ActivatShaders( } ActivatGLMaterials(rasty); - ActivateTexGen(rasty); + mBlenderShader->SetTexCoords(rasty); } void @@ -342,14 +388,10 @@ KX_BlenderMaterial::ActivateMat( cachingInfo = GetCachingInfo(); - if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) { + if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) tmp->setTexData( true,rasty ); - rasty->EnableTextures(true); - } - else{ + else tmp->setTexData( false,rasty); - rasty->EnableTextures(false); - } if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE) rasty->SetCullFace(false); @@ -365,11 +407,11 @@ KX_BlenderMaterial::ActivateMat( else rasty->SetLines(false); } + ActivatGLMaterials(rasty); ActivateTexGen(rasty); } - bool KX_BlenderMaterial::Activate( RAS_IRasterizer* rasty, @@ -377,7 +419,7 @@ KX_BlenderMaterial::Activate( )const { bool dopass = false; - if( RAS_EXT_support._ARB_shader_objects && ( mShader && mShader->Ok() ) ) { + if( GLEW_ARB_shader_objects && ( mShader && mShader->Ok() ) ) { if( (mPass++) < mShader->getNumPass() ) { ActivatShaders(rasty, cachingInfo); dopass = true; @@ -390,6 +432,18 @@ KX_BlenderMaterial::Activate( return dopass; } } + else if( GLEW_ARB_shader_objects && ( mBlenderShader && mBlenderShader->Ok() ) ) { + if( (mPass++) == 0 ) { + ActivateBlenderShaders(rasty, cachingInfo); + dopass = true; + return dopass; + } + else { + mPass = 0; + dopass = false; + return dopass; + } + } else { switch (mPass++) { @@ -408,34 +462,39 @@ KX_BlenderMaterial::Activate( void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterizer* rasty) const { - if(mShader && RAS_EXT_support._ARB_shader_objects) + if(mShader && GLEW_ARB_shader_objects) mShader->Update(ms, rasty); + if(mBlenderShader && GLEW_ARB_shader_objects) + mBlenderShader->Update(ms, rasty); } void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const { - rasty->SetSpecularity( - mMaterial->speccolor[0]*mMaterial->spec_f, - mMaterial->speccolor[1]*mMaterial->spec_f, - mMaterial->speccolor[2]*mMaterial->spec_f, - mMaterial->spec_f - ); + if(!mBlenderShader) { + rasty->SetSpecularity( + mMaterial->speccolor[0]*mMaterial->spec_f, + mMaterial->speccolor[1]*mMaterial->spec_f, + mMaterial->speccolor[2]*mMaterial->spec_f, + mMaterial->spec_f + ); + + rasty->SetShinyness( mMaterial->hard ); - rasty->SetShinyness( mMaterial->hard ); + rasty->SetDiffuse( + mMaterial->matcolor[0]*mMaterial->ref+mMaterial->emit, + mMaterial->matcolor[1]*mMaterial->ref+mMaterial->emit, + mMaterial->matcolor[2]*mMaterial->ref+mMaterial->emit, + 1.0f); - rasty->SetDiffuse( - mMaterial->matcolor[0]*mMaterial->ref+mMaterial->emit, - mMaterial->matcolor[1]*mMaterial->ref+mMaterial->emit, - mMaterial->matcolor[2]*mMaterial->ref+mMaterial->emit, - 1.0f); + rasty->SetEmissive( + mMaterial->matcolor[0]*mMaterial->emit, + mMaterial->matcolor[1]*mMaterial->emit, + mMaterial->matcolor[2]*mMaterial->emit, + 1.0 ); - rasty->SetEmissive( - mMaterial->matcolor[0]*mMaterial->emit, - mMaterial->matcolor[1]*mMaterial->emit, - mMaterial->matcolor[2]*mMaterial->emit, - 1.0 ); + rasty->SetAmbient(mMaterial->amb); + } - rasty->SetAmbient(mMaterial->amb); if (mMaterial->material) rasty->SetPolygonOffset(-mMaterial->material->zoffs, 0.0); } @@ -443,34 +502,46 @@ void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const { - if(mShader && RAS_EXT_support._ARB_shader_objects) - if(mShader->GetAttribute() == BL_Shader::SHD_TANGENT) - ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT); + if(ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) { + ras->SetAttribNum(0); + if(mShader && GLEW_ARB_shader_objects) { + if(mShader->GetAttribute() == BL_Shader::SHD_TANGENT) { + ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, 1); + ras->SetAttribNum(2); + } + } - for(int i=0; inum_enabled; i++) { - int mode = mMaterial->mapping[i].mapping; + ras->SetTexCoordNum(mMaterial->num_enabled); - if (mode &USECUSTOMUV) - { - STR_String str = mMaterial->mapping[i].uvCoName; - if (!str.IsEmpty()) - ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_UV2, i); - continue; + for(int i=0; inum_enabled; i++) { + int mode = mMaterial->mapping[i].mapping; + + if (mode &USECUSTOMUV) + { + STR_String str = mMaterial->mapping[i].uvCoName; + if (!str.IsEmpty()) + ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV2, i); + continue; + } + + if( mode &(USEREFL|USEOBJ)) + ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_GEN, i); + else if(mode &USEORCO) + ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_ORCO, i); + else if(mode &USENORM) + ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_NORM, i); + else if(mode &USEUV) + ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV1, i); + else if(mode &USETANG) + ras->SetTexCoord(RAS_IRasterizer::RAS_TEXTANGENT, i); + else + ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_DISABLE, i); } - if( mode &(USEREFL|USEOBJ)) - ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_GEN, i); - else if(mode &USEORCO) - ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_ORCO, i); - else if(mode &USENORM) - ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_NORM, i); - else if(mode &USEUV) - ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_UV1, i); - else if(mode &USETANG) - ras->SetTexCoords(RAS_IRasterizer::RAS_TEXTANGENT, i); - else - ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_DISABLE, i); + ras->EnableTextures(true); } + else + ras->EnableTextures(false); } bool KX_BlenderMaterial::setDefaultBlending() @@ -503,8 +574,7 @@ void KX_BlenderMaterial::setTexMatrixData(int i) glMatrixMode(GL_TEXTURE); glLoadIdentity(); -#ifdef GL_ARB_texture_cube_map - if( RAS_EXT_support._ARB_texture_cube_map && + if( GLEW_ARB_texture_cube_map && mTextures[i].GetTextureType() == GL_TEXTURE_CUBE_MAP_ARB && mMaterial->mapping[i].mapping & USEREFL) { glScalef( @@ -514,7 +584,6 @@ void KX_BlenderMaterial::setTexMatrixData(int i) ); } else -#endif { glScalef( mMaterial->mapping[i].scale[0], @@ -663,28 +732,23 @@ int KX_BlenderMaterial::_setattr(const STR_String& attr, PyObject *pyvalue) KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") { -#ifdef GL_ARB_fragment_shader - if( !RAS_EXT_support._ARB_fragment_shader) { + if( !GLEW_ARB_fragment_shader) { if(!mModified) spit("Fragment shaders not supported"); mModified = true; Py_Return; } -#endif -#ifdef GL_ARB_vertex_shader - if( !RAS_EXT_support._ARB_vertex_shader) { + if( !GLEW_ARB_vertex_shader) { if(!mModified) spit("Vertex shaders not supported"); mModified = true; Py_Return; } -#endif -#ifdef GL_ARB_shader_objects - if(!RAS_EXT_support._ARB_shader_objects) { + if(!GLEW_ARB_shader_objects) { if(!mModified) spit("GLSL not supported"); mModified = true; @@ -723,13 +787,20 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") } PyErr_Format(PyExc_ValueError, "GLSL Error"); return NULL; - -#else - Py_Return; -#endif//GL_ARB_shader_objects } +void KX_BlenderMaterial::SetBlenderGLSLShader(void) +{ + if(!mBlenderShader) + mBlenderShader = new BL_BlenderShader(mMaterial->material); + + if(!mBlenderShader->Ok()) { + delete mBlenderShader; + mBlenderShader = 0; + } +} + KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()") { return PyInt_FromLong( mMaterial->material_index ); diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index b9d48199520..62e96b71937 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -8,6 +8,7 @@ #include "BL_Material.h" #include "BL_Texture.h" #include "BL_Shader.h" +#include "BL_BlenderShader.h" #include "PyObjectPlus.h" @@ -60,6 +61,10 @@ public: TCachingInfo& cachingInfo )const; + void ActivateBlenderShaders( + RAS_IRasterizer* rasty, + TCachingInfo& cachingInfo + )const; MTFace* GetMTFace(void) const; unsigned int* GetMCol(void) const; @@ -86,8 +91,9 @@ public: // pre calculate to avoid pops/lag at startup virtual void OnConstruction( ); private: - BL_Material* mMaterial; - BL_Shader* mShader; + BL_Material* mMaterial; + BL_Shader* mShader; + BL_BlenderShader* mBlenderShader; KX_Scene* mScene; BL_Texture mTextures[MAXTEX]; // texture array bool mUserDefBlend; @@ -95,12 +101,15 @@ private: bool mModified; bool mConstructed; // if false, don't clean on exit + void SetBlenderGLSLShader(); + void ActivatGLMaterials( RAS_IRasterizer* rasty )const; void ActivateTexGen( RAS_IRasterizer *ras ) const; // message centers void setTexData( bool enable,RAS_IRasterizer *ras); + void setBlenderShaderData( bool enable, RAS_IRasterizer *ras); void setShaderData( bool enable, RAS_IRasterizer *ras); bool setDefaultBlending(); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6fde94fec53..5698c106b17 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -81,8 +81,8 @@ KX_GameObject::KX_GameObject( m_bVisible(true), m_pPhysicsController1(NULL), m_pPhysicsEnvironment(NULL), - m_isDeformable(false), - m_pHitObject(NULL) + m_pHitObject(NULL), + m_isDeformable(false) { m_ignore_activity_culling = false; m_pClient_info = new KX_ClientObjectInfo(this, KX_ClientObjectInfo::ACTOR); diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index bba289bf891..f069048cd3d 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -74,6 +74,9 @@ public: virtual void SetMaterials(bool val) =0; virtual bool GetMaterials()=0; + // use blender glsl materials + virtual void SetGLSLMaterials(bool val) =0; + virtual bool GetGLSLMaterials()=0; }; #endif //__KX_ISCENECONVERTER_H diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index a80a7f04e8f..0831788009d 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -28,25 +28,7 @@ * Initialize Python thingies. */ -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef WIN32 -#include -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#include -#else -#include -/* #if defined(__sun__) && !defined(__sparc__) -#include -#else */ -#include -/* #endif */ -#endif +#include "GL/glew.h" #include @@ -310,17 +292,13 @@ static PyObject* gPyGetCurrentScene(PyObject* self, static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) { #define pprint(x) std::cout << x << std::endl; - bgl::BL_EXTInfo ext = bgl::RAS_EXT_support; bool count=0; bool support=0; pprint("Supported Extensions..."); -#ifdef GL_ARB_shader_objects - pprint(" GL_ARB_shader_objects supported? "<< (ext._ARB_shader_objects?"yes.":"no.")); + pprint(" GL_ARB_shader_objects supported? "<< (GLEW_ARB_shader_objects?"yes.":"no.")); count = 1; -#endif -#ifdef GL_ARB_vertex_shader - support= ext._ARB_vertex_shader; + support= GLEW_ARB_vertex_shader; pprint(" GL_ARB_vertex_shader supported? "<< (support?"yes.":"no.")); count = 1; if(support){ @@ -339,9 +317,8 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) pprint(" Max combined texture units." << max); pprint(""); } -#endif -#ifdef GL_ARB_fragment_shader - support=ext._ARB_fragment_shader; + + support=GLEW_ARB_fragment_shader; pprint(" GL_ARB_fragment_shader supported? "<< (support?"yes.":"no.")); count = 1; if(support){ @@ -351,9 +328,8 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) pprint(" Max uniform components." << max); pprint(""); } -#endif -#ifdef GL_ARB_texture_cube_map - support = ext._ARB_texture_cube_map; + + support = GLEW_ARB_texture_cube_map; pprint(" GL_ARB_texture_cube_map supported? "<< (support?"yes.":"no.")); count = 1; if(support){ @@ -363,25 +339,21 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) pprint(" Max cubemap size." << size); pprint(""); } -#endif -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - support = ext._ARB_multitexture; - count = 1; - pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no.")); - if(support){ - pprint(" ----------Details----------"); - int units=0; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units); - pprint(" Max texture units available. " << units); - pprint(""); - } + + support = GLEW_ARB_multitexture; + count = 1; + pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no.")); + if(support){ + pprint(" ----------Details----------"); + int units=0; + glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&units); + pprint(" Max texture units available. " << units); + pprint(""); } -#endif -#ifdef GL_ARB_texture_env_combine - pprint(" GL_ARB_texture_env_combine supported? "<< (ext._ARB_texture_env_combine?"yes.":"no.")); + + pprint(" GL_ARB_texture_env_combine supported? "<< (GLEW_ARB_texture_env_combine?"yes.":"no.")); count = 1; -#endif + if(!count) pprint("No extenstions are used in this build"); diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index e6e541d0931..47a4855b00c 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -36,6 +36,7 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += $(OGL_CPPFLAGS) +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -I../../blender/python CPPFLAGS += -I$(NAN_STRING)/include diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index c7c80345796..fdac5a71071 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -18,7 +18,7 @@ incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common #sourc incs += ' #source/gameengine/Physics/BlOde #source/gameengine/Physics/Dummy' incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/include' incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork' -incs += ' #source/blender/misc #source/blender/blenloader' +incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include' cflags = [] if env['OURPLATFORM'] == 'win32-vc': diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index e604fe0e133..18a755afefd 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -31,6 +31,7 @@ SET(INC ../../../source/kernel/gen_system ../../../intern/string ../../../intern/moto/include + ../../../extern/glew/include ) BLENDERLIB(bf_rasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile index d544056e8ae..1ca3e3b0283 100644 --- a/source/gameengine/Rasterizer/Makefile +++ b/source/gameengine/Rasterizer/Makefile @@ -35,6 +35,7 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 80d6d55df25..291890a8dde 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -46,18 +46,7 @@ #include "RAS_2DFilterManager.h" #include -#ifdef WIN32 -// OpenGL gl.h needs 'windows.h' on windows platforms -#include -#endif //WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#else -#include -#endif - -#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" +#include "GL/glew.h" #ifdef HAVE_CONFIG_H #include @@ -69,7 +58,7 @@ texturewidth(-1), textureheight(-1), canvaswidth(-1), canvasheight(-1), numberoffilters(0),texname(-1) { - isshadersupported = bgl::QueryVersion(2,0); + isshadersupported = GLEW_VERSION_2_0; if(!isshadersupported) { std::cout<<"shaders not supported!" << std::endl; @@ -93,14 +82,14 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) { GLuint program = 0; #if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) - GLuint fShader = bgl::blCreateShaderObjectARB(GL_FRAGMENT_SHADER); + GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); GLint success; - bgl::blShaderSourceARB(fShader, 1, (const char**)&shadersource, NULL); + glShaderSourceARB(fShader, 1, (const char**)&shadersource, NULL); - bgl::blCompileShaderARB(fShader); + glCompileShaderARB(fShader); - bgl::blGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success); + glGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success); if(!success) { /*Shader Comile Error*/ @@ -108,11 +97,11 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) return 0; } - program = bgl::blCreateProgramObjectARB(); - bgl::blAttachObjectARB(program, fShader); + program = glCreateProgramObjectARB(); + glAttachObjectARB(program, fShader); - bgl::blLinkProgramARB(program); - bgl::blGetObjectParameterivARB(program, GL_LINK_STATUS, &success); + glLinkProgramARB(program); + glGetObjectParameterivARB(program, GL_LINK_STATUS, &success); if (!success) { /*Program Link Error*/ @@ -120,8 +109,8 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) return 0; } - bgl::blValidateProgramARB(program); - bgl::blGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success); + glValidateProgramARB(program); + glGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success); if (!success) { /*Program Validation Error*/ @@ -164,30 +153,30 @@ void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) { #if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) GLint uniformLoc; - bgl::blUseProgramObjectARB(shaderprogram); - uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); - bgl::blActiveTextureARB(GL_TEXTURE0); + glUseProgramObjectARB(shaderprogram); + uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); + glActiveTextureARB(GL_TEXTURE0); //glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texname); if (uniformLoc != -1) { - bgl::blUniform1iARB(uniformLoc, 0); + glUniform1iARB(uniformLoc, 0); } - uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_TextureCoordinateOffset"); + uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_TextureCoordinateOffset"); if (uniformLoc != -1) { - bgl::blUniform2fvARB(uniformLoc, 9, textureoffsets); + glUniform2fvARB(uniformLoc, 9, textureoffsets); } - uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureWidth"); + uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureWidth"); if (uniformLoc != -1) { - bgl::blUniform1fARB(uniformLoc,texturewidth); + glUniform1fARB(uniformLoc,texturewidth); } - uniformLoc = bgl::blGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureHeight"); + uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureHeight"); if (uniformLoc != -1) { - bgl::blUniform1fARB(uniformLoc,textureheight); + glUniform1fARB(uniformLoc,textureheight); } #endif } @@ -195,7 +184,7 @@ void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) void RAS_2DFilterManager::EndShaderProgram() { #if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) - bgl::blUseProgramObjectARB(0); + glUseProgramObjectARB(0); #endif } @@ -325,7 +314,7 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str if(mode == RAS_2DFILTER_NOFILTER) { if(m_filters[pass]) - bgl::blDeleteObjectARB(m_filters[pass]); + glDeleteObjectARB(m_filters[pass]); m_enabled[pass] = 0; m_filters[pass] = 0; return; @@ -334,7 +323,7 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str if(mode == RAS_2DFILTER_CUSTOMFILTER) { if(m_filters[pass]) - bgl::blDeleteObjectARB(m_filters[pass]); + glDeleteObjectARB(m_filters[pass]); m_filters[pass] = CreateShaderProgram(text.Ptr()); m_enabled[pass] = 1; return; @@ -343,7 +332,7 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str if(mode>=RAS_2DFILTER_MOTIONBLUR && mode<=RAS_2DFILTER_INVERT) { if(m_filters[pass]) - bgl::blDeleteObjectARB(m_filters[pass]); + glDeleteObjectARB(m_filters[pass]); m_filters[pass] = CreateShaderProgram(mode); m_enabled[pass] = 1; } diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index 6aa9b34962b..0327a3f4763 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -49,12 +49,12 @@ struct RAS_CameraData m_clipstart(clipstart), m_clipend(clipend), m_perspective(perspective), - m_focallength(focallength), m_viewport(viewport), m_viewportleft(viewportleft), m_viewportbottom(viewportbottom), m_viewportright(viewportright), - m_viewporttop(viewporttop) + m_viewporttop(viewporttop), + m_focallength(focallength) { } }; diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index 61860c4c405..bff98abe058 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -56,7 +56,6 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, m_bIsTriangle(bIsTriangle), m_polymatid(m_newpolymatid++), m_flag(0), - m_enabled(0), m_multimode(0) { m_shininess = 35.0; @@ -148,10 +147,5 @@ const unsigned int RAS_IPolyMaterial::GetFlag() const { return m_flag; } -const unsigned int RAS_IPolyMaterial::GetEnabled() const -{ - return m_enabled; -} - unsigned int RAS_IPolyMaterial::m_newpolymatid = 0; diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 3284ddb7ddd..09824f6975c 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -77,7 +77,6 @@ protected: // will move... unsigned int m_flag;//MaterialProps - unsigned int m_enabled;// enabled for this mat int m_multimode; // sum of values public: @@ -141,7 +140,6 @@ public: const STR_String& GetMaterialName() const; const STR_String& GetTextureName() const; const unsigned int GetFlag() const; - const unsigned int GetEnabled() const; /* * PreCalculate texture gen diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 18a7f261c94..dbedc492afa 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -213,17 +213,7 @@ public: bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot)=0; - /** - * @copydoc IndexPrimitives - * IndexPrimitivesEx will renormalize faces if @param vertexarrays[i].getFlag() & TV_CALCFACENORMAL - */ - virtual void IndexPrimitives_Ex( const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor)=0; + /** * IndexPrimitives_3DText will render text into the polygons. * The text to be rendered is from @param rendertools client object's text property. @@ -246,16 +236,6 @@ public: const MT_Vector4& rgbacolor, class KX_ListSlot** slot)=0; - virtual void IndexPrimitivesMulti_Ex( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor)=0; - - virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0; /* This one should become our final version, methinks. */ /** @@ -389,8 +369,11 @@ public: virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)=0; - virtual void SetTexCoords(TexCoGen coords, int unit) = 0; - virtual void SetAttrib(int type) = 0; + + virtual void SetTexCoordNum(int num) = 0; + virtual void SetAttribNum(int num) = 0; + virtual void SetTexCoord(TexCoGen coords, int unit) = 0; + virtual void SetAttrib(TexCoGen coords, int unit) = 0; virtual void GetViewMatrix(MT_Matrix4x4 &mat) const = 0; virtual bool QueryLists(){return false;} diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 96ce220ae4d..1beade7acf7 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -177,7 +177,6 @@ bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_I bool dolights = false; const unsigned int flag = m_material->GetFlag(); - if( flag & RAS_BLENDERMAT) dolights = (flag &RAS_MULTILIGHT)!=0; else @@ -237,11 +236,10 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa rendertools, // needed for textprinting on polys ms.m_bObjectColor, ms.m_RGBAcolor); - } // for using glMultiTexCoord - else if(m_material->GetFlag() & RAS_MULTITEX ) + else if((m_material->GetFlag() & RAS_MULTITEX)) { rasty->IndexPrimitivesMulti( ms.m_mesh->GetVertexCache(m_material), @@ -251,37 +249,10 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa rendertools, ms.m_bObjectColor, ms.m_RGBAcolor, - &ms.m_DisplayList + (ms.m_pDeformer)? 0: &ms.m_DisplayList ); } - // for using glMultiTexCoord on deformer - else if(m_material->GetFlag() & RAS_DEFMULTI ) - { - rasty->IndexPrimitivesMulti_Ex( - ms.m_mesh->GetVertexCache(m_material), - ms.m_mesh->GetIndexCache(m_material), - drawmode, - m_material, - rendertools, - ms.m_bObjectColor, - ms.m_RGBAcolor - ); - } - - // Use the (slower) IndexPrimitives_Ex which can recalc face normals & such - // for deformed objects - eventually should be extended to recalc ALL normals - else if (ms.m_pDeformer){ - rasty->IndexPrimitives_Ex( - ms.m_mesh->GetVertexCache(m_material), - ms.m_mesh->GetIndexCache(m_material), - drawmode, - m_material, - rendertools, // needed for textprinting on polys - ms.m_bObjectColor, - ms.m_RGBAcolor - ); - } // Use the normal IndexPrimitives else { @@ -293,7 +264,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa rendertools, // needed for textprinting on polys ms.m_bObjectColor, ms.m_RGBAcolor, - &ms.m_DisplayList + (ms.m_pDeformer)? 0: &ms.m_DisplayList ); } @@ -316,14 +287,14 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans, //rasty->SetMaterial(*m_material); - int drawmode; for (T_MeshSlotList::const_iterator it = m_meshSlots.begin(); ! (it == m_meshSlots.end()); ++it) { rendertools->SetClientObject((*it).m_clientObj); - while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode)) + while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode)) { RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode); + } } // to reset the eventual GL_CW mode rendertools->SetClientObject(NULL); diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index e4b654343e7..db74110ceea 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -256,27 +256,30 @@ int RAS_MeshObject::FindOrAddVertex(int vtxarray, const MT_Vector4& tangent, const unsigned int rgbacolor, const MT_Vector3& normal, + bool flat, RAS_IPolyMaterial* mat, int orgindex) { KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray]; - RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, 0); + RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, flat? TV_CALCFACENORMAL: 0); + #define KX_FIND_SHARED_VERTICES #ifdef KX_FIND_SHARED_VERTICES - - for (std::vector::iterator it = m_xyz_index_to_vertex_index_mapping[orgindex].begin(); - it != m_xyz_index_to_vertex_index_mapping[orgindex].end(); - it++) - { - if ((*it).m_arrayindex1 == ao->m_index1 && - (*it).m_array == vtxarray && - *(*it).m_matid == *mat && - (*ao->m_VertexArrayCache1[vtxarray])[(*it).m_index].closeTo(&newvert) - ) + if(!flat) { + for (std::vector::iterator it = m_xyz_index_to_vertex_index_mapping[orgindex].begin(); + it != m_xyz_index_to_vertex_index_mapping[orgindex].end(); + it++) { - return (*it).m_index; + if ((*it).m_arrayindex1 == ao->m_index1 && + (*it).m_array == vtxarray && + *(*it).m_matid == *mat && + (*ao->m_VertexArrayCache1[vtxarray])[(*it).m_index].closeTo(&newvert) + ) + { + return (*it).m_index; + } } } #endif // KX_FIND_SHARED_VERTICES diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index 89c472cd0d4..d8e7a3391aa 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -238,6 +238,7 @@ public: const MT_Vector4& tangent, const unsigned int rgbacolor, const MT_Vector3& normal, + bool flat, RAS_IPolyMaterial* mat, int orgindex ); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h deleted file mode 100644 index a2f27ce3361..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef __ARB_MULTITEXTURE_H__ -#define __ARB_MULTITEXTURE_H__ - -/* -*/ - -/* ---------------------------------------------------------------------------- - GL_ARB_multitexture ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_multitexture - #define GL_TEXTURE0_ARB 0x84C0 - #define GL_TEXTURE1_ARB 0x84C1 - #define GL_TEXTURE2_ARB 0x84C2 - #define GL_TEXTURE3_ARB 0x84C3 - #define GL_TEXTURE4_ARB 0x84C4 - #define GL_TEXTURE5_ARB 0x84C5 - #define GL_TEXTURE6_ARB 0x84C6 - #define GL_TEXTURE7_ARB 0x84C7 - #define GL_TEXTURE8_ARB 0x84C8 - #define GL_TEXTURE9_ARB 0x84C9 - #define GL_TEXTURE10_ARB 0x84CA - #define GL_ACTIVE_TEXTURE_ARB 0x84E0 - #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 - #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - - -/* ---------------------------------------------------------------------------- - GL_ARB_texture_env_combine ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_texture_env_combine - #define GL_COMBINE_ARB 0x8570 - #define GL_COMBINE_RGB_ARB 0x8571 - #define GL_COMBINE_ALPHA_ARB 0x8572 - #define GL_SOURCE0_RGB_ARB 0x8580 - #define GL_SOURCE1_RGB_ARB 0x8581 - #define GL_SOURCE2_RGB_ARB 0x8582 - #define GL_SOURCE0_ALPHA_ARB 0x8588 - #define GL_SOURCE1_ALPHA_ARB 0x8589 - #define GL_SOURCE2_ALPHA_ARB 0x858A - #define GL_OPERAND0_RGB_ARB 0x8590 - #define GL_OPERAND1_RGB_ARB 0x8591 - #define GL_OPERAND2_RGB_ARB 0x8592 - #define GL_OPERAND0_ALPHA_ARB 0x8598 - #define GL_OPERAND1_ALPHA_ARB 0x8599 - #define GL_OPERAND2_ALPHA_ARB 0x859A - #define GL_RGB_SCALE_ARB 0x8573 - #define GL_ADD_SIGNED_ARB 0x8574 - #define GL_INTERPOLATE_ARB 0x8575 - #define GL_SUBTRACT_ARB 0x84E7 - #define GL_CONSTANT_ARB 0x8576 - #define GL_PRIMARY_COLOR_ARB 0x8577 - #define GL_PREVIOUS_ARB 0x8578 -#endif - -/* ---------------------------------------------------------------------------- - GL_ARB_texture_cube_map ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_texture_cube_map - #define GL_NORMAL_MAP_ARB 0x8511 - #define GL_REFLECTION_MAP_ARB 0x8512 - #define GL_TEXTURE_CUBE_MAP_ARB 0x8513 - #define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 - #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 - #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 - #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 - #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 - #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 - #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A - #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B - #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -/* ---------------------------------------------------------------------------- - GL_ARB_shader_objects ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_shader_objects - #define GL_PROGRAM_OBJECT_ARB 0x8B40 - #define GL_SHADER_OBJECT_ARB 0x8B48 - #define GL_OBJECT_TYPE_ARB 0x8B4E - #define GL_OBJECT_SUBTYPE_ARB 0x8B4F - #define GL_FLOAT_VEC2_ARB 0x8B50 - #define GL_FLOAT_VEC3_ARB 0x8B51 - #define GL_FLOAT_VEC4_ARB 0x8B52 - #define GL_INT_VEC2_ARB 0x8B53 - #define GL_INT_VEC3_ARB 0x8B54 - #define GL_INT_VEC4_ARB 0x8B55 - #define GL_BOOL_ARB 0x8B56 - #define GL_BOOL_VEC2_ARB 0x8B57 - #define GL_BOOL_VEC3_ARB 0x8B58 - #define GL_BOOL_VEC4_ARB 0x8B59 - #define GL_FLOAT_MAT2_ARB 0x8B5A - #define GL_FLOAT_MAT3_ARB 0x8B5B - #define GL_FLOAT_MAT4_ARB 0x8B5C - #define GL_SAMPLER_1D_ARB 0x8B5D - #define GL_SAMPLER_2D_ARB 0x8B5E - #define GL_SAMPLER_3D_ARB 0x8B5F - #define GL_SAMPLER_CUBE_ARB 0x8B60 - #define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 - #define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 - #define GL_SAMPLER_2D_RECT_ARB 0x8B63 - #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 - #define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 - #define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 - #define GL_OBJECT_LINK_STATUS_ARB 0x8B82 - #define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 - #define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 - #define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 - #define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 - #define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 - #define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -/* ---------------------------------------------------------------------------- - GL_ARB_vertex_shader ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_vertex_shader - #define GL_VERTEX_SHADER_ARB 0x8B31 - #define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A - #define GL_MAX_VARYING_FLOATS_ARB 0x8B4B - #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C - #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D - #define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 - #define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - - -/* ---------------------------------------------------------------------------- - GL_ARB_fragment_shader ----------------------------------------------------------------------------- */ -#ifdef GL_ARB_fragment_shader - #define GL_FRAGMENT_SHADER_ARB 0x8B30 - #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 - #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - - -/* ---------------------------------------------------------------------------- - GL_ARB_depth_texture ----------------------------------------------------------------------------- */ -#ifndef GL_ARB_depth_texture - #define GL_DEPTH_COMPONENT16_ARB 0x81A5 - #define GL_DEPTH_COMPONENT24_ARB 0x81A6 - #define GL_DEPTH_COMPONENT32_ARB 0x81A7 - #define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A - #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - - -#endif//__ARB_MULTITEXTURE_H__ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index 5153834899b..2a6d64ecc73 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -31,6 +31,7 @@ SET(INC ../../../../intern/string ../../../../intern/moto/include ../../../../source/gameengine/Rasterizer + ../../../../extern/glew/include ) BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h deleted file mode 100644 index 5a9d8f32a87..00000000000 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_VERSION_1_2 -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile index 1a88c51dc25..f01978b8eb1 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile @@ -36,6 +36,7 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) +CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp index 81a7ccb7a5d..d241bd1ee31 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp @@ -25,665 +25,43 @@ * * ***** END GPL LICENSE BLOCK ***** */ -/* - The extension manager's job is to link at runtime OpenGL extension - functions. - Since the various platform have different methods of finding a fn - pointer, this file attempts to encapsulate all that, so it gets a - little messy. Hopefully we can -*/ -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef WIN32 -# include - -# include - -#elif defined(__APPLE__) -# include -# define GL_GLEXT_LEGACY 1 -# include - -#else /* UNIX */ -# include -# include - -# include -#endif - -#include #include -#include -#include -#include - -#include "STR_String.h" #include "RAS_GLExtensionManager.h" -/* ----------------------------------------------------------------------------- - - Platform specific functions section. - - Required Functions: - static void bglInitEntryPoints (void) -- Loads the GL library - static void bglDeallocEntryPoints (void) -- Frees the GL library - static void *bglGetProcAddress(const GLubyte* entry) -- Finds the address of - the GL function entry - -*/ -#if defined(BGL_NO_EXTENSIONS) -static void bglInitEntryPoints (void) {} -static void bglDeallocEntryPoints (void) {} - -static void *bglGetProcAddress(const GLubyte* entry) -{ - /* No Extensions! */ - return NULL; -} -#elif defined(__APPLE__) -/* http://developer.apple.com/qa/qa2001/qa1188.html */ -CFBundleRef gBundleRefOpenGL = NULL; - -// ------------------------- - -static OSStatus bglInitEntryPoints (void) -{ - OSStatus err = noErr; - const Str255 frameworkName = "\pOpenGL.framework"; - FSRefParam fileRefParam; - FSRef fileRef; - CFURLRef bundleURLOpenGL; - - memset(&fileRefParam, 0, sizeof(fileRefParam)); - memset(&fileRef, 0, sizeof(fileRef)); - - fileRefParam.ioNamePtr = frameworkName; - fileRefParam.newRef = &fileRef; - - // Frameworks directory/folder - err = FindFolder (kSystemDomain, kFrameworksFolderType, false, - &fileRefParam.ioVRefNum, (SInt32*)&fileRefParam.ioDirID); - if (noErr != err) { - DebugStr ((unsigned char *)"\pCould not find frameworks folder"); - return err; - } - err = PBMakeFSRefSync (&fileRefParam); // make FSRef for folder - if (noErr != err) { - DebugStr ((unsigned char *)"\pCould make FSref to frameworks folder"); - return err; - } - // create URL to folder - bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault, - &fileRef); - if (!bundleURLOpenGL) { - DebugStr ((unsigned char *)"\pCould create OpenGL Framework bundle URL"); - return paramErr; - } - // create ref to GL's bundle - gBundleRefOpenGL = CFBundleCreate (kCFAllocatorDefault, - bundleURLOpenGL); - if (!gBundleRefOpenGL) { - DebugStr ((unsigned char *)"\pCould not create OpenGL Framework bundle"); - return paramErr; - } - CFRelease (bundleURLOpenGL); // release created bundle - // if the code was successfully loaded, look for our function. - if (!CFBundleLoadExecutable (gBundleRefOpenGL)) { - DebugStr ((unsigned char *)"\pCould not load MachO executable"); - return paramErr; - } - return err; -} - -// ------------------------- - -static void bglDeallocEntryPoints (void) -{ - if (gBundleRefOpenGL != NULL) { - // unload the bundle's code. - CFBundleUnloadExecutable (gBundleRefOpenGL); - CFRelease (gBundleRefOpenGL); - gBundleRefOpenGL = NULL; - } -} - -// ------------------------- - -/*unused*/ -static void * bglGetProcAddress (const GLubyte * pszProc) -{ - if (!gBundleRefOpenGL) - return NULL; - - return CFBundleGetFunctionPointerForName (gBundleRefOpenGL, - CFStringCreateWithCStringNoCopy (NULL, - (const char *) pszProc, CFStringGetSystemEncoding (), NULL)); -} -#elif defined(GLX_ARB_get_proc_address) -/* Not all glx.h define PFNGLXGETPROCADDRESSARBPROC ! - We define our own if needed. */ -#ifdef HAVE_PFNGLXGETPROCADDRESSARBPROC -#define PFNBGLXGETPROCADDRESSARBPROC PFNGLXGETPROCADDRESSARBPROC -#else -typedef void (*(*PFNBGLXGETPROCADDRESSARBPROC)(const GLubyte *procname))(); -#endif - -void *_getProcAddress(const GLubyte *procName) { return NULL; } -PFNBGLXGETPROCADDRESSARBPROC bglGetProcAddress; - - -//weird bug related to combination of pthreads,libGL and dlopen -//cannot call dlclose in such environment, causes crashes -//so try to keep a global handle to libGL -void* libGL = 0; - -static void bglInitEntryPoints (void) -{ - Display *dpy = glXGetCurrentDisplay(); - std::vector Xextensions = STR_String(glXQueryExtensionsString(dpy, DefaultScreen(dpy))).Explode(' '); - if (std::find(Xextensions.begin(), Xextensions.end(), "GLX_ARB_get_proc_address") != Xextensions.end()) - { - if (!libGL) - { - libGL = dlopen("libGL.so", RTLD_LAZY|RTLD_GLOBAL); - if (libGL) - bglGetProcAddress = (PFNBGLXGETPROCADDRESSARBPROC) (dlsym(libGL, "glXGetProcAddressARB")); - else - std::cout << "Error: " << dlerror() << std::endl; - - // dlclose(libGL); - if (!bglGetProcAddress) - bglGetProcAddress = (PFNBGLXGETPROCADDRESSARBPROC) _getProcAddress; - - // -- - if(!bglGetProcAddress) - std::cout << "Error: unable to find _getProcAddress in libGL" << std::endl; - } - } -} - -static void bglDeallocEntryPoints (void) {} - -#elif defined(WIN32) -static void bglInitEntryPoints (void) {} -static void bglDeallocEntryPoints (void) {} - -#define bglGetProcAddress(entry) wglGetProcAddress((LPCSTR) entry) - -#else /* Unknown Platform - disable extensions */ -static void bglInitEntryPoints (void) {} -static void bglDeallocEntryPoints (void) {} - -static void *bglGetProcAddress(const GLubyte* entry) -{ - /* No Extensions! */ - return NULL; -} - -#endif /* End Platform Specific */ - -/* ----------------------------------------------------------------------------- - - GL Extension Manager. -*/ - /* Bit array of available extensions */ -static std::bitset enabled_extensions; -static std::vector extensions; -static int m_debug; - -static void LinkExtensions(); - -static void EnableExtension(bgl::ExtensionName name) -{ - unsigned int num = (unsigned int) name; - if (num < bgl::NUM_EXTENSIONS) - enabled_extensions.set(num); -} - - -static bool QueryExtension(STR_String extension_name) -{ - return std::find(extensions.begin(), extensions.end(), extension_name) != extensions.end(); -} - namespace bgl { - -void InitExtensions(int debug) -{ - m_debug = debug; - bglInitEntryPoints (); //init bundle - EnableExtension(_BGL_TEST); - LinkExtensions(); - bglDeallocEntryPoints(); -} - -bool QueryExtension(ExtensionName name) -{ - unsigned int num = (unsigned int) name; - if (num < NUM_EXTENSIONS) - return enabled_extensions[num]; - - return false; -} - -bool QueryVersion(int major, int minor) -{ - static int gl_major = 0; - static int gl_minor = 0; - - if (gl_major == 0) + void InitExtensions(bool debug) { - const char *gl_version_str = (const char *) glGetString(GL_VERSION); - if (!gl_version_str) - return false; - STR_String gl_version = STR_String(gl_version_str); - int i = gl_version.Find('.'); - gl_major = gl_version.Left(i).ToInt(); - gl_minor = gl_version.Mid(i+1, gl_version.FindOneOf(". ", i+1) - i - 1).ToInt(); - - static bool doQueryVersion = m_debug; - if (doQueryVersion) - { - doQueryVersion = false; - std::cout << "GL_VERSION: " << gl_major << "." << gl_minor << " (" << gl_version << ")" << std::endl; - } - } - - if (gl_major > major) - return true; - - if (gl_major == major && gl_minor >= minor) - return true; + static bool firsttime = true; - return false; -} - - -/******************************************************************************* -1. Extension function entry points go here - -Need to #ifdef (compile time test for extension) -Add null functions if appropriate - -Some extensions have been incorporated into the core GL, eg Multitexture was -added in GL v1.1. If Blender calls one of these functions before they are -linked, it will crash. Even worse, if Blender *indirectly* calls one of these -functions, (ie the GL implementation calls them itself) Blender will crash. - -We fix this by adding them to the bgl namespace - the functions are now -private to the gameengine. Code can transparently use extensions by adding: - -using namespace bgl; - -to their source. Cunning like a weasel. - - ******************************************************************************/ - -#if defined(PFNGLPNTRIANGLESIATIPROC) -PFNGLPNTRIANGLESIATIPROC glPNTrianglesiATI; -PFNGLPNTRIANGLESFATIPROC glPNTrianglesfATI; -#endif - -BL_EXTInfo RAS_EXT_support; - -#ifdef GL_ARB_multitexture -int max_texture_units = 2; -PFNGLACTIVETEXTUREARBPROC blActiveTextureARB; -PFNGLCLIENTACTIVETEXTUREARBPROC blClientActiveTextureARB; -PFNGLMULTITEXCOORD1DARBPROC blMultiTexCoord1dARB; -PFNGLMULTITEXCOORD1DVARBPROC blMultiTexCoord1dvARB; -PFNGLMULTITEXCOORD1FARBPROC blMultiTexCoord1fARB; -PFNGLMULTITEXCOORD1FVARBPROC blMultiTexCoord1fvARB; -PFNGLMULTITEXCOORD1IARBPROC blMultiTexCoord1iARB; -PFNGLMULTITEXCOORD1IVARBPROC blMultiTexCoord1ivARB; -PFNGLMULTITEXCOORD1SARBPROC blMultiTexCoord1sARB; -PFNGLMULTITEXCOORD1SVARBPROC blMultiTexCoord1svARB; -PFNGLMULTITEXCOORD2DARBPROC blMultiTexCoord2dARB; -PFNGLMULTITEXCOORD2DVARBPROC blMultiTexCoord2dvARB; -PFNGLMULTITEXCOORD2FARBPROC blMultiTexCoord2fARB; -PFNGLMULTITEXCOORD2FVARBPROC blMultiTexCoord2fvARB; -PFNGLMULTITEXCOORD2IARBPROC blMultiTexCoord2iARB; -PFNGLMULTITEXCOORD2IVARBPROC blMultiTexCoord2ivARB; -PFNGLMULTITEXCOORD2SARBPROC blMultiTexCoord2sARB; -PFNGLMULTITEXCOORD2SVARBPROC blMultiTexCoord2svARB; -PFNGLMULTITEXCOORD3DARBPROC blMultiTexCoord3dARB; -PFNGLMULTITEXCOORD3DVARBPROC blMultiTexCoord3dvARB; -PFNGLMULTITEXCOORD3FARBPROC blMultiTexCoord3fARB; -PFNGLMULTITEXCOORD3FVARBPROC blMultiTexCoord3fvARB; -PFNGLMULTITEXCOORD3IARBPROC blMultiTexCoord3iARB; -PFNGLMULTITEXCOORD3IVARBPROC blMultiTexCoord3ivARB; -PFNGLMULTITEXCOORD3SARBPROC blMultiTexCoord3sARB; -PFNGLMULTITEXCOORD3SVARBPROC blMultiTexCoord3svARB; -PFNGLMULTITEXCOORD4DARBPROC blMultiTexCoord4dARB; -PFNGLMULTITEXCOORD4DVARBPROC blMultiTexCoord4dvARB; -PFNGLMULTITEXCOORD4FARBPROC blMultiTexCoord4fARB; -PFNGLMULTITEXCOORD4FVARBPROC blMultiTexCoord4fvARB; -PFNGLMULTITEXCOORD4IARBPROC blMultiTexCoord4iARB; -PFNGLMULTITEXCOORD4IVARBPROC blMultiTexCoord4ivARB; -PFNGLMULTITEXCOORD4SARBPROC blMultiTexCoord4sARB; -PFNGLMULTITEXCOORD4SVARBPROC blMultiTexCoord4svARB; -#endif - -#ifdef GL_ARB_shader_objects - PFNGLDELETEOBJECTARBPROC blDeleteObjectARB; - PFNGLGETHANDLEARBPROC blGetHandleARB; - PFNGLDETACHOBJECTARBPROC blDetachObjectARB; - PFNGLCREATESHADEROBJECTARBPROC blCreateShaderObjectARB; - PFNGLSHADERSOURCEARBPROC blShaderSourceARB; - PFNGLCOMPILESHADERARBPROC blCompileShaderARB; - PFNGLCREATEPROGRAMOBJECTARBPROC blCreateProgramObjectARB; - PFNGLATTACHOBJECTARBPROC blAttachObjectARB; - PFNGLLINKPROGRAMARBPROC blLinkProgramARB; - PFNGLUSEPROGRAMOBJECTARBPROC blUseProgramObjectARB; - PFNGLVALIDATEPROGRAMARBPROC blValidateProgramARB; - PFNGLUNIFORM1FARBPROC blUniform1fARB; - PFNGLUNIFORM2FARBPROC blUniform2fARB; - PFNGLUNIFORM3FARBPROC blUniform3fARB; - PFNGLUNIFORM4FARBPROC blUniform4fARB; - PFNGLUNIFORM1IARBPROC blUniform1iARB; - PFNGLUNIFORM2IARBPROC blUniform2iARB; - PFNGLUNIFORM3IARBPROC blUniform3iARB; - PFNGLUNIFORM4IARBPROC blUniform4iARB; - PFNGLUNIFORM1FVARBPROC blUniform1fvARB; - PFNGLUNIFORM2FVARBPROC blUniform2fvARB; - PFNGLUNIFORM3FVARBPROC blUniform3fvARB; - PFNGLUNIFORM4FVARBPROC blUniform4fvARB; - PFNGLUNIFORM1IVARBPROC blUniform1ivARB; - PFNGLUNIFORM2IVARBPROC blUniform2ivARB; - PFNGLUNIFORM3IVARBPROC blUniform3ivARB; - PFNGLUNIFORM4IVARBPROC blUniform4ivARB; - PFNGLUNIFORMMATRIX2FVARBPROC blUniformMatrix2fvARB; - PFNGLUNIFORMMATRIX3FVARBPROC blUniformMatrix3fvARB; - PFNGLUNIFORMMATRIX4FVARBPROC blUniformMatrix4fvARB; - PFNGLGETOBJECTPARAMETERFVARBPROC blGetObjectParameterfvARB; - PFNGLGETOBJECTPARAMETERIVARBPROC blGetObjectParameterivARB; - PFNGLGETINFOLOGARBPROC blGetInfoLogARB; - PFNGLGETATTACHEDOBJECTSARBPROC blGetAttachedObjectsARB; - PFNGLGETUNIFORMLOCATIONARBPROC blGetUniformLocationARB; - PFNGLGETACTIVEUNIFORMARBPROC blGetActiveUniformARB; - PFNGLGETUNIFORMFVARBPROC blGetUniformfvARB; - PFNGLGETUNIFORMIVARBPROC blGetUniformivARB; - PFNGLGETSHADERSOURCEARBPROC blGetShaderSourceARB; -#endif - -#ifdef GL_ARB_vertex_shader -PFNGLBINDATTRIBLOCATIONARBPROC blBindAttribLocationARB; -PFNGLGETACTIVEATTRIBARBPROC blGetActiveAttribARB; -PFNGLGETATTRIBLOCATIONARBPROC blGetAttribLocationARB; -#endif - -#ifdef GL_ARB_vertex_program - PFNGLVERTEXATTRIB1FARBPROC blVertexAttrib1fARB; - PFNGLVERTEXATTRIB1FVARBPROC blVertexAttrib1fvARB; - PFNGLVERTEXATTRIB2FARBPROC blVertexAttrib2fARB; - PFNGLVERTEXATTRIB2FVARBPROC blVertexAttrib2fvARB; - PFNGLVERTEXATTRIB3FARBPROC blVertexAttrib3fARB; - PFNGLVERTEXATTRIB3FVARBPROC blVertexAttrib3fvARB; - PFNGLVERTEXATTRIB4FARBPROC blVertexAttrib4fARB; - PFNGLVERTEXATTRIB4FVARBPROC blVertexAttrib4fvARB; - PFNGLGETPROGRAMSTRINGARBPROC blGetProgramStringARB; - PFNGLGETVERTEXATTRIBDVARBPROC blGetVertexAttribdvARB; - PFNGLGETVERTEXATTRIBFVARBPROC blGetVertexAttribfvARB; - PFNGLGETVERTEXATTRIBIVARBPROC blGetVertexAttribivARB; -#endif - - /* -#ifdef GL_EXT_compiled_vertex_array - PFNGLLOCKARRAYSEXTPROC blLockArraysEXT; - PFNGLUNLOCKARRAYSEXTPROC blUnlockArraysEXT; -#endif -*/ - -} // namespace bgl - -using namespace bgl; -/******************************************************************************* -2. Query extension functions here - -Need to #ifdef (compile time test for extension) -Use QueryExtension("GL_EXT_name") to test at runtime. -Use bglGetProcAddress to find entry point -Use EnableExtension(_GL_EXT_...) to allow Blender to use the extension. - - ******************************************************************************/ -static void LinkExtensions() -{ - static bool doDebugMessages = m_debug; - extensions = STR_String((const char *) glGetString(GL_EXTENSIONS)).Explode(' '); - RAS_EXT_support = BL_EXTInfo(); - -#if defined(PFNGLPNTRIANGLESIATIPROC) - if (QueryExtension("GL_ATI_pn_triangles")) - { - glPNTrianglesiATI = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glPNTrianglesiATI")); - glPNTrianglesfATI = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glPNTrianglesfATI")); - if (glPNTrianglesiATI && glPNTrianglesfATI) { - EnableExtension(_GL_ATI_pn_triangles); - if (doDebugMessages) - std::cout << "Enabled GL_ATI_pn_triangles" << std::endl; - } else { - std::cout << "ERROR: GL_ATI_pn_triangles implementation is broken!" << std::endl; - } - } -#endif - -#ifdef GL_ARB_texture_env_combine - if (QueryExtension("GL_ARB_texture_env_combine")) - { - EnableExtension(_GL_ARB_texture_env_combine); - RAS_EXT_support._ARB_texture_env_combine = 1; - if (doDebugMessages) - { - std::cout << "Detected GL_ARB_texture_env_combine" << std::endl; - } - } -#endif - -#ifdef GL_ARB_texture_cube_map - if (QueryExtension("GL_ARB_texture_cube_map")) - { - EnableExtension(_GL_ARB_texture_cube_map); - RAS_EXT_support._ARB_texture_cube_map = 1; - if (doDebugMessages) - std::cout << "Detected GL_ARB_texture_cube_map" << std::endl; - } -#endif - -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if (QueryExtension("GL_ARB_multitexture")) { - bgl::blActiveTextureARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glActiveTextureARB")); - bgl::blClientActiveTextureARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glClientActiveTextureARB")); - bgl::blMultiTexCoord1dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dARB")); - bgl::blMultiTexCoord1dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dvARB")); - bgl::blMultiTexCoord1fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fARB")); - bgl::blMultiTexCoord1fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fvARB")); - bgl::blMultiTexCoord1iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1iARB")); - bgl::blMultiTexCoord1ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1ivARB")); - bgl::blMultiTexCoord1sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1sARB")); - bgl::blMultiTexCoord1svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1svARB")); - bgl::blMultiTexCoord2dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dARB")); - bgl::blMultiTexCoord2dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dvARB")); - bgl::blMultiTexCoord2fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fARB")); - bgl::blMultiTexCoord2fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fvARB")); - bgl::blMultiTexCoord2iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2iARB")); - bgl::blMultiTexCoord2ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2ivARB")); - bgl::blMultiTexCoord2sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2sARB")); - bgl::blMultiTexCoord2svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2svARB")); - bgl::blMultiTexCoord3dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dARB")); - bgl::blMultiTexCoord3dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dvARB")); - bgl::blMultiTexCoord3fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fARB")); - bgl::blMultiTexCoord3fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fvARB")); - bgl::blMultiTexCoord3iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3iARB")); - bgl::blMultiTexCoord3ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3ivARB")); - bgl::blMultiTexCoord3sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3sARB")); - bgl::blMultiTexCoord3svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3svARB")); - bgl::blMultiTexCoord4dARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dARB")); - bgl::blMultiTexCoord4dvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dvARB")); - bgl::blMultiTexCoord4fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fARB")); - bgl::blMultiTexCoord4fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fvARB")); - bgl::blMultiTexCoord4iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4iARB")); - bgl::blMultiTexCoord4ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4ivARB")); - bgl::blMultiTexCoord4sARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4sARB")); - bgl::blMultiTexCoord4svARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4svARB")); - if (bgl::blActiveTextureARB && bgl::blClientActiveTextureARB && bgl::blMultiTexCoord1dARB && bgl::blMultiTexCoord1dvARB && bgl::blMultiTexCoord1fARB && bgl::blMultiTexCoord1fvARB && bgl::blMultiTexCoord1iARB && bgl::blMultiTexCoord1ivARB && bgl::blMultiTexCoord1sARB && bgl::blMultiTexCoord1svARB && bgl::blMultiTexCoord2dARB && bgl::blMultiTexCoord2dvARB && bgl::blMultiTexCoord2fARB && bgl::blMultiTexCoord2fvARB && bgl::blMultiTexCoord2iARB && bgl::blMultiTexCoord2ivARB && bgl::blMultiTexCoord2sARB && bgl::blMultiTexCoord2svARB && bgl::blMultiTexCoord3dARB && bgl::blMultiTexCoord3dvARB && bgl::blMultiTexCoord3fARB && bgl::blMultiTexCoord3fvARB && bgl::blMultiTexCoord3iARB && bgl::blMultiTexCoord3ivARB && bgl::blMultiTexCoord3sARB && bgl::blMultiTexCoord3svARB && bgl::blMultiTexCoord4dARB && bgl::blMultiTexCoord4dvARB && bgl::blMultiTexCoord4fARB && bgl::blMultiTexCoord4fvARB && bgl::blMultiTexCoord4iARB && bgl::blMultiTexCoord4ivARB && bgl::blMultiTexCoord4sARB && bgl::blMultiTexCoord4svARB) { - EnableExtension(_GL_ARB_multitexture); - RAS_EXT_support._ARB_multitexture = 1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_multitexture" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_multitexture implementation is broken!" << std::endl; + if(firsttime) { + firsttime = false; + + if(debug) { + if(GLEW_ATI_pn_triangles) + std::cout << "Enabled GL_ATI_pn_triangles" << std::endl; + if(GLEW_ARB_texture_env_combine) + std::cout << "Detected GL_ARB_texture_env_combine" << std::endl; + if(GLEW_ARB_texture_cube_map) + std::cout << "Detected GL_ARB_texture_cube_map" << std::endl; + if(GLEW_ARB_multitexture) + std::cout << "Detected GL_ARB_multitexture" << std::endl; + if(GLEW_ARB_shader_objects) + std::cout << "Detected GL_ARB_shader_objects" << std::endl; + if(GLEW_ARB_vertex_shader) + std::cout << "Detected GL_ARB_vertex_shader" << std::endl; + if(GLEW_ARB_fragment_shader) + std::cout << "Detected GL_ARB_fragment_shader" << std::endl; + if(GLEW_ARB_vertex_program) + std::cout << "Detected GL_ARB_vertex_program" << std::endl; + if(GLEW_ARB_depth_texture) + std::cout << "Detected GL_ARB_depth_texture" << std::endl; + if(GLEW_EXT_separate_specular_color) + std::cout << "Detected GL_EXT_separate_specular_color" << std::endl; } } } -#endif - -#if GL_ARB_shader_objects - if (QueryExtension("GL_ARB_shader_objects")) - { - bgl::blDeleteObjectARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glDeleteObjectARB")); - bgl::blGetHandleARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetHandleARB")); - bgl::blDetachObjectARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glDetachObjectARB")); - bgl::blCreateShaderObjectARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glCreateShaderObjectARB")); - bgl::blShaderSourceARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glShaderSourceARB")); - bgl::blCompileShaderARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glCompileShaderARB")); - bgl::blCreateProgramObjectARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glCreateProgramObjectARB")); - bgl::blAttachObjectARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glAttachObjectARB")); - bgl::blLinkProgramARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glLinkProgramARB")); - bgl::blUseProgramObjectARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUseProgramObjectARB")); - bgl::blValidateProgramARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glValidateProgramARB")); - bgl::blUniform1fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform1fARB")); - bgl::blUniform2fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform2fARB")); - bgl::blUniform3fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform3fARB")); - bgl::blUniform4fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform4fARB")); - bgl::blUniform1iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform1iARB")); - bgl::blUniform2iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform2iARB")); - bgl::blUniform3iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform3iARB")); - bgl::blUniform4iARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform4iARB")); - bgl::blUniform1fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform1fvARB")); - bgl::blUniform2fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform2fvARB")); - bgl::blUniform3fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform3fvARB")); - bgl::blUniform4fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform4fvARB")); - bgl::blUniform1ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform1ivARB")); - bgl::blUniform2ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform2ivARB")); - bgl::blUniform3ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform3ivARB")); - bgl::blUniform4ivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniform4ivARB")); - bgl::blUniformMatrix2fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniformMatrix2fvARB")); - bgl::blUniformMatrix3fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniformMatrix3fvARB")); - bgl::blUniformMatrix4fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUniformMatrix4fvARB")); - bgl::blGetObjectParameterfvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetObjectParameterfvARB")); - bgl::blGetObjectParameterivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetObjectParameterivARB")); - bgl::blGetInfoLogARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetInfoLogARB")); - bgl::blGetAttachedObjectsARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetAttachedObjectsARB")); - bgl::blGetUniformLocationARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetUniformLocationARB")); - bgl::blGetActiveUniformARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetActiveUniformARB")); - bgl::blGetUniformfvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetUniformfvARB")); - bgl::blGetUniformivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetUniformivARB")); - bgl::blGetShaderSourceARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetShaderSourceARB")); - if (bgl::blDeleteObjectARB && bgl::blGetHandleARB && bgl::blDetachObjectARB && bgl::blCreateShaderObjectARB && bgl::blShaderSourceARB && bgl::blCompileShaderARB && bgl::blCreateProgramObjectARB && bgl::blAttachObjectARB && bgl::blLinkProgramARB && bgl::blUseProgramObjectARB && bgl::blValidateProgramARB && bgl::blUniform1fARB && bgl::blUniform2fARB && bgl::blUniform3fARB && bgl::blUniform4fARB && bgl::blUniform1iARB && bgl::blUniform2iARB && bgl::blUniform3iARB && bgl::blUniform4iARB && bgl::blUniform1fvARB && bgl::blUniform2fvARB && bgl::blUniform3fvARB && bgl::blUniform4fvARB && bgl::blUniform1ivARB && bgl::blUniform2ivARB && bgl::blUniform3ivARB && bgl::blUniform4ivARB && bgl::blUniformMatrix2fvARB && bgl::blUniformMatrix3fvARB && bgl::blUniformMatrix4fvARB && bgl::blGetObjectParameterfvARB && bgl::blGetObjectParameterivARB && bgl::blGetInfoLogARB && bgl::blGetAttachedObjectsARB && bgl::blGetUniformLocationARB && bgl::blGetActiveUniformARB && bgl::blGetUniformfvARB && bgl::blGetUniformivARB && bgl::blGetShaderSourceARB) { - EnableExtension(_GL_ARB_shader_objects); - RAS_EXT_support._ARB_shader_objects =1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_shader_objects" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_shader_objects implementation is broken!" << std::endl; - } - } -#endif - -#if GL_ARB_vertex_shader - if (QueryExtension("GL_ARB_vertex_shader")) - { - bgl::blBindAttribLocationARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glBindAttribLocationARB")); - bgl::blGetActiveAttribARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetActiveAttribARB")); - bgl::blGetAttribLocationARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetAttribLocationARB")); - if (bgl::blBindAttribLocationARB && bgl::blGetActiveAttribARB && bgl::blGetAttribLocationARB) { - EnableExtension(_GL_ARB_vertex_shader); - RAS_EXT_support._ARB_vertex_shader = 1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_vertex_shader" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_vertex_shader implementation is broken!" << std::endl; - } - } -#endif - -#ifdef GL_ARB_fragment_shader - if (QueryExtension("GL_ARB_fragment_shader")) - { - EnableExtension(_GL_ARB_fragment_shader); - RAS_EXT_support._ARB_fragment_shader = 1; - if (doDebugMessages) - std::cout << "Detected GL_ARB_fragment_shader" << std::endl; - } -#endif - -#if defined(GL_ARB_vertex_program) - if (QueryExtension("GL_ARB_vertex_program")) - { - bgl::blVertexAttrib1fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glVertexAttrib1fARB")); - bgl::blVertexAttrib1fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glVertexAttrib1fvARB")); - bgl::blVertexAttrib2fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glVertexAttrib2fARB")); - bgl::blVertexAttrib2fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glVertexAttrib2fvARB")); - bgl::blVertexAttrib3fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glVertexAttrib3fARB")); - bgl::blVertexAttrib3fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glVertexAttrib3fvARB")); - bgl::blVertexAttrib4fARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glVertexAttrib4fARB")); - bgl::blVertexAttrib4fvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glVertexAttrib4fvARB")); - bgl::blGetVertexAttribdvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetVertexAttribdvARB")); - bgl::blGetVertexAttribfvARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetVertexAttribfvARB")); - bgl::blGetVertexAttribivARB = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glGetVertexAttribivARB")); - if (bgl::blVertexAttrib1fARB && bgl::blVertexAttrib1fvARB && bgl::blVertexAttrib2fARB && bgl::blVertexAttrib2fvARB && bgl::blVertexAttrib3fARB && bgl::blVertexAttrib3fvARB && bgl::blGetVertexAttribdvARB) { - EnableExtension(_GL_ARB_vertex_program); - RAS_EXT_support._ARB_vertex_program = 1; - if (doDebugMessages) - std::cout << "Enabled GL_ARB_vertex_program" << std::endl; - } else { - std::cout << "ERROR: GL_ARB_vertex_program implementation is broken!" << std::endl; - } - } -#endif - - -#ifdef GL_ARB_depth_texture - if (QueryExtension("GL_ARB_depth_texture")) - { - EnableExtension(_GL_ARB_depth_texture); - RAS_EXT_support._ARB_depth_texture = 1; - if (doDebugMessages) - { - std::cout << "Detected GL_ARB_depth_texture" << std::endl; - } - } -#endif -/* -#ifdef GL_EXT_compiled_vertex_array - if (QueryExtension("GL_EXT_compiled_vertex_array")) - { - blLockArraysEXT = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glLockArraysEXT")); - blUnlockArraysEXT = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUnlockArraysEXT")); - if (blLockArraysEXT && blUnlockArraysEXT) { - EnableExtension(_GL_EXT_compiled_vertex_array); - RAS_EXT_support._EXT_compiled_vertex_array = 1; - if (doDebugMessages) - std::cout << "Enabled GL_EXT_compiled_vertex_array" << std::endl; - } else { - std::cout << "ERROR: GL_EXT_compiled_vertex_array implementation is broken!" << std::endl; - } - } -#endif -*/ - if (QueryExtension("GL_EXT_separate_specular_color")) - { - EnableExtension(_GL_EXT_separate_specular_color); - if (doDebugMessages) - std::cout << "Detected GL_EXT_separate_specular_color" << std::endl; - } - - doDebugMessages = false; -} +} // namespace bgl diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h index 3e24ee204a1..2265becbdad 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h @@ -29,513 +29,14 @@ #ifndef __RAS_GLEXTENSIONMANAGER_H__ #define __RAS_GLEXTENSIONMANAGER_H__ +#include "GL/glew.h" -#ifdef WIN32 -# include -# include +/* Note: this used to have a lot more code, but now extension handling + * is done by GLEW, so it does mostly debug stuff */ -#elif defined(__APPLE__) -# define GL_GLEXT_LEGACY 1 -# include -# include - -#else /* UNIX */ -# define __glext_h_ -# include -# include -# undef GL_ARB_multitexture // (ubuntu) -# undef __glext_h_ -#endif - -#ifdef WITH_GLEXT -#ifdef WIN32 -# include -#elif defined(__APPLE__) -# include "mac_compat_glext.h" -# include -#else -# include -#endif -#endif - -#ifdef __sgi -# undef GL_ARB_vertex_program -#endif - -#include "EXT_separate_specular_color.h" -#include "ARB_multitexture.h" namespace bgl { - /** - * This is a list of all registered OpenGL extensions. - * It is available from: - * http://oss.sgi.com/projects/ogl-sample/registry/ - */ - typedef enum { - /* ARB Extensions */ - _GL_ARB_imaging, - _GL_ARB_multitexture , - _GLX_ARB_get_proc_address , - _GL_ARB_transpose_matrix , - _WGL_ARB_buffer_region , - _GL_ARB_multisample , - _GL_ARB_texture_env_add , - _GL_ARB_texture_cube_map , - _WGL_ARB_extensions_string , - _WGL_ARB_pixel_format , - _WGL_ARB_make_current_read , - _WGL_ARB_pbuffer , - _GL_ARB_texture_compression , - _GL_ARB_texture_border_clamp , - _GL_ARB_point_parameters , - _GL_ARB_vertex_blend , - _GL_ARB_matrix_palette , - _GL_ARB_texture_env_combine , - _GL_ARB_texture_env_crossbar , - _GL_ARB_texture_env_dot3 , - _WGL_ARB_render_texture , - _GL_ARB_texture_mirrored_repeat , - _GL_ARB_depth_texture , - _GL_ARB_shadow , - _GL_ARB_shadow_ambient , - _GL_ARB_window_pos , - _GL_ARB_vertex_program , - _GL_ARB_fragment_program , - _GL_ARB_vertex_buffer_object , - _GL_ARB_occlusion_query , - _GL_ARB_shader_objects , - _GL_ARB_vertex_shader , - _GL_ARB_fragment_shader , - _GL_ARB_shading_language_100 , - _GL_ARB_texture_non_power_of_two , - _GL_ARB_point_sprite , - _GL_ARB_fragment_program_shadow , - - /* Non ARB Extensions */ - _GL_EXT_abgr , - _GL_EXT_blend_color , - _GL_EXT_polygon_offset , - _GL_EXT_texture , - _GL_EXT_texture3D , - _GL_SGIS_texture_filter4 , - _GL_EXT_subtexture , - _GL_EXT_copy_texture , - _GL_EXT_histogram , - _GL_EXT_convolution , - _GL_SGI_color_matrix , - _GL_SGI_color_table , - _GL_SGIS_pixel_texture , - _GL_SGIS_texture4D , - _GL_SGI_texture_color_table , - _GL_EXT_cmyka , - _GL_EXT_texture_object , - _GL_SGIS_detail_texture , - _GL_SGIS_sharpen_texture , - _GL_EXT_packed_pixels , - _GL_SGIS_texture_lod , - _GL_SGIS_multisample , - _GL_EXT_rescale_normal , - _GLX_EXT_visual_info , - _GL_EXT_vertex_array , - _GL_EXT_misc_attribute , - _GL_SGIS_generate_mipmap , - _GL_SGIX_clipmap , - _GL_SGIX_shadow , - _GL_SGIS_texture_edge_clamp , - _GL_SGIS_texture_border_clamp , - _GL_EXT_blend_minmax , - _GL_EXT_blend_subtract , - _GL_EXT_blend_logic_op , - _GLX_SGI_swap_control , - _GLX_SGI_video_sync , - _GLX_SGI_make_current_read , - _GLX_SGIX_video_source , - _GLX_EXT_visual_rating , - _GL_SGIX_interlace , - _GLX_EXT_import_context , - _GLX_SGIX_fbconfig , - _GLX_SGIX_pbuffer , - _GL_SGIS_texture_select , - _GL_SGIX_sprite , - _GL_SGIX_texture_multi_buffer , - _GL_EXT_point_parameters , - _GL_SGIX_instruments , - _GL_SGIX_texture_scale_bias , - _GL_SGIX_framezoom , - _GL_SGIX_tag_sample_buffer , - _GL_SGIX_reference_plane , - _GL_SGIX_flush_raster , - _GLX_SGI_cushion , - _GL_SGIX_depth_texture , - _GL_SGIS_fog_function , - _GL_SGIX_fog_offset , - _GL_HP_image_transform , - _GL_HP_convolution_border_modes , - _GL_SGIX_texture_add_env , - _GL_EXT_color_subtable , - _GLU_EXT_object_space_tess , - _GL_PGI_vertex_hints , - _GL_PGI_misc_hints , - _GL_EXT_paletted_texture , - _GL_EXT_clip_volume_hint , - _GL_SGIX_list_priority , - _GL_SGIX_ir_instrument1 , - _GLX_SGIX_video_resize , - _GL_SGIX_texture_lod_bias , - _GLU_SGI_filter4_parameters , - _GLX_SGIX_dm_buffer , - _GL_SGIX_shadow_ambient , - _GLX_SGIX_swap_group , - _GLX_SGIX_swap_barrier , - _GL_EXT_index_texture , - _GL_EXT_index_material , - _GL_EXT_index_func , - _GL_EXT_index_array_formats , - _GL_EXT_compiled_vertex_array , - _GL_EXT_cull_vertex , - _GLU_EXT_nurbs_tessellator , - _GL_SGIX_ycrcb , - _GL_EXT_fragment_lighting , - _GL_IBM_rasterpos_clip , - _GL_HP_texture_lighting , - _GL_EXT_draw_range_elements , - _GL_WIN_phong_shading , - _GL_WIN_specular_fog , - _GLX_SGIS_color_range , - _GL_EXT_light_texture , - _GL_SGIX_blend_alpha_minmax , - _GL_EXT_scene_marker , - _GL_SGIX_pixel_texture_bits , - _GL_EXT_bgra , - _GL_SGIX_async , - _GL_SGIX_async_pixel , - _GL_SGIX_async_histogram , - _GL_INTEL_texture_scissor , - _GL_INTEL_parallel_arrays , - _GL_HP_occlusion_test , - _GL_EXT_pixel_transform , - _GL_EXT_pixel_transform_color_table , - _GL_EXT_shared_texture_palette , - _GLX_SGIS_blended_overlay , - _GL_EXT_separate_specular_color , - _GL_EXT_secondary_color , - _GL_EXT_texture_env , - _GL_EXT_texture_perturb_normal , - _GL_EXT_multi_draw_arrays , - _GL_EXT_fog_coord , - _GL_REND_screen_coordinates , - _GL_EXT_coordinate_frame , - _GL_EXT_texture_env_combine , - _GL_APPLE_specular_vector , - _GL_SGIX_pixel_texture , - _GL_APPLE_transform_hint , - _GL_SUNX_constant_data , - _GL_SUN_global_alpha , - _GL_SUN_triangle_list , - _GL_SUN_vertex , - _WGL_EXT_display_color_table , - _WGL_EXT_extensions_string , - _WGL_EXT_make_current_read , - _WGL_EXT_pixel_format , - _WGL_EXT_pbuffer , - _WGL_EXT_swap_control , - _GL_EXT_blend_func_separate , - _GL_INGR_color_clamp , - _GL_INGR_interlace_read , - _GL_EXT_stencil_wrap , - _WGL_EXT_depth_float , - _GL_EXT_422_pixels , - _GL_NV_texgen_reflection , - _GL_SGIX_texture_range , - _GL_SUN_convolution_border_modes , - _GLX_SUN_get_transparent_index , - _GL_EXT_texture_env_add , - _GL_EXT_texture_lod_bias , - _GL_EXT_texture_filter_anisotropic , - _GL_EXT_vertex_weighting , - _GL_NV_light_max_exponent , - _GL_NV_vertex_array_range , - _GL_NV_register_combiners , - _GL_NV_fog_distance , - _GL_NV_texgen_emboss , - _GL_NV_blend_square , - _GL_NV_texture_env_combine4 , - _GL_MESA_resize_buffers , - _GL_MESA_window_pos , - _GL_EXT_texture_compression_s3tc , - _GL_IBM_cull_vertex , - _GL_IBM_multimode_draw_arrays , - _GL_IBM_vertex_array_lists , - _GL_3DFX_texture_compression_FXT1 , - _GL_3DFX_multisample , - _GL_3DFX_tbuffer , - _WGL_EXT_multisample , - _GL_SGIX_vertex_preclip , - _GL_SGIX_resample , - _GL_SGIS_texture_color_mask , - _GLX_MESA_copy_sub_buffer , - _GLX_MESA_pixmap_colormap , - _GLX_MESA_release_buffers , - _GLX_MESA_set_3dfx_mode , - _GL_EXT_texture_env_dot3 , - _GL_ATI_texture_mirror_once , - _GL_NV_fence , - _GL_IBM_static_data , - _GL_IBM_texture_mirrored_repeat , - _GL_NV_evaluators , - _GL_NV_packed_depth_stencil , - _GL_NV_register_combiners2 , - _GL_NV_texture_compression_vtc , - _GL_NV_texture_rectangle , - _GL_NV_texture_shader , - _GL_NV_texture_shader2 , - _GL_NV_vertex_array_range2 , - _GL_NV_vertex_program , - _GLX_SGIX_visual_select_group , - _GL_SGIX_texture_coordinate_clamp , - _GLX_OML_swap_method , - _GLX_OML_sync_control , - _GL_OML_interlace , - _GL_OML_subsample , - _GL_OML_resample , - _WGL_OML_sync_control , - _GL_NV_copy_depth_to_color , - _GL_ATI_envmap_bumpmap , - _GL_ATI_fragment_shader , - _GL_ATI_pn_triangles , - _GL_ATI_vertex_array_object , - _GL_EXT_vertex_shader , - _GL_ATI_vertex_streams , - _WGL_I3D_digital_video_control , - _WGL_I3D_gamma , - _WGL_I3D_genlock , - _WGL_I3D_image_buffer , - _WGL_I3D_swap_frame_lock , - _WGL_I3D_swap_frame_usage , - _GL_ATI_element_array , - _GL_SUN_mesh_array , - _GL_SUN_slice_accum , - _GL_NV_multisample_filter_hint , - _GL_NV_depth_clamp , - _GL_NV_occlusion_query , - _GL_NV_point_sprite , - _WGL_NV_render_depth_texture , - _WGL_NV_render_texture_rectangle , - _GL_NV_texture_shader3 , - _GL_NV_vertex_program1_1 , - _GL_EXT_shadow_funcs , - _GL_EXT_stencil_two_side , - _GL_ATI_text_fragment_shader , - _GL_APPLE_client_storage , - _GL_APPLE_element_array , - _GL_APPLE_fence , - _GL_APPLE_vertex_array_object , - _GL_APPLE_vertex_array_range , - _GL_APPLE_ycbcr_422 , - _GL_S3_s3tc , - _GL_ATI_draw_buffers , - _WGL_ATI_pixel_format_float , - _GL_ATI_texture_env_combine3 , - _GL_ATI_texture_float , - _GL_NV_float_buffer , - _GL_NV_fragment_program , - _GL_NV_half_float , - _GL_NV_pixel_data_range , - _GL_NV_primitive_restart , - _GL_NV_texture_expand_normal , - _GL_NV_vertex_program2 , - _GL_ATI_map_object_buffer , - _GL_ATI_separate_stencil , - _GL_ATI_vertex_attrib_array_object , - _GL_OES_byte_coordinates , - _GL_OES_fixed_point , - _GL_OES_single_precision , - _GL_OES_compressed_paletted_texture , - _GL_OES_read_format , - _GL_OES_query_matrix , - _GL_EXT_depth_bounds_test , - _GL_EXT_texture_mirror_clamp , - _GL_EXT_blend_equation_separate , - _GL_MESA_pack_invert , - _GL_MESA_ycbcr_texture, - - /* Finished */ - _BGL_TEST, - NUM_EXTENSIONS - } ExtensionName; - - /** - * Checks at runtime whether OpenGL supports the named extension. - * Returns true if OpenGL supports the given extension. - * - * @param name The extension name to check. - */ - bool QueryExtension(ExtensionName name); - /** - * Checks the OpenGL version. - * Returns true if OpenGL is at least the given version. - * - * @param major The major version required - * @param minor The minor version required - */ - bool QueryVersion(int major, int minor); - /** - * This will dynamically link all runtime supported extensions into - * the binary. - * - * @param debug Enable debug printing. This will print debugging info - * when extensions are loaded. - */ - void InitExtensions(int debug); - -#if defined(PFNGLPNTRIANGLESIATIPROC) -extern PFNGLPNTRIANGLESIATIPROC blPNTrianglesiATI; -extern PFNGLPNTRIANGLESFATIPROC blPNTrianglesfATI; -#endif - - -// quick runtime checks -typedef struct BL_EXTInfo -{ - BL_EXTInfo(): - _ARB_multitexture(0), - _ARB_texture_env_combine(0), - _EXT_blend_color(0), - _ARB_texture_cube_map(0), - _ARB_shader_objects(0), - _ARB_vertex_shader(0), - _ARB_fragment_shader(0), - _EXT_texture3D(0), - _ARB_vertex_program(0), - _ARB_depth_texture(0), - _EXT_compiled_vertex_array(0) - { - // - } - bool _ARB_multitexture; - bool _ARB_texture_env_combine; - bool _EXT_blend_color; - bool _ARB_texture_cube_map; - bool _ARB_shader_objects; - bool _ARB_vertex_shader; - bool _ARB_fragment_shader; - bool _EXT_texture3D; - bool _ARB_vertex_program; - bool _ARB_depth_texture; - bool _EXT_compiled_vertex_array; -}BL_EXTInfo; - -extern BL_EXTInfo RAS_EXT_support; - -#ifdef GL_ARB_multitexture // defined in glext.h now... -extern int max_texture_units; -extern PFNGLACTIVETEXTUREARBPROC blActiveTextureARB; -extern PFNGLCLIENTACTIVETEXTUREARBPROC blClientActiveTextureARB; -extern PFNGLMULTITEXCOORD1DARBPROC blMultiTexCoord1dARB; -extern PFNGLMULTITEXCOORD1DVARBPROC blMultiTexCoord1dvARB; -extern PFNGLMULTITEXCOORD1FARBPROC blMultiTexCoord1fARB; -extern PFNGLMULTITEXCOORD1FVARBPROC blMultiTexCoord1fvARB; -extern PFNGLMULTITEXCOORD1IARBPROC blMultiTexCoord1iARB; -extern PFNGLMULTITEXCOORD1IVARBPROC blMultiTexCoord1ivARB; -extern PFNGLMULTITEXCOORD1SARBPROC blMultiTexCoord1sARB; -extern PFNGLMULTITEXCOORD1SVARBPROC blMultiTexCoord1svARB; -extern PFNGLMULTITEXCOORD2DARBPROC blMultiTexCoord2dARB; -extern PFNGLMULTITEXCOORD2DVARBPROC blMultiTexCoord2dvARB; -extern PFNGLMULTITEXCOORD2FARBPROC blMultiTexCoord2fARB; -extern PFNGLMULTITEXCOORD2FVARBPROC blMultiTexCoord2fvARB; -extern PFNGLMULTITEXCOORD2IARBPROC blMultiTexCoord2iARB; -extern PFNGLMULTITEXCOORD2IVARBPROC blMultiTexCoord2ivARB; -extern PFNGLMULTITEXCOORD2SARBPROC blMultiTexCoord2sARB; -extern PFNGLMULTITEXCOORD2SVARBPROC blMultiTexCoord2svARB; -extern PFNGLMULTITEXCOORD3DARBPROC blMultiTexCoord3dARB; -extern PFNGLMULTITEXCOORD3DVARBPROC blMultiTexCoord3dvARB; -extern PFNGLMULTITEXCOORD3FARBPROC blMultiTexCoord3fARB; -extern PFNGLMULTITEXCOORD3FVARBPROC blMultiTexCoord3fvARB; -extern PFNGLMULTITEXCOORD3IARBPROC blMultiTexCoord3iARB; -extern PFNGLMULTITEXCOORD3IVARBPROC blMultiTexCoord3ivARB; -extern PFNGLMULTITEXCOORD3SARBPROC blMultiTexCoord3sARB; -extern PFNGLMULTITEXCOORD3SVARBPROC blMultiTexCoord3svARB; -extern PFNGLMULTITEXCOORD4DARBPROC blMultiTexCoord4dARB; -extern PFNGLMULTITEXCOORD4DVARBPROC blMultiTexCoord4dvARB; -extern PFNGLMULTITEXCOORD4FARBPROC blMultiTexCoord4fARB; -extern PFNGLMULTITEXCOORD4FVARBPROC blMultiTexCoord4fvARB; -extern PFNGLMULTITEXCOORD4IARBPROC blMultiTexCoord4iARB; -extern PFNGLMULTITEXCOORD4IVARBPROC blMultiTexCoord4ivARB; -extern PFNGLMULTITEXCOORD4SARBPROC blMultiTexCoord4sARB; -extern PFNGLMULTITEXCOORD4SVARBPROC blMultiTexCoord4svARB; -#endif - - -#ifdef GL_ARB_shader_objects -extern PFNGLDELETEOBJECTARBPROC blDeleteObjectARB; -extern PFNGLGETHANDLEARBPROC blGetHandleARB; -extern PFNGLDETACHOBJECTARBPROC blDetachObjectARB; -extern PFNGLCREATESHADEROBJECTARBPROC blCreateShaderObjectARB; -extern PFNGLSHADERSOURCEARBPROC blShaderSourceARB; -extern PFNGLCOMPILESHADERARBPROC blCompileShaderARB; -extern PFNGLCREATEPROGRAMOBJECTARBPROC blCreateProgramObjectARB; -extern PFNGLATTACHOBJECTARBPROC blAttachObjectARB; -extern PFNGLLINKPROGRAMARBPROC blLinkProgramARB; -extern PFNGLUSEPROGRAMOBJECTARBPROC blUseProgramObjectARB; -extern PFNGLVALIDATEPROGRAMARBPROC blValidateProgramARB; -extern PFNGLUNIFORM1FARBPROC blUniform1fARB; -extern PFNGLUNIFORM2FARBPROC blUniform2fARB; -extern PFNGLUNIFORM3FARBPROC blUniform3fARB; -extern PFNGLUNIFORM4FARBPROC blUniform4fARB; -extern PFNGLUNIFORM1IARBPROC blUniform1iARB; -extern PFNGLUNIFORM2IARBPROC blUniform2iARB; -extern PFNGLUNIFORM3IARBPROC blUniform3iARB; -extern PFNGLUNIFORM4IARBPROC blUniform4iARB; -extern PFNGLUNIFORM1FVARBPROC blUniform1fvARB; -extern PFNGLUNIFORM2FVARBPROC blUniform2fvARB; -extern PFNGLUNIFORM3FVARBPROC blUniform3fvARB; -extern PFNGLUNIFORM4FVARBPROC blUniform4fvARB; -extern PFNGLUNIFORM1IVARBPROC blUniform1ivARB; -extern PFNGLUNIFORM2IVARBPROC blUniform2ivARB; -extern PFNGLUNIFORM3IVARBPROC blUniform3ivARB; -extern PFNGLUNIFORM4IVARBPROC blUniform4ivARB; -extern PFNGLUNIFORMMATRIX2FVARBPROC blUniformMatrix2fvARB; -extern PFNGLUNIFORMMATRIX3FVARBPROC blUniformMatrix3fvARB; -extern PFNGLUNIFORMMATRIX4FVARBPROC blUniformMatrix4fvARB; -extern PFNGLGETOBJECTPARAMETERFVARBPROC blGetObjectParameterfvARB; -extern PFNGLGETOBJECTPARAMETERIVARBPROC blGetObjectParameterivARB; -extern PFNGLGETINFOLOGARBPROC blGetInfoLogARB; -extern PFNGLGETATTACHEDOBJECTSARBPROC blGetAttachedObjectsARB; -extern PFNGLGETUNIFORMLOCATIONARBPROC blGetUniformLocationARB; -extern PFNGLGETACTIVEUNIFORMARBPROC blGetActiveUniformARB; -extern PFNGLGETUNIFORMFVARBPROC blGetUniformfvARB; -extern PFNGLGETUNIFORMIVARBPROC blGetUniformivARB; -extern PFNGLGETSHADERSOURCEARBPROC blGetShaderSourceARB; -#endif - -#ifdef GL_ARB_vertex_shader -extern PFNGLBINDATTRIBLOCATIONARBPROC blBindAttribLocationARB; -extern PFNGLGETACTIVEATTRIBARBPROC blGetActiveAttribARB; -extern PFNGLGETATTRIBLOCATIONARBPROC blGetAttribLocationARB; -#endif - -#ifdef GL_ARB_vertex_program -extern PFNGLVERTEXATTRIB1FARBPROC blVertexAttrib1fARB; -extern PFNGLVERTEXATTRIB1FVARBPROC blVertexAttrib1fvARB; -extern PFNGLVERTEXATTRIB2FARBPROC blVertexAttrib2fARB; -extern PFNGLVERTEXATTRIB2FVARBPROC blVertexAttrib2fvARB; -extern PFNGLVERTEXATTRIB3FARBPROC blVertexAttrib3fARB; -extern PFNGLVERTEXATTRIB3FVARBPROC blVertexAttrib3fvARB; -extern PFNGLVERTEXATTRIB4FARBPROC blVertexAttrib4fARB; -extern PFNGLVERTEXATTRIB4FVARBPROC blVertexAttrib4fvARB; -extern PFNGLGETPROGRAMSTRINGARBPROC blGetProgramStringARB; -extern PFNGLGETVERTEXATTRIBDVARBPROC blGetVertexAttribdvARB; -extern PFNGLGETVERTEXATTRIBFVARBPROC blGetVertexAttribfvARB; -extern PFNGLGETVERTEXATTRIBIVARBPROC blGetVertexAttribivARB; -#endif - -/* -#ifdef GL_EXT_compiled_vertex_array -extern PFNGLLOCKARRAYSEXTPROC blLockArraysEXT; -extern PFNGLUNLOCKARRAYSEXTPROC blUnlockArraysEXT; -#endif -*/ + void InitExtensions(bool debug); } /* namespace bgl */ - #endif /* __RAS_GLEXTENSIONMANAGER_H__ */ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index afa98fdb274..39080b80492 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -6,15 +6,10 @@ #ifdef WIN32 #include #endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#else -#include -#endif + +#include "GL/glew.h" #include "RAS_TexVert.h" -#include "RAS_GLExtensionManager.h" #include "MT_assert.h" //#ifndef NDEBUG @@ -27,8 +22,8 @@ RAS_ListSlot::RAS_ListSlot(RAS_ListRasterizer* rasty) : KX_ListSlot(), - m_flag(LIST_MODIFY|LIST_CREATE), m_list(0), + m_flag(LIST_MODIFY|LIST_CREATE), m_rasty(rasty) { } @@ -176,7 +171,7 @@ void RAS_ListRasterizer::IndexPrimitives( RAS_ListSlot* localSlot =0; // useObjectColor(are we updating every frame?) - if(!useObjectColor) { + if(!useObjectColor && slot) { localSlot = FindOrAdd(vertexarrays, slot); localSlot->DrawList(); if(localSlot->End()) { @@ -203,7 +198,7 @@ void RAS_ListRasterizer::IndexPrimitives( ); } - if(!useObjectColor) { + if(!useObjectColor && slot) { localSlot->EndList(); *slot = localSlot; } @@ -223,7 +218,7 @@ void RAS_ListRasterizer::IndexPrimitivesMulti( RAS_ListSlot* localSlot =0; // useObjectColor(are we updating every frame?) - if(!useObjectColor) { + if(!useObjectColor && slot) { localSlot = FindOrAdd(vertexarrays, slot); localSlot->DrawList(); @@ -251,7 +246,7 @@ void RAS_ListRasterizer::IndexPrimitivesMulti( ); } - if(!useObjectColor) { + if(!useObjectColor && slot) { localSlot->EndList(); *slot = localSlot; } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index f99121e5b7c..d3c0426de86 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -31,33 +31,13 @@ #include "RAS_OpenGLRasterizer.h" -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifdef WIN32 -#include -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#include -#else -#include -#if defined(__sun__) && !defined(__sparc__) -#include -#else -#include -#endif -#endif +#include "GL/glew.h" #include "RAS_Rect.h" #include "RAS_TexVert.h" #include "MT_CmMatrix4x4.h" #include "RAS_IRenderTools.h" // rendering text -#include "RAS_GLExtensionManager.h" - /** * 32x32 bit masks for vinterlace stereo mode */ @@ -83,10 +63,11 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas) m_focallength(0.0), m_setfocallength(false), m_noOfScanlines(32), - m_useTang(false), - m_materialCachingInfo(0), m_motionblur(0), - m_motionblurvalue(-1.0) + m_motionblurvalue(-1.0), + m_texco_num(0), + m_attrib_num(0), + m_materialCachingInfo(0) { m_viewmatrix.Identity(); @@ -335,7 +316,7 @@ void RAS_OpenGLRasterizer::Exit() glDisable(GL_POLYGON_STIPPLE); glDisable(GL_LIGHTING); - if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2)) + if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); EndFrame(); @@ -802,277 +783,6 @@ void RAS_OpenGLRasterizer::IndexPrimitives(const vecVertexArray & vertexarrays, } -void RAS_OpenGLRasterizer::IndexPrimitives_Ex(const vecVertexArray & vertexarrays, - const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor - ) -{ - bool recalc; - GLenum drawmode; - switch (mode) - { - case 0: - drawmode = GL_TRIANGLES; - break; - case 1: - drawmode = GL_LINES; - break; - case 2: - drawmode = GL_QUADS; - break; - default: - drawmode = GL_LINES; - break; - } - - const RAS_TexVert* vertexarray ; - unsigned int numindices,vt; - - for (vt=0;vt RAS_MAX_TEXCO) + m_texco_num = RAS_MAX_TEXCO; +} + +void RAS_OpenGLRasterizer::SetAttribNum(int num) +{ + m_attrib_num = num; + if(m_attrib_num > RAS_MAX_ATTRIB) + m_attrib_num = RAS_MAX_ATTRIB; +} + +void RAS_OpenGLRasterizer::SetTexCoord(TexCoGen coords, int unit) { // this changes from material to material - if(unit < RAS_MAX) + if(unit < RAS_MAX_TEXCO) m_texco[unit] = coords; } -void RAS_OpenGLRasterizer::SetAttrib(int type) +void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit) { - if(type == RAS_TEXTANGENT) m_useTang=true; + // this changes from material to material + if(unit < RAS_MAX_ATTRIB) + m_attrib[unit] = coords; } -void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv, int enabled) +void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv) { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(bgl::RAS_EXT_support._ARB_multitexture) { - for(int unit=0; unitGetEnabled(); + const RAS_TexVert* vertexarray ; + unsigned int numindices,vt; - if (!numindices) - break; + for (vt=0;vtGetEnabled(); - - if (!numindices) - continue; - - int vindex=0; - switch (mode) - { - case 1: - { - glBegin(GL_LINES); - vindex=0; - for (unsigned int i=0;i m_debugLines; - virtual void SetTexCoords(TexCoGen coords,int enabled); - virtual void SetAttrib(int type); - void TexCoord(const RAS_TexVert &tv, int unit); + virtual void SetTexCoordNum(int num); + virtual void SetAttribNum(int num); + virtual void SetTexCoord(TexCoGen coords, int unit); + virtual void SetAttrib(TexCoGen coords, int unit); + + void TexCoord(const RAS_TexVert &tv); virtual void GetViewMatrix(MT_Matrix4x4 &mat) const; void Tangent(const RAS_TexVert& v1, diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index ddfcc3f3f9d..67c72aacdcf 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -32,34 +32,21 @@ #include "RAS_VAOpenGLRasterizer.h" #include -#ifdef WIN32 -#include -#endif // WIN32 -#ifdef __APPLE__ -#define GL_GLEXT_LEGACY 1 -#include -#else -#include -#endif +#include "GL/glew.h" #include "STR_String.h" #include "RAS_TexVert.h" #include "MT_CmMatrix4x4.h" #include "RAS_IRenderTools.h" // rendering text - -#include "RAS_GLExtensionManager.h" - -using namespace bgl; - RAS_VAOpenGLRasterizer::RAS_VAOpenGLRasterizer(RAS_ICanvas* canvas, bool lock) : RAS_OpenGLRasterizer(canvas), - m_Lock(lock && RAS_EXT_support._EXT_compiled_vertex_array) + m_Lock(lock && GLEW_EXT_compiled_vertex_array), + m_last_texco_num(0), + m_last_attrib_num(0) { } - - RAS_VAOpenGLRasterizer::~RAS_VAOpenGLRasterizer() { } @@ -82,53 +69,36 @@ bool RAS_VAOpenGLRasterizer::Init(void) return result; } - - void RAS_VAOpenGLRasterizer::SetDrawingMode(int drawingmode) { m_drawingmode = drawingmode; - switch (m_drawingmode) + switch (m_drawingmode) { - case KX_BOUNDINGBOX: - { - } - case KX_WIREFRAME: - { + case KX_BOUNDINGBOX: + case KX_WIREFRAME: glDisable (GL_CULL_FACE); break; - } - case KX_TEXTURED: - { - } - case KX_SHADED: - { + case KX_TEXTURED: + case KX_SHADED: glEnableClientState(GL_COLOR_ARRAY); - } - case KX_SOLID: - { + case KX_SOLID: + break; + default: break; - } - default: - { - } } } - - void RAS_VAOpenGLRasterizer::Exit() { glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); + EnableTextures(false); RAS_OpenGLRasterizer::Exit(); } - - void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, int mode, @@ -142,24 +112,16 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays GLenum drawmode; switch (mode) { - case 0: - { - drawmode = GL_TRIANGLES; - break; - } - case 2: - { - drawmode = GL_QUADS; - break; - } - case 1: //lines - { - } - default: - { - drawmode = GL_LINES; - break; - } + case 0: + drawmode = GL_TRIANGLES; + break; + case 2: + drawmode = GL_QUADS; + break; + case 1: //lines + default: + drawmode = GL_LINES; + break; } const RAS_TexVert* vertexarray; unsigned int numindices, vt; @@ -208,7 +170,6 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays } } - void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, int mode, @@ -222,28 +183,19 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa GLenum drawmode; switch (mode) { - case 0: - { - drawmode = GL_TRIANGLES; - break; - } - case 2: - { - drawmode = GL_QUADS; - break; - } - case 1: //lines - { - } - default: - { - drawmode = GL_LINES; - break; - } + case 0: + drawmode = GL_TRIANGLES; + break; + case 2: + drawmode = GL_QUADS; + break; + case 1: //lines + default: + drawmode = GL_LINES; + break; } const RAS_TexVert* vertexarray; unsigned int numindices, vt; - const unsigned int enabled = polymat->GetEnabled(); if (drawmode != GL_LINES) { @@ -251,7 +203,8 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa { glDisableClientState(GL_COLOR_ARRAY); glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - } else + } + else { glColor4d(0,0,0,1.0); glEnableClientState(GL_COLOR_ARRAY); @@ -271,11 +224,10 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa if (!numindices) continue; - + glVertexPointer(3,GL_FLOAT,vtxstride,vertexarray->getLocalXYZ()); - TexCoordPtr(vertexarray, enabled); + TexCoordPtr(vertexarray); - //glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1()); glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); glNormalPointer(GL_FLOAT,vtxstride,vertexarray->getNormal()); @@ -290,62 +242,146 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa } } -void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv, int enabled) +void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv) { -#if defined(GL_ARB_multitexture) && defined(WITH_GLEXT) - if (!getenv("WITHOUT_GLEXT")) { - if(bgl::RAS_EXT_support._ARB_multitexture) - { - for(int unit=0; unitgetFlag() & TV_2NDUV && (int)tv->getUnit() == unit) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); - if( tv->getFlag() & TV_2NDUV && tv->getUnit() == unit ) { - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2()); - continue; - } - switch(m_texco[unit]) - { - case RAS_TEXCO_DISABLE: - case RAS_TEXCO_OBJECT: - case RAS_TEXCO_GEN: - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - break; - case RAS_TEXCO_ORCO: - case RAS_TEXCO_GLOB: - glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getLocalXYZ()); - break; - case RAS_TEXCO_UV1: - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV1()); - break; - case RAS_TEXCO_NORM: - glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getNormal()); - break; - case RAS_TEXTANGENT: - glTexCoordPointer(4, GL_FLOAT, sizeof(RAS_TexVert),tv->getTangent()); - break; - case RAS_TEXCO_UV2: - glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV2()); - break; - } + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2()); + continue; + } + switch(m_texco[unit]) + { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getLocalXYZ()); + break; + case RAS_TEXCO_UV1: + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV1()); + break; + case RAS_TEXCO_NORM: + glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getNormal()); + break; + case RAS_TEXTANGENT: + glTexCoordPointer(4, GL_FLOAT, sizeof(RAS_TexVert),tv->getTangent()); + break; + case RAS_TEXCO_UV2: + glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV2()); + break; + default: + break; } } + } -#ifdef GL_ARB_vertex_program - if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program) - bgl::blVertexAttrib4fvARB(1/*tangent*/, tv->getTangent()); -#endif + if(GLEW_ARB_vertex_program) { + for(unit=0; unitgetLocalXYZ()); + break; + case RAS_TEXCO_UV1: + glVertexAttribPointer(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV1()); + break; + case RAS_TEXCO_NORM: + glVertexAttribPointer(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal()); + break; + case RAS_TEXTANGENT: + glVertexAttribPointer(unit, 4, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getTangent()); + break; + case RAS_TEXCO_UV2: + glVertexAttribPointer(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV2()); + break; + default: + break; + } + } } -#endif } - void RAS_VAOpenGLRasterizer::EnableTextures(bool enable) { - if (enable) - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - else - glDisableClientState(GL_TEXTURE_COORD_ARRAY); + TexCoGen *texco, *attrib; + int unit, texco_num, attrib_num; + + /* disable previously enabled texture coordinates and attributes. ideally + * this shouldn't be necessary .. */ + if(enable) + EnableTextures(false); + + /* we cache last texcoords and attribs to ensure we disable the ones that + * were actually last set */ + if(enable) { + texco = m_texco; + texco_num = m_texco_num; + attrib = m_attrib; + attrib_num = m_attrib_num; + + memcpy(m_last_texco, m_texco, sizeof(TexCoGen)*m_texco_num); + m_last_texco_num = m_texco_num; + memcpy(m_last_attrib, m_attrib, sizeof(TexCoGen)*m_attrib_num); + m_last_attrib_num = m_attrib_num; + } + else { + texco = m_last_texco; + texco_num = m_last_texco_num; + attrib = m_last_attrib; + attrib_num = m_last_attrib_num; + } + + if(GLEW_ARB_multitexture) { + for(unit=0; unit tmp -# Code can be copied & pasted from tmp to GL_ExtensionManager.cpp. -# -# glext.h is available here: http://oss.sgi.com/projects/ogl-sample/ABI/glext.h -# - -from sys import stdin -import string, re - -glext_h = string.split(stdin.read(), '\n') - -# These extensions have been incorporated into the core GL or been superceded. -# Code will not be generated for these extensions -blacklist = [ - "GL_EXT_multisample", - "GL_INGR_blend_func_separate", - "GL_SGIX_fragment_lighting", - "GL_SGIX_polynomial_ffd", - "GL_SGIS_point_parameters", - "GL_EXT_texture_object", - "GL_EXT_subtexture", - "GL_EXT_copy_texture", - "GL_EXT_vertex_array", - "GL_EXT_point_parameters", - "GL_EXT_blend_color", - "GL_EXT_polygon_offset", - "GL_EXT_texture"] - -# Only code for these extensions will be generated. Extensions on both the -# blacklist & whitelist will not have code generated. -# This list is from http://oss.sgi.com/projects/ogl-sample/registry/ at 14-Mar-04 -whitelist = [ - # ARB Extensions - "GL_ARB_multitexture", - "GLX_ARB_get_proc_address", - "GL_ARB_transpose_matrix", - "WGL_ARB_buffer_region", - "GL_ARB_multisample", - "GL_ARB_texture_env_add", - "GL_ARB_texture_cube_map", - "WGL_ARB_extensions_string", - "WGL_ARB_pixel_format", - "WGL_ARB_make_current_read", - "WGL_ARB_pbuffer", - "GL_ARB_texture_compression", - "GL_ARB_texture_border_clamp", - "GL_ARB_point_parameters", - "GL_ARB_vertex_blend", - "GL_ARB_matrix_palette", - "GL_ARB_texture_env_combine", - "GL_ARB_texture_env_crossbar", - "GL_ARB_texture_env_dot3", - "WGL_ARB_render_texture", - "GL_ARB_texture_mirrored_repeat", - "GL_ARB_depth_texture", - "GL_ARB_shadow", - "GL_ARB_shadow_ambient", - "GL_ARB_window_pos", - "GL_ARB_vertex_program", - "GL_ARB_fragment_program", - "GL_ARB_vertex_buffer_object", - "GL_ARB_occlusion_query", - "GL_ARB_shader_objects", - "GL_ARB_vertex_shader", - "GL_ARB_fragment_shader", - "GL_ARB_shading_language_100", - "GL_ARB_texture_non_power_of_two", - "GL_ARB_point_sprite", - "GL_ARB_fragment_program_shadow", - - # Non ARB Extensions - "GL_EXT_abgr", - "GL_EXT_blend_color", - "GL_EXT_polygon_offset", - "GL_EXT_texture", - "GL_EXT_texture3D", - "GL_SGIS_texture_filter4", - "GL_EXT_subtexture", - "GL_EXT_copy_texture", - "GL_EXT_histogram", - "GL_EXT_convolution", - "GL_SGI_color_matrix", - "GL_SGI_color_table", - "GL_SGIS_pixel_texture", - "GL_SGIS_texture4D", - "GL_SGI_texture_color_table", - "GL_EXT_cmyka", - "GL_EXT_texture_object", - "GL_SGIS_detail_texture", - "GL_SGIS_sharpen_texture", - "GL_EXT_packed_pixels", - "GL_SGIS_texture_lod", - "GL_SGIS_multisample", - "GL_EXT_rescale_normal", - "GLX_EXT_visual_info", - "GL_EXT_vertex_array", - "GL_EXT_misc_attribute", - "GL_SGIS_generate_mipmap", - "GL_SGIX_clipmap", - "GL_SGIX_shadow", - "GL_SGIS_texture_edge_clamp", - "GL_SGIS_texture_border_clamp", - "GL_EXT_blend_minmax", - "GL_EXT_blend_subtract", - "GL_EXT_blend_logic_op", - "GLX_SGI_swap_control", - "GLX_SGI_video_sync", - "GLX_SGI_make_current_read", - "GLX_SGIX_video_source", - "GLX_EXT_visual_rating", - "GL_SGIX_interlace", - "GLX_EXT_import_context", - "GLX_SGIX_fbconfig", - "GLX_SGIX_pbuffer", - "GL_SGIS_texture_select", - "GL_SGIX_sprite", - "GL_SGIX_texture_multi_buffer", - "GL_EXT_point_parameters", - "GL_SGIX_instruments", - "GL_SGIX_texture_scale_bias", - "GL_SGIX_framezoom", - "GL_SGIX_tag_sample_buffer", - "GL_SGIX_reference_plane", - "GL_SGIX_flush_raster", - "GLX_SGI_cushion", - "GL_SGIX_depth_texture", - "GL_SGIS_fog_function", - "GL_SGIX_fog_offset", - "GL_HP_image_transform", - "GL_HP_convolution_border_modes", - "GL_SGIX_texture_add_env", - "GL_EXT_color_subtable", - "GLU_EXT_object_space_tess", - "GL_PGI_vertex_hints", - "GL_PGI_misc_hints", - "GL_EXT_paletted_texture", - "GL_EXT_clip_volume_hint", - "GL_SGIX_list_priority", - "GL_SGIX_ir_instrument1", - "GLX_SGIX_video_resize", - "GL_SGIX_texture_lod_bias", - "GLU_SGI_filter4_parameters", - "GLX_SGIX_dm_buffer", - "GL_SGIX_shadow_ambient", - "GLX_SGIX_swap_group", - "GLX_SGIX_swap_barrier", - "GL_EXT_index_texture", - "GL_EXT_index_material", - "GL_EXT_index_func", - "GL_EXT_index_array_formats", - "GL_EXT_compiled_vertex_array", - "GL_EXT_cull_vertex", - "GLU_EXT_nurbs_tessellator", - "GL_SGIX_ycrcb", - "GL_EXT_fragment_lighting", - "GL_IBM_rasterpos_clip", - "GL_HP_texture_lighting", - "GL_EXT_draw_range_elements", - "GL_WIN_phong_shading", - "GL_WIN_specular_fog", - "GLX_SGIS_color_range", - "GL_EXT_light_texture", - "GL_SGIX_blend_alpha_minmax", - "GL_EXT_scene_marker", - "GL_SGIX_pixel_texture_bits", - "GL_EXT_bgra", - "GL_SGIX_async", - "GL_SGIX_async_pixel", - "GL_SGIX_async_histogram", - "GL_INTEL_texture_scissor", - "GL_INTEL_parallel_arrays", - "GL_HP_occlusion_test", - "GL_EXT_pixel_transform", - "GL_EXT_pixel_transform_color_table", - "GL_EXT_shared_texture_palette", - "GLX_SGIS_blended_overlay", - "GL_EXT_separate_specular_color", - "GL_EXT_secondary_color", - "GL_EXT_texture_env", - "GL_EXT_texture_perturb_normal", - "GL_EXT_multi_draw_arrays", - "GL_EXT_fog_coord", - "GL_REND_screen_coordinates", - "GL_EXT_coordinate_frame", - "GL_EXT_texture_env_combine", - "GL_APPLE_specular_vector", - "GL_SGIX_pixel_texture", - "GL_APPLE_transform_hint", - "GL_SUNX_constant_data", - "GL_SUN_global_alpha", - "GL_SUN_triangle_list", - "GL_SUN_vertex", - "WGL_EXT_display_color_table", - "WGL_EXT_extensions_string", - "WGL_EXT_make_current_read", - "WGL_EXT_pixel_format", - "WGL_EXT_pbuffer", - "WGL_EXT_swap_control", - "GL_EXT_blend_func_separate", - "GL_INGR_color_clamp", - "GL_INGR_interlace_read", - "GL_EXT_stencil_wrap", - "WGL_EXT_depth_float", - "GL_EXT_422_pixels", - "GL_NV_texgen_reflection", - "GL_SGIX_texture_range", - "GL_SUN_convolution_border_modes", - "GLX_SUN_get_transparent_index", - "GL_EXT_texture_env_add", - "GL_EXT_texture_lod_bias", - "GL_EXT_texture_filter_anisotropic", - "GL_EXT_vertex_weighting", - "GL_NV_light_max_exponent", - "GL_NV_vertex_array_range", - "GL_NV_register_combiners", - "GL_NV_fog_distance", - "GL_NV_texgen_emboss", - "GL_NV_blend_square", - "GL_NV_texture_env_combine4", - "GL_MESA_resize_buffers", - "GL_MESA_window_pos", - "GL_EXT_texture_compression_s3tc", - "GL_IBM_cull_vertex", - "GL_IBM_multimode_draw_arrays", - "GL_IBM_vertex_array_lists", - "GL_3DFX_texture_compression_FXT1", - "GL_3DFX_multisample", - "GL_3DFX_tbuffer", - "WGL_EXT_multisample", - "GL_SGIX_vertex_preclip", - "GL_SGIX_resample", - "GL_SGIS_texture_color_mask", - "GLX_MESA_copy_sub_buffer", - "GLX_MESA_pixmap_colormap", - "GLX_MESA_release_buffers", - "GLX_MESA_set_3dfx_mode", - "GL_EXT_texture_env_dot3", - "GL_ATI_texture_mirror_once", - "GL_NV_fence", - "GL_IBM_static_data", - "GL_IBM_texture_mirrored_repeat", - "GL_NV_evaluators", - "GL_NV_packed_depth_stencil", - "GL_NV_register_combiners2", - "GL_NV_texture_compression_vtc", - "GL_NV_texture_rectangle", - "GL_NV_texture_shader", - "GL_NV_texture_shader2", - "GL_NV_vertex_array_range2", - "GL_NV_vertex_program", - "GLX_SGIX_visual_select_group", - "GL_SGIX_texture_coordinate_clamp", - "GLX_OML_swap_method", - "GLX_OML_sync_control", - "GL_OML_interlace", - "GL_OML_subsample", - "GL_OML_resample", - "WGL_OML_sync_control", - "GL_NV_copy_depth_to_color", - "GL_ATI_envmap_bumpmap", - "GL_ATI_fragment_shader", - "GL_ATI_pn_triangles", - "GL_ATI_vertex_array_object", - "GL_EXT_vertex_shader", - "GL_ATI_vertex_streams", - "WGL_I3D_digital_video_control", - "WGL_I3D_gamma", - "WGL_I3D_genlock", - "WGL_I3D_image_buffer", - "WGL_I3D_swap_frame_lock", - "WGL_I3D_swap_frame_usage", - "GL_ATI_element_array", - "GL_SUN_mesh_array", - "GL_SUN_slice_accum", - "GL_NV_multisample_filter_hint", - "GL_NV_depth_clamp", - "GL_NV_occlusion_query", - "GL_NV_point_sprite", - "WGL_NV_render_depth_texture", - "WGL_NV_render_texture_rectangle", - "GL_NV_texture_shader3", - "GL_NV_vertex_program1_1", - "GL_EXT_shadow_funcs", - "GL_EXT_stencil_two_side", - "GL_ATI_text_fragment_shader", - "GL_APPLE_client_storage", - "GL_APPLE_element_array", - "GL_APPLE_fence", - "GL_APPLE_vertex_array_object", - "GL_APPLE_vertex_array_range", - "GL_APPLE_ycbcr_422", - "GL_S3_s3tc", - "GL_ATI_draw_buffers", - "WGL_ATI_pixel_format_float", - "GL_ATI_texture_env_combine3", - "GL_ATI_texture_float", - "GL_NV_float_buffer", - "GL_NV_fragment_program", - "GL_NV_half_float", - "GL_NV_pixel_data_range", - "GL_NV_primitive_restart", - "GL_NV_texture_expand_normal", - "GL_NV_vertex_program2", - "GL_ATI_map_object_buffer", - "GL_ATI_separate_stencil", - "GL_ATI_vertex_attrib_array_object", - "GL_OES_byte_coordinates", - "GL_OES_fixed_point", - "GL_OES_single_precision", - "GL_OES_compressed_paletted_texture", - "GL_OES_read_format", - "GL_OES_query_matrix", - "GL_EXT_depth_bounds_test", - "GL_EXT_texture_mirror_clamp", - "GL_EXT_blend_equation_separate", - "GL_MESA_pack_invert", - "GL_MESA_ycbcr_texture"] - -""" -Example code output: -#ifdef GL_EXT_compiled_vertex_array - if (QueryExtension("GL_EXT_compiled_vertex_array")) - { - glUnlockArraysEXT = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glUnlockArraysEXT")); - glLockArraysEXT = reinterpret_cast(bglGetProcAddress((const GLubyte *) "glLockArraysEXT")); - if (glUnlockArraysEXT && glLockArraysEXT) - { - EnableExtension(_GL_EXT_compiled_vertex_array); - if (doDebugMessages) - std::cout << "Detected GL_EXT_compiled_vertex_array" << std::endl; - } else { - std::cout << "ERROR: GL_EXT_compiled_vertex_array implementation is broken!" << std::endl; - } - } -#endif -""" -def writeext(ext, fnlist): - if (find(blacklist, ext)): - return - if (len(fnlist) == 0): - # This extension has no functions to detect - don't need to wrap in - # #ifdef GL_extension names - print "\tif (QueryExtension(\"" + ext + "\"))" - print "\t{" - print "\t\tEnableExtension(_" + ext + ");" - print "\t\tif (doDebugMessages)" - print "\t\t\tstd::cout << \"Detected " + ext + "\" << std::endl;" - print "\t}" - print - return - print "#if defined(" + ext + ")" - print "\tif (QueryExtension(\"" + ext + "\"))" - print "\t{" - for fn in fnlist: - print "\t\t" + fn[0] + " = reinterpret_cast<" + fn[1] + ">(bglGetProcAddress((const GLubyte *) \"" + fn[0] + "\"));" - errcheck = "" - for fn in fnlist: - if (errcheck == ""): - errcheck = fn[0] - else: - errcheck = errcheck + " && " + fn[0] - print "\t\tif (" + errcheck + ") {" - print "\t\t\tEnableExtension(_" + ext + ");" - print "\t\t\tif (doDebugMessages)" - print "\t\t\t\tstd::cout << \"Enabled " + ext + "\" << std::endl;" - print "\t\t} else {" - print "\t\t\tstd::cout << \"ERROR: " + ext + " implementation is broken!\" << std::endl;" - print "\t\t}" - print "\t}" - print "#endif" - print - -""" -Example Output: -#if defined(GL_EXT_compiled_vertex_array) -PFNGLLOCKARRAYSEXTPROC glLockArraysEXT; -PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT; -#endif -""" -def writeproto(ext, fnlist): - if (find(blacklist, ext) or not find(whitelist, ext)): - return - print "#if defined(" + ext + ")" - for fn in fnlist: - print fn[1] + " " + fn[0] + ";" - print "#endif" - print - -""" -#ifdef GL_EXT_compiled_vertex_array -extern PFNGLLOCKARRAYSEXTPROC glLockArraysEXT; -extern PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT; -#endif -""" -def writeheader(ext, fnlisti): - if (find(blacklist, ext) or not find(whitelist, ext)): - return - print "#if defined(" + ext + ")" - for fn in fnlist: - print "extern " + fn[1] + " " + fn[0] + ";" - print "#endif" - print - -def find(l, x): - for i in l: - if (i == x): - return 1 - return 0 - - -# Write Prototypes -ext = "" -fns = [] -fnlist = [] -ifdef = 0 -for i in glext_h: - line = re.search('^#ifn?def', i) - if (line): - ifdef = ifdef + 1 - - line = re.search('^#ifndef (GL_.*)', i) - if (line): - if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))): - ext = line.group(1) - - line = re.search('^#endif', i) - if (line): - ifdef = ifdef - 1 - if (ifdef == 0 and ext != ""): - writeproto(ext, fnlist) - ext = "" - fns = [] - fnlist = [] - if (ext != ""): - line = re.search('.* (gl.*) \(.*\);', i) - if (line): - fns += [line.group(1)] - line = re.search('.*PFN(.*)PROC.*', i) - if (line): - for j in fns: - if (string.lower(line.group(1)) == string.lower(j)): - fnlist += [(j, "PFN" + line.group(1) + "PROC")] - -# Write link code -ext = "" -fns = [] -fnlist = [] -ifdef = 0 -for i in glext_h: - line = re.search('^#ifn?def', i) - if (line): - ifdef = ifdef + 1 - - line = re.search('^#ifndef (GL_.*)', i) - if (line): - if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))): - ext = line.group(1) - - line = re.search('^#endif', i) - if (line): - ifdef = ifdef - 1 - if (ifdef == 0 and ext != ""): - writeext(ext, fnlist) - ext = "" - fns = [] - fnlist = [] - if (ext != ""): - line = re.search('.* (gl.*) \(.*\);', i) - if (line): - fns += [line.group(1)] - line = re.search('.*PFN(.*)PROC.*', i) - if (line): - for j in fns: - if (string.lower(line.group(1)) == string.lower(j)): - fnlist += [(j, "PFN" + line.group(1) + "PROC")] - -# Write header code -ext = "" -fns = [] -fnlist = [] -ifdef = 0 -for i in glext_h: - line = re.search('^#ifn?def', i) - if (line): - ifdef = ifdef + 1 - - line = re.search('^#ifndef (GL_.*)', i) - if (line): - if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))): - ext = line.group(1) - - line = re.search('^#endif', i) - if (line): - ifdef = ifdef - 1 - if (ifdef == 0 and ext != ""): - writeheader(ext, fnlist) - ext = "" - fns = [] - fnlist = [] - if (ext != ""): - line = re.search('.* (gl.*) \(.*\);', i) - if (line): - fns += [line.group(1)] - line = re.search('.*PFN(.*)PROC.*', i) - if (line): - for j in fns: - if (string.lower(line.group(1)) == string.lower(j)): - fnlist += [(j, "PFN" + line.group(1) + "PROC")] - -# Write Python link code -ext = "" -extensions = [] -fns = [] -defines = [] -ifdef = 0 -for i in glext_h: - line = re.search('^#ifn?def', i) - if (line): - ifdef = ifdef + 1 - - line = re.search('^#ifndef (GL_.*)', i) - if (line): - if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))): - ext = line.group(1) - - line = re.search('^#endif', i) - if (line): - ifdef = ifdef - 1 - if (ifdef == 0 and ext != ""): - done = 0 - for e in range(len(extensions)): - if extensions[e][0] == ext: - extensions[e] = (ext, defines + extensions[e][1], fns + extensions[e][2]) - done = 1 - if not done: - extensions = extensions + [(ext, defines, fns)] - ext = "" - fns = [] - defines = [] - if (ext != ""): - line = re.search('#define +(GL.*) +(0x.*)', i) # #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 - if (line): - defines += [(line.group(1), line.group(2))] - - line = re.search('(.* )(gl.*)(\(.*\));', i) # GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); - if (line): - fns += [(line.group(1), line.group(2), line.group(3))] - -for ext in extensions: - if (find(blacklist, ext[0]) or not find(whitelist, ext[0])): - continue - print "#if defined(" + ext[0] + ")" - for fn in ext[2]: - line = re.search('gl(.*)', fn[1]) - # BGL_Wrap(2, RasterPos2f, void, (GLfloat, GLfloat)) - rtype = "" - for r in string.split(fn[0]): - if r != "GLAPI" and r != "APIENTRY": - rtype = rtype + " " + r - params = "" - for p in string.split(fn[2], ','): - pline = re.search('(.*) \*', p) - if (pline): - p = pline.group(1) + "P" - if params == "": - params = p - else: - params = params + "," + p - if not params[-1] == ")": - params = params + ")" - print "BGL_Wrap(" + str(len(string.split(fn[2], ','))) + ", " + line.group(1) + ",\t" + rtype + ",\t" + params + ")" - print "#endif" - print - -for ext in extensions: - if (find(blacklist, ext[0]) or not find(whitelist, ext[0])): - continue - print 'PyDict_SetItemString(dict, "' + ext[0] + '", PyInt_FromLong(_' + ext[0] + '))' - print "#if defined(" + ext[0] + ")" - print "if (bglQueryExtension(_" + ext[0] + ")) {" - if len(ext[2]) > 0: - for fn in ext[2]: - line = re.search('gl(.*)', fn[1]) - # MethodDef(Vertex3iv), - print " BGL_AddMethod(" + line.group(1) + ");" - print - - for define in ext[1]: - print " BGL_AddConst(" + define[0] + ");" - print - - print "}" - print "#endif" - print diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index ff79a5d97b8..f077833b850 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -7,7 +7,7 @@ if env['WITH_BF_GLEXT'] == 1: env['CPPFLAGS'].append('-DWITH_GLEXT') -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines' +incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include' if env['OURPLATFORM']=='win32-vc': cflags = [] -- cgit v1.2.3 From 2bece8dcb5104bc95149b0c40723f1dc855d6b29 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 18 Jun 2008 06:46:49 +0000 Subject: BGE Patch: Add Shape Action support and update MSCV_7 project file for glew. Shape Action are now supported in the BGE. A new type of actuator "Shape Action" is available on mesh objects. It can be combined with Action actuator on parent armature. Only relative keys are supported. All the usual action options are available: type, blending, priority, Python API. Only actions with shape channels should be specified of course, otherwise the actuator has no effect. Shape action will still work after a mesh replacement provided that the new mesh has compatible shape keys. --- .../Converter/BL_BlenderDataConversion.cpp | 37 +- .../Converter/BL_DeformableGameObject.cpp | 47 ++ .../gameengine/Converter/BL_DeformableGameObject.h | 40 +- source/gameengine/Converter/BL_MeshDeformer.cpp | 2 +- source/gameengine/Converter/BL_MeshDeformer.h | 4 +- .../Converter/BL_ShapeActionActuator.cpp | 797 +++++++++++++++++++++ .../gameengine/Converter/BL_ShapeActionActuator.h | 133 ++++ source/gameengine/Converter/BL_ShapeDeformer.cpp | 125 ++++ source/gameengine/Converter/BL_ShapeDeformer.h | 93 +++ source/gameengine/Converter/BL_SkinDeformer.cpp | 50 +- source/gameengine/Converter/BL_SkinDeformer.h | 35 +- source/gameengine/Converter/BL_SkinMeshObject.cpp | 58 ++ source/gameengine/Converter/BL_SkinMeshObject.h | 36 +- .../gameengine/Converter/KX_ConvertActuators.cpp | 25 + source/gameengine/GameLogic/SCA_IObject.h | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 1 + source/gameengine/Ketsji/KX_GameObject.h | 17 +- source/gameengine/Ketsji/KX_Scene.cpp | 130 ++-- source/gameengine/Rasterizer/RAS_Deformer.h | 2 +- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 5 +- source/gameengine/Rasterizer/RAS_MeshObject.h | 5 +- 21 files changed, 1523 insertions(+), 121 deletions(-) create mode 100644 source/gameengine/Converter/BL_ShapeActionActuator.cpp create mode 100644 source/gameengine/Converter/BL_ShapeActionActuator.h create mode 100644 source/gameengine/Converter/BL_ShapeDeformer.cpp create mode 100644 source/gameengine/Converter/BL_ShapeDeformer.h (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 0ad9258bcc0..32946267202 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -90,6 +90,7 @@ #include "BKE_object.h" #include "BKE_scene.h" #include "BL_SkinMeshObject.h" +#include "BL_ShapeDeformer.h" #include "BL_SkinDeformer.h" #include "BL_MeshDeformer.h" //#include "BL_ArmatureController.h" @@ -223,15 +224,16 @@ static unsigned int KX_Mcol2uint_new(MCol col) static void SetDefaultFaceType(Scene* scene) { default_face_mode = TF_DYNAMIC; - Base *base = static_cast(scene->base.first); - while(base) + Scene *sce; + Base *base; + + for(SETLOOPER(scene,base)) { if (base->object->type == OB_LAMP) { default_face_mode = TF_DYNAMIC|TF_LIGHT; return; } - base = base->next; } } @@ -800,12 +802,12 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* // Determine if we need to make a skinned mesh - if (mesh->dvert){ - meshobj = new BL_SkinMeshObject(lightlayer); + if (mesh->dvert || mesh->key){ + meshobj = new BL_SkinMeshObject(mesh, lightlayer); skinMesh = true; } else { - meshobj = new RAS_MeshObject(lightlayer); + meshobj = new RAS_MeshObject(mesh, lightlayer); } MT_Vector4 *tangent = 0; if (tface) @@ -1644,7 +1646,7 @@ static KX_GameObject *gameobject_from_blenderobject( // needed for python scripting kxscene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj); - gameobj = new BL_DeformableGameObject(kxscene,KX_Scene::m_callbacks); + gameobj = new BL_DeformableGameObject(ob,kxscene,KX_Scene::m_callbacks); // set transformation gameobj->AddMesh(meshobj); @@ -1655,12 +1657,24 @@ static KX_GameObject *gameobject_from_blenderobject( ((ob->gameflag2 & OB_NEVER_DO_ACTIVITY_CULLING)!=0); gameobj->SetIgnoreActivityCulling(ignoreActivityCulling); - // If this is a skin object, make Skin Controller - if (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && ((Mesh*)ob->data)->dvert){ + // two options exists for deform: shape keys and armature + // only support relative shape key + bool bHasShapeKey = mesh->key != NULL && mesh->key->type==KEY_RELATIVE; + bool bHasDvert = mesh->dvert != NULL; + bool bHasArmature = (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && bHasDvert); + + if (bHasShapeKey) { + // not that we can have shape keys without dvert! + BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj, + ob, (BL_SkinMeshObject*)meshobj); + ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; + } else if (bHasArmature) { BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj ); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; - } - else if (((Mesh*)ob->data)->dvert){ + } else if (bHasDvert) { + // this case correspond to a mesh that can potentially deform but not with the + // object to which it is attached for the moment. A skin mesh was created in + // BL_ConvertMesh() so must create a deformer too! BL_MeshDeformer *dcont = new BL_MeshDeformer(ob, (BL_SkinMeshObject*)meshobj ); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; } @@ -1696,6 +1710,7 @@ static KX_GameObject *gameobject_from_blenderobject( { gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment()); gameobj->SetLayer(ob->lay); + gameobj->SetBlenderObject(ob); } return gameobj; } diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp index 68a2e41ca47..d23274324ee 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.cpp +++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp @@ -28,6 +28,8 @@ */ #include "BL_DeformableGameObject.h" +#include "BL_ShapeDeformer.h" +#include "BL_ShapeActionActuator.h" #ifdef HAVE_CONFIG_H #include @@ -60,3 +62,48 @@ CValue* BL_DeformableGameObject::GetReplica() ProcessReplica(replica); return replica; } + +bool BL_DeformableGameObject::SetActiveAction(BL_ShapeActionActuator *act, short priority, double curtime) +{ + if (curtime != m_lastframe){ + m_activePriority = 9999; + m_lastframe= curtime; + m_activeAct = NULL; + } + + if (priority<=m_activePriority) + { + if (m_activeAct && (m_activeAct!=act)) + m_activeAct->SetBlendTime(0.0f); /* Reset the blend timer */ + m_activeAct = act; + m_activePriority = priority; + m_lastframe = curtime; + + return true; + } + else{ + act->SetBlendTime(0.0f); + return false; + } +} + +bool BL_DeformableGameObject::GetShape(vector &shape) +{ + shape.clear(); + if (m_pDeformer) + { + Mesh* mesh = ((BL_MeshDeformer*)m_pDeformer)->GetMesh(); + // this check is normally superfluous: a shape deformer can only be created if the mesh + // has relative keys + if (mesh && mesh->key && mesh->key->type==KEY_RELATIVE) + { + KeyBlock *kb; + for (kb = (KeyBlock*)mesh->key->block.first; kb; kb = (KeyBlock*)kb->next) + { + shape.push_back(kb->curval); + } + } + } + return !shape.empty(); +} + diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index d943cc7388a..57a404ad72b 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -34,15 +34,28 @@ #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 +#include "DNA_mesh_types.h" #include "KX_GameObject.h" -#include "RAS_Deformer.h" +#include "BL_MeshDeformer.h" +#include + +class BL_ShapeActionActuator; +struct Key; class BL_DeformableGameObject : public KX_GameObject { public: - RAS_Deformer *m_pDeformer; CValue* GetReplica(); + + double GetLastFrame () + { + return m_lastframe; + } + Object* GetBlendObject() + { + return m_blendobj; + } virtual void Relink(GEN_Map*map) { if (m_pDeformer) @@ -50,13 +63,32 @@ public: }; void ProcessReplica(KX_GameObject* replica); - BL_DeformableGameObject(void* sgReplicationInfo, SG_Callbacks callbacks) : + BL_DeformableGameObject(Object* blendobj, void* sgReplicationInfo, SG_Callbacks callbacks) : KX_GameObject(sgReplicationInfo,callbacks), - m_pDeformer(NULL) + m_pDeformer(NULL), + m_activeAct(NULL), + m_lastframe(0.), + m_blendobj(blendobj), + m_activePriority(9999) { m_isDeformable = true; }; virtual ~BL_DeformableGameObject(); + bool SetActiveAction(class BL_ShapeActionActuator *act, short priority, double curtime); + + bool GetShape(vector &shape); + Key* GetKey() + { + return (m_pDeformer) ? ((BL_MeshDeformer*)m_pDeformer)->GetMesh()->key : NULL; + } + +public: + RAS_Deformer *m_pDeformer; +protected: + class BL_ShapeActionActuator *m_activeAct; + double m_lastframe; + Object* m_blendobj; + short m_activePriority; }; diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index 85ba894f9a5..212827a660f 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -198,7 +198,7 @@ void BL_MeshDeformer::RecalcNormals() void BL_MeshDeformer::VerifyStorage() { /* Ensure that we have the right number of verts assigned */ - if (m_tvtot!=m_bmesh->totvert+m_bmesh->totface) { + if (m_tvtot!=m_bmesh->totvert){ if (m_transverts) delete [] m_transverts; if (m_transnors) diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 88dc2500859..8d8b56b1eed 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -32,6 +32,7 @@ #include "RAS_Deformer.h" #include "DNA_object_types.h" +#include "DNA_key_types.h" #include "MT_Point3.h" #include @@ -56,8 +57,9 @@ public: virtual ~BL_MeshDeformer(); virtual void SetSimulatedTime(double time){}; virtual bool Apply(class RAS_IPolyMaterial *mat); - virtual void Update(void){}; + virtual bool Update(void){ return false; }; virtual RAS_Deformer* GetReplica(){return NULL;}; + struct Mesh* GetMesh() { return m_bmesh; }; // virtual void InitDeform(double time){}; protected: class BL_SkinMeshObject* m_pMeshObject; diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp new file mode 100644 index 00000000000..3e1369e1e9f --- /dev/null +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -0,0 +1,797 @@ +/** +* $Id: BL_ShapeActionActuator.cpp 14444 2008-04-16 22:40:48Z hos $ +* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** +*/ + +#if defined (__sgi) +#include +#else +#include +#endif + +#include "SCA_LogicManager.h" +#include "BL_ShapeActionActuator.h" +#include "BL_ActionActuator.h" +#include "BL_ShapeDeformer.h" +#include "KX_GameObject.h" +#include "STR_HashedString.h" +#include "DNA_action_types.h" +#include "DNA_nla_types.h" +#include "DNA_actuator_types.h" +#include "BKE_action.h" +#include "DNA_armature_types.h" +#include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "MT_Matrix4x4.h" +#include "BKE_utildefines.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +BL_ShapeActionActuator::~BL_ShapeActionActuator() +{ +} + +void BL_ShapeActionActuator::ProcessReplica() +{ + m_localtime=m_startframe; + m_lastUpdate=-1; +} + +void BL_ShapeActionActuator::SetBlendTime (float newtime) +{ + m_blendframe = newtime; +} + +CValue* BL_ShapeActionActuator::GetReplica() +{ + BL_ShapeActionActuator* replica = new BL_ShapeActionActuator(*this);//m_float,GetName()); + replica->ProcessReplica(); + + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + return replica; +} + +bool BL_ShapeActionActuator::ClampLocalTime() +{ + if (m_startframe < m_endframe) { + if (m_localtime < m_startframe) + { + m_localtime = m_startframe; + return true; + } + else if (m_localtime > m_endframe) + { + m_localtime = m_endframe; + return true; + } + } else { + if (m_localtime > m_startframe) + { + m_localtime = m_startframe; + return true; + } + else if (m_localtime < m_endframe) + { + m_localtime = m_endframe; + return true; + } + } + return false; +} + +void BL_ShapeActionActuator::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_KetsjiEngine::GetAnimFrameRate(); + else + m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate(); +} + +void BL_ShapeActionActuator::SetLocalTime(float curtime) +{ + float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate(); + + if (m_endframe < m_startframe) + delta_time = -delta_time; + + if (!(m_flag & ACT_FLAG_REVERSE)) + m_localtime = m_startframe + delta_time; + else + m_localtime = m_endframe - delta_time; +} + +void BL_ShapeActionActuator::BlendShape(Key* key, float srcweight) +{ + vector::const_iterator it; + float dstweight; + int i; + KeyBlock *kb; + + dstweight = 1.0F - srcweight; + + for (it=m_blendshape.begin(), kb = (KeyBlock*)key->block.first; + kb && it != m_blendshape.end(); + kb = (KeyBlock*)kb->next, it++) { + kb->curval = kb->curval * dstweight + (*it) * srcweight; + } +} + +bool BL_ShapeActionActuator::Update(double curtime, bool frame) +{ + bool bNegativeEvent = false; + bool bPositiveEvent = false; + bool keepgoing = true; + bool wrap = false; + bool apply=true; + int priority; + float newweight; + + // result = true if animation has to be continued, false if animation stops + // maybe there are events for us in the queue ! + if (frame) + { + for (vector::iterator i=m_events.begin(); !(i==m_events.end());i++) + { + if ((*i)->GetNumber() == 0.0f) + bNegativeEvent = true; + else + bPositiveEvent= true; + (*i)->Release(); + + } + m_events.clear(); + + if (bPositiveEvent) + m_flag |= ACT_FLAG_ACTIVE; + + if (bNegativeEvent) + { + if (!(m_flag & ACT_FLAG_ACTIVE)) + return false; + m_flag &= ~ACT_FLAG_ACTIVE; + } + } + + /* This action can only be attached to a deform object */ + BL_DeformableGameObject *obj = (BL_DeformableGameObject*)GetParent(); + float length = m_endframe - m_startframe; + + priority = m_priority; + + /* Determine pre-incrementation behaviour and set appropriate flags */ + switch (m_playtype){ + case ACT_ACTION_MOTION: + if (bNegativeEvent){ + keepgoing=false; + apply=false; + }; + break; + case ACT_ACTION_FROM_PROP: + if (bNegativeEvent){ + apply=false; + keepgoing=false; + } + break; + case ACT_ACTION_LOOP_END: + if (bPositiveEvent){ + if (!(m_flag & ACT_FLAG_LOCKINPUT)){ + m_flag &= ~ACT_FLAG_KEYUP; + m_flag &= ~ACT_FLAG_REVERSE; + m_flag |= ACT_FLAG_LOCKINPUT; + m_localtime = m_startframe; + m_starttime = curtime; + } + } + if (bNegativeEvent){ + m_flag |= ACT_FLAG_KEYUP; + } + break; + case ACT_ACTION_LOOP_STOP: + if (bPositiveEvent){ + if (!(m_flag & ACT_FLAG_LOCKINPUT)){ + m_flag &= ~ACT_FLAG_REVERSE; + m_flag &= ~ACT_FLAG_KEYUP; + m_flag |= ACT_FLAG_LOCKINPUT; + SetStartTime(curtime); + } + } + if (bNegativeEvent){ + m_flag |= ACT_FLAG_KEYUP; + m_flag &= ~ACT_FLAG_LOCKINPUT; + keepgoing=false; + apply=false; + } + break; + case ACT_ACTION_FLIPPER: + if (bPositiveEvent){ + if (!(m_flag & ACT_FLAG_LOCKINPUT)){ + m_flag &= ~ACT_FLAG_REVERSE; + m_flag |= ACT_FLAG_LOCKINPUT; + SetStartTime(curtime); + } + } + else if (bNegativeEvent){ + m_flag |= ACT_FLAG_REVERSE; + m_flag &= ~ACT_FLAG_LOCKINPUT; + SetStartTime(curtime); + } + break; + case ACT_ACTION_PLAY: + if (bPositiveEvent){ + if (!(m_flag & ACT_FLAG_LOCKINPUT)){ + m_flag &= ~ACT_FLAG_REVERSE; + m_localtime = m_starttime; + m_starttime = curtime; + m_flag |= ACT_FLAG_LOCKINPUT; + } + } + break; + default: + break; + } + + /* Perform increment */ + if (keepgoing){ + if (m_playtype == ACT_ACTION_MOTION){ + MT_Point3 newpos; + MT_Point3 deltapos; + + newpos = obj->NodeGetWorldPosition(); + + /* Find displacement */ + deltapos = newpos-m_lastpos; + m_localtime += (length/m_stridelength) * deltapos.length(); + m_lastpos = newpos; + } + else{ + SetLocalTime(curtime); + } + } + + /* Check if a wrapping response is needed */ + if (length){ + if (m_localtime < m_startframe || m_localtime > m_endframe) + { + m_localtime = m_startframe + fmod(m_localtime, length); + wrap = true; + } + } + else + m_localtime = m_startframe; + + /* Perform post-increment tasks */ + switch (m_playtype){ + case ACT_ACTION_FROM_PROP: + { + CValue* propval = GetParent()->GetProperty(m_propname); + if (propval) + m_localtime = propval->GetNumber(); + + if (bNegativeEvent){ + keepgoing=false; + } + } + break; + case ACT_ACTION_MOTION: + break; + case ACT_ACTION_LOOP_STOP: + break; + case ACT_ACTION_FLIPPER: + if (wrap){ + if (!(m_flag & ACT_FLAG_REVERSE)){ + m_localtime=m_endframe; + //keepgoing = false; + } + else { + m_localtime=m_startframe; + keepgoing = false; + } + } + break; + case ACT_ACTION_LOOP_END: + if (wrap){ + if (m_flag & ACT_FLAG_KEYUP){ + keepgoing = false; + m_localtime = m_endframe; + m_flag &= ~ACT_FLAG_LOCKINPUT; + } + SetStartTime(curtime); + } + break; + case ACT_ACTION_PLAY: + if (wrap){ + m_localtime = m_endframe; + keepgoing = false; + m_flag &= ~ACT_FLAG_LOCKINPUT; + } + break; + default: + keepgoing = false; + break; + } + + + if (bNegativeEvent) + m_blendframe=0.0f; + + /* Apply the pose if necessary*/ + if (apply) { + + /* Priority test */ + if (obj->SetActiveAction(this, priority, curtime)){ + Key *key = obj->GetKey(); + + if (!key) { + // this could happen if the mesh was changed in the middle of an action + // and the new mesh has no key, stop the action + keepgoing = false; + } + else { + ListBase tchanbase= {NULL, NULL}; + + if (m_blendin && m_blendframe==0.0f){ + // this is the start of the blending, remember the startup shape + obj->GetShape(m_blendshape); + m_blendstart = curtime; + } + // only interested in shape channel + extract_ipochannels_from_action(&tchanbase, &key->id, m_action, "Shape", m_localtime); + + if (!execute_ipochannels(&tchanbase)) { + // no update, this is possible if action does not match the keys, stop the action + keepgoing = false; + } + else { + // the key have changed, apply blending if needed + if (m_blendin && (m_blendframem_blendin) + m_blendframe = m_blendin; + } + m_lastUpdate = m_localtime; + } + BLI_freelistN(&tchanbase); + } + } + else{ + m_blendframe = 0.0f; + } + } + + if (!keepgoing){ + m_blendframe = 0.0f; + } + return keepgoing; +}; + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ + +PyTypeObject BL_ShapeActionActuator::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "BL_ShapeActionActuator", + sizeof(BL_ShapeActionActuator), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject BL_ShapeActionActuator::Parents[] = { + &BL_ShapeActionActuator::Type, + &SCA_IActuator::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef BL_ShapeActionActuator::Methods[] = { + {"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, SetAction_doc}, + {"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, SetStart_doc}, + {"setEnd", (PyCFunction) BL_ShapeActionActuator::sPySetEnd, METH_VARARGS, SetEnd_doc}, + {"setBlendin", (PyCFunction) BL_ShapeActionActuator::sPySetBlendin, METH_VARARGS, SetBlendin_doc}, + {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, SetPriority_doc}, + {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, SetFrame_doc}, + {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, + {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc}, + + {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_VARARGS, GetAction_doc}, + {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_VARARGS, GetStart_doc}, + {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_VARARGS, GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_VARARGS, GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_VARARGS, GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_VARARGS, GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, + {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_VARARGS, GetType_doc}, + {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_VARARGS, SetType_doc}, + {NULL,NULL} //Sentinel +}; + +PyObject* BL_ShapeActionActuator::_getattr(const STR_String& attr) { + _getattr_up(SCA_IActuator); +} + +/* setStart */ +char BL_ShapeActionActuator::GetAction_doc[] = +"getAction()\n" +"\tReturns a string containing the name of the current action.\n"; + +PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + if (m_action){ + result = Py_BuildValue("s", m_action->id.name+2); + } + else{ + Py_INCREF(Py_None); + result = Py_None; + } + + return result; +} + +/* getProperty */ +char BL_ShapeActionActuator::GetProperty_doc[] = +"getProperty()\n" +"\tReturns the name of the property to be used in FromProp mode.\n"; + +PyObject* BL_ShapeActionActuator::PyGetProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + result = Py_BuildValue("s", (const char *)m_propname); + + return result; +} + +/* getFrame */ +char BL_ShapeActionActuator::GetFrame_doc[] = +"getFrame()\n" +"\tReturns the current frame number.\n"; + +PyObject* BL_ShapeActionActuator::PyGetFrame(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + result = Py_BuildValue("f", m_localtime); + + return result; +} + +/* getEnd */ +char BL_ShapeActionActuator::GetEnd_doc[] = +"getEnd()\n" +"\tReturns the last frame of the action.\n"; + +PyObject* BL_ShapeActionActuator::PyGetEnd(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + result = Py_BuildValue("f", m_endframe); + + return result; +} + +/* getStart */ +char BL_ShapeActionActuator::GetStart_doc[] = +"getStart()\n" +"\tReturns the starting frame of the action.\n"; + +PyObject* BL_ShapeActionActuator::PyGetStart(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + result = Py_BuildValue("f", m_startframe); + + return result; +} + +/* getBlendin */ +char BL_ShapeActionActuator::GetBlendin_doc[] = +"getBlendin()\n" +"\tReturns the number of interpolation animation frames to be\n" +"\tgenerated when this actuator is triggered.\n"; + +PyObject* BL_ShapeActionActuator::PyGetBlendin(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + result = Py_BuildValue("f", m_blendin); + + return result; +} + +/* getPriority */ +char BL_ShapeActionActuator::GetPriority_doc[] = +"getPriority()\n" +"\tReturns the priority for this actuator. Actuators with lower\n" +"\tPriority numbers will override actuators with higher numbers.\n"; + +PyObject* BL_ShapeActionActuator::PyGetPriority(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + result = Py_BuildValue("i", m_priority); + + return result; +} + +/* setAction */ +char BL_ShapeActionActuator::SetAction_doc[] = +"setAction(action, (reset))\n" +"\t - action : The name of the action to set as the current action.\n" +"\t Should be an action with Shape channels.\n" +"\t - reset : Optional parameter indicating whether to reset the\n" +"\t blend timer or not. A value of 1 indicates that the\n" +"\t timer should be reset. A value of 0 will leave it\n" +"\t unchanged. If reset is not specified, the timer will" +"\t be reset.\n"; + +PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self, + PyObject* args, + PyObject* kwds) { + char *string; + int reset = 1; + + if (PyArg_ParseTuple(args,"s|i",&string, &reset)) + { + bAction *action; + + action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(STR_String(string)); + + if (!action){ + /* NOTE! Throw an exception or something */ + // printf ("setAction failed: Action not found\n", string); + } + else{ + m_action=action; + if (reset) + m_blendframe = 0.f; + } + } + + Py_INCREF(Py_None); + return Py_None; +} + +/* setStart */ +char BL_ShapeActionActuator::SetStart_doc[] = +"setStart(start)\n" +"\t - start : Specifies the starting frame of the animation.\n"; + +PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self, + PyObject* args, + PyObject* kwds) { + float start; + + if (PyArg_ParseTuple(args,"f",&start)) + { + m_startframe = start; + } + + Py_INCREF(Py_None); + return Py_None; +} + +/* setEnd */ +char BL_ShapeActionActuator::SetEnd_doc[] = +"setEnd(end)\n" +"\t - end : Specifies the ending frame of the animation.\n"; + +PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self, + PyObject* args, + PyObject* kwds) { + float end; + + if (PyArg_ParseTuple(args,"f",&end)) + { + m_endframe = end; + } + + Py_INCREF(Py_None); + return Py_None; +} + +/* setBlendin */ +char BL_ShapeActionActuator::SetBlendin_doc[] = +"setBlendin(blendin)\n" +"\t - blendin : Specifies the number of frames of animation to generate\n" +"\t when making transitions between actions.\n"; + +PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self, + PyObject* args, + PyObject* kwds) { + float blendin; + + if (PyArg_ParseTuple(args,"f",&blendin)) + { + m_blendin = blendin; + } + + Py_INCREF(Py_None); + return Py_None; +} + +/* setBlendtime */ +char BL_ShapeActionActuator::SetBlendtime_doc[] = +"setBlendtime(blendtime)\n" +"\t - blendtime : Allows the script to directly modify the internal timer\n" +"\t used when generating transitions between actions. This\n" +"\t parameter must be in the range from 0.0 to 1.0.\n"; + +PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self, + PyObject* args, + PyObject* kwds) { + float blendframe; + + if (PyArg_ParseTuple(args,"f",&blendframe)) + { + m_blendframe = blendframe * m_blendin; + if (m_blendframe<0.f) + m_blendframe = 0.f; + if (m_blendframe>m_blendin) + m_blendframe = m_blendin; + } + + Py_INCREF(Py_None); + return Py_None; +} + +/* setPriority */ +char BL_ShapeActionActuator::SetPriority_doc[] = +"setPriority(priority)\n" +"\t - priority : Specifies the new priority. Actuators will lower\n" +"\t priority numbers will override actuators with higher\n" +"\t numbers.\n"; + +PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, + PyObject* args, + PyObject* kwds) { + int priority; + + if (PyArg_ParseTuple(args,"i",&priority)) + { + m_priority = priority; + } + + Py_INCREF(Py_None); + return Py_None; +} + +/* setFrame */ +char BL_ShapeActionActuator::SetFrame_doc[] = +"setFrame(frame)\n" +"\t - frame : Specifies the new current frame for the animation\n"; + +PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self, + PyObject* args, + PyObject* kwds) { + float frame; + + if (PyArg_ParseTuple(args,"f",&frame)) + { + m_localtime = frame; + if (m_localtimem_endframe) + m_localtime=m_endframe; + } + + Py_INCREF(Py_None); + return Py_None; +} + +/* setProperty */ +char BL_ShapeActionActuator::SetProperty_doc[] = +"setProperty(prop)\n" +"\t - prop : A string specifying the property name to be used in\n" +"\t FromProp playback mode.\n"; + +PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + char *string; + + if (PyArg_ParseTuple(args,"s",&string)) + { + m_propname = string; + } + + Py_INCREF(Py_None); + return Py_None; +} + +/* getType */ +char BL_ShapeActionActuator::GetType_doc[] = +"getType()\n" +"\tReturns the operation mode of the actuator.\n"; +PyObject* BL_ShapeActionActuator::PyGetType(PyObject* self, + PyObject* args, + PyObject* kwds) { + return Py_BuildValue("h", m_playtype); +} + +/* setType */ +char BL_ShapeActionActuator::SetType_doc[] = +"setType(mode)\n" +"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n" +"\tSet the operation mode of the actuator.\n"; +PyObject* BL_ShapeActionActuator::PySetType(PyObject* self, + PyObject* args, + PyObject* kwds) { + short typeArg; + + if (!PyArg_ParseTuple(args, "h", &typeArg)) { + return NULL; + } + + switch (typeArg) { + case ACT_ACTION_PLAY: + case ACT_ACTION_FLIPPER: + case ACT_ACTION_LOOP_STOP: + case ACT_ACTION_LOOP_END: + case ACT_ACTION_FROM_PROP: + m_playtype = typeArg; + break; + default: + printf("Invalid type for action actuator: %d\n", typeArg); /* error */ + } + + Py_Return; +} + diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h new file mode 100644 index 00000000000..c4236a5208e --- /dev/null +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -0,0 +1,133 @@ +/** + * $Id: BL_ShapeActionActuator.h 14444 2008-04-16 22:40:48Z hos $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BL_SHAPEACTIONACTUATOR +#define BL_SHAPEACTIONACTUATOR + +#include "GEN_HashedPtr.h" +#include "SCA_IActuator.h" +#include "MT_Point3.h" +#include + +struct Key; +class BL_ShapeActionActuator : public SCA_IActuator +{ +public: + Py_Header; + BL_ShapeActionActuator(SCA_IObject* gameobj, + const STR_String& propname, + float starttime, + float endtime, + struct bAction *action, + short playtype, + short blendin, + short priority, + float stride, + PyTypeObject* T=&Type) + : SCA_IActuator(gameobj,T), + + m_lastpos(0, 0, 0), + m_blendframe(0), + m_flag(0), + m_startframe (starttime), + m_endframe(endtime) , + m_starttime(0), + m_localtime(starttime), + m_lastUpdate(-1), + m_blendin(blendin), + m_blendstart(0), + m_stridelength(stride), + m_playtype(playtype), + m_priority(priority), + m_action(action), + m_propname(propname) + { + }; + virtual ~BL_ShapeActionActuator(); + virtual bool Update(double curtime, bool frame); + virtual CValue* GetReplica(); + virtual void ProcessReplica(); + + void SetBlendTime (float newtime); + void BlendShape(struct Key* key, float weigth); + + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetAction); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendin); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetPriority); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetStart); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetEnd); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrame); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetProperty); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendtime); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetChannel); + + KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetAction); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetBlendin); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetPriority); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetStart); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetEnd); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetFrame); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetProperty); +// KX_PYMETHOD(BL_ActionActuator,GetChannel); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetType); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType); + + virtual PyObject* _getattr(const STR_String& attr); + +protected: + + void SetStartTime(float curtime); + void SetLocalTime(float curtime); + bool ClampLocalTime(); + + MT_Point3 m_lastpos; + float m_blendframe; + int m_flag; + /** The frame this action starts */ + float m_startframe; + /** The frame this action ends */ + float m_endframe; + /** The time this action started */ + float m_starttime; + /** The current time of the action */ + float m_localtime; + + float m_lastUpdate; + float m_blendin; + float m_blendstart; + float m_stridelength; + short m_playtype; + short m_priority; + struct bAction *m_action; + STR_String m_propname; + vector m_blendshape; +}; + +#endif + diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp new file mode 100644 index 00000000000..54b1041c328 --- /dev/null +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -0,0 +1,125 @@ +/** + * $Id: BL_ShapeDeformer.cpp 14444 2008-04-16 22:40:48Z hos $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifdef WIN32 +#pragma warning (disable : 4786) +#endif //WIN32 + +#include "MEM_guardedalloc.h" +#include "BL_ShapeDeformer.h" +#include "GEN_Map.h" +#include "STR_HashedString.h" +#include "RAS_IPolygonMaterial.h" +#include "BL_SkinMeshObject.h" + +//#include "BL_ArmatureController.h" +#include "DNA_armature_types.h" +#include "DNA_action_types.h" +#include "DNA_key_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "BKE_armature.h" +#include "BKE_action.h" +#include "BKE_key.h" +#include "MT_Point3.h" + +extern "C"{ + #include "BKE_lattice.h" +} + #include "BKE_utildefines.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" + +#define __NLA_DEFNORMALS +//#undef __NLA_DEFNORMALS + + +BL_ShapeDeformer::~BL_ShapeDeformer() +{ +}; + +RAS_Deformer *BL_ShapeDeformer::GetReplica() +{ + BL_ShapeDeformer *result; + + result = new BL_ShapeDeformer(*this); + result->ProcessReplica(); + return result; +} + +void BL_ShapeDeformer::ProcessReplica() +{ +} + +bool BL_ShapeDeformer::Update(void) +{ + bool bShapeUpdate = false; + bool bSkinUpdate = false; + + /* See if the object shape has changed */ + if (m_lastShapeUpdate != m_gameobj->GetLastFrame()) { + /* the key coefficient have been set already, we just need to blend the keys */ + Object* blendobj = m_gameobj->GetBlendObject(); + + // make sure the vertex weight cache is in line with this object + m_pMeshObject->CheckWeightCache(blendobj); + + /* we will blend the key directly in mvert array: it is used by armature as the start position */ + do_rel_key(0, m_bmesh->totvert, m_bmesh->totvert, (char *)m_bmesh->mvert->co, m_bmesh->key, 0); + + // Don't release the weight array as in Blender, it will most likely be reusable on next frame + // The weight array are ultimately deleted when the skin mesh is destroyed + + /* Update the current frame */ + m_lastShapeUpdate=m_gameobj->GetLastFrame(); + + // As we have changed, the mesh, the skin deformer must update as well. + // This will force the update + BL_SkinDeformer::ForceUpdate(); + bShapeUpdate = true; + } + // check for armature deform + bSkinUpdate = BL_SkinDeformer::Update(); + + if (!bSkinUpdate && bShapeUpdate) { + // this means that there is no armature, we still need to copy the vertex to m_transverts + // and update the normal (was not done after shape key calculation) + + /* store verts locally */ + VerifyStorage(); + + for (int v =0; vtotvert; v++) + VECCOPY(m_transverts[v], m_bmesh->mvert[v].co); + + RecalcNormals(); + bSkinUpdate = true; + } + return bSkinUpdate; +} diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h new file mode 100644 index 00000000000..920eae86b7e --- /dev/null +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -0,0 +1,93 @@ +/** + * $Id: BL_SkinDeformer.h 14444 2008-04-16 22:40:48Z hos $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BL_SHAPEDEFORMER +#define BL_SHAPEDEFORMER + +#ifdef WIN32 +#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning +#endif //WIN32 + +#include "BL_SkinDeformer.h" +#include "BL_DeformableGameObject.h" +#include + + +class BL_ShapeDeformer : public BL_SkinDeformer +{ +public: + virtual void Relink(GEN_Map*map) + { + void **h_obj = (*map)[m_gameobj]; + if (h_obj){ + m_gameobj = (BL_DeformableGameObject*)(*h_obj); + } + else + m_gameobj=NULL; + // relink the underlying skin deformer + BL_SkinDeformer::Relink(map); + }; + BL_ShapeDeformer(BL_DeformableGameObject *gameobj, + Object *bmeshobj, + BL_SkinMeshObject *mesh) + : + BL_SkinDeformer(bmeshobj, mesh), + m_lastShapeUpdate(-1), + m_gameobj(gameobj) + { + }; + + /* this second constructor is needed for making a mesh deformable on the fly. */ + BL_ShapeDeformer(BL_DeformableGameObject *gameobj, + struct Object *bmeshobj_old, + struct Object *bmeshobj_new, + class BL_SkinMeshObject *mesh, + bool release_object, + BL_ArmatureObject* arma = NULL) + : + BL_SkinDeformer(bmeshobj_old, bmeshobj_new, mesh, release_object, arma), + m_lastShapeUpdate(-1), + m_gameobj(gameobj) + { + }; + + virtual void ProcessReplica(); + virtual RAS_Deformer *GetReplica(); + virtual ~BL_ShapeDeformer(); + + bool Update (void); + +protected: + double m_lastShapeUpdate; + BL_DeformableGameObject* m_gameobj; + +}; + +#endif + diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 0f884674c09..78fc73f21a1 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -57,6 +57,19 @@ extern "C"{ #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS +BL_SkinDeformer::BL_SkinDeformer(struct Object *bmeshobj, + class BL_SkinMeshObject *mesh, + BL_ArmatureObject* arma) + : // + BL_MeshDeformer(bmeshobj, mesh), + m_armobj(arma), + m_lastArmaUpdate(-1), + m_defbase(&bmeshobj->defbase), + m_releaseobject(false) +{ + Mat4CpyMat4(m_obmat, bmeshobj->obmat); +}; + BL_SkinDeformer::BL_SkinDeformer( struct Object *bmeshobj_old, // Blender object that owns the new mesh struct Object *bmeshobj_new, // Blender object that owns the original mesh @@ -65,25 +78,22 @@ BL_SkinDeformer::BL_SkinDeformer( BL_ArmatureObject* arma) : BL_MeshDeformer(bmeshobj_old, mesh), m_armobj(arma), - m_lastUpdate(-1), + m_lastArmaUpdate(-1), m_defbase(&bmeshobj_old->defbase), m_releaseobject(release_object) { - Mat4CpyMat4(m_obmat, bmeshobj_old->obmat); - m_restoremat = true; // this is needed to ensure correct deformation of mesh: // the deformation is done with Blender's armature_deform_verts() function // that takes an object as parameter and not a mesh. The object matrice is used - // in the calculation, so we must force the same matrice to simulate a pure replacement of mesh - Mat4CpyMat4(bmeshobj_old->obmat, bmeshobj_new->obmat); + // in the calculation, so we must use the matrix of the original object to + // simulate a pure replacement of the mesh. + Mat4CpyMat4(m_obmat, bmeshobj_new->obmat); } BL_SkinDeformer::~BL_SkinDeformer() { if(m_releaseobject && m_armobj) m_armobj->Release(); - if (m_restoremat) - Mat4CpyMat4(m_objMesh->obmat, m_obmat); } bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) @@ -98,15 +108,13 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) MT_Point3 pt; // float co[3]; - if (!m_armobj) + if (!Update()) + // no need to update the cache return false; - Update(); - array = m_pMeshObject->GetVertexCache(mat); mvarray = m_pMeshObject->GetMVertCache(mat); diarray = m_pMeshObject->GetDIndexCache(mat); - // For each array for (i=0; iGetLastFrame()){ + if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()){ + float obmat[4][4]; // the original object matrice /* Do all of the posing necessary */ m_armobj->ApplyPose(); @@ -161,14 +170,27 @@ void BL_SkinDeformer::Update(void) for (int v =0; vtotvert; v++) VECCOPY(m_transverts[v], m_bmesh->mvert[v].co); + // save matrix first + Mat4CpyMat4(obmat, m_objMesh->obmat); + // set reference matrix + Mat4CpyMat4(m_objMesh->obmat, m_obmat); + armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, ARM_DEF_VGROUP, NULL, NULL ); + + // restore matrix + Mat4CpyMat4(m_objMesh->obmat, obmat); + #ifdef __NLA_DEFNORMALS RecalcNormals(); #endif /* Update the current frame */ - m_lastUpdate=m_armobj->GetLastFrame(); + m_lastArmaUpdate=m_armobj->GetLastFrame(); + + /* indicate that the m_transverts and normals are up to date */ + return true; } + return false; } /* XXX note: I propose to drop this function */ diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index 79f6453a25d..603e716fb1e 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -52,27 +52,20 @@ public: // void SetArmatureController (BL_ArmatureController *cont); virtual void Relink(GEN_Map*map) { - void **h_obj = (*map)[m_armobj]; - if (h_obj){ - SetArmature( (BL_ArmatureObject*)(*h_obj) ); + if (m_armobj){ + void **h_obj = (*map)[m_armobj]; + if (h_obj){ + SetArmature( (BL_ArmatureObject*)(*h_obj) ); + } + else + m_armobj=NULL; } - else - m_armobj=NULL; } void SetArmature (class BL_ArmatureObject *armobj); BL_SkinDeformer(struct Object *bmeshobj, class BL_SkinMeshObject *mesh, - BL_ArmatureObject* arma = NULL) - : // - BL_MeshDeformer(bmeshobj, mesh), - m_armobj(arma), - m_lastUpdate(-1), - m_defbase(&bmeshobj->defbase), - m_restoremat(false), - m_releaseobject(false) - { - }; + BL_ArmatureObject* arma = NULL); /* this second constructor is needed for making a mesh deformable on the fly. */ BL_SkinDeformer(struct Object *bmeshobj_old, @@ -84,16 +77,20 @@ public: virtual void ProcessReplica(); virtual RAS_Deformer *GetReplica(); virtual ~BL_SkinDeformer(); - void Update (void); + bool Update (void); bool Apply (class RAS_IPolyMaterial *polymat); + void ForceUpdate() + { + m_lastArmaUpdate = -1.0; + }; + protected: BL_ArmatureObject* m_armobj; // Our parent object float m_time; - double m_lastUpdate; + double m_lastArmaUpdate; ListBase* m_defbase; - float m_obmat[4][4]; // the original object matrice in case of dynamic mesh replacement - bool m_restoremat; + float m_obmat[4][4]; // the reference matrix for skeleton deform bool m_releaseobject; }; diff --git a/source/gameengine/Converter/BL_SkinMeshObject.cpp b/source/gameengine/Converter/BL_SkinMeshObject.cpp index 69feb72f5dc..9d3702b53a2 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.cpp +++ b/source/gameengine/Converter/BL_SkinMeshObject.cpp @@ -150,5 +150,63 @@ void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObje } +static get_def_index(Object* ob, const char* vgroup) +{ + bDeformGroup *curdef; + int index = 0; + + for (curdef = (bDeformGroup*)ob->defbase.first; curdef; curdef=(bDeformGroup*)curdef->next, index++) + if (!strcmp(curdef->name, vgroup)) + return index; + return -1; +} + +void BL_SkinMeshObject::CheckWeightCache(Object* obj) +{ + KeyBlock *kb; + int kbindex, defindex; + MDeformVert *dvert= NULL; + int totvert, i, j; + float *weights; + + if (!m_mesh->key) + return; + + for(kbindex=0, kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next, kbindex++) + { + // first check the cases where the weight must be cleared + if (kb->vgroup[0] == 0 || + m_mesh->dvert == NULL || + (defindex = get_def_index(obj, kb->vgroup)) == -1) { + if (kb->weights) { + MEM_freeN(kb->weights); + kb->weights = NULL; + } + m_cacheWeightIndex[kbindex] = -1; + } else if (m_cacheWeightIndex[kbindex] != defindex) { + // a weight array is required but the cache is not matching + if (kb->weights) { + MEM_freeN(kb->weights); + kb->weights = NULL; + } + + dvert= m_mesh->dvert; + totvert= m_mesh->totvert; + + weights= (float*)MEM_callocN(totvert*sizeof(float), "weights"); + + for (i=0; i < totvert; i++, dvert++) { + for(j=0; jtotweight; j++) { + if (dvert->dw[j].def_nr == defindex) { + weights[i]= dvert->dw[j].weight; + break; + } + } + } + kb->weights = weights; + m_cacheWeightIndex[kbindex] = defindex; + } + } +} diff --git a/source/gameengine/Converter/BL_SkinMeshObject.h b/source/gameengine/Converter/BL_SkinMeshObject.h index 2422d4cd4c9..cc2b8de600e 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.h +++ b/source/gameengine/Converter/BL_SkinMeshObject.h @@ -33,7 +33,7 @@ #ifdef WIN32 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 - +#include "MEM_guardedalloc.h" #include "RAS_MeshObject.h" #include "RAS_Deformer.h" #include "RAS_IPolygonMaterial.h" @@ -41,6 +41,7 @@ #include "BL_MeshDeformer.h" #include "DNA_mesh_types.h" +#include "DNA_key_types.h" #include "DNA_meshdata_types.h" typedef vector BL_MVertArray; @@ -105,6 +106,8 @@ class BL_SkinMeshObject : public RAS_MeshObject } protected: + vector m_cacheWeightIndex; + public: struct BL_MDVertMap { RAS_IPolyMaterial *mat; int index; }; vector > m_mvert_to_dvert_mapping; @@ -113,10 +116,33 @@ public: // void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,class RAS_BucketManager* bucketmgr); int FindVertexArray(int numverts,RAS_IPolyMaterial* polymat); - BL_SkinMeshObject(int lightlayer) : RAS_MeshObject (lightlayer) - { m_class = 1;}; + BL_SkinMeshObject(Mesh* mesh, int lightlayer) : RAS_MeshObject (mesh, lightlayer) + { + m_class = 1; + if (m_mesh && m_mesh->key) + { + KeyBlock *kb; + int count=0; + // initialize weight cache for shape objects + // count how many keys in this mesh + for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next) + count++; + m_cacheWeightIndex.resize(count,-1); + } + }; - virtual ~BL_SkinMeshObject(){ + virtual ~BL_SkinMeshObject() + { + if (m_mesh && m_mesh->key) + { + KeyBlock *kb; + // remove the weight cache to avoid memory leak + for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next) { + if(kb->weights) + MEM_freeN(kb->weights); + kb->weights= NULL; + } + } }; const vecIndexArrays& GetDIndexCache (RAS_IPolyMaterial* mat) @@ -154,6 +180,8 @@ public: return index; } + // for shape keys, + void CheckWeightCache(struct Object* obj); }; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 6b594e2e70b..f219c3a1472 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -84,6 +84,7 @@ #include "DNA_actuator_types.h" #include "DNA_packedFile_types.h" #include "BL_ActionActuator.h" +#include "BL_ShapeActionActuator.h" /* end of blender include block */ #include "BL_BlenderDataConversion.h" @@ -195,6 +196,30 @@ void BL_ConvertActuators(char* maggiename, else printf ("Discarded action actuator from non-armature object [%s]\n", blenderobject->id.name+2); } + case ACT_SHAPEACTION: + { + if (blenderobject->type==OB_MESH){ + bActionActuator* actact = (bActionActuator*) bact->data; + STR_String propname = (actact->name ? actact->name : ""); + + BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator( + gameobj, + propname, + actact->sta, + actact->end, + actact->act, + actact->type, // + 1, because Blender starts to count at zero, + actact->blendin, + actact->priority, + actact->stridelength + // Ketsji at 1, because zero is reserved for "NoDef" + ); + baseact= tmpbaseact; + break; + } + else + printf ("Discarded shape action actuator from non-mesh object [%s]\n", blenderobject->id.name+2); + } case ACT_IPO: { bIpoActuator* ipoact = (bIpoActuator*) bact->data; diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index 4b0fc741b8f..e8251e0ceaa 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -120,7 +120,7 @@ public: virtual int GetGameObjectType() {return -1;} typedef enum ObjectTypes { - OBJ_ARMATURE=0 + OBJ_ARMATURE=0, }ObjectTypes; }; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 5698c106b17..88b936aafd5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -78,6 +78,7 @@ KX_GameObject::KX_GameObject( m_bSuspendDynamics(false), m_bUseObjectColor(false), m_bIsNegativeScaling(false), + m_pBlenderObject(NULL), m_bVisible(true), m_pPhysicsController1(NULL), m_pPhysicsEnvironment(NULL), diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 8a90ec1463a..63a660617c4 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -55,7 +55,7 @@ struct KX_ClientObjectInfo; class RAS_MeshObject; class KX_IPhysicsController; class PHY_IPhysicsEnvironment; - +struct Object; /** * KX_GameObject is the main class for dynamic objects. @@ -71,6 +71,7 @@ protected: STR_String m_text; int m_layer; std::vector m_meshes; + struct Object* m_pBlenderObject; bool m_bSuspendDynamics; bool m_bUseObjectColor; @@ -359,6 +360,20 @@ public: return m_pSGNode; } + /** + * @section blender object accessor functions. + */ + + struct Object* GetBlenderObject( ) + { + return m_pBlenderObject; + } + + void SetBlenderObject( struct Object* obj) + { + m_pBlenderObject = obj; + } + /** * Set the Scene graph node for this game object. * warning - it is your responsibility to make sure diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index e4054e07475..fff33ca82fd 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -74,7 +74,7 @@ #include "KX_IPhysicsController.h" #include "KX_BlenderSceneConverter.h" -#include "BL_SkinDeformer.h" +#include "BL_ShapeDeformer.h" #include "BL_DeformableGameObject.h" // to get USE_BULLET! @@ -809,67 +809,80 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) -void KX_Scene::ReplaceMesh(class CValue* gameobj,void* meshobj) +void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) { - KX_GameObject* newobj = static_cast(gameobj); + KX_GameObject* gameobj = static_cast(obj); RAS_MeshObject* mesh = static_cast(meshobj); - const STR_String origMeshName = newobj->GetMesh(0)->GetName(); - - if( !newobj || !mesh ) + if(!gameobj || !mesh) { std::cout << "warning: invalid object, mesh will not be replaced" << std::endl; return; } - newobj->RemoveMeshes(); - newobj->AddMesh(mesh); - - bool isDeformer = (newobj->m_isDeformable && mesh->m_class == 1); - if(isDeformer) - { - /* FindBlendObjByGameObj() can return 0... - In the case of 0 here, - the replicated object that is calling this function - is some how not in the map. (which is strange because it's added) - So we will search the map by the first mesh name - to try to locate it there. If its still not found - spit some message rather than crash - */ - Object* blendobj = static_cast(m_logicmgr->FindBlendObjByGameObj(newobj)); - Object* oldblendobj = static_cast(m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName())); + gameobj->RemoveMeshes(); + gameobj->AddMesh(mesh); - bool parSkin = blendobj && blendobj->parent && blendobj->parent->type == OB_ARMATURE && blendobj->partype==PARSKEL; - bool releaseParent = true; - KX_GameObject* parentobj = newobj->GetParent(); - - - // lookup by mesh name if blendobj is 0 - if( !blendobj && parentobj ) + if (gameobj->m_isDeformable) + { + BL_DeformableGameObject* newobj = static_cast( gameobj ); + + if (newobj->m_pDeformer) { - blendobj = static_cast(m_logicmgr->FindBlendObjByGameMeshName(origMeshName)); - - // replace the mesh on the parent armature - if( blendobj ) - parSkin = parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE; - - // can't do it - else - std::cout << "warning: child object for " << parentobj->GetName().ReadPtr() - << " not found, and can't create!" << std::endl; + delete newobj->m_pDeformer; + newobj->m_pDeformer = NULL; } - if( blendobj && oldblendobj ) + if (mesh->m_class == 1) { - isDeformer = (static_cast(blendobj->data)->dvert != 0); - BL_DeformableGameObject* deformIter =0; - - // armature parent - if( parSkin && isDeformer ) + // we must create a new deformer but which one? + KX_GameObject* parentobj = newobj->GetParent(); + // this always return the original game object (also for replicate) + Object* blendobj = newobj->GetBlenderObject(); + // object that owns the new mesh + Object* oldblendobj = static_cast(m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName())); + Mesh* blendmesh = mesh->GetMesh(); + + bool bHasShapeKey = blendmesh->key != NULL && blendmesh->key->type==KEY_RELATIVE; + bool bHasDvert = blendmesh->dvert != NULL; + bool bHasArmature = + parentobj && // current parent is armature + parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE && + oldblendobj && // needed for mesh deform + blendobj->parent && // original object had armature (not sure this test is needed) + blendobj->parent->type == OB_ARMATURE && + blendobj->partype==PARSKEL && + blendmesh->dvert!=NULL; // mesh has vertex group + bool releaseParent = true; + + if (bHasShapeKey) + { + BL_ShapeDeformer* shapeDeformer; + if (bHasArmature) + { + shapeDeformer = new BL_ShapeDeformer( + newobj, + oldblendobj, blendobj, + static_cast(mesh), + true, + static_cast( parentobj ) + ); + releaseParent= false; + } + else + { + shapeDeformer = new BL_ShapeDeformer( + newobj, + oldblendobj, blendobj, + static_cast(mesh), + false, + NULL + ); + } + newobj->m_pDeformer = shapeDeformer; + } + else if (bHasArmature) { - deformIter = static_cast( newobj ); - delete deformIter->m_pDeformer; - BL_SkinDeformer* skinDeformer = new BL_SkinDeformer( oldblendobj, blendobj, static_cast(mesh), @@ -877,27 +890,22 @@ void KX_Scene::ReplaceMesh(class CValue* gameobj,void* meshobj) static_cast( parentobj ) ); releaseParent= false; - deformIter->m_pDeformer = skinDeformer; + newobj->m_pDeformer = skinDeformer; } - - // normal deformer - if( !parSkin && isDeformer) + else if (bHasDvert) { - deformIter = static_cast( newobj ); - delete deformIter->m_pDeformer; - BL_MeshDeformer* meshdeformer = new BL_MeshDeformer( oldblendobj, static_cast(mesh) ); - - deformIter->m_pDeformer = meshdeformer; + newobj->m_pDeformer = meshdeformer; } + + // release parent reference if its not being used + if( releaseParent && parentobj) + parentobj->Release(); } - // release parent reference if its not being used - if( releaseParent && parentobj) - parentobj->Release(); } - newobj->Bucketize(); + gameobj->Bucketize(); } diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index bea68e203a9..4e8484ab880 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -43,7 +43,7 @@ public: virtual ~RAS_Deformer(){}; virtual void Relink(GEN_Map*map)=0; virtual bool Apply(class RAS_IPolyMaterial *polymat)=0; - virtual void Update(void)=0; + virtual bool Update(void)=0; virtual RAS_Deformer *GetReplica()=0; protected: class RAS_MeshObject *m_pMesh; diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index db74110ceea..d7ab88a6b06 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -63,12 +63,13 @@ KX_ArrayOptimizer::~KX_ArrayOptimizer() -RAS_MeshObject::RAS_MeshObject(int lightlayer) +RAS_MeshObject::RAS_MeshObject(Mesh* mesh, int lightlayer) : m_bModified(true), m_lightlayer(lightlayer), m_zsort(false), m_MeshMod(true), - m_class(0) + m_class(0), + m_mesh(mesh) { } diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index d8e7a3391aa..d9aa133efb2 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -43,6 +43,7 @@ #include "GEN_HashedPtr.h" +struct Mesh; /** * This class holds an array of vertices and indicies. */ @@ -144,9 +145,10 @@ protected: GEN_Map m_matVertexArrayS; RAS_MaterialBucket::Set m_materials; + Mesh* m_mesh; public: // for now, meshes need to be in a certain layer (to avoid sorting on lights in realtime) - RAS_MeshObject(int lightlayer); + RAS_MeshObject(Mesh* mesh, int lightlayer); virtual ~RAS_MeshObject(); vector m_sortedMaterials; @@ -258,6 +260,7 @@ public: bool MeshModified(); void SetMeshModified(bool v){m_MeshMod = v;} + Mesh* GetMesh() { return m_mesh; } }; -- cgit v1.2.3 From 48c7c9d957896b0f3faa10c72cc86a55b5c39b88 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 18 Jun 2008 07:03:47 +0000 Subject: Forgot to set Id property on new shape action files --- source/gameengine/Converter/BL_ShapeActionActuator.cpp | 2 +- source/gameengine/Converter/BL_ShapeActionActuator.h | 2 +- source/gameengine/Converter/BL_ShapeDeformer.cpp | 2 +- source/gameengine/Converter/BL_ShapeDeformer.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 3e1369e1e9f..58d46d76e5b 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -1,5 +1,5 @@ /** -* $Id: BL_ShapeActionActuator.cpp 14444 2008-04-16 22:40:48Z hos $ +* $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index c4236a5208e..434a62a1233 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -1,5 +1,5 @@ /** - * $Id: BL_ShapeActionActuator.h 14444 2008-04-16 22:40:48Z hos $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 54b1041c328..b8a589c295a 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -1,5 +1,5 @@ /** - * $Id: BL_ShapeDeformer.cpp 14444 2008-04-16 22:40:48Z hos $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 920eae86b7e..9bbdde3fb2c 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -1,5 +1,5 @@ /** - * $Id: BL_SkinDeformer.h 14444 2008-04-16 22:40:48Z hos $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From d39154bb50571c07fa5f2425261f123034b0b1c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Jun 2008 09:06:51 +0000 Subject: bugfix, BGE, use vec.safe_normalized() rather then vec.normalized() because in some cases the ray_cast sensor could crash blender. --- source/gameengine/Ketsji/KX_RayCast.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index b88741625b6..89e2d645d54 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -49,7 +49,7 @@ bool KX_RayCast::RayTest(KX_IPhysicsController* ignore_controller, PHY_IPhysicsE // // returns true if an object was found, false if not. MT_Point3 frompoint(_frompoint); - const MT_Vector3 todir( (topoint - frompoint).normalized() ); + const MT_Vector3 todir( (topoint - frompoint).safe_normalized() ); PHY_IPhysicsController* hit_controller; PHY__Vector3 phy_pos; -- cgit v1.2.3 From 5cd4b6ac90da5e01da3d758480a404c1562cb792 Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Wed, 18 Jun 2008 09:52:31 +0000 Subject: Small fix to be able to compile Blender. --- source/gameengine/Converter/BL_SkinMeshObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_SkinMeshObject.cpp b/source/gameengine/Converter/BL_SkinMeshObject.cpp index 9d3702b53a2..49492923c7c 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.cpp +++ b/source/gameengine/Converter/BL_SkinMeshObject.cpp @@ -150,7 +150,7 @@ void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObje } -static get_def_index(Object* ob, const char* vgroup) +static int get_def_index(Object* ob, const char* vgroup) { bDeformGroup *curdef; int index = 0; -- cgit v1.2.3 From 3f488f4d7092f8636a7af7860bd9c134f92baecf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 18 Jun 2008 10:30:14 +0000 Subject: * Fix for a crash in game engine vertex array drawing with texfaces. * For 2D filters, don't require opengl 2.0 but just the extensions, so it works on computers without full 2.0 support too. * In debug mode, don't print memory statistics for preview render. --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 17 ++++++----------- .../RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp | 20 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 291890a8dde..e9ab4ccca8d 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -54,11 +54,13 @@ RAS_2DFilterManager::RAS_2DFilterManager(): -texturewidth(-1), textureheight(-1), +texname(-1), texturewidth(-1), textureheight(-1), canvaswidth(-1), canvasheight(-1), -numberoffilters(0),texname(-1) +numberoffilters(0) { - isshadersupported = GLEW_VERSION_2_0; + isshadersupported = GLEW_ARB_shader_objects && + GLEW_ARB_fragment_shader && GLEW_ARB_multitexture; + if(!isshadersupported) { std::cout<<"shaders not supported!" << std::endl; @@ -81,7 +83,6 @@ RAS_2DFilterManager::~RAS_2DFilterManager() unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) { GLuint program = 0; -#if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); GLint success; @@ -117,7 +118,7 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) std::cout << "2dFilters - Shader program validation error" << std::endl; return 0; } -#endif + return program; } @@ -151,7 +152,6 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) { -#if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) GLint uniformLoc; glUseProgramObjectARB(shaderprogram); uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); @@ -178,14 +178,11 @@ void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) { glUniform1fARB(uniformLoc,textureheight); } -#endif } void RAS_2DFilterManager::EndShaderProgram() { -#if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) glUseProgramObjectARB(0); -#endif } void RAS_2DFilterManager::SetupTexture() @@ -295,7 +292,6 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str { if(!isshadersupported) return; -#if defined(GL_ARB_shader_objects) && defined(WITH_GLEXT) if(pass<0 || pass>=MAX_RENDER_PASS) return; @@ -336,5 +332,4 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str m_filters[pass] = CreateShaderProgram(mode); m_enabled[pass] = 1; } -#endif } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index 67c72aacdcf..ce76318c2ce 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -142,6 +142,9 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays glColor3d(0,0,0); } + EnableTextures(false); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + // use glDrawElements to draw each vertexarray for (vt=0;vt Date: Wed, 18 Jun 2008 21:22:17 +0000 Subject: BGE patch #13625: getLinearVelocity() rewrite to use only vector and matrix operations --- source/gameengine/Ketsji/KX_GameObject.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 88b936aafd5..eaa6564ba84 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -646,8 +646,8 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis) MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { - MT_Vector3 velocity(0.0,0.0,0.0); - MT_Matrix3x3 ori, locvel; + MT_Vector3 velocity(0.0,0.0,0.0), locvel; + MT_Matrix3x3 ori; int i, j; if (m_pPhysicsController1) { @@ -657,11 +657,8 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { ori = GetSGNode()->GetWorldOrientation(); - for(i=0; i < 3; i++) - for(j=0; j < 3; j++) - locvel[i][j]= velocity[i]*ori[i][j]; - for(i=0; i < 3; i++) - velocity[i] = locvel[0][i] + locvel[1][i] + locvel[2][i]; + locvel = velocity * ori; + return locvel; } } return velocity; -- cgit v1.2.3 From de7619991c73bdc93294c8ff892e9df92e0f681d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 19 Jun 2008 14:40:46 +0000 Subject: BGE bug fix for new shape action: mesh with multiple materials did not deform properly --- source/gameengine/Converter/BL_ShapeDeformer.cpp | 2 ++ source/gameengine/Converter/BL_SkinDeformer.cpp | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index b8a589c295a..3ae634905b9 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -118,7 +118,9 @@ bool BL_ShapeDeformer::Update(void) for (int v =0; vtotvert; v++) VECCOPY(m_transverts[v], m_bmesh->mvert[v].co); +#ifdef __NLA_DEFNORMALS RecalcNormals(); +#endif bSkinUpdate = true; } return bSkinUpdate; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 78fc73f21a1..1015221c392 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -108,9 +108,7 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) MT_Point3 pt; // float co[3]; - if (!Update()) - // no need to update the cache - return false; + Update(); array = m_pMeshObject->GetVertexCache(mat); mvarray = m_pMeshObject->GetMVertCache(mat); -- cgit v1.2.3 From a1e78a0cca624061929eb3bae4420be5c16fd540 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 20 Jun 2008 20:54:29 +0000 Subject: * Documented that get/setOrientation use an inverted rotation matrix * OB prefix is needed when specifying the object for the Message Actuator, this is very bad since other object fields in the BGE dont need this prefix - a real fix would need do_versions to keep old files running. * RotationMatrix was all nans if the rotation vector axis was 0,0,0, Changed so in this case just return a matrix that doesn't rotate anything, spent some angry hours to find these issues, maybe this will save others the hassle ;) --- source/gameengine/PyDoc/KX_GameObject.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 678df59e4a9..ff55f975543 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -50,7 +50,7 @@ class KX_GameObject: """ Sets the game object's orientation. - @type orn: 3x3 rotation matrix, or Quaternion. + @type orn: 3x3 inverted rotation matrix, or Quaternion. @param orn: a rotation matrix specifying the new rotation. """ def alignAxisToVect(vect, axis): @@ -69,7 +69,7 @@ class KX_GameObject: """ Gets the game object's orientation. - @rtype: 3x3 rotation matrix + @rtype: 3x3 inverted rotation matrix @return: The game object's rotation matrix """ def getLinearVelocity(local): -- cgit v1.2.3 From 5372def2b069699809cf9439381b03364137adb5 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 22 Jun 2008 14:23:57 +0000 Subject: BGE patch: add state engine support in the logic bricks. This patch introduces a simple state engine system with the logic bricks. This system features full backward compatibility, multiple active states, multiple state transitions, automatic disabling of sensor and actuators, full GUI support and selective display of sensors and actuators. Note: Python API is available but not documented yet. It will be added asap. State internals =============== The state system is object based. The current state mask is stored in the object as a 32 bit value; each bit set in the mask is an active state. The controllers have a state mask too but only one bit can be set: a controller belongs to a single state. The game engine will only execute controllers that belong to active states. Sensors and actuators don't have a state mask but are effectively attached to states via their links to the controllers. Sensors and actuators can be connected to more than one state. When a controller becomes inactive because of a state change, its links to sensors and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated, i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated, the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that it can react as if the game just started when it gets reconnected to an active controller. For example, an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more controllers of a single state) will generate a pulse each time the state becomes active. This feature is not available on all sensors, see the notes below. GUI === This system system is fully configurable through the GUI: the object state mask is visible under the object bar in the controller's colum as an array of buttons just like the 3D view layer mask. Click on a state bit to only display the controllers of that state. You can select more than one state with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object. The Ini button sets the state mask back to the object default state. You can change the default state of object by first selecting the desired state mask and storing using the menu under the State button. If you define a default state mask, it will be loaded into the object state make when you load the blend file or when you run the game under the blenderplayer. However, when you run the game under Blender, the current selected state mask will be used as the startup state for the object. This allows you to test specific state during the game design. The controller display the state they belong to with a new button in the controller header. When you add a new controller, it is added by default in the lowest enabled state. You can change the controller state by clicking on the button and selecting another state. If more than one state is enabled in the object state mask, controllers are grouped by state for more readibility. The new Sta button in the sensor and actuator column header allows you to display only the sensors and actuators that are linked to visible controllers. A new state actuator is available to modify the state during the game. It defines a bit mask and the operation to apply on the current object state mask: Cpy: the bit mask is copied to the object state mask. Add: the bits that set in the bit mask will be turned on in the object state mask. Sub: the bits that set in the bit mask will be turned off in the object state mask. Inv: the bits that set in the bit mask will be inverted in the objecyy state mask. Notes ===== - Although states have no name, a simply convention consists in using the name of the first controller of the state as the state name. The GUI will support that convention by displaying as a hint the name of the first controller of the state when you move the mouse over a state bit of the object state mask or of the state actuator bit mask. - Each object has a state mask and each object can have a state engine but if several objects are part of a logical group, it is recommended to put the state engine only in the main object and to link the controllers of that object to the sensors and actuators of the different objects. - When loading an old blend file, the state mask of all objects and controllers are initialized to 1 so that all the controllers belong to this single state. This ensures backward compatibility with existing game. - When the state actuator is activated at the same time as other actuators, these actuators are guaranteed to execute before being eventually disabled due to the state change. This is useful for example to send a message or update a property at the time of changing the state. - Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they are acticated again, they will behave as follow: * keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive to new key press. * collision sensor: objects already colliding won't be detected. Only new collisions are detected. * near and radar sensor: same as collision sensor. --- .../Converter/BL_BlenderDataConversion.cpp | 8 + .../gameengine/Converter/KX_ConvertActuators.cpp | 15 +- .../gameengine/Converter/KX_ConvertControllers.cpp | 1 + source/gameengine/GameLogic/SCA_AlwaysSensor.cpp | 7 +- source/gameengine/GameLogic/SCA_AlwaysSensor.h | 2 + source/gameengine/GameLogic/SCA_IActuator.cpp | 10 + source/gameengine/GameLogic/SCA_IActuator.h | 7 + source/gameengine/GameLogic/SCA_IController.cpp | 97 +++++++++- source/gameengine/GameLogic/SCA_IController.h | 4 + source/gameengine/GameLogic/SCA_IObject.cpp | 13 +- source/gameengine/GameLogic/SCA_IObject.h | 19 +- source/gameengine/GameLogic/SCA_ISensor.cpp | 23 ++- source/gameengine/GameLogic/SCA_ISensor.h | 10 + source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 6 +- source/gameengine/GameLogic/SCA_JoystickSensor.h | 1 + source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 11 +- source/gameengine/GameLogic/SCA_KeyboardSensor.h | 2 + source/gameengine/GameLogic/SCA_LogicManager.cpp | 20 +- source/gameengine/GameLogic/SCA_MouseSensor.cpp | 6 +- source/gameengine/GameLogic/SCA_MouseSensor.h | 2 +- source/gameengine/GameLogic/SCA_PropertySensor.cpp | 6 +- source/gameengine/GameLogic/SCA_PropertySensor.h | 1 + source/gameengine/GameLogic/SCA_RandomSensor.cpp | 16 +- source/gameengine/GameLogic/SCA_RandomSensor.h | 1 + .../Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 7 +- .../Ketsji/KXNetwork/KX_NetworkMessageSensor.h | 1 + source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 5 +- source/gameengine/Ketsji/KX_MouseFocusSensor.h | 1 + source/gameengine/Ketsji/KX_RadarSensor.cpp | 1 - source/gameengine/Ketsji/KX_RaySensor.cpp | 14 +- source/gameengine/Ketsji/KX_RaySensor.h | 1 + source/gameengine/Ketsji/KX_Scene.cpp | 2 - source/gameengine/Ketsji/KX_StateActuator.cpp | 207 +++++++++++++++++++++ source/gameengine/Ketsji/KX_StateActuator.h | 83 +++++++++ source/gameengine/Ketsji/KX_TouchSensor.cpp | 14 +- source/gameengine/Ketsji/KX_TouchSensor.h | 1 + 36 files changed, 582 insertions(+), 43 deletions(-) create mode 100644 source/gameengine/Ketsji/KX_StateActuator.cpp create mode 100644 source/gameengine/Ketsji/KX_StateActuator.h (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 32946267202..21c18634e21 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2324,6 +2324,14 @@ void BL_ConvertBlenderObjects(struct Main* maggie, bool isInActiveLayer = (blenderobj->lay & activeLayerBitInfo)!=0; BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,keydev,executePriority,activeLayerBitInfo,isInActiveLayer,canvas,converter); } + // apply the initial state to controllers + for ( i=0;iGetCount();i++) + { + KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); + struct Object* blenderobj = converter->FindBlenderObject(gameobj); + gameobj->SetState(blenderobj->state); + } + #endif //CONVERT_LOGIC logicbrick_conversionlist->Release(); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index f219c3a1472..c02c2a29595 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -56,6 +56,7 @@ #include "KX_ConstraintActuator.h" #include "KX_CameraActuator.h" #include "KX_GameActuator.h" +#include "KX_StateActuator.h" #include "KX_VisibilityActuator.h" #include "KX_SCA_AddObjectActuator.h" #include "KX_SCA_EndObjectActuator.h" @@ -857,7 +858,19 @@ void BL_ConvertActuators(char* maggiename, baseact = tmp_vis_act; } break; - + + case ACT_STATE: + { + bStateActuator *sta_act = (bStateActuator *) bact->data; + KX_StateActuator * tmp_sta_act = NULL; + + tmp_sta_act = + new KX_StateActuator(gameobj, sta_act->type, sta_act->mask); + + baseact = tmp_sta_act; + } + break; + case ACT_2DFILTER: { bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data; diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index a26cfa95b6d..179dd9f8478 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -161,6 +161,7 @@ void BL_ConvertControllers( if (gamecontroller) { gamecontroller->SetExecutePriority(executePriority++); + gamecontroller->SetState(bcontr->state_mask); STR_String uniquename = bcontr->name; uniquename += "#CONTR#"; uniqueint++; diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp index 67df5d091ab..f9fbf2387c4 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp @@ -53,10 +53,13 @@ SCA_AlwaysSensor::SCA_AlwaysSensor(class SCA_EventManager* eventmgr, : SCA_ISensor(gameobj,eventmgr, T) { //SetDrawColor(255,0,0); - m_alwaysresult = true; + Init(); } - +void SCA_AlwaysSensor::Init() +{ + m_alwaysresult = true; +} SCA_AlwaysSensor::~SCA_AlwaysSensor() { diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.h b/source/gameengine/GameLogic/SCA_AlwaysSensor.h index 474ed025432..8bf2a8aa98e 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h +++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.h @@ -45,6 +45,8 @@ public: virtual CValue* GetReplica(); virtual bool Evaluate(CValue* event); virtual bool IsPositiveTrigger(); + virtual void Init(); + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp index 568d0eb4a89..eeca2d7b44c 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.cpp +++ b/source/gameengine/GameLogic/SCA_IActuator.cpp @@ -36,6 +36,7 @@ using namespace std; SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj, PyTypeObject* T) : + m_links(0), SCA_ILogicBrick(gameobj,T) { // nothing to do @@ -109,3 +110,12 @@ SCA_IActuator::~SCA_IActuator() RemoveAllEvents(); } +void SCA_IActuator::DecLink() +{ + m_links--; + if (m_links < 0) + { + printf("Warning: actuator %s has negative m_links: %d\n", m_name.Ptr(), m_links); + m_links = 0; + } +} diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h index b802aa4b298..774b27c5ad4 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.h +++ b/source/gameengine/GameLogic/SCA_IActuator.h @@ -34,8 +34,11 @@ class SCA_IActuator : public SCA_ILogicBrick { + friend class SCA_LogicManager; protected: std::vector m_events; + int m_links; // number of active links to controllers + // when 0, the actuator is automatically stopped void RemoveAllEvents(); public: @@ -83,6 +86,10 @@ public: */ bool IsNegativeEvent() const; virtual ~SCA_IActuator(); + + void IncLink() { m_links++; } + void DecLink(); + bool IsNoLink() const { return !m_links; } }; #endif //__KX_IACTUATOR diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index 5cb62678c6b..bbe5a51db3c 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -29,6 +29,7 @@ #include "SCA_IController.h" #include "SCA_LogicManager.h" #include "SCA_IActuator.h" +#include "SCA_ISensor.h" #ifdef HAVE_CONFIG_H #include @@ -37,6 +38,7 @@ SCA_IController::SCA_IController(SCA_IObject* gameobj, PyTypeObject* T) : + m_statemask(0), SCA_ILogicBrick(gameobj,T) { } @@ -45,6 +47,7 @@ SCA_IController::SCA_IController(SCA_IObject* gameobj, SCA_IController::~SCA_IController() { + UnlinkAllActuators(); } @@ -65,6 +68,14 @@ const std::vector& SCA_IController::GetLinkedActuators() void SCA_IController::UnlinkAllSensors() { + if (IsActive()) + { + std::vector::iterator sensit; + for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit) + { + (*sensit)->DecLink(); + } + } m_linkedsensors.clear(); } @@ -72,6 +83,14 @@ void SCA_IController::UnlinkAllSensors() void SCA_IController::UnlinkAllActuators() { + if (IsActive()) + { + std::vector::iterator actit; + for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit) + { + (*actit)->DecLink(); + } + } m_linkedactuators.clear(); } @@ -95,26 +114,94 @@ void SCA_IController::Trigger(SCA_LogicManager* logicmgr) void SCA_IController::LinkToActuator(SCA_IActuator* actua) { m_linkedactuators.push_back(actua); + if (IsActive()) + { + actua->IncLink(); + } } void SCA_IController::UnlinkActuator(class SCA_IActuator* actua) { std::vector::iterator actit; - std::vector::iterator actfound = m_linkedactuators.end(); for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit) { if ((*actit) == actua) - actfound = actit; + { + break; + } } - if (!(actfound==m_linkedactuators.end())) + if (!(actit==m_linkedactuators.end())) { - m_linkedactuators.erase(actfound); + m_linkedactuators.erase(actit); + if (IsActive()) + { + (*actit)->DecLink(); + } } - } void SCA_IController::LinkToSensor(SCA_ISensor* sensor) { m_linkedsensors.push_back(sensor); + if (IsActive()) + { + sensor->IncLink(); + } +} + +void SCA_IController::UnlinkSensor(class SCA_ISensor* sensor) +{ + std::vector::iterator sensit; + for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit) + { + if ((*sensit) == sensor) + { + break; + } + + } + if (!(sensit==m_linkedsensors.end())) + { + m_linkedsensors.erase(sensit); + if (IsActive()) + { + (*sensit)->DecLink(); + } + } } + +void SCA_IController::ApplyState(unsigned int state) +{ + std::vector::iterator actit; + std::vector::iterator sensit; + + if (m_statemask & state) + { + if (!IsActive()) + { + // reactive the controller, all the links to actuator are valid again + for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit) + { + (*actit)->IncLink(); + } + for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit) + { + (*sensit)->IncLink(); + } + SetActive(true); + } + } else if (IsActive()) + { + for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit) + { + (*actit)->DecLink(); + } + for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit) + { + (*sensit)->DecLink(); + } + SetActive(false); + } +} + diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h index 79e956dec4e..f67c0942eb4 100644 --- a/source/gameengine/GameLogic/SCA_IController.h +++ b/source/gameengine/GameLogic/SCA_IController.h @@ -36,6 +36,7 @@ class SCA_IController : public SCA_ILogicBrick protected: std::vector m_linkedsensors; std::vector m_linkedactuators; + unsigned int m_statemask; public: SCA_IController(SCA_IObject* gameobj,PyTypeObject* T); virtual ~SCA_IController(); @@ -47,6 +48,9 @@ public: void UnlinkAllSensors(); void UnlinkAllActuators(); void UnlinkActuator(class SCA_IActuator* actua); + void UnlinkSensor(class SCA_ISensor* sensor); + void SetState(unsigned int state) { m_statemask = state; } + void ApplyState(unsigned int state); }; diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 6df9e23f3fa..826e7bbdf0e 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -40,7 +40,7 @@ MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0); -SCA_IObject::SCA_IObject(PyTypeObject* T): CValue(T) +SCA_IObject::SCA_IObject(PyTypeObject* T): m_state(0), CValue(T) { m_suspended = false; } @@ -329,6 +329,17 @@ void SCA_IObject::Resume(void) } } +void SCA_IObject::SetState(unsigned int state) +{ + m_state = state; + // update the status of the controllers + SCA_ControllerList::iterator contit; + for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++) + { + (*contit)->ApplyState(m_state); + } +} + /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index e8251e0ceaa..07b4310a91e 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -67,7 +67,12 @@ protected: * Ignore updates? */ bool m_suspended; - + + /** + * current state = bit mask of state that are active + */ + unsigned int m_state; + public: SCA_IObject(PyTypeObject* T=&Type); @@ -111,7 +116,17 @@ public: * Resume progress */ void Resume(void); - + + /** + * Set the object state + */ + void SetState(unsigned int state); + + /** + * Get the object state + */ + unsigned int GetState(void) { return m_state; } + // const class MT_Point3& ConvertPythonPylist(PyObject* pylist); // here come the python forwarded methods diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 9fdee0c19da..1c29eb27be5 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -52,6 +52,7 @@ SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj, SCA_ILogicBrick(gameobj,T), m_triggered(false) { + m_links = 0; m_suspended = false; m_invert = false; m_pos_ticks = 0; @@ -111,6 +112,25 @@ void SCA_ISensor::Resume() { m_suspended = false; } +void SCA_ISensor::Init() { + printf("Sensor %s has no init function, please report this bug to Blender.org\n", m_name); +} + +void SCA_ISensor::DecLink() { + m_links--; + if (m_links < 0) + { + printf("Warning: sensor %s has negative m_links: %d\n", m_name.Ptr(), m_links); + m_links = 0; + } + if (!m_links) + { + // sensor is detached from all controllers, initialize it so that it + // is fresh as at startup when it is reattached again. + Init(); + } +} + /* python integration */ PyTypeObject SCA_ISensor::Type = { @@ -177,7 +197,8 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event) { // calculate if a __triggering__ is wanted - if (!m_suspended) { + // don't evaluate a sensor that is not connected to any controller + if (m_links && !m_suspended) { bool result = this->Evaluate(event); if (result) { logicmgr->AddActivatedSensor(this); diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index e14fb34241a..292b2d160ae 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -64,6 +64,9 @@ class SCA_ISensor : public SCA_ILogicBrick /** Sensor must ignore updates? */ bool m_suspended; + /** number of connections to controller */ + int m_links; + /** Pass the activation on to the logic manager.*/ void SignalActivation(class SCA_LogicManager* logicmgr); @@ -81,6 +84,7 @@ public: void Activate(class SCA_LogicManager* logicmgr,CValue* event); virtual bool Evaluate(CValue* event) = 0; virtual bool IsPositiveTrigger(); + virtual void Init(); virtual PyObject* _getattr(const STR_String& attr); virtual CValue* GetReplica()=0; @@ -114,6 +118,12 @@ public: /** Resume sensing. */ void Resume(); + void IncLink() + { m_links++; } + void DecLink(); + bool IsNoLink() const + { return !m_links; } + /* Python functions: */ KX_PYMETHOD_DOC(SCA_ISensor,IsPositive); KX_PYMETHOD_DOC(SCA_ISensor,GetUsePosPulseMode); diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index b0e7fee130d..81938f05af1 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -64,9 +64,13 @@ std::cout << " button flag "<< m_buttonf << std::endl; std::cout << " hat " << m_hat << std::endl; std::cout << " hat flag " << m_hatf << std::endl; */ - m_istrig=0; + Init(); } +void SCA_JoystickSensor::Init() +{ + m_istrig=0; +} SCA_JoystickSensor::~SCA_JoystickSensor() { diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index 2fbe1edf1e7..69068da6494 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -95,6 +95,7 @@ public: virtual bool Evaluate(CValue* event); virtual bool IsPositiveTrigger(); + virtual void Init(); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index f13b1bcf4c9..c6c06846e3b 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -62,7 +62,7 @@ SCA_KeyboardSensor::SCA_KeyboardSensor(SCA_KeyboardManager* keybdmgr, if (hotkey == SCA_IInputDevice::KX_ESCKEY) keybdmgr->GetInputDevice()->HookEscape(); // SetDrawColor(0xff0000ff); - m_val=0; + Init(); } @@ -71,7 +71,14 @@ SCA_KeyboardSensor::~SCA_KeyboardSensor() { } - +void SCA_KeyboardSensor::Init() +{ + // this function is used when the sensor is disconnected from all controllers + // by the state engine. It reinitializes the sensor as if it was just created. + // However, if the target key is pressed when the sensor is reactivated, it + // will not generated an event (see remark in Evaluate()). + m_val = 0; +} CValue* SCA_KeyboardSensor::GetReplica() { diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h index e87eddecd32..b86f6931d27 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h @@ -114,6 +114,8 @@ public: PyTypeObject* T=&Type ); virtual ~SCA_KeyboardSensor(); virtual CValue* GetReplica(); + virtual void Init(); + short int GetHotkey(); virtual bool Evaluate(CValue* event); diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 49f01d643e5..fb1a2c29eb6 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -165,6 +165,11 @@ void* SCA_LogicManager::FindBlendObjByGameMeshName(const STR_String& gamemeshnam void SCA_LogicManager::RemoveSensor(SCA_ISensor* sensor) { + controllerlist contlist = m_sensorcontrollermapje[sensor]; + for (controllerlist::const_iterator c= contlist.begin();!(c==contlist.end());c++) + { + (*c)->UnlinkSensor(sensor); + } m_sensorcontrollermapje.erase(sensor); for (vector::const_iterator ie=m_eventmanagers.begin(); @@ -176,6 +181,8 @@ void SCA_LogicManager::RemoveSensor(SCA_ISensor* sensor) void SCA_LogicManager::RemoveController(SCA_IController* controller) { + controller->UnlinkAllSensors(); + controller->UnlinkAllActuators(); std::map::iterator sit; for (sit = m_sensorcontrollermapje.begin();!(sit==m_sensorcontrollermapje.end());++sit) { @@ -236,7 +243,8 @@ void SCA_LogicManager::BeginFrame(double curtime, double fixedtime) !(c==contlist.end());c++) { SCA_IController* contr = *c;//controllerarray->at(c); - triggeredControllerSet.insert(SmartControllerPtr(contr,0)); + if (contr->IsActive()) + triggeredControllerSet.insert(SmartControllerPtr(contr,0)); } //sensor->SetActive(false); } @@ -273,6 +281,16 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame) (*ia)->SetActive(false); //m_activeactuators.pop_back(); + } else if ((*ia)->IsNoLink()) + { + // This actuator has no more links but it still active + // make sure it will get a negative event on next frame to stop it + // Do this check after Update() rather than before to make sure + // that all the actuators that are activated at same time than a state + // actuator have a chance to execute. + CValue* event = new CBoolValue(false); + (*ia)->RemoveAllEvents(); + (*ia)->AddEvent(event); } } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 8810b7470ed..11e67eda014 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -58,7 +58,6 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, { m_mousemode = mousemode; m_triggermode = true; - m_val = 0; /* stores the latest attribute */ switch (m_mousemode) { case KX_MOUSESENSORMODE_LEFTBUTTON: @@ -79,7 +78,12 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, default: ; /* ignore, no hotkey */ } + Init(); +} +void SCA_MouseSensor::Init() +{ + m_val = 0; /* stores the latest attribute */ } SCA_MouseSensor::~SCA_MouseSensor() diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h index 86c9d96a800..26a1c5e3fd2 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.h +++ b/source/gameengine/GameLogic/SCA_MouseSensor.h @@ -96,7 +96,7 @@ class SCA_MouseSensor : public SCA_ISensor virtual ~SCA_MouseSensor(); virtual CValue* GetReplica(); virtual bool Evaluate(CValue* event); - + virtual void Init(); virtual bool IsPositiveTrigger(); short int GetModeKey(); SCA_IInputDevice::KX_EnumInputs GetHotKey(); diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index f1fcb18d32e..d6eb246ffd2 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -57,7 +57,6 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, m_lastresult(false), m_range_expr(NULL) { - m_recentresult=false; //CParser pars; //pars.SetContext(this->AddRef()); //CValue* resultval = m_rightexpr->Calculate(); @@ -73,7 +72,12 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, { PrecalculateRangeExpression(); } + Init(); +} +void SCA_PropertySensor::Init() +{ + m_recentresult = false; } void SCA_PropertySensor::PrecalculateRangeExpression() diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h index 81c9b958f25..6871cb3afdc 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.h +++ b/source/gameengine/GameLogic/SCA_PropertySensor.h @@ -77,6 +77,7 @@ public: virtual void Delete(); virtual ~SCA_PropertySensor(); virtual CValue* GetReplica(); + virtual void Init(); void PrecalculateRangeExpression(); bool CheckPropertyCondition(); diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 0e856e0d6bb..3626522e49a 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -50,16 +50,9 @@ SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr, PyTypeObject* T) : SCA_ISensor(gameobj,eventmgr, T) { - m_iteration = 0; - m_interval = 0; - m_lastdraw = false; - // m_basegenerator is never deleted => memory leak m_basegenerator = new SCA_RandomNumberGenerator(startseed); - m_currentDraw = m_basegenerator->Draw(); - //registration is done globally, don't do it here - //Note: it was probably done to work around a bug in Evaluate(). It is now fixed - //RegisterToManager(); + Init(); } @@ -69,6 +62,13 @@ SCA_RandomSensor::~SCA_RandomSensor() /* Nothing to be done here. */ } +void SCA_RandomSensor::Init() +{ + m_iteration = 0; + m_interval = 0; + m_lastdraw = false; + m_currentDraw = m_basegenerator->Draw(); +} CValue* SCA_RandomSensor::GetReplica() diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h index cc54179aa4e..d29bfb6837a 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.h +++ b/source/gameengine/GameLogic/SCA_RandomSensor.h @@ -54,6 +54,7 @@ public: virtual CValue* GetReplica(); virtual bool Evaluate(CValue* event); virtual bool IsPositiveTrigger(); + virtual void Init(); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index e320453b7aa..027cb2a0ffa 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -58,10 +58,15 @@ KX_NetworkMessageSensor::KX_NetworkMessageSensor( m_NetworkScene(NetworkScene), m_subject(subject), m_frame_message_count (0), - m_IsUp(false), m_BodyList(NULL), m_SubjectList(NULL) { + Init(); +} + +void KX_NetworkMessageSensor::Init() +{ + m_IsUp = false; } KX_NetworkMessageSensor::~KX_NetworkMessageSensor() diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index d051b715aab..6fd92d17be3 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -65,6 +65,7 @@ public: virtual CValue* GetReplica(); virtual bool Evaluate(CValue* event); virtual bool IsPositiveTrigger(); + virtual void Init(); void EndFrame(); /* ------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 60b90138abe..f306f0dbfbb 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -69,11 +69,14 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, m_gp_canvas(canvas), m_kxscene(kxscene) { + Init(); +} +void KX_MouseFocusSensor::Init() +{ m_mouse_over_in_previous_frame = false; m_positive_event = false; m_hitObject = 0; - } bool KX_MouseFocusSensor::Evaluate(CValue* event) diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index 86f32fbf4be..b011ebe1288 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -68,6 +68,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor * @attention Overrides default evaluate. */ virtual bool Evaluate(CValue* event); + virtual void Init(); virtual bool IsPositiveTrigger() { bool result = m_positive_event; diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 31fffffa3c1..987e0b946b2 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -71,7 +71,6 @@ KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr, //sumoObj->setClientObject(&m_client_info); } - KX_RadarSensor::~KX_RadarSensor() { diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index a85dc61cac8..02b814105b4 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -60,17 +60,19 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr, m_bFindMaterial(bFindMaterial), m_distance(distance), m_scene(ketsjiScene), - m_bTriggered(false), - m_axis(axis), - m_rayHit(false), - m_hitObject(NULL) + m_axis(axis) { - + Init(); } - +void KX_RaySensor::Init() +{ + m_bTriggered = false; + m_rayHit = false; + m_hitObject = NULL; +} KX_RaySensor::~KX_RaySensor() { diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index 8a317ffaa07..f4305b053d1 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -66,6 +66,7 @@ public: virtual bool Evaluate(CValue* event); virtual bool IsPositiveTrigger(); + virtual void Init(); bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index fff33ca82fd..1526709f425 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -754,8 +754,6 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) for (SCA_ControllerList::iterator itc = controllers.begin(); !(itc==controllers.end());itc++) { - (*itc)->UnlinkAllSensors(); - (*itc)->UnlinkAllActuators(); m_logicmgr->RemoveController(*itc); } diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp new file mode 100644 index 00000000000..95a79f0c480 --- /dev/null +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -0,0 +1,207 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * Actuator to toggle visibility/invisibility of objects + */ + +#include "KX_StateActuator.h" +#include "KX_GameObject.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +KX_StateActuator::KX_StateActuator( + SCA_IObject* gameobj, + int operation, + unsigned int mask, + PyTypeObject* T + ) + : SCA_IActuator(gameobj,T), + m_operation(operation), + m_mask(mask) +{ + // intentionally empty +} + +KX_StateActuator::~KX_StateActuator( + void + ) +{ + // intentionally empty +} + +CValue* +KX_StateActuator::GetReplica( + void + ) +{ + KX_StateActuator* replica = new KX_StateActuator(*this); + replica->ProcessReplica(); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + return replica; +} + +bool +KX_StateActuator::Update() +{ + bool bNegativeEvent = IsNegativeEvent(); + unsigned int objMask; + + RemoveAllEvents(); + if (bNegativeEvent) return false; + + KX_GameObject *obj = (KX_GameObject*) GetParent(); + + objMask = obj->GetState(); + switch (m_operation) + { + case OP_CPY: + objMask = m_mask; + break; + case OP_SET: + objMask |= m_mask; + break; + case OP_CLR: + objMask &= ~m_mask; + break; + case OP_NEG: + objMask ^= m_mask; + break; + default: + // unsupported operation, no nothing + return false; + } + obj->SetState(objMask); + return false; +} + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + + + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject +KX_StateActuator::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "KX_StateActuator", + sizeof(KX_StateActuator), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject +KX_StateActuator::Parents[] = { + &KX_StateActuator::Type, + &SCA_IActuator::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef +KX_StateActuator::Methods[] = { + {"setOperation", (PyCFunction) KX_StateActuator::sPySetOperation, + METH_VARARGS, SetOperation_doc}, + {"setMask", (PyCFunction) KX_StateActuator::sPySetMask, + METH_VARARGS, SetMask_doc}, + {NULL,NULL} //Sentinel +}; + +PyObject* +KX_StateActuator::_getattr( + const STR_String& attr + ) +{ + _getattr_up(SCA_IActuator); +}; + + + +/* set operation ---------------------------------------------------------- */ +char +KX_StateActuator::SetOperation_doc[] = +"setOperation(op)\n" +"\t - op : bit operation (0=Copy, 1=Set, 2=Clear, 3=Negate)" +"\tSet the type of bit operation to be applied on object state mask.\n" +"\tUse setMask() to specify the bits that will be modified.\n"; +PyObject* + +KX_StateActuator::PySetOperation(PyObject* self, + PyObject* args, + PyObject* kwds) { + int oper; + + if(!PyArg_ParseTuple(args, "i", &oper)) { + return NULL; + } + + m_operation = oper; + + Py_Return; +} + +/* set mask ---------------------------------------------------------- */ +char +KX_StateActuator::SetMask_doc[] = +"setMask(mask)\n" +"\t - mask : bits that will be modified" +"\tSet the value that defines the bits that will be modified by the operation.\n" +"\tThe bits that are 1 in the value will be updated in the object state,\n" +"\tthe bits that are 0 are will be left unmodified expect for the Copy operation\n" +"\twhich copies the value to the object state.\n"; +PyObject* + +KX_StateActuator::PySetMask(PyObject* self, + PyObject* args, + PyObject* kwds) { + int mask; + + if(!PyArg_ParseTuple(args, "i", &mask)) { + return NULL; + } + + m_mask = mask; + + Py_Return; +} + + diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h new file mode 100644 index 00000000000..8698e51b2c1 --- /dev/null +++ b/source/gameengine/Ketsji/KX_StateActuator.h @@ -0,0 +1,83 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * Actuator to toggle visibility/invisibility of objects + */ + +#ifndef __KX_STATEACTUATOR +#define __KX_STATEACTUATOR + +#include "SCA_IActuator.h" + +class KX_StateActuator : public SCA_IActuator +{ + Py_Header; + + /** Make visible? */ + enum { + OP_CPY = 0, + OP_SET, + OP_CLR, + OP_NEG + }; + int m_operation; + unsigned int m_mask; + + public: + + KX_StateActuator( + SCA_IObject* gameobj, + int operation, + unsigned int mask, + PyTypeObject* T=&Type + ); + + virtual + ~KX_StateActuator( + void + ); + + virtual CValue* + GetReplica( + void + ); + + virtual bool + Update(); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + //KX_PYMETHOD_DOC + KX_PYMETHOD_DOC(KX_StateActuator,SetOperation); + KX_PYMETHOD_DOC(KX_StateActuator,SetMask); +}; + +#endif + diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 3f185359de0..56c2780871b 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -77,18 +77,14 @@ KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj :SCA_ISensor(gameobj,eventmgr,T), m_touchedpropname(touchedpropname), m_bFindMaterial(bFindMaterial), -m_eventmgr(eventmgr), +m_eventmgr(eventmgr) /*m_sumoObj(sumoObj),*/ -m_bCollision(false), -m_bTriggered(false), -m_bLastTriggered(false) { // KX_TouchEventManager* touchmgr = (KX_TouchEventManager*) eventmgr; // m_resptable = touchmgr->GetResponseTable(); // m_solidHandle = m_sumoObj->getObjectHandle(); - m_hitObject = NULL; m_colliders = new CListValue(); KX_ClientObjectInfo *client_info = gameobj->getClientInfo(); @@ -98,8 +94,16 @@ m_bLastTriggered(false) m_physCtrl = dynamic_cast(gameobj->GetPhysicsController()); MT_assert( !gameobj->GetPhysicsController() || m_physCtrl ); + Init(); } +void KX_TouchSensor::Init() +{ + m_bCollision = false; + m_bTriggered = false; + m_bLastTriggered = false; + m_hitObject = NULL; +} KX_TouchSensor::~KX_TouchSensor() { diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index f594196628a..056440ccd6c 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -72,6 +72,7 @@ public: virtual CValue* GetReplica(); virtual void SynchronizeTransform(); virtual bool Evaluate(CValue* event); + virtual void Init(); virtual void ReParent(SCA_IObject* parent); virtual void RegisterSumo(KX_TouchEventManager* touchman); -- cgit v1.2.3 From 75e22a1917fb638a67d475b224cb6e368e821783 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 23 Jun 2008 15:32:44 +0000 Subject: BGE patch #14386: Action Actuator Current Frame Prop. This patch is very usefull for action feedback logic: a sensor on the property can be used to detect a certain moment in the action and trigger more stuff. The property must be on float type for best results --- source/gameengine/Converter/BL_ActionActuator.cpp | 49 ++++++++++++++++++++++ source/gameengine/Converter/BL_ActionActuator.h | 7 +++- .../gameengine/Converter/KX_ConvertActuators.cpp | 2 + 3 files changed, 57 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index ad126ebf123..83be5d3a14f 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -49,6 +49,7 @@ #include "BLI_arithb.h" #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" +#include "FloatValue.h" #ifdef HAVE_CONFIG_H #include @@ -348,6 +349,18 @@ bool BL_ActionActuator::Update(double curtime, bool frame) break; } + /* Set the property if its defined */ + if (m_framepropname) { + CValue* propowner = GetParent(); + CValue* oldprop = propowner->GetProperty(m_framepropname); + CValue* newval = new CFloatValue(m_localtime); + if (oldprop) { + oldprop->SetValue(newval); + } else { + propowner->SetProperty(m_framepropname, newval); + } + newval->Release(); + } if (bNegativeEvent) m_blendframe=0.0; @@ -446,6 +459,7 @@ PyMethodDef BL_ActionActuator::Methods[] = { {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, SetPriority_doc}, {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, SetFrame_doc}, {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, SetFrameProperty_doc}, {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc}, {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, GetAction_doc}, @@ -455,6 +469,7 @@ PyMethodDef BL_ActionActuator::Methods[] = { {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, GetPriority_doc}, {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, GetFrame_doc}, {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, GetFrameProperty_doc}, {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, SetChannel_doc}, // {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS}, {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc}, @@ -502,6 +517,21 @@ PyObject* BL_ActionActuator::PyGetProperty(PyObject* self, return result; } +/* getProperty */ +char BL_ActionActuator::GetFrameProperty_doc[] = +"getFrameProperty()\n" +"\tReturns the name of the property, that is set to the current frame number.\n"; + +PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + PyObject *result; + + result = Py_BuildValue("s", (const char *)m_framepropname); + + return result; +} + /* getFrame */ char BL_ActionActuator::GetFrame_doc[] = "getFrame()\n" @@ -763,6 +793,25 @@ PyObject* BL_ActionActuator::PySetProperty(PyObject* self, return Py_None; } +/* setFrameProperty */ +char BL_ActionActuator::SetFrameProperty_doc[] = +"setFrameProperty(prop)\n" +"\t - prop : A string specifying the property of the frame set up update.\n"; + +PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + char *string; + + if (PyArg_ParseTuple(args,"s",&string)) + { + m_framepropname = string; + } + + Py_INCREF(Py_None); + return Py_None; +} + /* PyObject* BL_ActionActuator::PyGetChannel(PyObject* self, PyObject* args, diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 62edcc7fad7..190f727c9c3 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -40,6 +40,7 @@ public: Py_Header; BL_ActionActuator(SCA_IObject* gameobj, const STR_String& propname, + const STR_String& framepropname, float starttime, float endtime, struct bAction *action, @@ -67,7 +68,8 @@ public: m_blendpose(NULL), m_userpose(NULL), m_action(action), - m_propname(propname) + m_propname(propname), + m_framepropname(framepropname) { }; virtual ~BL_ActionActuator(); @@ -84,6 +86,7 @@ public: KX_PYMETHOD_DOC(BL_ActionActuator,SetEnd); KX_PYMETHOD_DOC(BL_ActionActuator,SetFrame); KX_PYMETHOD_DOC(BL_ActionActuator,SetProperty); + KX_PYMETHOD_DOC(BL_ActionActuator,SetFrameProperty); KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendtime); KX_PYMETHOD_DOC(BL_ActionActuator,SetChannel); @@ -94,6 +97,7 @@ public: KX_PYMETHOD_DOC(BL_ActionActuator,GetEnd); KX_PYMETHOD_DOC(BL_ActionActuator,GetFrame); KX_PYMETHOD_DOC(BL_ActionActuator,GetProperty); + KX_PYMETHOD_DOC(BL_ActionActuator,GetFrameProperty); // KX_PYMETHOD(BL_ActionActuator,GetChannel); KX_PYMETHOD_DOC(BL_ActionActuator,GetType); KX_PYMETHOD_DOC(BL_ActionActuator,SetType); @@ -138,6 +142,7 @@ protected: struct bPose* m_userpose; struct bAction *m_action; STR_String m_propname; + STR_String m_framepropname; }; enum { diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index c02c2a29595..89e2925a6c1 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -178,10 +178,12 @@ void BL_ConvertActuators(char* maggiename, if (blenderobject->type==OB_ARMATURE){ bActionActuator* actact = (bActionActuator*) bact->data; STR_String propname = (actact->name ? actact->name : ""); + STR_String propframe = (actact->frameProp ? actact->frameProp : ""); BL_ActionActuator* tmpbaseact = new BL_ActionActuator( gameobj, propname, + propframe, actact->sta, actact->end, actact->act, -- cgit v1.2.3 From 67c0b32375c9c2f9838cf110975d7fce9d783daa Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 23 Jun 2008 20:26:48 +0000 Subject: BGE patch: Add level option on sensor and fix sensor reset. Level option is now available on all sensors but is only implemented on mouse and keyboard sensors. The purpose of that option is to make the sensor react on level rather than edge by default. It's only applicable to state engine system when there is a state transition: the sensor will generate a pulse if the condition is met from the start of the state. Normally, the keyboard sensor generate a pulse only when the key is pressed and not when the key is already pressed. This patch allows to select this behavior. The second part of the patch corrects the reset method for sensors with inverted output. --- source/gameengine/Converter/KX_ConvertSensors.cpp | 5 +++- source/gameengine/GameLogic/SCA_ISensor.cpp | 34 ++++++++++++++++++++++ source/gameengine/GameLogic/SCA_ISensor.h | 7 +++++ source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 2 +- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 24 +++++++-------- source/gameengine/GameLogic/SCA_MouseSensor.cpp | 11 +++---- source/gameengine/GameLogic/SCA_PropertySensor.cpp | 2 +- source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 8 ++--- source/gameengine/Ketsji/KX_RaySensor.cpp | 2 +- 9 files changed, 68 insertions(+), 27 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 80fa3838d60..e7e4eeae7d2 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -251,6 +251,7 @@ void BL_ConvertSensors(struct Object* blenderobject, bool neg_pulsemode = false; int frequency = 0; bool invert = false; + bool level = false; while(sens) { @@ -263,7 +264,8 @@ void BL_ConvertSensors(struct Object* blenderobject, frequency = sens->freq; invert = !(sens->invert == 0); - + level = !(sens->level == 0); + switch (sens->type) { case SENS_ALWAYS: @@ -711,6 +713,7 @@ void BL_ConvertSensors(struct Object* blenderobject, neg_pulsemode, frequency); gamesensor->SetInvert(invert); + gamesensor->SetLevel(level); gamesensor->SetName(STR_String(sens->name)); gameobj->AddSensor(gamesensor); diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 1c29eb27be5..6cfae9d8919 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -55,6 +55,7 @@ SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj, m_links = 0; m_suspended = false; m_invert = false; + m_level = false; m_pos_ticks = 0; m_neg_ticks = 0; m_pos_pulsemode = false; @@ -95,6 +96,10 @@ void SCA_ISensor::SetInvert(bool inv) { m_invert = inv; } +void SCA_ISensor::SetLevel(bool lvl) { + m_level = lvl; +} + float SCA_ISensor::GetNumber() { return IsPositiveTrigger(); @@ -177,6 +182,10 @@ PyMethodDef SCA_ISensor::Methods[] = { METH_VARARGS, GetInvert_doc}, {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert, METH_VARARGS, SetInvert_doc}, + {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel, + METH_VARARGS, GetLevel_doc}, + {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel, + METH_VARARGS, SetLevel_doc}, {NULL,NULL} //Sentinel }; @@ -328,6 +337,31 @@ PyObject* SCA_ISensor::PySetInvert(PyObject* self, PyObject* args, PyObject* kwd Py_Return; } +char SCA_ISensor::GetLevel_doc[] = +"getLevel()\n" +"\tReturns whether this sensor is a level detector or a edge detector.\n" +"\tIt makes a difference only in case of logic state transition (state actuator).\n" +"\tA level detector will immediately generate a pulse if the condition for the\n" +"\tdetector is met when entering the state. A edge detector will wait for an off-on\n" +"\ttransition to occur.\n" +"\tOnly some sensors implement this feature: keyboard.\n"; +PyObject* SCA_ISensor::PyGetLevel(PyObject* self, PyObject* args, PyObject* kwds) +{ + return BoolToPyArg(m_level); +} + +char SCA_ISensor::SetLevel_doc[] = +"setLevel(level?)\n" +"\t- level?: Detect level instead of edge? (KX_TRUE, KX_FALSE)\n" +"\tSet whether to detect level or edge transition when entering a state.\n"; +PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds) +{ + int pyarg = 0; + if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; } + m_level = PyArgToBool(pyarg); + Py_Return; +} + char SCA_ISensor::GetUseNegPulseMode_doc[] = "getUseNegPulseMode()\n" "\tReturns whether negative pulse mode is active.\n"; diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 292b2d160ae..3527b87ebdb 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -61,6 +61,9 @@ class SCA_ISensor : public SCA_ILogicBrick /** invert the output signal*/ bool m_invert; + /** detect level instead of edge*/ + bool m_level; + /** Sensor must ignore updates? */ bool m_suspended; @@ -105,6 +108,8 @@ public: virtual void Delete() { Release(); } /** Set inversion of pulses on or off. */ void SetInvert(bool inv); + /** set the level detection on or off */ + void SetLevel(bool lvl); void RegisterToManager(); virtual float GetNumber(); @@ -134,6 +139,8 @@ public: KX_PYMETHOD_DOC(SCA_ISensor,SetUseNegPulseMode); KX_PYMETHOD_DOC(SCA_ISensor,GetInvert); KX_PYMETHOD_DOC(SCA_ISensor,SetInvert); + KX_PYMETHOD_DOC(SCA_ISensor,GetLevel); + KX_PYMETHOD_DOC(SCA_ISensor,SetLevel); }; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 81938f05af1..8668c22f044 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -69,7 +69,7 @@ std::cout << " hat flag " << m_hatf << std::endl; void SCA_JoystickSensor::Init() { - m_istrig=0; + m_istrig=(m_invert)?1:0; } SCA_JoystickSensor::~SCA_JoystickSensor() diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index c6c06846e3b..43ce25f94df 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -77,7 +77,7 @@ void SCA_KeyboardSensor::Init() // by the state engine. It reinitializes the sensor as if it was just created. // However, if the target key is pressed when the sensor is reactivated, it // will not generated an event (see remark in Evaluate()). - m_val = 0; + m_val = (m_invert)?1:0; } CValue* SCA_KeyboardSensor::GetReplica() @@ -176,10 +176,10 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (m_val == 0) { - //see comment below - //m_val = 1; - //result = true; - ; + if (m_level) { + m_val = 1; + result = true; + } } } else { @@ -229,15 +229,11 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (m_val == 0) { - //hmm, this abnormal situation may occur in the following cases: - //- the key was pressed while the scene was suspended - //- this is a new scene and the key is active from the start - //In the second case, it's dangerous to activate the sensor - //(think of a key to go to next scene) - //What we really need is a edge/level flag in the key sensor - //m_val = 1; - //result = true; - ; + if (m_level) + { + m_val = 1; + result = true; + } } } } diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 11e67eda014..42d35837489 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -83,7 +83,7 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, void SCA_MouseSensor::Init() { - m_val = 0; /* stores the latest attribute */ + m_val = (m_invert)?1:0; /* stores the latest attribute */ } SCA_MouseSensor::~SCA_MouseSensor() @@ -168,10 +168,11 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { if (m_val == 0) { - //dangerous - //m_val = 1; - //result = true; - ; + if (m_level) + { + m_val = 1; + result = true; + } } } else { diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index d6eb246ffd2..655e9060238 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -54,7 +54,6 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, m_checkpropval(propval), m_checkpropmaxval(propmaxval), m_checkpropname(propname), - m_lastresult(false), m_range_expr(NULL) { //CParser pars; @@ -78,6 +77,7 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, void SCA_PropertySensor::Init() { m_recentresult = false; + m_lastresult = m_invert?true:false; } void SCA_PropertySensor::PrecalculateRangeExpression() diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index f306f0dbfbb..f89d32bbe66 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -74,7 +74,7 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, void KX_MouseFocusSensor::Init() { - m_mouse_over_in_previous_frame = false; + m_mouse_over_in_previous_frame = (m_invert)?true:false; m_positive_event = false; m_hitObject = 0; } @@ -92,13 +92,13 @@ bool KX_MouseFocusSensor::Evaluate(CValue* event) obHasFocus = ParentObjectHasFocus(); if (!obHasFocus) { + m_positive_event = false; if (m_mouse_over_in_previous_frame) { - m_positive_event = false; - result = true; + result = true; } } else { + m_positive_event = true; if (!m_mouse_over_in_previous_frame) { - m_positive_event = true; result = true; } } diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 02b814105b4..e847c59bae1 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -69,7 +69,7 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr, void KX_RaySensor::Init() { - m_bTriggered = false; + m_bTriggered = (m_invert)?true:false; m_rayHit = false; m_hitObject = NULL; } -- cgit v1.2.3 From 02132de7aadee611c8641f01fa44efdf43f54cc4 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 23 Jun 2008 20:41:18 +0000 Subject: BGE patch: Add NAND, NOR, XOR, XNOR controllers. NAND controller is an inverted AND controller: the output is 1 if any of the input is 0. NOR controller is an inverted OR controller: the output is 0 if any of the input is 1. XOR controller is an exclusive OR: the output is 1 if and only if one input is 1 and all the other inputs are 0. XNOR controller is an inverted XOR: the output is 0 if and only if one input is 0 and all the other inputs are 0. The NAND, NORT and XNOR controllers are very usefull to create complementary outputs to start and stop actuators synchronously. MSCV project files updated. --- .../gameengine/Converter/KX_ConvertControllers.cpp | 28 ++++ source/gameengine/GameLogic/SCA_NANDController.cpp | 144 ++++++++++++++++++++ source/gameengine/GameLogic/SCA_NANDController.h | 56 ++++++++ source/gameengine/GameLogic/SCA_NORController.cpp | 144 ++++++++++++++++++++ source/gameengine/GameLogic/SCA_NORController.h | 56 ++++++++ source/gameengine/GameLogic/SCA_XNORController.cpp | 148 +++++++++++++++++++++ source/gameengine/GameLogic/SCA_XNORController.h | 56 ++++++++ source/gameengine/GameLogic/SCA_XORController.cpp | 148 +++++++++++++++++++++ source/gameengine/GameLogic/SCA_XORController.h | 56 ++++++++ source/gameengine/Ketsji/KX_TouchSensor.cpp | 2 +- 10 files changed, 837 insertions(+), 1 deletion(-) create mode 100644 source/gameengine/GameLogic/SCA_NANDController.cpp create mode 100644 source/gameengine/GameLogic/SCA_NANDController.h create mode 100644 source/gameengine/GameLogic/SCA_NORController.cpp create mode 100644 source/gameengine/GameLogic/SCA_NORController.h create mode 100644 source/gameengine/GameLogic/SCA_XNORController.cpp create mode 100644 source/gameengine/GameLogic/SCA_XNORController.h create mode 100644 source/gameengine/GameLogic/SCA_XORController.cpp create mode 100644 source/gameengine/GameLogic/SCA_XORController.h (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 179dd9f8478..da490b4ee85 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -35,6 +35,10 @@ // Controller #include "SCA_ANDController.h" #include "SCA_ORController.h" +#include "SCA_NANDController.h" +#include "SCA_NORController.h" +#include "SCA_XORController.h" +#include "SCA_XNORController.h" #include "SCA_PythonController.h" #include "SCA_ExpressionController.h" @@ -112,6 +116,30 @@ void BL_ConvertControllers( LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); break; } + case CONT_LOGIC_NAND: + { + gamecontroller = new SCA_NANDController(gameobj); + LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); + break; + } + case CONT_LOGIC_NOR: + { + gamecontroller = new SCA_NORController(gameobj); + LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); + break; + } + case CONT_LOGIC_XOR: + { + gamecontroller = new SCA_XORController(gameobj); + LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); + break; + } + case CONT_LOGIC_XNOR: + { + gamecontroller = new SCA_XNORController(gameobj); + LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter); + break; + } case CONT_EXPRESSION: { bExpressionCont* bexpcont = (bExpressionCont*) bcontr->data; diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp new file mode 100644 index 00000000000..5b869ee8298 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_NANDController.cpp @@ -0,0 +1,144 @@ +/** + * 'Nand' together all inputs + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "SCA_NANDController.h" +#include "SCA_ISensor.h" +#include "SCA_LogicManager.h" +#include "BoolValue.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_NANDController::SCA_NANDController(SCA_IObject* gameobj, + PyTypeObject* T) + : + SCA_IController(gameobj,T) +{ +} + + + +SCA_NANDController::~SCA_NANDController() +{ +} + + + +void SCA_NANDController::Trigger(SCA_LogicManager* logicmgr) +{ + + bool sensorresult = false; + + for (vector::const_iterator is=m_linkedsensors.begin(); + !(is==m_linkedsensors.end());is++) + { + SCA_ISensor* sensor = *is; + if (!sensor->IsPositiveTrigger()) + { + sensorresult = true; + break; + } + } + + CValue* newevent = new CBoolValue(sensorresult); + + for (vector::const_iterator i=m_linkedactuators.begin(); + !(i==m_linkedactuators.end());i++) + { + SCA_IActuator* actua = *i;//m_linkedactuators.at(i); + logicmgr->AddActiveActuator(actua,newevent); + } + + // every actuator that needs the event, has a it's own reference to it now so + // release it (so to be clear: if there is no actuator, it's deleted right now) + newevent->Release(); + +} + + + +CValue* SCA_NANDController::GetReplica() +{ + CValue* replica = new SCA_NANDController(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_NANDController::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_NANDController", + sizeof(SCA_NANDController), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_NANDController::Parents[] = { + &SCA_NANDController::Type, + &SCA_IController::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_NANDController::Methods[] = { + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_NANDController::_getattr(const STR_String& attr) { + _getattr_up(SCA_IController); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_NANDController.h b/source/gameengine/GameLogic/SCA_NANDController.h new file mode 100644 index 00000000000..1193ff64f07 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_NANDController.h @@ -0,0 +1,56 @@ +/** + * SCA_NANDController.h + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __KX_NANDCONTROLLER +#define __KX_NANDCONTROLLER + +#include "SCA_IController.h" + +class SCA_NANDController : public SCA_IController +{ + Py_Header; + //virtual void Trigger(class SCA_LogicManager* logicmgr); +public: + SCA_NANDController(SCA_IObject* gameobj,PyTypeObject* T=&Type); + virtual ~SCA_NANDController(); + virtual CValue* GetReplica(); + virtual void Trigger(SCA_LogicManager* logicmgr); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + +}; + +#endif //__KX_NANDCONTROLLER + diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp new file mode 100644 index 00000000000..2866dec0b74 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_NORController.cpp @@ -0,0 +1,144 @@ +/** + * 'Nor' together all inputs + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "SCA_NORController.h" +#include "SCA_ISensor.h" +#include "SCA_LogicManager.h" +#include "BoolValue.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_NORController::SCA_NORController(SCA_IObject* gameobj, + PyTypeObject* T) + : + SCA_IController(gameobj,T) +{ +} + + + +SCA_NORController::~SCA_NORController() +{ +} + + + +void SCA_NORController::Trigger(SCA_LogicManager* logicmgr) +{ + + bool sensorresult = true; + + for (vector::const_iterator is=m_linkedsensors.begin(); + !(is==m_linkedsensors.end());is++) + { + SCA_ISensor* sensor = *is; + if (sensor->IsPositiveTrigger()) + { + sensorresult = false; + break; + } + } + + CValue* newevent = new CBoolValue(sensorresult); + + for (vector::const_iterator i=m_linkedactuators.begin(); + !(i==m_linkedactuators.end());i++) + { + SCA_IActuator* actua = *i;//m_linkedactuators.at(i); + logicmgr->AddActiveActuator(actua,newevent); + } + + // every actuator that needs the event, has a it's own reference to it now so + // release it (so to be clear: if there is no actuator, it's deleted right now) + newevent->Release(); + +} + + + +CValue* SCA_NORController::GetReplica() +{ + CValue* replica = new SCA_NORController(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_NORController::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_NORController", + sizeof(SCA_NORController), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_NORController::Parents[] = { + &SCA_NORController::Type, + &SCA_IController::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_NORController::Methods[] = { + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_NORController::_getattr(const STR_String& attr) { + _getattr_up(SCA_IController); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_NORController.h b/source/gameengine/GameLogic/SCA_NORController.h new file mode 100644 index 00000000000..aab59e3d46c --- /dev/null +++ b/source/gameengine/GameLogic/SCA_NORController.h @@ -0,0 +1,56 @@ +/** + * SCA_NORController.h + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __KX_NORCONTROLLER +#define __KX_NORCONTROLLER + +#include "SCA_IController.h" + +class SCA_NORController : public SCA_IController +{ + Py_Header; + //virtual void Trigger(class SCA_LogicManager* logicmgr); +public: + SCA_NORController(SCA_IObject* gameobj,PyTypeObject* T=&Type); + virtual ~SCA_NORController(); + virtual CValue* GetReplica(); + virtual void Trigger(SCA_LogicManager* logicmgr); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + +}; + +#endif //__KX_NORCONTROLLER + diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp new file mode 100644 index 00000000000..3ef7c07fe0a --- /dev/null +++ b/source/gameengine/GameLogic/SCA_XNORController.cpp @@ -0,0 +1,148 @@ +/** + * 'Xnor' together all inputs + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "SCA_XNORController.h" +#include "SCA_ISensor.h" +#include "SCA_LogicManager.h" +#include "BoolValue.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_XNORController::SCA_XNORController(SCA_IObject* gameobj, + PyTypeObject* T) + : + SCA_IController(gameobj,T) +{ +} + + + +SCA_XNORController::~SCA_XNORController() +{ +} + + + +void SCA_XNORController::Trigger(SCA_LogicManager* logicmgr) +{ + + bool sensorresult = true; + + for (vector::const_iterator is=m_linkedsensors.begin(); + !(is==m_linkedsensors.end());is++) + { + SCA_ISensor* sensor = *is; + if (sensor->IsPositiveTrigger()) + { + if (sensorresult == false) + { + sensorresult = true; + break; + } + sensorresult = false; + } + } + + CValue* newevent = new CBoolValue(sensorresult); + + for (vector::const_iterator i=m_linkedactuators.begin(); + !(i==m_linkedactuators.end());i++) + { + SCA_IActuator* actua = *i;//m_linkedactuators.at(i); + logicmgr->AddActiveActuator(actua,newevent); + } + + // every actuator that needs the event, has a it's own reference to it now so + // release it (so to be clear: if there is no actuator, it's deleted right now) + newevent->Release(); + +} + + + +CValue* SCA_XNORController::GetReplica() +{ + CValue* replica = new SCA_XNORController(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_XNORController::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_XNORController", + sizeof(SCA_XNORController), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_XNORController::Parents[] = { + &SCA_XNORController::Type, + &SCA_IController::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_XNORController::Methods[] = { + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_XNORController::_getattr(const STR_String& attr) { + _getattr_up(SCA_IController); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_XNORController.h b/source/gameengine/GameLogic/SCA_XNORController.h new file mode 100644 index 00000000000..4b1eaee95d8 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_XNORController.h @@ -0,0 +1,56 @@ +/** + * SCA_XNORController.h + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __KX_XNORCONTROLLER +#define __KX_XNORCONTROLLER + +#include "SCA_IController.h" + +class SCA_XNORController : public SCA_IController +{ + Py_Header; + //virtual void Trigger(class SCA_LogicManager* logicmgr); +public: + SCA_XNORController(SCA_IObject* gameobj,PyTypeObject* T=&Type); + virtual ~SCA_XNORController(); + virtual CValue* GetReplica(); + virtual void Trigger(SCA_LogicManager* logicmgr); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + +}; + +#endif //__KX_XNORCONTROLLER + diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp new file mode 100644 index 00000000000..6499c62f5f2 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -0,0 +1,148 @@ +/** + * 'Xor' together all inputs + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "SCA_XORController.h" +#include "SCA_ISensor.h" +#include "SCA_LogicManager.h" +#include "BoolValue.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_XORController::SCA_XORController(SCA_IObject* gameobj, + PyTypeObject* T) + : + SCA_IController(gameobj,T) +{ +} + + + +SCA_XORController::~SCA_XORController() +{ +} + + + +void SCA_XORController::Trigger(SCA_LogicManager* logicmgr) +{ + + bool sensorresult = false; + + for (vector::const_iterator is=m_linkedsensors.begin(); + !(is==m_linkedsensors.end());is++) + { + SCA_ISensor* sensor = *is; + if (sensor->IsPositiveTrigger()) + { + if (sensorresult == true) + { + sensorresult = false; + break; + } + sensorresult = true; + } + } + + CValue* newevent = new CBoolValue(sensorresult); + + for (vector::const_iterator i=m_linkedactuators.begin(); + !(i==m_linkedactuators.end());i++) + { + SCA_IActuator* actua = *i;//m_linkedactuators.at(i); + logicmgr->AddActiveActuator(actua,newevent); + } + + // every actuator that needs the event, has a it's own reference to it now so + // release it (so to be clear: if there is no actuator, it's deleted right now) + newevent->Release(); + +} + + + +CValue* SCA_XORController::GetReplica() +{ + CValue* replica = new SCA_XORController(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_XORController::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_XORController", + sizeof(SCA_XORController), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_XORController::Parents[] = { + &SCA_XORController::Type, + &SCA_IController::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_XORController::Methods[] = { + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_XORController::_getattr(const STR_String& attr) { + _getattr_up(SCA_IController); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_XORController.h b/source/gameengine/GameLogic/SCA_XORController.h new file mode 100644 index 00000000000..f50cd33c125 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_XORController.h @@ -0,0 +1,56 @@ +/** + * SCA_XORController.h + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __KX_XORCONTROLLER +#define __KX_XORCONTROLLER + +#include "SCA_IController.h" + +class SCA_XORController : public SCA_IController +{ + Py_Header; + //virtual void Trigger(class SCA_LogicManager* logicmgr); +public: + SCA_XORController(SCA_IObject* gameobj,PyTypeObject* T=&Type); + virtual ~SCA_XORController(); + virtual CValue* GetReplica(); + virtual void Trigger(SCA_LogicManager* logicmgr); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + +}; + +#endif //__KX_XORCONTROLLER + diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 56c2780871b..5311f059f03 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -101,7 +101,7 @@ void KX_TouchSensor::Init() { m_bCollision = false; m_bTriggered = false; - m_bLastTriggered = false; + m_bLastTriggered = (m_invert)?true:false; m_hitObject = NULL; } -- cgit v1.2.3 From 15c105c157057d249192b02f438cc60af600f9e6 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 24 Jun 2008 19:37:43 +0000 Subject: BGE patch: Add damping and clamping option to motion actuator. This patch introduces two options for the motion actuator: damping: number of frames to reach the target velocity. It takes into account the startup velocityin the target velocity direction and add 1/damping fraction of target velocity until the full velocity is reached. Works only with linear and angular velocity. It will be extended to delta and force motion method in a future release. clamping: apply the force and torque as long as the target velocity is not reached. If this option is set, the velocity specified in linV or angV are not applied to the object but used as target velocity. You should also specify a force in force or torque field: the force will be applied as long as the velocity along the axis of the vector set in linV or angV is not reached. Works best in low friction environment. --- .../Converter/BL_BlenderDataConversion.cpp | 4 +- .../gameengine/Converter/KX_ConvertActuators.cpp | 4 +- .../Ketsji/KX_BulletPhysicsController.cpp | 7 ++ .../gameengine/Ketsji/KX_BulletPhysicsController.h | 1 + source/gameengine/Ketsji/KX_GameObject.cpp | 21 ++++ source/gameengine/Ketsji/KX_GameObject.h | 8 ++ source/gameengine/Ketsji/KX_IPhysicsController.h | 1 + source/gameengine/Ketsji/KX_ObjectActuator.cpp | 131 ++++++++++++++++++--- source/gameengine/Ketsji/KX_ObjectActuator.h | 36 +++++- .../gameengine/Ketsji/KX_SumoPhysicsController.h | 2 + 10 files changed, 195 insertions(+), 20 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 21c18634e21..665783a1ba5 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1668,6 +1668,8 @@ static KX_GameObject *gameobject_from_blenderobject( BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj, ob, (BL_SkinMeshObject*)meshobj); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; + if (bHasArmature) + dcont->LoadShapeDrivers(ob->parent); } else if (bHasArmature) { BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj ); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; @@ -2329,7 +2331,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); struct Object* blenderobj = converter->FindBlenderObject(gameobj); - gameobj->SetState(blenderobj->state); + gameobj->SetState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state); } #endif //CONVERT_LOGIC diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 89e2925a6c1..f0b549594f2 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -137,6 +137,7 @@ void BL_ConvertActuators(char* maggiename, MT_Vector3 angvelvec ( KX_BLENDERTRUNC(obact->angularvelocity[0]), KX_BLENDERTRUNC(obact->angularvelocity[1]), KX_BLENDERTRUNC(obact->angularvelocity[2])); + short damping = obact->damping; drotvec /= BLENDER_HACK_DTIME; //drotvec /= BLENDER_HACK_DTIME; @@ -157,7 +158,7 @@ void BL_ConvertActuators(char* maggiename, bitLocalFlag.DRot = bool((obact->flag & ACT_DROT_LOCAL)!=0); bitLocalFlag.LinearVelocity = bool((obact->flag & ACT_LIN_VEL_LOCAL)!=0); bitLocalFlag.AngularVelocity = bool((obact->flag & ACT_ANG_VEL_LOCAL)!=0); - + bitLocalFlag.ClampVelocity = bool((obact->flag & ACT_CLAMP_VEL)!=0); bitLocalFlag.AddOrSetLinV = bool((obact->flag & ACT_ADD_LIN_VEL)!=0); @@ -168,6 +169,7 @@ void BL_ConvertActuators(char* maggiename, drotvec.getValue(), linvelvec.getValue(), angvelvec.getValue(), + damping, bitLocalFlag ); baseact = tmpbaseact; diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index aa7c75e9633..70443ced7a9 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -102,6 +102,13 @@ MT_Vector3 KX_BulletPhysicsController::GetLinearVelocity() CcdPhysicsController::GetLinearVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz return MT_Vector3(angVel[0],angVel[1],angVel[2]); } +MT_Vector3 KX_BulletPhysicsController::GetAngularVelocity() +{ + float angVel[3]; + //CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]); + CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz + return MT_Vector3(angVel[0],angVel[1],angVel[2]); +} MT_Vector3 KX_BulletPhysicsController::GetVelocity(const MT_Point3& pos) { float linVel[3]; diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 619ac42503f..0853755dffa 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -25,6 +25,7 @@ public: virtual void ApplyTorque(const MT_Vector3& torque,bool local); virtual void ApplyForce(const MT_Vector3& force,bool local); virtual MT_Vector3 GetLinearVelocity(); + virtual MT_Vector3 GetAngularVelocity(); virtual MT_Vector3 GetVelocity(const MT_Point3& pos); virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local); virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index eaa6564ba84..cdbce81d610 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -664,6 +664,27 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) return velocity; } +MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) +{ + MT_Vector3 velocity(0.0,0.0,0.0), locvel; + MT_Matrix3x3 ori; + int i, j; + if (m_pPhysicsController1) + { + velocity = m_pPhysicsController1->GetAngularVelocity(); + + if (local) + { + ori = GetSGNode()->GetWorldOrientation(); + + locvel = velocity * ori; + return locvel; + } + } + return velocity; +} + + // scenegraph node stuff diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 63a660617c4..cab1f3167d5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -258,6 +258,14 @@ public: bool local=false ); + /** + * Return the angular velocity of the game object. + */ + MT_Vector3 + GetAngularVelocity( + bool local=false + ); + /** * Align the object to a given normal. */ diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h index 009db40d3e8..2ec66a883eb 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ b/source/gameengine/Ketsji/KX_IPhysicsController.h @@ -64,6 +64,7 @@ public: virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0; virtual void ApplyForce(const MT_Vector3& force,bool local)=0; virtual MT_Vector3 GetLinearVelocity()=0; + virtual MT_Vector3 GetAngularVelocity()=0; virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0; virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0; virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0; diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 22a406792f9..03ae14997ab 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -50,6 +50,7 @@ KX_ObjectActuator( const MT_Vector3& drot, const MT_Vector3& linV, const MT_Vector3& angV, + const short damping, const KX_LocalFlags& flag, PyTypeObject* T ) : @@ -60,9 +61,16 @@ KX_ObjectActuator( m_drot(drot), m_linear_velocity(linV), m_angular_velocity(angV), + m_linear_length2(0.0), + m_current_linear_factor(0.0), + m_current_angular_factor(0.0), + m_damping(damping), m_bitLocalFlag (flag), - m_active_combined_velocity (false) + m_active_combined_velocity (false), + m_linear_damping_active(false), + m_angular_damping_active(false) { + UpdateFuzzyFlags(); } bool KX_ObjectActuator::Update() @@ -87,42 +95,98 @@ bool KX_ObjectActuator::Update() ); m_active_combined_velocity = false; } + m_linear_damping_active = false; return false; } else if (parent) { - /* Probably better to use some flags, so these MT_zero tests can be */ - /* skipped. */ - if (!MT_fuzzyZero(m_force)) + if (!m_bitLocalFlag.ZeroForce) { - parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0); + if (m_bitLocalFlag.ClampVelocity && !m_bitLocalFlag.ZeroLinearVelocity) + { + // The user is requesting not to exceed the velocity set in m_linear_velocity + // The verification is done by projecting the actual speed along the linV direction + // and comparing it with the linV vector length + MT_Vector3 linV; + linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity); + if (linV.dot(m_linear_velocity) < m_linear_length2) + parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0); + } else + { + parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0); + } } - if (!MT_fuzzyZero(m_torque)) + if (!m_bitLocalFlag.ZeroTorque) { - parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0); + if (m_bitLocalFlag.ClampVelocity && !m_bitLocalFlag.ZeroAngularVelocity) + { + // The user is requesting not to exceed the velocity set in m_angular_velocity + // The verification is done by projecting the actual speed in the + MT_Vector3 angV; + angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity); + if (angV.dot(m_angular_velocity) < m_angular_velocity.length2()) + parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0); + } else + { + parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0); + } } - if (!MT_fuzzyZero(m_dloc)) + if (!m_bitLocalFlag.ZeroDLoc) { parent->ApplyMovement(m_dloc,(m_bitLocalFlag.DLoc) != 0); } - if (!MT_fuzzyZero(m_drot)) + if (!m_bitLocalFlag.ZeroDRot) { parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0); } - if (!MT_fuzzyZero(m_linear_velocity)) + if (!m_bitLocalFlag.ZeroLinearVelocity && !m_bitLocalFlag.ClampVelocity) { if (m_bitLocalFlag.AddOrSetLinV) { parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); } else { m_active_combined_velocity = true; - parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); + if (m_damping > 0) { + MT_Vector3 linV; + if (!m_linear_damping_active) { + // delta and the start speed (depends on the existing speed in that direction) + linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity); + // keep only the projection along the desired direction + m_current_linear_factor = linV.dot(m_linear_velocity)/m_linear_length2; + m_linear_damping_active = true; + } + if (m_current_linear_factor < 1.0) + m_current_linear_factor += 1.0/m_damping; + if (m_current_linear_factor > 1.0) + m_current_linear_factor = 1.0; + linV = m_current_linear_factor * m_linear_velocity; + parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); + } else { + parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); + } } } - if (!MT_fuzzyZero(m_angular_velocity)) + if (!m_bitLocalFlag.ZeroAngularVelocity && !m_bitLocalFlag.ClampVelocity) { - parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0); m_active_combined_velocity = true; + if (m_damping > 0) { + MT_Vector3 angV; + if (!m_angular_damping_active) { + // delta and the start speed (depends on the existing speed in that direction) + angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity); + // keep only the projection along the desired direction + m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2; + m_angular_damping_active = true; + } + if (m_current_angular_factor < 1.0) + m_current_angular_factor += 1.0/m_damping; + if (m_current_angular_factor > 1.0) + m_current_angular_factor = 1.0; + angV = m_current_angular_factor * m_angular_velocity; + parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); + } else { + parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0); + } } } @@ -199,6 +263,8 @@ PyMethodDef KX_ObjectActuator::Methods[] = { {"setLinearVelocity", (PyCFunction) KX_ObjectActuator::sPySetLinearVelocity, METH_VARARGS}, {"getAngularVelocity", (PyCFunction) KX_ObjectActuator::sPyGetAngularVelocity, METH_VARARGS}, {"setAngularVelocity", (PyCFunction) KX_ObjectActuator::sPySetAngularVelocity, METH_VARARGS}, + {"setVelocityDamping", (PyCFunction) KX_ObjectActuator::sPySetVelocityDamping, METH_VARARGS}, + {"getVelocityDamping", (PyCFunction) KX_ObjectActuator::sPyGetVelocityDamping, METH_VARARGS}, {NULL,NULL} //Sentinel @@ -238,6 +304,7 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* self, } m_force.setValue(vecArg); m_bitLocalFlag.Force = PyArgToBool(bToggle); + UpdateFuzzyFlags(); Py_Return; } @@ -268,6 +335,7 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* self, } m_torque.setValue(vecArg); m_bitLocalFlag.Torque = PyArgToBool(bToggle); + UpdateFuzzyFlags(); Py_Return; } @@ -298,6 +366,7 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* self, } m_dloc.setValue(vecArg); m_bitLocalFlag.DLoc = PyArgToBool(bToggle); + UpdateFuzzyFlags(); Py_Return; } @@ -328,6 +397,7 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* self, } m_drot.setValue(vecArg); m_bitLocalFlag.DRot = PyArgToBool(bToggle); + UpdateFuzzyFlags(); Py_Return; } @@ -341,6 +411,7 @@ PyObject* KX_ObjectActuator::PyGetLinearVelocity(PyObject* self, PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1])); PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2])); PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.LinearVelocity)); + PyList_SetItem(retVal, 4, BoolToPyArg(m_bitLocalFlag.ClampVelocity)); return retVal; } @@ -351,12 +422,15 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* self, PyObject* kwds) { float vecArg[3]; int bToggle = 0; - if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], - &vecArg[2], &bToggle)) { + int bClamp = 0; + if (!PyArg_ParseTuple(args, "fffi|i", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle, &bClamp)) { return NULL; } m_linear_velocity.setValue(vecArg); m_bitLocalFlag.LinearVelocity = PyArgToBool(bToggle); + m_bitLocalFlag.ClampVelocity = PyArgToBool(bClamp); + UpdateFuzzyFlags(); Py_Return; } @@ -371,6 +445,7 @@ PyObject* KX_ObjectActuator::PyGetAngularVelocity(PyObject* self, PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1])); PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2])); PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.AngularVelocity)); + PyList_SetItem(retVal, 4, BoolToPyArg(m_bitLocalFlag.ClampVelocity)); return retVal; } @@ -380,15 +455,37 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* self, PyObject* kwds) { float vecArg[3]; int bToggle = 0; - if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], - &vecArg[2], &bToggle)) { + int bClamp = 0; + if (!PyArg_ParseTuple(args, "fffi|i", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle, &bClamp)) { return NULL; } m_angular_velocity.setValue(vecArg); m_bitLocalFlag.AngularVelocity = PyArgToBool(bToggle); + m_bitLocalFlag.ClampVelocity = PyArgToBool(bClamp); + UpdateFuzzyFlags(); Py_Return; } +/* 13. setVelocityDamping */ +PyObject* KX_ObjectActuator::PySetVelocityDamping(PyObject* self, + PyObject* args, + PyObject* kwds) { + int damping = 0; + if (!PyArg_ParseTuple(args, "i", &damping) || damping < 0 || damping > 1000) { + return NULL; + } + m_damping = damping; + Py_Return; +} + +/* 13. getVelocityDamping */ +PyObject* KX_ObjectActuator::PyGetVelocityDamping(PyObject* self, + PyObject* args, + PyObject* kwds) { + return Py_BuildValue("i",m_damping); +} + diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index edbae154b8b..ec6dab5cd48 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -46,7 +46,13 @@ struct KX_LocalFlags { DLoc(false), LinearVelocity(false), AngularVelocity(false), - AddOrSetLinV(false) + AddOrSetLinV(false), + ClampVelocity(false), + ZeroForce(false), + ZeroDRot(false), + ZeroDLoc(false), + ZeroLinearVelocity(false), + ZeroAngularVelocity(false) { } @@ -57,6 +63,13 @@ struct KX_LocalFlags { unsigned short LinearVelocity : 1; unsigned short AngularVelocity : 1; unsigned short AddOrSetLinV : 1; + unsigned short ClampVelocity : 1; + unsigned short ZeroForce : 1; + unsigned short ZeroTorque : 1; + unsigned short ZeroDRot : 1; + unsigned short ZeroDLoc : 1; + unsigned short ZeroLinearVelocity : 1; + unsigned short ZeroAngularVelocity : 1; }; class KX_ObjectActuator : public SCA_IActuator @@ -69,6 +82,11 @@ class KX_ObjectActuator : public SCA_IActuator MT_Vector3 m_drot; MT_Vector3 m_linear_velocity; MT_Vector3 m_angular_velocity; + MT_Scalar m_linear_length2; + MT_Scalar m_angular_length2; + MT_Scalar m_current_linear_factor; + MT_Scalar m_current_angular_factor; + short m_damping; KX_LocalFlags m_bitLocalFlag; // A hack bool -- oh no sorry everyone @@ -77,6 +95,8 @@ class KX_ObjectActuator : public SCA_IActuator // setting linear velocity. bool m_active_combined_velocity; + bool m_linear_damping_active; + bool m_angular_damping_active; public: enum KX_OBJECT_ACT_VEC_TYPE { @@ -103,6 +123,7 @@ public: const MT_Vector3& drot, const MT_Vector3& linV, const MT_Vector3& angV, + const short damping, const KX_LocalFlags& flag, PyTypeObject* T=&Type ); @@ -110,6 +131,17 @@ public: CValue* GetReplica(); void SetForceLoc(const double force[3]) { /*m_force=force;*/ } + void UpdateFuzzyFlags() + { + m_bitLocalFlag.ZeroForce = MT_fuzzyZero(m_force); + m_bitLocalFlag.ZeroTorque = MT_fuzzyZero(m_torque); + m_bitLocalFlag.ZeroDLoc = MT_fuzzyZero(m_dloc); + m_bitLocalFlag.ZeroDRot = MT_fuzzyZero(m_drot); + m_bitLocalFlag.ZeroLinearVelocity = MT_fuzzyZero(m_linear_velocity); + m_linear_length2 = (m_bitLocalFlag.ZeroLinearVelocity) ? 0.0 : m_linear_velocity.length2(); + m_bitLocalFlag.ZeroAngularVelocity = MT_fuzzyZero(m_angular_velocity); + m_angular_length2 = (m_bitLocalFlag.ZeroAngularVelocity) ? 0.0 : m_angular_velocity.length2(); + } virtual bool Update(); @@ -132,6 +164,8 @@ public: KX_PYMETHOD(KX_ObjectActuator,SetLinearVelocity); KX_PYMETHOD(KX_ObjectActuator,GetAngularVelocity); KX_PYMETHOD(KX_ObjectActuator,SetAngularVelocity); + KX_PYMETHOD(KX_ObjectActuator,SetVelocityDamping); + KX_PYMETHOD(KX_ObjectActuator,GetVelocityDamping); }; #endif //__KX_OBJECTACTUATOR diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h index 868465c8f10..8c061ae4056 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h @@ -68,6 +68,8 @@ public: void ApplyTorque(const MT_Vector3& torque,bool local); void ApplyForce(const MT_Vector3& force,bool local); MT_Vector3 GetLinearVelocity(); + MT_Vector3 GetAngularVelocity() // to keep compiler happy + { return MT_Vector3(0.0,0.0,0.0); } MT_Vector3 GetVelocity(const MT_Point3& pos); void SetAngularVelocity(const MT_Vector3& ang_vel,bool local); void SetLinearVelocity(const MT_Vector3& lin_vel,bool local); -- cgit v1.2.3 From 4d478cbe8629bed1d32205f85e3583f73a5c16a7 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 24 Jun 2008 21:39:45 +0000 Subject: BGE patch: remove Shape key driver code from previous commit --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 665783a1ba5..1bde5ad3450 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1668,8 +1668,6 @@ static KX_GameObject *gameobject_from_blenderobject( BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj, ob, (BL_SkinMeshObject*)meshobj); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; - if (bHasArmature) - dcont->LoadShapeDrivers(ob->parent); } else if (bHasArmature) { BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj ); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; -- cgit v1.2.3 From 820c2df12c9d1ba7479c0a924f90f79a33028db9 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 24 Jun 2008 22:19:00 +0000 Subject: BGE patch: Add automatic support for armature driven shape keys. To take advantage of this feature, you must have a mesh with relative shape keys and shape Ipo curves with drivers referring to bones of the mesh's parent armature. The BGE will automatically detect the dependency between the shape keys and the armature and execute the Ipo drivers during the rendering of the armature actions. This technique is used to make the armature action more natural: the shape keys compensate in places where the armature deformation is uggly and the drivers make sure that the shape correction is synchronized with the bone position. Note: This is not compatible with shape actions; BLender does not allow to have Shape Ipo Curves and Shape actions at the same time. --- .../Converter/BL_BlenderDataConversion.cpp | 2 + source/gameengine/Converter/BL_ShapeDeformer.cpp | 47 ++++++++++++++++++++++ source/gameengine/Converter/BL_ShapeDeformer.h | 9 +++++ source/gameengine/Converter/BL_SkinDeformer.cpp | 5 +-- source/gameengine/Converter/BL_SkinDeformer.h | 8 ++++ source/gameengine/Ketsji/KX_Scene.cpp | 1 + 6 files changed, 68 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 1bde5ad3450..665783a1ba5 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1668,6 +1668,8 @@ static KX_GameObject *gameobject_from_blenderobject( BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj, ob, (BL_SkinMeshObject*)meshobj); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; + if (bHasArmature) + dcont->LoadShapeDrivers(ob->parent); } else if (bHasArmature) { BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj ); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 3ae634905b9..eb5c1467ea5 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -44,9 +44,12 @@ #include "DNA_key_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "DNA_ipo_types.h" +#include "DNA_curve_types.h" #include "BKE_armature.h" #include "BKE_action.h" #include "BKE_key.h" +#include "BKE_ipo.h" #include "MT_Point3.h" extern "C"{ @@ -78,11 +81,55 @@ void BL_ShapeDeformer::ProcessReplica() { } +bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma) +{ + IpoCurve *icu; + + m_shapeDrivers.clear(); + // check if this mesh has armature driven shape keys + if (m_bmesh->key->ipo) { + for(icu= (IpoCurve*)m_bmesh->key->ipo->curve.first; icu; icu= (IpoCurve*)icu->next) { + if(icu->driver && + (icu->flag & IPO_MUTE) == 0 && + icu->driver->type == IPO_DRIVER_TYPE_NORMAL && + icu->driver->ob == arma && + icu->driver->blocktype == ID_AR) { + // this shape key ipo curve has a driver on the parent armature + // record this curve in the shape deformer so that the corresponding + m_shapeDrivers.push_back(icu); + } + } + } + return !m_shapeDrivers.empty(); +} + +bool BL_ShapeDeformer::ExecuteShapeDrivers(void) +{ + if (!m_shapeDrivers.empty() && PoseUpdated()) { + vector::iterator it; + void *poin; + int type; + for (it=m_shapeDrivers.begin(); it!=m_shapeDrivers.end(); it++) { + // no need to set a specific time: this curve has a driver + IpoCurve *icu = *it; + calc_icu(icu, 1.0f); + poin = get_ipo_poin((ID*)m_bmesh->key, icu, &type); + if (poin) + write_ipo_poin(poin, type, icu->curval); + } + ForceUpdate(); + return true; + } + return false; +} + bool BL_ShapeDeformer::Update(void) { bool bShapeUpdate = false; bool bSkinUpdate = false; + ExecuteShapeDrivers(); + /* See if the object shape has changed */ if (m_lastShapeUpdate != m_gameobj->GetLastFrame()) { /* the key coefficient have been set already, we just need to blend the keys */ diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 9bbdde3fb2c..9f8361dbaca 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -38,6 +38,7 @@ #include "BL_DeformableGameObject.h" #include +struct IpoCurve; class BL_ShapeDeformer : public BL_SkinDeformer { @@ -82,8 +83,16 @@ public: virtual ~BL_ShapeDeformer(); bool Update (void); + bool LoadShapeDrivers(Object* arma); + bool ExecuteShapeDrivers(void); + + void ForceUpdate() + { + m_lastShapeUpdate = -1.0; + }; protected: + vector m_shapeDrivers; double m_lastShapeUpdate; BL_DeformableGameObject* m_gameobj; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 1015221c392..dd7119b1031 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -149,12 +149,9 @@ void BL_SkinDeformer::ProcessReplica() bool BL_SkinDeformer::Update(void) { /* See if the armature has been updated for this frame */ - if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()){ + if (PoseUpdated()){ float obmat[4][4]; // the original object matrice - /* Do all of the posing necessary */ - m_armobj->ApplyPose(); - /* XXX note: where_is_pose() (from BKE_armature.h) calculates all matrices needed to start deforming */ /* but it requires the blender object pointer... */ diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index 603e716fb1e..c5568c049cb 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -79,6 +79,14 @@ public: virtual ~BL_SkinDeformer(); bool Update (void); bool Apply (class RAS_IPolyMaterial *polymat); + bool PoseUpdated(void) + { + if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) { + m_armobj->ApplyPose(); + return true; + } + return false; + } void ForceUpdate() { diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 1526709f425..a7e91e27df3 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -866,6 +866,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) static_cast( parentobj ) ); releaseParent= false; + shapeDeformer->LoadShapeDrivers(blendobj->parent); } else { -- cgit v1.2.3 From c353af4d3a1ce51125b81f023c8725855906601e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 25 Jun 2008 14:09:15 +0000 Subject: BGE patch 15044 approved: Edit Object Dynamics Actuator. Add enable/disable dynamics actuator under the "Edit Object" category. The Enable/disable rigid body option is also availale but not implemented. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 10 + source/gameengine/Ketsji/KX_GameObject.cpp | 25 +-- source/gameengine/Ketsji/KX_GameObject.h | 28 ++- .../gameengine/Ketsji/KX_SCA_DynamicActuator.cpp | 206 +++++++++++++++++++++ source/gameengine/Ketsji/KX_SCA_DynamicActuator.h | 76 ++++++++ 5 files changed, 321 insertions(+), 24 deletions(-) create mode 100644 source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp create mode 100644 source/gameengine/Ketsji/KX_SCA_DynamicActuator.h (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index f0b549594f2..a50c072914d 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -62,6 +62,7 @@ #include "KX_SCA_EndObjectActuator.h" #include "KX_SCA_ReplaceMeshActuator.h" #include "KX_ParentActuator.h" +#include "KX_SCA_DynamicActuator.h" #include "KX_Scene.h" #include "KX_KetsjiEngine.h" @@ -602,6 +603,15 @@ void BL_ConvertActuators(char* maggiename, blenderobject->upflag ); baseact = tmptrackact; + break; + } + case ACT_EDOB_DYNAMICS: + { + KX_SCA_DynamicActuator* tmpdynact + = new KX_SCA_DynamicActuator(gameobj, + editobact->dyn_operation + ); + baseact = tmpdynact; } } break; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index cdbce81d610..4b467a229f0 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1283,17 +1283,7 @@ PyObject* KX_GameObject::PySuspendDynamics(PyObject* self, PyObject* args, PyObject* kwds) { - if (m_bSuspendDynamics) - { - Py_Return; - } - - if (m_pPhysicsController1) - { - m_pPhysicsController1->SuspendDynamics(); - } - m_bSuspendDynamics = true; - + SuspendDynamics(); Py_Return; } @@ -1303,18 +1293,7 @@ PyObject* KX_GameObject::PyRestoreDynamics(PyObject* self, PyObject* args, PyObject* kwds) { - - if (!m_bSuspendDynamics) - { - Py_Return; - } - - if (m_pPhysicsController1) - { - m_pPhysicsController1->RestoreDynamics(); - } - m_bSuspendDynamics = false; - + RestoreDynamics(); Py_Return; } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index cab1f3167d5..a0507cb9dbc 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -46,7 +46,7 @@ #include "GEN_HashedPtr.h" #include "KX_Scene.h" #include "KX_KetsjiEngine.h" /* for m_anim_framerate */ - +#include "KX_IPhysicsController.h" /* for suspend/resume */ #define KX_OB_DYNAMIC 1 @@ -652,6 +652,32 @@ public: */ void Resume(void); + void SuspendDynamics(void) { + if (m_bSuspendDynamics) + { + return; + } + + if (m_pPhysicsController1) + { + m_pPhysicsController1->SuspendDynamics(); + } + m_bSuspendDynamics = true; + } + + void RestoreDynamics(void) { + if (!m_bSuspendDynamics) + { + return; + } + + if (m_pPhysicsController1) + { + m_pPhysicsController1->RestoreDynamics(); + } + m_bSuspendDynamics = false; + } + KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; } /** * @section Python interface functions. diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp new file mode 100644 index 00000000000..d44ab477749 --- /dev/null +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp @@ -0,0 +1,206 @@ +// +// Adjust dynamics settins for this object +// +// $Id$ +// +// ***** BEGIN GPL LICENSE BLOCK ***** +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +// All rights reserved. +// +// The Original Code is: all of this file. +// +// Contributor(s): none yet. +// +// ***** END GPL LICENSE BLOCK ***** + +// +// Previously existed as: + +// \source\gameengine\GameLogic\SCA_DynamicActuator.cpp + +// Please look here for revision history. + +#include "KX_SCA_DynamicActuator.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ + + PyTypeObject + +KX_SCA_DynamicActuator:: + +Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "KX_SCA_DynamicActuator", + sizeof(KX_SCA_DynamicActuator), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, + __repr, + 0, + 0, + 0, + 0, + 0 +}; + +PyParentObject KX_SCA_DynamicActuator::Parents[] = { + &KX_SCA_DynamicActuator::Type, + &SCA_IActuator::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + + +PyMethodDef KX_SCA_DynamicActuator::Methods[] = { + KX_PYMETHODTABLE(KX_SCA_DynamicActuator, setOperation), + KX_PYMETHODTABLE(KX_SCA_DynamicActuator, getOperation), + {NULL,NULL} //Sentinel +}; + + + +PyObject* KX_SCA_DynamicActuator::_getattr(const STR_String& attr) +{ + _getattr_up(SCA_IActuator); +} + + + +/* 1. setOperation */ +KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, setOperation, +"setOperation(operation?)\n" +"\t - operation? : type of dynamic operation\n" +"\t 0 = restore dynamics\n" +"\t 1 = disable dynamics\n" +"\t 2 = enable rigid body\n" +"\t 3 = disable rigid body\n" +"Change the dynamic status of the parent object.\n") +{ + int dyn_operation; + + if (!PyArg_ParseTuple(args, "i", &dyn_operation)) + { + return NULL; + } + if (dyn_operation <0 || dyn_operation>3) { + PyErr_SetString(PyExc_IndexError, "Dynamic Actuator's setOperation() range must be between 0 and 3"); + return NULL; + } + m_dyn_operation= dyn_operation; + Py_Return; +} + +KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, getOperation, +"getOperation() -> integer\n" +"Returns the operation type of this actuator.\n" +) +{ + return PyInt_FromLong((long)m_dyn_operation); +} + + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +KX_SCA_DynamicActuator::KX_SCA_DynamicActuator(SCA_IObject *gameobj, + short dyn_operation, + PyTypeObject* T) : + + SCA_IActuator(gameobj, T), + m_dyn_operation(dyn_operation) +{ +} /* End of constructor */ + + +KX_SCA_DynamicActuator::~KX_SCA_DynamicActuator() +{ + // there's nothing to be done here, really.... +} /* end of destructor */ + + + +bool KX_SCA_DynamicActuator::Update() +{ + // bool result = false; /*unused*/ + KX_GameObject *obj = (KX_GameObject*) GetParent(); + bool bNegativeEvent = IsNegativeEvent(); + KX_IPhysicsController* controller; + RemoveAllEvents(); + + if (bNegativeEvent) + return false; // do nothing on negative events + + if (!obj) + return false; // object not accessible, shouldnt happen + controller = obj->GetPhysicsController(); + if (!controller) + return false; // no physic object + + switch (m_dyn_operation) + { + case 0: + obj->RestoreDynamics(); + break; + case 1: + obj->SuspendDynamics(); + break; + case 2: + controller->setRigidBody(true); + break; + case 3: + controller->setRigidBody(false); + break; + } + + return false; +} + + + +CValue* KX_SCA_DynamicActuator::GetReplica() +{ + KX_SCA_DynamicActuator* replica = + new KX_SCA_DynamicActuator(*this); + + if (replica == NULL) + return NULL; + + replica->ProcessReplica(); + + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +}; + + +/* eof */ diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h new file mode 100644 index 00000000000..b47c3a511d9 --- /dev/null +++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h @@ -0,0 +1,76 @@ +// +// Add object to the game world on action of this actuator +// +// $Id$ +// +// ***** BEGIN GPL LICENSE BLOCK ***** +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software Foundation, +// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +// The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +// All rights reserved. +// +// The Original Code is: all of this file. +// +// Contributor(s): Campbell Barton +// +// ***** END GPL LICENSE BLOCK ***** +// + +#ifndef __KX_SCA_DYNAMICACTUATOR +#define __KX_SCA_DYNAMICACTUATOR + +#include "SCA_IActuator.h" +#include "SCA_PropertyActuator.h" +#include "SCA_LogicManager.h" + +#include "KX_GameObject.h" +#include "KX_IPhysicsController.h" + +class KX_SCA_DynamicActuator : public SCA_IActuator +{ + Py_Header; + + // dynamics operation to apply to the game object + short m_dyn_operation; + public: + KX_SCA_DynamicActuator( + SCA_IObject* gameobj, + short dyn_operation, + PyTypeObject* T=&Type + ); + + ~KX_SCA_DynamicActuator( + ); + + CValue* + GetReplica( + ); + + virtual bool + Update(); + + virtual PyObject* + _getattr( + const STR_String& attr + ); + + /* 1. setOperation */ + KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,setOperation); + KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,getOperation); + +}; + +#endif -- cgit v1.2.3 From 84c4e89eba40d13795ce6b808f2faf3771ba2550 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Jun 2008 16:09:29 +0000 Subject: Commented out face transp changing when switching images, this is more annoying then helpful. Edited Game engine docs to note that the matrix will need to be transposed if used with Mathutils.Matrix() Edited "Collision" button since ray-sensor also uses collision. --- source/gameengine/PyDoc/KX_GameObject.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index ff55f975543..abcf5a942dd 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -50,8 +50,9 @@ class KX_GameObject: """ Sets the game object's orientation. - @type orn: 3x3 inverted rotation matrix, or Quaternion. + @type orn: 3x3 rotation matrix, or Quaternion. @param orn: a rotation matrix specifying the new rotation. + @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed. """ def alignAxisToVect(vect, axis): """ @@ -71,6 +72,7 @@ class KX_GameObject: @rtype: 3x3 inverted rotation matrix @return: The game object's rotation matrix + @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed. """ def getLinearVelocity(local): """ -- cgit v1.2.3 From 11cdc2a002c5baf1a1405e7dc246cacbd2d9392d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Jun 2008 12:39:06 +0000 Subject: Python API/Game engine fixes, dosn't affect 2.47 * Action FrameProp was checking if the string was true, not that it contained any text. * Added GameObject.getVisible() since there is already a getVisible * Added GameObject.getPropertyNames() Needed in apricot so Franky can collect and throw items in the level without having the names defined elsewhere or modifying his game logic which is stored in a separate blend file. --- source/gameengine/Converter/BL_ActionActuator.cpp | 2 +- source/gameengine/Expressions/Value.cpp | 24 ++++++++++++++++++----- source/gameengine/Expressions/Value.h | 2 ++ source/gameengine/Ketsji/KX_GameObject.cpp | 15 ++++++++++++++ source/gameengine/Ketsji/KX_GameObject.h | 3 +++ source/gameengine/PyDoc/KX_GameObject.py | 15 ++++++++++++-- 6 files changed, 53 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 83be5d3a14f..5050da3fe7f 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -350,7 +350,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) } /* Set the property if its defined */ - if (m_framepropname) { + if (m_framepropname[0] != '\0') { CValue* propowner = GetParent(); CValue* oldprop = propowner->GetProperty(m_framepropname); CValue* newval = new CFloatValue(m_localtime); diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 56208ab4ad5..f0195d5df82 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -520,11 +520,6 @@ void CValue::CloneProperties(CValue *replica) } - - - - - double* CValue::GetVector3(bool bGetTransformedVec) { assertd(false); // don;t get vector from me @@ -775,6 +770,25 @@ int CValue::_setattr(const STR_String& attr,PyObject* pyobj) //PyObjectPlus::_setattr(attr,value); return 0; }; + +PyObject* CValue::ConvertKeysToPython( void ) +{ + PyObject *pylist = PyList_New( 0 ); + PyObject *pystr; + + if (m_pNamedPropertyArray) + { + for ( std::map::iterator it = m_pNamedPropertyArray->begin(); + !(it == m_pNamedPropertyArray->end());it++) + { + pystr = PyString_FromString( (*it).first ); + PyList_Append(pylist, pystr); + Py_DECREF( pystr ); + } + } + return pylist; +} + /* PyObject* CValue::PyMake(PyObject* ignored,PyObject* args) { diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index ccb9c34749d..561e5521d60 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -253,6 +253,8 @@ public: virtual int _delattr(const STR_String& attr); virtual int _setattr(const STR_String& attr,PyObject* value); + virtual PyObject* ConvertKeysToPython( void ); + KX_PYMETHOD(CValue,GetName); #else diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 4b467a229f0..3ca5f5809e6 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -803,6 +803,7 @@ void KX_GameObject::Suspend(void) PyMethodDef KX_GameObject::Methods[] = { {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS}, + {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_VARARGS}, {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS}, {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_VARARGS}, {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_VARARGS}, @@ -823,6 +824,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_VARARGS}, {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS}, + {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_VARARGS}, KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), KX_PYMETHODTABLE(KX_GameObject, rayCastTo), KX_PYMETHODTABLE(KX_GameObject, rayCast), @@ -1095,6 +1097,12 @@ PyObject* KX_GameObject::PySetVisible(PyObject* self, } +PyObject* KX_GameObject::PyGetVisible(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + return PyInt_FromLong(m_bVisible); +} PyObject* KX_GameObject::PyGetVelocity(PyObject* self, @@ -1383,6 +1391,13 @@ PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self, return PyInt_FromLong((long)physid); } +PyObject* KX_GameObject::PyGetPropertyNames(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + return ConvertKeysToPython(); +} + KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo, "getDistanceTo(other): get distance to another point/KX_GameObject") { diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index a0507cb9dbc..796cb4a161f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -718,6 +718,7 @@ public: KX_PYMETHOD(KX_GameObject,GetReactionForce); KX_PYMETHOD(KX_GameObject,GetOrientation); KX_PYMETHOD(KX_GameObject,SetOrientation); + KX_PYMETHOD(KX_GameObject,GetVisible); KX_PYMETHOD(KX_GameObject,SetVisible); KX_PYMETHOD(KX_GameObject,AlignAxisToVect); KX_PYMETHOD(KX_GameObject,SuspendDynamics); @@ -731,9 +732,11 @@ public: KX_PYMETHOD(KX_GameObject,SetParent); KX_PYMETHOD(KX_GameObject,RemoveParent); KX_PYMETHOD(KX_GameObject,GetPhysicsId); + KX_PYMETHOD(KX_GameObject,GetPropertyNames); KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); KX_PYMETHOD_DOC(KX_GameObject,rayCast); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); + private : /** diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index abcf5a942dd..572ac2d42ae 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -25,7 +25,12 @@ class KX_GameObject: @ivar timeOffset: adjust the slowparent delay at runtime. @type timeOffset: float """ - + def getVisible(visible): + """ + Gets the game object's visible flag. + + @type visible: boolean + """ def setVisible(visible): """ Sets the game object's visible flag. @@ -176,6 +181,12 @@ class KX_GameObject: """ Returns the user data object associated with this game object's physics controller. """ + def getPropertyNames(): + """ + Gets a list of all property names. + @rtype: list + @return: All property names for this object. + """ def getDistanceTo(other): """ Returns the distance to another object or point. @@ -216,7 +227,7 @@ class KX_GameObject: If is casted from/to object center or explicit [x,y,z] points. The ray does not have X-Ray capability: the first object hit (other than self object) stops the ray If a property was specified and the first object hit does not have that property, there is no hit - The ray ignores collision-free objects + The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects. @param to: [x,y,z] or object to which the ray is casted @type to: L{KX_GameObject} or 3-tuple -- cgit v1.2.3 From f0a3cbcdac4c7f84daef7c33e858a10277400a5f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 27 Jun 2008 11:35:55 +0000 Subject: patch [#15865] BGE API call to delete objects from Dalai Felinto (dfelinto) renamed deleteObject to endObject() to match the user interface. --- source/gameengine/Ketsji/KX_GameObject.cpp | 13 +++++++++++++ source/gameengine/Ketsji/KX_GameObject.h | 3 ++- source/gameengine/PyDoc/KX_GameObject.py | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 3ca5f5809e6..fd06b223216 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -825,6 +825,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS}, {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_VARARGS}, + {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_VARARGS}, KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), KX_PYMETHODTABLE(KX_GameObject, rayCastTo), KX_PYMETHODTABLE(KX_GameObject, rayCast), @@ -858,6 +859,18 @@ PyObject* KX_GameObject::sPySetPosition(PyObject* self, } +PyObject* KX_GameObject::PyEndObject(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + + KX_Scene *scene = PHY_GetActiveScene(); + scene->DelayedRemoveObject(this); + + return Py_None; + +} + PyObject* KX_GameObject::PyGetPosition(PyObject* self, PyObject* args, diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 796cb4a161f..682b339bf62 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -710,7 +710,7 @@ public: PyObject* args, PyObject* kwds ); - + KX_PYMETHOD(KX_GameObject,GetPosition); KX_PYMETHOD(KX_GameObject,GetLinearVelocity); KX_PYMETHOD(KX_GameObject,GetVelocity); @@ -733,6 +733,7 @@ public: KX_PYMETHOD(KX_GameObject,RemoveParent); KX_PYMETHOD(KX_GameObject,GetPhysicsId); KX_PYMETHOD(KX_GameObject,GetPropertyNames); + KX_PYMETHOD(KX_GameObject,EndObject); KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); KX_PYMETHOD_DOC(KX_GameObject,rayCast); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 572ac2d42ae..f971a7f5f54 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -25,6 +25,11 @@ class KX_GameObject: @ivar timeOffset: adjust the slowparent delay at runtime. @type timeOffset: float """ + def endObject(visible): + """ + Delete this object, can be used inpace of the EndObject Actuator. + The actual removal of the object from the scene is delayed. + """ def getVisible(visible): """ Gets the game object's visible flag. -- cgit v1.2.3 From 1231a2171adf1f5ce596eb12a018978bb6a39695 Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Sat, 28 Jun 2008 03:18:11 +0000 Subject: BGE 2d-filter, custom shaders now can have depth texture and luminance texture --- .../BlenderRoutines/KX_BlenderRenderTools.cpp | 4 +- .../BlenderRoutines/KX_BlenderRenderTools.h | 2 +- .../gameengine/Converter/KX_ConvertActuators.cpp | 2 +- .../gameengine/GameLogic/SCA_2DFilterActuator.cpp | 4 +- source/gameengine/GameLogic/SCA_2DFilterActuator.h | 2 + .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 101 +++++++++++++++++---- source/gameengine/Rasterizer/RAS_2DFilterManager.h | 10 +- source/gameengine/Rasterizer/RAS_IRenderTools.h | 2 +- 8 files changed, 99 insertions(+), 28 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 07a3649aa0f..73d2870720a 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -483,9 +483,9 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) +void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag) { - m_filtermanager.EnableFilter(filtermode, pass, text); + m_filtermanager.EnableFilter(filtermode, pass, text, texture_flag); } void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 31eaa14d66b..7748e31156d 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -101,7 +101,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a50c072914d..ea26c55a44e 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -944,7 +944,7 @@ void BL_ConvertActuators(char* maggiename, } tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, - _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools); + _2dfilter->float_arg,_2dfilter->int_arg,_2dfilter->texture_flag,ketsjiEngine->GetRasterizer(),rendertools); if (_2dfilter->text) { diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index f3b5b1fdda2..56249bb52ec 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -18,6 +18,7 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( short flag, float float_arg, int int_arg, + short texture_flag, RAS_IRasterizer* rasterizer, RAS_IRenderTools* rendertools, PyTypeObject* T) @@ -25,6 +26,7 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( m_type(type), m_flag(flag), m_int_arg(int_arg), + m_texture_flag(texture_flag), m_float_arg(float_arg), m_rasterizer(rasterizer), m_rendertools(rendertools) @@ -72,7 +74,7 @@ bool SCA_2DFilterActuator::Update() } else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) { - m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText); + m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText, m_texture_flag); } return true; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 7b0cfff951e..451a7b9491a 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -16,6 +16,7 @@ private: short m_flag; float m_float_arg; int m_int_arg; + short m_texture_flag; STR_String m_shaderText; RAS_IRasterizer* m_rasterizer; RAS_IRenderTools* m_rendertools; @@ -28,6 +29,7 @@ public: short flag, float float_arg, int int_arg, + short texture_flag, RAS_IRasterizer* rasterizer, RAS_IRenderTools* rendertools, PyTypeObject* T=&Type diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index e9ab4ccca8d..e2761ce0a15 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -54,7 +54,7 @@ RAS_2DFilterManager::RAS_2DFilterManager(): -texname(-1), texturewidth(-1), textureheight(-1), +texturewidth(-1), textureheight(-1), canvaswidth(-1), canvasheight(-1), numberoffilters(0) { @@ -72,8 +72,9 @@ numberoffilters(0) { m_filters[passindex] = 0; m_enabled[passindex] = 0; + texflag[passindex] = 0; } - + texname[0] = texname[1] = texname[2] = -1; } RAS_2DFilterManager::~RAS_2DFilterManager() @@ -150,30 +151,54 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) return 0; } -void RAS_2DFilterManager::StartShaderProgram(unsigned int shaderprogram) +void RAS_2DFilterManager::StartShaderProgram(int passindex) { GLint uniformLoc; - glUseProgramObjectARB(shaderprogram); - uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTexture"); + glUseProgramObjectARB(m_filters[passindex]); + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTexture"); glActiveTextureARB(GL_TEXTURE0); - //glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, texname); + glBindTexture(GL_TEXTURE_2D, texname[0]); if (uniformLoc != -1) { glUniform1iARB(uniformLoc, 0); } - uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_TextureCoordinateOffset"); + + /* send depth texture to glsl program if it needs */ + if(texflag[passindex] & 0x1){ + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture"); + glActiveTextureARB(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texname[1]); + + if (uniformLoc != -1) + { + glUniform1iARB(uniformLoc, 1); + } + } + + /* send luminance texture to glsl program if it needs */ + if(texflag[passindex] & 0x1){ + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture"); + glActiveTextureARB(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, texname[2]); + + if (uniformLoc != -1) + { + glUniform1iARB(uniformLoc, 2); + } + } + + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_TextureCoordinateOffset"); if (uniformLoc != -1) { glUniform2fvARB(uniformLoc, 9, textureoffsets); } - uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureWidth"); + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureWidth"); if (uniformLoc != -1) { glUniform1fARB(uniformLoc,texturewidth); } - uniformLoc = glGetUniformLocationARB(shaderprogram, "bgl_RenderedTextureHeight"); + uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureHeight"); if (uniformLoc != -1) { glUniform1fARB(uniformLoc,textureheight); @@ -187,14 +212,33 @@ void RAS_2DFilterManager::EndShaderProgram() void RAS_2DFilterManager::SetupTexture() { - if(texname!=-1) + if(texname[0]!=-1 || texname[1]!=-1) { - glDeleteTextures(1,(const GLuint *)&texname); + glDeleteTextures(2, texname); } - glGenTextures(1, (GLuint *)&texname); - glBindTexture(GL_TEXTURE_2D, texname); + glGenTextures(3, texname); + + glBindTexture(GL_TEXTURE_2D, texname[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGB, - GL_UNSIGNED_BYTE, 0); + GL_UNSIGNED_BYTE, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glBindTexture(GL_TEXTURE_2D, texname[1]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight, 0, GL_DEPTH_COMPONENT, + GL_FLOAT,NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, + GL_NONE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + glBindTexture(GL_TEXTURE_2D, texname[2]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, texturewidth, textureheight, 0, GL_LUMINANCE, + GL_UNSIGNED_BYTE, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); @@ -246,12 +290,27 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) int passindex; bool first = true; + for(passindex =0; passindex Date: Sat, 28 Jun 2008 14:19:25 +0000 Subject: BGE , fix an compile error --- source/gameengine/GamePlayer/common/GPC_RenderTools.cpp | 4 ++-- source/gameengine/GamePlayer/common/GPC_RenderTools.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 44eeccedbd1..a5017574873 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -602,9 +602,9 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) +void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag) { - m_filtermanager.EnableFilter(filtermode, pass, text); + m_filtermanager.EnableFilter(filtermode, pass, text, texture_flag); } void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index f7230cb0865..cb7193f3513 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -142,7 +142,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); + virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag); virtual void Render2DFilters(RAS_ICanvas* canvas); -- cgit v1.2.3 From 7056d63f418dfcfd774d7dce27aa442939daf7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Luc=20Peuri=C3=A8re?= Date: Sun, 29 Jun 2008 12:25:15 +0000 Subject: adding explicit cast to get things compiling --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index e2761ce0a15..23153fcd86c 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -214,9 +214,9 @@ void RAS_2DFilterManager::SetupTexture() { if(texname[0]!=-1 || texname[1]!=-1) { - glDeleteTextures(2, texname); + glDeleteTextures(2, (GLuint*)texname); } - glGenTextures(3, texname); + glGenTextures(3, (GLuint*)texname); glBindTexture(GL_TEXTURE_2D, texname[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGB, -- cgit v1.2.3 From ab7794392e9708ddbba24d9b444f61c06b19099b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 29 Jun 2008 21:51:27 +0000 Subject: Fix for bug #7753: after game engine drawing with vertex arrays, nurbs/curves/text dissappears. This also removes the "vertex arrays" option and enables it always for OpenGL version >= 1.1 - there's no need to have an option to make things render faster disabled by default, also it should work stable now. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 34 +++++++++------------- .../GamePlayer/ghost/GPG_Application.cpp | 12 ++++---- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 3 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 3 ++ .../RAS_VAOpenGLRasterizer.cpp | 5 ++-- 5 files changed, 26 insertions(+), 31 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 06aa0609ad9..4af5ac4d5d2 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -165,20 +165,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, RAS_IRenderTools* rendertools = new KX_BlenderRenderTools(); RAS_IRasterizer* rasterizer = NULL; - // let's see if we want to use vertexarrays or not - int usevta = SYS_GetCommandLineInt(syshandle,"vertexarrays",1); - bool useVertexArrays = (usevta > 0); - - bool lock_arrays = (displaylists && useVertexArrays); - - if(displaylists){ - if (useVertexArrays) - rasterizer = new RAS_ListRasterizer(canvas, true, lock_arrays); + if(displaylists) { + if (GLEW_VERSION_1_1) + rasterizer = new RAS_ListRasterizer(canvas, true, true); else rasterizer = new RAS_ListRasterizer(canvas); } - else if (useVertexArrays && GLEW_VERSION_1_1) - rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays); + else if (GLEW_VERSION_1_1) + rasterizer = new RAS_VAOpenGLRasterizer(canvas, false); else rasterizer = new RAS_OpenGLRasterizer(canvas); @@ -513,16 +507,14 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, RAS_IRenderTools* rendertools = new KX_BlenderRenderTools(); RAS_IRasterizer* rasterizer = NULL; - // let's see if we want to use vertexarrays or not - int usevta = SYS_GetCommandLineInt(syshandle,"vertexarrays",1); - bool useVertexArrays = (usevta > 0); - - bool lock_arrays = (displaylists && useVertexArrays); - - if(displaylists && !useVertexArrays) - rasterizer = new RAS_ListRasterizer(canvas); - else if (useVertexArrays && GLEW_VERSION_1_1) - rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays); + if(displaylists) { + if (GLEW_VERSION_1_1) + rasterizer = new RAS_ListRasterizer(canvas, true, true); + else + rasterizer = new RAS_ListRasterizer(canvas); + } + else if (GLEW_VERSION_1_1) + rasterizer = new RAS_VAOpenGLRasterizer(canvas, false); else rasterizer = new RAS_OpenGLRasterizer(canvas); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index c4cf698d5ee..d6908b53d40 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -496,7 +496,6 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixed_framerate", fixedFr) != 0); bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); - bool useVertexArrays = SYS_GetCommandLineInt(syshandle,"vertexarrays",1) != 0; bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DIAPLAY_LISTS) != 0); if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) { @@ -514,16 +513,17 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) if (!m_rendertools) goto initFailed; - if(useLists) - if (useVertexArrays) { + if(useLists) { + if(GLEW_VERSION_1_1) m_rasterizer = new RAS_ListRasterizer(m_canvas, true); - } else { + else m_rasterizer = new RAS_ListRasterizer(m_canvas); - } - else if (useVertexArrays && GLEW_VERSION_1_1) + } + else if (GLEW_VERSION_1_1) m_rasterizer = new RAS_VAOpenGLRasterizer(m_canvas); else m_rasterizer = new RAS_OpenGLRasterizer(m_canvas); + m_rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) stereoMode); if (!m_rasterizer) goto initFailed; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index bc80c0a7612..8222e5c8bac 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -187,11 +187,10 @@ void usage(char* program) printf(" show_framerate 0 Show the frame rate\n"); printf(" show_properties 0 Show debug properties\n"); printf(" show_profile 0 Show profiling information\n"); - printf(" vertexarrays 1 Enable vertex arrays\n"); printf(" blender_material 0 Enable material settings\n"); printf("\n"); printf("example: %s -p 10 10 320 200 -g noaudio c:\\loadtest.blend\n", program); - printf("example: %s -g vertexarrays = 0 c:\\loadtest.blend\n", program); + printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program); } char *get_filename(int argc, char **argv) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index d3c0426de86..18147b53f4c 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -125,6 +125,9 @@ static void Myinit_gl_stuff(void) glDisable(GL_TEXTURE_1D); glDisable(GL_TEXTURE_2D); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glPixelTransferi(GL_MAP_COLOR, GL_FALSE); glPixelTransferi(GL_RED_SCALE, 1); glPixelTransferi(GL_RED_BIAS, 0); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index ce76318c2ce..c4702fe5a74 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -91,9 +91,10 @@ void RAS_VAOpenGLRasterizer::SetDrawingMode(int drawingmode) void RAS_VAOpenGLRasterizer::Exit() { - glDisableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_NORMAL_ARRAY); EnableTextures(false); RAS_OpenGLRasterizer::Exit(); -- cgit v1.2.3 From 6a3e8e7fff4e577bea02966546293760c19deec7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 29 Jun 2008 21:52:23 +0000 Subject: BGE python api addition, GameObject get/setState and Controller.getState() Also added a note in the tooltip for action priority when using more then 1 action at a time. --- .../gameengine/GameLogic/SCA_PythonController.cpp | 9 ++++++ source/gameengine/GameLogic/SCA_PythonController.h | 1 + source/gameengine/Ketsji/KX_GameObject.cpp | 35 ++++++++++++++++++++++ source/gameengine/Ketsji/KX_GameObject.h | 2 ++ source/gameengine/PyDoc/KX_GameObject.py | 14 +++++++++ source/gameengine/PyDoc/SCA_PythonController.py | 8 +++++ 6 files changed, 69 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 44cdc0a7de5..be00117cd21 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -232,6 +232,7 @@ PyMethodDef SCA_PythonController::Methods[] = { METH_VARARGS, SCA_PythonController::GetSensor_doc}, {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_VARARGS}, {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_VARARGS}, + {"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_VARARGS}, {NULL,NULL} //Sentinel }; @@ -442,4 +443,12 @@ PyObject* SCA_PythonController::PySetScript(PyObject* self, Py_Return; } +/* 1. getScript */ +PyObject* SCA_PythonController::PyGetState(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + return PyInt_FromLong(m_statemask); +} + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 63975234da9..f3af54f402f 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -81,6 +81,7 @@ class SCA_PythonController : public SCA_IController KX_PYMETHOD_DOC(SCA_PythonController,GetActuators); KX_PYMETHOD(SCA_PythonController,SetScript); KX_PYMETHOD(SCA_PythonController,GetScript); + KX_PYMETHOD(SCA_PythonController,GetState); }; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index fd06b223216..b7750e68e8f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -804,6 +804,8 @@ void KX_GameObject::Suspend(void) PyMethodDef KX_GameObject::Methods[] = { {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS}, {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_VARARGS}, + {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_VARARGS}, + {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_VARARGS}, {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS}, {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_VARARGS}, {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_VARARGS}, @@ -1117,6 +1119,39 @@ PyObject* KX_GameObject::PyGetVisible(PyObject* self, return PyInt_FromLong(m_bVisible); } +PyObject* KX_GameObject::PyGetState(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + int state = 0; + state |= GetState(); + return PyInt_FromLong(state); +} + +PyObject* KX_GameObject::PySetState(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + int state_i; + unsigned int state = 0; + + if (PyArg_ParseTuple(args,"i",&state_i)) + { + state |= state_i; + if ((state & ((1<<30)-1)) == 0) { + PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); + return NULL; + } + SetState(state); + } + else + { + return NULL; + } + Py_Return; +} + + PyObject* KX_GameObject::PyGetVelocity(PyObject* self, PyObject* args, diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 682b339bf62..89f4cb396d1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -720,6 +720,8 @@ public: KX_PYMETHOD(KX_GameObject,SetOrientation); KX_PYMETHOD(KX_GameObject,GetVisible); KX_PYMETHOD(KX_GameObject,SetVisible); + KX_PYMETHOD(KX_GameObject,GetState); + KX_PYMETHOD(KX_GameObject,SetState); KX_PYMETHOD(KX_GameObject,AlignAxisToVect); KX_PYMETHOD(KX_GameObject,SuspendDynamics); KX_PYMETHOD(KX_GameObject,RestoreDynamics); diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index f971a7f5f54..ec7496daa75 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -40,6 +40,20 @@ class KX_GameObject: """ Sets the game object's visible flag. + @type visible: boolean + """ + def getState(): + """ + Gets the game object's state bitmask. + + @rtype: int + @return: the objects state. + """ + def setState(): + """ + Sets the game object's visible flag. + The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29) + @type visible: boolean """ def setPosition(pos): diff --git a/source/gameengine/PyDoc/SCA_PythonController.py b/source/gameengine/PyDoc/SCA_PythonController.py index eb9e57c0819..6d91736d636 100644 --- a/source/gameengine/PyDoc/SCA_PythonController.py +++ b/source/gameengine/PyDoc/SCA_PythonController.py @@ -46,4 +46,12 @@ class SCA_PythonController(SCA_IController): @type script: string. """ + def getState(): + """ + Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active. + This for instance will always be true however you could compare with a previous state to see when the state was activated. + GameLogic.getCurrentController().getState() & GameLogic.getCurrentController().getOwner().getState() + + @rtype: int + """ -- cgit v1.2.3 From 96152f8409d98983630f4246427f795412787ac8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Jul 2008 05:16:08 +0000 Subject: track to would crash (with a C++ assert) if the source and target are in the same location, which I have had happen a few times while testing. --- source/gameengine/Ketsji/KX_TrackToActuator.cpp | 35 +++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index b9792303565..731a610c2eb 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -224,7 +224,8 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) { KX_GameObject* curobj = (KX_GameObject*) GetParent(); MT_Vector3 dir = ((KX_GameObject*)m_object)->NodeGetWorldPosition() - curobj->NodeGetWorldPosition(); - dir.normalize(); + if (dir.length2()) + dir.normalize(); MT_Vector3 up(0,0,1); @@ -250,12 +251,12 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) #endif if (m_allow3D) { - up = (up - up.dot(dir) * dir).normalized(); + up = (up - up.dot(dir) * dir).safe_normalized(); } else { - dir = (dir - up.dot(dir)*up).normalized(); + dir = (dir - up.dot(dir)*up).safe_normalized(); } MT_Vector3 left; @@ -266,8 +267,8 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) case 0: // TRACK X { // (1.0 , 0.0 , 0.0 ) x direction is forward, z (0.0 , 0.0 , 1.0 ) up - left = dir.normalized(); - dir = (left.cross(up)).normalized(); + left = dir.safe_normalized(); + dir = (left.cross(up)).safe_normalized(); mat.setValue ( left[0], dir[0],up[0], left[1], dir[1],up[1], @@ -279,7 +280,7 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) case 1: // TRACK Y { // (0.0 , 1.0 , 0.0 ) y direction is forward, z (0.0 , 0.0 , 1.0 ) up - left = (dir.cross(up)).normalized(); + left = (dir.cross(up)).safe_normalized(); mat.setValue ( left[0], dir[0],up[0], left[1], dir[1],up[1], @@ -291,10 +292,10 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) case 2: // track Z { - left = up.normalized(); - up = dir.normalized(); + left = up.safe_normalized(); + up = dir.safe_normalized(); dir = left; - left = (dir.cross(up)).normalized(); + left = (dir.cross(up)).safe_normalized(); mat.setValue ( left[0], dir[0],up[0], left[1], dir[1],up[1], @@ -306,8 +307,8 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) case 3: // TRACK -X { // (1.0 , 0.0 , 0.0 ) x direction is forward, z (0.0 , 0.0 , 1.0 ) up - left = -dir.normalized(); - dir = -(left.cross(up)).normalized(); + left = -dir.safe_normalized(); + dir = -(left.cross(up)).safe_normalized(); mat.setValue ( left[0], dir[0],up[0], left[1], dir[1],up[1], @@ -319,7 +320,7 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) case 4: // TRACK -Y { // (0.0 , -1.0 , 0.0 ) -y direction is forward, z (0.0 , 0.0 , 1.0 ) up - left = (-dir.cross(up)).normalized(); + left = (-dir.cross(up)).safe_normalized(); mat.setValue ( left[0], -dir[0],up[0], left[1], -dir[1],up[1], @@ -329,10 +330,10 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) } case 5: // track -Z { - left = up.normalized(); - up = -dir.normalized(); + left = up.safe_normalized(); + up = -dir.safe_normalized(); dir = left; - left = (dir.cross(up)).normalized(); + left = (dir.cross(up)).safe_normalized(); mat.setValue ( left[0], dir[0],up[0], left[1], dir[1],up[1], @@ -345,8 +346,8 @@ bool KX_TrackToActuator::Update(double curtime, bool frame) default: { // (1.0 , 0.0 , 0.0 ) -x direction is forward, z (0.0 , 0.0 , 1.0 ) up - left = -dir.normalized(); - dir = -(left.cross(up)).normalized(); + left = -dir.safe_normalized(); + dir = -(left.cross(up)).safe_normalized(); mat.setValue ( left[0], dir[0],up[0], left[1], dir[1],up[1], -- cgit v1.2.3 From bc8364fef030d95f27cff5ae6e068cc78bd1abd5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Jul 2008 13:21:37 +0000 Subject: bugfix, ActionActuator was missing many checks for PyArg_ParseTuple failing. This meant an error in a script could be reported in a different line or script file which makes it quite hard to trace the problem. There were also places where invalid pointers could be used because of this. The whole game engine pyapi probably needs to have these checks added. --- source/gameengine/Converter/BL_ActionActuator.cpp | 33 ++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 5050da3fe7f..44f6ec1af90 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -641,6 +641,9 @@ PyObject* BL_ActionActuator::PySetAction(PyObject* self, m_blendframe = 0; } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -660,6 +663,9 @@ PyObject* BL_ActionActuator::PySetStart(PyObject* self, { m_startframe = start; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -679,6 +685,9 @@ PyObject* BL_ActionActuator::PySetEnd(PyObject* self, { m_endframe = end; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -699,6 +708,9 @@ PyObject* BL_ActionActuator::PySetBlendin(PyObject* self, { m_blendin = blendin; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -724,6 +736,9 @@ PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self, if (m_blendframe>m_blendin) m_blendframe = m_blendin; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -745,6 +760,9 @@ PyObject* BL_ActionActuator::PySetPriority(PyObject* self, { m_priority = priority; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -768,6 +786,9 @@ PyObject* BL_ActionActuator::PySetFrame(PyObject* self, else if (m_localtime>m_endframe) m_localtime=m_endframe; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -788,6 +809,9 @@ PyObject* BL_ActionActuator::PySetProperty(PyObject* self, { m_propname = string; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -807,6 +831,9 @@ PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self, { m_framepropname = string; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -822,6 +849,9 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self, { m_propname = string; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -846,7 +876,8 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self, int row,col; int mode = 0; /* 0 for bone space, 1 for armature/world space */ - PyArg_ParseTuple(args,"sO|i", &string, &pylist, &mode); + if (!PyArg_ParseTuple(args,"sO|i", &string, &pylist, &mode)) + return NULL; if (pylist->ob_type == &CListValue::Type) { -- cgit v1.2.3 From b0958b6646b3b1fa8127f7620ce00e63ff82d0e7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Jul 2008 16:43:46 +0000 Subject: Checked all cases where PyArg_ParseTuple is used in blenders game engine and made sure all will raise errors when called with invalid args. --- .../Converter/BL_ShapeActionActuator.cpp | 24 +++++++++ source/gameengine/Ketsji/BL_Shader.cpp | 2 +- .../Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp | 14 ++++- .../Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 3 ++ source/gameengine/Ketsji/KX_Camera.cpp | 8 ++- source/gameengine/Ketsji/KX_GameObject.cpp | 9 +++- source/gameengine/Ketsji/KX_MeshProxy.cpp | 12 +++++ .../gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp | 12 +++++ .../gameengine/Ketsji/KX_PyConstraintBinding.cpp | 63 +++++++++++++++++++++- source/gameengine/Ketsji/KX_PythonInit.cpp | 20 ++++++- source/gameengine/Ketsji/KX_VehicleWrapper.cpp | 33 +++++++++--- 11 files changed, 187 insertions(+), 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 58d46d76e5b..7196b393ed4 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -604,6 +604,9 @@ PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self, m_blendframe = 0.f; } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -623,6 +626,9 @@ PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self, { m_startframe = start; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -642,6 +648,9 @@ PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self, { m_endframe = end; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -662,6 +671,9 @@ PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self, { m_blendin = blendin; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -687,6 +699,9 @@ PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self, if (m_blendframe>m_blendin) m_blendframe = m_blendin; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -708,6 +723,9 @@ PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, { m_priority = priority; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -731,6 +749,9 @@ PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self, else if (m_localtime>m_endframe) m_localtime=m_endframe; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; @@ -751,6 +772,9 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, { m_propname = string; } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 15350db6650..f6f9a29b0e2 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -812,7 +812,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProg mUse = 0; Py_Return; } - Py_Return; + return NULL; } diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index 3ade810c394..85921ae75ca 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -158,6 +158,9 @@ PyObject* KX_NetworkMessageActuator::PySetToPropName( if (PyArg_ParseTuple(args, "s", &ToPropName)) { m_toPropName = ToPropName; } + else { + return NULL; + } Py_Return; } @@ -173,7 +176,10 @@ PyObject* KX_NetworkMessageActuator::PySetSubject( if (PyArg_ParseTuple(args, "s", &Subject)) { m_subject = Subject; } - + else { + return NULL; + } + Py_Return; } @@ -188,6 +194,9 @@ PyObject* KX_NetworkMessageActuator::PySetBodyType( if (PyArg_ParseTuple(args, "i", &BodyType)) { m_bodyType = BodyType; } + else { + return NULL; + } Py_Return; } @@ -203,6 +212,9 @@ PyObject* KX_NetworkMessageActuator::PySetBody( if (PyArg_ParseTuple(args, "s", &Body)) { m_body = Body; } + else { + return NULL; + } Py_Return; } diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 027cb2a0ffa..0c66ac1fde3 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -233,6 +233,9 @@ PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText( { m_subject = Subject; } + else { + return NULL; + } Py_Return; } diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 27e47d72bbe..3830d422138 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -588,7 +588,7 @@ KX_PYMETHODDEF_DOC(KX_Camera, sphereInsideFrustum, PyErr_SetString(PyExc_TypeError, "sphereInsideFrustum: Expected arguments: (center, radius)"); - Py_Return; + return NULL; } KX_PYMETHODDEF_DOC(KX_Camera, boxInsideFrustum, @@ -766,6 +766,10 @@ KX_PYMETHODDEF_DOC(KX_Camera, enableViewport, else EnableViewport(false); } + else { + return NULL; + } + Py_Return; } @@ -777,6 +781,8 @@ KX_PYMETHODDEF_DOC(KX_Camera, setViewport, if (PyArg_ParseTuple(args,"iiii",&left, &bottom, &right, &top)) { SetViewport(left, bottom, right, top); + } else { + return NULL; } Py_Return; } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index b7750e68e8f..ee8161702e1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1168,6 +1168,9 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* self, if (pypos) PyVecTo(pypos, point); } + else { + return NULL; + } if (m_pPhysicsController1) { @@ -1256,6 +1259,10 @@ PyObject* KX_GameObject::PySetParent(PyObject* self, this->SetParent(scene, obj); } + else { + return NULL; + } + Py_Return; } @@ -1282,7 +1289,7 @@ PyObject* KX_GameObject::PyGetMesh(PyObject* self, return meshproxy; } } - Py_Return; + return NULL; } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 5c8fef1fca0..c7a251751cd 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -157,6 +157,9 @@ PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* self, { matname = m_meshobj->GetMaterialName(matid); } + else { + return NULL; + } return PyString_FromString(matname.Ptr()); @@ -174,6 +177,9 @@ PyObject* KX_MeshProxy::PyGetTextureName(PyObject* self, { matname = m_meshobj->GetTextureName(matid); } + else { + return NULL; + } return PyString_FromString(matname.Ptr()); @@ -195,6 +201,9 @@ PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* self, length = m_meshobj->GetVertexArrayLength(mat); } } + else { + return NULL; + } return PyInt_FromLong(length); @@ -217,6 +226,9 @@ PyObject* KX_MeshProxy::PyGetVertex(PyObject* self, vertexob = new KX_VertexProxy(this, vertex); } } + else { + return NULL; + } return vertexob; diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index 27cfaefc076..2df4c6a9980 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -58,6 +58,9 @@ PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* self, { m_ctrl->setPosition(x,y,z); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -72,6 +75,9 @@ PyObject* KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject* self, { m_ctrl->SetLinearVelocity(x,y,z,local != 0); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -85,6 +91,9 @@ PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self, { m_ctrl->SetAngularVelocity(x,y,z,local != 0); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -97,6 +106,9 @@ PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self, { m_ctrl->SetActive(active!=0); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 172882ff18d..c01d6a632a3 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -82,12 +82,15 @@ static PyObject* gPySetGravity(PyObject* self, PyObject* kwds) { float x,y,z; - int len = PyTuple_Size(args); - if ((len == 3) && PyArg_ParseTuple(args,"fff",&x,&y,&z)) + if (PyArg_ParseTuple(args,"fff",&x,&y,&z)) { if (PHY_GetActiveEnvironment()) PHY_GetActiveEnvironment()->setGravity(x,y,z); } + else { + return NULL; + } + Py_INCREF(Py_None); return Py_None; } @@ -105,6 +108,10 @@ static PyObject* gPySetDebugMode(PyObject* self, } } + else { + return NULL; + } + Py_INCREF(Py_None); return Py_None; } @@ -122,6 +129,9 @@ static PyObject* gPySetNumTimeSubSteps(PyObject* self, PHY_GetActiveEnvironment()->setNumTimeSubSteps(substep); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -138,6 +148,9 @@ static PyObject* gPySetNumIterations(PyObject* self, PHY_GetActiveEnvironment()->setNumIterations(iter); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -155,6 +168,9 @@ static PyObject* gPySetDeactivationTime(PyObject* self, PHY_GetActiveEnvironment()->setDeactivationTime(deactive_time); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -171,6 +187,9 @@ static PyObject* gPySetDeactivationLinearTreshold(PyObject* self, PHY_GetActiveEnvironment()->setDeactivationLinearTreshold( linearDeactivationTreshold); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -187,6 +206,9 @@ static PyObject* gPySetDeactivationAngularTreshold(PyObject* self, PHY_GetActiveEnvironment()->setDeactivationAngularTreshold( angularDeactivationTreshold); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -202,6 +224,9 @@ static PyObject* gPySetContactBreakingTreshold(PyObject* self, PHY_GetActiveEnvironment()->setContactBreakingTreshold( contactBreakingTreshold); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -218,6 +243,9 @@ static PyObject* gPySetCcdMode(PyObject* self, PHY_GetActiveEnvironment()->setCcdMode( ccdMode); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -233,6 +261,9 @@ static PyObject* gPySetSorConstant(PyObject* self, PHY_GetActiveEnvironment()->setSolverSorConstant( sor); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -248,6 +279,9 @@ static PyObject* gPySetSolverTau(PyObject* self, PHY_GetActiveEnvironment()->setSolverTau( tau); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -264,6 +298,9 @@ static PyObject* gPySetSolverDamping(PyObject* self, PHY_GetActiveEnvironment()->setSolverDamping( damping); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -279,6 +316,9 @@ static PyObject* gPySetLinearAirDamping(PyObject* self, PHY_GetActiveEnvironment()->setLinearAirDamping( damping); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -295,6 +335,9 @@ static PyObject* gPySetUseEpa(PyObject* self, PHY_GetActiveEnvironment()->setUseEpa(epa); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } static PyObject* gPySetSolverType(PyObject* self, @@ -309,6 +352,9 @@ static PyObject* gPySetSolverType(PyObject* self, PHY_GetActiveEnvironment()->setSolverType(solverType); } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -338,6 +384,9 @@ static PyObject* gPyGetVehicleConstraint(PyObject* self, } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -395,6 +444,9 @@ static PyObject* gPyCreateConstraint(PyObject* self, } } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -421,6 +473,9 @@ static PyObject* gPyGetAppliedImpulse(PyObject* self, appliedImpulse = PHY_GetActiveEnvironment()->getAppliedImpulse(constraintid); } } + else { + return NULL; + } return PyFloat_FromDouble(appliedImpulse); } @@ -443,6 +498,10 @@ static PyObject* gPyRemoveConstraint(PyObject* self, PHY_GetActiveEnvironment()->removeConstraint(constraintid); } } + else { + return NULL; + } + Py_INCREF(Py_None); return Py_None; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 0831788009d..47f5577552f 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -425,7 +425,7 @@ static PyObject* gPyEnableVisibility(PyObject*, } else { - Py_Return; + return NULL; } Py_Return; } @@ -449,6 +449,9 @@ static PyObject* gPyShowMouse(PyObject*, gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); } } + else { + return NULL; + } Py_Return; } @@ -465,6 +468,9 @@ static PyObject* gPySetMousePosition(PyObject*, if (gp_Canvas) gp_Canvas->SetMousePosition(x,y); } + else { + return NULL; + } Py_Return; } @@ -568,6 +574,9 @@ static PyObject* gPySetMistStart(PyObject*, gp_Rasterizer->SetFogStart(miststart); } } + else { + return NULL; + } Py_Return; } @@ -586,6 +595,9 @@ static PyObject* gPySetMistEnd(PyObject*, gp_Rasterizer->SetFogEnd(mistend); } } + else { + return NULL; + } Py_Return; } @@ -623,6 +635,9 @@ static PyObject* gPyMakeScreenshot(PyObject*, gp_Canvas->MakeScreenShot(filename); } } + else { + return NULL; + } Py_Return; } @@ -638,6 +653,9 @@ static PyObject* gPyEnableMotionBlur(PyObject*, gp_Rasterizer->EnableMotionBlur(motionblurvalue); } } + else { + return NULL; + } Py_Return; } diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index fba2ecc223b..7e8160a4d67 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -68,6 +68,8 @@ PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* self, printf("attempt for addWheel: suspensionRestLength%f wheelRadius %f, hasSteering:%d\n",suspensionRestLength,wheelRadius,hasSteering); m_vehicle->AddWheel(motionState,aPos,aDir,aAxle,suspensionRestLength,wheelRadius,hasSteering); + } else { + return NULL; } Py_INCREF(Py_None); return Py_None; @@ -90,8 +92,7 @@ PyObject* KX_VehicleWrapper::PyGetWheelPosition(PyObject* self, MT_Vector3 pos(position[0],position[1],position[2]); return PyObjectFrom(pos); } - Py_INCREF(Py_None); - return Py_None; + return NULL; } PyObject* KX_VehicleWrapper::PyGetWheelRotation(PyObject* self, @@ -103,8 +104,7 @@ PyObject* KX_VehicleWrapper::PyGetWheelRotation(PyObject* self, { return PyFloat_FromDouble(m_vehicle->GetWheelRotation(wheelIndex)); } - Py_INCREF(Py_None); - return Py_None; + return NULL; } PyObject* KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject* self, @@ -120,8 +120,7 @@ PyObject* KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject* self, MT_Matrix3x3 ornmat(quatorn); return PyObjectFrom(ornmat); } - Py_INCREF(Py_None); - return Py_None; + return NULL; } @@ -155,6 +154,9 @@ PyObject* KX_VehicleWrapper::PyApplyEngineForce(PyObject* self, force *= -1.f;//someone reverse some conventions inside Bullet (axle winding) m_vehicle->ApplyEngineForce(force,wheelIndex); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -170,6 +172,9 @@ PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self, { m_vehicle->SetWheelFriction(wheelFriction,wheelIndex); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -185,6 +190,9 @@ PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self, { m_vehicle->SetSuspensionStiffness(suspensionStiffness,wheelIndex); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -199,6 +207,8 @@ PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self, if (PyArg_ParseTuple(args,"fi",&suspensionDamping,&wheelIndex)) { m_vehicle->SetSuspensionDamping(suspensionDamping,wheelIndex); + } else { + return NULL; } Py_INCREF(Py_None); return Py_None; @@ -214,6 +224,8 @@ PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self, if (PyArg_ParseTuple(args,"fi",&suspensionCompression,&wheelIndex)) { m_vehicle->SetSuspensionCompression(suspensionCompression,wheelIndex); + } else { + return NULL; } Py_INCREF(Py_None); return Py_None; @@ -230,6 +242,9 @@ PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self, { m_vehicle->SetRollInfluence(rollInfluence,wheelIndex); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -246,6 +261,9 @@ PyObject* KX_VehicleWrapper::PyApplyBraking(PyObject* self, { m_vehicle->ApplyBraking(braking,wheelIndex); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } @@ -264,6 +282,9 @@ PyObject* KX_VehicleWrapper::PySetSteeringValue(PyObject* self, { m_vehicle->SetSteeringValue(steeringValue,wheelIndex); } + else { + return NULL; + } Py_INCREF(Py_None); return Py_None; } -- cgit v1.2.3 From 31aa43da9736a014579ec05fb68ff2051f5eb69d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 3 Jul 2008 01:34:50 +0000 Subject: Adding GameObject setLinearVelocity(), without this interacting with objects requires them to have logic bricks to apply force which doesn't work well when the character is in a seperate blend file to the levels. (its also messy to have a script & multiple motion actuators on each object you can pickup and throw). This is also needed for removing any force that existed before suspending dynamics - In the case of franky hanging, resuming dynamics when he fell would apply the velocity he had when grabbing making dropping to the ground work unpredictably. Also note in pydocs that enable/disable rigidbody physics doesn't work with bullet yet. --- source/gameengine/Ketsji/KX_GameObject.cpp | 18 +++++++++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 1 + source/gameengine/PyDoc/KX_GameObject.py | 20 ++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index ee8161702e1..993e852a7ee 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -812,6 +812,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_VARARGS}, {"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_VARARGS}, {"getLinearVelocity", (PyCFunction) KX_GameObject::sPyGetLinearVelocity, METH_VARARGS}, + {"setLinearVelocity", (PyCFunction) KX_GameObject::sPySetLinearVelocity, METH_VARARGS}, {"getVelocity", (PyCFunction) KX_GameObject::sPyGetVelocity, METH_VARARGS}, {"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_VARARGS}, {"getReactionForce", (PyCFunction) KX_GameObject::sPyGetReactionForce, METH_VARARGS}, @@ -1091,7 +1092,22 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, } } - +PyObject* KX_GameObject::PySetLinearVelocity(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + int local = 0; + PyObject* pyvect; + + if (PyArg_ParseTuple(args,"O|i",&pyvect,&local)) { + MT_Vector3 velocity; + if (PyVecTo(pyvect, velocity)) { + setLinearVelocity(velocity, (local!=0)); + Py_Return; + } + } + return NULL; +} PyObject* KX_GameObject::PySetVisible(PyObject* self, PyObject* args, diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 89f4cb396d1..3a9abd2fc61 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -713,6 +713,7 @@ public: KX_PYMETHOD(KX_GameObject,GetPosition); KX_PYMETHOD(KX_GameObject,GetLinearVelocity); + KX_PYMETHOD(KX_GameObject,SetLinearVelocity); KX_PYMETHOD(KX_GameObject,GetVelocity); KX_PYMETHOD(KX_GameObject,GetMass); KX_PYMETHOD(KX_GameObject,GetReactionForce); diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index ec7496daa75..faadf61abb5 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -98,7 +98,7 @@ class KX_GameObject: @return: The game object's rotation matrix @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed. """ - def getLinearVelocity(local): + def getLinearVelocity(local = 0): """ Gets the game object's linear velocity. @@ -106,11 +106,24 @@ class KX_GameObject: ie no angular velocity component. @type local: boolean - @param local: - False: you get the "global" velocity ie: relative to world orientation. + @param local: - False: you get the "global" velocity ie: relative to world orientation (default). - True: you get the "local" velocity ie: relative to object orientation. @rtype: list [vx, vy, vz] @return: the object's linear velocity. """ + def setLinearVelocity(velocity, local = 0): + """ + Sets the game object's linear velocity. + + This method sets game object's velocity through it's centre of mass, + ie no angular velocity component. + + @type velocity: 3d vector. + @param velocity: linear velocity vector. + @type local: boolean + @param local: - False: you get the "global" velocity ie: relative to world orientation (default). + - True: you get the "local" velocity ie: relative to object orientation. + """ def getVelocity(point): """ Gets the game object's velocity at the specified point. @@ -158,16 +171,19 @@ class KX_GameObject: def restoreDynamics(): """ Resumes physics for this object. + @Note: The objects linear velocity will be applied from when the dynamics were suspended. """ def enableRigidBody(): """ Enables rigid body physics for this object. Rigid body physics allows the object to roll on collisions. + @Note: This is not working with bullet physics yet. """ def disableRigidBody(): """ Disables rigid body physics for this object. + @Note: This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later. """ def getParent(): """ -- cgit v1.2.3 From 5c93e756823cda49466ce7e546268d551fb7de2f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Jul 2008 00:05:50 +0000 Subject: non user visible changes and small optimizations to the game engine pyapi as well as fixing some bugs. * 2 returning errors without exception set another return None instead of NULL. * a missing check for parent relation * BPY matrix length was incorrect in matrix.c, this change could break some scripts, however when a script expects a list of lists for a matrix, the len() function is incorrect and will give an error. This was the only thing stopping apricot game logic running in trunk. Also added a function for GameObjects - getAxisVect(vec), multiplies the vector be the objects worldspace rotation matrix. Very useful if you want to know what the forward direction is for an object and dont want to use Blender.Mathutils which is tedious and not available in BlenderPlayer yet. --- source/gameengine/Expressions/PyObjectPlus.h | 27 ++ .../gameengine/GameLogic/SCA_PythonController.cpp | 79 ++--- source/gameengine/GameLogic/SCA_PythonController.h | 21 +- source/gameengine/Ketsji/KX_GameObject.cpp | 326 +++++++++------------ source/gameengine/Ketsji/KX_GameObject.h | 57 ++-- source/gameengine/PyDoc/KX_GameObject.py | 13 +- 6 files changed, 234 insertions(+), 289 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index de89ed9b5c8..04cc119efee 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -99,6 +99,18 @@ static inline void Py_Fatal(char *M) { return ((class_name*) self)->Py##method_name(self, args, kwds); \ }; \ +#define KX_PYMETHOD_NOARGS(class_name, method_name) \ + PyObject* Py##method_name(PyObject* self); \ + static PyObject* sPy##method_name( PyObject* self) { \ + return ((class_name*) self)->Py##method_name(self); \ + }; \ + +#define KX_PYMETHOD_O(class_name, method_name) \ + PyObject* Py##method_name(PyObject* self, PyObject* value); \ + static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \ + return ((class_name*) self)->Py##method_name(self, value); \ + }; \ + #define KX_PYMETHOD_DOC(class_name, method_name) \ PyObject* Py##method_name(PyObject* self, PyObject* args, PyObject* kwds); \ static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \ @@ -106,6 +118,21 @@ static inline void Py_Fatal(char *M) { }; \ static char method_name##_doc[]; \ +#define KX_PYMETHOD_DOC_O(class_name, method_name) \ + PyObject* Py##method_name(PyObject* self, PyObject* value); \ + static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \ + return ((class_name*) self)->Py##method_name(self, value); \ + }; \ + static char method_name##_doc[]; \ + +#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \ + PyObject* Py##method_name(PyObject* self); \ + static PyObject* sPy##method_name( PyObject* self) { \ + return ((class_name*) self)->Py##method_name(self); \ + }; \ + static char method_name##_doc[]; \ + + /* The line above should remain empty */ /** * Method table macro (with doc) diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index be00117cd21..76386079bdf 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -144,9 +144,7 @@ static char* sPyGetCurrentController__doc__; #endif -PyObject* SCA_PythonController::sPyGetCurrentController(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* SCA_PythonController::sPyGetCurrentController(PyObject* self) { m_sCurrentController->AddRef(); return m_sCurrentController; @@ -159,8 +157,7 @@ static char* sPyAddActiveActuator__doc__; PyObject* SCA_PythonController::sPyAddActiveActuator( PyObject* self, - PyObject* args, - PyObject* kwds) + PyObject* args) { PyObject* ob1; @@ -187,8 +184,7 @@ PyObject* SCA_PythonController::sPyAddActiveActuator( m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)act,boolval); boolval->Release(); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -222,17 +218,13 @@ PyParentObject SCA_PythonController::Parents[] = { NULL }; PyMethodDef SCA_PythonController::Methods[] = { - {"getActuators", (PyCFunction) SCA_PythonController::sPyGetActuators, - METH_VARARGS, SCA_PythonController::GetActuators_doc}, - {"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, - METH_VARARGS, SCA_PythonController::GetActuator_doc}, - {"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, - METH_VARARGS, SCA_PythonController::GetSensors_doc}, - {"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, - METH_VARARGS, SCA_PythonController::GetSensor_doc}, - {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_VARARGS}, - {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_VARARGS}, - {"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_VARARGS}, + {"getActuators", (PyCFunction) SCA_PythonController::sPyGetActuators, METH_NOARGS, SCA_PythonController::GetActuators_doc}, + {"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, METH_O, SCA_PythonController::GetActuator_doc}, + {"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, METH_NOARGS, SCA_PythonController::GetSensors_doc}, + {"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, METH_O, SCA_PythonController::GetSensor_doc}, + {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS}, + {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O}, + {"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_NOARGS}, {NULL,NULL} //Sentinel }; @@ -330,14 +322,12 @@ PyObject* SCA_PythonController::_getattr(const STR_String& attr) -PyObject* SCA_PythonController::PyGetActuators(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* SCA_PythonController::PyGetActuators(PyObject* self) { PyObject* resultlist = PyList_New(m_linkedactuators.size()); for (unsigned int index=0;indexAddRef()); + PyList_SET_ITEM(resultlist,index,m_linkedactuators[index]->AddRef()); } return resultlist; @@ -346,14 +336,12 @@ PyObject* SCA_PythonController::PyGetActuators(PyObject* self, char SCA_PythonController::GetSensor_doc[] = "GetSensor (char sensorname) return linked sensor that is named [sensorname]\n"; PyObject* -SCA_PythonController::PyGetSensor(PyObject* self, - PyObject* args, - PyObject* kwds) +SCA_PythonController::PyGetSensor(PyObject* self, PyObject* value) { - char *scriptArg; - - if (!PyArg_ParseTuple(args, "s", &scriptArg)) { + char *scriptArg = PyString_AsString(value); + if (scriptArg==NULL) { + PyErr_SetString(PyExc_TypeError, "expected a string (sensor name)"); return NULL; } @@ -376,14 +364,12 @@ SCA_PythonController::PyGetSensor(PyObject* self, char SCA_PythonController::GetActuator_doc[] = "GetActuator (char sensorname) return linked actuator that is named [actuatorname]\n"; PyObject* -SCA_PythonController::PyGetActuator(PyObject* self, - PyObject* args, - PyObject* kwds) +SCA_PythonController::PyGetActuator(PyObject* self, PyObject* value) { - char *scriptArg; - - if (!PyArg_ParseTuple(args, "s", &scriptArg)) { + char *scriptArg = PyString_AsString(value); + if (scriptArg==NULL) { + PyErr_SetString(PyExc_TypeError, "expected a string (actuator name)"); return NULL; } @@ -404,34 +390,29 @@ SCA_PythonController::PyGetActuator(PyObject* self, char SCA_PythonController::GetSensors_doc[] = "getSensors returns a list of all attached sensors"; PyObject* -SCA_PythonController::PyGetSensors(PyObject* self, - PyObject* args, - PyObject* kwds) +SCA_PythonController::PyGetSensors(PyObject* self) { PyObject* resultlist = PyList_New(m_linkedsensors.size()); for (unsigned int index=0;indexAddRef()); + PyList_SET_ITEM(resultlist,index,m_linkedsensors[index]->AddRef()); } return resultlist; } /* 1. getScript */ -PyObject* SCA_PythonController::PyGetScript(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* SCA_PythonController::PyGetScript(PyObject* self) { return PyString_FromString(m_scriptText); } /* 2. setScript */ -PyObject* SCA_PythonController::PySetScript(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* SCA_PythonController::PySetScript(PyObject* self, PyObject* value) { - char *scriptArg; - if (!PyArg_ParseTuple(args, "s", &scriptArg)) { + char *scriptArg = PyString_AsString(value); + if (scriptArg==NULL) { + PyErr_SetString(PyExc_TypeError, "expected a string (script name)"); return NULL; } @@ -440,13 +421,11 @@ PyObject* SCA_PythonController::PySetScript(PyObject* self, this->SetScriptText(scriptArg); - Py_Return; + Py_RETURN_NONE; } /* 1. getScript */ -PyObject* SCA_PythonController::PyGetState(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* SCA_PythonController::PyGetState(PyObject* self) { return PyInt_FromLong(m_statemask); } diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index f3af54f402f..39b6c68c359 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -66,22 +66,19 @@ class SCA_PythonController : public SCA_IController void SetDictionary(PyObject* pythondictionary); static char* sPyGetCurrentController__doc__; - static PyObject* sPyGetCurrentController(PyObject* self, - PyObject* args, - PyObject* kwds); + static PyObject* sPyGetCurrentController(PyObject* self); static char* sPyAddActiveActuator__doc__; static PyObject* sPyAddActiveActuator(PyObject* self, - PyObject* args, - PyObject* kwds); + PyObject* args); virtual PyObject* _getattr(const STR_String& attr); - KX_PYMETHOD_DOC(SCA_PythonController,GetSensors); - KX_PYMETHOD_DOC(SCA_PythonController,GetSensor); - KX_PYMETHOD_DOC(SCA_PythonController,GetActuator); - KX_PYMETHOD_DOC(SCA_PythonController,GetActuators); - KX_PYMETHOD(SCA_PythonController,SetScript); - KX_PYMETHOD(SCA_PythonController,GetScript); - KX_PYMETHOD(SCA_PythonController,GetState); + KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetSensors); + KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetActuators); + KX_PYMETHOD_DOC_O(SCA_PythonController,GetSensor); + KX_PYMETHOD_DOC_O(SCA_PythonController,GetActuator); + KX_PYMETHOD_O(SCA_PythonController,SetScript); + KX_PYMETHOD_NOARGS(SCA_PythonController,GetScript); + KX_PYMETHOD_NOARGS(SCA_PythonController,GetState); }; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 993e852a7ee..c4925cb772c 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -648,7 +648,6 @@ MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { MT_Vector3 velocity(0.0,0.0,0.0), locvel; MT_Matrix3x3 ori; - int i, j; if (m_pPhysicsController1) { velocity = m_pPhysicsController1->GetLinearVelocity(); @@ -668,7 +667,6 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) { MT_Vector3 velocity(0.0,0.0,0.0), locvel; MT_Matrix3x3 ori; - int i, j; if (m_pPhysicsController1) { velocity = m_pPhysicsController1->GetAngularVelocity(); @@ -802,36 +800,37 @@ void KX_GameObject::Suspend(void) PyMethodDef KX_GameObject::Methods[] = { - {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS}, - {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_VARARGS}, - {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_VARARGS}, - {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_VARARGS}, - {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS}, - {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_VARARGS}, - {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_VARARGS}, - {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_VARARGS}, - {"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_VARARGS}, + {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_NOARGS}, + {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_O}, {"getLinearVelocity", (PyCFunction) KX_GameObject::sPyGetLinearVelocity, METH_VARARGS}, {"setLinearVelocity", (PyCFunction) KX_GameObject::sPySetLinearVelocity, METH_VARARGS}, {"getVelocity", (PyCFunction) KX_GameObject::sPyGetVelocity, METH_VARARGS}, - {"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_VARARGS}, - {"getReactionForce", (PyCFunction) KX_GameObject::sPyGetReactionForce, METH_VARARGS}, + {"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_NOARGS}, + {"getReactionForce", (PyCFunction) KX_GameObject::sPyGetReactionForce, METH_NOARGS}, + {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_NOARGS}, + {"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_O}, + {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_NOARGS}, + {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_O}, + {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_NOARGS}, + {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_O}, + {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS}, + {"getAxisVect",(PyCFunction) KX_GameObject::sPyGetAxisVect, METH_O}, + {"suspendDynamics", (PyCFunction)KX_GameObject::sPySuspendDynamics,METH_NOARGS}, + {"restoreDynamics", (PyCFunction)KX_GameObject::sPyRestoreDynamics,METH_NOARGS}, + {"enableRigidBody", (PyCFunction)KX_GameObject::sPyEnableRigidBody,METH_NOARGS}, + {"disableRigidBody", (PyCFunction)KX_GameObject::sPyDisableRigidBody,METH_NOARGS}, {"applyImpulse", (PyCFunction) KX_GameObject::sPyApplyImpulse, METH_VARARGS}, - {"setCollisionMargin", (PyCFunction) KX_GameObject::sPySetCollisionMargin, METH_VARARGS}, - {"suspendDynamics", (PyCFunction)KX_GameObject::sPySuspendDynamics,METH_VARARGS}, - {"restoreDynamics", (PyCFunction)KX_GameObject::sPyRestoreDynamics,METH_VARARGS}, - {"enableRigidBody", (PyCFunction)KX_GameObject::sPyEnableRigidBody,METH_VARARGS}, - {"disableRigidBody", (PyCFunction)KX_GameObject::sPyDisableRigidBody,METH_VARARGS}, - {"getParent", (PyCFunction)KX_GameObject::sPyGetParent,METH_VARARGS}, - {"setParent", (PyCFunction)KX_GameObject::sPySetParent,METH_VARARGS}, - {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_VARARGS}, + {"setCollisionMargin", (PyCFunction) KX_GameObject::sPySetCollisionMargin, METH_O}, + {"getParent", (PyCFunction)KX_GameObject::sPyGetParent,METH_NOARGS}, + {"setParent", (PyCFunction)KX_GameObject::sPySetParent,METH_O}, + {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_NOARGS}, {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, - {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS}, - {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_VARARGS}, - {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_VARARGS}, - KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), + {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS}, + {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS}, + {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS}, KX_PYMETHODTABLE(KX_GameObject, rayCastTo), KX_PYMETHODTABLE(KX_GameObject, rayCast), + KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), {NULL,NULL} //Sentinel }; @@ -853,18 +852,7 @@ bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args, } */ - -PyObject* KX_GameObject::sPySetPosition(PyObject* self, - PyObject* args, - PyObject* kwds) -{ - return ((KX_GameObject*) self)->PySetPosition(self, args, kwds); -} - - -PyObject* KX_GameObject::PyEndObject(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyEndObject(PyObject* self) { KX_Scene *scene = PHY_GetActiveScene(); @@ -875,9 +863,7 @@ PyObject* KX_GameObject::PyEndObject(PyObject* self, } -PyObject* KX_GameObject::PyGetPosition(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetPosition(PyObject* self) { return PyObjectFrom(NodeGetWorldPosition()); } @@ -931,7 +917,7 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr) parent->AddRef(); return parent; } - Py_Return; + Py_RETURN_NONE; } if (attr == "visible") @@ -982,7 +968,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr { MT_Scalar val = PyFloat_AsDouble(value); if (attr == "timeOffset") { - if (m_pSGNode->GetSGParent()->IsSlowParent()) { + if (m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsSlowParent()) { static_cast(m_pSGNode->GetSGParent()->GetParentRelation())->SetTimeOffset(val); return 0; } else { @@ -1103,68 +1089,57 @@ PyObject* KX_GameObject::PySetLinearVelocity(PyObject* self, MT_Vector3 velocity; if (PyVecTo(pyvect, velocity)) { setLinearVelocity(velocity, (local!=0)); - Py_Return; + Py_RETURN_NONE; } } return NULL; } -PyObject* KX_GameObject::PySetVisible(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PySetVisible(PyObject* self, PyObject* value) { - int visible = 1; + int visible = PyInt_AsLong(value); - if (PyArg_ParseTuple(args,"i",&visible)) - { - MarkVisible(visible!=0); - m_bVisible = (visible!=0); - } - else - { - return NULL; + if (visible==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "expected 0 or 1"); + return NULL; } - Py_Return; + + MarkVisible(visible!=0); + m_bVisible = (visible!=0); + Py_RETURN_NONE; } -PyObject* KX_GameObject::PyGetVisible(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetVisible(PyObject* self) { return PyInt_FromLong(m_bVisible); } -PyObject* KX_GameObject::PyGetState(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetState(PyObject* self) { int state = 0; state |= GetState(); return PyInt_FromLong(state); } -PyObject* KX_GameObject::PySetState(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PySetState(PyObject* self, PyObject* value) { - int state_i; + int state_i = PyInt_AsLong(value); unsigned int state = 0; - if (PyArg_ParseTuple(args,"i",&state_i)) - { - state |= state_i; - if ((state & ((1<<30)-1)) == 0) { - PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); - return NULL; - } - SetState(state); + if (state_i == -1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "expected an int bit field"); + return NULL; } - else - { - return NULL; + + state |= state_i; + if ((state & ((1<<30)-1)) == 0) { + PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)"); + return NULL; } - Py_Return; + SetState(state); + + Py_RETURN_NONE; } @@ -1198,26 +1173,14 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* self, -PyObject* KX_GameObject::PyGetMass(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetMass(PyObject* self) { - PyObject* pymass = NULL; - - float mass = GetPhysicsController()->GetMass(); - pymass = PyFloat_FromDouble(mass); - - if (pymass) - return pymass; - - Py_Return; + return PyFloat_FromDouble(GetPhysicsController()->GetMass()); } -PyObject* KX_GameObject::PyGetReactionForce(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetReactionForce(PyObject* self) { // only can get the velocity if we have a physics object connected to us... return PyObjectFrom(GetPhysicsController()->getReactionForce()); @@ -1225,32 +1188,25 @@ PyObject* KX_GameObject::PyGetReactionForce(PyObject* self, -PyObject* KX_GameObject::PyEnableRigidBody(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyEnableRigidBody(PyObject* self) { - GetPhysicsController()->setRigidBody(true); - Py_Return; + Py_RETURN_NONE; } -PyObject* KX_GameObject::PyDisableRigidBody(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyDisableRigidBody(PyObject* self) { GetPhysicsController()->setRigidBody(false); - Py_Return; + Py_RETURN_NONE; } -PyObject* KX_GameObject::PyGetParent(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetParent(PyObject* self) { KX_GameObject* parent = this->GetParent(); if (parent) @@ -1258,37 +1214,31 @@ PyObject* KX_GameObject::PyGetParent(PyObject* self, parent->AddRef(); return parent; } - Py_Return; + Py_RETURN_NONE; } -PyObject* KX_GameObject::PySetParent(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PySetParent(PyObject* self, PyObject* value) { - PyObject* gameobj; - if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) - { - // The object we want to set as parent - CValue *m_ob = (CValue*)gameobj; - KX_GameObject *obj = ((KX_GameObject*)m_ob); - KX_Scene *scene = PHY_GetActiveScene(); - - this->SetParent(scene, obj); - } - else { + if (!PyObject_TypeCheck(value, &KX_GameObject::Type)) { + PyErr_SetString(PyExc_TypeError, "expected a KX_GameObject type"); return NULL; } - Py_Return; + // The object we want to set as parent + CValue *m_ob = (CValue*)value; + KX_GameObject *obj = ((KX_GameObject*)m_ob); + KX_Scene *scene = PHY_GetActiveScene(); + + this->SetParent(scene, obj); + + Py_RETURN_NONE; } -PyObject* KX_GameObject::PyRemoveParent(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyRemoveParent(PyObject* self) { KX_Scene *scene = PHY_GetActiveScene(); this->RemoveParent(scene); - Py_Return; + Py_RETURN_NONE; } PyObject* KX_GameObject::PyGetMesh(PyObject* self, @@ -1312,21 +1262,21 @@ PyObject* KX_GameObject::PyGetMesh(PyObject* self, -PyObject* KX_GameObject::PySetCollisionMargin(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PySetCollisionMargin(PyObject* self, PyObject* value) { - float collisionMargin; - if (PyArg_ParseTuple(args, "f", &collisionMargin)) - { - if (m_pPhysicsController1) - { - m_pPhysicsController1->setMargin(collisionMargin); - Py_Return; - } - + float collisionMargin = PyFloat_AsDouble(value); + + if (collisionMargin==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "expected a float"); + return NULL; } + if (m_pPhysicsController1) + { + m_pPhysicsController1->setMargin(collisionMargin); + Py_RETURN_NONE; + } + PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller"); return NULL; } @@ -1338,17 +1288,20 @@ PyObject* KX_GameObject::PyApplyImpulse(PyObject* self, { PyObject* pyattach; PyObject* pyimpulse; + + if (!m_pPhysicsController1) { + PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller"); + return NULL; + } + if (PyArg_ParseTuple(args, "OO", &pyattach, &pyimpulse)) { MT_Point3 attach; MT_Vector3 impulse; - if (m_pPhysicsController1) + if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse)) { - if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse)) - { - m_pPhysicsController1->applyImpulse(attach, impulse); - Py_Return; - } + m_pPhysicsController1->applyImpulse(attach, impulse); + Py_RETURN_NONE; } } @@ -1358,59 +1311,46 @@ PyObject* KX_GameObject::PyApplyImpulse(PyObject* self, -PyObject* KX_GameObject::PySuspendDynamics(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PySuspendDynamics(PyObject* self) { SuspendDynamics(); - Py_Return; + Py_RETURN_NONE; } -PyObject* KX_GameObject::PyRestoreDynamics(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyRestoreDynamics(PyObject* self) { RestoreDynamics(); - Py_Return; + Py_RETURN_NONE; } -PyObject* KX_GameObject::PyGetOrientation(PyObject* self, - PyObject* args, - PyObject* kwds) //keywords +PyObject* KX_GameObject::PyGetOrientation(PyObject* self) //keywords { return PyObjectFrom(NodeGetWorldOrientation()); } -PyObject* KX_GameObject::PySetOrientation(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PySetOrientation(PyObject* self, PyObject* value) { - PyObject* pylist; - - if (PyArg_ParseTuple(args,"O",&pylist)) + MT_Matrix3x3 matrix; + if (PyObject_IsMT_Matrix(value, 3) && PyMatTo(value, matrix)) { - MT_Matrix3x3 matrix; - if (PyObject_IsMT_Matrix(pylist, 3) && PyMatTo(pylist, matrix)) - { - NodeSetLocalOrientation(matrix); - NodeUpdateGS(0.f,true); - Py_Return; - } - - MT_Quaternion quat; - if (PyVecTo(pylist, quat)) - { - matrix.setRotation(quat); - NodeSetLocalOrientation(matrix); - NodeUpdateGS(0.f,true); - Py_Return; - } + NodeSetLocalOrientation(matrix); + NodeUpdateGS(0.f,true); + Py_RETURN_NONE; + } + + MT_Quaternion quat; + if (PyVecTo(value, quat)) + { + matrix.setRotation(quat); + NodeSetLocalOrientation(matrix); + NodeUpdateGS(0.f,true); + Py_RETURN_NONE; } return NULL; } @@ -1428,30 +1368,36 @@ PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, if (PyVecTo(pyvect, vect)) { AlignAxisToVect(vect,axis); - Py_Return; + Py_RETURN_NONE; } } return NULL; } -PyObject* KX_GameObject::PySetPosition(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetAxisVect(PyObject* self, PyObject* value) +{ + MT_Vector3 vect; + if (PyVecTo(value, vect)) + { + return PyObjectFrom(vect * NodeGetWorldOrientation()); + } + return NULL; +} + +PyObject* KX_GameObject::PySetPosition(PyObject* self, PyObject* value) { MT_Point3 pos; - if (PyVecArgTo(args, pos)) + if (PyVecTo(value, pos)) { NodeSetLocalPosition(pos); NodeUpdateGS(0.f,true); - Py_Return; + Py_RETURN_NONE; } - + return NULL; } -PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self) { KX_IPhysicsController* ctrl = GetPhysicsController(); uint_ptr physid=0; @@ -1462,9 +1408,7 @@ PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self, return PyInt_FromLong((long)physid); } -PyObject* KX_GameObject::PyGetPropertyNames(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetPropertyNames(PyObject* self) { return ConvertKeysToPython(); } @@ -1563,7 +1507,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, m_pHitObject->AddRef(); return m_pHitObject; } - Py_Return; + Py_RETURN_NONE; } KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, @@ -1646,7 +1590,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, // resultNormal[0], resultNormal[1], resultNormal[2]); } return Py_BuildValue("OOO", Py_None, Py_None, Py_None); - //Py_Return; + //Py_RETURN_NONE; } /* --------------------------------------------------------------------- diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 3a9abd2fc61..31b56df5368 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -696,47 +696,34 @@ public: PyObject *value ); // _setattr method - PyObject* - PySetPosition( - PyObject* self, - PyObject* args, - PyObject* kwds - ); - - static - PyObject* - sPySetPosition( - PyObject* self, - PyObject* args, - PyObject* kwds - ); - - KX_PYMETHOD(KX_GameObject,GetPosition); + KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition); + KX_PYMETHOD_O(KX_GameObject,SetPosition); KX_PYMETHOD(KX_GameObject,GetLinearVelocity); KX_PYMETHOD(KX_GameObject,SetLinearVelocity); KX_PYMETHOD(KX_GameObject,GetVelocity); - KX_PYMETHOD(KX_GameObject,GetMass); - KX_PYMETHOD(KX_GameObject,GetReactionForce); - KX_PYMETHOD(KX_GameObject,GetOrientation); - KX_PYMETHOD(KX_GameObject,SetOrientation); - KX_PYMETHOD(KX_GameObject,GetVisible); - KX_PYMETHOD(KX_GameObject,SetVisible); - KX_PYMETHOD(KX_GameObject,GetState); - KX_PYMETHOD(KX_GameObject,SetState); + KX_PYMETHOD_NOARGS(KX_GameObject,GetMass); + KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce); + KX_PYMETHOD_NOARGS(KX_GameObject,GetOrientation); + KX_PYMETHOD_O(KX_GameObject,SetOrientation); + KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible); + KX_PYMETHOD_O(KX_GameObject,SetVisible); + KX_PYMETHOD_NOARGS(KX_GameObject,GetState); + KX_PYMETHOD_O(KX_GameObject,SetState); KX_PYMETHOD(KX_GameObject,AlignAxisToVect); - KX_PYMETHOD(KX_GameObject,SuspendDynamics); - KX_PYMETHOD(KX_GameObject,RestoreDynamics); - KX_PYMETHOD(KX_GameObject,EnableRigidBody); - KX_PYMETHOD(KX_GameObject,DisableRigidBody); + KX_PYMETHOD_O(KX_GameObject,GetAxisVect); + KX_PYMETHOD_NOARGS(KX_GameObject,SuspendDynamics); + KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics); + KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody); + KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody); KX_PYMETHOD(KX_GameObject,ApplyImpulse); - KX_PYMETHOD(KX_GameObject,SetCollisionMargin); + KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin); + KX_PYMETHOD_NOARGS(KX_GameObject,GetParent); + KX_PYMETHOD_O(KX_GameObject,SetParent); + KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent); KX_PYMETHOD(KX_GameObject,GetMesh); - KX_PYMETHOD(KX_GameObject,GetParent); - KX_PYMETHOD(KX_GameObject,SetParent); - KX_PYMETHOD(KX_GameObject,RemoveParent); - KX_PYMETHOD(KX_GameObject,GetPhysicsId); - KX_PYMETHOD(KX_GameObject,GetPropertyNames); - KX_PYMETHOD(KX_GameObject,EndObject); + KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId); + KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames); + KX_PYMETHOD_NOARGS(KX_GameObject,EndObject); KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); KX_PYMETHOD_DOC(KX_GameObject,rayCast); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index faadf61abb5..37c188b7f22 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -90,11 +90,22 @@ class KX_GameObject: - 1: Y axis - 2: Z axis (default) """ + def getAxisVect(vect): + """ + Returns the axis vector rotates by the objects worldspace orientation. + This is the equivalent if multiplying the vector by the orientation matrix. + + @type vect: 3d vector. + @param vect: a vector to align the axis. + @rtype: 3d vector. + @return: The vector in relation to the objects rotation. + + """ def getOrientation(): """ Gets the game object's orientation. - @rtype: 3x3 inverted rotation matrix + @rtype: 3x3 rotation matrix @return: The game object's rotation matrix @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed. """ -- cgit v1.2.3 From bd74679a397efa82ac81386bf8da5877bd32dded Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Jul 2008 00:30:44 +0000 Subject: small changes to py funcs that can run 100s of times a second, so python wont generate empty args tuple when they are not needed. --- source/gameengine/GameLogic/SCA_ILogicBrick.cpp | 12 ++++-------- source/gameengine/GameLogic/SCA_ILogicBrick.h | 4 ++-- source/gameengine/GameLogic/SCA_ISensor.cpp | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index 8423d06dfcd..f6efd485adb 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -242,8 +242,8 @@ PyParentObject SCA_ILogicBrick::Parents[] = { PyMethodDef SCA_ILogicBrick::Methods[] = { - {"getOwner", (PyCFunction) SCA_ILogicBrick::sPyGetOwner, METH_VARARGS}, - {"getExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_VARARGS}, + {"getOwner", (PyCFunction) SCA_ILogicBrick::sPyGetOwner, METH_NOARGS}, + {"getExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_NOARGS}, {"setExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_VARARGS}, {NULL,NULL} //Sentinel }; @@ -258,9 +258,7 @@ SCA_ILogicBrick::_getattr(const STR_String& attr) -PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self) { CValue* parent = GetParent(); if (parent) @@ -294,9 +292,7 @@ PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* self, -PyObject* SCA_ILogicBrick::PyGetExecutePriority(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* SCA_ILogicBrick::PyGetExecutePriority(PyObject* self) { return PyInt_FromLong(m_Execute_Ueber_Priority); } diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index f359ee0911b..80bc6ae3b86 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -82,9 +82,9 @@ public: // python methods - KX_PYMETHOD(SCA_ILogicBrick,GetOwner); + KX_PYMETHOD_NOARGS(SCA_ILogicBrick,GetOwner); KX_PYMETHOD(SCA_ILogicBrick,SetExecutePriority); - KX_PYMETHOD(SCA_ILogicBrick,GetExecutePriority); + KX_PYMETHOD_NOARGS(SCA_ILogicBrick,GetExecutePriority); enum KX_BOOL_TYPE { KX_BOOL_NODEF = 0, diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 6cfae9d8919..1b163deb7bb 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -118,7 +118,7 @@ void SCA_ISensor::Resume() { } void SCA_ISensor::Init() { - printf("Sensor %s has no init function, please report this bug to Blender.org\n", m_name); + printf("Sensor %s has no init function, please report this bug to Blender.org\n", m_name.Ptr()); } void SCA_ISensor::DecLink() { -- cgit v1.2.3 From 70d239ef7d2eb3d3c92fc4f1441f4a41815370cb Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 4 Jul 2008 08:14:50 +0000 Subject: BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor. General ======= - Removal of Damp option in motion actuator (replaced by Servo control motion). - No PyDoc at present, will be added soon. Generalization of the Lvl option ================================ A sensor with the Lvl option selected will always produce an event at the start of the game or when entering a state or at object creation. The event will be positive or negative depending of the sensor condition. A negative pulse makes sense when used with a NAND controller: it will be converted into an actuator activation. Servo control motion ==================== A new variant of the motion actuator allows to control speed with force. The control if of type "PID" (Propotional, Integral, Derivate): the force is automatically adapted to achieve the target speed. All the parameters of the servo controller are configurable. The result is a great variety of motion style: anysotropic friction, flying, sliding, pseudo Dloc... This actuator should be used in preference to Dloc and LinV as it produces more fluid movements and avoids the collision problem with Dloc. LinV : target speed as (X,Y,Z) vector in local or world coordinates (mostly useful in local coordinates). Limit: the force can be limited along each axis (in the same coordinates of LinV). No limitation means that the force will grow as large as necessary to achieve the target speed along that axis. Set a max value to limit the accelaration along an axis (slow start) and set a min value (negative) to limit the brake force. P: Proportional coefficient of servo controller, don't set directly unless you know what you're doing. I: Integral coefficient of servo controller. Use low value (<0.1) for slow reaction (sliding), high values (>0.5) for hard control. The P coefficient will be automatically set to 60 times the I coefficient (a reasonable value). D: Derivate coefficient. Leave to 0 unless you know what you're doing. High values create instability. Notes: - This actuator works perfectly in zero friction environment: the PID controller will simulate friction by applying force as needed. - This actuator is compatible with simple Drot motion actuator but not with LinV and Dloc motion. - (0,0,0) is a valid target speed. - All parameters are accessible through Python. Distance constraint actuator ============================ A new variant of the constraint actuator allows to set the distance and orientation relative to a surface. The controller uses a ray to detect the surface (or any object) and adapt the distance and orientation parallel to the surface. Damp: Time constant (in nb of frames) of distance and orientation control. Dist: Select to enable distance control and set target distance. The object will be position at the given distance of surface along the ray direction. Direction: chose a local axis as the ray direction. Range: length of ray. Objecgt within this distance will be detected. N : Select to enable orientation control. The actuator will change the orientation and the location of the object so that it is parallel to the surface at the vertical of the point of contact of the ray. M/P : Select to enable material detection. Default is property detection. Property/Material: name of property/material that the target of ray must have to be detected. If not set, property/ material filter is disabled and any collisioning object within range will be detected. PER : Select to enable persistent operation. Normally the actuator disables itself automatically if the ray does not reach a valid target. time : Maximum activation time of actuator. 0 : unlimited. >0: number of frames before automatic deactivation. rotDamp: Time constant (in nb of frame) of orientation control. 0 : use Damp parameter. >0: use a different time constant for orientation. Notes: - If neither N nor Dist options are set, the actuator does not change the position and orientation of the object; it works as a ray sensor. - The ray has no "X-ray" capability: if the first object hit does not have the required property/material, it returns no hit and the actuator disables itself unless PER option is enabled. - This actuator changes the position and orientation but not the speed of the object. This has an important implication in a gravity environment: the gravity will cause the speed to increase although the object seems to stay still (it is repositioned at each frame). The gravity must be compensated in one way or another. the new servo control motion actuator is the simplest way: set the target speed along the ray axis to 0 and the servo control will automatically compensate the gravity. - This actuator changes the orientation of the object and will conflict with Drot motion unless it is placed BEFORE the Drot motion actuator (the order of actuator is important) - All parameters are accessible through Python. Orientation constraint ====================== A new variant of the constraint actuator allows to align an object axis along a global direction. Damp : Time constant (in nb of frames) of orientation control. X,Y,Z: Global coordinates of reference direction. time : Maximum activation time of actuator. 0 : unlimited. >0: number of frames before automatic deactivation. Notes: - (X,Y,Z) = (0,0,0) is not a valid direction - This actuator changes the orientation of the object and will conflict with Drot motion unless it is placed BEFORE the Drot motion actuator (the order of actuator is important). - This actuator doesn't change the location and speed. It is compatible with gravity. - All parameters are accessible through Python. Actuator sensor =============== This sensor detects the activation and deactivation of actuators of the same object. The sensor generates a positive pulse when the corresponding sensor is activated and a negative pulse when it is deactivated (the contrary if the Inv option is selected). This is mostly useful to chain actions and to detect the loss of contact of the distance motion actuator. Notes: - Actuators are disabled at the start of the game; if you want to detect the On-Off transition of an actuator after it has been activated at least once, unselect the Lvl and Inv options and use a NAND controller. - Some actuators deactivates themselves immediately after being activated. The sensor detects this situation as an On-Off transition. - The actuator name can be set through Python. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 130 +++-- source/gameengine/Converter/KX_ConvertSensors.cpp | 14 + .../GameLogic/SCA_ActuatorEventManager.cpp | 76 +++ .../GameLogic/SCA_ActuatorEventManager.h | 52 ++ source/gameengine/GameLogic/SCA_ActuatorSensor.cpp | 196 +++++++ source/gameengine/GameLogic/SCA_ActuatorSensor.h | 74 +++ source/gameengine/GameLogic/SCA_EventManager.cpp | 4 +- source/gameengine/GameLogic/SCA_EventManager.h | 4 +- source/gameengine/GameLogic/SCA_IObject.cpp | 34 +- source/gameengine/GameLogic/SCA_ISensor.cpp | 1 + source/gameengine/GameLogic/SCA_ISensor.h | 3 + source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 8 +- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 17 +- source/gameengine/GameLogic/SCA_LogicManager.cpp | 4 + source/gameengine/GameLogic/SCA_MouseSensor.cpp | 12 +- source/gameengine/GameLogic/SCA_PropertySensor.cpp | 7 +- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 576 +++++++++++++++++---- source/gameengine/Ketsji/KX_ConstraintActuator.h | 59 ++- source/gameengine/Ketsji/KX_GameObject.cpp | 34 ++ source/gameengine/Ketsji/KX_GameObject.h | 9 + source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 8 +- source/gameengine/Ketsji/KX_NearSensor.cpp | 5 +- source/gameengine/Ketsji/KX_ObjectActuator.cpp | 363 +++++++++---- source/gameengine/Ketsji/KX_ObjectActuator.h | 19 +- source/gameengine/Ketsji/KX_RaySensor.cpp | 10 +- source/gameengine/Ketsji/KX_Scene.cpp | 3 + source/gameengine/Ketsji/KX_TouchSensor.cpp | 12 +- 27 files changed, 1448 insertions(+), 286 deletions(-) create mode 100644 source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp create mode 100644 source/gameengine/GameLogic/SCA_ActuatorEventManager.h create mode 100644 source/gameengine/GameLogic/SCA_ActuatorSensor.cpp create mode 100644 source/gameengine/GameLogic/SCA_ActuatorSensor.h (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index ea26c55a44e..6e05ea31fe8 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -159,7 +159,7 @@ void BL_ConvertActuators(char* maggiename, bitLocalFlag.DRot = bool((obact->flag & ACT_DROT_LOCAL)!=0); bitLocalFlag.LinearVelocity = bool((obact->flag & ACT_LIN_VEL_LOCAL)!=0); bitLocalFlag.AngularVelocity = bool((obact->flag & ACT_ANG_VEL_LOCAL)!=0); - bitLocalFlag.ClampVelocity = bool((obact->flag & ACT_CLAMP_VEL)!=0); + bitLocalFlag.ServoControl = bool(obact->type == ACT_OBJECT_SERVO); bitLocalFlag.AddOrSetLinV = bool((obact->flag & ACT_ADD_LIN_VEL)!=0); @@ -619,51 +619,105 @@ void BL_ConvertActuators(char* maggiename, case ACT_CONSTRAINT: { float min = 0.0, max = 0.0; + char *prop = NULL; KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF; bConstraintActuator *conact = (bConstraintActuator*) bact->data; /* convert settings... degrees in the ui become radians */ /* internally */ - switch (conact->flag) { - case ACT_CONST_LOCX: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX; - min = conact->minloc[0]; - max = conact->maxloc[0]; - break; - case ACT_CONST_LOCY: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY; - min = conact->minloc[1]; - max = conact->maxloc[1]; - break; - case ACT_CONST_LOCZ: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ; - min = conact->minloc[2]; - max = conact->maxloc[2]; - break; - case ACT_CONST_ROTX: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX; - min = MT_2_PI * conact->minrot[0] / 360.0; - max = MT_2_PI * conact->maxrot[0] / 360.0; - break; - case ACT_CONST_ROTY: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY; - min = MT_2_PI * conact->minrot[1] / 360.0; - max = MT_2_PI * conact->maxrot[1] / 360.0; - break; - case ACT_CONST_ROTZ: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ; - min = MT_2_PI * conact->minrot[2] / 360.0; - max = MT_2_PI * conact->maxrot[2] / 360.0; - break; - default: - ; /* error */ + if (conact->type == ACT_CONST_TYPE_ORI) { + switch (conact->mode) { + case ACT_CONST_DIRPX: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX; + break; + case ACT_CONST_DIRPY: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY; + break; + case ACT_CONST_DIRPZ: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ; + break; + } + } else if (conact->type == ACT_CONST_TYPE_DIST) { + switch (conact->mode) { + case ACT_CONST_DIRPX: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX; + min = conact->minloc[0]; + max = conact->maxloc[0]; + break; + case ACT_CONST_DIRPY: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY; + min = conact->minloc[1]; + max = conact->maxloc[1]; + break; + case ACT_CONST_DIRPZ: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPZ; + min = conact->minloc[2]; + max = conact->maxloc[2]; + break; + case ACT_CONST_DIRMX: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRMX; + min = conact->minloc[0]; + max = conact->maxloc[0]; + break; + case ACT_CONST_DIRMY: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRMY; + min = conact->minloc[1]; + max = conact->maxloc[1]; + break; + case ACT_CONST_DIRMZ: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRMZ; + min = conact->minloc[2]; + max = conact->maxloc[2]; + break; + } + prop = conact->matprop; + } else { + switch (conact->flag) { + case ACT_CONST_LOCX: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX; + min = conact->minloc[0]; + max = conact->maxloc[0]; + break; + case ACT_CONST_LOCY: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY; + min = conact->minloc[1]; + max = conact->maxloc[1]; + break; + case ACT_CONST_LOCZ: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ; + min = conact->minloc[2]; + max = conact->maxloc[2]; + break; + case ACT_CONST_ROTX: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX; + min = MT_2_PI * conact->minrot[0] / 360.0; + max = MT_2_PI * conact->maxrot[0] / 360.0; + break; + case ACT_CONST_ROTY: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY; + min = MT_2_PI * conact->minrot[1] / 360.0; + max = MT_2_PI * conact->maxrot[1] / 360.0; + break; + case ACT_CONST_ROTZ: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ; + min = MT_2_PI * conact->minrot[2] / 360.0; + max = MT_2_PI * conact->maxrot[2] / 360.0; + break; + default: + ; /* error */ + } } KX_ConstraintActuator *tmpconact = new KX_ConstraintActuator(gameobj, - conact->damp, - min, - max, - locrot); + conact->damp, + conact->rotdamp, + min, + max, + conact->maxrot, + locrot, + conact->time, + conact->flag, + prop); baseact = tmpconact; break; } diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index e7e4eeae7d2..7c9df688d45 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -64,6 +64,7 @@ probably misplaced */ #include "KX_MouseFocusSensor.h" #include "SCA_JoystickSensor.h" #include "KX_NetworkMessageSensor.h" +#include "SCA_ActuatorSensor.h" #include "SCA_PropertySensor.h" @@ -538,6 +539,19 @@ void BL_ConvertSensors(struct Object* blenderobject, break; } + case SENS_ACTUATOR: + { + bActuatorSensor* blenderactsensor = (bActuatorSensor*) sens->data; + // we will reuse the property event manager, there is nothing special with this sensor + SCA_EventManager* eventmgr + = logicmgr->FindEventManager(SCA_EventManager::ACTUATOR_EVENTMGR); + if (eventmgr) + { + STR_String propname=blenderactsensor->name; + gamesensor = new SCA_ActuatorSensor(eventmgr,gameobj,propname); + } + break; + } case SENS_RADAR: { diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp new file mode 100644 index 00000000000..28ca1fd673f --- /dev/null +++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp @@ -0,0 +1,76 @@ +/** + * $Id$ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "SCA_ISensor.h" +#include "SCA_ActuatorEventManager.h" +#include "SCA_ActuatorSensor.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + + +SCA_ActuatorEventManager::SCA_ActuatorEventManager(class SCA_LogicManager* logicmgr) + : SCA_EventManager(ACTUATOR_EVENTMGR), + m_logicmgr(logicmgr) +{ +} + + + +SCA_ActuatorEventManager::~SCA_ActuatorEventManager() +{ + +} + + + +void SCA_ActuatorEventManager::RegisterSensor(SCA_ISensor* sensor) +{ + m_sensors.push_back(sensor); +} + + + +void SCA_ActuatorEventManager::NextFrame() +{ + // check for changed actuator + for (vector::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++) + { + (*it)->Activate(m_logicmgr,NULL); + } +} + +void SCA_ActuatorEventManager::UpdateFrame() +{ + // update the state of actuator before executing them + for (vector::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++) + { + ((SCA_ActuatorSensor*)(*it))->Update(); + } +} \ No newline at end of file diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h new file mode 100644 index 00000000000..b5108764197 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h @@ -0,0 +1,52 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __KX_ACTUATOREVENTMANAGER +#define __KX_ACTUATOREVENTMANAGER + +#include "SCA_EventManager.h" + +#include + +using namespace std; + +class SCA_ActuatorEventManager : public SCA_EventManager +{ + class SCA_LogicManager* m_logicmgr; + +public: + SCA_ActuatorEventManager(class SCA_LogicManager* logicmgr); + virtual ~SCA_ActuatorEventManager(); + virtual void NextFrame(); + virtual void UpdateFrame(); + virtual void RegisterSensor(SCA_ISensor* sensor); + //SCA_LogicManager* GetLogicManager() { return m_logicmgr;} +}; + +#endif //__KX_ACTUATOREVENTMANAGER + diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp new file mode 100644 index 00000000000..9645bfbed4a --- /dev/null +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -0,0 +1,196 @@ +/** + * Actuator sensor + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include "SCA_ActuatorSensor.h" +#include "SCA_EventManager.h" +#include "SCA_LogicManager.h" + +#ifdef HAVE_CONFIG_H +#include +#endif + +SCA_ActuatorSensor::SCA_ActuatorSensor(SCA_EventManager* eventmgr, + SCA_IObject* gameobj, + const STR_String& actname, + PyTypeObject* T ) + : SCA_ISensor(gameobj,eventmgr,T), + m_checkactname(actname) +{ + m_actuator = GetParent()->FindActuator(m_checkactname); + Init(); +} + +void SCA_ActuatorSensor::Init() +{ + m_lastresult = m_invert?true:false; + m_midresult = m_lastresult; + m_reset = true; +} + +CValue* SCA_ActuatorSensor::GetReplica() +{ + SCA_ActuatorSensor* replica = new SCA_ActuatorSensor(*this); + // m_range_expr must be recalculated on replica! + CValue::AddDataToReplica(replica); + replica->Init(); + + return replica; +} + +void SCA_ActuatorSensor::ReParent(SCA_IObject* parent) +{ + m_actuator = parent->FindActuator(m_checkactname); + SCA_ISensor::ReParent(parent); +} + +bool SCA_ActuatorSensor::IsPositiveTrigger() +{ + bool result = m_lastresult; + if (m_invert) + result = !result; + + return result; +} + + + +SCA_ActuatorSensor::~SCA_ActuatorSensor() +{ +} + + + +bool SCA_ActuatorSensor::Evaluate(CValue* event) +{ + if (m_actuator) + { + bool result = m_actuator->IsActive(); + bool reset = m_reset && m_level; + + m_reset = false; + if (m_lastresult != result || m_midresult != result) + { + m_lastresult = m_midresult = result; + return true; + } + return (reset) ? true : false; + } + return false; +} + +void SCA_ActuatorSensor::Update() +{ + if (m_actuator) + { + m_midresult = m_actuator->IsActive(); + } +} + + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_ActuatorSensor::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_ActuatorSensor", + sizeof(SCA_ActuatorSensor), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_ActuatorSensor::Parents[] = { + &SCA_ActuatorSensor::Type, + &SCA_ISensor::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_ActuatorSensor::Methods[] = { + {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_VARARGS, GetActuator_doc}, + {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, SetActuator_doc}, + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_ActuatorSensor::_getattr(const STR_String& attr) { + _getattr_up(SCA_ISensor); /* implicit return! */ +} + +/* 3. getActuator */ +char SCA_ActuatorSensor::GetActuator_doc[] = +"getActuator()\n" +"\tReturn the Actuator with which the sensor operates.\n"; +PyObject* SCA_ActuatorSensor::PyGetActuator(PyObject* self, PyObject* args, PyObject* kwds) +{ + return PyString_FromString(m_checkactname); +} + +/* 4. setActuator */ +char SCA_ActuatorSensor::SetActuator_doc[] = +"setActuator(name)\n" +"\t- name: string\n" +"\tSets the Actuator with which to operate. If there is no Actuator\n" +"\tof this name, the call is ignored.\n"; +PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyObject* kwds) +{ + /* We should query whether the name exists. Or should we create a prop */ + /* on the fly? */ + char *actNameArg = NULL; + + if (!PyArg_ParseTuple(args, "s", &actNameArg)) { + return NULL; + } + + SCA_IActuator* act = GetParent()->FindActuator(STR_String(actNameArg)); + if (act) { + m_checkactname = actNameArg; + m_actuator = act; + } else { + ; /* error: bad actuator name */ + } + Py_Return; +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h new file mode 100644 index 00000000000..6086c5bfce0 --- /dev/null +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h @@ -0,0 +1,74 @@ +/** + * Actuator sensor + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __KX_ACTUATORSENSOR +#define __KX_ACTUATORSENSOR + +#include "SCA_ISensor.h" +#include "SCA_IActuator.h" + +class SCA_ActuatorSensor : public SCA_ISensor +{ + Py_Header; + STR_String m_checkactname; + bool m_lastresult; + bool m_midresult; + protected: + SCA_IActuator* m_actuator; +public: + SCA_ActuatorSensor(class SCA_EventManager* eventmgr, + SCA_IObject* gameobj, + const STR_String& actname, + PyTypeObject* T=&Type ); + + virtual ~SCA_ActuatorSensor(); + virtual CValue* GetReplica(); + virtual void Init(); + virtual bool Evaluate(CValue* event); + virtual bool IsPositiveTrigger(); + virtual void ReParent(SCA_IObject* parent); + void Update(); + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + + /* 3. setProperty */ + KX_PYMETHOD_DOC(SCA_ActuatorSensor,SetActuator); + /* 4. getProperty */ + KX_PYMETHOD_DOC(SCA_ActuatorSensor,GetActuator); + +}; + +#endif + diff --git a/source/gameengine/GameLogic/SCA_EventManager.cpp b/source/gameengine/GameLogic/SCA_EventManager.cpp index 1ca88182ddc..0169864a133 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.cpp +++ b/source/gameengine/GameLogic/SCA_EventManager.cpp @@ -72,7 +72,9 @@ void SCA_EventManager::EndFrame() { } - +void SCA_EventManager::UpdateFrame() +{ +} int SCA_EventManager::GetType() { diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h index 89731497f6f..9cc1718cd1e 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.h +++ b/source/gameengine/GameLogic/SCA_EventManager.h @@ -49,7 +49,8 @@ public: RAY_EVENTMGR, RADAR_EVENTMGR, NETWORK_EVENTMGR, - JOY_EVENTMGR + JOY_EVENTMGR, + ACTUATOR_EVENTMGR }; SCA_EventManager(EVENT_MANAGER_TYPE mgrtype); @@ -58,6 +59,7 @@ public: virtual void RemoveSensor(class SCA_ISensor* sensor); virtual void NextFrame(double curtime, double fixedtime); virtual void NextFrame(); + virtual void UpdateFrame(); virtual void EndFrame(); virtual void RegisterSensor(class SCA_ISensor* sensor)=0; int GetType(); diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 826e7bbdf0e..27e7d5faada 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -157,15 +157,15 @@ bool SCA_IObject::GetIgnoreActivityCulling() void SCA_IObject::ReParentLogic() { - SCA_SensorList& oldsensors = GetSensors(); - - int sen = 0; - SCA_SensorList::iterator its; - for (its = oldsensors.begin(); !(its==oldsensors.end()); ++its) + SCA_ActuatorList& oldactuators = GetActuators(); + int act = 0; + SCA_ActuatorList::iterator ita; + for (ita = oldactuators.begin(); !(ita==oldactuators.end()); ++ita) { - SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica(); - newsensor->ReParent(this); - oldsensors[sen++] = newsensor; + SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica(); + newactuator->ReParent(this); + newactuator->SetActive(false); + oldactuators[act++] = newactuator; } SCA_ControllerList& oldcontrollers = GetControllers(); @@ -178,17 +178,17 @@ void SCA_IObject::ReParentLogic() oldcontrollers[con++]=newcontroller; } - SCA_ActuatorList& oldactuators = GetActuators(); - - int act = 0; - SCA_ActuatorList::iterator ita; - for (ita = oldactuators.begin(); !(ita==oldactuators.end()); ++ita) + // convert sensors last so that actuators are already available for Actuator sensor + SCA_SensorList& oldsensors = GetSensors(); + int sen = 0; + SCA_SensorList::iterator its; + for (its = oldsensors.begin(); !(its==oldsensors.end()); ++its) { - SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica(); - newactuator->ReParent(this); - newactuator->SetActive(false); - oldactuators[act++] = newactuator; + SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica(); + newsensor->ReParent(this); + oldsensors[sen++] = newsensor; } + // a new object cannot be client of any actuator m_registeredActuators.clear(); diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 1b163deb7bb..68341b57435 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -56,6 +56,7 @@ SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj, m_suspended = false; m_invert = false; m_level = false; + m_reset = false; m_pos_ticks = 0; m_neg_ticks = 0; m_pos_pulsemode = false; diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 3527b87ebdb..f2ed6a803c2 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -64,6 +64,9 @@ class SCA_ISensor : public SCA_ILogicBrick /** detect level instead of edge*/ bool m_level; + /** sensor has been reset */ + bool m_reset; + /** Sensor must ignore updates? */ bool m_suspended; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 8668c22f044..3fb439eb25b 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -70,6 +70,7 @@ std::cout << " hat flag " << m_hatf << std::endl; void SCA_JoystickSensor::Init() { m_istrig=(m_invert)?1:0; + m_reset = true; } SCA_JoystickSensor::~SCA_JoystickSensor() @@ -79,9 +80,10 @@ SCA_JoystickSensor::~SCA_JoystickSensor() CValue* SCA_JoystickSensor::GetReplica() { - CValue* replica = new SCA_JoystickSensor(*this); + SCA_JoystickSensor* replica = new SCA_JoystickSensor(*this); // this will copy properties and so on... CValue::AddDataToReplica(replica); + replica->Init(); return replica; } @@ -99,7 +101,9 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) { SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice(); bool result = false; + bool reset = m_reset && m_level; + m_reset = false; switch(m_joymode) { case KX_JOYSENSORMODE_AXIS: @@ -240,6 +244,8 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) if(!js->IsTrig()){ m_istrig = 0; } + if (reset) + result = true; return result; } diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 43ce25f94df..a7a6fa93db4 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -78,14 +78,15 @@ void SCA_KeyboardSensor::Init() // However, if the target key is pressed when the sensor is reactivated, it // will not generated an event (see remark in Evaluate()). m_val = (m_invert)?1:0; + m_reset = true; } CValue* SCA_KeyboardSensor::GetReplica() { - CValue* replica = new SCA_KeyboardSensor(*this); + SCA_KeyboardSensor* replica = new SCA_KeyboardSensor(*this); // this will copy properties and so on... CValue::AddDataToReplica(replica); - + replica->Init(); return replica; } @@ -120,8 +121,8 @@ bool SCA_KeyboardSensor::TriggerOnAllKeys() bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { bool result = false; + bool reset = m_reset && m_level; SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice(); - // cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n"; /* See if we need to do logging: togPropState exists and is @@ -134,7 +135,7 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) LogKeystrokes(); } - + m_reset = false; /* Now see whether events must be bounced. */ if (m_bAllKeys) @@ -176,8 +177,8 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (m_val == 0) { + m_val = 1; if (m_level) { - m_val = 1; result = true; } } @@ -229,9 +230,9 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { if (m_val == 0) { + m_val = 1; if (m_level) { - m_val = 1; result = true; } } @@ -240,7 +241,9 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) } } } - + if (reset) + // force an event + result = true; return result; } diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index fb1a2c29eb6..f50161cbecb 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -271,6 +271,10 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame) } m_removedActuators.clear(); + // About to run actuators, but before update the sensors for those which depends on actuators + for (vector::const_iterator ie=m_eventmanagers.begin(); !(ie==m_eventmanagers.end()); ie++) + (*ie)->UpdateFrame(); + for (set::iterator ia = m_activeActuators.begin();!(ia==m_activeActuators.end());ia++) { //SCA_IActuator* actua = *ia; diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 42d35837489..2298ddb0743 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -84,6 +84,7 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, void SCA_MouseSensor::Init() { m_val = (m_invert)?1:0; /* stores the latest attribute */ + m_reset = true; } SCA_MouseSensor::~SCA_MouseSensor() @@ -95,9 +96,10 @@ SCA_MouseSensor::~SCA_MouseSensor() CValue* SCA_MouseSensor::GetReplica() { - CValue* replica = new SCA_MouseSensor(*this); + SCA_MouseSensor* replica = new SCA_MouseSensor(*this); // this will copy properties and so on... CValue::AddDataToReplica(replica); + replica->Init(); return replica; } @@ -132,6 +134,7 @@ SCA_IInputDevice::KX_EnumInputs SCA_MouseSensor::GetHotKey() bool SCA_MouseSensor::Evaluate(CValue* event) { bool result = false; + bool reset = m_reset && m_level; SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice(); @@ -143,7 +146,7 @@ bool SCA_MouseSensor::Evaluate(CValue* event) /* both MOUSEX and MOUSEY. Treat all of these as key-presses. */ /* So, treat KX_MOUSESENSORMODE_POSITION as */ /* KX_MOUSESENSORMODE_POSITIONX || KX_MOUSESENSORMODE_POSITIONY */ - + m_reset = false; switch (m_mousemode) { case KX_MOUSESENSORMODE_LEFTBUTTON: case KX_MOUSESENSORMODE_MIDDLEBUTTON: @@ -168,9 +171,9 @@ bool SCA_MouseSensor::Evaluate(CValue* event) { if (m_val == 0) { + m_val = 1; if (m_level) { - m_val = 1; result = true; } } @@ -222,6 +225,9 @@ bool SCA_MouseSensor::Evaluate(CValue* event) ; /* error */ } + if (reset) + // force an event + result = true; return result; } diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index 655e9060238..c50c011cc63 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -78,6 +78,7 @@ void SCA_PropertySensor::Init() { m_recentresult = false; m_lastresult = m_invert?true:false; + m_reset = true; } void SCA_PropertySensor::PrecalculateRangeExpression() @@ -111,6 +112,7 @@ CValue* SCA_PropertySensor::GetReplica() SCA_PropertySensor* replica = new SCA_PropertySensor(*this); // m_range_expr must be recalculated on replica! CValue::AddDataToReplica(replica); + replica->Init(); replica->m_range_expr = NULL; if (replica->m_checktype==KX_PROPSENSOR_INTERVAL) @@ -153,14 +155,15 @@ SCA_PropertySensor::~SCA_PropertySensor() bool SCA_PropertySensor::Evaluate(CValue* event) { bool result = CheckPropertyCondition(); + bool reset = m_reset && m_level; + m_reset = false; if (m_lastresult!=result) { m_lastresult = result; return true; } - - return false; + return (reset) ? true : false; } diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index bd843d97199..80288a72485 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -35,6 +35,7 @@ #include "MT_Point3.h" #include "MT_Matrix3x3.h" #include "KX_GameObject.h" +#include "KX_RayCast.h" #ifdef HAVE_CONFIG_H #include @@ -45,35 +46,54 @@ /* ------------------------------------------------------------------------- */ KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj, - int dampTime, + int posDampTime, + int rotDampTime, float minBound, float maxBound, + float refDir[3], int locrotxyz, - PyTypeObject* T) - : SCA_IActuator(gameobj, T) + int time, + int option, + char *property, + PyTypeObject* T) : + m_refDirection(refDir), + m_currentTime(0), + SCA_IActuator(gameobj, T) { - m_dampTime = dampTime; + m_posDampTime = posDampTime; + m_rotDampTime = rotDampTime; m_locrot = locrotxyz; + m_option = option; + m_activeTime = time; + if (property) { + strncpy(m_property, property, sizeof(m_property)); + m_property[sizeof(m_property)-1] = 0; + } else { + m_property[0] = 0; + } /* The units of bounds are determined by the type of constraint. To */ /* make the constraint application easier and more transparent later on, */ /* I think converting the bounds to the applicable domain makes more */ /* sense. */ switch (m_locrot) { - case KX_ACT_CONSTRAINT_LOCX: - case KX_ACT_CONSTRAINT_LOCY: - case KX_ACT_CONSTRAINT_LOCZ: + case KX_ACT_CONSTRAINT_ORIX: + case KX_ACT_CONSTRAINT_ORIY: + case KX_ACT_CONSTRAINT_ORIZ: + { + MT_Scalar len = m_refDirection.length(); + if (MT_fuzzyZero(len)) { + // missing a valid direction + std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no valid reference direction!" << std::endl; + m_locrot = KX_ACT_CONSTRAINT_NODEF; + } else { + m_refDirection /= len; + } + } + break; + default: m_minimumBound = minBound; m_maximumBound = maxBound; break; - case KX_ACT_CONSTRAINT_ROTX: - case KX_ACT_CONSTRAINT_ROTY: - case KX_ACT_CONSTRAINT_ROTZ: - /* The user interface asks for degrees, we are radian. */ - m_minimumBound = MT_radians(minBound); - m_maximumBound = MT_radians(maxBound); - break; - default: - ; /* error */ } } /* End of constructor */ @@ -83,77 +103,239 @@ KX_ConstraintActuator::~KX_ConstraintActuator() // there's nothing to be done here, really.... } /* end of destructor */ -bool KX_ConstraintActuator::Update(double curtime, bool frame) +bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) { - bool result = false; - bool bNegativeEvent = IsNegativeEvent(); - RemoveAllEvents(); - - if (bNegativeEvent) - return false; // do nothing on negative events - - /* Constraint clamps the values to the specified range, with a sort of */ - /* low-pass filtered time response, if the damp time is unequal to 0. */ - - /* Having to retrieve location/rotation and setting it afterwards may not */ - /* be efficient enough... Somthing to look at later. */ - KX_GameObject *parent = (KX_GameObject*) GetParent(); - MT_Point3 position = parent->NodeGetWorldPosition(); - MT_Matrix3x3 rotation = parent->NodeGetWorldOrientation(); -// MT_Vector3 eulerrot = rotation.getEuler(); + KX_GameObject* hitKXObj = client->m_gameobject; - switch (m_locrot) { - case KX_ACT_CONSTRAINT_LOCX: - Clamp(position[0], m_minimumBound, m_maximumBound); - result = true; - break; - case KX_ACT_CONSTRAINT_LOCY: - Clamp(position[1], m_minimumBound, m_maximumBound); - result = true; - break; - case KX_ACT_CONSTRAINT_LOCZ: - Clamp(position[2], m_minimumBound, m_maximumBound); - result = true; - break; - -// case KX_ACT_CONSTRAINT_ROTX: -// /* The angles are Euler angles (I think that's what they are called) */ -// /* but we need to convert from/to the MT_Matrix3x3. */ -// Clamp(eulerrot[0], m_minimumBound, m_maximumBound); -// break; -// case KX_ACT_CONSTRAINT_ROTY: -// Clamp(eulerrot[1], m_minimumBound, m_maximumBound); -// break; -// case KX_ACT_CONSTRAINT_ROTZ: -// Clamp(eulerrot[2], m_minimumBound, m_maximumBound); -// break; -// default: -// ; /* error */ + if (client->m_type > KX_ClientObjectInfo::ACTOR) + { + // false hit + return false; } + bool bFound = false; - /* Will be replaced by a filtered clamp. */ - + if (m_property[0] == 0) + { + bFound = true; + } + else + { + if (m_option & KX_ACT_CONSTRAINT_MATERIAL) + { + if (client->m_auxilary_info) + { + bFound = !strcmp(m_property, ((char*)client->m_auxilary_info)); + } + } + else + { + bFound = hitKXObj->GetProperty(m_property) != NULL; + } + } - switch (m_locrot) { - case KX_ACT_CONSTRAINT_LOCX: - case KX_ACT_CONSTRAINT_LOCY: - case KX_ACT_CONSTRAINT_LOCZ: - parent->NodeSetLocalPosition(position); - break; + return bFound; +} +bool KX_ConstraintActuator::Update(double curtime, bool frame) +{ -// case KX_ACT_CONSTRAINT_ROTX: -// case KX_ACT_CONSTRAINT_ROTY: -// case KX_ACT_CONSTRAINT_ROTZ: -// rotation.setEuler(eulerrot); -// parent->NodeSetLocalOrientation(rotation); - break; + bool result = false; + bool bNegativeEvent = IsNegativeEvent(); + RemoveAllEvents(); - default: - ; /* error */ + if (!bNegativeEvent) { + /* Constraint clamps the values to the specified range, with a sort of */ + /* low-pass filtered time response, if the damp time is unequal to 0. */ + + /* Having to retrieve location/rotation and setting it afterwards may not */ + /* be efficient enough... Somthing to look at later. */ + KX_GameObject *obj = (KX_GameObject*) GetParent(); + MT_Point3 position = obj->NodeGetWorldPosition(); + MT_Point3 newposition; + MT_Vector3 direction; + MT_Matrix3x3 rotation = obj->NodeGetWorldOrientation(); + MT_Scalar filter, newdistance; + int axis, sign; + + if (m_posDampTime) { + filter = m_posDampTime/(1.0+m_posDampTime); + } + switch (m_locrot) { + case KX_ACT_CONSTRAINT_ORIX: + case KX_ACT_CONSTRAINT_ORIY: + case KX_ACT_CONSTRAINT_ORIZ: + switch (m_locrot) { + case KX_ACT_CONSTRAINT_ORIX: + direction[0] = rotation[0][0]; + direction[1] = rotation[1][0]; + direction[2] = rotation[2][0]; + axis = 0; + break; + case KX_ACT_CONSTRAINT_ORIY: + direction[0] = rotation[0][1]; + direction[1] = rotation[1][1]; + direction[2] = rotation[2][1]; + axis = 1; + break; + case KX_ACT_CONSTRAINT_ORIZ: + direction[0] = rotation[0][2]; + direction[1] = rotation[1][2]; + direction[2] = rotation[2][2]; + axis = 2; + break; + } + // apply damping on the direction + if (m_posDampTime) { + direction = filter*direction + (1.0-filter)*m_refDirection; + } + obj->AlignAxisToVect(direction, axis); + result = true; + goto CHECK_TIME; + case KX_ACT_CONSTRAINT_DIRPX: + case KX_ACT_CONSTRAINT_DIRPY: + case KX_ACT_CONSTRAINT_DIRPZ: + case KX_ACT_CONSTRAINT_DIRMX: + case KX_ACT_CONSTRAINT_DIRMY: + case KX_ACT_CONSTRAINT_DIRMZ: + switch (m_locrot) { + case KX_ACT_CONSTRAINT_DIRPX: + direction[0] = rotation[0][0]; + direction[1] = rotation[1][0]; + direction[2] = rotation[2][0]; + axis = 0; // axis according to KX_GameObject::AlignAxisToVect() + sign = 1; // X axis will be anti parrallel to normal + break; + case KX_ACT_CONSTRAINT_DIRPY: + direction[0] = rotation[0][1]; + direction[1] = rotation[1][1]; + direction[2] = rotation[2][1]; + axis = 1; + sign = 1; + break; + case KX_ACT_CONSTRAINT_DIRPZ: + direction[0] = rotation[0][2]; + direction[1] = rotation[1][2]; + direction[2] = rotation[2][2]; + axis = 2; + sign = 1; + break; + case KX_ACT_CONSTRAINT_DIRMX: + direction[0] = -rotation[0][0]; + direction[1] = -rotation[1][0]; + direction[2] = -rotation[2][0]; + axis = 0; + sign = 0; + break; + case KX_ACT_CONSTRAINT_DIRMY: + direction[0] = -rotation[0][1]; + direction[1] = -rotation[1][1]; + direction[2] = -rotation[2][1]; + axis = 1; + sign = 0; + break; + case KX_ACT_CONSTRAINT_DIRMZ: + direction[0] = -rotation[0][2]; + direction[1] = -rotation[1][2]; + direction[2] = -rotation[2][2]; + axis = 2; + sign = 0; + break; + } + direction.normalize(); + { + MT_Point3 topoint = position + (m_maximumBound) * direction; + MT_Point3 resultpoint; + MT_Vector3 resultnormal; + PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment(); + KX_IPhysicsController *spc = obj->GetPhysicsController(); + + if (!pe) { + std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl; + goto CHECK_TIME; + } + if (!spc) { + // the object is not physical, we probably want to avoid hitting its own parent + KX_GameObject *parent = obj->GetParent(); + if (parent) { + spc = parent->GetPhysicsController(); + parent->Release(); + } + } + result = KX_RayCast::RayTest(spc, pe, position, topoint, resultpoint, resultnormal, KX_RayCast::Callback(this)); + + if (result) { + // compute new position & orientation + if ((m_option & (KX_ACT_CONSTRAINT_NORMAL|KX_ACT_CONSTRAINT_DISTANCE)) == 0) { + // if none option is set, the actuator does nothing but detect ray + // (works like a sensor) + goto CHECK_TIME; + } + if (m_option & KX_ACT_CONSTRAINT_NORMAL) { + // the new orientation must be so that the axis is parallel to normal + if (sign) + resultnormal = -resultnormal; + // apply damping on the direction + if (m_rotDampTime) { + MT_Scalar rotFilter = 1.0/(1.0+m_rotDampTime); + resultnormal = (-m_rotDampTime*rotFilter)*direction + rotFilter*resultnormal; + } else if (m_posDampTime) { + resultnormal = -filter*direction + (1.0-filter)*resultnormal; + } + obj->AlignAxisToVect(resultnormal, axis); + direction = -resultnormal; + } + if (m_option & KX_ACT_CONSTRAINT_DISTANCE) { + if (m_posDampTime) { + newdistance = filter*(position-resultpoint).length()+(1.0-filter)*m_minimumBound; + } else { + newdistance = m_minimumBound; + } + } else { + newdistance = (position-resultpoint).length(); + } + newposition = resultpoint-newdistance*direction; + } else if (m_option & KX_ACT_CONSTRAINT_PERMANENT) { + // no contact but still keep running + result = true; + goto CHECK_TIME; + } + } + break; + case KX_ACT_CONSTRAINT_LOCX: + case KX_ACT_CONSTRAINT_LOCY: + case KX_ACT_CONSTRAINT_LOCZ: + newposition = position; + switch (m_locrot) { + case KX_ACT_CONSTRAINT_LOCX: + Clamp(newposition[0], m_minimumBound, m_maximumBound); + break; + case KX_ACT_CONSTRAINT_LOCY: + Clamp(newposition[1], m_minimumBound, m_maximumBound); + break; + case KX_ACT_CONSTRAINT_LOCZ: + Clamp(newposition[2], m_minimumBound, m_maximumBound); + break; + } + result = true; + if (m_posDampTime) { + newposition = filter*position + (1.0-filter)*newposition; + } + break; + } + if (result) { + // set the new position but take into account parent if any + obj->NodeSetWorldPosition(newposition); + } + CHECK_TIME: + if (result && m_activeTime > 0 ) { + if (++m_currentTime >= m_activeTime) + result = false; + } + } + if (!result) { + m_currentTime = 0; } - return result; } /* end of KX_ConstraintActuator::Update(double curtime,double deltatime) */ @@ -214,10 +396,24 @@ PyParentObject KX_ConstraintActuator::Parents[] = { PyMethodDef KX_ConstraintActuator::Methods[] = { {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, SetDamp_doc}, {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_VARARGS, GetDamp_doc}, + {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, SetRotDamp_doc}, + {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_VARARGS, GetRotDamp_doc}, + {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, SetDirection_doc}, + {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_VARARGS, GetDirection_doc}, + {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, SetOption_doc}, + {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_VARARGS, GetOption_doc}, + {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, SetTime_doc}, + {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_VARARGS, GetTime_doc}, + {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, + {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, SetMin_doc}, {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_VARARGS, GetMin_doc}, + {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, SetDistance_doc}, + {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_VARARGS, GetDistance_doc}, {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, SetMax_doc}, {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_VARARGS, GetMax_doc}, + {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, SetRayLength_doc}, + {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_VARARGS, GetRayLength_doc}, {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, SetLimit_doc}, {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_VARARGS, GetLimit_doc}, {NULL,NULL} //Sentinel @@ -231,7 +427,7 @@ PyObject* KX_ConstraintActuator::_getattr(const STR_String& attr) { char KX_ConstraintActuator::SetDamp_doc[] = "setDamp(duration)\n" "\t- duration: integer\n" -"\tSets the time with which the constraint application is delayed.\n" +"\tSets the time constant of the orientation and distance constraint.\n" "\tIf the duration is negative, it is set to 0.\n"; PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self, PyObject* args, @@ -241,21 +437,192 @@ PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self, return NULL; } - m_dampTime = dampArg; - if (m_dampTime < 0) m_dampTime = 0; + m_posDampTime = dampArg; + if (m_posDampTime < 0) m_posDampTime = 0; Py_Return; } /* 3. getDamp */ char KX_ConstraintActuator::GetDamp_doc[] = -"GetDamp()\n" -"\tReturns the damping time for application of the constraint.\n"; +"getDamp()\n" +"\tReturns the damping parameter.\n"; PyObject* KX_ConstraintActuator::PyGetDamp(PyObject* self, PyObject* args, PyObject* kwds){ - return PyInt_FromLong(m_dampTime); + return PyInt_FromLong(m_posDampTime); } +/* 2. setRotDamp */ +char KX_ConstraintActuator::SetRotDamp_doc[] = +"setRotDamp(duration)\n" +"\t- duration: integer\n" +"\tSets the time constant of the orientation constraint.\n" +"\tIf the duration is negative, it is set to 0.\n"; +PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* self, + PyObject* args, + PyObject* kwds) { + int dampArg; + if(!PyArg_ParseTuple(args, "i", &dampArg)) { + return NULL; + } + + m_rotDampTime = dampArg; + if (m_rotDampTime < 0) m_rotDampTime = 0; + + Py_Return; +} +/* 3. getRotDamp */ +char KX_ConstraintActuator::GetRotDamp_doc[] = +"getRotDamp()\n" +"\tReturns the damping time for application of the constraint.\n"; +PyObject* KX_ConstraintActuator::PyGetRotDamp(PyObject* self, + PyObject* args, + PyObject* kwds){ + return PyInt_FromLong(m_rotDampTime); +} + +/* 2. setDirection */ +char KX_ConstraintActuator::SetDirection_doc[] = +"setDirection(vector)\n" +"\t- vector: 3-tuple\n" +"\tSets the reference direction in world coordinate for the orientation constraint.\n"; +PyObject* KX_ConstraintActuator::PySetDirection(PyObject* self, + PyObject* args, + PyObject* kwds) { + float x, y, z; + MT_Scalar len; + MT_Vector3 dir; + + if(!PyArg_ParseTuple(args, "(fff)", &x, &y, &z)) { + return NULL; + } + dir[0] = x; + dir[1] = y; + dir[2] = z; + len = dir.length(); + if (MT_fuzzyZero(len)) { + std::cout << "Invalid direction" << std::endl; + return NULL; + } + m_refDirection = dir/len; + + Py_Return; +} +/* 3. getDirection */ +char KX_ConstraintActuator::GetDirection_doc[] = +"getDirection()\n" +"\tReturns the reference direction of the orientation constraint as a 3-tuple.\n"; +PyObject* KX_ConstraintActuator::PyGetDirection(PyObject* self, + PyObject* args, + PyObject* kwds){ + PyObject *retVal = PyList_New(3); + + PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_refDirection[0])); + PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_refDirection[1])); + PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_refDirection[2])); + return retVal; +} + +/* 2. setOption */ +char KX_ConstraintActuator::SetOption_doc[] = +"setOption(option)\n" +"\t- option: integer\n" +"\tSets several options of the distance constraint.\n" +"\tBinary combination of the following values:\n" +"\t\t 64 : Activate alignment to surface\n" +"\t\t128 : Detect material rather than property\n" +"\t\t256 : No deactivation if ray does not hit target\n" +"\t\t512 : Activate distance control\n"; +PyObject* KX_ConstraintActuator::PySetOption(PyObject* self, + PyObject* args, + PyObject* kwds) { + int option; + if(!PyArg_ParseTuple(args, "i", &option)) { + return NULL; + } + + m_option = option; + + Py_Return; +} +/* 3. getOption */ +char KX_ConstraintActuator::GetOption_doc[] = +"getOption()\n" +"\tReturns the option parameter.\n"; +PyObject* KX_ConstraintActuator::PyGetOption(PyObject* self, + PyObject* args, + PyObject* kwds){ + return PyInt_FromLong(m_option); +} + +/* 2. setTime */ +char KX_ConstraintActuator::SetTime_doc[] = +"setTime(duration)\n" +"\t- duration: integer\n" +"\tSets the activation time of the actuator.\n" +"\tThe actuator disables itself after this many frame.\n" +"\tIf set to 0 or negative, the actuator is not limited in time.\n"; +PyObject* KX_ConstraintActuator::PySetTime(PyObject* self, + PyObject* args, + PyObject* kwds) { + int t; + if(!PyArg_ParseTuple(args, "i", &t)) { + return NULL; + } + + if (t < 0) + t = 0; + m_activeTime = t; + + Py_Return; +} +/* 3. getTime */ +char KX_ConstraintActuator::GetTime_doc[] = +"getTime()\n" +"\tReturns the time parameter.\n"; +PyObject* KX_ConstraintActuator::PyGetTime(PyObject* self, + PyObject* args, + PyObject* kwds){ + return PyInt_FromLong(m_activeTime); +} + +/* 2. setProperty */ +char KX_ConstraintActuator::SetProperty_doc[] = +"setProperty(property)\n" +"\t- property: string\n" +"\tSets the name of the property or material for the ray detection of the distance constraint.\n" +"\tIf empty, the ray will detect any collisioning object.\n"; +PyObject* KX_ConstraintActuator::PySetProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + char *property; + if (!PyArg_ParseTuple(args, "s", &property)) { + return NULL; + } + if (property == NULL) { + m_property[0] = 0; + } else { + strncpy(m_property, property, sizeof(m_property)); + m_property[sizeof(m_property)-1] = 0; + } + + Py_Return; +} +/* 3. getProperty */ +char KX_ConstraintActuator::GetProperty_doc[] = +"getProperty()\n" +"\tReturns the property parameter.\n"; +PyObject* KX_ConstraintActuator::PyGetProperty(PyObject* self, + PyObject* args, + PyObject* kwds){ + return PyString_FromString(m_property); +} + +/* 4. setDistance */ +char KX_ConstraintActuator::SetDistance_doc[] = +"setDistance(distance)\n" +"\t- distance: float\n" +"\tSets the target distance in distance constraint\n"; /* 4. setMin */ char KX_ConstraintActuator::SetMin_doc[] = "setMin(lower_bound)\n" @@ -271,9 +638,7 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self, } switch (m_locrot) { - case KX_ACT_CONSTRAINT_LOCX: - case KX_ACT_CONSTRAINT_LOCY: - case KX_ACT_CONSTRAINT_LOCZ: + default: m_minimumBound = minArg; break; case KX_ACT_CONSTRAINT_ROTX: @@ -281,12 +646,14 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self, case KX_ACT_CONSTRAINT_ROTZ: m_minimumBound = MT_radians(minArg); break; - default: - ; /* error */ } Py_Return; } +/* 5. getDistance */ +char KX_ConstraintActuator::GetDistance_doc[] = +"getDistance()\n" +"\tReturns the distance parameter \n"; /* 5. getMin */ char KX_ConstraintActuator::GetMin_doc[] = "getMin()\n" @@ -298,6 +665,11 @@ PyObject* KX_ConstraintActuator::PyGetMin(PyObject* self, return PyFloat_FromDouble(m_minimumBound); } +/* 6. setRayLength */ +char KX_ConstraintActuator::SetRayLength_doc[] = +"setRayLength(length)\n" +"\t- length: float\n" +"\tSets the maximum ray length of the distance constraint\n"; /* 6. setMax */ char KX_ConstraintActuator::SetMax_doc[] = "setMax(upper_bound)\n" @@ -313,9 +685,7 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self, } switch (m_locrot) { - case KX_ACT_CONSTRAINT_LOCX: - case KX_ACT_CONSTRAINT_LOCY: - case KX_ACT_CONSTRAINT_LOCZ: + default: m_maximumBound = maxArg; break; case KX_ACT_CONSTRAINT_ROTX: @@ -323,12 +693,14 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self, case KX_ACT_CONSTRAINT_ROTZ: m_maximumBound = MT_radians(maxArg); break; - default: - ; /* error */ } Py_Return; } +/* 7. getRayLength */ +char KX_ConstraintActuator::GetRayLength_doc[] = +"getRayLength()\n" +"\tReturns the length of the ray\n"; /* 7. getMax */ char KX_ConstraintActuator::GetMax_doc[] = "getMax()\n" @@ -345,9 +717,19 @@ PyObject* KX_ConstraintActuator::PyGetMax(PyObject* self, /* 8. setLimit */ char KX_ConstraintActuator::SetLimit_doc[] = "setLimit(type)\n" -"\t- type: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY,\n" -"\t KX_CONSTRAINTACT_LOCZ, KX_CONSTRAINTACT_ROTX,\n" -"\t KX_CONSTRAINTACT_ROTY, or KX_CONSTRAINTACT_ROTZ.\n" +"\t- type: integer\n" +"\t 1 : LocX\n" +"\t 2 : LocY\n" +"\t 3 : LocZ\n" +"\t 7 : Distance along +X axis\n" +"\t 8 : Distance along +Y axis\n" +"\t 9 : Distance along +Z axis\n" +"\t 10 : Distance along -X axis\n" +"\t 11 : Distance along -Y axis\n" +"\t 12 : Distance along -Z axis\n" +"\t 13 : Align X axis\n" +"\t 14 : Align Y axis\n" +"\t 15 : Align Z axis\n" "\tSets the type of constraint.\n"; PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self, PyObject* args, @@ -363,7 +745,7 @@ PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self, } /* 9. getLimit */ char KX_ConstraintActuator::GetLimit_doc[] = -"getLimit(type)\n" +"getLimit()\n" "\tReturns the type of constraint.\n"; PyObject* KX_ConstraintActuator::PyGetLimit(PyObject* self, PyObject* args, diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index a21a5f30de6..5a1d4d23217 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -34,19 +34,31 @@ #include "SCA_IActuator.h" #include "MT_Scalar.h" +#include "MT_Vector3.h" +#include "KX_ClientObjectInfo.h" class KX_ConstraintActuator : public SCA_IActuator { Py_Header; protected: // Damp time (int), - int m_dampTime; - // min (float), + int m_posDampTime; + int m_rotDampTime; + // min (float) float m_minimumBound; - // max (float), + // max (float) float m_maximumBound; + // reference direction + MT_Vector3 m_refDirection; // locrotxyz choice (pick one): only one choice allowed at a time! int m_locrot; + // active time of actuator + int m_activeTime; + int m_currentTime; + // option + int m_option; + // property to check + char m_property[32]; /** * Clamp to , . Borders are included (in as far as @@ -56,6 +68,7 @@ protected: public: + // m_locrot enum KX_CONSTRAINTTYPE { KX_ACT_CONSTRAINT_NODEF = 0, KX_ACT_CONSTRAINT_LOCX, @@ -64,16 +77,37 @@ protected: KX_ACT_CONSTRAINT_ROTX, KX_ACT_CONSTRAINT_ROTY, KX_ACT_CONSTRAINT_ROTZ, + KX_ACT_CONSTRAINT_DIRPX, + KX_ACT_CONSTRAINT_DIRPY, + KX_ACT_CONSTRAINT_DIRPZ, + KX_ACT_CONSTRAINT_DIRMX, + KX_ACT_CONSTRAINT_DIRMY, + KX_ACT_CONSTRAINT_DIRMZ, + KX_ACT_CONSTRAINT_ORIX, + KX_ACT_CONSTRAINT_ORIY, + KX_ACT_CONSTRAINT_ORIZ, KX_ACT_CONSTRAINT_MAX }; - + // match ACT_CONST_... values from BIF_interface.h + enum KX_CONSTRAINTOPT { + KX_ACT_CONSTRAINT_NORMAL = 64, + KX_ACT_CONSTRAINT_MATERIAL = 128, + KX_ACT_CONSTRAINT_PERMANENT = 256, + KX_ACT_CONSTRAINT_DISTANCE = 512 + }; bool IsValidMode(KX_CONSTRAINTTYPE m); + bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); KX_ConstraintActuator(SCA_IObject* gameobj, - int damptime, + int posDamptime, + int rotDampTime, float min, float max, + float refDir[3], int locrot, + int time, + int option, + char *property, PyTypeObject* T=&Type); virtual ~KX_ConstraintActuator(); virtual CValue* GetReplica() { @@ -94,13 +128,26 @@ protected: KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDamp); KX_PYMETHOD_DOC(KX_ConstraintActuator,GetDamp); + KX_PYMETHOD_DOC(KX_ConstraintActuator,SetRotDamp); + KX_PYMETHOD_DOC(KX_ConstraintActuator,GetRotDamp); + KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDirection); + KX_PYMETHOD_DOC(KX_ConstraintActuator,GetDirection); + KX_PYMETHOD_DOC(KX_ConstraintActuator,SetOption); + KX_PYMETHOD_DOC(KX_ConstraintActuator,GetOption); + KX_PYMETHOD_DOC(KX_ConstraintActuator,SetTime); + KX_PYMETHOD_DOC(KX_ConstraintActuator,GetTime); + KX_PYMETHOD_DOC(KX_ConstraintActuator,SetProperty); + KX_PYMETHOD_DOC(KX_ConstraintActuator,GetProperty); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMin); KX_PYMETHOD_DOC(KX_ConstraintActuator,GetMin); + static char SetDistance_doc[]; + static char GetDistance_doc[]; KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMax); KX_PYMETHOD_DOC(KX_ConstraintActuator,GetMax); + static char SetRayLength_doc[]; + static char GetRayLength_doc[]; KX_PYMETHOD_DOC(KX_ConstraintActuator,SetLimit); KX_PYMETHOD_DOC(KX_ConstraintActuator,GetLimit); - }; #endif //__KX_CONSTRAINTACTUATOR diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index c4925cb772c..d6d2254850a 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -644,6 +644,15 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis) NodeSetLocalOrientation(orimat); } +MT_Scalar KX_GameObject::GetMass() +{ + if (m_pPhysicsController1) + { + return m_pPhysicsController1->GetMass(); + } + return 0.0; +} + MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { MT_Vector3 velocity(0.0,0.0,0.0), locvel; @@ -735,6 +744,31 @@ void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale) GetSGNode()->RelativeScale(scale); } +void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans) +{ + SG_Node* parent = m_pSGNode->GetSGParent(); + if (parent != NULL) + { + // Make sure the objects have some scale + MT_Vector3 scale = parent->GetWorldScaling(); + if (fabs(scale[0]) < FLT_EPSILON || + fabs(scale[1]) < FLT_EPSILON || + fabs(scale[2]) < FLT_EPSILON) + { + return; + } + scale[0] = 1.0/scale[0]; + scale[1] = 1.0/scale[1]; + scale[2] = 1.0/scale[2]; + MT_Matrix3x3 invori = parent->GetWorldOrientation().inverse(); + MT_Vector3 newpos = invori*(trans-parent->GetWorldPosition())*scale; + NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2])); + } + else + { + NodeSetLocalPosition(trans); + } +} void KX_GameObject::NodeUpdateGS(double time,bool bInitiator) diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 31b56df5368..5e44a36515d 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -258,6 +258,12 @@ public: bool local=false ); + /** + * Return the mass of the object + */ + MT_Scalar + GetMass(); + /** * Return the angular velocity of the game object. */ @@ -332,6 +338,9 @@ public: void NodeSetRelativeScale( const MT_Vector3& scale ); + // adapt local position so that world position is set to desired position + void NodeSetWorldPosition(const MT_Point3& trans); + void NodeUpdateGS( double time, diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index f89d32bbe66..db0bef8b7e1 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -77,15 +77,17 @@ void KX_MouseFocusSensor::Init() m_mouse_over_in_previous_frame = (m_invert)?true:false; m_positive_event = false; m_hitObject = 0; + m_reset = true; } bool KX_MouseFocusSensor::Evaluate(CValue* event) { bool result = false; bool obHasFocus = false; + bool reset = m_reset && m_level; // cout << "evaluate focus mouse sensor "<m_colliders = new CListValue(); - replica->m_bCollision = false; - replica->m_bTriggered= false; - replica->m_hitObject = NULL; - replica->m_bLastTriggered = false; + replica->Init(); // this will copy properties and so on... CValue::AddDataToReplica(replica); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 03ae14997ab..9ac0b4d4703 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -68,8 +68,15 @@ KX_ObjectActuator( m_bitLocalFlag (flag), m_active_combined_velocity (false), m_linear_damping_active(false), - m_angular_damping_active(false) + m_angular_damping_active(false), + m_error_accumulator(0.0,0.0,0.0), + m_previous_error(0.0,0.0,0.0) { + if (m_bitLocalFlag.ServoControl) + { + // in servo motion, the force is local if the target velocity is local + m_bitLocalFlag.Force = m_bitLocalFlag.LinearVelocity; + } UpdateFuzzyFlags(); } @@ -87,105 +94,151 @@ bool KX_ObjectActuator::Update() // it should reconcile the externally set velocity with it's // own velocity. if (m_active_combined_velocity) { - parent->ResolveCombinedVelocities( - m_linear_velocity, - m_angular_velocity, - (m_bitLocalFlag.LinearVelocity) != 0, - (m_bitLocalFlag.AngularVelocity) != 0 - ); + if (parent) + parent->ResolveCombinedVelocities( + m_linear_velocity, + m_angular_velocity, + (m_bitLocalFlag.LinearVelocity) != 0, + (m_bitLocalFlag.AngularVelocity) != 0 + ); m_active_combined_velocity = false; } m_linear_damping_active = false; + m_angular_damping_active = false; + m_error_accumulator.setValue(0.0,0.0,0.0); + m_previous_error.setValue(0.0,0.0,0.0); return false; - } else - if (parent) + } else if (parent) { - if (!m_bitLocalFlag.ZeroForce) + if (m_bitLocalFlag.ServoControl) { - if (m_bitLocalFlag.ClampVelocity && !m_bitLocalFlag.ZeroLinearVelocity) + // In this mode, we try to reach a target speed using force + // As we don't know the friction, we must implement a generic + // servo control to achieve the speed in a configurable + // v = current velocity + // V = target velocity + // e = V-v = speed error + // dt = time interval since previous update + // I = sum(e(t)*dt) + // dv = e(t) - e(t-1) + // KP, KD, KI : coefficient + // F = KP*e+KI*I+KD*dv + MT_Scalar mass = parent->GetMass(); + if (mass < MT_EPSILON) + return false; + MT_Vector3 v = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity); + MT_Vector3 e = m_linear_velocity - v; + MT_Vector3 dv = e - m_previous_error; + MT_Vector3 I = m_error_accumulator + e; + + m_force = m_torque.x()*e+m_torque.y()*I+m_torque.z()*dv; + // to automatically adapt the PID coefficient to mass; + m_force *= mass; + if (m_bitLocalFlag.Torque) { - // The user is requesting not to exceed the velocity set in m_linear_velocity - // The verification is done by projecting the actual speed along the linV direction - // and comparing it with the linV vector length - MT_Vector3 linV; - linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity); - if (linV.dot(m_linear_velocity) < m_linear_length2) - parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0); - } else + if (m_force[0] > m_dloc[0]) + { + m_force[0] = m_dloc[0]; + I[0] = m_error_accumulator[0]; + } else if (m_force[0] < m_drot[0]) + { + m_force[0] = m_drot[0]; + I[0] = m_error_accumulator[0]; + } + } + if (m_bitLocalFlag.DLoc) { - parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0); + if (m_force[1] > m_dloc[1]) + { + m_force[1] = m_dloc[1]; + I[1] = m_error_accumulator[1]; + } else if (m_force[1] < m_drot[1]) + { + m_force[1] = m_drot[1]; + I[1] = m_error_accumulator[1]; + } } - } - if (!m_bitLocalFlag.ZeroTorque) + if (m_bitLocalFlag.DRot) + { + if (m_force[2] > m_dloc[2]) + { + m_force[2] = m_dloc[2]; + I[2] = m_error_accumulator[2]; + } else if (m_force[2] < m_drot[2]) + { + m_force[2] = m_drot[2]; + I[2] = m_error_accumulator[2]; + } + } + m_previous_error = e; + m_error_accumulator = I; + parent->ApplyForce(m_force,(m_bitLocalFlag.LinearVelocity) != 0); + } else { - if (m_bitLocalFlag.ClampVelocity && !m_bitLocalFlag.ZeroAngularVelocity) + if (!m_bitLocalFlag.ZeroForce) { - // The user is requesting not to exceed the velocity set in m_angular_velocity - // The verification is done by projecting the actual speed in the - MT_Vector3 angV; - angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity); - if (angV.dot(m_angular_velocity) < m_angular_velocity.length2()) - parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0); - } else + parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0); + } + if (!m_bitLocalFlag.ZeroTorque) { parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0); } - } - if (!m_bitLocalFlag.ZeroDLoc) - { - parent->ApplyMovement(m_dloc,(m_bitLocalFlag.DLoc) != 0); - } - if (!m_bitLocalFlag.ZeroDRot) - { - parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0); - } - if (!m_bitLocalFlag.ZeroLinearVelocity && !m_bitLocalFlag.ClampVelocity) - { - if (m_bitLocalFlag.AddOrSetLinV) { - parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); - } else { + if (!m_bitLocalFlag.ZeroDLoc) + { + parent->ApplyMovement(m_dloc,(m_bitLocalFlag.DLoc) != 0); + } + if (!m_bitLocalFlag.ZeroDRot) + { + parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0); + } + if (!m_bitLocalFlag.ZeroLinearVelocity) + { + if (m_bitLocalFlag.AddOrSetLinV) { + parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); + } else { + m_active_combined_velocity = true; + if (m_damping > 0) { + MT_Vector3 linV; + if (!m_linear_damping_active) { + // delta and the start speed (depends on the existing speed in that direction) + linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity); + // keep only the projection along the desired direction + m_current_linear_factor = linV.dot(m_linear_velocity)/m_linear_length2; + m_linear_damping_active = true; + } + if (m_current_linear_factor < 1.0) + m_current_linear_factor += 1.0/m_damping; + if (m_current_linear_factor > 1.0) + m_current_linear_factor = 1.0; + linV = m_current_linear_factor * m_linear_velocity; + parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); + } else { + parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); + } + } + } + if (!m_bitLocalFlag.ZeroAngularVelocity) + { m_active_combined_velocity = true; if (m_damping > 0) { - MT_Vector3 linV; - if (!m_linear_damping_active) { + MT_Vector3 angV; + if (!m_angular_damping_active) { // delta and the start speed (depends on the existing speed in that direction) - linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity); + angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity); // keep only the projection along the desired direction - m_current_linear_factor = linV.dot(m_linear_velocity)/m_linear_length2; - m_linear_damping_active = true; + m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2; + m_angular_damping_active = true; } - if (m_current_linear_factor < 1.0) - m_current_linear_factor += 1.0/m_damping; - if (m_current_linear_factor > 1.0) - m_current_linear_factor = 1.0; - linV = m_current_linear_factor * m_linear_velocity; - parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); + if (m_current_angular_factor < 1.0) + m_current_angular_factor += 1.0/m_damping; + if (m_current_angular_factor > 1.0) + m_current_angular_factor = 1.0; + angV = m_current_angular_factor * m_angular_velocity; + parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); } else { - parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); - } - } - } - if (!m_bitLocalFlag.ZeroAngularVelocity && !m_bitLocalFlag.ClampVelocity) - { - m_active_combined_velocity = true; - if (m_damping > 0) { - MT_Vector3 angV; - if (!m_angular_damping_active) { - // delta and the start speed (depends on the existing speed in that direction) - angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity); - // keep only the projection along the desired direction - m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2; - m_angular_damping_active = true; + parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0); } - if (m_current_angular_factor < 1.0) - m_current_angular_factor += 1.0/m_damping; - if (m_current_angular_factor > 1.0) - m_current_angular_factor = 1.0; - angV = m_current_angular_factor * m_angular_velocity; - parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); - } else { - parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0); } } @@ -263,8 +316,17 @@ PyMethodDef KX_ObjectActuator::Methods[] = { {"setLinearVelocity", (PyCFunction) KX_ObjectActuator::sPySetLinearVelocity, METH_VARARGS}, {"getAngularVelocity", (PyCFunction) KX_ObjectActuator::sPyGetAngularVelocity, METH_VARARGS}, {"setAngularVelocity", (PyCFunction) KX_ObjectActuator::sPySetAngularVelocity, METH_VARARGS}, - {"setVelocityDamping", (PyCFunction) KX_ObjectActuator::sPySetVelocityDamping, METH_VARARGS}, - {"getVelocityDamping", (PyCFunction) KX_ObjectActuator::sPyGetVelocityDamping, METH_VARARGS}, + {"setDamping", (PyCFunction) KX_ObjectActuator::sPySetDamping, METH_VARARGS}, + {"getDamping", (PyCFunction) KX_ObjectActuator::sPyGetDamping, METH_VARARGS}, + {"setForceLimitX", (PyCFunction) KX_ObjectActuator::sPySetForceLimitX, METH_VARARGS}, + {"getForceLimitX", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitX, METH_VARARGS}, + {"setForceLimitY", (PyCFunction) KX_ObjectActuator::sPySetForceLimitY, METH_VARARGS}, + {"getForceLimitY", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitY, METH_VARARGS}, + {"setForceLimitZ", (PyCFunction) KX_ObjectActuator::sPySetForceLimitZ, METH_VARARGS}, + {"getForceLimitZ", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitZ, METH_VARARGS}, + {"setPID", (PyCFunction) KX_ObjectActuator::sPyGetPID, METH_VARARGS}, + {"getPID", (PyCFunction) KX_ObjectActuator::sPySetPID, METH_VARARGS}, + {NULL,NULL} //Sentinel @@ -411,7 +473,6 @@ PyObject* KX_ObjectActuator::PyGetLinearVelocity(PyObject* self, PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1])); PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2])); PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.LinearVelocity)); - PyList_SetItem(retVal, 4, BoolToPyArg(m_bitLocalFlag.ClampVelocity)); return retVal; } @@ -422,14 +483,12 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* self, PyObject* kwds) { float vecArg[3]; int bToggle = 0; - int bClamp = 0; - if (!PyArg_ParseTuple(args, "fffi|i", &vecArg[0], &vecArg[1], - &vecArg[2], &bToggle, &bClamp)) { + if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle)) { return NULL; } m_linear_velocity.setValue(vecArg); m_bitLocalFlag.LinearVelocity = PyArgToBool(bToggle); - m_bitLocalFlag.ClampVelocity = PyArgToBool(bClamp); UpdateFuzzyFlags(); Py_Return; } @@ -445,7 +504,6 @@ PyObject* KX_ObjectActuator::PyGetAngularVelocity(PyObject* self, PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1])); PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2])); PyList_SetItem(retVal, 3, BoolToPyArg(m_bitLocalFlag.AngularVelocity)); - PyList_SetItem(retVal, 4, BoolToPyArg(m_bitLocalFlag.ClampVelocity)); return retVal; } @@ -455,22 +513,20 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* self, PyObject* kwds) { float vecArg[3]; int bToggle = 0; - int bClamp = 0; - if (!PyArg_ParseTuple(args, "fffi|i", &vecArg[0], &vecArg[1], - &vecArg[2], &bToggle, &bClamp)) { + if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], + &vecArg[2], &bToggle)) { return NULL; } m_angular_velocity.setValue(vecArg); m_bitLocalFlag.AngularVelocity = PyArgToBool(bToggle); - m_bitLocalFlag.ClampVelocity = PyArgToBool(bClamp); UpdateFuzzyFlags(); Py_Return; } -/* 13. setVelocityDamping */ -PyObject* KX_ObjectActuator::PySetVelocityDamping(PyObject* self, - PyObject* args, - PyObject* kwds) { +/* 13. setDamping */ +PyObject* KX_ObjectActuator::PySetDamping(PyObject* self, + PyObject* args, + PyObject* kwds) { int damping = 0; if (!PyArg_ParseTuple(args, "i", &damping) || damping < 0 || damping > 1000) { return NULL; @@ -480,11 +536,124 @@ PyObject* KX_ObjectActuator::PySetVelocityDamping(PyObject* self, } /* 13. getVelocityDamping */ -PyObject* KX_ObjectActuator::PyGetVelocityDamping(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_ObjectActuator::PyGetDamping(PyObject* self, + PyObject* args, + PyObject* kwds) { return Py_BuildValue("i",m_damping); } +/* 6. getForceLimitX */ +PyObject* KX_ObjectActuator::PyGetForceLimitX(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + PyObject *retVal = PyList_New(3); + + PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[0])); + PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[0])); + PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.Torque)); + + return retVal; +} +/* 7. setForceLimitX */ +PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + float vecArg[2]; + int bToggle = 0; + if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { + return NULL; + } + m_drot[0] = vecArg[0]; + m_dloc[0] = vecArg[1]; + m_bitLocalFlag.Torque = PyArgToBool(bToggle); + Py_Return; +} + +/* 6. getForceLimitY */ +PyObject* KX_ObjectActuator::PyGetForceLimitY(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + PyObject *retVal = PyList_New(3); + + PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[1])); + PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[1])); + PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.DLoc)); + + return retVal; +} +/* 7. setForceLimitY */ +PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + float vecArg[2]; + int bToggle = 0; + if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { + return NULL; + } + m_drot[1] = vecArg[0]; + m_dloc[1] = vecArg[1]; + m_bitLocalFlag.DLoc = PyArgToBool(bToggle); + Py_Return; +} + +/* 6. getForceLimitZ */ +PyObject* KX_ObjectActuator::PyGetForceLimitZ(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + PyObject *retVal = PyList_New(3); + + PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[2])); + PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[2])); + PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.DRot)); + + return retVal; +} +/* 7. setForceLimitZ */ +PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + float vecArg[2]; + int bToggle = 0; + if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { + return NULL; + } + m_drot[2] = vecArg[0]; + m_dloc[2] = vecArg[1]; + m_bitLocalFlag.DRot = PyArgToBool(bToggle); + Py_Return; +} + +/* 4. getPID */ +PyObject* KX_ObjectActuator::PyGetPID(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + PyObject *retVal = PyList_New(3); + + PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_torque[0])); + PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_torque[1])); + PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_torque[2])); + + return retVal; +} +/* 5. setPID */ +PyObject* KX_ObjectActuator::PySetPID(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + float vecArg[3]; + if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2])) { + return NULL; + } + m_torque.setValue(vecArg); + Py_Return; +} + diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index ec6dab5cd48..bb74756551f 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -47,7 +47,6 @@ struct KX_LocalFlags { LinearVelocity(false), AngularVelocity(false), AddOrSetLinV(false), - ClampVelocity(false), ZeroForce(false), ZeroDRot(false), ZeroDLoc(false), @@ -63,7 +62,7 @@ struct KX_LocalFlags { unsigned short LinearVelocity : 1; unsigned short AngularVelocity : 1; unsigned short AddOrSetLinV : 1; - unsigned short ClampVelocity : 1; + unsigned short ServoControl : 1; unsigned short ZeroForce : 1; unsigned short ZeroTorque : 1; unsigned short ZeroDRot : 1; @@ -84,9 +83,13 @@ class KX_ObjectActuator : public SCA_IActuator MT_Vector3 m_angular_velocity; MT_Scalar m_linear_length2; MT_Scalar m_angular_length2; + // used in damping MT_Scalar m_current_linear_factor; MT_Scalar m_current_angular_factor; short m_damping; + // used in servo control + MT_Vector3 m_previous_error; + MT_Vector3 m_error_accumulator; KX_LocalFlags m_bitLocalFlag; // A hack bool -- oh no sorry everyone @@ -164,8 +167,16 @@ public: KX_PYMETHOD(KX_ObjectActuator,SetLinearVelocity); KX_PYMETHOD(KX_ObjectActuator,GetAngularVelocity); KX_PYMETHOD(KX_ObjectActuator,SetAngularVelocity); - KX_PYMETHOD(KX_ObjectActuator,SetVelocityDamping); - KX_PYMETHOD(KX_ObjectActuator,GetVelocityDamping); + KX_PYMETHOD(KX_ObjectActuator,SetDamping); + KX_PYMETHOD(KX_ObjectActuator,GetDamping); + KX_PYMETHOD(KX_ObjectActuator,GetForceLimitX); + KX_PYMETHOD(KX_ObjectActuator,SetForceLimitX); + KX_PYMETHOD(KX_ObjectActuator,GetForceLimitY); + KX_PYMETHOD(KX_ObjectActuator,SetForceLimitY); + KX_PYMETHOD(KX_ObjectActuator,GetForceLimitZ); + KX_PYMETHOD(KX_ObjectActuator,SetForceLimitZ); + KX_PYMETHOD(KX_ObjectActuator,GetPID); + KX_PYMETHOD(KX_ObjectActuator,SetPID); }; #endif //__KX_OBJECTACTUATOR diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index e847c59bae1..a416c8c9f89 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -72,6 +72,7 @@ void KX_RaySensor::Init() m_bTriggered = (m_invert)?true:false; m_rayHit = false; m_hitObject = NULL; + m_reset = true; } KX_RaySensor::~KX_RaySensor() @@ -83,9 +84,10 @@ KX_RaySensor::~KX_RaySensor() CValue* KX_RaySensor::GetReplica() { - CValue* replica = new KX_RaySensor(*this); + KX_RaySensor* replica = new KX_RaySensor(*this); // this will copy properties and so on... CValue::AddDataToReplica(replica); + replica->Init(); return replica; } @@ -151,6 +153,7 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_ bool KX_RaySensor::Evaluate(CValue* event) { bool result = false; + bool reset = m_reset && m_level; m_rayHit = false; m_hitObject = NULL; m_hitPosition = MT_Vector3(0,0,0); @@ -162,6 +165,7 @@ bool KX_RaySensor::Evaluate(CValue* event) MT_Matrix3x3 invmat = matje.inverse(); MT_Vector3 todir; + m_reset = false; switch (m_axis) { case 1: // X @@ -263,7 +267,9 @@ bool KX_RaySensor::Evaluate(CValue* event) } } - + if (reset) + // force an event + result = true; return result; } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index a7e91e27df3..337b1af6df7 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -48,6 +48,7 @@ #include "SCA_KeyboardManager.h" #include "SCA_MouseManager.h" #include "SCA_PropertyEventManager.h" +#include "SCA_ActuatorEventManager.h" #include "KX_Camera.h" #include "SCA_JoystickManager.h" @@ -143,6 +144,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, SCA_AlwaysEventManager* alwaysmgr = new SCA_AlwaysEventManager(m_logicmgr); SCA_PropertyEventManager* propmgr = new SCA_PropertyEventManager(m_logicmgr); + SCA_ActuatorEventManager* actmgr = new SCA_ActuatorEventManager(m_logicmgr); SCA_RandomEventManager* rndmgr = new SCA_RandomEventManager(m_logicmgr); KX_RayEventManager* raymgr = new KX_RayEventManager(m_logicmgr); @@ -152,6 +154,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_logicmgr->RegisterEventManager(alwaysmgr); m_logicmgr->RegisterEventManager(propmgr); + m_logicmgr->RegisterEventManager(actmgr); m_logicmgr->RegisterEventManager(m_keyboardmgr); m_logicmgr->RegisterEventManager(m_mousemgr); m_logicmgr->RegisterEventManager(m_timemgr); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 5311f059f03..ce3aa1de2ef 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -61,7 +61,9 @@ void KX_TouchSensor::EndFrame() { bool KX_TouchSensor::Evaluate(CValue* event) { bool result = false; + bool reset = m_reset && m_level; + m_reset = false; if (m_bTriggered != m_bLastTriggered) { m_bLastTriggered = m_bTriggered; @@ -69,7 +71,9 @@ bool KX_TouchSensor::Evaluate(CValue* event) m_hitObject = NULL; result = true; } - + if (reset) + // force an event + result = true; return result; } @@ -103,6 +107,7 @@ void KX_TouchSensor::Init() m_bTriggered = false; m_bLastTriggered = (m_invert)?true:false; m_hitObject = NULL; + m_reset = true; } KX_TouchSensor::~KX_TouchSensor() @@ -115,10 +120,7 @@ CValue* KX_TouchSensor::GetReplica() { KX_TouchSensor* replica = new KX_TouchSensor(*this); replica->m_colliders = new CListValue(); - replica->m_bCollision = false; - replica->m_bTriggered= false; - replica->m_hitObject = NULL; - replica->m_bLastTriggered = false; + replica->Init(); // this will copy properties and so on... CValue::AddDataToReplica(replica); return replica; -- cgit v1.2.3 From 107b78a3d2b1a37f91b1e46511a3ea29f7f5cbbf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Jul 2008 19:00:56 +0000 Subject: Made some python game engine funcs use NOARGS, getAxisVec was using wrong multiplication order. Use BUT_TOGDUAL for controllers init states so you can see what the init state is for any controller without using the button to check. --- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 28 +++++++++++----------------- 2 files changed, 12 insertions(+), 18 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index d6d2254850a..507cedcd5d3 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1413,7 +1413,7 @@ PyObject* KX_GameObject::PyGetAxisVect(PyObject* self, PyObject* value) MT_Vector3 vect; if (PyVecTo(value, vect)) { - return PyObjectFrom(vect * NodeGetWorldOrientation()); + return PyObjectFrom(NodeGetWorldOrientation() * vect); } return NULL; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 47f5577552f..433e0636833 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -103,9 +103,7 @@ void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,cons static PyObject* ErrorObject; STR_String gPyGetRandomFloat_doc="getRandomFloat returns a random floating point value in the range [0..1)"; -static PyObject* gPyGetRandomFloat(PyObject*, - PyObject*, - PyObject*) +static PyObject* gPyGetRandomFloat(PyObject*) { return PyFloat_FromDouble(MT_random()); } @@ -156,9 +154,7 @@ static PyObject* gPyExpandPath(PyObject*, static bool usedsp = false; // this gets a pointer to an array filled with floats -static PyObject* gPyGetSpectrum(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyGetSpectrum(PyObject*) { SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); @@ -237,7 +233,7 @@ static PyObject* gPySetLogicTicRate(PyObject*, return NULL; } -static PyObject* gPyGetLogicTicRate(PyObject*, PyObject*, PyObject*) +static PyObject* gPyGetLogicTicRate(PyObject*) { return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate()); } @@ -273,7 +269,7 @@ static PyObject* gPySetPhysicsDebug(PyObject*, -static PyObject* gPyGetPhysicsTicRate(PyObject*, PyObject*, PyObject*) +static PyObject* gPyGetPhysicsTicRate(PyObject*) { return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep()); } @@ -281,9 +277,7 @@ static PyObject* gPyGetPhysicsTicRate(PyObject*, PyObject*, PyObject*) static STR_String gPyGetCurrentScene_doc = "getCurrentScene()\n" "Gets a reference to the current scene.\n"; -static PyObject* gPyGetCurrentScene(PyObject* self, - PyObject* args, - PyObject* kwds) +static PyObject* gPyGetCurrentScene(PyObject* self) { Py_INCREF(gp_KetsjiScene); return (PyObject*) gp_KetsjiScene; @@ -366,19 +360,19 @@ static struct PyMethodDef game_methods[] = { {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, gPyExpandPath_doc}, {"getCurrentController", (PyCFunction) SCA_PythonController::sPyGetCurrentController, - METH_VARARGS, SCA_PythonController::sPyGetCurrentController__doc__}, + METH_NOARGS, SCA_PythonController::sPyGetCurrentController__doc__}, {"getCurrentScene", (PyCFunction) gPyGetCurrentScene, - METH_VARARGS, gPyGetCurrentScene_doc.Ptr()}, + METH_NOARGS, gPyGetCurrentScene_doc.Ptr()}, {"addActiveActuator",(PyCFunction) SCA_PythonController::sPyAddActiveActuator, METH_VARARGS, SCA_PythonController::sPyAddActiveActuator__doc__}, {"getRandomFloat",(PyCFunction) gPyGetRandomFloat, - METH_VARARGS,gPyGetRandomFloat_doc.Ptr()}, + METH_NOARGS,gPyGetRandomFloat_doc.Ptr()}, {"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS,"set Gravitation"}, - {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_VARARGS,"get audio spectrum"}, + {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS,"get audio spectrum"}, {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS,"stop using the audio dsp (for performance reasons)"}, - {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_VARARGS, "Gets the logic tic rate"}, + {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, "Gets the logic tic rate"}, {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"}, - {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_VARARGS, "Gets the physics tic rate"}, + {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, "Gets the physics tic rate"}, {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, "Prints GL Extension Info"}, {NULL, (PyCFunction) NULL, 0, NULL } -- cgit v1.2.3 From 0bdfc6a953ef23be522523c4eec50b32716a6afd Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Fri, 4 Jul 2008 20:24:15 +0000 Subject: == BUGFIX == - fix crash when exiting game engine (with ESC-key). - reason for crash: std::vector iterator is invalid after vector::erase --- source/gameengine/GameLogic/SCA_IController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index bbe5a51db3c..8f156cc63e7 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -133,11 +133,11 @@ void SCA_IController::UnlinkActuator(class SCA_IActuator* actua) } if (!(actit==m_linkedactuators.end())) { - m_linkedactuators.erase(actit); if (IsActive()) { (*actit)->DecLink(); } + m_linkedactuators.erase(actit); } } @@ -163,11 +163,11 @@ void SCA_IController::UnlinkSensor(class SCA_ISensor* sensor) } if (!(sensit==m_linkedsensors.end())) { - m_linkedsensors.erase(sensit); if (IsActive()) { (*sensit)->DecLink(); } + m_linkedsensors.erase(sensit); } } -- cgit v1.2.3 From 8a729824f454bfee6c66db1db0411ecc5fd4ad38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 Jul 2008 14:11:30 +0000 Subject: GameObject rayCast and rayCastTo were not setting exception strings (causes return without exception set error) Also made game state buttons only have a dot in states that have controllers in them. --- source/gameengine/Ketsji/KX_GameObject.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 507cedcd5d3..bde5e2cd0a2 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1506,8 +1506,10 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, { KX_GameObject *other; PyErr_Clear(); - if (!PyType_IsSubtype(pyarg->ob_type, &KX_GameObject::Type)) + if (!PyType_IsSubtype(pyarg->ob_type, &KX_GameObject::Type)) { + PyErr_SetString(PyExc_TypeError, "the first argument to rayCastTo must be a vector or a KX_GameObject"); return NULL; + } other = static_cast(pyarg); toPoint = other->NodeGetWorldPosition(); } @@ -1567,8 +1569,10 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, if (!PyVecTo(pyto, toPoint)) { PyErr_Clear(); - if (!PyType_IsSubtype(pyto->ob_type, &KX_GameObject::Type)) + if (!PyType_IsSubtype(pyto->ob_type, &KX_GameObject::Type)) { + PyErr_SetString(PyExc_TypeError, "the first argument to rayCast must be a vector or a KX_GameObject"); return NULL; + } other = static_cast(pyto); toPoint = other->NodeGetWorldPosition(); } @@ -1579,8 +1583,10 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, else if (!PyVecTo(pyfrom, fromPoint)) { PyErr_Clear(); - if (!PyType_IsSubtype(pyfrom->ob_type, &KX_GameObject::Type)) + if (!PyType_IsSubtype(pyfrom->ob_type, &KX_GameObject::Type)) { + PyErr_SetString(PyExc_TypeError, "the second optional argument to rayCast must be a vector or a KX_GameObject"); return NULL; + } other = static_cast(pyfrom); fromPoint = other->NodeGetWorldPosition(); } -- cgit v1.2.3 From d1fd99b0700b6a779e4d01ddbffb4b946d02b382 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 8 Jul 2008 12:18:43 +0000 Subject: BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system. New Add mode for Ipo actuator ============================= A new Add button, mutually exclusive with Force button, is available in the Ipo actuator. When selected, it activates the Add mode that consists in adding the Ipo curve to the current object situation in world coordinates, or parent coordinates if the object has a parent. Scale Ipo curves are multiplied instead of added to the object current scale. If the local flag is selected, the Ipo curve is added (multiplied) in the object's local coordinates. Delta Ipo curves are handled identically to normal Ipo curve and there is no need to work with Delta Ipo curves provided that you make sure that the Ipo curve starts from origin. Origin means location 0 for Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for Scale Ipo curve. The "current object situation" means the object's location, rotation and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo actuators, this means at the start of each loop. This initial state is used as a base during the execution of the Ipo Curve but when the Ipo curve is restarted (later or immediately in case of Loop mode), the object current situation at that time is used as the new base. For reference, here is the exact operation of the Add mode for each type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale and orientation matrix at the start of the curve; iLoc, iRot, iScale, iMat: Ipo curve loc/rot/scale and orientation matrix resulting from the rotation). Location Local=false: newLoc = oLoc+iLoc Local=true : newLoc = oLoc+oScale*(oMat*iLoc) Rotation Local=false: newMat = iMat*oMat Local=true : newMat = oMat*iMat Scale Local=false: newScale = oScale*iScale Local=true : newScale = oScale*iScale Add+Local mode is very useful to have dynamic object executing complex movement relative to their current location/orientation. Of cource, dynamics should be disabled during the execution of the curve. Several corrections in state system =================================== - Object initial state is taken into account when adding object dynamically - Fix bug with link count when adding object dynamically - Fix false on-off detection for Actuator sensor when actuator is trigged on negative event. - Fix Parent actuator false activation on negative event - Loop Ipo curve not restarting at correct frame when start frame is different from one. --- .../Converter/BL_BlenderDataConversion.cpp | 3 +- .../gameengine/Converter/KX_ConvertActuators.cpp | 7 +- source/gameengine/GameLogic/SCA_ActuatorSensor.cpp | 2 +- source/gameengine/GameLogic/SCA_IActuator.h | 1 + source/gameengine/GameLogic/SCA_IObject.cpp | 8 +- source/gameengine/GameLogic/SCA_IObject.h | 15 ++ source/gameengine/GameLogic/SCA_ISensor.h | 2 + source/gameengine/Ketsji/KX_GameObject.cpp | 39 ++--- source/gameengine/Ketsji/KX_GameObject.h | 14 +- source/gameengine/Ketsji/KX_IPO_SGController.cpp | 87 ++++++++--- source/gameengine/Ketsji/KX_IPO_SGController.h | 7 +- source/gameengine/Ketsji/KX_IpoActuator.cpp | 171 ++++++++++----------- source/gameengine/Ketsji/KX_IpoActuator.h | 12 +- source/gameengine/Ketsji/KX_ParentActuator.cpp | 6 + source/gameengine/Ketsji/KX_Scene.cpp | 2 + source/gameengine/SceneGraph/SG_Controller.h | 4 +- 16 files changed, 225 insertions(+), 155 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 665783a1ba5..d8b157cb5b4 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2331,7 +2331,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); struct Object* blenderobj = converter->FindBlenderObject(gameobj); - gameobj->SetState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state); + gameobj->SetInitState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state); + gameobj->ResetState(); } #endif //CONVERT_LOGIC diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 6e05ea31fe8..9b1bc1e6b90 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -233,7 +233,8 @@ void BL_ConvertActuators(char* maggiename, STR_String propname = ( ipoact->name ? ipoact->name : ""); // first bit? bool ipo_as_force = (ipoact->flag & ACT_IPOFORCE); - bool force_local = (ipoact->flag & ACT_IPOFORCE_LOCAL); + bool local = (ipoact->flag & ACT_IPOLOCAL); + bool ipo_add = (ipoact->flag & ACT_IPOADD); KX_IpoActuator* tmpbaseact = new KX_IpoActuator( gameobj, @@ -244,8 +245,8 @@ void BL_ConvertActuators(char* maggiename, ipoact->type + 1, // + 1, because Blender starts to count at zero, // Ketsji at 1, because zero is reserved for "NoDef" ipo_as_force, - force_local - ); + ipo_add, + local); baseact = tmpbaseact; break; } diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index 9645bfbed4a..e1c8ef87dd1 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -111,7 +111,7 @@ void SCA_ActuatorSensor::Update() { if (m_actuator) { - m_midresult = m_actuator->IsActive(); + m_midresult = m_actuator->IsActive() && !m_actuator->IsNegativeEvent(); } } diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h index 774b27c5ad4..7ffb21b5490 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.h +++ b/source/gameengine/GameLogic/SCA_IActuator.h @@ -87,6 +87,7 @@ public: bool IsNegativeEvent() const; virtual ~SCA_IActuator(); + void ClrLink() { m_links=0; } void IncLink() { m_links++; } void DecLink(); bool IsNoLink() const { return !m_links; } diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 27e7d5faada..c5bb4a41552 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -40,7 +40,7 @@ MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0); -SCA_IObject::SCA_IObject(PyTypeObject* T): m_state(0), CValue(T) +SCA_IObject::SCA_IObject(PyTypeObject* T): m_initState(0), m_state(0), CValue(T) { m_suspended = false; } @@ -164,7 +164,9 @@ void SCA_IObject::ReParentLogic() { SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica(); newactuator->ReParent(this); + // actuators are initially not connected to any controller newactuator->SetActive(false); + newactuator->ClrLink(); oldactuators[act++] = newactuator; } @@ -175,6 +177,7 @@ void SCA_IObject::ReParentLogic() { SCA_IController* newcontroller = (SCA_IController*)(*itc)->GetReplica(); newcontroller->ReParent(this); + newcontroller->SetActive(false); oldcontrollers[con++]=newcontroller; } @@ -186,6 +189,9 @@ void SCA_IObject::ReParentLogic() { SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica(); newsensor->ReParent(this); + newsensor->SetActive(false); + // sensors are initially not connected to any controller + newsensor->ClrLink(); oldsensors[sen++] = newsensor; } diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h index 07b4310a91e..38a7ed29dca 100644 --- a/source/gameengine/GameLogic/SCA_IObject.h +++ b/source/gameengine/GameLogic/SCA_IObject.h @@ -68,6 +68,11 @@ protected: */ bool m_suspended; + /** + * init state of object (used when object is created) + */ + unsigned int m_initState; + /** * current state = bit mask of state that are active */ @@ -117,6 +122,16 @@ public: */ void Resume(void); + /** + * Set init state + */ + void SetInitState(unsigned int initState) { m_initState = initState; } + + /** + * initialize the state when object is created + */ + void ResetState(void) { SetState(m_initState); } + /** * Set the object state */ diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index f2ed6a803c2..4ce49e71507 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -126,6 +126,8 @@ public: /** Resume sensing. */ void Resume(); + void ClrLink() + { m_links = 0; } void IncLink() { m_links++; } void DecLink(); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index bde5e2cd0a2..88fbbb5fd1f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -405,34 +405,25 @@ void KX_GameObject::ResetDebugColor() SetDebugColor(0xff000000); } +void KX_GameObject::InitIPO(bool ipo_as_force, + bool ipo_add, + bool ipo_local) +{ + SGControllerList::iterator it = GetSGNode()->GetSGControllerList().begin(); + while (it != GetSGNode()->GetSGControllerList().end()) { + (*it)->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true); + (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, ipo_as_force); + (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, ipo_add); + (*it)->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, ipo_local); + it++; + } +} void KX_GameObject::UpdateIPO(float curframetime, - bool recurse, - bool ipo_as_force, - bool force_local) + bool recurse) { - - // The ipo-actuator needs a sumo reference... this is retrieved (unfortunately) - // by the iposgcontr itself... -// ipocontr->SetSumoReference(gameobj->GetSumoScene(), -// gameobj->GetSumoObject()); - - - // The ipo has to be treated as a force, and not a displacement! - // For this case, we send some settings to the controller. This - // may need some caching... - if (ipo_as_force) { - SGControllerList::iterator it = GetSGNode()->GetSGControllerList().begin(); - - while (it != GetSGNode()->GetSGControllerList().end()) { - (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, ipo_as_force); - (*it)->SetOption(SG_Controller::SG_CONTR_IPO_FORCES_ACT_LOCAL, force_local); - it++; - } - } - - // The rest is the 'normal' update procedure. + // just the 'normal' update procedure. GetSGNode()->SetSimulatedTime(curframetime,recurse); GetSGNode()->UpdateWorldData(curframetime); UpdateTransform(); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 5e44a36515d..b4f50087742 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -489,15 +489,23 @@ public: UpdateNonDynas( ); + /** + * Function to set IPO option at start of IPO + */ + void + InitIPO( + bool ipo_as_force, + bool ipo_add, + bool ipo_local + ); + /** * Odd function to update an ipo. ??? */ void UpdateIPO( float curframetime, - bool recurse, - bool ipo_as_force, - bool force_ipo_local + bool recurse ); /** * Updates Material Ipo data diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index 5303e9a9e85..d3aa924665e 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -55,7 +55,8 @@ typedef unsigned long uint_ptr; // start on another frame, the 1.0 should change. KX_IpoSGController::KX_IpoSGController() : m_ipo_as_force(false), - m_force_ipo_acts_local(false), + m_ipo_add(false), + m_ipo_local(false), m_modified(true), m_ipo_start_initialized(false), m_ipotime(1.0) @@ -75,8 +76,23 @@ void KX_IpoSGController::SetOption( m_ipo_as_force = (value != 0); m_modified = true; break; - case SG_CONTR_IPO_FORCES_ACT_LOCAL: - m_force_ipo_acts_local = (value != 0); + case SG_CONTR_IPO_IPO_ADD: + m_ipo_add = (value != 0); + m_modified = true; + break; + case SG_CONTR_IPO_RESET: + if (m_ipo_start_initialized && value) { + m_ipo_start_initialized = false; + m_modified = true; + } + break; + case SG_CONTR_IPO_LOCAL: + if (value/* && ((SG_Node*)m_pObject)->GetSGParent() == NULL*/) { + // only accept local Ipo if the object has no parent + m_ipo_local = true; + } else { + m_ipo_local = false; + } m_modified = true; break; default: @@ -129,15 +145,19 @@ bool KX_IpoSGController::Update(double currentTime) { if (m_game_object && ob) { - m_game_object->GetPhysicsController()->ApplyForce(m_force_ipo_acts_local ? + m_game_object->GetPhysicsController()->ApplyForce(m_ipo_local ? ob->GetWorldOrientation() * m_ipo_xform.GetPosition() : m_ipo_xform.GetPosition(), false); } } else { - //by default, leave object as it stands - MT_Point3 newPosition = ob->GetLocalPosition(); + // Local ipo should be defined with the object position at (0,0,0) + // Local transform is applied to the object based on initial position + MT_Point3 newPosition(0.0,0.0,0.0); + + if (!m_ipo_add) + newPosition = ob->GetLocalPosition(); //apply separate IPO channels if there is any data in them //Loc and dLoc act by themselves or are additive //LocX and dLocX @@ -145,23 +165,28 @@ bool KX_IpoSGController::Update(double currentTime) newPosition[0] = (m_ipo_channels_active[OB_DLOC_X] ? m_ipo_xform.GetPosition()[0] + m_ipo_xform.GetDeltaPosition()[0] : m_ipo_xform.GetPosition()[0]); } else if (m_ipo_channels_active[OB_DLOC_X] && m_ipo_start_initialized) { - newPosition[0] = (m_ipo_start_point[0] + m_ipo_xform.GetDeltaPosition()[0]); + newPosition[0] = (((!m_ipo_add)?m_ipo_start_point[0]:0.0) + m_ipo_xform.GetDeltaPosition()[0]); } //LocY and dLocY if (m_ipo_channels_active[OB_LOC_Y]) { newPosition[1] = (m_ipo_channels_active[OB_DLOC_Y] ? m_ipo_xform.GetPosition()[1] + m_ipo_xform.GetDeltaPosition()[1] : m_ipo_xform.GetPosition()[1]); } else if (m_ipo_channels_active[OB_DLOC_Y] && m_ipo_start_initialized) { - newPosition[1] = (m_ipo_start_point[1] + m_ipo_xform.GetDeltaPosition()[1]); + newPosition[1] = (((!m_ipo_add)?m_ipo_start_point[1]:0.0) + m_ipo_xform.GetDeltaPosition()[1]); } //LocZ and dLocZ if (m_ipo_channels_active[OB_LOC_Z]) { newPosition[2] = (m_ipo_channels_active[OB_DLOC_Z] ? m_ipo_xform.GetPosition()[2] + m_ipo_xform.GetDeltaPosition()[2] : m_ipo_xform.GetPosition()[2]); } else if (m_ipo_channels_active[OB_DLOC_Z] && m_ipo_start_initialized) { - newPosition[2] = (m_ipo_start_point[2] + m_ipo_xform.GetDeltaPosition()[2]); + newPosition[2] = (((!m_ipo_add)?m_ipo_start_point[2]:0.0) + m_ipo_xform.GetDeltaPosition()[2]); + } + if (m_ipo_add) { + if (m_ipo_local) + newPosition = m_ipo_start_point + m_ipo_start_scale*(m_ipo_start_orient*newPosition); + else + newPosition = m_ipo_start_point + newPosition; } - ob->SetLocalPosition(newPosition); } } @@ -170,21 +195,23 @@ bool KX_IpoSGController::Update(double currentTime) if (m_ipo_as_force) { if (m_game_object && ob) { - m_game_object->ApplyTorque(m_force_ipo_acts_local ? + m_game_object->ApplyTorque(m_ipo_local ? ob->GetWorldOrientation() * m_ipo_xform.GetEulerAngles() : m_ipo_xform.GetEulerAngles(), false); } } else { - double yaw, pitch, roll; //final Euler angles + double yaw=0, pitch=0, roll=0; //final Euler angles double tempYaw=0, tempPitch=0, tempRoll=0; //temp holders - ob->GetLocalOrientation().getEuler(yaw, pitch, roll); + if (!m_ipo_add) + ob->GetLocalOrientation().getEuler(yaw, pitch, roll); //RotX and dRotX if (m_ipo_channels_active[OB_ROT_X]) { yaw = (m_ipo_channels_active[OB_DROT_X] ? (m_ipo_xform.GetEulerAngles()[0] + m_ipo_xform.GetDeltaEulerAngles()[0]) : m_ipo_xform.GetEulerAngles()[0] ); } else if (m_ipo_channels_active[OB_DROT_X] && m_ipo_start_initialized) { - m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); + if (!m_ipo_add) + m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); yaw = tempYaw + m_ipo_xform.GetDeltaEulerAngles()[0]; } @@ -193,7 +220,8 @@ bool KX_IpoSGController::Update(double currentTime) pitch = (m_ipo_channels_active[OB_DROT_Y] ? (m_ipo_xform.GetEulerAngles()[1] + m_ipo_xform.GetDeltaEulerAngles()[1]) : m_ipo_xform.GetEulerAngles()[1] ); } else if (m_ipo_channels_active[OB_DROT_Y] && m_ipo_start_initialized) { - m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); + if (!m_ipo_add) + m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); pitch = tempPitch + m_ipo_xform.GetDeltaEulerAngles()[1]; } @@ -202,23 +230,34 @@ bool KX_IpoSGController::Update(double currentTime) roll = (m_ipo_channels_active[OB_DROT_Z] ? (m_ipo_xform.GetEulerAngles()[2] + m_ipo_xform.GetDeltaEulerAngles()[2]) : m_ipo_xform.GetEulerAngles()[2] ); } else if (m_ipo_channels_active[OB_DROT_Z] && m_ipo_start_initialized) { - m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); + if (!m_ipo_add) + m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); roll = tempRoll + m_ipo_xform.GetDeltaEulerAngles()[2]; } - - ob->SetLocalOrientation(MT_Vector3(yaw, pitch, roll)); + if (m_ipo_add) { + MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll)); + if (m_ipo_local) + rotation = m_ipo_start_orient * rotation; + else + rotation = rotation * m_ipo_start_orient; + ob->SetLocalOrientation(rotation); + } else { + ob->SetLocalOrientation(MT_Vector3(yaw, pitch, roll)); + } } } //modifies scale? if (m_ipo_channels_active[OB_SIZE_X] || m_ipo_channels_active[OB_SIZE_Y] || m_ipo_channels_active[OB_SIZE_Z] || m_ipo_channels_active[OB_DSIZE_X] || m_ipo_channels_active[OB_DSIZE_Y] || m_ipo_channels_active[OB_DSIZE_Z]) { //default is no scale change - MT_Vector3 newScale = ob->GetLocalScale(); + MT_Vector3 newScale(1.0,1.0,1.0); + if (!m_ipo_add) + newScale = ob->GetLocalScale(); if (m_ipo_channels_active[OB_SIZE_X]) { newScale[0] = (m_ipo_channels_active[OB_DSIZE_X] ? (m_ipo_xform.GetScaling()[0] + m_ipo_xform.GetDeltaScaling()[0]) : m_ipo_xform.GetScaling()[0]); } else if (m_ipo_channels_active[OB_DSIZE_X] && m_ipo_start_initialized) { - newScale[0] = (m_ipo_xform.GetDeltaScaling()[0] + m_ipo_start_scale[0]); + newScale[0] = (m_ipo_xform.GetDeltaScaling()[0] + ((!m_ipo_add)?m_ipo_start_scale[0]:0.0)); } //RotY dRotY @@ -226,7 +265,7 @@ bool KX_IpoSGController::Update(double currentTime) newScale[1] = (m_ipo_channels_active[OB_DSIZE_Y] ? (m_ipo_xform.GetScaling()[1] + m_ipo_xform.GetDeltaScaling()[1]): m_ipo_xform.GetScaling()[1]); } else if (m_ipo_channels_active[OB_DSIZE_Y] && m_ipo_start_initialized) { - newScale[1] = (m_ipo_xform.GetDeltaScaling()[1] + m_ipo_start_scale[1]); + newScale[1] = (m_ipo_xform.GetDeltaScaling()[1] + ((!m_ipo_add)?m_ipo_start_scale[1]:0.0)); } //RotZ and dRotZ @@ -234,7 +273,11 @@ bool KX_IpoSGController::Update(double currentTime) newScale[2] = (m_ipo_channels_active[OB_DSIZE_Z] ? (m_ipo_xform.GetScaling()[2] + m_ipo_xform.GetDeltaScaling()[2]) : m_ipo_xform.GetScaling()[2]); } else if (m_ipo_channels_active[OB_DSIZE_Z] && m_ipo_start_initialized) { - newScale[2] = (m_ipo_xform.GetDeltaScaling()[2] + m_ipo_start_scale[2]); + newScale[2] = (m_ipo_xform.GetDeltaScaling()[2] + ((!m_ipo_add)?m_ipo_start_scale[2]:1.0)); + } + + if (m_ipo_add) { + newScale = m_ipo_start_scale * newScale; } ob->SetLocalScale(newScale); diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h index 7b5a151b41c..0bd8980f11c 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.h +++ b/source/gameengine/Ketsji/KX_IPO_SGController.h @@ -48,8 +48,11 @@ class KX_IpoSGController : public SG_Controller /** Interpret the ipo as a force rather than a displacement? */ bool m_ipo_as_force; - /** Ipo-as-force acts in local rather than in global coordinates? */ - bool m_force_ipo_acts_local; + /** Add Ipo curve to current loc/rot/scale */ + bool m_ipo_add; + + /** Ipo must be applied in local coordinate rather than in global coordinates (used for force and Add mode)*/ + bool m_ipo_local; /** Were settings altered since the last update? */ bool m_modified; diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index cf246342cf9..b7103f49aee 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -59,40 +59,6 @@ STR_String KX_IpoActuator::S_KX_ACT_IPO_FROM_PROP_STRING = "FromProp"; /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ -/** Another poltergeist? This seems to be a very transient class... */ -class CIpoAction : public CAction -{ - float m_curtime; - bool m_recurse; - KX_GameObject* m_gameobj; - bool m_ipo_as_force; - bool m_force_ipo_local; - -public: - CIpoAction(KX_GameObject* gameobj, - float curtime, - bool recurse, - bool ipo_as_force, - bool force_ipo_local) : - m_curtime(curtime) , - m_recurse(recurse), - m_gameobj(gameobj), - m_ipo_as_force(ipo_as_force), - m_force_ipo_local(force_ipo_local) - { - /* intentionally empty */ - }; - - virtual void Execute() const - { - m_gameobj->UpdateIPO( - m_curtime, - m_recurse, - m_ipo_as_force, - m_force_ipo_local); - }; - -}; KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj, const STR_String& propname, @@ -101,7 +67,8 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj, bool recurse, int acttype, bool ipo_as_force, - bool force_ipo_local, + bool ipo_add, + bool ipo_local, PyTypeObject* T) : SCA_IActuator(gameobj,T), m_bNegativeEvent(false), @@ -112,7 +79,8 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj, m_direction(1), m_propname(propname), m_ipo_as_force(ipo_as_force), - m_force_ipo_local(force_ipo_local), + m_ipo_add(ipo_add), + m_ipo_local(ipo_local), m_type((IpoActType)acttype) { m_starttime = -2.0*fabs(m_endframe - m_startframe) - 1.0; @@ -160,7 +128,7 @@ bool KX_IpoActuator::ClampLocalTime() void KX_IpoActuator::SetStartTime(float curtime) { - float direction = m_startframe < m_endframe ? 1.0 : -1.0; + float direction = m_startframe < m_endframe ? 1.0f : -1.0f; curtime = curtime - KX_KetsjiEngine::GetSuspendedDelta(); if (m_direction > 0) @@ -195,31 +163,26 @@ bool KX_IpoActuator::Update(double curtime, bool frame) // maybe there are events for us in the queue ! bool bNegativeEvent = false; int numevents = 0; + bool bIpoStart = false; if (frame) { numevents = m_events.size(); - for (vector::iterator i=m_events.end(); !(i==m_events.begin());) - { - --i; - if ((*i)->GetNumber() == 0.0f) - bNegativeEvent = true; - - (*i)->Release(); - } - m_events.clear(); + bNegativeEvent = IsNegativeEvent(); + RemoveAllEvents(); } - double start_smaller_then_end = ( m_startframe < m_endframe ? 1.0 : -1.0); + float start_smaller_then_end = ( m_startframe < m_endframe ? 1.0f : -1.0f); bool result=true; if (!bNegativeEvent) { - if (m_starttime < -2.0*start_smaller_then_end*(m_endframe - m_startframe)) + if (m_starttime < -2.0f*start_smaller_then_end*(m_endframe - m_startframe)) { // start for all Ipo, initial start for LOOP_STOP m_starttime = curtime - KX_KetsjiEngine::GetSuspendedDelta(); m_bIpoPlaying = true; + bIpoStart = true; } } @@ -230,7 +193,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) { // Check if playing forwards. result = ! finished - if (start_smaller_then_end > 0.0) + if (start_smaller_then_end > 0.f) result = (m_localtime < m_endframe && m_bIpoPlaying); else result = (m_localtime > m_endframe && m_bIpoPlaying); @@ -241,14 +204,10 @@ bool KX_IpoActuator::Update(double curtime, bool frame) /* Perform clamping */ ClampLocalTime(); - - CIpoAction ipoaction( - (KX_GameObject*)GetParent(), - m_localtime, - m_recurse, - m_ipo_as_force, - m_force_ipo_local); - GetParent()->Execute(ipoaction); + + if (bIpoStart) + ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local); + ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse); } else { m_localtime=m_startframe; @@ -270,13 +229,9 @@ bool KX_IpoActuator::Update(double curtime, bool frame) m_direction = -m_direction; } - CIpoAction ipoaction( - (KX_GameObject*) GetParent(), - m_localtime, - m_recurse, - m_ipo_as_force, - m_force_ipo_local); - GetParent()->Execute(ipoaction); + if (bIpoStart && m_direction > 0) + ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local); + ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse); break; } case KX_ACT_IPO_FLIPPER: @@ -299,14 +254,10 @@ bool KX_IpoActuator::Update(double curtime, bool frame) if (ClampLocalTime() && m_localtime == m_startframe) result = false; - - CIpoAction ipoaction( - (KX_GameObject*) GetParent(), - m_localtime, - m_recurse, - m_ipo_as_force, - m_force_ipo_local); - GetParent()->Execute(ipoaction); + + if (bIpoStart) + ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local); + ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse); break; } @@ -352,8 +303,12 @@ bool KX_IpoActuator::Update(double curtime, bool frame) if (!m_bNegativeEvent){ /* Perform wraparound */ SetLocalTime(curtime); - m_localtime = m_startframe + fmod(m_localtime, m_startframe - m_endframe); + if (start_smaller_then_end > 0.f) + m_localtime = m_startframe + fmod(m_localtime - m_startframe, m_endframe - m_startframe); + else + m_localtime = m_startframe - fmod(m_startframe - m_localtime, m_startframe - m_endframe); SetStartTime(curtime); + bIpoStart = true; } else { @@ -365,13 +320,9 @@ bool KX_IpoActuator::Update(double curtime, bool frame) } } - CIpoAction ipoaction( - (KX_GameObject*) GetParent(), - m_localtime, - m_recurse, - m_ipo_as_force, - m_force_ipo_local); - GetParent()->Execute(ipoaction); + if (m_bIpoPlaying && bIpoStart) + ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local); + ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse); break; } @@ -391,14 +342,9 @@ bool KX_IpoActuator::Update(double curtime, bool frame) { m_localtime = propval->GetNumber(); - CIpoAction ipoaction( - (KX_GameObject*) GetParent(), - m_localtime, - m_recurse, - m_ipo_as_force, - m_force_ipo_local); - GetParent()->Execute(ipoaction); - + if (bIpoStart) + ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local); + ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse); } else { result = false; @@ -493,6 +439,10 @@ PyMethodDef KX_IpoActuator::Methods[] = { METH_VARARGS, SetIpoAsForce_doc}, {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, METH_VARARGS, GetIpoAsForce_doc}, + {"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, + METH_VARARGS, SetIpoAdd_doc}, + {"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, + METH_VARARGS, GetIpoAdd_doc}, {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, SetType_doc}, {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, @@ -512,11 +462,11 @@ PyObject* KX_IpoActuator::_getattr(const STR_String& attr) { /* set --------------------------------------------------------------------- */ char KX_IpoActuator::Set_doc[] = -"set(mode, startframe, endframe, force?)\n" -"\t - mode: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n" +"set(type, startframe, endframe, mode?)\n" +"\t - type: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n" "\t - startframe: first frame to use (int)\n" "\t - endframe : last frame to use (int)\n" -"\t - force? : interpret this ipo as a force? (KX_TRUE, KX_FALSE)" +"\t - mode? : special mode (0=normal, 1=interpret location as force, 2=additive)" "\tSet the properties of the actuator.\n"; PyObject* KX_IpoActuator::PySet(PyObject* self, PyObject* args, @@ -543,7 +493,8 @@ PyObject* KX_IpoActuator::PySet(PyObject* self, m_type = modenum; m_startframe = startFrame; m_endframe = stopFrame; - m_ipo_as_force = PyArgToBool(forceToggle); + m_ipo_as_force = forceToggle == 1; + m_ipo_add = forceToggle == 2; break; default: ; /* error */ @@ -641,6 +592,8 @@ PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self, } m_ipo_as_force = PyArgToBool(boolArg); + if (m_ipo_as_force) + m_ipo_add = false; Py_Return; } @@ -654,6 +607,36 @@ PyObject* KX_IpoActuator::PyGetIpoAsForce(PyObject* self, return BoolToPyArg(m_ipo_as_force); } +/* 6. setIpoAsForce: */ +char KX_IpoActuator::SetIpoAdd_doc[] = +"setIpoAdd(add?)\n" +"\t - add? : add flag (KX_TRUE, KX_FALSE)\n" +"\tSet whether to interpret the ipo as additive rather than absolute.\n"; +PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self, + PyObject* args, + PyObject* kwds) { + int boolArg; + + if (!PyArg_ParseTuple(args, "i", &boolArg)) { + return NULL; + } + + m_ipo_add = PyArgToBool(boolArg); + if (m_ipo_add) + m_ipo_as_force = false; + + Py_Return; +} +/* 7. getIpoAsForce: */ +char KX_IpoActuator::GetIpoAdd_doc[] = +"getIpoAsAdd()\n" +"\tReturns whether to interpret the ipo as additive rather than absolute.\n"; +PyObject* KX_IpoActuator::PyGetIpoAdd(PyObject* self, + PyObject* args, + PyObject* kwds) { + return BoolToPyArg(m_ipo_add); +} + /* 8. setType: */ char KX_IpoActuator::SetType_doc[] = "setType(mode)\n" @@ -701,7 +684,7 @@ PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* self, return NULL; } - m_force_ipo_local = PyArgToBool(boolArg); + m_ipo_local = PyArgToBool(boolArg); Py_Return; } @@ -713,7 +696,7 @@ char KX_IpoActuator::GetForceIpoActsLocal_doc[] = PyObject* KX_IpoActuator::PyGetForceIpoActsLocal(PyObject* self, PyObject* args, PyObject* kwds) { - return BoolToPyArg(m_force_ipo_local); + return BoolToPyArg(m_ipo_local); } diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index 79e8daa3f87..ae554fb0fce 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -75,8 +75,11 @@ protected: /** Interpret the ipo as a force? */ bool m_ipo_as_force; - /** Apply a force-ipo locally? */ - bool m_force_ipo_local; + /** Add Ipo curve to current loc/rot/scale */ + bool m_ipo_add; + + /** The Ipo curve is applied in local coordinates */ + bool m_ipo_local; bool m_bIpoPlaying; @@ -113,7 +116,8 @@ public: bool recurse, int acttype, bool ipo_as_force, - bool force_ipo_local, + bool ipo_add, + bool ipo_local, PyTypeObject* T=&Type); virtual ~KX_IpoActuator() {}; @@ -144,6 +148,8 @@ public: KX_PYMETHOD_DOC(KX_IpoActuator,GetEnd); KX_PYMETHOD_DOC(KX_IpoActuator,SetIpoAsForce); KX_PYMETHOD_DOC(KX_IpoActuator,GetIpoAsForce); + KX_PYMETHOD_DOC(KX_IpoActuator,SetIpoAdd); + KX_PYMETHOD_DOC(KX_IpoActuator,GetIpoAdd); KX_PYMETHOD_DOC(KX_IpoActuator,SetType); KX_PYMETHOD_DOC(KX_IpoActuator,GetType); KX_PYMETHOD_DOC(KX_IpoActuator,SetForceIpoActsLocal); diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 5c433cb68b1..8b379bcd44f 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -77,6 +77,12 @@ CValue* KX_ParentActuator::GetReplica() bool KX_ParentActuator::Update() { + bool bNegativeEvent = IsNegativeEvent(); + RemoveAllEvents(); + + if (bNegativeEvent) + return false; // do nothing on negative events + KX_GameObject *obj = (KX_GameObject*) GetParent(); KX_Scene *scene = PHY_GetActiveScene(); switch (m_mode) { diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 337b1af6df7..c5f6230b2f2 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -601,6 +601,8 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) } } } + // ready to set initial state + newobj->ResetState(); } diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h index d65a2f0c256..c32885b915f 100644 --- a/source/gameengine/SceneGraph/SG_Controller.h +++ b/source/gameengine/SceneGraph/SG_Controller.h @@ -101,7 +101,9 @@ public: enum SG_Controller_option { SG_CONTR_NODEF = 0, SG_CONTR_IPO_IPO_AS_FORCE, - SG_CONTR_IPO_FORCES_ACT_LOCAL, + SG_CONTR_IPO_IPO_ADD, + SG_CONTR_IPO_LOCAL, + SG_CONTR_IPO_RESET, SG_CONTR_CAMIPO_LENS, SG_CONTR_CAMIPO_CLIPEND, SG_CONTR_CAMIPO_CLIPSTART, -- cgit v1.2.3 From bbf1ce2762651f0d3f3a9c302c3575c68ca21ca7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Jul 2008 17:57:31 +0000 Subject: bugfix - GameEngine PyObject methods did not all return when using dir(), because inherited methods were ignored, This made it incredibly annoying, not only having to search a C++ file to see what functions were available. but looking up methods inherited from other C++ classes. There is still no __members__ attribute so dir() wont work at all for attributes. --- source/gameengine/Expressions/PyObjectPlus.h | 30 ++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 04cc119efee..2bcb604dd23 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -76,18 +76,36 @@ static inline void Py_Fatal(char *M) { virtual PyTypeObject *GetType(void) {return &Type;}; \ virtual PyParentObject *GetParents(void) {return Parents;} + // This defines the _getattr_up macro // which allows attribute and method calls // to be properly passed up the hierarchy. #define _getattr_up(Parent) \ - PyObject *rvalue = Py_FindMethod(Methods, this, const_cast(attr.ReadPtr())); \ - if (rvalue == NULL) \ - { \ + PyObject *rvalue = NULL; \ + if (attr=="__methods__") { \ + PyObject *_attr_string = NULL; \ + PyMethodDef *meth = Methods; \ + rvalue = Parent::_getattr(attr); \ + if (rvalue==NULL) { \ + PyErr_Clear(); \ + rvalue = PyList_New(0); \ + } \ + if (meth) { \ + for (; meth->ml_name != NULL; meth++) { \ + _attr_string = PyString_FromString(meth->ml_name); \ + PyList_Append(rvalue, _attr_string); \ + Py_DECREF(_attr_string); \ + } \ + } \ + } else { \ + rvalue = Py_FindMethod(Methods, this, const_cast(attr.ReadPtr())); \ + if (rvalue == NULL) { \ PyErr_Clear(); \ - return Parent::_getattr(attr); \ + rvalue = Parent::_getattr(attr); \ } \ - else \ - return rvalue + } \ + return rvalue; \ + /** * These macros are helpfull when embedding Python routines. The second -- cgit v1.2.3 From e279fc4a8181a7e8083c80c29e1c1bb6dfba7473 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Jul 2008 22:43:44 +0000 Subject: fix for crasher with touch sensor, ben you may want to look at this, should be ok since the ray sensor does NULL checks in for getNewClientInfo in a similar area. --- source/gameengine/Ketsji/KX_TouchEventManager.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index 80ee15a9475..423543eef5c 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -137,14 +137,18 @@ void KX_TouchEventManager::NextFrame() // KX_GameObject* gameOb1 = ctrl1->getClientInfo(); KX_ClientObjectInfo *client_info = static_cast(ctrl1->getNewClientInfo()); - list::iterator sit; - for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) - static_cast(*sit)->NewHandleCollision((*cit).first, (*cit).second, NULL); - + if (client_info) { + for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) { + static_cast(*sit)->NewHandleCollision((*cit).first, (*cit).second, NULL); + } + } client_info = static_cast((*cit).second->getNewClientInfo()); - for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) - static_cast(*sit)->NewHandleCollision((*cit).second, (*cit).first, NULL); + if (client_info) { + for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) { + static_cast(*sit)->NewHandleCollision((*cit).second, (*cit).first, NULL); + } + } } m_newCollisions.clear(); -- cgit v1.2.3 From 60d099648c05ac469e3499e9755477c5180b9721 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Jul 2008 09:21:52 +0000 Subject: added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes. (can be improved to rotate correctly but for our use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed), This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch. Without this rotation is instant and jerky. currently this is done with Mathutils which isnt available in Blender Player. def do_rotate_up(own): own.alignAxisToVect([0,0,1], 2, 0.1) replaces... def do_rotate_up(own): up_nor = Vector(0,0,1) own_mat = Matrix(*own.getOrientation()).transpose() own_up = up_nor * own_mat ang = AngleBetweenVecs(own_up, up_nor) if ang > 0.005: # Set orientation cross = CrossVecs(own_up, up_nor) new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross) own.setOrientation(new_mat.transpose()) M source/gameengine/Ketsji/KX_GameObject.cpp M source/gameengine/Ketsji/KX_GameObject.h --- source/gameengine/Ketsji/KX_GameObject.cpp | 39 +++++++++++++++++++++++++----- source/gameengine/Ketsji/KX_GameObject.h | 3 ++- 2 files changed, 35 insertions(+), 7 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 88fbbb5fd1f..e29ca72500a 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -572,7 +572,7 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec) m_objectColor = rgbavec; } -void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis) +void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) { MT_Matrix3x3 orimat; MT_Vector3 vect,ori,z,x,y; @@ -585,6 +585,11 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis) cout << "alignAxisToVect() Error: Null vector!\n"; return; } + + if (fac<=0.0) { + return; + } + // normalize vect /= len; orimat = GetSGNode()->GetWorldOrientation(); @@ -594,7 +599,14 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis) ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector paralell to the pivot? ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot! - x = vect; + if (fac == 1.0) { + x = vect; + } else { + x = (vect * fac) + ((orimat * MT_Vector3(1.0, 0.0, 0.0)) * (1-fac)); + len = x.length(); + if (MT_fuzzyZero(len)) x = vect; + else x /= len; + } y = ori.cross(x); z = x.cross(y); break; @@ -602,7 +614,14 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis) ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]); if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]); - y = vect; + if (fac == 1.0) { + y = vect; + } else { + y = (vect * fac) + ((orimat * MT_Vector3(0.0, 1.0, 0.0)) * (1-fac)); + len = y.length(); + if (MT_fuzzyZero(len)) y = vect; + else y /= len; + } z = ori.cross(y); x = y.cross(z); break; @@ -610,7 +629,14 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis) ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]); if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]); - z = vect; + if (fac == 1.0) { + z = vect; + } else { + z = (vect * fac) + ((orimat * MT_Vector3(0.0, 0.0, 1.0)) * (1-fac)); + len = z.length(); + if (MT_fuzzyZero(len)) z = vect; + else z /= len; + } x = ori.cross(z); y = z.cross(x); break; @@ -1386,13 +1412,14 @@ PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, { PyObject* pyvect; int axis = 2; //z axis is the default + float fac = 1.0; - if (PyArg_ParseTuple(args,"O|i",&pyvect,&axis)) + if (PyArg_ParseTuple(args,"O|if",&pyvect,&axis, &fac)) { MT_Vector3 vect; if (PyVecTo(pyvect, vect)) { - AlignAxisToVect(vect,axis); + AlignAxisToVect(vect,axis,fac); Py_RETURN_NONE; } } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index b4f50087742..ddbf863aa1a 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -278,7 +278,8 @@ public: void AlignAxisToVect( const MT_Vector3& vect, - int axis = 2 + int axis = 2, + float fac = 1.0 ); /** -- cgit v1.2.3 From 732d886e0a8853ad8029e3e68cc826b69a28cf87 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Jul 2008 15:30:15 +0000 Subject: bugfix, vector was not checked for zero length before normalizing, closing blender instantly with an assert. --- source/gameengine/Ketsji/KX_GameObject.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index e29ca72500a..db13d30e2f1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1608,14 +1608,18 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, other = static_cast(pyfrom); fromPoint = other->NodeGetWorldPosition(); } - - if (dist != 0.0f) - { + + if (dist != 0.0f) { MT_Vector3 toDir = toPoint-fromPoint; + if (MT_fuzzyZero(toDir.length2())) { + return Py_BuildValue("OOO", Py_None, Py_None, Py_None); + } toDir.normalize(); toPoint = fromPoint + (dist) * toDir; + } else if (MT_fuzzyZero((toPoint-fromPoint).length2())) { + return Py_BuildValue("OOO", Py_None, Py_None, Py_None); } - + MT_Point3 resultPoint; MT_Vector3 resultNormal; PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); -- cgit v1.2.3 From 99fdf27af92b9bd9d05c108f2c2c8a240c5536bc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 10 Jul 2008 12:47:20 +0000 Subject: Sync with Apricot Game Engine ============================= * Clean up and optimizations in skinned/deformed mesh code. * Compatibility fixes and clean up in the rasterizer. * Changes related to GLSL shadow buffers which should have no effect, to keep the code in sync with apricot. --- source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 2 +- .../Converter/BL_BlenderDataConversion.cpp | 118 +++++++------- source/gameengine/Converter/BL_MeshDeformer.cpp | 174 +++++++++++---------- source/gameengine/Converter/BL_MeshDeformer.h | 14 +- source/gameengine/Converter/BL_ShapeDeformer.h | 11 +- source/gameengine/Converter/BL_SkinDeformer.cpp | 61 ++++---- source/gameengine/Converter/BL_SkinDeformer.h | 6 +- source/gameengine/Converter/BL_SkinMeshObject.cpp | 84 ---------- source/gameengine/Converter/BL_SkinMeshObject.h | 94 ----------- source/gameengine/Ketsji/BL_BlenderShader.cpp | 80 ++++++---- source/gameengine/Ketsji/BL_BlenderShader.h | 15 +- source/gameengine/Ketsji/BL_Material.cpp | 6 +- source/gameengine/Ketsji/BL_Material.h | 7 +- source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 100 ++++++++---- source/gameengine/Ketsji/KX_BlenderMaterial.h | 2 + source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 46 +++++- source/gameengine/Ketsji/KX_KetsjiEngine.h | 1 + source/gameengine/Ketsji/KX_Light.cpp | 80 +++++++++- source/gameengine/Ketsji/KX_Light.h | 16 +- source/gameengine/Ketsji/KX_Scene.cpp | 41 +++-- source/gameengine/Ketsji/KX_Scene.h | 8 +- source/gameengine/Rasterizer/RAS_BucketManager.cpp | 2 +- .../gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 16 ++ .../gameengine/Rasterizer/RAS_IPolygonMaterial.h | 2 + source/gameengine/Rasterizer/RAS_IRasterizer.h | 59 ++++--- .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 51 +++--- source/gameengine/Rasterizer/RAS_MaterialBucket.h | 10 +- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 61 +++++--- source/gameengine/Rasterizer/RAS_MeshObject.h | 6 +- .../RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp | 25 ++- .../RAS_OpenGLRasterizer/RAS_ListRasterizer.h | 8 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 102 +++--------- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 10 +- .../RAS_VAOpenGLRasterizer.cpp | 94 +++++------ .../RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h | 8 +- source/gameengine/Rasterizer/RAS_TexVert.cpp | 42 +---- source/gameengine/Rasterizer/RAS_TexVert.h | 24 ++- 38 files changed, 730 insertions(+), 758 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 230d6b262c6..ed6ea7c5f6a 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -26,6 +26,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include "GL/glew.h" #include "KX_BlenderGL.h" #ifdef HAVE_CONFIG_H @@ -44,7 +45,6 @@ #include "BMF_Api.h" -#include "GL/glew.h" #include "BIF_gl.h" #include "BL_Material.h" // MAXTEX diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index d8b157cb5b4..f3e22cd297a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -312,11 +312,13 @@ BL_Material* ConvertMaterial( Mesh* mesh, Material *mat, MTFace* tface, + const char *tfaceName, MFace* mface, MCol* mmcol, int lightlayer, Object* blenderobj, - MTF_localLayer *layers) + MTF_localLayer *layers, + bool glslmat) { //this needs some type of manager BL_Material *material = new BL_Material(); @@ -335,7 +337,7 @@ BL_Material* ConvertMaterial( if(validmat) { // use vertex colors by explicitly setting - if(mat->mode &MA_VERTEXCOLP) + if(mat->mode &MA_VERTEXCOLP || glslmat) type = 0; // use lighting? @@ -558,6 +560,7 @@ BL_Material* ConvertMaterial( } else { int valid = 0; + // check for tface tex to fallback on if( validface ){ @@ -590,6 +593,7 @@ BL_Material* ConvertMaterial( } MT_Point2 uv[4]; MT_Point2 uv2[4]; + const char *uvName = "", *uv2Name = ""; uv[0]= uv[1]= uv[2]= uv[3]= MT_Point2(0.0f, 0.0f); uv2[0]= uv2[1]= uv2[2]= uv2[3]= MT_Point2(0.0f, 0.0f); @@ -616,6 +620,8 @@ BL_Material* ConvertMaterial( if (mface->v4) uv[3] = MT_Point2(tface->uv[3]); + + uvName = tfaceName; } else { // nothing at all @@ -641,39 +647,38 @@ BL_Material* ConvertMaterial( isFirstSet = false; else { - MT_Point2 uvSet[4]; for (int lay=0; layuv[0]); uvSet[1] = MT_Point2(layer.face->uv[1]); uvSet[2] = MT_Point2(layer.face->uv[2]); if (mface->v4) uvSet[3] = MT_Point2(layer.face->uv[3]); + else + uvSet[3] = MT_Point2(0.0f, 0.0f); - processed = true; - } - - if (!processed) continue; - - if (isFirstSet) - { - uv[0] = uvSet[0]; uv[1] = uvSet[1]; - uv[2] = uvSet[2]; uv[3] = uvSet[3]; - isFirstSet = false; - } - else - { - uv2[0] = uvSet[0]; uv2[1] = uvSet[1]; - uv2[2] = uvSet[2]; uv2[3] = uvSet[3]; - map.mapping |= USECUSTOMUV; + if (isFirstSet) + { + uv[0] = uvSet[0]; uv[1] = uvSet[1]; + uv[2] = uvSet[2]; uv[3] = uvSet[3]; + isFirstSet = false; + uvName = layer.name; + } + else + { + uv2[0] = uvSet[0]; uv2[1] = uvSet[1]; + uv2[2] = uvSet[2]; uv2[3] = uvSet[3]; + map.mapping |= USECUSTOMUV; + uv2Name = layer.name; + } } } } @@ -693,9 +698,8 @@ BL_Material* ConvertMaterial( } material->SetConversionRGB(rgb); - material->SetConversionUV(uv); - material->SetConversionUV2(uv2); - + material->SetConversionUV(uvName, uv); + material->SetConversionUV2(uv2Name, uv2); material->ras_mode |= (mface->v4==0)?TRIANGLE:0; if(validmat) @@ -797,6 +801,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* MFace* mface = static_cast(mesh->mface); MTFace* tface = static_cast(mesh->mtface); + const char *tfaceName = ""; MCol* mmcol = mesh->mcol; MT_assert(mface || mesh->totface == 0); @@ -832,14 +837,14 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* layers[validLayers].face = (MTFace*)mesh->fdata.layers[i].data;; layers[validLayers].name = mesh->fdata.layers[i].name; + if(tface == layers[validLayers].face) + tfaceName = layers[validLayers].name; validLayers++; } } meshobj->SetName(mesh->id.name); meshobj->m_xyz_index_to_vertex_index_mapping.resize(mesh->totvert); - if(skinMesh) - ((BL_SkinMeshObject*)meshobj)->m_mvert_to_dvert_mapping.resize(mesh->totvert); for (int f=0;ftotface;f++,mface++) { @@ -898,8 +903,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* else ma = give_current_material(blenderobj, 1); - bl_mat = ConvertMaterial(mesh, ma, tface, mface, mmcol, lightlayer, blenderobj, layers); - bl_mat->glslmat = converter->GetGLSLMaterials(); + bl_mat = ConvertMaterial(mesh, ma, tface, tfaceName, mface, mmcol, lightlayer, blenderobj, layers, converter->GetGLSLMaterials()); // set the index were dealing with bl_mat->material_index = (int)mface->mat_nr; @@ -1059,35 +1063,25 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* int nverts = mface->v4?4:3; int vtxarray = meshobj->FindVertexArray(nverts,polymat); RAS_Polygon* poly = new RAS_Polygon(bucket,polyvisible,nverts,vtxarray); - if (skinMesh) { - int d1, d2, d3, d4=0; - bool flat; + bool flat; + + if (skinMesh) { /* If the face is set to solid, all fnors are the same */ if (mface->flag & ME_SMOOTH) flat = false; else flat = true; - - d1=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v1, &mesh->dvert[mface->v1], polymat); - d2=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v2, &mesh->dvert[mface->v2], polymat); - d3=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v3, &mesh->dvert[mface->v3], polymat); - if (nverts==4) - d4=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v4, &mesh->dvert[mface->v4], polymat); - poly->SetVertex(0,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,d1,flat,polymat,mface->v1)); - poly->SetVertex(1,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,d2,flat,polymat,mface->v2)); - poly->SetVertex(2,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,d3,flat,polymat,mface->v3)); - if (nverts==4) - poly->SetVertex(3,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,d4,flat,polymat,mface->v4)); } else - { - poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,false,polymat,mface->v1)); - poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,false,polymat,mface->v2)); - poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,false,polymat,mface->v3)); - if (nverts==4) - poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,false,polymat,mface->v4)); - } + flat = false; + + poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,flat,polymat,mface->v1)); + poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,flat,polymat,mface->v2)); + poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,flat,polymat,mface->v3)); + if (nverts==4) + poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,flat,polymat,mface->v4)); + meshobj->AddPolygon(poly); if (poly->IsCollider()) { @@ -1125,8 +1119,6 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* } } meshobj->m_xyz_index_to_vertex_index_mapping.clear(); - if(skinMesh) - ((BL_SkinMeshObject*)meshobj)->m_mvert_to_dvert_mapping.clear(); meshobj->UpdateMaterialList(); // pre calculate texture generation @@ -1545,7 +1537,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, -static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRenderTools *rendertools, KX_BlenderSceneConverter *converter) { +static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRenderTools *rendertools, KX_BlenderSceneConverter *converter) { RAS_LightObject lightobj; KX_LightObject *gamelight; @@ -1577,8 +1569,15 @@ static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX } else { lightobj.m_type = RAS_LightObject::LIGHT_NORMAL; } + +#ifdef BLENDER_GLSL + if(converter->GetGLSLMaterials()) + GPU_lamp_from_blender(ob, la); - gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj); + gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj, ob->gpulamp); +#else + gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj, NULL); +#endif BL_ConvertLampIpos(la, gamelight, converter); return gamelight; @@ -1610,7 +1609,7 @@ static KX_GameObject *gameobject_from_blenderobject( { case OB_LAMP: { - KX_LightObject* gamelight= gamelight_from_blamp(static_cast(ob->data), ob->lay, kxscene, rendertools, converter); + KX_LightObject* gamelight= gamelight_from_blamp(ob, static_cast(ob->data), ob->lay, kxscene, rendertools, converter); gameobj = gamelight; gamelight->AddRef(); @@ -1660,7 +1659,7 @@ static KX_GameObject *gameobject_from_blenderobject( // two options exists for deform: shape keys and armature // only support relative shape key bool bHasShapeKey = mesh->key != NULL && mesh->key->type==KEY_RELATIVE; - bool bHasDvert = mesh->dvert != NULL; + bool bHasDvert = mesh->dvert != NULL && ob->defbase.first; bool bHasArmature = (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && bHasDvert); if (bHasShapeKey) { @@ -1671,13 +1670,15 @@ static KX_GameObject *gameobject_from_blenderobject( if (bHasArmature) dcont->LoadShapeDrivers(ob->parent); } else if (bHasArmature) { - BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj ); + BL_SkinDeformer *dcont = new BL_SkinDeformer((BL_DeformableGameObject*)gameobj, + ob, (BL_SkinMeshObject*)meshobj); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; } else if (bHasDvert) { // this case correspond to a mesh that can potentially deform but not with the // object to which it is attached for the moment. A skin mesh was created in // BL_ConvertMesh() so must create a deformer too! - BL_MeshDeformer *dcont = new BL_MeshDeformer(ob, (BL_SkinMeshObject*)meshobj ); + BL_MeshDeformer *dcont = new BL_MeshDeformer((BL_DeformableGameObject*)gameobj, + ob, (BL_SkinMeshObject*)meshobj); ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; } @@ -2075,7 +2076,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (blenderscene->camera) { KX_Camera *gamecamera= (KX_Camera*) converter->FindGameObject(blenderscene->camera); - kxscene->SetActiveCamera(gamecamera); + if(gamecamera) + kxscene->SetActiveCamera(gamecamera); } // Set up armatures diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index 212827a660f..39d66a90e92 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -39,6 +39,7 @@ #endif #include "RAS_IPolygonMaterial.h" +#include "BL_DeformableGameObject.h" #include "BL_MeshDeformer.h" #include "BL_SkinMeshObject.h" #include "DNA_mesh_types.h" @@ -47,33 +48,40 @@ #include "GEN_Map.h" #include "STR_HashedString.h" -bool BL_MeshDeformer::Apply(RAS_IPolyMaterial *mat) +bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*) { - size_t i, j, index; - vecVertexArray array; - vecIndexArrays mvarray; - vecIndexArrays diarray; - - RAS_TexVert *tv; - MVert *mvert; - - // For each material - array = m_pMeshObject->GetVertexCache(mat); - mvarray = m_pMeshObject->GetMVertCache(mat); - diarray = m_pMeshObject->GetDIndexCache(mat); - - // For each array - for (i=0; isize(); j++){ - tv = &((*array[i])[j]); - index = ((*diarray[i])[j]); - - mvert = &(m_bmesh->mvert[((*mvarray[i])[index])]); - tv->SetXYZ(MT_Point3(mvert->co)); + size_t i, j; + float *co; + + // only apply once per frame if the mesh is actually modified + if(m_pMeshObject->MeshModified() && + m_lastDeformUpdate != m_gameobj->GetLastFrame()) { + // For each material + for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); + mit != m_pMeshObject->GetLastMaterial(); ++ mit) { + RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); + + vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); + + // For each array + for (i=0; imvert[v.getOrigIndex()].co; + v.SetXYZ(MT_Point3(co)); + } + } } + + m_lastDeformUpdate = m_gameobj->GetLastFrame(); + + return true; } - return true; + + return false; } BL_MeshDeformer::~BL_MeshDeformer() @@ -92,83 +100,86 @@ void BL_MeshDeformer::RecalcNormals() /* We don't normalize for performance, not doing it for faces normals * gives area-weight normals which often look better anyway, and use * GL_NORMALIZE so we don't have to do per vertex normalization either - * since the GPU can do it faster - * - * There's a lot of indirection here to get to the data, can this work - * with less arrays/indirection? */ - - vecIndexArrays indexarrays; - vecIndexArrays mvarrays; - vecIndexArrays diarrays; - vecVertexArray vertexarrays; + * since the GPU can do it faster */ size_t i, j; /* set vertex normals to zero */ - for (i=0; i<(size_t)m_bmesh->totvert; i++) - m_transnors[i] = MT_Vector3(0.0f, 0.0f, 0.0f); + memset(m_transnors, 0, sizeof(float)*3*m_bmesh->totvert); /* add face normals to vertices. */ for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); mit != m_pMeshObject->GetLastMaterial(); ++ mit) { RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); - indexarrays = m_pMeshObject->GetIndexCache(mat); - vertexarrays = m_pMeshObject->GetVertexCache(mat); - diarrays = m_pMeshObject->GetDIndexCache(mat); - mvarrays = m_pMeshObject->GetMVertCache(mat); + const vecIndexArrays& indexarrays = m_pMeshObject->GetIndexCache(mat); + vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); for (i=0; iUsesTriangles()? 3: 4; for(j=0; jgetLocalXYZ(); + + n1[0]= co1[0]-co3[0]; + n1[1]= co1[1]-co3[1]; + n1[2]= co1[2]-co3[2]; - fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))); //.safe_normalized(); + n2[0]= co2[0]-co4[0]; + n2[1]= co2[1]-co4[1]; + n2[2]= co2[2]-co4[2]; } - else - fnor = ((mv2-mv1).cross(mv3-mv2)); //.safe_normalized(); + else { + n1[0]= co1[0]-co2[0]; + n2[0]= co2[0]-co3[0]; + n1[1]= co1[1]-co2[1]; + + n2[1]= co2[1]-co3[1]; + n1[2]= co1[2]-co2[2]; + n2[2]= co2[2]-co3[2]; + } + + fnor[0]= n1[1]*n2[2] - n1[2]*n2[1]; + fnor[1]= n1[2]*n2[0] - n1[0]*n2[2]; + fnor[2]= n1[0]*n2[1] - n1[1]*n2[0]; /* add to vertices for smooth normals */ - m_transnors[mvarray[diarray[i1]]] += fnor; - m_transnors[mvarray[diarray[i2]]] += fnor; - m_transnors[mvarray[diarray[i3]]] += fnor; + float *vn1 = m_transnors[v1.getOrigIndex()]; + float *vn2 = m_transnors[v2.getOrigIndex()]; + float *vn3 = m_transnors[v3.getOrigIndex()]; + + vn1[0] += fnor[0]; vn1[1] += fnor[1]; vn1[2] += fnor[2]; + vn2[0] += fnor[0]; vn2[1] += fnor[1]; vn2[2] += fnor[2]; + vn3[0] += fnor[0]; vn3[1] += fnor[1]; vn3[2] += fnor[2]; + + if(v4) { + float *vn4 = m_transnors[v4->getOrigIndex()]; + vn4[0] += fnor[0]; vn4[1] += fnor[1]; vn4[2] += fnor[2]; + } /* in case of flat - just assign, the vertices are split */ if(v1.getFlag() & TV_CALCFACENORMAL) { v1.SetNormal(fnor); v2.SetNormal(fnor); v3.SetNormal(fnor); - } - - if(nvert == 4) { - int i4 = indexarray[j+3]; - RAS_TexVert& v4 = vertexarray[i4]; - - /* same as above */ - m_transnors[mvarray[diarray[i4]]] += fnor; - - if(v4.getFlag() & TV_CALCFACENORMAL) - v4.SetNormal(fnor); + if(v4) + v4->SetNormal(fnor); } } } @@ -179,18 +190,17 @@ void BL_MeshDeformer::RecalcNormals() mit != m_pMeshObject->GetLastMaterial(); ++ mit) { RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); - vertexarrays = m_pMeshObject->GetVertexCache(mat); - diarrays = m_pMeshObject->GetDIndexCache(mat); - mvarrays = m_pMeshObject->GetMVertCache(mat); + vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); for (i=0; itotvert)][3]; - m_transnors=new MT_Vector3[m_bmesh->totvert]; + m_transverts=new float[m_bmesh->totvert][3]; + m_transnors=new float[m_bmesh->totvert][3]; m_tvtot = m_bmesh->totvert; } } diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 8d8b56b1eed..e9f7f0b192f 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -40,19 +40,25 @@ #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 +class BL_DeformableGameObject; + class BL_MeshDeformer : public RAS_Deformer { public: void VerifyStorage(); void RecalcNormals(); virtual void Relink(GEN_Map*map){}; - BL_MeshDeformer(struct Object* obj, class BL_SkinMeshObject *meshobj ): + BL_MeshDeformer(BL_DeformableGameObject *gameobj, + struct Object* obj, + class BL_SkinMeshObject *meshobj ): m_pMeshObject(meshobj), m_bmesh((struct Mesh*)(obj->data)), m_transverts(0), m_transnors(0), m_objMesh(obj), - m_tvtot(0) + m_tvtot(0), + m_gameobj(gameobj), + m_lastDeformUpdate(-1) {}; virtual ~BL_MeshDeformer(); virtual void SetSimulatedTime(double time){}; @@ -68,10 +74,12 @@ protected: // this is so m_transverts doesn't need to be converted // before deformation float (*m_transverts)[3]; - MT_Vector3* m_transnors; + float (*m_transnors)[3]; struct Object* m_objMesh; // -- int m_tvtot; + BL_DeformableGameObject* m_gameobj; + double m_lastDeformUpdate; }; #endif diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 9f8361dbaca..5f0188e3a42 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -58,9 +58,8 @@ public: Object *bmeshobj, BL_SkinMeshObject *mesh) : - BL_SkinDeformer(bmeshobj, mesh), - m_lastShapeUpdate(-1), - m_gameobj(gameobj) + BL_SkinDeformer(gameobj,bmeshobj, mesh), + m_lastShapeUpdate(-1) { }; @@ -72,9 +71,8 @@ public: bool release_object, BL_ArmatureObject* arma = NULL) : - BL_SkinDeformer(bmeshobj_old, bmeshobj_new, mesh, release_object, arma), - m_lastShapeUpdate(-1), - m_gameobj(gameobj) + BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, arma), + m_lastShapeUpdate(-1) { }; @@ -94,7 +92,6 @@ public: protected: vector m_shapeDrivers; double m_lastShapeUpdate; - BL_DeformableGameObject* m_gameobj; }; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index dd7119b1031..d3442fe5298 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -57,11 +57,12 @@ extern "C"{ #define __NLA_DEFNORMALS //#undef __NLA_DEFNORMALS -BL_SkinDeformer::BL_SkinDeformer(struct Object *bmeshobj, +BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj, + struct Object *bmeshobj, class BL_SkinMeshObject *mesh, BL_ArmatureObject* arma) : // - BL_MeshDeformer(bmeshobj, mesh), + BL_MeshDeformer(gameobj, bmeshobj, mesh), m_armobj(arma), m_lastArmaUpdate(-1), m_defbase(&bmeshobj->defbase), @@ -71,12 +72,13 @@ BL_SkinDeformer::BL_SkinDeformer(struct Object *bmeshobj, }; BL_SkinDeformer::BL_SkinDeformer( + BL_DeformableGameObject *gameobj, struct Object *bmeshobj_old, // Blender object that owns the new mesh struct Object *bmeshobj_new, // Blender object that owns the original mesh class BL_SkinMeshObject *mesh, bool release_object, BL_ArmatureObject* arma) : - BL_MeshDeformer(bmeshobj_old, mesh), + BL_MeshDeformer(gameobj, bmeshobj_old, mesh), m_armobj(arma), m_lastArmaUpdate(-1), m_defbase(&bmeshobj_old->defbase), @@ -96,35 +98,32 @@ BL_SkinDeformer::~BL_SkinDeformer() m_armobj->Release(); } -bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) +bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *) { - size_t i, j, index; - vecVertexArray array; - vecIndexArrays mvarray; - vecMDVertArray dvarray; - vecIndexArrays diarray; - - RAS_TexVert *tv; - MT_Point3 pt; -// float co[3]; - - Update(); - - array = m_pMeshObject->GetVertexCache(mat); - mvarray = m_pMeshObject->GetMVertCache(mat); - diarray = m_pMeshObject->GetDIndexCache(mat); - // For each array - for (i=0; isize(); j++) { - - tv = &((*array[i])[j]); - - index = ((*diarray[i])[j]); - - // Copy the untransformed data from the original mvert - // Set the data - tv->SetXYZ(m_transverts[((*mvarray[i])[index])]); + size_t i, j; + + if (!Update()) + // no need to update the cache + return false; + + // Update all materials at once, so we can do the above update test + // without ending up with some materials not updated + for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); + mit != m_pMeshObject->GetLastMaterial(); ++ mit) { + RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); + + vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); + + // For each array + for (i=0; im_MvertArrayCache1[vtxarray]->size(); - - /* Check to see if this has already been pushed */ - for (vector::iterator it = m_mvert_to_dvert_mapping[mv].begin(); - it != m_mvert_to_dvert_mapping[mv].end(); - it++) - { - if(it->mat == mat) - return it->index; - } - - ao->m_MvertArrayCache1[vtxarray]->push_back(mv); - ao->m_DvertArrayCache1[vtxarray]->push_back(dv); - - BL_MDVertMap mdmap; - mdmap.mat = mat; - mdmap.index = numvert; - m_mvert_to_dvert_mapping[mv].push_back(mdmap); - - return numvert; -}; - -int BL_SkinMeshObject::FindVertexArray(int numverts,RAS_IPolyMaterial* polymat) -{ - int array=-1; - - BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(polymat); - - - for (size_t i=0;im_VertexArrayCache1.size();i++) - { - if ( (ao->m_TriangleArrayCount[i] + (numverts-2)) < BUCKET_MAX_TRIANGLES) - { - if((ao->m_VertexArrayCache1[i]->size()+numverts < BUCKET_MAX_INDICES)) - { - array = i; - ao->m_TriangleArrayCount[array]+=numverts-2; - break; - } - } - } - - - if (array == -1) - { - array = ao->m_VertexArrayCache1.size(); - - vector* va = new vector; - ao->m_VertexArrayCache1.push_back(va); - - KX_IndexArray *ia = new KX_IndexArray(); - ao->m_IndexArrayCache1.push_back(ia); - - KX_IndexArray *bva = new KX_IndexArray(); - ao->m_MvertArrayCache1.push_back(bva); - - BL_DeformVertArray *dva = new BL_DeformVertArray(); - ao->m_DvertArrayCache1.push_back(dva); - - KX_IndexArray *da = new KX_IndexArray(); - ao->m_DIndexArrayCache1.push_back(da); - - ao->m_TriangleArrayCount.push_back(numverts-2); - - } - - - return array; -} - - //void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,RAS_BucketManager* bucketmgr) void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec) { diff --git a/source/gameengine/Converter/BL_SkinMeshObject.h b/source/gameengine/Converter/BL_SkinMeshObject.h index cc2b8de600e..c21fb64204b 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.h +++ b/source/gameengine/Converter/BL_SkinMeshObject.h @@ -44,78 +44,19 @@ #include "DNA_key_types.h" #include "DNA_meshdata_types.h" -typedef vector BL_MVertArray; -typedef vector BL_DeformVertArray; -typedef vector BL_VertexArray; - - -typedef vector*> vecMDVertArray; -typedef vector*> vecBVertexArray; - -class BL_SkinArrayOptimizer : public KX_ArrayOptimizer -{ -public: - BL_SkinArrayOptimizer(int index) - :KX_ArrayOptimizer (index) {}; - virtual ~BL_SkinArrayOptimizer(){ - - for (vector::iterator itv = m_MvertArrayCache1.begin(); - !(itv == m_MvertArrayCache1.end());itv++) - { - delete (*itv); - } - for (vector::iterator itd = m_DvertArrayCache1.begin(); - !(itd == m_DvertArrayCache1.end());itd++) - { - delete (*itd); - } - for (vector::iterator iti = m_DIndexArrayCache1.begin(); - !(iti == m_DIndexArrayCache1.end());iti++) - { - delete (*iti); - } - - m_MvertArrayCache1.clear(); - m_DvertArrayCache1.clear(); - m_DIndexArrayCache1.clear(); - }; - - vector m_MvertArrayCache1; - vector m_DvertArrayCache1; - vector m_DIndexArrayCache1; - -}; - class BL_SkinMeshObject : public RAS_MeshObject { // enum { BUCKET_MAX_INDICES = 16384};//2048};//8192}; // enum { BUCKET_MAX_TRIANGLES = 4096}; - KX_ArrayOptimizer* GetArrayOptimizer(RAS_IPolyMaterial* polymat) - { - KX_ArrayOptimizer** aop = (m_matVertexArrayS[*polymat]); - if (aop) - return *aop; - int numelements = m_matVertexArrayS.size(); - m_sortedMaterials.push_back(polymat); - - BL_SkinArrayOptimizer* ao = new BL_SkinArrayOptimizer(numelements); - m_matVertexArrayS.insert(*polymat,ao); - return ao; - } - protected: vector m_cacheWeightIndex; public: - struct BL_MDVertMap { RAS_IPolyMaterial *mat; int index; }; - vector > m_mvert_to_dvert_mapping; - void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec); // void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,class RAS_BucketManager* bucketmgr); - int FindVertexArray(int numverts,RAS_IPolyMaterial* polymat); BL_SkinMeshObject(Mesh* mesh, int lightlayer) : RAS_MeshObject (mesh, lightlayer) { m_class = 1; @@ -144,42 +85,7 @@ public: } } }; - - const vecIndexArrays& GetDIndexCache (RAS_IPolyMaterial* mat) - { - BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); - return ao->m_DIndexArrayCache1; - } - const vecMDVertArray& GetDVertCache (RAS_IPolyMaterial* mat) - { - BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); - return ao->m_DvertArrayCache1; - } - const vecIndexArrays& GetMVertCache (RAS_IPolyMaterial* mat) - { - BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); - return ao->m_MvertArrayCache1; - } - void AddPolygon(RAS_Polygon* poly); - int FindOrAddDeform(unsigned int vtxarray, unsigned int mv, struct MDeformVert *dv, RAS_IPolyMaterial* mat); - int FindOrAddVertex(int vtxarray,const MT_Point3& xyz, - const MT_Point2& uv, - const MT_Point2& uv2, - const MT_Vector4& tangent, - const unsigned int rgbacolor, - const MT_Vector3& normal, int defnr, bool flat, RAS_IPolyMaterial* mat, int origindex) - { - BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat); - int numverts = ao->m_VertexArrayCache1[vtxarray]->size(); - int index = RAS_MeshObject::FindOrAddVertex(vtxarray, xyz, uv, uv2, tangent, rgbacolor, normal, flat, mat, origindex); - - /* this means a new vertex was added, so we add the defnr too */ - if(index == numverts) - ao->m_DIndexArrayCache1[vtxarray]->push_back(defnr); - - return index; - } // for shape keys, void CheckWeightCache(struct Object* obj); diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 06e012123b1..dd45d522b9f 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -1,9 +1,11 @@ #include "DNA_customdata_types.h" +#include "DNA_material_types.h" #include "BL_BlenderShader.h" +#include "BL_Material.h" -#if 0 +#ifdef BLENDER_GLSL #include "GPU_extensions.h" #include "GPU_material.h" #endif @@ -13,29 +15,32 @@ const bool BL_BlenderShader::Ok()const { -#if 0 +#ifdef BLENDER_GLSL return (mGPUMat != 0); +#else + return 0; #endif - - return false; } -BL_BlenderShader::BL_BlenderShader(struct Material *ma) +BL_BlenderShader::BL_BlenderShader(struct Material *ma, int lightlayer) : -#if 0 +#ifdef BLENDER_GLSL mGPUMat(0), #endif - mBound(false) + mBound(false), + mLightLayer(lightlayer) { -#if 0 - if(ma) - mGPUMat = GPU_material_from_blender(ma, GPU_PROFILE_DERIVEDMESH); +#ifdef BLENDER_GLSL + if(ma) { + GPU_material_from_blender(ma); + mGPUMat = ma->gpumaterial; + } #endif } BL_BlenderShader::~BL_BlenderShader() { -#if 0 +#ifdef BLENDER_GLSL if(mGPUMat) { GPU_material_unbind(mGPUMat); mGPUMat = 0; @@ -43,16 +48,12 @@ BL_BlenderShader::~BL_BlenderShader() #endif } -void BL_BlenderShader::ApplyShader() -{ -} - void BL_BlenderShader::SetProg(bool enable) { -#if 0 +#ifdef BLENDER_GLSL if(mGPUMat) { if(enable) { - GPU_material_bind(mGPUMat); + GPU_material_bind(mGPUMat, mLightLayer); mBound = true; } else { @@ -65,7 +66,7 @@ void BL_BlenderShader::SetProg(bool enable) int BL_BlenderShader::GetAttribNum() { -#if 0 +#ifdef BLENDER_GLSL GPUVertexAttribs attribs; int i, enabled = 0; @@ -82,17 +83,19 @@ int BL_BlenderShader::GetAttribNum() enabled = BL_MAX_ATTRIB; return enabled; -#endif - +#else return 0; +#endif } -void BL_BlenderShader::SetTexCoords(RAS_IRasterizer* ras) +void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat) { -#if 0 +#ifdef BLENDER_GLSL GPUVertexAttribs attribs; int i, attrib_num; + ras->SetAttribNum(0); + if(!mGPUMat) return; @@ -109,14 +112,24 @@ void BL_BlenderShader::SetTexCoords(RAS_IRasterizer* ras) if(attribs.layer[i].glindex > attrib_num) continue; - if(attribs.layer[i].type == CD_MTFACE) - ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex); + if(attribs.layer[i].type == CD_MTFACE) { + if(!mat->uvName.IsEmpty() && strcmp(mat->uvName.ReadPtr(), attribs.layer[i].name) == 0) + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex); + else if(!mat->uv2Name.IsEmpty() && strcmp(mat->uv2Name.ReadPtr(), attribs.layer[i].name) == 0) + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV2, attribs.layer[i].glindex); + else + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex); + } else if(attribs.layer[i].type == CD_TANGENT) ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, attribs.layer[i].glindex); else if(attribs.layer[i].type == CD_ORCO) ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_ORCO, attribs.layer[i].glindex); else if(attribs.layer[i].type == CD_NORMAL) ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_NORM, attribs.layer[i].glindex); + else if(attribs.layer[i].type == CD_MCOL) + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_VCOL, attribs.layer[i].glindex); + else + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, attribs.layer[i].glindex); } ras->EnableTextures(true); @@ -128,8 +141,8 @@ void BL_BlenderShader::SetTexCoords(RAS_IRasterizer* ras) void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) { -#if 0 - float obmat[4][4], viewmat[4][4]; +#ifdef BLENDER_GLSL + float obmat[4][4], viewmat[4][4], viewinvmat[4][4]; if(!mGPUMat || !mBound) return; @@ -142,7 +155,20 @@ void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) model.getValue((float*)obmat); view.getValue((float*)viewmat); - GPU_material_bind_uniforms(mGPUMat, obmat, viewmat); + view.invert(); + view.getValue((float*)viewinvmat); + + GPU_material_bind_uniforms(mGPUMat, obmat, viewmat, viewinvmat); +#endif +} + +bool BL_BlenderShader::Equals(BL_BlenderShader *blshader) +{ +#ifdef BLENDER_GLSL + /* to avoid unneeded state switches */ + return (blshader && mGPUMat == blshader->mGPUMat && mLightLayer == blshader->mLightLayer); +#else + return true; #endif } diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index 4cab0e644c3..b758d1a9cba 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -2,7 +2,7 @@ #ifndef __BL_GPUSHADER_H__ #define __BL_GPUSHADER_H__ -#if 0 +#ifdef BLENDER_GLSL #include "GPU_material.h" #endif @@ -12,7 +12,10 @@ #include "MT_Tuple3.h" #include "MT_Tuple4.h" +#include "RAS_IPolygonMaterial.h" + struct Material; +class BL_Material; #define BL_MAX_ATTRIB 16 @@ -23,22 +26,24 @@ struct Material; class BL_BlenderShader { private: -#if 0 +#ifdef BLENDER_GLSL GPUMaterial *mGPUMat; #endif bool mBound; + int mLightLayer; public: - BL_BlenderShader(struct Material *ma); + BL_BlenderShader(struct Material *ma, int lightlayer); virtual ~BL_BlenderShader(); const bool Ok()const; void SetProg(bool enable); - void ApplyShader(); - void SetTexCoords(class RAS_IRasterizer* ras); int GetAttribNum(); + void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat); void Update(const class KX_MeshSlot & ms, class RAS_IRasterizer* rasty); + + bool Equals(BL_BlenderShader *blshader); }; #endif//__BL_GPUSHADER_H__ diff --git a/source/gameengine/Ketsji/BL_Material.cpp b/source/gameengine/Ketsji/BL_Material.cpp index f5312ccd023..7e3d6984f19 100644 --- a/source/gameengine/Ketsji/BL_Material.cpp +++ b/source/gameengine/Ketsji/BL_Material.cpp @@ -105,7 +105,8 @@ void BL_Material::GetConversionRGB(unsigned int *nrgb) { *nrgb = rgb[3]; } -void BL_Material::SetConversionUV(MT_Point2 *nuv) { +void BL_Material::SetConversionUV(const STR_String& name, MT_Point2 *nuv) { + uvName = name; uv[0] = *nuv++; uv[1] = *nuv++; uv[2] = *nuv++; @@ -118,7 +119,8 @@ void BL_Material::GetConversionUV(MT_Point2 *nuv){ *nuv++ = uv[2]; *nuv = uv[3]; } -void BL_Material::SetConversionUV2(MT_Point2 *nuv) { +void BL_Material::SetConversionUV2(const STR_String& name, MT_Point2 *nuv) { + uv2Name = name; uv2[0] = *nuv++; uv2[1] = *nuv++; uv2[2] = *nuv++; diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index ddb6662830a..568f7e171de 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -83,13 +83,16 @@ public: MT_Point2 uv[4]; MT_Point2 uv2[4]; + STR_String uvName; + STR_String uv2Name; + void SetConversionRGB(unsigned int *rgb); void GetConversionRGB(unsigned int *rgb); - void SetConversionUV(MT_Point2 *uv); + void SetConversionUV(const STR_String& name, MT_Point2 *uv); void GetConversionUV(MT_Point2 *uv); - void SetConversionUV2(MT_Point2 *uv); + void SetConversionUV2(const STR_String& name, MT_Point2 *uv); void GetConversionUV2(MT_Point2 *uv); void SetSharedMaterial(bool v); diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 02b1ffd432a..0f445a9f32e 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -38,6 +38,8 @@ extern "C" { // ------------------------------------ #define spit(x) std::cout << x << std::endl; +BL_BlenderShader *KX_BlenderMaterial::mLastBlenderShader = NULL; + //static PyObject *gTextureDict = 0; KX_BlenderMaterial::KX_BlenderMaterial( @@ -126,32 +128,31 @@ void KX_BlenderMaterial::OnConstruction() // when material are reused between objects return; - if(mMaterial->glslmat) { + if(mMaterial->glslmat) SetBlenderGLSLShader(); - } - else { - // for each unique material... - int i; - for(i=0; inum_enabled; i++) { - if( mMaterial->mapping[i].mapping & USEENV ) { - if(!GLEW_ARB_texture_cube_map) { - spit("CubeMap textures not supported"); - continue; - } - if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) ) + + // for each unique material... + int i; + for(i=0; inum_enabled; i++) { + if( mMaterial->mapping[i].mapping & USEENV ) { + if(!GLEW_ARB_texture_cube_map) { + spit("CubeMap textures not supported"); + continue; + } + if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) ) + spit("unable to initialize image("<matname<< ", image will not be available"); + } + + else { + if( mMaterial->img[i] ) { + if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) spit("unable to initialize image("<matname<< ", image will not be available"); - } - - else { - if( mMaterial->img[i] ) { - if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 )) - spit("unable to initialize image("<matname<< ", image will not be available"); - } + mMaterial->matname<< ", image will not be available"); } } } + mBlendFunc[0] =0; mBlendFunc[1] =0; mConstructed = true; @@ -168,7 +169,11 @@ void KX_BlenderMaterial::OnExit() } if( mBlenderShader ) { - mBlenderShader->SetProg(false); + if(mBlenderShader == mLastBlenderShader) { + mBlenderShader->SetProg(false); + mLastBlenderShader = NULL; + } + delete mBlenderShader; mBlenderShader = 0; } @@ -225,14 +230,23 @@ void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras { if( !enable || !mBlenderShader->Ok() ) { // frame cleanup. - mBlenderShader->SetProg(false); + if(mLastBlenderShader) { + mLastBlenderShader->SetProg(false); + mLastBlenderShader= NULL; + } BL_Texture::DisableAllTextures(); return; } - BL_Texture::DisableAllTextures(); - mBlenderShader->SetProg(true); - mBlenderShader->ApplyShader(); + if(!mBlenderShader->Equals(mLastBlenderShader)) { + BL_Texture::DisableAllTextures(); + + if(mLastBlenderShader) + mLastBlenderShader->SetProg(false); + + mBlenderShader->SetProg(true); + mLastBlenderShader= mBlenderShader; + } } void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) @@ -298,7 +312,12 @@ KX_BlenderMaterial::ActivatShaders( // reset... if(tmp->mMaterial->IsShared()) cachingInfo =0; - + + if(mLastBlenderShader) { + mLastBlenderShader->SetProg(false); + mLastBlenderShader= NULL; + } + if (GetCachingInfo() != cachingInfo) { if (!cachingInfo) @@ -372,7 +391,7 @@ KX_BlenderMaterial::ActivateBlenderShaders( } ActivatGLMaterials(rasty); - mBlenderShader->SetTexCoords(rasty); + mBlenderShader->SetAttribs(rasty, mMaterial); } void @@ -382,6 +401,12 @@ KX_BlenderMaterial::ActivateMat( )const { KX_BlenderMaterial *tmp = const_cast(this); + + if(mLastBlenderShader) { + mLastBlenderShader->SetProg(false); + mLastBlenderShader= NULL; + } + if (GetCachingInfo() != cachingInfo) { if (!cachingInfo) tmp->setTexData( false,rasty ); @@ -460,17 +485,29 @@ KX_BlenderMaterial::Activate( return dopass; } +bool KX_BlenderMaterial::UsesLighting(RAS_IRasterizer *rasty) const +{ + if(!RAS_IPolyMaterial::UsesLighting(rasty)) + return false; + + if(mShader && mShader->Ok()); + else if(mBlenderShader && mBlenderShader->Ok()) + return false; + + return true; +} + void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterizer* rasty) const { if(mShader && GLEW_ARB_shader_objects) mShader->Update(ms, rasty); - if(mBlenderShader && GLEW_ARB_shader_objects) + else if(mBlenderShader && GLEW_ARB_shader_objects) mBlenderShader->Update(ms, rasty); } void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const { - if(!mBlenderShader) { + if(mShader || !mBlenderShader) { rasty->SetSpecularity( mMaterial->speccolor[0]*mMaterial->spec_f, mMaterial->speccolor[1]*mMaterial->spec_f, @@ -506,6 +543,7 @@ void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const ras->SetAttribNum(0); if(mShader && GLEW_ARB_shader_objects) { if(mShader->GetAttribute() == BL_Shader::SHD_TANGENT) { + ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, 0); ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, 1); ras->SetAttribNum(2); } @@ -793,7 +831,7 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") void KX_BlenderMaterial::SetBlenderGLSLShader(void) { if(!mBlenderShader) - mBlenderShader = new BL_BlenderShader(mMaterial->material); + mBlenderShader = new BL_BlenderShader(mMaterial->material, m_lightlayer); if(!mBlenderShader->Ok()) { delete mBlenderShader; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 62e96b71937..bf6d2095e7c 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -94,6 +94,7 @@ private: BL_Material* mMaterial; BL_Shader* mShader; BL_BlenderShader* mBlenderShader; + static BL_BlenderShader *mLastBlenderShader; KX_Scene* mScene; BL_Texture mTextures[MAXTEX]; // texture array bool mUserDefBlend; @@ -106,6 +107,7 @@ private: void ActivatGLMaterials( RAS_IRasterizer* rasty )const; void ActivateTexGen( RAS_IRasterizer *ras ) const; + bool UsesLighting(RAS_IRasterizer *rasty) const; // message centers void setTexData( bool enable,RAS_IRasterizer *ras); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index db13d30e2f1..2ac4f909077 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1306,7 +1306,7 @@ PyObject* KX_GameObject::PyGetMesh(PyObject* self, return meshproxy; } } - return NULL; + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 56a06786679..20187a193ba 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -55,6 +55,7 @@ #include "KX_Scene.h" #include "MT_CmMatrix4x4.h" #include "KX_Camera.h" +#include "KX_Light.h" #include "KX_PythonInit.h" #include "KX_PyConstraintBinding.h" #include "PHY_IPhysicsEnvironment.h" @@ -614,6 +615,9 @@ void KX_KetsjiEngine::Render() // pass the scene's worldsettings to the rasterizer SetWorldSettings(scene->GetWorldInfo()); + // shadow buffers + RenderShadowBuffers(scene); + // Avoid drawing the scene with the active camera twice when it's viewport is enabled if(cam && !cam->GetViewport()) { @@ -885,8 +889,48 @@ void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam) viewport.GetTop() ); -} +} + +void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) +{ + CListValue *lightlist = scene->GetLightList(); + int i, drawmode; + for(i=0; iGetCount(); i++) { + KX_LightObject *light = (KX_LightObject*)lightlist->GetValue(i); + + light->Update(); + + if(m_drawingmode == RAS_IRasterizer::KX_TEXTURED && light->HasShadowBuffer()) { + /* make temporary camera */ + RAS_CameraData camdata = RAS_CameraData(); + KX_Camera *cam = new KX_Camera(scene, scene->m_callbacks, camdata, false); + cam->SetName("__shadow__cam__"); + + MT_Transform camtrans; + + /* switch drawmode for speed */ + drawmode = m_rasterizer->GetDrawingMode(); + m_rasterizer->SetDrawingMode(RAS_IRasterizer::KX_SHADOW); + + /* binds framebuffer object, sets up camera .. */ + light->BindShadowBuffer(m_rasterizer, cam, camtrans); + + /* update scene */ + scene->UpdateMeshTransformations(); + scene->CalculateVisibleMeshes(m_rasterizer, cam, light->GetShadowLayer()); + + /* render */ + m_rasterizer->ClearDepthBuffer(); + scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools); + + /* unbind framebuffer object, restore drawmode, free camera */ + light->UnbindShadowBuffer(m_rasterizer); + m_rasterizer->SetDrawingMode(drawmode); + cam->Release(); + } + } +} // update graphics void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 4c09bc3fcd5..77b69ec2d9e 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -179,6 +179,7 @@ private: void RenderFrame(KX_Scene* scene, KX_Camera* cam); void PostRenderFrame(); void RenderDebugProperties(); + void RenderShadowBuffers(KX_Scene *scene); void SetBackGround(KX_WorldInfo* worldinfo); void SetWorldSettings(KX_WorldInfo* worldinfo); void DoSound(KX_Scene* scene); diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 7decc5bc769..4e3d6180d22 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -36,14 +36,20 @@ #endif #include "KX_Light.h" +#include "KX_Camera.h" +#include "RAS_IRasterizer.h" #include "RAS_IRenderTools.h" #include "KX_PyMath.h" +#ifdef BLENDER_GLSL +#include "GPU_material.h" +#endif KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, class RAS_IRenderTools* rendertools, const RAS_LightObject& lightobj, + struct GPULamp *gpulamp, PyTypeObject* T ) : @@ -53,12 +59,12 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, m_lightobj = lightobj; m_lightobj.m_worldmatrix = GetOpenGLMatrixPtr(); m_rendertools->AddLight(&m_lightobj); + m_gpulamp = gpulamp; }; KX_LightObject::~KX_LightObject() { - m_rendertools->RemoveLight(&m_lightobj); } @@ -78,6 +84,78 @@ CValue* KX_LightObject::GetReplica() return replica; } +void KX_LightObject::Update() +{ +#ifdef BLENDER_GLSL + if(m_gpulamp) { + float obmat[4][4]; + double *dobmat = GetOpenGLMatrixPtr()->getPointer(); + + for(int i=0; i<4; i++) + for(int j=0; j<4; j++, dobmat++) + obmat[i][j] = (float)*dobmat; + + GPU_lamp_update(m_gpulamp, obmat); + } +#endif +} + +bool KX_LightObject::HasShadowBuffer() +{ +#ifdef BLENDER_GLSL + return (m_gpulamp && GPU_lamp_has_shadow_buffer(m_gpulamp)); +#else + return false; +#endif +} + +int KX_LightObject::GetShadowLayer() +{ +#ifdef BLENDER_GLSL + if(m_gpulamp) + return GPU_lamp_shadow_layer(m_gpulamp); + else +#endif + return 0; +} + +void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_Transform& camtrans) +{ +#ifdef BLENDER_GLSL + float viewmat[4][4], winmat[4][4]; + int winsize; + + /* bind framebuffer */ + GPU_lamp_shadow_buffer_bind(m_gpulamp, viewmat, &winsize, winmat); + + /* setup camera transformation */ + MT_Matrix4x4 modelviewmat((float*)viewmat); + MT_Matrix4x4 projectionmat((float*)winmat); + + MT_Transform trans = MT_Transform((float*)viewmat); + camtrans.invert(trans); + + cam->SetModelviewMatrix(modelviewmat); + cam->SetProjectionMatrix(projectionmat); + + cam->NodeSetLocalPosition(camtrans.getOrigin()); + cam->NodeSetLocalOrientation(camtrans.getBasis()); + cam->NodeUpdateGS(0,true); + + /* setup rasterizer transformations */ + ras->SetProjectionMatrix(projectionmat); + ras->SetViewMatrix(modelviewmat, cam->NodeGetWorldPosition(), + cam->GetCameraLocation(), cam->GetCameraOrientation()); +#endif +} + +void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras) +{ +#ifdef BLENDER_GLSL + GPU_lamp_shadow_buffer_unbind(m_gpulamp); +#endif +} + PyObject* KX_LightObject::_getattr(const STR_String& attr) { if (attr == "layer") diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 236d3e4e12e..62eb26c61a8 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -32,19 +32,33 @@ #include "RAS_LightObject.h" #include "KX_GameObject.h" +struct GPULamp; +class KX_Camera; +class RAS_IRasterizer; +class RAS_IRenderTools; +class MT_Transform; + class KX_LightObject : public KX_GameObject { Py_Header; protected: RAS_LightObject m_lightobj; class RAS_IRenderTools* m_rendertools; //needed for registering and replication of lightobj + struct GPULamp *m_gpulamp; static char doc[]; public: - KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, PyTypeObject *T = &Type); + KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, struct GPULamp *gpulamp, PyTypeObject *T = &Type); virtual ~KX_LightObject(); virtual CValue* GetReplica(); RAS_LightObject* GetLightData() { return &m_lightobj;} + + /* GLSL shadow */ + bool HasShadowBuffer(); + int GetShadowLayer(); + void BindShadowBuffer(class RAS_IRasterizer *ras, class KX_Camera *cam, class MT_Transform& camtrans); + void UnbindShadowBuffer(class RAS_IRasterizer *ras); + void Update(); virtual PyObject* _getattr(const STR_String& attr); /* lens, near, far, projection_matrix */ virtual int _setattr(const STR_String& attr, PyObject *pyvalue); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index c5f6230b2f2..065800379d8 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -888,6 +888,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) else if (bHasArmature) { BL_SkinDeformer* skinDeformer = new BL_SkinDeformer( + newobj, oldblendobj, blendobj, static_cast(mesh), true, @@ -899,7 +900,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) else if (bHasDvert) { BL_MeshDeformer* meshdeformer = new BL_MeshDeformer( - oldblendobj, static_cast(mesh) + newobj, oldblendobj, static_cast(mesh) ); newobj->m_pDeformer = meshdeformer; } @@ -1004,12 +1005,13 @@ void KX_Scene::UpdateMeshTransformations() } } -void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam) +void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam, int layer) { int intersect = KX_Camera::INTERSECT; KX_GameObject *gameobj = node->Client()?(KX_GameObject*) node->Client()->GetSGClientObject():NULL; - bool dotest = (gameobj && gameobj->GetVisible()) || node->Left() || node->Right(); - + bool visible = (gameobj && gameobj->GetVisible() && (!layer || (gameobj->GetLayer() & layer))); + bool dotest = visible || node->Left() || node->Right(); + /* If the camera is inside the box, assume intersect. */ if (dotest && !node->inside( cam->NodeGetWorldPosition())) { @@ -1033,19 +1035,19 @@ void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam break; case KX_Camera::INTERSECT: if (gameobj) - MarkVisible(rasty, gameobj,cam); + MarkVisible(rasty, gameobj, cam, layer); if (node->Left()) - MarkVisible(node->Left(), rasty,cam); + MarkVisible(node->Left(), rasty, cam, layer); if (node->Right()) - MarkVisible(node->Right(), rasty,cam); + MarkVisible(node->Right(), rasty, cam, layer); break; case KX_Camera::INSIDE: - MarkSubTreeVisible(node, rasty, true,cam); + MarkSubTreeVisible(node, rasty, true, cam, layer); break; } } -void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible,KX_Camera* cam) +void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera* cam, int layer) { if (node->Client()) { @@ -1068,16 +1070,23 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi } } if (node->Left()) - MarkSubTreeVisible(node->Left(), rasty, visible,cam); + MarkSubTreeVisible(node->Left(), rasty, visible, cam, layer); if (node->Right()) - MarkSubTreeVisible(node->Right(), rasty, visible,cam); + MarkSubTreeVisible(node->Right(), rasty, visible, cam, layer); } -void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Camera* cam) +void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Camera* cam,int layer) { // User (Python/Actuator) has forced object invisible... if (!gameobj->GetVisible()) return; + + // Shadow lamp layers + if(layer && !(gameobj->GetLayer() & layer)) { + gameobj->MarkVisible(false); + return; + } + // If Frustum culling is off, the object is always visible. bool vis = !cam->GetFrustumCulling(); @@ -1127,20 +1136,20 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam } } -void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam) +void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int layer) { // FIXME: When tree is operational #if 1 // do this incrementally in the future for (int i = 0; i < m_objectlist->GetCount(); i++) { - MarkVisible(rasty, static_cast(m_objectlist->GetValue(i)), cam); + MarkVisible(rasty, static_cast(m_objectlist->GetValue(i)), cam, layer); } #else if (cam->GetFrustumCulling()) - MarkVisible(m_objecttree, rasty, cam); + MarkVisible(m_objecttree, rasty, cam, layer); else - MarkSubTreeVisible(m_objecttree, rasty, true, cam); + MarkSubTreeVisible(m_objecttree, rasty, true, cam, layer); #endif } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 733df2f69a1..28dee1b5893 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -260,9 +260,9 @@ protected: /** * Visibility testing functions. */ - void MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera*cam); - void MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera*cam); - void MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj, KX_Camera*cam); + void MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera*cam,int layer=0); + void MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera*cam,int layer=0); + void MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj, KX_Camera*cam, int layer=0); double m_suspendedtime; double m_suspendeddelta; @@ -483,7 +483,7 @@ public: void SetNetworkScene(NG_NetworkScene *newScene); void SetWorldInfo(class KX_WorldInfo* wi); KX_WorldInfo* GetWorldInfo(); - void CalculateVisibleMeshes(RAS_IRasterizer* rasty, KX_Camera *cam); + void CalculateVisibleMeshes(RAS_IRasterizer* rasty, KX_Camera *cam, int layer=0); void UpdateMeshTransformations(); KX_Camera* GetpCamera(); SND_Scene* GetSoundScene(); diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 50df1a1e2ea..b4492ca03a9 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -109,7 +109,7 @@ void RAS_BucketManager::RenderAlphaBuckets( // it is needed for compatibility. rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED); - int drawingmode; + RAS_IRasterizer::DrawMode drawingmode; std::multiset< alphamesh, backtofront>::iterator msit = alphameshset.begin(); for (; msit != alphameshset.end(); ++msit) { diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index bff98abe058..cb10ba6bf37 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -27,6 +27,7 @@ */ #include "RAS_IPolygonMaterial.h" +#include "RAS_IRasterizer.h" #ifdef HAVE_CONFIG_H #include @@ -148,4 +149,19 @@ const unsigned int RAS_IPolyMaterial::GetFlag() const return m_flag; } +bool RAS_IPolyMaterial::UsesLighting(RAS_IRasterizer *rasty) const +{ + bool dolights = false; + + if(m_flag & RAS_BLENDERMAT) + dolights = (m_flag &RAS_MULTILIGHT)!=0; + else if(rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID); + else if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW); + else + dolights = (m_drawingmode & 16)!=0; + + return dolights; +} + unsigned int RAS_IPolyMaterial::m_newpolymatid = 0; + diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 09824f6975c..d2d1dba99d9 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -140,6 +140,8 @@ public: const STR_String& GetMaterialName() const; const STR_String& GetTextureName() const; const unsigned int GetFlag() const; + + virtual bool UsesLighting(RAS_IRasterizer *rasty) const; /* * PreCalculate texture gen diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index dbedc492afa..d4a9177a85d 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -33,12 +33,23 @@ #pragma warning (disable:4786) #endif +#include "STR_HashedString.h" + #include "MT_CmMatrix4x4.h" #include "MT_Matrix4x4.h" +#include "RAS_TexVert.h" + +#include +using namespace std; + class RAS_ICanvas; class RAS_IPolyMaterial; -#include "RAS_MaterialBucket.h" + +typedef vector KX_IndexArray; +typedef vector KX_VertexArray; +typedef vector< KX_VertexArray* > vecVertexArray; +typedef vector< KX_IndexArray* > vecIndexArrays; /** * 3D rendering device context interface. @@ -62,7 +73,18 @@ public: KX_WIREFRAME, KX_SOLID, KX_SHADED, - KX_TEXTURED + KX_TEXTURED, + KX_SHADOW + }; + + /** + * Drawing modes + */ + + enum DrawMode { + KX_MODE_LINES = 1, + KX_MODE_TRIANGLES, + KX_MODE_QUADS }; /** @@ -111,6 +133,7 @@ public: RAS_TEXCO_NORM, //< Normal coordinates RAS_TEXTANGENT, //< RAS_TEXCO_UV2, //< + RAS_TEXCO_VCOL, //< Vertex Color RAS_TEXCO_DISABLE //< Disable this texture unit (cached) }; @@ -197,45 +220,37 @@ public: * IndexPrimitives: Renders primitives. * @param vertexarrays is an array of vertex arrays * @param indexarrays is an array of index arrays - * @param mode determines the type of primitive stored in the vertex/index arrays: - * 0 triangles - * 1 lines (default) - * 2 quads - * @param polymat (reserved) + * @param mode determines the type of primitive stored in the vertex/index arrays * @param useObjectColor will render the object using @param rgbacolor instead of * vertex colors. */ - virtual void IndexPrimitives( const vecVertexArray& vertexarrays, + virtual void IndexPrimitives( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot)=0; + virtual void IndexPrimitivesMulti( + const vecVertexArray& vertexarrays, + const vecIndexArrays & indexarrays, + DrawMode mode, + bool useObjectColor, + const MT_Vector4& rgbacolor, + class KX_ListSlot** slot)=0; + /** * IndexPrimitives_3DText will render text into the polygons. * The text to be rendered is from @param rendertools client object's text property. */ virtual void IndexPrimitives_3DText( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, - int mode, + DrawMode mode, class RAS_IPolyMaterial* polymat, class RAS_IRenderTools* rendertools, bool useObjectColor, const MT_Vector4& rgbacolor)=0; - virtual void IndexPrimitivesMulti( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot)=0; - virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0; /* This one should become our final version, methinks. */ /** diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 1beade7acf7..e295d69e48e 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -167,38 +167,30 @@ RAS_MaterialBucket::T_MeshSlotList::iterator RAS_MaterialBucket::msEnd() } bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools *rendertools, int &drawmode) + RAS_IRenderTools *rendertools, RAS_IRasterizer::DrawMode &drawmode) { rendertools->SetViewMat(cameratrans); if (!rasty->SetMaterial(*m_material)) return false; - bool dolights = false; - const unsigned int flag = m_material->GetFlag(); - - if( flag & RAS_BLENDERMAT) - dolights = (flag &RAS_MULTILIGHT)!=0; + if (m_material->UsesLighting(rasty)) + rendertools->ProcessLighting(RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER/*m_material->GetLightLayer()*/); else - dolights = (m_material->GetDrawingMode()&16)!=0; - - if ((rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID) || !dolights) - { rendertools->ProcessLighting(-1); - } - else - { - rendertools->ProcessLighting(RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER/*m_material->GetLightLayer()*/); - } - drawmode = (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID ? - 1: (m_material->UsesTriangles() ? 0 : 2)); + if(rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID) + drawmode = RAS_IRasterizer::KX_MODE_LINES; + else if(m_material->UsesTriangles()) + drawmode = RAS_IRasterizer::KX_MODE_TRIANGLES; + else + drawmode = RAS_IRasterizer::KX_MODE_QUADS; return true; } void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, int drawmode) + RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, RAS_IRasterizer::DrawMode drawmode) { if (!ms.m_bVisible) return; @@ -225,6 +217,17 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa ms.m_DisplayList->SetModified(ms.m_mesh->MeshModified()); } + // verify if we can use display list, not for deformed object, and + // also don't create a new display list when drawing shadow buffers, + // then it won't have texture coordinates for actual drawing + KX_ListSlot **displaylist; + if(ms.m_pDeformer) + displaylist = 0; + else if(!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW) + displaylist = 0; + else + displaylist = &ms.m_DisplayList; + // Use the text-specific IndexPrimitives for text faces if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) { @@ -245,12 +248,9 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa ms.m_mesh->GetVertexCache(m_material), ms.m_mesh->GetIndexCache(m_material), drawmode, - m_material, - rendertools, ms.m_bObjectColor, ms.m_RGBAcolor, - (ms.m_pDeformer)? 0: &ms.m_DisplayList - ); + displaylist); } // Use the normal IndexPrimitives @@ -260,12 +260,9 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa ms.m_mesh->GetVertexCache(m_material), ms.m_mesh->GetIndexCache(m_material), drawmode, - m_material, - rendertools, // needed for textprinting on polys ms.m_bObjectColor, ms.m_RGBAcolor, - (ms.m_pDeformer)? 0: &ms.m_DisplayList - ); + displaylist); } if(rasty->QueryLists()) { @@ -287,7 +284,7 @@ void RAS_MaterialBucket::Render(const MT_Transform& cameratrans, //rasty->SetMaterial(*m_material); - int drawmode; + RAS_IRasterizer::DrawMode drawmode; for (T_MeshSlotList::const_iterator it = m_meshSlots.begin(); ! (it == m_meshSlots.end()); ++it) { diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index 5ad0c173a56..13d8a53714a 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -35,17 +35,13 @@ #include "MT_Transform.h" #include "RAS_IPolygonMaterial.h" +#include "RAS_IRasterizer.h" #include "RAS_Deformer.h" // __NLA #include #include #include using namespace std; -typedef vector KX_IndexArray; -typedef vector KX_VertexArray; -typedef vector< KX_VertexArray* > vecVertexArray; -typedef vector< KX_IndexArray* > vecIndexArrays; - /** * KX_VertexIndex */ @@ -146,9 +142,9 @@ public: const MT_Vector4& rgbavec); void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, int drawmode); + RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, RAS_IRasterizer::DrawMode drawmode); bool ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools *rendertools, int &drawmode); + RAS_IRenderTools *rendertools, RAS_IRasterizer::DrawMode& drawmode); unsigned int NumMeshSlots(); T_MeshSlotList::iterator msBegin(); diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index d7ab88a6b06..4420f16c56d 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -68,8 +68,8 @@ RAS_MeshObject::RAS_MeshObject(Mesh* mesh, int lightlayer) m_lightlayer(lightlayer), m_zsort(false), m_MeshMod(true), - m_class(0), - m_mesh(mesh) + m_mesh(mesh), + m_class(0) { } @@ -259,18 +259,18 @@ int RAS_MeshObject::FindOrAddVertex(int vtxarray, const MT_Vector3& normal, bool flat, RAS_IPolyMaterial* mat, - int orgindex) + int origindex) { - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); + KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray]; - RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, flat? TV_CALCFACENORMAL: 0); + RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, flat? TV_CALCFACENORMAL: 0,origindex); #define KX_FIND_SHARED_VERTICES #ifdef KX_FIND_SHARED_VERTICES if(!flat) { - for (std::vector::iterator it = m_xyz_index_to_vertex_index_mapping[orgindex].begin(); - it != m_xyz_index_to_vertex_index_mapping[orgindex].end(); + for (std::vector::iterator it = m_xyz_index_to_vertex_index_mapping[origindex].begin(); + it != m_xyz_index_to_vertex_index_mapping[origindex].end(); it++) { if ((*it).m_arrayindex1 == ao->m_index1 && @@ -293,22 +293,18 @@ int RAS_MeshObject::FindOrAddVertex(int vtxarray, idx.m_array = vtxarray; idx.m_index = numverts; idx.m_matid = mat; - m_xyz_index_to_vertex_index_mapping[orgindex].push_back(idx); + m_xyz_index_to_vertex_index_mapping[origindex].push_back(idx); return numverts; } - - -const vecVertexArray& RAS_MeshObject::GetVertexCache (RAS_IPolyMaterial* mat) +vecVertexArray& RAS_MeshObject::GetVertexCache (RAS_IPolyMaterial* mat) { - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); + KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); return ao->m_VertexArrayCache1; } - - int RAS_MeshObject::GetVertexArrayLength(RAS_IPolyMaterial* mat) { int len = 0; @@ -362,7 +358,7 @@ RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid, const vecIndexArrays& RAS_MeshObject::GetIndexCache (RAS_IPolyMaterial* mat) { - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]); + KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); return ao->m_IndexArrayCache1; } @@ -371,16 +367,27 @@ const vecIndexArrays& RAS_MeshObject::GetIndexCache (RAS_IPolyMaterial* mat) KX_ArrayOptimizer* RAS_MeshObject::GetArrayOptimizer(RAS_IPolyMaterial* polymat) { - KX_ArrayOptimizer** aop = (m_matVertexArrayS[*polymat]); + KX_ArrayOptimizer** aop = m_matVertexArrayS[polymat]; - if (aop) + if(aop) return *aop; + // didn't find array, but an array might already exist + // for a material equal to this one + for(int i=0;igetValue()); + if(*mat == *polymat) { + m_matVertexArrayS.insert(polymat, *m_matVertexArrayS.at(i)); + return *m_matVertexArrayS.at(i); + } + } + + // create new array int numelements = m_matVertexArrayS.size(); m_sortedMaterials.push_back(polymat); - + KX_ArrayOptimizer* ao = new KX_ArrayOptimizer(numelements); - m_matVertexArrayS.insert(*polymat,ao); + m_matVertexArrayS.insert(polymat, ao); return ao; } @@ -463,7 +470,7 @@ RAS_TexVert* RAS_MeshObject::GetVertex(short array, unsigned int index, RAS_IPolyMaterial* polymat) { - KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat);//*(m_matVertexArrays[*polymat]); + KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat); return &((*(ao->m_VertexArrayCache1)[array])[index]); } @@ -471,13 +478,19 @@ RAS_TexVert* RAS_MeshObject::GetVertex(short array, void RAS_MeshObject::ClearArrayData() { - for (int i=0;i m_matVertexArrayS; + GEN_Map m_matVertexArrayS; RAS_MaterialBucket::Set m_materials; Mesh* m_mesh; @@ -242,10 +242,10 @@ public: const MT_Vector3& normal, bool flat, RAS_IPolyMaterial* mat, - int orgindex + int origindex ); - const vecVertexArray& GetVertexCache (RAS_IPolyMaterial* mat); + vecVertexArray& GetVertexCache (RAS_IPolyMaterial* mat); int GetVertexArrayLength(RAS_IPolyMaterial* mat); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index 39080b80492..c2687319717 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -161,9 +161,7 @@ void RAS_ListRasterizer::ReleaseAlloc() void RAS_ListRasterizer::IndexPrimitives( const vecVertexArray & vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot) @@ -185,15 +183,13 @@ void RAS_ListRasterizer::IndexPrimitives( if (mUseVertexArrays) { RAS_VAOpenGLRasterizer::IndexPrimitives( vertexarrays, indexarrays, - mode, polymat, - rendertools, useObjectColor, + mode, useObjectColor, rgbacolor,slot ); } else { RAS_OpenGLRasterizer::IndexPrimitives( vertexarrays, indexarrays, - mode, polymat, - rendertools, useObjectColor, + mode, useObjectColor, rgbacolor,slot ); } @@ -208,9 +204,7 @@ void RAS_ListRasterizer::IndexPrimitives( void RAS_ListRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot) @@ -230,18 +224,19 @@ void RAS_ListRasterizer::IndexPrimitivesMulti( } } - if (mUseVertexArrays) { + // workaround: note how we do not use vertex arrays for making display + // lists, since glVertexAttribPointerARB doesn't seem to work correct + // in display lists on ATI? either a bug in the driver or in Blender .. + if (mUseVertexArrays && !localSlot) { RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( vertexarrays, indexarrays, - mode, polymat, - rendertools, useObjectColor, + mode, useObjectColor, rgbacolor,slot ); } else { RAS_OpenGLRasterizer::IndexPrimitivesMulti( vertexarrays, indexarrays, - mode, polymat, - rendertools, useObjectColor, + mode, useObjectColor, rgbacolor,slot ); } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h index 4b3304d7396..b1b19144c12 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h @@ -52,9 +52,7 @@ public: virtual void IndexPrimitives( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot @@ -63,9 +61,7 @@ public: virtual void IndexPrimitivesMulti( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 18147b53f4c..dcc36bf5a39 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -368,23 +368,11 @@ void RAS_OpenGLRasterizer::SetDrawingMode(int drawingmode) switch (m_drawingmode) { - case KX_BOUNDINGBOX: - { - } case KX_WIREFRAME: { glDisable (GL_CULL_FACE); break; } - case KX_TEXTURED: - { - } - case KX_SHADED: - { - } - case KX_SOLID: - { - } default: { } @@ -603,33 +591,14 @@ void RAS_OpenGLRasterizer::GetViewMatrix(MT_Matrix4x4 &mat) const void RAS_OpenGLRasterizer::IndexPrimitives(const vecVertexArray & vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot ) { - GLenum drawmode; - switch (mode) - { - case 0: - drawmode = GL_TRIANGLES; - break; - case 1: - drawmode = GL_LINES; - break; - case 2: - drawmode = GL_QUADS; - break; - default: - drawmode = GL_LINES; - break; - } - - const RAS_TexVert* vertexarray ; - unsigned int numindices,vt; + const RAS_TexVert* vertexarray; + unsigned int numindices, vt; for (vt=0;vtgetLocalXYZ()); - glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1()); - glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); glNormalPointer(GL_FLOAT,vtxstride,vertexarray->getNormal()); + glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1()); + if(glIsEnabled(GL_COLOR_ARRAY)) + glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); //if(m_Lock) // local->Begin(vertexarrays[vt]->size()); @@ -169,8 +166,6 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays //if(m_Lock) // local->End(); - - } glDisableClientState(GL_TEXTURE_COORD_ARRAY); @@ -178,28 +173,21 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot) { static const GLsizei vtxstride = sizeof(RAS_TexVert); + GLenum drawmode; - switch (mode) - { - case 0: - drawmode = GL_TRIANGLES; - break; - case 2: - drawmode = GL_QUADS; - break; - case 1: //lines - default: - drawmode = GL_LINES; - break; - } + if(mode == KX_MODE_TRIANGLES) + drawmode = GL_TRIANGLES; + else if(mode == KX_MODE_QUADS) + drawmode = GL_QUADS; + else + drawmode = GL_LINES; + const RAS_TexVert* vertexarray; unsigned int numindices, vt; @@ -232,10 +220,10 @@ void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexa continue; glVertexPointer(3,GL_FLOAT,vtxstride,vertexarray->getLocalXYZ()); - TexCoordPtr(vertexarray); - - glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); glNormalPointer(GL_FLOAT,vtxstride,vertexarray->getNormal()); + TexCoordPtr(vertexarray); + if(glIsEnabled(GL_COLOR_ARRAY)) + glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); //if(m_Lock) // local->Begin(vertexarrays[vt]->size()); @@ -296,19 +284,22 @@ void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv) switch(m_attrib[unit]) { case RAS_TEXCO_ORCO: case RAS_TEXCO_GLOB: - glVertexAttribPointer(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getLocalXYZ()); + glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getLocalXYZ()); break; case RAS_TEXCO_UV1: - glVertexAttribPointer(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV1()); + glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV1()); break; case RAS_TEXCO_NORM: - glVertexAttribPointer(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal()); + glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal()); break; case RAS_TEXTANGENT: - glVertexAttribPointer(unit, 4, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getTangent()); + glVertexAttribPointerARB(unit, 4, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getTangent()); break; case RAS_TEXCO_UV2: - glVertexAttribPointer(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV2()); + glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV2()); + break; + case RAS_TEXCO_VCOL: + glVertexAttribPointerARB(unit, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(RAS_TexVert), tv->getRGBA()); break; default: break; @@ -386,11 +377,12 @@ void RAS_VAOpenGLRasterizer::EnableTextures(bool enable) case RAS_TEXCO_NORM: case RAS_TEXTANGENT: case RAS_TEXCO_UV2: - if(enable) glEnableVertexAttribArray(unit); - else glDisableVertexAttribArray(unit); + case RAS_TEXCO_VCOL: + if(enable) glEnableVertexAttribArrayARB(unit); + else glDisableVertexAttribArrayARB(unit); break; default: - glDisableVertexAttribArray(unit); + glDisableVertexAttribArrayARB(unit); break; } } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h index ea08887028f..e4cc4ace0e8 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h @@ -52,9 +52,7 @@ public: virtual void IndexPrimitives( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot); @@ -62,9 +60,7 @@ public: virtual void IndexPrimitivesMulti( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, - int mode, - class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, + DrawMode mode, bool useObjectColor, const MT_Vector4& rgbacolor, class KX_ListSlot** slot); diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp index 61ac456b2bc..935633dc636 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.cpp +++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp @@ -40,7 +40,8 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz, const MT_Vector4& tangent, const unsigned int rgba, const MT_Vector3& normal, - const short flag) + const short flag, + const unsigned int origindex) { xyz.getValue(m_localxyz); uv.getValue(m_uv1); @@ -49,6 +50,7 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz, SetNormal(normal); tangent.getValue(m_tangent); m_flag = flag; + m_origindex = origindex; m_unit = 2; } @@ -107,44 +109,6 @@ void RAS_TexVert::SetNormal(const MT_Vector3& normal) normal.getValue(m_normal); } -#ifndef RAS_TexVert_INLINE - -// leave multiline for debugging -const float* RAS_TexVert::getUV1 () const -{ - return m_uv1; -} - -const float* RAS_TexVert::getUV2 () const -{ - return m_uv2; -} - - - -const float* RAS_TexVert::getNormal() const -{ - return m_normal; -} - -const float* RAS_TexVert::getTangent() const -{ - return m_tangent; -} - - -const float* RAS_TexVert::getLocalXYZ() const -{ - return m_localxyz; -} - -const unsigned char* RAS_TexVert::getRGBA() const -{ - return (unsigned char*) &m_rgba; -} - -#endif - // compare two vertices, and return TRUE if both are almost identical (they can be shared) bool RAS_TexVert::closeTo(const RAS_TexVert* other) { diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h index 84135db918f..bf092b4b230 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.h +++ b/source/gameengine/Rasterizer/RAS_TexVert.h @@ -42,8 +42,6 @@ static MT_Point2 g_pt2; #define TV_MAX 3//match Def in BL_Material.h -#define RAS_TexVert_INLINE 1 - class RAS_TexVert { @@ -55,9 +53,10 @@ class RAS_TexVert float m_normal[3]; // 3*2 = 6 short m_flag; // 2 unsigned int m_unit; // 4 + unsigned int m_origindex; // 4 //--------- - // 52 - //32 bytes total size, fits nice = 52 = not fit nice. + // 56 + // 32 bytes total size, fits nice = 56 = not fit nice. // We'll go for 64 bytes total size - 24 bytes left. public: short getFlag() const; @@ -71,11 +70,10 @@ public: const MT_Vector4& tangent, const unsigned int rgba, const MT_Vector3& normal, - const short flag); + const short flag, + const unsigned int origindex); ~RAS_TexVert() {}; - // leave multiline for debugging -#ifdef RAS_TexVert_INLINE const float* getUV1 () const { return m_uv1; }; @@ -99,13 +97,11 @@ public: const unsigned char* getRGBA() const { return (unsigned char *) &m_rgba; } -#else - const float* getUV1 () const; - const float* getUV2 () const; - const float* getNormal() const; - const float* getLocalXYZ() const; - const unsigned char* getRGBA() const; -#endif + + const unsigned int getOrigIndex() const { + return m_origindex; + } + void SetXYZ(const MT_Point3& xyz); void SetUV(const MT_Point2& uv); void SetUV2(const MT_Point2& uv); -- cgit v1.2.3 From 310a37c29c283b2a7aef0ec2e3cc7fe366b23698 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Jul 2008 14:23:19 +0000 Subject: Adding an option for action actuator - "Continue" this means animations always play from where they left off. Continue was the 2.46 operation too, so new functionality is the option to disable. When using states, an action like kick or throw can often switch out before finishing playing the action, and there was no way to play from the start frame the second time round. (even setting the actions current frame through python doesn't work work) --- source/gameengine/Converter/BL_ActionActuator.cpp | 30 ++++++++++++++++++++-- source/gameengine/Converter/BL_ActionActuator.h | 5 ++++ .../gameengine/Converter/KX_ConvertActuators.cpp | 1 + source/gameengine/PyDoc/BL_ActionActuator.py | 15 +++++++++++ 4 files changed, 49 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 44f6ec1af90..5d6dd694765 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -184,6 +184,11 @@ bool BL_ActionActuator::Update(double curtime, bool frame) if (bNegativeEvent) { + // dont continue where we left off when restarting + if (m_end_reset) { + m_flag &= ~ACT_FLAG_LOCKINPUT; + } + if (!(m_flag & ACT_FLAG_ACTIVE)) return false; m_flag &= ~ACT_FLAG_ACTIVE; @@ -472,8 +477,10 @@ PyMethodDef BL_ActionActuator::Methods[] = { {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, GetFrameProperty_doc}, {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, SetChannel_doc}, // {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS}, - {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc}, + {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc}, {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, SetType_doc}, + {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0}, + {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0}, {NULL,NULL} //Sentinel }; @@ -978,7 +985,26 @@ PyObject* BL_ActionActuator::PySetType(PyObject* self, default: printf("Invalid type for action actuator: %d\n", typeArg); /* error */ } + Py_RETURN_NONE; +} + +PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) { + return PyInt_FromLong((long)(m_end_reset==0)); +} + +PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) { + int param = PyObject_IsTrue( value ); - Py_Return; + if( param == -1 ) { + PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" ); + return NULL; + } + + if (param) { + m_end_reset = 0; + } else { + m_end_reset = 1; + } + Py_RETURN_NONE; } diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 190f727c9c3..a67b6d29b74 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -47,6 +47,7 @@ public: short playtype, short blendin, short priority, + short end_reset, float stride, PyTypeObject* T=&Type) : SCA_IActuator(gameobj,T), @@ -64,6 +65,7 @@ public: m_stridelength(stride), m_playtype(playtype), m_priority(priority), + m_end_reset(end_reset), m_pose(NULL), m_blendpose(NULL), m_userpose(NULL), @@ -101,6 +103,8 @@ public: // KX_PYMETHOD(BL_ActionActuator,GetChannel); KX_PYMETHOD_DOC(BL_ActionActuator,GetType); KX_PYMETHOD_DOC(BL_ActionActuator,SetType); + KX_PYMETHOD_NOARGS(BL_ActionActuator,GetContinue); + KX_PYMETHOD_O(BL_ActionActuator,SetContinue); virtual PyObject* _getattr(const STR_String& attr); @@ -137,6 +141,7 @@ protected: float m_stridelength; short m_playtype; short m_priority; + short m_end_reset; struct bPose* m_pose; struct bPose* m_blendpose; struct bPose* m_userpose; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 9b1bc1e6b90..1f87e9d9ac7 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -193,6 +193,7 @@ void BL_ConvertActuators(char* maggiename, actact->type, // + 1, because Blender starts to count at zero, actact->blendin, actact->priority, + actact->end_reset, actact->stridelength // Ketsji at 1, because zero is reserved for "NoDef" ); diff --git a/source/gameengine/PyDoc/BL_ActionActuator.py b/source/gameengine/PyDoc/BL_ActionActuator.py index 41f41080c31..d56888cde80 100644 --- a/source/gameengine/PyDoc/BL_ActionActuator.py +++ b/source/gameengine/PyDoc/BL_ActionActuator.py @@ -86,6 +86,14 @@ class BL_ActionActuator(SCA_IActuator): @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND @type mode: integer """ + + def setContinue(cont): + """ + Set the actions continue option True or False. see getContinue. + + @param cont: The continue option. + @type cont: bool + """ def getType(): """ @@ -94,6 +102,13 @@ class BL_ActionActuator(SCA_IActuator): @rtype: integer @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND """ + + def getContinue(): + """ + When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame. + + @rtype: bool + """ def getAction(): """ -- cgit v1.2.3 From a49c9c458aac2a738c3cf90860fb6e942747617e Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Sat, 12 Jul 2008 10:21:37 +0000 Subject: improvement of 2d-filter custom shader, some bugfixes, now you can use depth buffer and luminance buffer without any settings, also you can use object's properties in a shader --- .../BlenderRoutines/KX_BlenderRenderTools.cpp | 4 +- .../BlenderRoutines/KX_BlenderRenderTools.h | 2 +- .../gameengine/Converter/KX_ConvertActuators.cpp | 2 +- source/gameengine/Expressions/Value.cpp | 15 +- source/gameengine/Expressions/Value.h | 1 + .../gameengine/GameLogic/SCA_2DFilterActuator.cpp | 12 +- source/gameengine/GameLogic/SCA_2DFilterActuator.h | 6 +- .../GamePlayer/common/GPC_RenderTools.cpp | 4 +- .../gameengine/GamePlayer/common/GPC_RenderTools.h | 2 +- source/gameengine/Rasterizer/CMakeLists.txt | 2 + .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 186 ++++++++++++++------- source/gameengine/Rasterizer/RAS_2DFilterManager.h | 24 +-- source/gameengine/Rasterizer/RAS_IRenderTools.h | 2 +- source/gameengine/Rasterizer/SConscript | 3 +- 14 files changed, 171 insertions(+), 94 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 73d2870720a..220d174d464 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -483,9 +483,9 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void KX_BlenderRenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag) +void KX_BlenderRenderTools::Update2DFilter(vector& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) { - m_filtermanager.EnableFilter(filtermode, pass, text, texture_flag); + m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text); } void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 7748e31156d..8abce1b8c3e 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -101,7 +101,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag); + virtual void Update2DFilter(vector& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 1f87e9d9ac7..9aed5b1d510 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -1000,7 +1000,7 @@ void BL_ConvertActuators(char* maggiename, } tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, - _2dfilter->float_arg,_2dfilter->int_arg,_2dfilter->texture_flag,ketsjiEngine->GetRasterizer(),rendertools); + _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools); if (_2dfilter->text) { diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index f0195d5df82..48136eb9dc3 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -405,7 +405,20 @@ bool CValue::RemoveProperty(const STR_String & inName) return false; } - +// +// Get Property Names +// +vector CValue::GetPropertyNames() +{ + vector result; + if(!m_pNamedPropertyArray) return result; + for ( std::map::iterator it = m_pNamedPropertyArray->begin(); + !(it == m_pNamedPropertyArray->end());it++) + { + result.push_back((*it).first); + } + return result; +} // // Clear all properties diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index 561e5521d60..bcf231cf4f0 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -286,6 +286,7 @@ public: STR_String GetPropertyText(const STR_String & inName,const STR_String& deftext=""); // Get text description of property with name , returns an empty string if there is no property named float GetPropertyNumber(const STR_String& inName,float defnumber); virtual bool RemoveProperty(const STR_String & inName); // Remove the property named , returns true if the property was succesfully removed, false if property was not found or could not be removed + virtual vector GetPropertyNames(); virtual void ClearProperties(); // Clear all properties virtual void SetPropertiesModified(bool inModified); // Set all properties' modified flag to diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 56249bb52ec..96a770a553f 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -7,7 +7,6 @@ #endif #include - SCA_2DFilterActuator::~SCA_2DFilterActuator() { } @@ -18,7 +17,6 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( short flag, float float_arg, int int_arg, - short texture_flag, RAS_IRasterizer* rasterizer, RAS_IRenderTools* rendertools, PyTypeObject* T) @@ -26,11 +24,15 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( m_type(type), m_flag(flag), m_int_arg(int_arg), - m_texture_flag(texture_flag), m_float_arg(float_arg), m_rasterizer(rasterizer), m_rendertools(rendertools) { + m_gameObj = NULL; + if(gameobj){ + m_propNames = gameobj->GetPropertyNames(); + m_gameObj = gameobj; + } } void SCA_2DFilterActuator::SetShaderText(STR_String text) @@ -52,8 +54,6 @@ CValue* SCA_2DFilterActuator::GetReplica() bool SCA_2DFilterActuator::Update() { - bool result = false; - bool bNegativeEvent = IsNegativeEvent(); RemoveAllEvents(); @@ -74,7 +74,7 @@ bool SCA_2DFilterActuator::Update() } else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) { - m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText, m_texture_flag); + m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_type, m_int_arg, m_shaderText); } return true; } diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 451a7b9491a..7ec07cf5b19 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -5,18 +5,17 @@ #include "RAS_IRenderTools.h" #include "SCA_IActuator.h" - class SCA_2DFilterActuator : public SCA_IActuator { Py_Header; private: - + vector m_propNames; + void * m_gameObj; RAS_2DFilterManager::RAS_2DFILTER_MODE m_type; short m_flag; float m_float_arg; int m_int_arg; - short m_texture_flag; STR_String m_shaderText; RAS_IRasterizer* m_rasterizer; RAS_IRenderTools* m_rendertools; @@ -29,7 +28,6 @@ public: short flag, float float_arg, int int_arg, - short texture_flag, RAS_IRasterizer* rasterizer, RAS_IRenderTools* rendertools, PyTypeObject* T=&Type diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index a5017574873..8b828393c67 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -602,9 +602,9 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) } } -void GPC_RenderTools::Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag) +void GPC_RenderTools::Update2DFilter(vector& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text) { - m_filtermanager.EnableFilter(filtermode, pass, text, texture_flag); + m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text); } void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas) diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index cb7193f3513..8fae3d2b305 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -142,7 +142,7 @@ public: virtual void MotionBlur(RAS_IRasterizer* rasterizer); - virtual void Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short texture_flag); + virtual void Update2DFilter(vector& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text); virtual void Render2DFilters(RAS_ICanvas* canvas); diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt index 18a755afefd..6d53ee53471 100644 --- a/source/gameengine/Rasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/CMakeLists.txt @@ -32,6 +32,8 @@ SET(INC ../../../intern/string ../../../intern/moto/include ../../../extern/glew/include + ../Expressions + ${PYTHON_INC} ) BLENDERLIB(bf_rasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 23153fcd86c..958fead33ce 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -52,6 +52,7 @@ #include #endif +#include "Value.h" RAS_2DFilterManager::RAS_2DFilterManager(): texturewidth(-1), textureheight(-1), @@ -73,12 +74,14 @@ numberoffilters(0) m_filters[passindex] = 0; m_enabled[passindex] = 0; texflag[passindex] = 0; + m_gameObjects[passindex] = NULL; } texname[0] = texname[1] = texname[2] = -1; } RAS_2DFilterManager::~RAS_2DFilterManager() { + FreeTextures(); } unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) @@ -150,6 +153,27 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) } return 0; } +void RAS_2DFilterManager::AnalyseShader(int passindex, vector& propNames) +{ + texflag[passindex] = 0; + if(glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture") != -1) + { + texflag[passindex] |= 0x1; + } + if(glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture") != -1) + { + texflag[passindex] |= 0x2; + } + + if(m_gameObjects[passindex]) + { + int objProperties = propNames.size(); + int i; + for(i=0; iGetPropertyNumber(m_properties[passindex][i], 0.0); + glUniform1fARB(uniformLoc,value); + } + } } void RAS_2DFilterManager::EndShaderProgram() @@ -210,14 +245,21 @@ void RAS_2DFilterManager::EndShaderProgram() glUseProgramObjectARB(0); } -void RAS_2DFilterManager::SetupTexture() +void RAS_2DFilterManager::FreeTextures() { - if(texname[0]!=-1 || texname[1]!=-1) - { - glDeleteTextures(2, (GLuint*)texname); - } - glGenTextures(3, (GLuint*)texname); + if(texname[0]!=-1) + glDeleteTextures(1, (GLuint*)&texname[0]); + if(texname[1]!=-1) + glDeleteTextures(1, (GLuint*)&texname[1]); + if(texname[2]!=-1) + glDeleteTextures(1, (GLuint*)&texname[2]); +} +void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) +{ + FreeTextures(); + + glGenTextures(1, (GLuint*)&texname[0]); glBindTexture(GL_TEXTURE_2D, texname[0]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); @@ -226,23 +268,29 @@ void RAS_2DFilterManager::SetupTexture() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - glBindTexture(GL_TEXTURE_2D, texname[1]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight, 0, GL_DEPTH_COMPONENT, - GL_FLOAT,NULL); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, + if(depth){ + glGenTextures(1, (GLuint*)&texname[1]); + glBindTexture(GL_TEXTURE_2D, texname[1]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight, + 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); - - glBindTexture(GL_TEXTURE_2D, texname[2]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, texturewidth, textureheight, 0, GL_LUMINANCE, - GL_UNSIGNED_BYTE, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + } + + if(luminance){ + glGenTextures(1, (GLuint*)&texname[2]); + glBindTexture(GL_TEXTURE_2D, texname[2]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, texturewidth, textureheight, + 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + } } void RAS_2DFilterManager::UpdateOffsetMatrix(int width, int height) @@ -273,62 +321,72 @@ void RAS_2DFilterManager::UpdateOffsetMatrix(int width, int height) textureoffsets[(((i*3)+j)*2)+1] = (-1.0f * yInc) + ((GLfloat)j * yInc); } } - - SetupTexture(); } void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) { + bool need_depth=false; + bool need_luminance=false; + int num_filters = 0; + + int passindex; + if(!isshadersupported) return; + for(passindex =0; passindexGetWidth() || canvasheight != canvas->GetHeight()) { UpdateOffsetMatrix(canvas->GetWidth(), canvas->GetHeight()); + SetupTextures(need_depth, need_luminance); } GLuint viewport[4]={0}; - int passindex; - bool first = true; + if(need_depth){ + glActiveTextureARB(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, texname[1]); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, 0,0, texturewidth,textureheight, 0); + } + + if(need_luminance){ + glActiveTextureARB(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, texname[2]); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0,0, texturewidth,textureheight, 0); + } + + glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); + glViewport(0, 0, texturewidth, textureheight); + + glDisable(GL_DEPTH_TEST); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); for(passindex =0; passindex& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text) { if(!isshadersupported) return; @@ -374,16 +429,19 @@ void RAS_2DFilterManager::EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_Str glDeleteObjectARB(m_filters[pass]); m_enabled[pass] = 0; m_filters[pass] = 0; + m_gameObjects[pass] = NULL; + m_properties[pass].clear(); texflag[pass] = 0; return; } if(mode == RAS_2DFILTER_CUSTOMFILTER) { - texflag[pass] = tflag; if(m_filters[pass]) glDeleteObjectARB(m_filters[pass]); m_filters[pass] = CreateShaderProgram(text.Ptr()); + m_gameObjects[pass] = gameObj; + AnalyseShader(pass, propNames); m_enabled[pass] = 1; return; } diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index faf7c652388..9d8326b96de 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -28,8 +28,6 @@ #ifndef __RAS_I2DFILTER #define __RAS_I2DFILTER - - #define MAX_RENDER_PASS 100 class RAS_2DFilterManager @@ -37,9 +35,15 @@ class RAS_2DFilterManager private: unsigned int CreateShaderProgram(char* shadersource); unsigned int CreateShaderProgram(int filtermode); + void AnalyseShader(int passindex, vector& propNames); void StartShaderProgram(int passindex); void EndShaderProgram(); + void SetupTextures(bool depth, bool luminance); + void FreeTextures(); + + void UpdateOffsetMatrix(int width, int height); + float textureoffsets[18]; float view[4]; /* texname[0] contains render to texture, texname[1] contains depth texture, texname[2] contains luminance texture*/ @@ -54,6 +58,13 @@ private: short texflag[MAX_RENDER_PASS]; bool isshadersupported; + + unsigned int m_filters[MAX_RENDER_PASS]; + short m_enabled[MAX_RENDER_PASS]; + + // stores object properties to send to shaders in each pass + vector m_properties[MAX_RENDER_PASS]; + void* m_gameObjects[MAX_RENDER_PASS]; public: enum RAS_2DFILTER_MODE { RAS_2DFILTER_ENABLED = -2, @@ -74,19 +85,12 @@ public: RAS_2DFILTER_NUMBER_OF_FILTERS }; - unsigned int m_filters[MAX_RENDER_PASS]; - short m_enabled[MAX_RENDER_PASS]; - RAS_2DFilterManager(); ~RAS_2DFilterManager(); - void SetupTexture(); - - void UpdateOffsetMatrix(int width, int height); - void RenderFilters(RAS_ICanvas* canvas); - void EnableFilter(RAS_2DFILTER_MODE mode, int pass, STR_String& text, short tflag); + void EnableFilter(vector& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text); }; #endif diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index 781f90d4124..54a663ba111 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -185,7 +185,7 @@ public: virtual void - Update2DFilter(RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text, short textureflag)=0; + Update2DFilter(vector& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0; virtual void diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index f077833b850..e6bc657ed6d 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -7,7 +7,8 @@ if env['WITH_BF_GLEXT'] == 1: env['CPPFLAGS'].append('-DWITH_GLEXT') -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include' +incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions' +incs += ' ' + env['BF_PYTHON_INC'] if env['OURPLATFORM']=='win32-vc': cflags = [] -- cgit v1.2.3 From 572f1d88d2116bb87abd8173ab4971ab6dfdcc24 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 12 Jul 2008 12:10:27 +0000 Subject: BGE bug fix (good for 2.47): automatic detection that target object of AddObject actuator is being deleted to avoid crash (bad game design anyway) --- .../gameengine/Converter/KX_ConvertActuators.cpp | 2 +- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 39 +++++++++++++++++++--- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.h | 10 ++++-- 3 files changed, 43 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 9aed5b1d510..1cc1b2e27a3 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -539,7 +539,7 @@ void BL_ConvertActuators(char* maggiename, // does the 'original' for replication exists, and // is it in a non-active layer ? - CValue* originalval = NULL; + SCA_IObject* originalval = NULL; if (editobact->ob && !(editobact->ob->lay & activeLayerBitInfo)) originalval = converter->FindGameObject(editobact->ob); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 76ce086ab97..e5ee4cbddf1 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -48,7 +48,7 @@ /* ------------------------------------------------------------------------- */ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj, - CValue* original, + SCA_IObject *original, int time, SCA_IScene* scene, const MT_Vector3& linvel, @@ -61,6 +61,9 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj, m_linear_velocity(linvel), m_localFlag(local) { + if (m_OriginalObject) + m_OriginalObject->RegisterActuator(this); + m_lastCreatedObject = NULL; m_timeProp = time; } @@ -69,6 +72,8 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj, KX_SCA_AddObjectActuator::~KX_SCA_AddObjectActuator() { + if (m_OriginalObject) + m_OriginalObject->UnregisterActuator(this); if (m_lastCreatedObject) m_lastCreatedObject->Release(); } @@ -108,12 +113,29 @@ CValue* KX_SCA_AddObjectActuator::GetReplica() // this will copy properties and so on... replica->ProcessReplica(); - replica->m_lastCreatedObject=NULL; CValue::AddDataToReplica(replica); return replica; } +void KX_SCA_AddObjectActuator::ProcessReplica() +{ + if (m_OriginalObject) + m_OriginalObject->RegisterActuator(this); + m_lastCreatedObject=NULL; + SCA_IActuator::ProcessReplica(); +} + +bool KX_SCA_AddObjectActuator::UnlinkObject(SCA_IObject* clientobj) +{ + if (clientobj == m_OriginalObject) + { + // this object is being deleted, we cannot continue to track it. + m_OriginalObject = NULL; + return true; + } + return false; +} /* ------------------------------------------------------------------------- */ @@ -181,7 +203,11 @@ PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self, PyObject* gameobj; if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) { - m_OriginalObject = (CValue*)gameobj; + if (m_OriginalObject != NULL) + m_OriginalObject->UnregisterActuator(this); + m_OriginalObject = (SCA_IObject*)gameobj; + if (m_OriginalObject) + m_OriginalObject->RegisterActuator(this); Py_Return; } PyErr_Clear(); @@ -189,8 +215,11 @@ PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self, char* objectname; if (PyArg_ParseTuple(args, "s", &objectname)) { - m_OriginalObject= (CValue*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));; - + if (m_OriginalObject != NULL) + m_OriginalObject->UnregisterActuator(this); + m_OriginalObject = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));; + if (m_OriginalObject) + m_OriginalObject->RegisterActuator(this); Py_Return; } diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 2126a646303..42123b94a68 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -53,7 +53,7 @@ class KX_SCA_AddObjectActuator : public SCA_IActuator int m_timeProp; /// Original object reference (object to replicate) - CValue* m_OriginalObject; + SCA_IObject* m_OriginalObject; /// Object will be added to the following scene SCA_IScene* m_scene; @@ -75,7 +75,7 @@ public: KX_SCA_AddObjectActuator( SCA_IObject *gameobj, - CValue* original, + SCA_IObject *original, int time, SCA_IScene* scene, const MT_Vector3& linvel, @@ -89,6 +89,12 @@ public: GetReplica( ) ; + virtual void + ProcessReplica(); + + virtual bool + UnlinkObject(SCA_IObject* clientobj); + virtual bool Update(); -- cgit v1.2.3 From 38cfe9c1a20ae98e9fed46b523d2464d8e8cc69b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Jul 2008 00:47:07 +0000 Subject: importing the GameLogic module was being done by adding the text "import GameLogic" to the start of all scripts used in the game engine, this meant every error line number was off by 1 (quite annoying). better to do this to the dictionary that the scripts run with. --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 11 ++++++++++- source/gameengine/GameLogic/SCA_PythonController.cpp | 14 +++++++++----- source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 2 +- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 5 ++++- source/gameengine/Ketsji/KX_PythonInit.cpp | 13 +------------ source/gameengine/Ketsji/KX_PythonInit.h | 1 - source/gameengine/Ketsji/KX_SoundActuator.cpp | 3 ++- 7 files changed, 27 insertions(+), 22 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 4af5ac4d5d2..b3a3a47152a 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -332,6 +332,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(rasterizer, canvas); PyObject *gameLogic = initGameLogic(startscene); + PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module. initGameKeys(); initPythonConstraintBinding(); @@ -399,7 +400,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, exitstring = ketsjiengine->GetExitString(); // when exiting the mainloop - dictionaryClearByHand(gameLogic); + + // Clears the dictionary by hand: + // This prevents, extra references to global variables + // inside the GameLogic dictionary when the python interpreter is finalized. + // which allows the scene to safely delete them :) + // see: (space.c)->start_game + PyDict_Clear(PyModule_GetDict(gameLogic)); + ketsjiengine->StopEngine(); exitGamePythonScripting(); networkdevice->Disconnect(); @@ -591,6 +599,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(rasterizer, canvas); PyObject *gameLogic = initGameLogic(startscene); + PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 76386079bdf..01ae4072335 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -116,7 +116,7 @@ CValue* SCA_PythonController::GetReplica() void SCA_PythonController::SetScriptText(const STR_String& text) { - m_scriptText = "import GameLogic\n" + text; + m_scriptText = text; m_bModified = true; } @@ -354,8 +354,10 @@ SCA_PythonController::PyGetSensor(PyObject* self, PyObject* value) return sensor->AddRef(); } } - - PyErr_SetString(PyExc_AttributeError, "Unable to find requested sensor"); + + char emsg[96]; + PyOS_snprintf( emsg, sizeof( emsg ), "Unable to find requested sensor \"%s\"", scriptArg ); + PyErr_SetString(PyExc_AttributeError, emsg); return NULL; } @@ -382,8 +384,10 @@ SCA_PythonController::PyGetActuator(PyObject* self, PyObject* value) return actua->AddRef(); } } - - PyErr_SetString(PyExc_AttributeError, "Unable to find requested actuator"); + + char emsg[96]; + PyOS_snprintf( emsg, sizeof( emsg ), "Unable to find requested actuator \"%s\"", scriptArg ); + PyErr_SetString(PyExc_AttributeError, emsg); return NULL; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index d6908b53d40..b5ebffb9378 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -644,7 +644,7 @@ bool GPG_Application::startEngine(void) PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest); m_ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(m_rasterizer, m_canvas); - PyObject *gameLogic = initGameLogic(startscene); + PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 20187a193ba..db099d56b55 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -231,7 +231,10 @@ void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer) } - +/* + * At the moment the GameLogic module is imported into 'pythondictionary' after this function is called. + * if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand. + */ void KX_KetsjiEngine::SetPythonDictionary(PyObject* pythondictionary) { MT_assert(pythondictionary); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 433e0636833..61ed8b6a8e4 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -828,20 +828,9 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook Py_FatalError("can't initialize module GameLogic"); } - return d; + return m; } -void dictionaryClearByHand(PyObject *dict) -{ - // Clears the dictionary by hand: - // This prevents, extra references to global variables - // inside the GameLogic dictionary when the python interpreter is finalized. - // which allows the scene to safely delete them :) - // see: (space.c)->start_game - if(dict) PyDict_Clear(dict); -} - - // Python Sandbox code // override builtin functions import() and open() diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index c7d8f1b78bc..41cf7fd67b3 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -47,7 +47,6 @@ PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level); void exitGamePythonScripting(); -void dictionaryClearByHand(PyObject *dict); void PHY_SetActiveScene(class KX_Scene* scene); class KX_Scene* PHY_GetActiveScene(); diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index 949156571a7..34a3baec093 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -291,7 +291,8 @@ PyObject* KX_SoundActuator::PyGetFilename(PyObject* self, PyObject* args, PyObje char* name = objectname.Ptr(); if (!name) { - Py_Return; /* internal error */ + PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename"); + return NULL; } else return PyString_FromString(name); } -- cgit v1.2.3 From 4c48b4846e9ce8e639a28b9601a905ba9bedb72a Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Tue, 15 Jul 2008 18:12:08 +0000 Subject: Updated so things compile. (Missing includes needed) Kent --- source/gameengine/Rasterizer/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile index 1ca3e3b0283..e3b1f274ee5 100644 --- a/source/gameengine/Rasterizer/Makefile +++ b/source/gameengine/Rasterizer/Makefile @@ -41,6 +41,9 @@ CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../kernel/gen_system CPPFLAGS += -I../BlenderRoutines +CPPFLAGS += -I../Expressions + +CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings -- cgit v1.2.3 From e433719f51b025c8424965ceddb5bb33686fa470 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 15 Jul 2008 18:57:10 +0000 Subject: BGE bug fix (good for 2.47): radar and near sensor did not filter correctly the collisioning objects based on ACTOR flag when the parent object was added dynamically. This could result in a very big performance decrease. --- source/gameengine/Ketsji/KX_NearSensor.cpp | 4 +--- source/gameengine/Ketsji/KX_RadarSensor.cpp | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index d69871275b9..89699d80031 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -135,9 +135,6 @@ CValue* KX_NearSensor::GetReplica() void KX_NearSensor::ReParent(SCA_IObject* parent) { - - SCA_ISensor::ReParent(parent); - m_client_info->m_gameobject = static_cast(parent); m_client_info->m_sensors.push_back(this); @@ -151,6 +148,7 @@ void KX_NearSensor::ReParent(SCA_IObject* parent) */ ((KX_GameObject*)GetParent())->GetSGNode()->ComputeWorldTransforms(NULL); SynchronizeTransform(); + SCA_ISensor::ReParent(parent); } diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 987e0b946b2..9dab09f8f2a 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -92,6 +92,10 @@ CValue* KX_RadarSensor::GetReplica() if (replica->m_physCtrl) { replica->m_physCtrl = replica->m_physCtrl->GetReplica(); + if (replica->m_physCtrl) + { + replica->m_physCtrl->setNewClientInfo(replica->m_client_info); + } } //todo: make sure replication works fine! -- cgit v1.2.3 From 7afacb6ea86ffd3de726f93086ba3fedca428352 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 15 Jul 2008 20:05:23 +0000 Subject: BGE patch: DUPLIGROUP option supported in BGE. Blender duplicates groups in the 3D view at the location of objects having the DUPLIGROUP option set. This feature is now supported in the BGE: the groups will be instantiated as in the 3D view when the scene is converted. This is useful to populate a scene with multiple enemies without having to actually duplicate the objects in the blend file. Notes: * The BGE applies the same criteria to instantiate the group as Blender to display them: if you see the group in the 3D view, it will be instantiated in the BGE. * Groups are instantiated as if the object having the DUPLIGROUP option (usually an empty) executed an AddObject actuator on the top objects of the group (objects without parent). * As a result, only intra-group parent relationship is supported: the BGE will not instantiate objects that have parents outside the group. * Intra-group logic bricks connections are preserved between the duplicated objects, even between the top objects of the group. * For best result, the state engine of the objects in the group should be self-contained: logic bricks should only have intra-group connections. Use messages to communicate with state engines outside the group. * Nested groups are supported: if one or more objects in the group have the DUPLIGROUP option set, the corresponding groups will be instantiated at the corresponding position and orientation. * Nested groups are instantiated as separate groups, not as one big group. * Linked groups are supported as well as groups containing objects from the active layers. * There is a difference in the way Blender displays the groups in the 3D view and how BGE instantiates them: Blender does not take into account the parent relationship in the group and displays the objects as if they were all children of the object having the DUPLIGROUP option. That's correct for the top objects of the group but not for the children. Hence the orientation of the children objects may be different in the BGE. * An AddGroup actuator will be added in a future release. --- .../Converter/BL_BlenderDataConversion.cpp | 243 +++++++++++++++++++-- source/gameengine/Ketsji/KX_GameObject.h | 8 + source/gameengine/Ketsji/KX_RadarSensor.cpp | 5 +- source/gameengine/Ketsji/KX_Scene.cpp | 124 +++++++++++ source/gameengine/Ketsji/KX_Scene.h | 1 + 5 files changed, 361 insertions(+), 20 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index f3e22cd297a..1f1ac6da119 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1847,7 +1847,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie, int aspect_width; int aspect_height; vector inivel,iniang; - + set grouplist; // list of groups to be converted + set allblobj; // all objects converted + set groupobj; // objects from groups (never in active layer) + if (alwaysUseExpandFraming) { frame_type = RAS_FrameSettings::e_frame_extend; aspect_width = canvas->GetWidth(); @@ -1919,6 +1922,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for (SETLOOPER(blenderscene, base)) { Object* blenderobject = base->object; + allblobj.insert(blenderobject); + KX_GameObject* gameobj = gameobject_from_blenderobject( base->object, kxscene, @@ -2046,7 +2051,9 @@ void BL_ConvertBlenderObjects(struct Main* maggie, gameobj->NodeUpdateGS(0,true); gameobj->Bucketize(); - + + if (gameobj->IsDupliGroup()) + grouplist.insert(blenderobject->dup_group); } else { @@ -2073,6 +2080,188 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } + if (!grouplist.empty()) + { + // now convert the group referenced by dupli group object + // keep track of all groups already converted + set allgrouplist = grouplist; + set tempglist; + // recurse + while (!grouplist.empty()) + { + set::iterator git; + tempglist.clear(); + tempglist.swap(grouplist); + for (git=tempglist.begin(); git!=tempglist.end(); git++) + { + Group* group = *git; + GroupObject* go; + for(go=(GroupObject*)group->gobject.first; go; go=(GroupObject*)go->next) + { + Object* blenderobject = go->ob; + if (converter->FindGameObject(blenderobject) == NULL) + { + allblobj.insert(blenderobject); + groupobj.insert(blenderobject); + KX_GameObject* gameobj = gameobject_from_blenderobject( + blenderobject, + kxscene, + rendertools, + converter, + blenderscene); + + // this code is copied from above except that + // object from groups are never is active layer + bool isInActiveLayer = false; + bool addobj=true; + + if (converter->addInitFromFrame) + if (!isInActiveLayer) + addobj=false; + + if (gameobj&&addobj) + { + MT_Point3 posPrev; + MT_Matrix3x3 angor; + if (converter->addInitFromFrame) + blenderscene->r.cfra=blenderscene->r.sfra; + + MT_Point3 pos = MT_Point3( + blenderobject->loc[0]+blenderobject->dloc[0], + blenderobject->loc[1]+blenderobject->dloc[1], + blenderobject->loc[2]+blenderobject->dloc[2] + ); + MT_Vector3 eulxyz = MT_Vector3( + blenderobject->rot[0], + blenderobject->rot[1], + blenderobject->rot[2] + ); + MT_Vector3 scale = MT_Vector3( + blenderobject->size[0], + blenderobject->size[1], + blenderobject->size[2] + ); + if (converter->addInitFromFrame){//rcruiz + float eulxyzPrev[3]; + blenderscene->r.cfra=blenderscene->r.sfra-1; + update_for_newframe(); + MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0], + blenderobject->loc[1]+blenderobject->dloc[1], + blenderobject->loc[2]+blenderobject->dloc[2] + ); + eulxyzPrev[0]=blenderobject->rot[0]; + eulxyzPrev[1]=blenderobject->rot[1]; + eulxyzPrev[2]=blenderobject->rot[2]; + + double fps = (double) blenderscene->r.frs_sec/ + (double) blenderscene->r.frs_sec_base; + + tmp.scale(fps, fps, fps); + inivel.push_back(tmp); + tmp=eulxyz-eulxyzPrev; + tmp.scale(fps, fps, fps); + iniang.push_back(tmp); + blenderscene->r.cfra=blenderscene->r.sfra; + update_for_newframe(); + } + + gameobj->NodeSetLocalPosition(pos); + gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz)); + gameobj->NodeSetLocalScale(scale); + gameobj->NodeUpdateGS(0,true); + + BL_ConvertIpos(blenderobject,gameobj,converter); + // TODO: expand to multiple ipos per mesh + Material *mat = give_current_material(blenderobject, 1); + if(mat) BL_ConvertMaterialIpos(mat, gameobj, converter); + + sumolist->Add(gameobj->AddRef()); + + BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer); + + + gameobj->SetName(blenderobject->id.name); + + // templist to find Root Parents (object with no parents) + templist->Add(gameobj->AddRef()); + + // update children/parent hierarchy + if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame)) + { + // blender has an additional 'parentinverse' offset in each object + SG_Node* parentinversenode = new SG_Node(NULL,NULL,SG_Callbacks()); + + // define a normal parent relationship for this node. + KX_NormalParentRelation * parent_relation = KX_NormalParentRelation::New(); + parentinversenode->SetParentRelation(parent_relation); + + parentChildLink pclink; + pclink.m_blenderchild = blenderobject; + pclink.m_gamechildnode = parentinversenode; + vec_parent_child.push_back(pclink); + + float* fl = (float*) blenderobject->parentinv; + MT_Transform parinvtrans(fl); + parentinversenode->SetLocalPosition(parinvtrans.getOrigin()); + parentinversenode->SetLocalOrientation(parinvtrans.getBasis()); + + parentinversenode->AddChild(gameobj->GetSGNode()); + } + + // needed for python scripting + logicmgr->RegisterGameObjectName(gameobj->GetName(),gameobj); + + // needed for dynamic object morphing + logicmgr->RegisterGameObj(gameobj, blenderobject); + for (int i = 0; i < gameobj->GetMeshCount(); i++) + logicmgr->RegisterGameMeshName(gameobj->GetMesh(i)->GetName(), blenderobject); + + converter->RegisterGameObject(gameobj, blenderobject); + // this was put in rapidly, needs to be looked at more closely + // only draw/use objects in active 'blender' layers + + logicbrick_conversionlist->Add(gameobj->AddRef()); + + if (converter->addInitFromFrame){ + posPrev=gameobj->NodeGetWorldPosition(); + angor=gameobj->NodeGetWorldOrientation(); + } + if (isInActiveLayer) + { + objectlist->Add(gameobj->AddRef()); + //tf.Add(gameobj->GetSGNode()); + + gameobj->NodeUpdateGS(0,true); + gameobj->Bucketize(); + + } + else + { + //we must store this object otherwise it will be deleted + //at the end of this function if it is not a root object + inactivelist->Add(gameobj->AddRef()); + + } + if (gameobj->IsDupliGroup()) + { + // check that the group is not already converted + if (allgrouplist.insert(blenderobject->dup_group).second) + grouplist.insert(blenderobject->dup_group); + } + if (converter->addInitFromFrame){ + gameobj->NodeSetLocalPosition(posPrev); + gameobj->NodeSetLocalOrientation(angor); + } + + } + if (gameobj) + gameobj->Release(); + } + } + } + } + } + if (blenderscene->camera) { KX_Camera *gamecamera= (KX_Camera*) converter->FindGameObject(blenderscene->camera); @@ -2081,15 +2270,18 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } // Set up armatures - for(SETLOOPER(blenderscene, base)){ - if (base->object->type==OB_MESH){ - Mesh *me = (Mesh*)base->object->data; + set::iterator oit; + for(oit=allblobj.begin(); oit!=allblobj.end(); oit++) + { + Object* blenderobj = *oit; + if (blenderobj->type==OB_MESH){ + Mesh *me = (Mesh*)blenderobj->data; if (me->dvert){ - KX_GameObject *obj = converter->FindGameObject(base->object); + KX_GameObject *obj = converter->FindGameObject(blenderobj); - if (base->object->parent && base->object->parent->type==OB_ARMATURE && base->object->partype==PARSKEL){ - KX_GameObject *par = converter->FindGameObject(base->object->parent); + if (obj && blenderobj->parent && blenderobj->parent->type==OB_ARMATURE && blenderobj->partype==PARSKEL){ + KX_GameObject *par = converter->FindGameObject(blenderobj->parent); if (par) ((BL_SkinDeformer*)(((BL_DeformableGameObject*)obj)->m_pDeformer))->SetArmature((BL_ArmatureObject*) par); } @@ -2174,7 +2366,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { meshobj = gameobj->GetMesh(0); } - BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,activeLayerBitInfo,physics_engine,converter,processCompoundChildren); + int layerMask = (groupobj.find(blenderobject) == groupobj.end()) ? activeLayerBitInfo : 0; + BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,physics_engine,converter,processCompoundChildren); } processCompoundChildren = true; @@ -2189,7 +2382,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { meshobj = gameobj->GetMesh(0); } - BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,activeLayerBitInfo,physics_engine,converter,processCompoundChildren); + int layerMask = (groupobj.find(blenderobject) == groupobj.end()) ? activeLayerBitInfo : 0; + BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,physics_engine,converter,processCompoundChildren); } @@ -2311,22 +2505,25 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); struct Object* blenderobj = converter->FindBlenderObject(gameobj); - bool isInActiveLayer = (blenderobj->lay & activeLayerBitInfo)!=0; - BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,executePriority, activeLayerBitInfo,isInActiveLayer,rendertools,converter); + int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; + bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; + BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,executePriority, layerMask,isInActiveLayer,rendertools,converter); } for ( i=0;iGetCount();i++) { KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); struct Object* blenderobj = converter->FindBlenderObject(gameobj); - bool isInActiveLayer = (blenderobj->lay & activeLayerBitInfo)!=0; - BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,executePriority,activeLayerBitInfo,isInActiveLayer,converter); + int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; + bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; + BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,executePriority,layerMask,isInActiveLayer,converter); } for ( i=0;iGetCount();i++) { KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); struct Object* blenderobj = converter->FindBlenderObject(gameobj); - bool isInActiveLayer = (blenderobj->lay & activeLayerBitInfo)!=0; - BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,keydev,executePriority,activeLayerBitInfo,isInActiveLayer,canvas,converter); + int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; + bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; + BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,keydev,executePriority,layerMask,isInActiveLayer,canvas,converter); } // apply the initial state to controllers for ( i=0;iGetCount();i++) @@ -2344,5 +2541,19 @@ void BL_ConvertBlenderObjects(struct Main* maggie, // Calculate the scene btree - // too slow - commented out. //kxscene->SetNodeTree(tf.MakeTree()); + + // instantiate dupli group, we will loop trough the object + // that are in active layers. Note that duplicating group + // has the effect of adding objects at the end of objectlist. + // Only loop through the first part of the list. + int objcount = objectlist->GetCount(); + for (i=0;iGetValue(i); + if (gameobj->IsDupliGroup()) + { + kxscene->DupliGroupRecurse(gameobj, 0); + } + } } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index ddbf863aa1a..eba154e1094 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -47,6 +47,7 @@ #include "KX_Scene.h" #include "KX_KetsjiEngine.h" /* for m_anim_framerate */ #include "KX_IPhysicsController.h" /* for suspend/resume */ +#include "DNA_object_types.h" #define KX_OB_DYNAMIC 1 @@ -392,6 +393,13 @@ public: m_pBlenderObject = obj; } + bool IsDupliGroup() + { + return (m_pBlenderObject && + (m_pBlenderObject->transflag & OB_DUPLIGROUP) && + m_pBlenderObject->dup_group != NULL) ? true : false; + } + /** * Set the Scene graph node for this game object. * warning - it is your responsibility to make sure diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 9dab09f8f2a..bf2ba18f490 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -80,10 +80,7 @@ CValue* KX_RadarSensor::GetReplica() { KX_RadarSensor* replica = new KX_RadarSensor(*this); replica->m_colliders = new CListValue(); - replica->m_bCollision = false; - replica->m_bTriggered= false; - replica->m_hitObject = NULL; - replica->m_bLastTriggered = false; + replica->Init(); // this will copy properties and so on... CValue::AddDataToReplica(replica); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 065800379d8..560333bd5cb 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -66,6 +66,8 @@ #include "SG_Controller.h" #include "SG_IObject.h" #include "SG_Tree.h" +#include "DNA_group_types.h" +#include "BKE_anim.h" #include "KX_SG_NodeRelationships.h" @@ -605,6 +607,128 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) newobj->ResetState(); } +void KX_Scene::DupliGroupRecurse(CValue* obj, int level) +{ + KX_GameObject* groupobj = (KX_GameObject*) obj; + KX_GameObject* replica; + Object* blgroupobj = groupobj->GetBlenderObject(); + Group* group; + GroupObject *go; + vector duplilist; + + if (!groupobj->IsDupliGroup() || + level>MAX_DUPLI_RECUR) + return; + + // we will add one group at a time + m_logicHierarchicalGameObjects.clear(); + m_map_gameobject_to_replica.clear(); + m_ueberExecutionPriority++; + + group = blgroupobj->dup_group; + for(go=(GroupObject*)group->gobject.first; go; go=(GroupObject*)go->next) + { + Object* blenderobj = go->ob; + if (blgroupobj == blenderobj) + // this check is also in group_duplilist() + continue; + KX_GameObject* gameobj = m_sceneConverter->FindGameObject(blenderobj); + if (gameobj == NULL) + { + // this object has not been converted!!! + // Should not happen as dupli group are created automatically + continue; + } + if (gameobj->GetParent() != NULL) + { + // this object is not a top parent. Either it is the child of another + // object in the group and it will be added automatically when the parent + // is added. Or it is the child of an object outside the group and the group + // is inconsistent, skip it anyway + continue; + } + if (blenderobj->lay & group->layer==0) + { + // object is not visible in the 3D view, will not be instantiated + continue; + } + replica = (KX_GameObject*) AddNodeReplicaObject(NULL,gameobj); + // add to 'rootparent' list (this is the list of top hierarchy objects, updated each frame) + m_parentlist->Add(replica->AddRef()); + + // recurse replication into children nodes + NodeList& children = gameobj->GetSGNode()->GetSGChildren(); + + replica->GetSGNode()->ClearSGChildren(); + for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit) + { + SG_Node* orgnode = (*childit); + SG_Node* childreplicanode = orgnode->GetSGReplica(); + replica->GetSGNode()->AddChild(childreplicanode); + } + // don't replicate logic now: we assume that the objects in the group can have + // logic relationship, even outside parent relationship + + MT_Point3 newpos = groupobj->NodeGetWorldPosition(); + replica->NodeSetLocalPosition(newpos); + + MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation(); + replica->NodeSetLocalOrientation(newori); + + // get the rootnode's scale + MT_Vector3 newscale = groupobj->GetSGNode()->GetRootSGParent()->GetLocalScale(); + + // set the replica's relative scale with the rootnode's scale + replica->NodeSetRelativeScale(newscale); + + if (replica->GetPhysicsController()) + { + replica->GetPhysicsController()->setPosition(newpos); + replica->GetPhysicsController()->setOrientation(newori.getRotation()); + replica->GetPhysicsController()->setScaling(newscale); + } + + replica->GetSGNode()->UpdateWorldData(0); + replica->GetSGNode()->SetBBox(gameobj->GetSGNode()->BBox()); + replica->GetSGNode()->SetRadius(gameobj->GetSGNode()->Radius()); + // done with replica + replica->Release(); + } + + // relink any pointers as necessary, sort of a temporary solution + vector::iterator git; + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { + (*git)->Relink(&m_map_gameobject_to_replica); + // add the object in the layer of the parent + (*git)->SetLayer(groupobj->GetLayer()); + } + + // now replicate logic + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { + (*git)->ReParentLogic(); + } + + // replicate crosslinks etc. between logic bricks + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { + ReplicateLogic((*git)); + } + + // now look if object in the hierarchy have dupli group and recurse + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { + if ((*git) != groupobj && (*git)->IsDupliGroup()) + // can't instantiate group immediately as it destroys m_logicHierarchicalGameObjects + duplilist.push_back((*git)); + } + + for (git = duplilist.begin(); !(git == duplilist.end()); ++git) + { + DupliGroupRecurse((*git), level+1); + } +} SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 28dee1b5893..374545f9a90 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -291,6 +291,7 @@ public: * Update all transforms according to the scenegraph. */ void UpdateParents(double curtime); + void DupliGroupRecurse(CValue* gameobj, int level); SCA_IObject* AddReplicaObject(CValue* gameobj, CValue* locationobj, int lifespan=0); -- cgit v1.2.3 From dbfc5f6b7110031a82da4482d62ed8b36873b369 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 16 Jul 2008 21:24:54 +0000 Subject: BGE patch: fix mesh deformation errors with duplicated objects sharing the same mesh in case of 1) armature+multiple material 2) shape drivers --- source/gameengine/Converter/BL_ShapeDeformer.cpp | 7 ++++ source/gameengine/Converter/BL_SkinDeformer.cpp | 48 ++++++++++++------------ source/gameengine/Converter/BL_SkinDeformer.h | 6 ++- 3 files changed, 36 insertions(+), 25 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index eb5c1467ea5..b2e54539b19 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -109,6 +109,13 @@ bool BL_ShapeDeformer::ExecuteShapeDrivers(void) vector::iterator it; void *poin; int type; + // the shape drivers use the bone matrix as input. Must + // update the matrix now + Object* par_arma = m_armobj->GetArmatureObject(); + m_armobj->ApplyPose(); + where_is_pose( par_arma ); + PoseApplied(true); + for (it=m_shapeDrivers.begin(); it!=m_shapeDrivers.end(); it++) { // no need to set a specific time: this curve has a driver IpoCurve *icu = *it; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index d3442fe5298..f96c40c098f 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -66,7 +66,8 @@ BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj, m_armobj(arma), m_lastArmaUpdate(-1), m_defbase(&bmeshobj->defbase), - m_releaseobject(false) + m_releaseobject(false), + m_poseApplied(false) { Mat4CpyMat4(m_obmat, bmeshobj->obmat); }; @@ -98,32 +99,28 @@ BL_SkinDeformer::~BL_SkinDeformer() m_armobj->Release(); } -bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *) +bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) { size_t i, j; - if (!Update()) - // no need to update the cache - return false; + // update the vertex in m_transverts + Update(); - // Update all materials at once, so we can do the above update test - // without ending up with some materials not updated - for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); - mit != m_pMeshObject->GetLastMaterial(); ++ mit) { - RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); + // The vertex cache can only be updated for this deformer: + // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) + // share the same mesh (=the same cache). As the rendering is done per polymaterial + // cycling through the objects, the entire mesh cache cannot be updated in one shot. + vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); - vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); + // For each array + for (i=0; iGetArmatureObject(); - where_is_pose( par_arma ); + if (!PoseApplied()){ + m_armobj->ApplyPose(); + where_is_pose( par_arma ); + } /* store verts locally */ VerifyStorage(); @@ -180,7 +179,8 @@ bool BL_SkinDeformer::Update(void) /* Update the current frame */ m_lastArmaUpdate=m_armobj->GetLastFrame(); - + /* reset for next frame */ + PoseApplied(false); /* indicate that the m_transverts and normals are up to date */ return true; } diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index f35db8273c4..d3fc5ae2a81 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -81,10 +81,13 @@ public: virtual ~BL_SkinDeformer(); bool Update (void); bool Apply (class RAS_IPolyMaterial *polymat); + bool PoseApplied() + { return m_poseApplied; } + void PoseApplied(bool applied) + { m_poseApplied = applied; } bool PoseUpdated(void) { if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) { - m_armobj->ApplyPose(); return true; } return false; @@ -102,6 +105,7 @@ protected: ListBase* m_defbase; float m_obmat[4][4]; // the reference matrix for skeleton deform bool m_releaseobject; + bool m_poseApplied; }; -- cgit v1.2.3 From 5848fee125790e1d8f28dd13d5b4809687d7375f Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 17 Jul 2008 12:29:42 +0000 Subject: BGE bug fix (good for 2.47): fix logic reconnection after replication. The old method was matching the bricks by name assuming they are unique but it is not always the case, especially with the new dupligroup feature. The new method matches the bricks by objects and position. --- source/gameengine/Ketsji/KX_Scene.cpp | 100 ++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 48 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 560333bd5cb..ffb39bc0fb6 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -508,6 +508,11 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal // hierarchy that's because first ALL bricks must exist in the new // replica of the hierarchy in order to make cross-links work properly // ! +// It is VERY important that the order of sensors and actuators in +// the replicated object is preserved: it is is used to reconnect the logic. +// This method is more robust then using the bricks name in case of complex +// group replication. The replication of logic bricks is done in +// SCA_IObject::ReParentLogic(), make sure it preserves the order of the bricks. void KX_Scene::ReplicateLogic(KX_GameObject* newobj) { // also relink the controller to sensors/actuators @@ -530,37 +535,36 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) for (vector::iterator its = linkedsensors.begin();!(its==linkedsensors.end());its++) { SCA_ISensor* oldsensor = (*its); - STR_String name = oldsensor->GetName(); - //find this name in the list - SCA_ISensor* newsensor = newobj->FindSensor(name); + SCA_IObject* oldsensorobj = oldsensor->GetParent(); + SCA_IObject* newsensorobj = NULL; - if (newsensor) + // the original owner of the sensor has been replicated? + void **h_obj = m_map_gameobject_to_replica[oldsensorobj]; + if (h_obj) + newsensorobj = (SCA_IObject*)(*h_obj); + if (!newsensorobj) { - // relink this newsensor to the controller - m_logicmgr->RegisterToSensor(cont,newsensor); + // no, then the sensor points outside the hierachy, keep it the same + m_logicmgr->RegisterToSensor(cont,oldsensor); } else { - // it can be linked somewhere in the hierarchy or... - for (vector::iterator git = m_logicHierarchicalGameObjects.begin(); - !(git==m_logicHierarchicalGameObjects.end());++git) - { - newsensor = (*git)->FindSensor(name); - if (newsensor) - break; - } + // yes, then the new sensor has the same position + SCA_SensorList& sensorlist = oldsensorobj->GetSensors(); + SCA_SensorList::iterator sit; + SCA_ISensor* newsensor = NULL; + int sensorpos; - if (newsensor) - { - // relink this newsensor to the controller somewhere else within this - // hierarchy - m_logicmgr->RegisterToSensor(cont,newsensor); - } - else + for (sensorpos=0, sit=sensorlist.begin(); sit!=sensorlist.end(); sit++, sensorpos++) { - // must be an external sensor, so... - m_logicmgr->RegisterToSensor(cont,oldsensor); + if ((*sit) == oldsensor) + { + newsensor = newsensorobj->GetSensors().at(sensorpos); + break; + } } + assert(newsensor != NULL); + m_logicmgr->RegisterToSensor(cont,newsensor); } } @@ -568,38 +572,38 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) for (vector::iterator ita = linkedactuators.begin();!(ita==linkedactuators.end());ita++) { SCA_IActuator* oldactuator = (*ita); - STR_String name = oldactuator->GetName(); - //find this name in the list - SCA_IActuator* newactuator = newobj->FindActuator(name); - if (newactuator) + SCA_IObject* oldactuatorobj = oldactuator->GetParent(); + SCA_IObject* newactuatorobj = NULL; + + // the original owner of the sensor has been replicated? + void **h_obj = m_map_gameobject_to_replica[oldactuatorobj]; + if (h_obj) + newactuatorobj = (SCA_IObject*)(*h_obj); + + if (!newactuatorobj) { - // relink this newsensor to the controller - m_logicmgr->RegisterToActuator(cont,newactuator); - newactuator->SetUeberExecutePriority(m_ueberExecutionPriority); + // no, then the sensor points outside the hierachy, keep it the same + m_logicmgr->RegisterToActuator(cont,oldactuator); } else { - // it can be linked somewhere in the hierarchy or... - for (vector::iterator git = m_logicHierarchicalGameObjects.begin(); - !(git==m_logicHierarchicalGameObjects.end());++git) - { - newactuator= (*git)->FindActuator(name); - if (newactuator) - break; - } + // yes, then the new sensor has the same position + SCA_ActuatorList& actuatorlist = oldactuatorobj->GetActuators(); + SCA_ActuatorList::iterator ait; + SCA_IActuator* newactuator = NULL; + int actuatorpos; - if (newactuator) - { - // relink this actuator to the controller somewhere else within this - // hierarchy - m_logicmgr->RegisterToActuator(cont,newactuator); - newactuator->SetUeberExecutePriority(m_ueberExecutionPriority); - } - else + for (actuatorpos=0, ait=actuatorlist.begin(); ait!=actuatorlist.end(); ait++, actuatorpos++) { - // must be an external actuator, so... - m_logicmgr->RegisterToActuator(cont,oldactuator); + if ((*ait) == oldactuator) + { + newactuator = newactuatorobj->GetActuators().at(actuatorpos); + break; + } } + assert(newactuator != NULL); + m_logicmgr->RegisterToActuator(cont,newactuator); + newactuator->SetUeberExecutePriority(m_ueberExecutionPriority); } } } -- cgit v1.2.3 From 439e474e4e6ba3c2fe6eb498e225c442d025a4ee Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 17 Jul 2008 15:33:27 +0000 Subject: BGE patch: use the Blender convention to duplicate groups in the BGE so that the objects will be created with the location and orientation as in Blender. Note that the BGE handles scaling in a parent tree differently than Blender. To avoid discrepencies between the 3D view and the BGE, use only isotropic scaling on all your objects except the leaf objects (i.e. without children) that can have anisotropic scaling --- source/gameengine/Ketsji/KX_Scene.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index ffb39bc0fb6..891cd9b3d85 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -672,19 +672,22 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) } // don't replicate logic now: we assume that the objects in the group can have // logic relationship, even outside parent relationship + // In order to match 3D view, the position of groupobj is used as a + // transformation matrix instead of the new position. This means that + // the group reference point is 0,0,0 - MT_Point3 newpos = groupobj->NodeGetWorldPosition(); - replica->NodeSetLocalPosition(newpos); - - MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation(); - replica->NodeSetLocalOrientation(newori); - // get the rootnode's scale - MT_Vector3 newscale = groupobj->GetSGNode()->GetRootSGParent()->GetLocalScale(); - + MT_Vector3 newscale = groupobj->NodeGetWorldScaling(); // set the replica's relative scale with the rootnode's scale replica->NodeSetRelativeScale(newscale); + MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldOrientation(); + replica->NodeSetLocalOrientation(newori); + + MT_Point3 newpos = groupobj->NodeGetWorldPosition() + + newscale*(groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldPosition()); + replica->NodeSetLocalPosition(newpos); + if (replica->GetPhysicsController()) { replica->GetPhysicsController()->setPosition(newpos); -- cgit v1.2.3 From a397b4b82fb9c658bb9e034e96692b9e5af5819a Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 18 Jul 2008 14:40:24 +0000 Subject: BGE bug fix (good for 2.47): SetParent actuator did not work on dynamic objects. Dynamics will now be disabled automatically and the object will be set ghost for the duration of the parenting; this is to avoid static interaction with the parent object. The dynamic state is restored when the parenting is removed with RemoveParent actuator. This fix also applies to setParent() and removeParent() python functions. --- source/gameengine/GameLogic/SCA_IObject.cpp | 2 +- .../Ketsji/KX_BulletPhysicsController.cpp | 23 +++++++++++++++++----- .../gameengine/Ketsji/KX_BulletPhysicsController.h | 5 +++-- source/gameengine/Ketsji/KX_GameObject.cpp | 10 +++++++++- source/gameengine/Ketsji/KX_IPhysicsController.h | 2 +- .../gameengine/Ketsji/KX_OdePhysicsController.cpp | 2 +- source/gameengine/Ketsji/KX_OdePhysicsController.h | 2 +- .../gameengine/Ketsji/KX_SumoPhysicsController.cpp | 2 +- .../gameengine/Ketsji/KX_SumoPhysicsController.h | 2 +- 9 files changed, 36 insertions(+), 14 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index c5bb4a41552..25b4af696ea 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -306,7 +306,7 @@ const MT_Point3& SCA_IObject::ConvertPythonPylist(PyObject* pylist) } #endif -void SCA_IObject::Suspend(void) +void SCA_IObject::Suspend() { if ((!m_ignore_activity_culling) && (!m_suspended)) { diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index 70443ced7a9..dba11efef72 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -17,7 +17,8 @@ KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna) : KX_IPhysicsController(dyna,(PHY_IPhysicsController*)this), -CcdPhysicsController(ci) +CcdPhysicsController(ci), +m_savedCollisionFlags(0) { } @@ -161,14 +162,26 @@ void KX_BulletPhysicsController::setRigidBody(bool rigid) { } -void KX_BulletPhysicsController::SuspendDynamics() +void KX_BulletPhysicsController::SuspendDynamics(bool ghost) { - GetRigidBody()->setActivationState(DISABLE_SIMULATION); - + btRigidBody *body = GetRigidBody(); + if (body->getActivationState() != DISABLE_SIMULATION) + { + m_savedCollisionFlags = body->getCollisionFlags(); + body->setActivationState(DISABLE_SIMULATION); + body->setCollisionFlags((btCollisionObject::CF_STATIC_OBJECT)| + ((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:0)); + } } + void KX_BulletPhysicsController::RestoreDynamics() { - GetRigidBody()->forceActivationState(ACTIVE_TAG); + btRigidBody *body = GetRigidBody(); + if (body->getActivationState() == DISABLE_SIMULATION) + { + GetRigidBody()->forceActivationState(ACTIVE_TAG); + body->setCollisionFlags(m_savedCollisionFlags); + } } SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode) diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 0853755dffa..6f048deb16b 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -7,7 +7,8 @@ class KX_BulletPhysicsController : public KX_IPhysicsController ,public CcdPhysicsController { - +private: + int m_savedCollisionFlags; public: KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna); @@ -39,7 +40,7 @@ public: virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ); - virtual void SuspendDynamics(); + virtual void SuspendDynamics(bool ghost); virtual void RestoreDynamics(); virtual SG_Controller* GetReplica(class SG_Node* destnode); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 2ac4f909077..576ff3ec68f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -238,6 +238,10 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) if (rootlist->RemoveValue(this)) // the object was in parent list, decrement ref count as it's now removed Release(); + if (m_pPhysicsController1) + { + m_pPhysicsController1->SuspendDynamics(true); + } } } @@ -258,6 +262,10 @@ void KX_GameObject::RemoveParent(KX_Scene *scene) if (!rootlist->SearchValue(this)) // object was not in root list, add it now and increment ref count rootlist->Add(AddRef()); + if (m_pPhysicsController1) + { + m_pPhysicsController1->RestoreDynamics(); + } } } @@ -832,7 +840,7 @@ void KX_GameObject::Resume(void) } } -void KX_GameObject::Suspend(void) +void KX_GameObject::Suspend() { if ((!m_ignore_activity_culling) && (!m_suspended)) { diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h index 2ec66a883eb..bc4cc185a04 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ b/source/gameengine/Ketsji/KX_IPhysicsController.h @@ -78,7 +78,7 @@ public: virtual MT_Vector3 getReactionForce()=0; virtual void setRigidBody(bool rigid)=0; - virtual void SuspendDynamics()=0; + virtual void SuspendDynamics(bool ghost=false)=0; virtual void RestoreDynamics()=0; virtual SG_Controller* GetReplica(class SG_Node* destnode)=0; diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp index 4e45ce484e3..8b0a6dafc22 100644 --- a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp @@ -177,7 +177,7 @@ void KX_OdePhysicsController::setRigidBody(bool rigid) } -void KX_OdePhysicsController::SuspendDynamics() +void KX_OdePhysicsController::SuspendDynamics(bool) { ODEPhysicsController::SuspendDynamics(); } diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h index 07a0bee9775..c96c71c81f9 100644 --- a/source/gameengine/Ketsji/KX_OdePhysicsController.h +++ b/source/gameengine/Ketsji/KX_OdePhysicsController.h @@ -74,7 +74,7 @@ public: virtual MT_Vector3 getReactionForce(); virtual void setRigidBody(bool rigid); - virtual void SuspendDynamics(); + virtual void SuspendDynamics(bool); virtual void RestoreDynamics(); diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp index 6ea5461dbaa..ffb078b346e 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp @@ -101,7 +101,7 @@ void KX_SumoPhysicsController::SetSumoTransform(bool nondynaonly) } -void KX_SumoPhysicsController::SuspendDynamics() +void KX_SumoPhysicsController::SuspendDynamics(bool) { SumoPhysicsController::SuspendDynamics(); } diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h index 8c061ae4056..33666036c0d 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h @@ -76,7 +76,7 @@ public: void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ); - void SuspendDynamics(); + void SuspendDynamics(bool); void RestoreDynamics(); virtual void getOrientation(MT_Quaternion& orn); virtual void setOrientation(const MT_Quaternion& orn); -- cgit v1.2.3 From 5e2ee191877d1073a20da32c52d9e97cfab8f5c8 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 18 Jul 2008 19:56:56 +0000 Subject: BGE patch: support for partial hierarchy in dupligroup instantiation; removal of links that point to inactive objects during group instantiation. This situation corresponds to a group containing only a portion of a parent hierarchy (the Apricot team needed that to avoid logic duplication). The BGE will instantiate only the children that are in the group so that it follows the 3D view more closely. As a result, the logic links to the objects in the portion of the hierarchy that was not replicated will point to inactive objects (if the groups are stored in inactive layers as they should be). To keep the logic system consistent, these links are automatically removed. This last part of the patch is a general fix that could go in 2.47 but as this situation does not normally occurs in pre-2.47 games, it is not needed. --- source/gameengine/Ketsji/KX_Scene.cpp | 44 ++++++++++++++++++++++------- source/gameengine/Ketsji/KX_Scene.h | 15 ++++++++++ source/gameengine/SceneGraph/SG_IObject.cpp | 6 ++-- source/gameengine/SceneGraph/SG_IObject.h | 2 +- source/gameengine/SceneGraph/SG_Node.cpp | 29 +++++++++++++++---- source/gameengine/SceneGraph/SG_Node.h | 2 +- 6 files changed, 78 insertions(+), 20 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 891cd9b3d85..200883a094c 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -431,6 +431,11 @@ void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gam KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CValue* gameobj) { + // for group duplication, limit the duplication of the hierarchy to the + // objects that are part of the group. + if (!IsObjectInGroup(gameobj)) + return NULL; + KX_GameObject* orgobj = (KX_GameObject*)gameobj; KX_GameObject* newobj = (KX_GameObject*)orgobj->GetReplica(); m_map_gameobject_to_replica.insert(orgobj, newobj); @@ -545,7 +550,9 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) if (!newsensorobj) { // no, then the sensor points outside the hierachy, keep it the same - m_logicmgr->RegisterToSensor(cont,oldsensor); + if (m_objectlist->SearchValue(oldsensorobj)) + // only replicate links that points to active objects + m_logicmgr->RegisterToSensor(cont,oldsensor); } else { @@ -583,7 +590,9 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj) if (!newactuatorobj) { // no, then the sensor points outside the hierachy, keep it the same - m_logicmgr->RegisterToActuator(cont,oldactuator); + if (m_objectlist->SearchValue(oldactuatorobj)) + // only replicate links that points to active objects + m_logicmgr->RegisterToActuator(cont,oldactuator); } else { @@ -615,6 +624,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) { KX_GameObject* groupobj = (KX_GameObject*) obj; KX_GameObject* replica; + KX_GameObject* gameobj; Object* blgroupobj = groupobj->GetBlenderObject(); Group* group; GroupObject *go; @@ -628,6 +638,10 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) m_logicHierarchicalGameObjects.clear(); m_map_gameobject_to_replica.clear(); m_ueberExecutionPriority++; + // for groups will do something special: + // we will force the creation of objects to those in the group only + // Again, this is match what Blender is doing (it doesn't care of parent relationship) + m_groupGameObjects.clear(); group = blgroupobj->dup_group; for(go=(GroupObject*)group->gobject.first; go; go=(GroupObject*)go->next) @@ -636,13 +650,25 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) if (blgroupobj == blenderobj) // this check is also in group_duplilist() continue; - KX_GameObject* gameobj = m_sceneConverter->FindGameObject(blenderobj); + gameobj = m_sceneConverter->FindGameObject(blenderobj); if (gameobj == NULL) { // this object has not been converted!!! // Should not happen as dupli group are created automatically continue; } + if (blenderobj->lay & group->layer==0) + { + // object is not visible in the 3D view, will not be instantiated + continue; + } + m_groupGameObjects.insert(gameobj); + } + + set::iterator oit; + for (oit=m_groupGameObjects.begin(); oit != m_groupGameObjects.end(); oit++) + { + gameobj = (KX_GameObject*)(*oit); if (gameobj->GetParent() != NULL) { // this object is not a top parent. Either it is the child of another @@ -651,11 +677,6 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) // is inconsistent, skip it anyway continue; } - if (blenderobj->lay & group->layer==0) - { - // object is not visible in the 3D view, will not be instantiated - continue; - } replica = (KX_GameObject*) AddNodeReplicaObject(NULL,gameobj); // add to 'rootparent' list (this is the list of top hierarchy objects, updated each frame) m_parentlist->Add(replica->AddRef()); @@ -668,7 +689,8 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) { SG_Node* orgnode = (*childit); SG_Node* childreplicanode = orgnode->GetSGReplica(); - replica->GetSGNode()->AddChild(childreplicanode); + if (childreplicanode) + replica->GetSGNode()->AddChild(childreplicanode); } // don't replicate logic now: we assume that the objects in the group can have // logic relationship, even outside parent relationship @@ -745,6 +767,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, m_logicHierarchicalGameObjects.clear(); m_map_gameobject_to_replica.clear(); + m_groupGameObjects.clear(); // todo: place a timebomb in the object, for temporarily objects :) // lifespan of zero means 'this object lives forever' @@ -778,7 +801,8 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, { SG_Node* orgnode = (*childit); SG_Node* childreplicanode = orgnode->GetSGReplica(); - replica->GetSGNode()->AddChild(childreplicanode); + if (childreplicanode) + replica->GetSGNode()->AddChild(childreplicanode); } // relink any pointers as necessary, sort of a temporary solution diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 374545f9a90..80a2abe287a 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -216,6 +216,16 @@ protected: */ std::vector m_logicHierarchicalGameObjects; + /** + * This temporary variable will contain the list of + * object that can be added during group instantiation. + * objects outside this list will not be added (can + * happen with children that are outside the group). + * Used in AddReplicaObject. If the list is empty, it + * means don't care. + */ + std::set m_groupGameObjects; + /** * Pointer to system variable passed in in constructor * only used in constructor so we do not need to keep it @@ -292,6 +302,11 @@ public: */ void UpdateParents(double curtime); void DupliGroupRecurse(CValue* gameobj, int level); + bool IsObjectInGroup(CValue* gameobj) + { + return (m_groupGameObjects.empty() || + m_groupGameObjects.find(gameobj) != m_groupGameObjects.end()); + } SCA_IObject* AddReplicaObject(CValue* gameobj, CValue* locationobj, int lifespan=0); diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp index c347bbc6d9a..d0bdac5c8f0 100644 --- a/source/gameengine/SceneGraph/SG_IObject.cpp +++ b/source/gameengine/SceneGraph/SG_IObject.cpp @@ -104,7 +104,7 @@ SetSGClientObject( } - void + bool SG_IObject:: ActivateReplicationCallback( SG_IObject *replica @@ -112,8 +112,10 @@ ActivateReplicationCallback( if (m_callbacks.m_replicafunc) { // Call client provided replication func - m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo); + if (m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo) == NULL) + return false; } + return true; }; void diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index 438ab48c556..7f6bdfbbb1c 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -202,7 +202,7 @@ public: protected : - void + bool ActivateReplicationCallback( SG_IObject *replica ); diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp index 4e90d7c4653..8de7ac83477 100644 --- a/source/gameengine/SceneGraph/SG_Node.cpp +++ b/source/gameengine/SceneGraph/SG_Node.cpp @@ -68,7 +68,7 @@ SG_Node* SG_Node::GetSGReplica() SG_Node* replica = new SG_Node(*this); if (replica == NULL) return NULL; - ProcessSGReplica(replica); + ProcessSGReplica(&replica); return replica; } @@ -76,25 +76,42 @@ SG_Node* SG_Node::GetSGReplica() void SG_Node:: ProcessSGReplica( - SG_Node* replica + SG_Node** replica ){ // Apply the replication call back function. - ActivateReplicationCallback(replica); + if (!ActivateReplicationCallback(*replica)) + { + delete (*replica); + *replica = NULL; + return; + } // clear the replica node of it's parent. - static_cast(replica)->m_SGparent = NULL; + static_cast(*replica)->m_SGparent = NULL; if (m_children.begin() != m_children.end()) { // if this node has children, the replica has too, so clear and clone children - replica->ClearSGChildren(); + (*replica)->ClearSGChildren(); NodeList::iterator childit; for (childit = m_children.begin();childit!=m_children.end();++childit) { - replica->AddChild((*childit)->GetSGReplica()); + SG_Node* childnode = (*childit)->GetSGReplica(); + if (childnode) + (*replica)->AddChild(childnode); } } + // Nodes without children and without client object are + // not worth to keep, they will just take up CPU + // This can happen in partial replication of hierarchy + // during group duplication. + if ((*replica)->m_children.empty() && + (*replica)->GetSGClientObject() == NULL) + { + delete (*replica); + *replica = NULL; + } } diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h index f86e3046d93..ffaaad861e2 100644 --- a/source/gameengine/SceneGraph/SG_Node.h +++ b/source/gameengine/SceneGraph/SG_Node.h @@ -205,7 +205,7 @@ private: void ProcessSGReplica( - SG_Node* replica + SG_Node** replica ); /** -- cgit v1.2.3 From 9ed079bf5cbe8a5a371190a8dedec970bcbd3ac2 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 19 Jul 2008 07:45:19 +0000 Subject: BGE patch: Relink actuators with target within group when duplicating group; generalize protection against object deletion for all actuators that point to objects. Certain actuators hold a pointer to an objects: Property, SceneCamera, AddObject, Camera, Parent, TractTo. When a group is duplicated, the actuators that point to objects within the group will be relinked to point to the replicated objects and not to the original objects. This helps to setup self-contained group with a camera following a character for example. This feature also works when adding a single object (and all its children) with the AddObject actuator. The second part of the patch extends the protection against object deletion to all the actuators of the above list (previously, only the TrackTo, AddObject and Property actuators were protected). In case the target object of these actuators is deleted, the BGE won't crash. --- .../gameengine/Converter/BL_DeformableGameObject.h | 1 + .../gameengine/Converter/KX_ConvertActuators.cpp | 2 +- source/gameengine/GameLogic/SCA_ILogicBrick.cpp | 5 +- source/gameengine/GameLogic/SCA_ILogicBrick.h | 3 ++ .../gameengine/GameLogic/SCA_PropertyActuator.cpp | 33 +++++++++--- source/gameengine/GameLogic/SCA_PropertyActuator.h | 8 +-- source/gameengine/Ketsji/KX_CameraActuator.cpp | 62 +++++++++++++++++----- source/gameengine/Ketsji/KX_CameraActuator.h | 8 ++- source/gameengine/Ketsji/KX_GameObject.cpp | 18 ++++++- source/gameengine/Ketsji/KX_ParentActuator.cpp | 51 ++++++++++++++++-- source/gameengine/Ketsji/KX_ParentActuator.h | 7 ++- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 11 ++++ .../gameengine/Ketsji/KX_SCA_AddObjectActuator.h | 3 ++ source/gameengine/Ketsji/KX_Scene.cpp | 31 ++++++----- source/gameengine/Ketsji/KX_SceneActuator.cpp | 45 +++++++++++++++- source/gameengine/Ketsji/KX_SceneActuator.h | 3 ++ source/gameengine/Ketsji/KX_TrackToActuator.cpp | 12 +++++ source/gameengine/Ketsji/KX_TrackToActuator.h | 1 + 18 files changed, 254 insertions(+), 50 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index 57a404ad72b..315ad18c42c 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -60,6 +60,7 @@ public: { if (m_pDeformer) m_pDeformer->Relink (map); + KX_GameObject::Relink(map); }; void ProcessReplica(KX_GameObject* replica); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 1cc1b2e27a3..8739fb109fd 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -503,7 +503,7 @@ void BL_ConvertActuators(char* maggiename, case ACT_PROPERTY: { bPropertyActuator* propact = (bPropertyActuator*) bact->data; - CValue* destinationObj = NULL; + SCA_IObject* destinationObj = NULL; /* here the destinationobject is searched. problem with multiple scenes: other scenes diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index f6efd485adb..e73358bc1e8 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -82,7 +82,10 @@ void SCA_ILogicBrick::ReParent(SCA_IObject* parent) m_gameobj = parent; } - +void SCA_ILogicBrick::Relink(GEN_Map *obj_map) +{ + // nothing to do +} CValue* SCA_ILogicBrick::Calc(VALUE_OPERATOR op, CValue *val) { diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h index 80bc6ae3b86..c28711ac0f6 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.h +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h @@ -32,6 +32,8 @@ #include "Value.h" #include "SCA_IObject.h" #include "BoolValue.h" +#include "GEN_Map.h" +#include "GEN_HashedPtr.h" class SCA_ILogicBrick : public CValue { @@ -59,6 +61,7 @@ public: SCA_IObject* GetParent(); virtual void ReParent(SCA_IObject* parent); + virtual void Relink(GEN_Map *obj_map); // act as a BoolValue (with value IsPositiveTrigger) virtual CValue* Calc(VALUE_OPERATOR op, CValue *val); diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index ebe1cd51863..7062f2cef6a 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -42,7 +42,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ -SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,CValue* sourceObj,const STR_String& propname,const STR_String& expr,int acttype,PyTypeObject* T ) +SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,SCA_IObject* sourceObj,const STR_String& propname,const STR_String& expr,int acttype,PyTypeObject* T ) : SCA_IActuator(gameobj,T), m_type(acttype), m_propname(propname), @@ -51,14 +51,14 @@ SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,CValue* sourceOb { // protect ourselves against someone else deleting the source object // don't protect against ourselves: it would create a dead lock - if (m_sourceObj && m_sourceObj != GetParent()) - m_sourceObj->AddRef(); + if (m_sourceObj) + m_sourceObj->RegisterActuator(this); } SCA_PropertyActuator::~SCA_PropertyActuator() { - if (m_sourceObj && m_sourceObj != GetParent()) - m_sourceObj->Release(); + if (m_sourceObj) + m_sourceObj->UnregisterActuator(this); } bool SCA_PropertyActuator::Update() @@ -185,10 +185,31 @@ void SCA_PropertyActuator::ProcessReplica() // no need to check for self reference like in the constructor: // the replica will always have a different parent if (m_sourceObj) - m_sourceObj->AddRef(); + m_sourceObj->RegisterActuator(this); SCA_IActuator::ProcessReplica(); } +bool SCA_PropertyActuator::UnlinkObject(SCA_IObject* clientobj) +{ + if (clientobj == m_sourceObj) + { + // this object is being deleted, we cannot continue to track it. + m_sourceObj = NULL; + return true; + } + return false; +} + +void SCA_PropertyActuator::Relink(GEN_Map *obj_map) +{ + void **h_obj = (*obj_map)[m_sourceObj]; + if (h_obj) { + if (m_sourceObj) + m_sourceObj->UnregisterActuator(this); + m_sourceObj = (SCA_IObject*)(*h_obj); + m_sourceObj->RegisterActuator(this); + } +} /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h index f8305901c51..1e435684572 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.h +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h @@ -52,7 +52,7 @@ class SCA_PropertyActuator : public SCA_IActuator int m_type; STR_String m_propname; STR_String m_exprtxt; - CValue* m_sourceObj; // for copy property actuator + SCA_IObject* m_sourceObj; // for copy property actuator public: @@ -60,7 +60,7 @@ public: SCA_PropertyActuator( SCA_IObject* gameobj, - CValue* sourceObj, + SCA_IObject* sourceObj, const STR_String& propname, const STR_String& expr, int acttype, @@ -74,7 +74,9 @@ public: GetReplica( ); - void ProcessReplica(); + virtual void ProcessReplica(); + virtual bool UnlinkObject(SCA_IObject* clientobj); + virtual void Relink(GEN_Map *obj_map); virtual bool Update(); diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 27f4870de10..0a97b6f0a2f 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -49,7 +49,7 @@ STR_String KX_CameraActuator::Y_AXIS_STRING = "y"; KX_CameraActuator::KX_CameraActuator( SCA_IObject* gameobj, - CValue *obj, + SCA_IObject *obj, MT_Scalar hght, MT_Scalar minhght, MT_Scalar maxhght, @@ -63,11 +63,14 @@ KX_CameraActuator::KX_CameraActuator( m_maxHeight (maxhght), m_x (xytog) { + if (m_ob) + m_ob->RegisterActuator(this); } KX_CameraActuator::~KX_CameraActuator() { - //nothing to do + if (m_ob) + m_ob->UnregisterActuator(this); } CValue* @@ -81,9 +84,36 @@ GetReplica( return replica; }; +void KX_CameraActuator::ProcessReplica() +{ + if (m_ob) + m_ob->RegisterActuator(this); + SCA_IActuator::ProcessReplica(); +} +bool KX_CameraActuator::UnlinkObject(SCA_IObject* clientobj) +{ + if (clientobj == m_ob) + { + // this object is being deleted, we cannot continue to track it. + m_ob = NULL; + return true; + } + return false; +} +void KX_CameraActuator::Relink(GEN_Map *obj_map) +{ + void **h_obj = (*obj_map)[m_ob]; + if (h_obj) { + if (m_ob) + m_ob->UnregisterActuator(this); + m_ob = (SCA_IObject*)(*h_obj); + m_ob->RegisterActuator(this); + } +} + /* three functions copied from blender arith... don't know if there's an equivalent */ static float Kx_Normalize(float *n) @@ -181,8 +211,14 @@ static void Kx_VecUpMat3(float *vec, float mat[][3], short axis) bool KX_CameraActuator::Update(double curtime, bool frame) { - bool result = true; + /* wondering... is it really neccesary/desirable to suppress negative */ + /* events here? */ + bool bNegativeEvent = IsNegativeEvent(); + RemoveAllEvents(); + if (bNegativeEvent || !m_ob) + return false; + KX_GameObject *obj = (KX_GameObject*) GetParent(); MT_Point3 from = obj->NodeGetWorldPosition(); MT_Matrix3x3 frommat = obj->NodeGetWorldOrientation(); @@ -195,13 +231,6 @@ bool KX_CameraActuator::Update(double curtime, bool frame) float mindistsq, maxdistsq, distsq; float mat[3][3]; - /* wondering... is it really neccesary/desirable to suppress negative */ - /* events here? */ - bool bNegativeEvent = IsNegativeEvent(); - RemoveAllEvents(); - - if (bNegativeEvent) return false; - /* The rules: */ /* CONSTRAINT 1: not implemented */ /* CONSTRAINT 2: can camera see actor? */ @@ -315,7 +344,7 @@ bool KX_CameraActuator::Update(double curtime, bool frame) actormat[2][0]= mat[0][2]; actormat[2][1]= mat[1][2]; actormat[2][2]= mat[2][2]; obj->NodeSetLocalOrientation(actormat); - return result; + return true; } CValue *KX_CameraActuator::findObject(char *obName) @@ -404,7 +433,11 @@ PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* gameobj; if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) { - m_ob = (CValue*)gameobj; + if (m_ob) + m_ob->UnregisterActuator(this); + m_ob = (SCA_IObject*)gameobj; + if (m_ob) + m_ob->RegisterActuator(this); Py_Return; } PyErr_Clear(); @@ -412,10 +445,13 @@ PyObject* KX_CameraActuator::PySetObject(PyObject* self, char* objectname; if (PyArg_ParseTuple(args, "s", &objectname)) { - CValue *object = (CValue*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)); + SCA_IObject *object = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)); if(object) { + if (m_ob != NULL) + m_ob->UnregisterActuator(this); m_ob = object; + m_ob->RegisterActuator(this); Py_Return; } } diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index eb007e403ec..488b36922b0 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -49,7 +49,7 @@ class KX_CameraActuator : public SCA_IActuator Py_Header; private : /** Object that will be tracked. */ - CValue *m_ob; + SCA_IObject *m_ob; /** height (float), */ //const MT_Scalar m_height; @@ -87,7 +87,7 @@ private : SCA_IObject *gameobj, //const CValue *ob, - CValue *ob, + SCA_IObject *ob, MT_Scalar hght, MT_Scalar minhght, MT_Scalar maxhght, @@ -103,6 +103,7 @@ private : /** Methods Inherited from CValue */ CValue* GetReplica(); + virtual void ProcessReplica(); /** Methods inherited from SCA_IActuator */ @@ -110,7 +111,10 @@ private : double curtime, bool frame ); + virtual bool UnlinkObject(SCA_IObject* clientobj); + /** Methods inherited from SCA_ILogicBrick */ + virtual void Relink(GEN_Map *obj_map); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 576ff3ec68f..1845fdd7b50 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -61,6 +61,8 @@ typedef unsigned long uint_ptr; #include "KX_RayCast.h" #include "KX_PythonInit.h" #include "KX_PyMath.h" +#include "SCA_IActuator.h" +#include "SCA_ISensor.h" // This file defines relationships between parents and children // in the game engine. @@ -1668,6 +1670,20 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, * --------------------------------------------------------------------- */ void KX_GameObject::Relink(GEN_Map *map_parameter) { - /* intentionally empty ? */ + // we will relink the sensors and actuators that use object references + // if the object is part of the replicated hierarchy, use the new + // object reference instead + SCA_SensorList& sensorlist = GetSensors(); + SCA_SensorList::iterator sit; + for (sit=sensorlist.begin(); sit != sensorlist.end(); sit++) + { + (*sit)->Relink(map_parameter); + } + SCA_ActuatorList& actuatorlist = GetActuators(); + SCA_ActuatorList::iterator ait; + for (ait=actuatorlist.begin(); ait != actuatorlist.end(); ait++) + { + (*ait)->Relink(map_parameter); + } } diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 8b379bcd44f..fd1b56838e2 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -46,19 +46,22 @@ KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj, int mode, - CValue *ob, + SCA_IObject *ob, PyTypeObject* T) : SCA_IActuator(gameobj, T), m_mode(mode), m_ob(ob) { + if (m_ob) + m_ob->RegisterActuator(this); } KX_ParentActuator::~KX_ParentActuator() { - /* intentionally empty */ + if (m_ob) + m_ob->UnregisterActuator(this); } @@ -73,6 +76,36 @@ CValue* KX_ParentActuator::GetReplica() return replica; } +void KX_ParentActuator::ProcessReplica() +{ + if (m_ob) + m_ob->RegisterActuator(this); + SCA_IActuator::ProcessReplica(); +} + + +bool KX_ParentActuator::UnlinkObject(SCA_IObject* clientobj) +{ + if (clientobj == m_ob) + { + // this object is being deleted, we cannot continue to track it. + m_ob = NULL; + return true; + } + return false; +} + +void KX_ParentActuator::Relink(GEN_Map *obj_map) +{ + void **h_obj = (*obj_map)[m_ob]; + if (h_obj) { + if (m_ob) + m_ob->UnregisterActuator(this); + m_ob = (SCA_IObject*)(*h_obj); + m_ob->RegisterActuator(this); + } +} + bool KX_ParentActuator::Update() @@ -87,7 +120,8 @@ bool KX_ParentActuator::Update() KX_Scene *scene = PHY_GetActiveScene(); switch (m_mode) { case KX_PARENT_SET: - obj->SetParent(scene, (KX_GameObject*)m_ob); + if (m_ob) + obj->SetParent(scene, (KX_GameObject*)m_ob); break; case KX_PARENT_REMOVE: obj->RemoveParent(scene); @@ -148,7 +182,11 @@ PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* args, PyObjec PyObject* gameobj; if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) { - m_ob = (CValue*)gameobj; + if (m_ob != NULL) + m_ob->UnregisterActuator(this); + m_ob = (SCA_IObject*)gameobj; + if (m_ob) + m_ob->RegisterActuator(this); Py_Return; } PyErr_Clear(); @@ -156,10 +194,13 @@ PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* args, PyObjec char* objectname; if (PyArg_ParseTuple(args, "s", &objectname)) { - CValue *object = (CValue*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)); + SCA_IObject *object = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)); if(object) { + if (m_ob != NULL) + m_ob->UnregisterActuator(this); m_ob = object; + m_ob->RegisterActuator(this); Py_Return; } } diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 86dcd4e6c12..5255abf2e42 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -47,7 +47,7 @@ class KX_ParentActuator : public SCA_IActuator int m_mode; /** Object to set as parent */ - CValue *m_ob; + SCA_IObject *m_ob; @@ -62,12 +62,15 @@ class KX_ParentActuator : public SCA_IActuator KX_ParentActuator(class SCA_IObject* gameobj, int mode, - CValue *ob, + SCA_IObject *ob, PyTypeObject* T=&Type); virtual ~KX_ParentActuator(); virtual bool Update(); virtual CValue* GetReplica(); + virtual void ProcessReplica(); + virtual void KX_ParentActuator::Relink(GEN_Map *obj_map); + virtual bool KX_ParentActuator::UnlinkObject(SCA_IObject* clientobj); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index e5ee4cbddf1..e36891b56f4 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -137,6 +137,17 @@ bool KX_SCA_AddObjectActuator::UnlinkObject(SCA_IObject* clientobj) return false; } +void KX_SCA_AddObjectActuator::Relink(GEN_Map *obj_map) +{ + void **h_obj = (*obj_map)[m_OriginalObject]; + if (h_obj) { + if (m_OriginalObject) + m_OriginalObject->UnregisterActuator(this); + m_OriginalObject = (SCA_IObject*)(*h_obj); + m_OriginalObject->RegisterActuator(this); + } +} + /* ------------------------------------------------------------------------- */ /* Python functions */ diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 42123b94a68..1359f39278d 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -95,6 +95,9 @@ public: virtual bool UnlinkObject(SCA_IObject* clientobj); + virtual void + Relink(GEN_Map *obj_map); + virtual bool Update(); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 200883a094c..1bdd4002805 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -724,21 +724,23 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) replica->Release(); } - // relink any pointers as necessary, sort of a temporary solution + // the logic must be replicated first because we need + // the new logic bricks before relinking vector::iterator git; for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { + (*git)->ReParentLogic(); + } + + // relink any pointers as necessary, sort of a temporary solution + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { + // this will also relink the actuator to objects within the hierarchy (*git)->Relink(&m_map_gameobject_to_replica); // add the object in the layer of the parent (*git)->SetLayer(groupobj->GetLayer()); } - // now replicate logic - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { - (*git)->ReParentLogic(); - } - // replicate crosslinks etc. between logic bricks for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { @@ -805,21 +807,22 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, replica->GetSGNode()->AddChild(childreplicanode); } - // relink any pointers as necessary, sort of a temporary solution + // now replicate logic vector::iterator git; for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { + (*git)->ReParentLogic(); + } + + // relink any pointers as necessary, sort of a temporary solution + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { + // this will also relink the actuators in the hierarchy (*git)->Relink(&m_map_gameobject_to_replica); // add the object in the layer of the parent (*git)->SetLayer(parentobj->GetLayer()); } - // now replicate logic - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { - (*git)->ReParentLogic(); - } - // replicate crosslinks etc. between logic bricks for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) { diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 8f7cffd506f..d6164dc812a 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -58,13 +58,16 @@ KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj, m_KetsjiEngine=ketsjiEngine; m_camera = camera; m_nextSceneName = nextSceneName; + if (m_camera) + m_camera->RegisterActuator(this); } /* End of constructor */ KX_SceneActuator::~KX_SceneActuator() { - // there's nothing to be done here, really.... + if (m_camera) + m_camera->UnregisterActuator(this); } /* end of destructor */ @@ -79,6 +82,34 @@ CValue* KX_SceneActuator::GetReplica() return replica; } +void KX_SceneActuator::ProcessReplica() +{ + if (m_camera) + m_camera->RegisterActuator(this); + SCA_IActuator::ProcessReplica(); +} + +bool KX_SceneActuator::UnlinkObject(SCA_IObject* clientobj) +{ + if (clientobj == (SCA_IObject*)m_camera) + { + // this object is being deleted, we cannot continue to track it. + m_camera = NULL; + return true; + } + return false; +} + +void KX_SceneActuator::Relink(GEN_Map *obj_map) +{ + void **h_obj = (*obj_map)[m_camera]; + if (h_obj) { + if (m_camera) + m_camera->UnregisterActuator(this); + m_camera = (KX_Camera*)(*h_obj); + m_camera->RegisterActuator(this); + } +} bool KX_SceneActuator::Update() @@ -332,7 +363,11 @@ PyObject* KX_SceneActuator::PySetCamera(PyObject* self, PyObject *cam; if (PyArg_ParseTuple(args, "O!", &KX_Camera::Type, &cam)) { + if (m_camera) + m_camera->UnregisterActuator(this); m_camera = (KX_Camera*) cam; + if (m_camera) + m_camera->RegisterActuator(this); Py_Return; } PyErr_Clear(); @@ -345,7 +380,13 @@ PyObject* KX_SceneActuator::PySetCamera(PyObject* self, } KX_Camera *camOb = FindCamera(camName); - if (camOb) m_camera = camOb; + if (camOb) + { + if (m_camera) + m_camera->UnregisterActuator(this); + m_camera = camOb; + m_camera->RegisterActuator(this); + } Py_Return; } diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h index cfc79b93f8e..55aaf629d7c 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.h +++ b/source/gameengine/Ketsji/KX_SceneActuator.h @@ -82,6 +82,9 @@ class KX_SceneActuator : public SCA_IActuator virtual ~KX_SceneActuator(); virtual CValue* GetReplica(); + virtual void ProcessReplica(); + virtual bool UnlinkObject(SCA_IObject* clientobj); + virtual void Relink(GEN_Map *obj_map); virtual bool Update(); diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 731a610c2eb..c580aa4d4e5 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -210,6 +210,18 @@ bool KX_TrackToActuator::UnlinkObject(SCA_IObject* clientobj) return false; } +void KX_TrackToActuator::Relink(GEN_Map *obj_map) +{ + void **h_obj = (*obj_map)[m_object]; + if (h_obj) { + if (m_object) + m_object->UnregisterActuator(this); + m_object = (SCA_IObject*)(*h_obj); + m_object->RegisterActuator(this); + } +} + + bool KX_TrackToActuator::Update(double curtime, bool frame) { bool result = false; diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index a03aa115baa..1d1cf46d21b 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -68,6 +68,7 @@ class KX_TrackToActuator : public SCA_IActuator virtual void ProcessReplica(); virtual bool UnlinkObject(SCA_IObject* clientobj); + virtual void Relink(GEN_Map *obj_map); virtual bool Update(double curtime, bool frame); /* Python part */ -- cgit v1.2.3 From 7e990de294910cb528227cdb004414558b951890 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 19 Jul 2008 10:27:52 +0000 Subject: BGE bug fix (good for 2.47): remove static-static collision messages on the console since previous SetParent fix. The physical object is set to static+ghost while the object is parented. This behavior will be made optional in a future release. The DisableDynamics actuator will also make the object static except that the ghost/non-ghost flag is preserved. --- source/gameengine/Ketsji/KX_BulletPhysicsController.cpp | 15 ++++++++++++--- source/gameengine/Ketsji/KX_BulletPhysicsController.h | 2 ++ .../gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 10 ++++++++++ source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h | 2 ++ 4 files changed, 26 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index dba11efef72..e25deaf05a9 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -13,6 +13,7 @@ #include "KX_ClientObjectInfo.h" #include "PHY_IPhysicsEnvironment.h" +#include "CcdPhysicsEnvironment.h" KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna) @@ -167,10 +168,15 @@ void KX_BulletPhysicsController::SuspendDynamics(bool ghost) btRigidBody *body = GetRigidBody(); if (body->getActivationState() != DISABLE_SIMULATION) { + btBroadphaseProxy* handle = body->getBroadphaseHandle(); m_savedCollisionFlags = body->getCollisionFlags(); + m_savedCollisionFilterGroup = handle->m_collisionFilterGroup; + m_savedCollisionFilterMask = handle->m_collisionFilterMask; body->setActivationState(DISABLE_SIMULATION); - body->setCollisionFlags((btCollisionObject::CF_STATIC_OBJECT)| - ((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:0)); + GetPhysicsEnvironment()->updateCcdPhysicsController(this, + btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)), + btBroadphaseProxy::StaticFilter, + btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter); } } @@ -180,7 +186,10 @@ void KX_BulletPhysicsController::RestoreDynamics() if (body->getActivationState() == DISABLE_SIMULATION) { GetRigidBody()->forceActivationState(ACTIVE_TAG); - body->setCollisionFlags(m_savedCollisionFlags); + GetPhysicsEnvironment()->updateCcdPhysicsController(this, + m_savedCollisionFlags, + m_savedCollisionFilterGroup, + m_savedCollisionFilterMask); } } diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 6f048deb16b..3d7c7e5b030 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -9,6 +9,8 @@ class KX_BulletPhysicsController : public KX_IPhysicsController ,public CcdPhysi { private: int m_savedCollisionFlags; + short int m_savedCollisionFilterGroup; + short int m_savedCollisionFilterMask; public: KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index c9d346e316d..7f5457121ea 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -466,6 +466,16 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr } +void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctrl, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask) +{ + // this function is used when the collisionning group of a controller is changed + // remove and add the collistioning object + btRigidBody* body = ctrl->GetRigidBody(); + + m_dynamicsWorld->removeCollisionObject(body); + body->setCollisionFlags(newCollisionFlags); + m_dynamicsWorld->addCollisionObject(body, newCollisionGroup, newCollisionMask); +} void CcdPhysicsEnvironment::beginFrame() { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 9f14cf6cbef..dff17517b85 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -183,6 +183,8 @@ protected: void removeCcdPhysicsController(CcdPhysicsController* ctrl); + void updateCcdPhysicsController(CcdPhysicsController* ctrl, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask); + btBroadphaseInterface* getBroadphase(); -- cgit v1.2.3 From 37c8f08f28db1894cb3a10373b5a633ebafd32fd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Jul 2008 13:04:55 +0000 Subject: syntax change so GCC 4.3 will build --- source/gameengine/Ketsji/KX_ParentActuator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 5255abf2e42..93b07cd424b 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -69,8 +69,8 @@ class KX_ParentActuator : public SCA_IActuator virtual CValue* GetReplica(); virtual void ProcessReplica(); - virtual void KX_ParentActuator::Relink(GEN_Map *obj_map); - virtual bool KX_ParentActuator::UnlinkObject(SCA_IObject* clientobj); + virtual void Relink(GEN_Map *obj_map); + virtual bool UnlinkObject(SCA_IObject* clientobj); /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ -- cgit v1.2.3 From d725e5f78eae57b3cfd0d32b8404beaef4e11846 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 20 Jul 2008 15:40:03 +0000 Subject: BGE bug fix (for 2.47): setParent() fix, third part: set mass to 0 when parenting. Allow loc/scale/orientation change on child object with physic controller. --- .../Ketsji/KX_BulletPhysicsController.cpp | 5 ++++- .../gameengine/Ketsji/KX_BulletPhysicsController.h | 2 ++ source/gameengine/Ketsji/KX_GameObject.cpp | 25 +++++++++++----------- .../Physics/Bullet/CcdPhysicsController.h | 2 +- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 24 ++++++++++++++++++++- .../Physics/Bullet/CcdPhysicsEnvironment.h | 9 +++++++- 6 files changed, 51 insertions(+), 16 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index e25deaf05a9..1553c4c61c2 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -170,10 +170,12 @@ void KX_BulletPhysicsController::SuspendDynamics(bool ghost) { btBroadphaseProxy* handle = body->getBroadphaseHandle(); m_savedCollisionFlags = body->getCollisionFlags(); + m_savedMass = GetMass(); m_savedCollisionFilterGroup = handle->m_collisionFilterGroup; m_savedCollisionFilterMask = handle->m_collisionFilterMask; body->setActivationState(DISABLE_SIMULATION); GetPhysicsEnvironment()->updateCcdPhysicsController(this, + 0.0, btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)), btBroadphaseProxy::StaticFilter, btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter); @@ -185,11 +187,12 @@ void KX_BulletPhysicsController::RestoreDynamics() btRigidBody *body = GetRigidBody(); if (body->getActivationState() == DISABLE_SIMULATION) { - GetRigidBody()->forceActivationState(ACTIVE_TAG); GetPhysicsEnvironment()->updateCcdPhysicsController(this, + m_savedMass, m_savedCollisionFlags, m_savedCollisionFilterGroup, m_savedCollisionFilterMask); + GetRigidBody()->forceActivationState(ACTIVE_TAG); } } diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 3d7c7e5b030..93ee03660db 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -11,6 +11,8 @@ private: int m_savedCollisionFlags; short int m_savedCollisionFilterGroup; short int m_savedCollisionFilterMask; + MT_Scalar m_savedMass; + public: KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 1845fdd7b50..6f225304440 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -224,6 +224,10 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) RemoveParent(scene); obj->GetSGNode()->AddChild(GetSGNode()); + if (m_pPhysicsController1) + { + m_pPhysicsController1->SuspendDynamics(true); + } // Set us to our new scale, position, and orientation scale1[0] = scale1[0]/scale2[0]; scale1[1] = scale1[1]/scale2[1]; @@ -240,10 +244,6 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) if (rootlist->RemoveValue(this)) // the object was in parent list, decrement ref count as it's now removed Release(); - if (m_pPhysicsController1) - { - m_pPhysicsController1->SuspendDynamics(true); - } } } @@ -724,8 +724,12 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans) { - if (m_pPhysicsController1) + if (m_pPhysicsController1 && (!GetSGNode() || !GetSGNode()->GetSGParent())) { + // don't update physic controller if the object is a child: + // 1) the transformation will not be right + // 2) in this case, the physic controller is necessarily a static object + // that is updated from the normal kinematic synchronization m_pPhysicsController1->setPosition(trans); } @@ -737,25 +741,22 @@ void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans) void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot) { - if (m_pPhysicsController1) + if (m_pPhysicsController1 && (!GetSGNode() || !GetSGNode()->GetSGParent())) { + // see note above m_pPhysicsController1->setOrientation(rot.getRotation()); } if (GetSGNode()) GetSGNode()->SetLocalOrientation(rot); - else - { - int i; - i=0; - } } void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale) { - if (m_pPhysicsController1) + if (m_pPhysicsController1 && (!GetSGNode() || !GetSGNode()->GetSGParent())) { + // see note above m_pPhysicsController1->setScaling(scale); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 37fa465351f..abb71956f5a 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -106,6 +106,7 @@ class CcdPhysicsController : public PHY_IPhysicsController btRigidBody* m_body; class PHY_IMotionState* m_MotionState; btMotionState* m_bulletMotionState; + friend class CcdPhysicsEnvironment; // needed when updating the controller void* m_newClientInfo; @@ -194,7 +195,6 @@ class CcdPhysicsController : public PHY_IPhysicsController return m_cci.m_collisionFilterMask; } - virtual void calcXform() {} ; virtual void SetMargin(float margin) {}; virtual float GetMargin() const {return 0.f;}; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 7f5457121ea..b773f40650b 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -466,17 +466,39 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr } -void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctrl, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask) +void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask) { // this function is used when the collisionning group of a controller is changed // remove and add the collistioning object btRigidBody* body = ctrl->GetRigidBody(); + btVector3 inertia; m_dynamicsWorld->removeCollisionObject(body); body->setCollisionFlags(newCollisionFlags); + body->getCollisionShape()->calculateLocalInertia(newMass, inertia); + body->setMassProps(newMass, inertia); m_dynamicsWorld->addCollisionObject(body, newCollisionGroup, newCollisionMask); + // to avoid nasty interaction, we must update the property of the controller as well + ctrl->m_cci.m_mass = newMass; + ctrl->m_cci.m_collisionFilterGroup = newCollisionGroup; + ctrl->m_cci.m_collisionFilterMask = newCollisionMask; + ctrl->m_cci.m_collisionFlags = newCollisionFlags; } +void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctrl) +{ + std::vector::iterator i = + std::find(m_controllers.begin(), m_controllers.end(), ctrl); + if (i == m_controllers.end()) + { + btRigidBody* body = ctrl->GetRigidBody(); + m_dynamicsWorld->addCollisionObject(body, + ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask()); + } +} + + + void CcdPhysicsEnvironment::beginFrame() { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index dff17517b85..453749b27b3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -183,7 +183,14 @@ protected: void removeCcdPhysicsController(CcdPhysicsController* ctrl); - void updateCcdPhysicsController(CcdPhysicsController* ctrl, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask); + void updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask); + + void disableCcdPhysicsController(CcdPhysicsController* ctrl) + { + removeCcdPhysicsController(ctrl); + } + + void enableCcdPhysicsController(CcdPhysicsController* ctrl); btBroadphaseInterface* getBroadphase(); -- cgit v1.2.3 From e95e2fb43ec1546d3df05a78071269b1d0afb3e7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 20 Jul 2008 17:18:46 +0000 Subject: GameObject functions getChildren() and getChildrenRecursive() --- source/gameengine/Ketsji/KX_GameObject.cpp | 39 ++++++++++++++++++++++++++++++ source/gameengine/Ketsji/KX_GameObject.h | 2 ++ source/gameengine/PyDoc/KX_GameObject.py | 12 +++++++++ 3 files changed, 53 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6f225304440..6d0b7219ed1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -886,6 +886,8 @@ PyMethodDef KX_GameObject::Methods[] = { {"getParent", (PyCFunction)KX_GameObject::sPyGetParent,METH_NOARGS}, {"setParent", (PyCFunction)KX_GameObject::sPySetParent,METH_O}, {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_NOARGS}, + {"getChildren", (PyCFunction)KX_GameObject::sPyGetChildren,METH_NOARGS}, + {"getChildrenRecursive", (PyCFunction)KX_GameObject::sPyGetChildrenRecursive,METH_NOARGS}, {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS}, {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS}, @@ -1303,6 +1305,43 @@ PyObject* KX_GameObject::PyRemoveParent(PyObject* self) Py_RETURN_NONE; } + +static void walk_children(SG_Node* node, PyObject *list, bool recursive) +{ + NodeList& children = node->GetSGChildren(); + + for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit) + { + SG_Node* childnode = (*childit); + KX_GameObject* childobj = (KX_GameObject*)childnode->GetSGClientObject(); + if (childobj != NULL) // This is a GameObject + { + // add to the list + PyList_Append(list, (PyObject *)childobj); + } + + // if the childobj is NULL then this may be an inverse parent link + // so a non recursive search should still look down this node. + if (recursive || childobj==NULL) { + walk_children(childnode, list, recursive); + } + } +} + +PyObject* KX_GameObject::PyGetChildren(PyObject* self) +{ + PyObject * list = PyList_New(0); + walk_children(m_pSGNode, list, 0); + return list; +} + +PyObject* KX_GameObject::PyGetChildrenRecursive(PyObject* self) +{ + PyObject * list = PyList_New(0); + walk_children(m_pSGNode, list, 1); + return list; +} + PyObject* KX_GameObject::PyGetMesh(PyObject* self, PyObject* args, PyObject* kwds) diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index eba154e1094..6051cf850b5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -746,6 +746,8 @@ public: KX_PYMETHOD_NOARGS(KX_GameObject,GetParent); KX_PYMETHOD_O(KX_GameObject,SetParent); KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent); + KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren); + KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive); KX_PYMETHOD(KX_GameObject,GetMesh); KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId); KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames); diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 37c188b7f22..8f17cf26f15 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -214,6 +214,18 @@ class KX_GameObject: """ Removes this objects parent. """ + def getChildren(): + """ + Return a list of immediate children of this object. + @rtype: list + @return: a list of all this objects children. + """ + def getChildrenRecursive(): + """ + Return a list of children of this object, including all their childrens children. + @rtype: list + @return: a list of all this objects children recursivly. + """ def getMesh(mesh): """ Gets the mesh object for this object. -- cgit v1.2.3 From 9f5399918176c73fc366c0982738128c71615a77 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 20 Jul 2008 21:09:56 +0000 Subject: BGE patch: constraint orientation actuator did not work when damping=0. --- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 80288a72485..e0b2efb3a25 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -178,16 +178,18 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) direction[2] = rotation[2][1]; axis = 1; break; - case KX_ACT_CONSTRAINT_ORIZ: + default: direction[0] = rotation[0][2]; direction[1] = rotation[1][2]; direction[2] = rotation[2][2]; axis = 2; break; } - // apply damping on the direction if (m_posDampTime) { + // apply damping on the direction direction = filter*direction + (1.0-filter)*m_refDirection; + } else { + direction = m_refDirection; } obj->AlignAxisToVect(direction, axis); result = true; -- cgit v1.2.3 From 5350d5eb2c306b5ae65aa93df12d2bededd326fd Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Sun, 20 Jul 2008 23:03:01 +0000 Subject: BGE Bug Fix:#17349, fixes some problems about 2d-filters --- .../gameengine/BlenderRoutines/KX_BlenderCanvas.cpp | 12 ++++++++++++ source/gameengine/BlenderRoutines/KX_BlenderCanvas.h | 5 +++++ source/gameengine/GamePlayer/common/GPC_Canvas.h | 6 ++++++ source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 20 +++++++++++++------- source/gameengine/Rasterizer/RAS_2DFilterManager.h | 2 +- source/gameengine/Rasterizer/RAS_ICanvas.h | 8 ++++++++ 6 files changed, 45 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 5f37de24ed6..1604dfe5cce 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -101,6 +101,13 @@ int KX_BlenderCanvas::GetHeight( return scrarea_get_win_height(m_area); } +RAS_Rect & +KX_BlenderCanvas:: +GetWindowArea( +){ + return m_area_rect; +} + void KX_BlenderCanvas:: SetViewPort( @@ -112,6 +119,11 @@ SetViewPort( int minx = scrarea_get_win_x(m_area); int miny = scrarea_get_win_y(m_area); + m_area_rect.SetLeft(minx + x1); + m_area_rect.SetBottom(miny + y1); + m_area_rect.SetRight(minx + x2); + m_area_rect.SetTop(miny + y2); + glViewport(minx + x1, miny + y1, vp_width, vp_height); glScissor(minx + x1, miny + y1, vp_width, vp_height); } diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index b155d39e149..bc202a8558c 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -117,6 +117,10 @@ public: return m_displayarea; }; + RAS_Rect & + GetWindowArea( + ); + void SetViewPort( int x1, int y1, @@ -159,6 +163,7 @@ public: private: /** Blender area the game engine is running within */ struct ScrArea* m_area; + RAS_Rect m_area_rect; }; #endif // __KX_BLENDERCANVAS diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index f82166dfa88..87719041f65 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -130,6 +130,12 @@ public: ) { return m_displayarea; }; + + RAS_Rect & + GetWindowArea( + ) { + return m_displayarea; + } void BeginFrame( diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 958fead33ce..ebaeaa9e3d3 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -43,6 +43,7 @@ #include "STR_String.h" #include "RAS_ICanvas.h" +#include "RAS_Rect.h" #include "RAS_2DFilterManager.h" #include @@ -293,10 +294,13 @@ void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) } } -void RAS_2DFilterManager::UpdateOffsetMatrix(int width, int height) +void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas) { - canvaswidth = texturewidth = width; - canvasheight = textureheight = height; + RAS_Rect canvas_rect = canvas->GetWindowArea(); + canvaswidth = canvas->GetWidth(); + canvasheight = canvas->GetHeight(); + texturewidth = canvaswidth + canvas_rect.GetLeft(); + textureheight = canvasheight + canvas_rect.GetBottom(); GLint i,j; i = 0; @@ -352,7 +356,7 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) if(canvaswidth != canvas->GetWidth() || canvasheight != canvas->GetHeight()) { - UpdateOffsetMatrix(canvas->GetWidth(), canvas->GetHeight()); + UpdateOffsetMatrix(canvas); SetupTextures(need_depth, need_luminance); } GLuint viewport[4]={0}; @@ -360,19 +364,21 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) if(need_depth){ glActiveTextureARB(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texname[1]); - glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, 0,0, texturewidth,textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, 0, 0, texturewidth,textureheight, 0); } if(need_luminance){ glActiveTextureARB(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, texname[2]); - glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0,0, texturewidth,textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0, 0 , texturewidth,textureheight, 0); } glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); - glViewport(0, 0, texturewidth, textureheight); + glViewport(0,0, texturewidth, textureheight); glDisable(GL_DEPTH_TEST); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index 9d8326b96de..f5998e1f093 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -42,7 +42,7 @@ private: void SetupTextures(bool depth, bool luminance); void FreeTextures(); - void UpdateOffsetMatrix(int width, int height); + void UpdateOffsetMatrix(RAS_ICanvas* canvas); float textureoffsets[18]; float view[4]; diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index d799dc9c9bb..f3f817a943d 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -136,6 +136,14 @@ public: GetDisplayArea( ) = 0; + /** + * Used to get canvas area within blender. + */ + virtual + RAS_Rect & + GetWindowArea( + ) = 0; + /** * Set the visible vieport */ -- cgit v1.2.3 From 8f17a66036012ae3f527b95ea9489afbfb212429 Mon Sep 17 00:00:00 2001 From: Hamed Zaghaghi Date: Sun, 20 Jul 2008 23:34:17 +0000 Subject: BGE 2dFilters some extra fixes --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index ebaeaa9e3d3..ef206332057 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -159,7 +159,8 @@ void RAS_2DFilterManager::AnalyseShader(int passindex, vector& propN texflag[passindex] = 0; if(glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture") != -1) { - texflag[passindex] |= 0x1; + if(GLEW_ARB_depth_texture) + texflag[passindex] |= 0x1; } if(glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture") != -1) { @@ -262,7 +263,7 @@ void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) glGenTextures(1, (GLuint*)&texname[0]); glBindTexture(GL_TEXTURE_2D, texname[0]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGB, + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); -- cgit v1.2.3 From 4ae4ecd3ce3528a3a29ebdaaab8bb2eb01c0f5bf Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 21 Jul 2008 12:37:27 +0000 Subject: BGE patch: Optimization of bullet adaptation layer - part 1. First batch of optimizaton of the bullet adaptation layer in the BGE. - remove circular motion state update. - optimization of physic adaptation layer for bullet: bypass unecessary conversion of rotation matrix to quaternion and back. - remove double updates during object replication. --- .../Ketsji/KX_BulletPhysicsController.cpp | 5 ++-- .../gameengine/Ketsji/KX_BulletPhysicsController.h | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- source/gameengine/Ketsji/KX_IPhysicsController.h | 3 +- .../gameengine/Ketsji/KX_OdePhysicsController.cpp | 3 +- source/gameengine/Ketsji/KX_OdePhysicsController.h | 2 +- source/gameengine/Ketsji/KX_RadarSensor.cpp | 6 ++-- source/gameengine/Ketsji/KX_Scene.cpp | 13 ++++++--- .../gameengine/Ketsji/KX_SumoPhysicsController.cpp | 3 +- .../gameengine/Ketsji/KX_SumoPhysicsController.h | 2 +- .../Physics/Bullet/CcdPhysicsController.cpp | 34 ++++++++++++++++++---- .../Physics/Bullet/CcdPhysicsController.h | 3 ++ 12 files changed, 57 insertions(+), 21 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index 1553c4c61c2..c7b2a671f78 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -133,9 +133,10 @@ void KX_BulletPhysicsController::getOrientation(MT_Quaternion& orn) CcdPhysicsController::getOrientation(myorn[0],myorn[1],myorn[2],myorn[3]); orn = MT_Quaternion(myorn[0],myorn[1],myorn[2],myorn[3]); } -void KX_BulletPhysicsController::setOrientation(const MT_Quaternion& orn) +void KX_BulletPhysicsController::setOrientation(const MT_Matrix3x3& orn) { - CcdPhysicsController::setOrientation(orn.x(),orn.y(),orn.z(),orn.w()); + btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[1][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]); + CcdPhysicsController::setWorldOrientation(btmat); } void KX_BulletPhysicsController::setPosition(const MT_Point3& pos) { diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 93ee03660db..2efe0474b30 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -35,7 +35,7 @@ public: virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local); virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local); virtual void getOrientation(MT_Quaternion& orn); - virtual void setOrientation(const MT_Quaternion& orn); + virtual void setOrientation(const MT_Matrix3x3& orn); virtual void setPosition(const MT_Point3& pos); virtual void setScaling(const MT_Vector3& scaling); virtual MT_Scalar GetMass(); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6d0b7219ed1..d40fa1e2446 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -744,7 +744,7 @@ void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot) if (m_pPhysicsController1 && (!GetSGNode() || !GetSGNode()->GetSGParent())) { // see note above - m_pPhysicsController1->setOrientation(rot.getRotation()); + m_pPhysicsController1->setOrientation(rot); } if (GetSGNode()) GetSGNode()->SetLocalOrientation(rot); diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h index bc4cc185a04..ecfdb8c4275 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ b/source/gameengine/Ketsji/KX_IPhysicsController.h @@ -71,7 +71,8 @@ public: virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0; virtual void getOrientation(MT_Quaternion& orn)=0; - virtual void setOrientation(const MT_Quaternion& orn)=0; + virtual void setOrientation(const MT_Matrix3x3& orn)=0; + //virtual void setOrientation(const MT_Quaternion& orn)=0; virtual void setPosition(const MT_Point3& pos)=0; virtual void setScaling(const MT_Vector3& scaling)=0; virtual MT_Scalar GetMass()=0; diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp index 8b0a6dafc22..05feb11a2bc 100644 --- a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp @@ -133,8 +133,9 @@ void KX_OdePhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool l ODEPhysicsController::SetLinearVelocity(lin_vel[0],lin_vel[1],lin_vel[2],local); } -void KX_OdePhysicsController::setOrientation(const MT_Quaternion& orn) +void KX_OdePhysicsController::setOrientation(const MT_Matrix3x3& rot) { + MT_Quaternion orn = rot.getRotation(); ODEPhysicsController::setOrientation(orn[0],orn[1],orn[2],orn[3]); } diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h index c96c71c81f9..18f9edc6835 100644 --- a/source/gameengine/Ketsji/KX_OdePhysicsController.h +++ b/source/gameengine/Ketsji/KX_OdePhysicsController.h @@ -67,7 +67,7 @@ public: virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local); virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ); virtual void getOrientation(MT_Quaternion& orn); - virtual void setOrientation(const MT_Quaternion& orn); + virtual void setOrientation(const MT_Matrix3x3& orn); virtual void setPosition(const MT_Point3& pos); virtual void setScaling(const MT_Vector3& scaling); virtual MT_Scalar GetMass(); diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index bf2ba18f490..de4979ac4c9 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -176,8 +176,10 @@ void KX_RadarSensor::SynchronizeTransform() if (m_physCtrl) { - m_physCtrl->setPosition(trans.getOrigin().x(),trans.getOrigin().y(),trans.getOrigin().z()); - m_physCtrl->setOrientation(trans.getRotation().x(),trans.getRotation().y(),trans.getRotation().z(),trans.getRotation().w()); + MT_Quaternion orn = trans.getRotation(); + MT_Point3 pos = trans.getOrigin(); + m_physCtrl->setPosition(pos[0],pos[1],pos[2]); + m_physCtrl->setOrientation(orn[0],orn[1],orn[2],orn[3]); m_physCtrl->calcXform(); } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 1bdd4002805..c374b9d6fd1 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -712,8 +712,12 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) if (replica->GetPhysicsController()) { - replica->GetPhysicsController()->setPosition(newpos); - replica->GetPhysicsController()->setOrientation(newori.getRotation()); + // not required, already done in NodeSetLocalOrientation.. + //replica->GetPhysicsController()->setPosition(newpos); + //replica->GetPhysicsController()->setOrientation(newori.getRotation()); + // Scaling has been set relatively hereabove, this does not + // set the scaling of the controller. I don't know why it's just the + // relative scale and not the full scale that has to be put here... replica->GetPhysicsController()->setScaling(newscale); } @@ -843,8 +847,9 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, if (replica->GetPhysicsController()) { - replica->GetPhysicsController()->setPosition(newpos); - replica->GetPhysicsController()->setOrientation(newori.getRotation()); + // not needed, already done in NodeSetLocalPosition() + //replica->GetPhysicsController()->setPosition(newpos); + //replica->GetPhysicsController()->setOrientation(newori.getRotation()); replica->GetPhysicsController()->setScaling(newscale); } diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp index ffb078b346e..4032a795ce3 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp @@ -170,8 +170,9 @@ void KX_SumoPhysicsController::setMargin(float collisionMargin) } -void KX_SumoPhysicsController::setOrientation(const MT_Quaternion& orn) +void KX_SumoPhysicsController::setOrientation(const MT_Matrix3x3& rot) { + MT_Quaternion orn = rot.getRotation(); SumoPhysicsController::setOrientation( orn[0],orn[1],orn[2],orn[3]); diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h index 33666036c0d..1dd930bf3d9 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h @@ -79,7 +79,7 @@ public: void SuspendDynamics(bool); void RestoreDynamics(); virtual void getOrientation(MT_Quaternion& orn); - virtual void setOrientation(const MT_Quaternion& orn); + virtual void setOrientation(const MT_Matrix3x3& orn); virtual void setPosition(const MT_Point3& pos); virtual void setScaling(const MT_Vector3& scaling); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index e444c4c73be..5c70b071661 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -337,12 +337,33 @@ void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float { m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } - - m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); + // not required + //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); btTransform xform = m_body->getCenterOfMassTransform(); xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal)); m_body->setCenterOfMassTransform(xform); - m_bulletMotionState->setWorldTransform(xform); + // not required + //m_bulletMotionState->setWorldTransform(xform); + } + +} + +void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn) +{ + if (m_body) + { + m_body->activate(true); + if (m_body->isStaticObject()) + { + m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + } + // not required + //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); + btTransform xform = m_body->getCenterOfMassTransform(); + xform.setBasis(orn); + m_body->setCenterOfMassTransform(xform); + // not required + //m_bulletMotionState->setWorldTransform(xform); } } @@ -356,12 +377,13 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ) { m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } - - m_MotionState->setWorldPosition(posX,posY,posZ); + // not required, this function is only used to update the physic controller + //m_MotionState->setWorldPosition(posX,posY,posZ); btTransform xform = m_body->getCenterOfMassTransform(); xform.setOrigin(btVector3(posX,posY,posZ)); m_body->setCenterOfMassTransform(xform); - m_bulletMotionState->setWorldTransform(xform); + // not required + //m_bulletMotionState->setWorldTransform(xform); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index abb71956f5a..64f1876e199 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -116,6 +116,9 @@ class CcdPhysicsController : public PHY_IPhysicsController void CreateRigidbody(); + protected: + void setWorldOrientation(const btMatrix3x3& mat); + public: int m_collisionDelay; -- cgit v1.2.3 From 32d10bca2bd5e3abe853ca9b9d1c001886b28f84 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 22 Jul 2008 09:53:25 +0000 Subject: == Grease Pencil == Grease Pencil is a tool which allows you to draw freehand in some views, allowing you to annotate/scribble over the contents of that view in either 2d or 3d. This facilitates many easier communication and planning abilities. To use, simply enable it from the View menu (choose 'Grease Pencil...' and click 'Use Grease Pencil'). Then, click+drag using the left-mouse button and the shift-key held to draw a stroke. For more information, check the following page on the wiki: http://wiki.blender.org/index.php/User:Aligorith/247_Grease_Pencil --- source/gameengine/Ketsji/KX_BulletPhysicsController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index c7b2a671f78..539eaec4a7b 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -135,7 +135,7 @@ void KX_BulletPhysicsController::getOrientation(MT_Quaternion& orn) } void KX_BulletPhysicsController::setOrientation(const MT_Matrix3x3& orn) { - btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[1][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]); + btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]); CcdPhysicsController::setWorldOrientation(btmat); } void KX_BulletPhysicsController::setPosition(const MT_Point3& pos) -- cgit v1.2.3 From 1abe753bf0b05cd30785d2ccc6cca64026c2f893 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 22 Jul 2008 16:44:35 +0000 Subject: BGE patch: update KX_GameObject::getChildren() to use CListValue instead of python list (allows name search keep refcount consistent) --- source/gameengine/Ketsji/KX_GameObject.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index d40fa1e2446..185f456c83a 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1306,18 +1306,18 @@ PyObject* KX_GameObject::PyRemoveParent(PyObject* self) } -static void walk_children(SG_Node* node, PyObject *list, bool recursive) +static void walk_children(SG_Node* node, CListValue* list, bool recursive) { NodeList& children = node->GetSGChildren(); for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit) { SG_Node* childnode = (*childit); - KX_GameObject* childobj = (KX_GameObject*)childnode->GetSGClientObject(); + CValue* childobj = (CValue*)childnode->GetSGClientObject(); if (childobj != NULL) // This is a GameObject { // add to the list - PyList_Append(list, (PyObject *)childobj); + list->Add(childobj->AddRef()); } // if the childobj is NULL then this may be an inverse parent link @@ -1330,14 +1330,14 @@ static void walk_children(SG_Node* node, PyObject *list, bool recursive) PyObject* KX_GameObject::PyGetChildren(PyObject* self) { - PyObject * list = PyList_New(0); + CListValue* list = new CListValue(); walk_children(m_pSGNode, list, 0); return list; } PyObject* KX_GameObject::PyGetChildrenRecursive(PyObject* self) { - PyObject * list = PyList_New(0); + CListValue* list = new CListValue(); walk_children(m_pSGNode, list, 1); return list; } -- cgit v1.2.3 From a18c723d5514d3ee74b3d770f8e025091eee47c7 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 22 Jul 2008 23:05:06 +0000 Subject: BGE patch: Add min/max parameters to orientation constraint actuator The min/max parameters define a minimum/maximum angle that the object axis can have with the reference direction without being constrainted. The angle is expressed in degree and is limited to 0-180 range. The min/max parameters define a conical free zone around the reference direction. If the object axis is outside that free zone, the actuator will tend to put it back using as a temporary reference direction the vector that is exactly at min or max degree of the reference direction (depending if the axis angle is below the minimum or above the maximum) and is located in the plane formed by the axis and the reference direction. With a low damping value, this is equivalent to clamping the axis orientation within min/max degree of the reference direction. Backward compatibility corresponds to the absence of free zone: min = max = 0. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 2 + source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 48 ++++++++++++++++++++-- source/gameengine/Ketsji/KX_ConstraintActuator.h | 4 ++ 3 files changed, 50 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 8739fb109fd..f2ec01db839 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -628,6 +628,8 @@ void BL_ConvertActuators(char* maggiename, /* convert settings... degrees in the ui become radians */ /* internally */ if (conact->type == ACT_CONST_TYPE_ORI) { + min = (MT_2_PI * conact->minloc[0])/360.0; + max = (MT_2_PI * conact->maxloc[0])/360.0; switch (conact->mode) { case ACT_CONST_DIRPX: locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index e0b2efb3a25..800416b5f0a 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -88,11 +88,17 @@ KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj, } else { m_refDirection /= len; } + m_minimumBound = cos(minBound); + m_maximumBound = cos(maxBound); + m_minimumSine = sin(minBound); + m_maximumSine = sin(maxBound); } break; default: m_minimumBound = minBound; m_maximumBound = maxBound; + m_minimumSine = 0.f; + m_maximumSine = 0.f; break; } @@ -153,9 +159,9 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) KX_GameObject *obj = (KX_GameObject*) GetParent(); MT_Point3 position = obj->NodeGetWorldPosition(); MT_Point3 newposition; - MT_Vector3 direction; + MT_Vector3 direction, refDirection; MT_Matrix3x3 rotation = obj->NodeGetWorldOrientation(); - MT_Scalar filter, newdistance; + MT_Scalar filter, newdistance, cosangle; int axis, sign; if (m_posDampTime) { @@ -185,11 +191,45 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) axis = 2; break; } + if ((m_maximumBound < (1.0f-FLT_EPSILON)) || (m_minimumBound < (1.0f-FLT_EPSILON))) { + // reference direction needs to be evaluated + // 1. get the cosine between current direction and target + cosangle = direction.dot(m_refDirection); + if (cosangle >= (m_maximumBound-FLT_EPSILON) && cosangle <= (m_minimumBound+FLT_EPSILON)) { + // no change to do + result = true; + goto CHECK_TIME; + } + // 2. define a new reference direction + // compute local axis with reference direction as X and + // Y in direction X refDirection plane + MT_Vector3 zaxis = m_refDirection.cross(direction); + if (MT_fuzzyZero2(zaxis.length2())) { + // direction and refDirection are identical, + // choose any other direction to define plane + if (direction[0] < 0.9999) + zaxis = m_refDirection.cross(MT_Vector3(1.0,0.0,0.0)); + else + zaxis = m_refDirection.cross(MT_Vector3(0.0,1.0,0.0)); + } + MT_Vector3 yaxis = zaxis.cross(m_refDirection); + yaxis.normalize(); + if (cosangle > m_minimumBound) { + // angle is too close to reference direction, + // choose a new reference that is exactly at minimum angle + refDirection = m_minimumBound * m_refDirection + m_minimumSine * yaxis; + } else { + // angle is too large, choose new reference direction at maximum angle + refDirection = m_maximumBound * m_refDirection + m_maximumSine * yaxis; + } + } else { + refDirection = m_refDirection; + } if (m_posDampTime) { // apply damping on the direction - direction = filter*direction + (1.0-filter)*m_refDirection; + direction = filter*direction + (1.0-filter)*refDirection; } else { - direction = m_refDirection; + direction = refDirection; } obj->AlignAxisToVect(direction, axis); result = true; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index 5a1d4d23217..3ef51595098 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -48,6 +48,10 @@ protected: float m_minimumBound; // max (float) float m_maximumBound; + // sinus of minimum angle + float m_minimumSine; + // sinus of maximum angle + float m_maximumSine; // reference direction MT_Vector3 m_refDirection; // locrotxyz choice (pick one): only one choice allowed at a time! -- cgit v1.2.3 From dcbe9ade7a8ca91258742e3ac3abefa1c8108e0f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Jul 2008 15:45:23 +0000 Subject: Added NodeUpdateGS so GameObject Python api alignAxisToVect function, Otherwise the rotation isn't applied. --- source/gameengine/Ketsji/KX_GameObject.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 185f456c83a..cdcba8abb4d 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1470,6 +1470,7 @@ PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, if (PyVecTo(pyvect, vect)) { AlignAxisToVect(vect,axis,fac); + NodeUpdateGS(0.f,true); Py_RETURN_NONE; } } -- cgit v1.2.3 From 5eb14d70b9c70d155291446ad662ede658f69e6d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 23 Jul 2008 21:37:37 +0000 Subject: BGE patch: Add PyDoc for new logic bricks, set exception message on Py error, remove args on Py functions that don't take any to save CPU time --- .../Converter/BL_ShapeActionActuator.cpp | 59 ++++---- .../gameengine/Converter/BL_ShapeActionActuator.h | 16 +-- .../gameengine/Converter/KX_ConvertActuators.cpp | 12 +- source/gameengine/GameLogic/SCA_ActuatorSensor.cpp | 5 +- source/gameengine/GameLogic/SCA_ActuatorSensor.h | 2 +- source/gameengine/GameLogic/SCA_ISensor.cpp | 27 ++-- source/gameengine/GameLogic/SCA_ISensor.h | 10 +- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 79 +++++------ source/gameengine/Ketsji/KX_ConstraintActuator.h | 24 ++-- source/gameengine/Ketsji/KX_GameObject.cpp | 20 +-- source/gameengine/Ketsji/KX_IpoActuator.cpp | 44 +++--- source/gameengine/Ketsji/KX_IpoActuator.h | 12 +- source/gameengine/Ketsji/KX_ObjectActuator.cpp | 77 +++++----- source/gameengine/Ketsji/KX_ObjectActuator.h | 22 +-- source/gameengine/Ketsji/KX_PythonInit.cpp | 9 ++ source/gameengine/PyDoc/BL_ShapeActionActuator.py | 158 +++++++++++++++++++++ source/gameengine/PyDoc/KX_ActuatorSensor.py | 24 ++++ source/gameengine/PyDoc/KX_ConstraintActuator.py | 120 +++++++++++++++- source/gameengine/PyDoc/KX_IpoActuator.py | 19 ++- source/gameengine/PyDoc/KX_ObjectActuator.py | 104 +++++++++++++- source/gameengine/PyDoc/KX_StateActuator.py | 26 ++++ source/gameengine/PyDoc/SCA_ISensor.py | 18 +++ 22 files changed, 656 insertions(+), 231 deletions(-) create mode 100644 source/gameengine/PyDoc/BL_ShapeActionActuator.py create mode 100644 source/gameengine/PyDoc/KX_ActuatorSensor.py create mode 100644 source/gameengine/PyDoc/KX_StateActuator.py (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 7196b393ed4..242d648b062 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -442,15 +442,15 @@ PyMethodDef BL_ShapeActionActuator::Methods[] = { {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc}, - {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_VARARGS, GetAction_doc}, - {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_VARARGS, GetStart_doc}, - {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_VARARGS, GetEnd_doc}, - {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_VARARGS, GetBlendin_doc}, - {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_VARARGS, GetPriority_doc}, - {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_VARARGS, GetFrame_doc}, - {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, - {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_VARARGS, GetType_doc}, - {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_VARARGS, SetType_doc}, + {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, GetAction_doc}, + {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_NOARGS, GetStart_doc}, + {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_NOARGS, GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_NOARGS, GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, GetProperty_doc}, + {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, GetType_doc}, + {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, SetType_doc}, {NULL,NULL} //Sentinel }; @@ -463,9 +463,7 @@ char BL_ShapeActionActuator::GetAction_doc[] = "getAction()\n" "\tReturns a string containing the name of the current action.\n"; -PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) { PyObject *result; if (m_action){ @@ -484,9 +482,7 @@ char BL_ShapeActionActuator::GetProperty_doc[] = "getProperty()\n" "\tReturns the name of the property to be used in FromProp mode.\n"; -PyObject* BL_ShapeActionActuator::PyGetProperty(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* BL_ShapeActionActuator::PyGetProperty(PyObject* self) { PyObject *result; result = Py_BuildValue("s", (const char *)m_propname); @@ -499,9 +495,7 @@ char BL_ShapeActionActuator::GetFrame_doc[] = "getFrame()\n" "\tReturns the current frame number.\n"; -PyObject* BL_ShapeActionActuator::PyGetFrame(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* BL_ShapeActionActuator::PyGetFrame(PyObject* self) { PyObject *result; result = Py_BuildValue("f", m_localtime); @@ -514,9 +508,7 @@ char BL_ShapeActionActuator::GetEnd_doc[] = "getEnd()\n" "\tReturns the last frame of the action.\n"; -PyObject* BL_ShapeActionActuator::PyGetEnd(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* BL_ShapeActionActuator::PyGetEnd(PyObject* self) { PyObject *result; result = Py_BuildValue("f", m_endframe); @@ -529,9 +521,7 @@ char BL_ShapeActionActuator::GetStart_doc[] = "getStart()\n" "\tReturns the starting frame of the action.\n"; -PyObject* BL_ShapeActionActuator::PyGetStart(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* BL_ShapeActionActuator::PyGetStart(PyObject* self) { PyObject *result; result = Py_BuildValue("f", m_startframe); @@ -545,9 +535,7 @@ char BL_ShapeActionActuator::GetBlendin_doc[] = "\tReturns the number of interpolation animation frames to be\n" "\tgenerated when this actuator is triggered.\n"; -PyObject* BL_ShapeActionActuator::PyGetBlendin(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* BL_ShapeActionActuator::PyGetBlendin(PyObject* self) { PyObject *result; result = Py_BuildValue("f", m_blendin); @@ -561,9 +549,7 @@ char BL_ShapeActionActuator::GetPriority_doc[] = "\tReturns the priority for this actuator. Actuators with lower\n" "\tPriority numbers will override actuators with higher numbers.\n"; -PyObject* BL_ShapeActionActuator::PyGetPriority(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* BL_ShapeActionActuator::PyGetPriority(PyObject* self) { PyObject *result; result = Py_BuildValue("i", m_priority); @@ -605,6 +591,7 @@ PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self, } } else { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -627,6 +614,7 @@ PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self, m_startframe = start; } else { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -649,6 +637,7 @@ PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self, m_endframe = end; } else { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -672,6 +661,7 @@ PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self, m_blendin = blendin; } else { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -700,6 +690,7 @@ PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self, m_blendframe = m_blendin; } else { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -724,6 +715,7 @@ PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, m_priority = priority; } else { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -750,6 +742,7 @@ PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self, m_localtime=m_endframe; } else { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -773,6 +766,7 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, m_propname = string; } else { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -784,9 +778,7 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, char BL_ShapeActionActuator::GetType_doc[] = "getType()\n" "\tReturns the operation mode of the actuator.\n"; -PyObject* BL_ShapeActionActuator::PyGetType(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* BL_ShapeActionActuator::PyGetType(PyObject* self) { return Py_BuildValue("h", m_playtype); } @@ -801,6 +793,7 @@ PyObject* BL_ShapeActionActuator::PySetType(PyObject* self, short typeArg; if (!PyArg_ParseTuple(args, "h", &typeArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index 434a62a1233..a9b9ad8fa86 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -87,15 +87,15 @@ public: KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendtime); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetChannel); - KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetAction); - KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetBlendin); - KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetPriority); - KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetStart); - KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetEnd); - KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetFrame); - KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetProperty); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetAction); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetBlendin); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetPriority); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetStart); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetEnd); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrame); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetProperty); // KX_PYMETHOD(BL_ActionActuator,GetChannel); - KX_PYMETHOD_DOC(BL_ShapeActionActuator,GetType); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType); virtual PyObject* _getattr(const STR_String& attr); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index f2ec01db839..53ac730d203 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -658,18 +658,18 @@ void BL_ConvertActuators(char* maggiename, min = conact->minloc[2]; max = conact->maxloc[2]; break; - case ACT_CONST_DIRMX: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRMX; + case ACT_CONST_DIRNX: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX; min = conact->minloc[0]; max = conact->maxloc[0]; break; - case ACT_CONST_DIRMY: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRMY; + case ACT_CONST_DIRNY: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY; min = conact->minloc[1]; max = conact->maxloc[1]; break; - case ACT_CONST_DIRMZ: - locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRMZ; + case ACT_CONST_DIRNZ: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNZ; min = conact->minloc[2]; max = conact->maxloc[2]; break; diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index e1c8ef87dd1..099cb8eebd0 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -149,7 +149,7 @@ PyParentObject SCA_ActuatorSensor::Parents[] = { }; PyMethodDef SCA_ActuatorSensor::Methods[] = { - {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_VARARGS, GetActuator_doc}, + {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, GetActuator_doc}, {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, SetActuator_doc}, {NULL,NULL} //Sentinel }; @@ -162,7 +162,7 @@ PyObject* SCA_ActuatorSensor::_getattr(const STR_String& attr) { char SCA_ActuatorSensor::GetActuator_doc[] = "getActuator()\n" "\tReturn the Actuator with which the sensor operates.\n"; -PyObject* SCA_ActuatorSensor::PyGetActuator(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_ActuatorSensor::PyGetActuator(PyObject* self) { return PyString_FromString(m_checkactname); } @@ -180,6 +180,7 @@ PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyOb char *actNameArg = NULL; if (!PyArg_ParseTuple(args, "s", &actNameArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h index 6086c5bfce0..a71145f6852 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h @@ -66,7 +66,7 @@ public: /* 3. setProperty */ KX_PYMETHOD_DOC(SCA_ActuatorSensor,SetActuator); /* 4. getProperty */ - KX_PYMETHOD_DOC(SCA_ActuatorSensor,GetActuator); + KX_PYMETHOD_DOC_NOARGS(SCA_ActuatorSensor,GetActuator); }; diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 68341b57435..f11c8047fac 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -168,23 +168,23 @@ PyMethodDef SCA_ISensor::Methods[] = { {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive, METH_VARARGS, IsPositive_doc}, {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode, - METH_VARARGS, GetUsePosPulseMode_doc}, + METH_NOARGS, GetUsePosPulseMode_doc}, {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode, METH_VARARGS, SetUsePosPulseMode_doc}, {"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency, - METH_VARARGS, GetFrequency_doc}, + METH_NOARGS, GetFrequency_doc}, {"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency, METH_VARARGS, SetFrequency_doc}, {"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode, - METH_VARARGS, GetUseNegPulseMode_doc}, + METH_NOARGS, GetUseNegPulseMode_doc}, {"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode, METH_VARARGS, SetUseNegPulseMode_doc}, {"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert, - METH_VARARGS, GetInvert_doc}, + METH_NOARGS, GetInvert_doc}, {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert, METH_VARARGS, SetInvert_doc}, {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel, - METH_VARARGS, GetLevel_doc}, + METH_NOARGS, GetLevel_doc}, {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel, METH_VARARGS, SetLevel_doc}, {NULL,NULL} //Sentinel @@ -259,7 +259,7 @@ PyObject* SCA_ISensor::PyIsPositive(PyObject* self, PyObject* args, PyObject* kw char SCA_ISensor::GetUsePosPulseMode_doc[] = "getUsePosPulseMode()\n" "\tReturns whether positive pulse mode is active.\n"; -PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self) { return BoolToPyArg(m_pos_pulsemode); } @@ -286,7 +286,7 @@ PyObject* SCA_ISensor::PySetUsePosPulseMode(PyObject* self, PyObject* args, PyOb char SCA_ISensor::GetFrequency_doc[] = "getFrequency()\n" "\tReturns the frequency of the updates in pulse mode.\n" ; -PyObject* SCA_ISensor::PyGetFrequency(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_ISensor::PyGetFrequency(PyObject* self) { return PyInt_FromLong(m_pulse_frequency); } @@ -321,7 +321,7 @@ PyObject* SCA_ISensor::PySetFrequency(PyObject* self, PyObject* args, PyObject* char SCA_ISensor::GetInvert_doc[] = "getInvert()\n" "\tReturns whether or not pulses from this sensor are inverted.\n" ; -PyObject* SCA_ISensor::PyGetInvert(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_ISensor::PyGetInvert(PyObject* self) { return BoolToPyArg(m_invert); } @@ -342,11 +342,10 @@ char SCA_ISensor::GetLevel_doc[] = "getLevel()\n" "\tReturns whether this sensor is a level detector or a edge detector.\n" "\tIt makes a difference only in case of logic state transition (state actuator).\n" -"\tA level detector will immediately generate a pulse if the condition for the\n" -"\tdetector is met when entering the state. A edge detector will wait for an off-on\n" -"\ttransition to occur.\n" -"\tOnly some sensors implement this feature: keyboard.\n"; -PyObject* SCA_ISensor::PyGetLevel(PyObject* self, PyObject* args, PyObject* kwds) +"\tA level detector will immediately generate a pulse, negative or positive\n" +"\tdepending on the sensor condition, as soon as the state is activated.\n" +"\tA edge detector will wait for a state change before generating a pulse.\n"; +PyObject* SCA_ISensor::PyGetLevel(PyObject* self) { return BoolToPyArg(m_level); } @@ -366,7 +365,7 @@ PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds char SCA_ISensor::GetUseNegPulseMode_doc[] = "getUseNegPulseMode()\n" "\tReturns whether negative pulse mode is active.\n"; -PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self, PyObject* args, PyObject* kwds) +PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self) { return BoolToPyArg(m_neg_pulsemode); } diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 4ce49e71507..51837755ba4 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -136,15 +136,15 @@ public: /* Python functions: */ KX_PYMETHOD_DOC(SCA_ISensor,IsPositive); - KX_PYMETHOD_DOC(SCA_ISensor,GetUsePosPulseMode); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUsePosPulseMode); KX_PYMETHOD_DOC(SCA_ISensor,SetUsePosPulseMode); - KX_PYMETHOD_DOC(SCA_ISensor,GetFrequency); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetFrequency); KX_PYMETHOD_DOC(SCA_ISensor,SetFrequency); - KX_PYMETHOD_DOC(SCA_ISensor,GetUseNegPulseMode); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUseNegPulseMode); KX_PYMETHOD_DOC(SCA_ISensor,SetUseNegPulseMode); - KX_PYMETHOD_DOC(SCA_ISensor,GetInvert); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetInvert); KX_PYMETHOD_DOC(SCA_ISensor,SetInvert); - KX_PYMETHOD_DOC(SCA_ISensor,GetLevel); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetLevel); KX_PYMETHOD_DOC(SCA_ISensor,SetLevel); }; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 800416b5f0a..2401d69d3a3 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -237,9 +237,9 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) case KX_ACT_CONSTRAINT_DIRPX: case KX_ACT_CONSTRAINT_DIRPY: case KX_ACT_CONSTRAINT_DIRPZ: - case KX_ACT_CONSTRAINT_DIRMX: - case KX_ACT_CONSTRAINT_DIRMY: - case KX_ACT_CONSTRAINT_DIRMZ: + case KX_ACT_CONSTRAINT_DIRNX: + case KX_ACT_CONSTRAINT_DIRNY: + case KX_ACT_CONSTRAINT_DIRNZ: switch (m_locrot) { case KX_ACT_CONSTRAINT_DIRPX: direction[0] = rotation[0][0]; @@ -262,21 +262,21 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) axis = 2; sign = 1; break; - case KX_ACT_CONSTRAINT_DIRMX: + case KX_ACT_CONSTRAINT_DIRNX: direction[0] = -rotation[0][0]; direction[1] = -rotation[1][0]; direction[2] = -rotation[2][0]; axis = 0; sign = 0; break; - case KX_ACT_CONSTRAINT_DIRMY: + case KX_ACT_CONSTRAINT_DIRNY: direction[0] = -rotation[0][1]; direction[1] = -rotation[1][1]; direction[2] = -rotation[2][1]; axis = 1; sign = 0; break; - case KX_ACT_CONSTRAINT_DIRMZ: + case KX_ACT_CONSTRAINT_DIRNZ: direction[0] = -rotation[0][2]; direction[1] = -rotation[1][2]; direction[2] = -rotation[2][2]; @@ -437,27 +437,27 @@ PyParentObject KX_ConstraintActuator::Parents[] = { PyMethodDef KX_ConstraintActuator::Methods[] = { {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, SetDamp_doc}, - {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_VARARGS, GetDamp_doc}, + {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_NOARGS, GetDamp_doc}, {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, SetRotDamp_doc}, - {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_VARARGS, GetRotDamp_doc}, + {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_NOARGS, GetRotDamp_doc}, {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, SetDirection_doc}, - {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_VARARGS, GetDirection_doc}, + {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_NOARGS, GetDirection_doc}, {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, SetOption_doc}, - {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_VARARGS, GetOption_doc}, + {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_NOARGS, GetOption_doc}, {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, SetTime_doc}, - {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_VARARGS, GetTime_doc}, + {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_NOARGS, GetTime_doc}, {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, - {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, + {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_NOARGS, GetProperty_doc}, {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, SetMin_doc}, - {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_VARARGS, GetMin_doc}, + {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, GetMin_doc}, {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, SetDistance_doc}, - {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_VARARGS, GetDistance_doc}, + {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, GetDistance_doc}, {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, SetMax_doc}, - {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_VARARGS, GetMax_doc}, + {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, GetMax_doc}, {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, SetRayLength_doc}, - {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_VARARGS, GetRayLength_doc}, + {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, GetRayLength_doc}, {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, SetLimit_doc}, - {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_VARARGS, GetLimit_doc}, + {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_NOARGS, GetLimit_doc}, {NULL,NULL} //Sentinel }; @@ -476,6 +476,7 @@ PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self, PyObject* kwds) { int dampArg; if(!PyArg_ParseTuple(args, "i", &dampArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -488,9 +489,7 @@ PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self, char KX_ConstraintActuator::GetDamp_doc[] = "getDamp()\n" "\tReturns the damping parameter.\n"; -PyObject* KX_ConstraintActuator::PyGetDamp(PyObject* self, - PyObject* args, - PyObject* kwds){ +PyObject* KX_ConstraintActuator::PyGetDamp(PyObject* self){ return PyInt_FromLong(m_posDampTime); } @@ -505,6 +504,7 @@ PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* self, PyObject* kwds) { int dampArg; if(!PyArg_ParseTuple(args, "i", &dampArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -517,9 +517,7 @@ PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* self, char KX_ConstraintActuator::GetRotDamp_doc[] = "getRotDamp()\n" "\tReturns the damping time for application of the constraint.\n"; -PyObject* KX_ConstraintActuator::PyGetRotDamp(PyObject* self, - PyObject* args, - PyObject* kwds){ +PyObject* KX_ConstraintActuator::PyGetRotDamp(PyObject* self){ return PyInt_FromLong(m_rotDampTime); } @@ -536,6 +534,7 @@ PyObject* KX_ConstraintActuator::PySetDirection(PyObject* self, MT_Vector3 dir; if(!PyArg_ParseTuple(args, "(fff)", &x, &y, &z)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } dir[0] = x; @@ -554,9 +553,7 @@ PyObject* KX_ConstraintActuator::PySetDirection(PyObject* self, char KX_ConstraintActuator::GetDirection_doc[] = "getDirection()\n" "\tReturns the reference direction of the orientation constraint as a 3-tuple.\n"; -PyObject* KX_ConstraintActuator::PyGetDirection(PyObject* self, - PyObject* args, - PyObject* kwds){ +PyObject* KX_ConstraintActuator::PyGetDirection(PyObject* self){ PyObject *retVal = PyList_New(3); PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_refDirection[0])); @@ -580,6 +577,7 @@ PyObject* KX_ConstraintActuator::PySetOption(PyObject* self, PyObject* kwds) { int option; if(!PyArg_ParseTuple(args, "i", &option)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -591,9 +589,7 @@ PyObject* KX_ConstraintActuator::PySetOption(PyObject* self, char KX_ConstraintActuator::GetOption_doc[] = "getOption()\n" "\tReturns the option parameter.\n"; -PyObject* KX_ConstraintActuator::PyGetOption(PyObject* self, - PyObject* args, - PyObject* kwds){ +PyObject* KX_ConstraintActuator::PyGetOption(PyObject* self){ return PyInt_FromLong(m_option); } @@ -609,6 +605,7 @@ PyObject* KX_ConstraintActuator::PySetTime(PyObject* self, PyObject* kwds) { int t; if(!PyArg_ParseTuple(args, "i", &t)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -622,9 +619,7 @@ PyObject* KX_ConstraintActuator::PySetTime(PyObject* self, char KX_ConstraintActuator::GetTime_doc[] = "getTime()\n" "\tReturns the time parameter.\n"; -PyObject* KX_ConstraintActuator::PyGetTime(PyObject* self, - PyObject* args, - PyObject* kwds){ +PyObject* KX_ConstraintActuator::PyGetTime(PyObject* self){ return PyInt_FromLong(m_activeTime); } @@ -639,6 +634,7 @@ PyObject* KX_ConstraintActuator::PySetProperty(PyObject* self, PyObject* kwds) { char *property; if (!PyArg_ParseTuple(args, "s", &property)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } if (property == NULL) { @@ -654,9 +650,7 @@ PyObject* KX_ConstraintActuator::PySetProperty(PyObject* self, char KX_ConstraintActuator::GetProperty_doc[] = "getProperty()\n" "\tReturns the property parameter.\n"; -PyObject* KX_ConstraintActuator::PyGetProperty(PyObject* self, - PyObject* args, - PyObject* kwds){ +PyObject* KX_ConstraintActuator::PyGetProperty(PyObject* self){ return PyString_FromString(m_property); } @@ -676,6 +670,7 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self, PyObject* kwds) { float minArg; if(!PyArg_ParseTuple(args, "f", &minArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -701,9 +696,7 @@ char KX_ConstraintActuator::GetMin_doc[] = "getMin()\n" "\tReturns the lower value of the interval to which the value\n" "\tis clipped.\n"; -PyObject* KX_ConstraintActuator::PyGetMin(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_ConstraintActuator::PyGetMin(PyObject* self) { return PyFloat_FromDouble(m_minimumBound); } @@ -723,6 +716,7 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self, PyObject* kwds){ float maxArg; if(!PyArg_ParseTuple(args, "f", &maxArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -748,9 +742,7 @@ char KX_ConstraintActuator::GetMax_doc[] = "getMax()\n" "\tReturns the upper value of the interval to which the value\n" "\tis clipped.\n"; -PyObject* KX_ConstraintActuator::PyGetMax(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_ConstraintActuator::PyGetMax(PyObject* self) { return PyFloat_FromDouble(m_maximumBound); } @@ -778,6 +770,7 @@ PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self, PyObject* kwds) { int locrotArg; if(!PyArg_ParseTuple(args, "i", &locrotArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -789,9 +782,7 @@ PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self, char KX_ConstraintActuator::GetLimit_doc[] = "getLimit()\n" "\tReturns the type of constraint.\n"; -PyObject* KX_ConstraintActuator::PyGetLimit(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_ConstraintActuator::PyGetLimit(PyObject* self) { return PyInt_FromLong(m_locrot); } diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index 3ef51595098..d9f39124cac 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -84,9 +84,9 @@ protected: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, - KX_ACT_CONSTRAINT_DIRMX, - KX_ACT_CONSTRAINT_DIRMY, - KX_ACT_CONSTRAINT_DIRMZ, + KX_ACT_CONSTRAINT_DIRNX, + KX_ACT_CONSTRAINT_DIRNY, + KX_ACT_CONSTRAINT_DIRNZ, KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ, @@ -131,27 +131,27 @@ protected: virtual PyObject* _getattr(const STR_String& attr); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDamp); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetDamp); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDamp); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetRotDamp); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetRotDamp); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetRotDamp); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDirection); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetDirection); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDirection); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetOption); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetOption); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetOption); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetTime); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetTime); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetTime); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetProperty); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetProperty); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetProperty); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMin); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetMin); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMin); static char SetDistance_doc[]; static char GetDistance_doc[]; KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMax); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetMax); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMax); static char SetRayLength_doc[]; static char GetRayLength_doc[]; KX_PYMETHOD_DOC(KX_ConstraintActuator,SetLimit); - KX_PYMETHOD_DOC(KX_ConstraintActuator,GetLimit); + KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetLimit); }; #endif //__KX_CONSTRAINTACTUATOR diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index cdcba8abb4d..6c8b32b6d24 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1568,8 +1568,10 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, float dist = 0.0f; char *propName = NULL; - if (!PyArg_ParseTuple(args,"O|fs", &pyarg, &dist, &propName)) + if (!PyArg_ParseTuple(args,"O|fs", &pyarg, &dist, &propName)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; + } if (!PyVecTo(pyarg, toPoint)) { @@ -1616,11 +1618,11 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, } KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, -"rayCast(to,from,dist,prop): cast a ray and return tuple (object,hit,normal) of contact point with object within dist that matches prop or None if no hit\n" + "rayCast(to,from,dist,prop): cast a ray and return tuple (object,hit,normal) of contact point with object within dist that matches prop or (None,None,None) tuple if no hit\n" " prop = property name that object must have; can be omitted => detect any object\n" " dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to to\n" " from = 3-tuple or object reference for origin of ray (if object, use center of object)\n" -" Can None or omitted => start from self object center\n" +" Can be None or omitted => start from self object center\n" " to = 3-tuple or object reference for destination of ray (if object, use center of object)\n" "Note: the object on which you call this method matters: the ray will ignore it if it goes through it\n") { @@ -1632,8 +1634,10 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, char *propName = NULL; KX_GameObject *other; - if (!PyArg_ParseTuple(args,"O|Ofs", &pyto, &pyfrom, &dist, &propName)) + if (!PyArg_ParseTuple(args,"O|Ofs", &pyto, &pyfrom, &dist, &propName)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; + } if (!PyVecTo(pyto, toPoint)) { @@ -1691,16 +1695,14 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, if (m_pHitObject) { PyObject* returnValue = PyTuple_New(3); - if (!returnValue) + if (!returnValue) { + PyErr_SetString(PyExc_TypeError, "PyTuple_New() failed"); return NULL; + } PyTuple_SET_ITEM(returnValue, 0, m_pHitObject->AddRef()); PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(resultPoint)); PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(resultNormal)); return returnValue; - //return Py_BuildValue("(O,(fff),(fff))", - // m_pHitObject->AddRef(), // trick: KX_GameObject are not true Python object, they use a difference reference count system - // resultPoint[0], resultPoint[1], resultPoint[2], - // resultNormal[0], resultNormal[1], resultNormal[2]); } return Py_BuildValue("OOO", Py_None, Py_None, Py_None); //Py_RETURN_NONE; diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index b7103f49aee..af3add8a323 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -430,27 +430,27 @@ PyMethodDef KX_IpoActuator::Methods[] = { {"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, METH_VARARGS, SetStart_doc}, {"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, - METH_VARARGS, GetStart_doc}, + METH_NOARGS, GetStart_doc}, {"setEnd", (PyCFunction) KX_IpoActuator::sPySetEnd, METH_VARARGS, SetEnd_doc}, {"getEnd", (PyCFunction) KX_IpoActuator::sPyGetEnd, - METH_VARARGS, GetEnd_doc}, + METH_NOARGS, GetEnd_doc}, {"setIpoAsForce", (PyCFunction) KX_IpoActuator::sPySetIpoAsForce, METH_VARARGS, SetIpoAsForce_doc}, {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, - METH_VARARGS, GetIpoAsForce_doc}, + METH_NOARGS, GetIpoAsForce_doc}, {"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, METH_VARARGS, SetIpoAdd_doc}, {"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, - METH_VARARGS, GetIpoAdd_doc}, + METH_NOARGS, GetIpoAdd_doc}, {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, SetType_doc}, {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, - METH_VARARGS, GetType_doc}, + METH_NOARGS, GetType_doc}, {"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal, METH_VARARGS, SetForceIpoActsLocal_doc}, {"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal, - METH_VARARGS, GetForceIpoActsLocal_doc}, + METH_NOARGS, GetForceIpoActsLocal_doc}, {NULL,NULL} //Sentinel }; @@ -480,6 +480,7 @@ PyObject* KX_IpoActuator::PySet(PyObject* self, int startFrame, stopFrame; if(!PyArg_ParseTuple(args, "siii", &mode, &startFrame, &stopFrame, &forceToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } modenum = string2mode(mode); @@ -515,6 +516,7 @@ PyObject* KX_IpoActuator::PySetProperty(PyObject* self, /* args: property */ char *propertyName; if(!PyArg_ParseTuple(args, "s", &propertyName)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -533,6 +535,7 @@ PyObject* KX_IpoActuator::PySetStart(PyObject* self, PyObject* kwds) { float startArg; if(!PyArg_ParseTuple(args, "f", &startArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -544,9 +547,7 @@ PyObject* KX_IpoActuator::PySetStart(PyObject* self, char KX_IpoActuator::GetStart_doc[] = "getStart()\n" "\tReturns the frame from which the ipo starts playing.\n"; -PyObject* KX_IpoActuator::PyGetStart(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_IpoActuator::PyGetStart(PyObject* self) { return PyFloat_FromDouble(m_startframe); } @@ -560,6 +561,7 @@ PyObject* KX_IpoActuator::PySetEnd(PyObject* self, PyObject* kwds) { float endArg; if(!PyArg_ParseTuple(args, "f", &endArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -571,9 +573,7 @@ PyObject* KX_IpoActuator::PySetEnd(PyObject* self, char KX_IpoActuator::GetEnd_doc[] = "getEnd()\n" "\tReturns the frame at which the ipo stops playing.\n"; -PyObject* KX_IpoActuator::PyGetEnd(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_IpoActuator::PyGetEnd(PyObject* self) { return PyFloat_FromDouble(m_endframe); } @@ -588,6 +588,7 @@ PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self, int boolArg; if (!PyArg_ParseTuple(args, "i", &boolArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -601,9 +602,7 @@ PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self, char KX_IpoActuator::GetIpoAsForce_doc[] = "getIpoAsForce()\n" "\tReturns whether to interpret the ipo as a force rather than a displacement.\n"; -PyObject* KX_IpoActuator::PyGetIpoAsForce(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_IpoActuator::PyGetIpoAsForce(PyObject* self) { return BoolToPyArg(m_ipo_as_force); } @@ -618,6 +617,7 @@ PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self, int boolArg; if (!PyArg_ParseTuple(args, "i", &boolArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -631,9 +631,7 @@ PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self, char KX_IpoActuator::GetIpoAdd_doc[] = "getIpoAsAdd()\n" "\tReturns whether to interpret the ipo as additive rather than absolute.\n"; -PyObject* KX_IpoActuator::PyGetIpoAdd(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_IpoActuator::PyGetIpoAdd(PyObject* self) { return BoolToPyArg(m_ipo_add); } @@ -648,6 +646,7 @@ PyObject* KX_IpoActuator::PySetType(PyObject* self, int typeArg; if (!PyArg_ParseTuple(args, "i", &typeArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -662,9 +661,7 @@ PyObject* KX_IpoActuator::PySetType(PyObject* self, char KX_IpoActuator::GetType_doc[] = "getType()\n" "\tReturns the operation mode of the actuator.\n"; -PyObject* KX_IpoActuator::PyGetType(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_IpoActuator::PyGetType(PyObject* self) { return PyInt_FromLong(m_type); } @@ -681,6 +678,7 @@ PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* self, int boolArg; if (!PyArg_ParseTuple(args, "i", &boolArg)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -693,9 +691,7 @@ char KX_IpoActuator::GetForceIpoActsLocal_doc[] = "getForceIpoActsLocal()\n" "\tReturn whether to apply the force in the object's local\n" "\tcoordinates rather than the world global coordinates.\n"; -PyObject* KX_IpoActuator::PyGetForceIpoActsLocal(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_IpoActuator::PyGetForceIpoActsLocal(PyObject* self) { return BoolToPyArg(m_ipo_local); } diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index ae554fb0fce..d6f52f8d59d 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -143,17 +143,17 @@ public: KX_PYMETHOD_DOC(KX_IpoActuator,SetProperty); /* KX_PYMETHOD_DOC(KX_IpoActuator,SetKey2Key); */ KX_PYMETHOD_DOC(KX_IpoActuator,SetStart); - KX_PYMETHOD_DOC(KX_IpoActuator,GetStart); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetStart); KX_PYMETHOD_DOC(KX_IpoActuator,SetEnd); - KX_PYMETHOD_DOC(KX_IpoActuator,GetEnd); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetEnd); KX_PYMETHOD_DOC(KX_IpoActuator,SetIpoAsForce); - KX_PYMETHOD_DOC(KX_IpoActuator,GetIpoAsForce); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetIpoAsForce); KX_PYMETHOD_DOC(KX_IpoActuator,SetIpoAdd); - KX_PYMETHOD_DOC(KX_IpoActuator,GetIpoAdd); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetIpoAdd); KX_PYMETHOD_DOC(KX_IpoActuator,SetType); - KX_PYMETHOD_DOC(KX_IpoActuator,GetType); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetType); KX_PYMETHOD_DOC(KX_IpoActuator,SetForceIpoActsLocal); - KX_PYMETHOD_DOC(KX_IpoActuator,GetForceIpoActsLocal); + KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetForceIpoActsLocal); }; diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 9ac0b4d4703..5cd4d089c14 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -304,27 +304,27 @@ PyParentObject KX_ObjectActuator::Parents[] = { }; PyMethodDef KX_ObjectActuator::Methods[] = { - {"getForce", (PyCFunction) KX_ObjectActuator::sPyGetForce, METH_VARARGS}, + {"getForce", (PyCFunction) KX_ObjectActuator::sPyGetForce, METH_NOARGS}, {"setForce", (PyCFunction) KX_ObjectActuator::sPySetForce, METH_VARARGS}, - {"getTorque", (PyCFunction) KX_ObjectActuator::sPyGetTorque, METH_VARARGS}, + {"getTorque", (PyCFunction) KX_ObjectActuator::sPyGetTorque, METH_NOARGS}, {"setTorque", (PyCFunction) KX_ObjectActuator::sPySetTorque, METH_VARARGS}, - {"getDLoc", (PyCFunction) KX_ObjectActuator::sPyGetDLoc, METH_VARARGS}, + {"getDLoc", (PyCFunction) KX_ObjectActuator::sPyGetDLoc, METH_NOARGS}, {"setDLoc", (PyCFunction) KX_ObjectActuator::sPySetDLoc, METH_VARARGS}, - {"getDRot", (PyCFunction) KX_ObjectActuator::sPyGetDRot, METH_VARARGS}, + {"getDRot", (PyCFunction) KX_ObjectActuator::sPyGetDRot, METH_NOARGS}, {"setDRot", (PyCFunction) KX_ObjectActuator::sPySetDRot, METH_VARARGS}, - {"getLinearVelocity", (PyCFunction) KX_ObjectActuator::sPyGetLinearVelocity, METH_VARARGS}, + {"getLinearVelocity", (PyCFunction) KX_ObjectActuator::sPyGetLinearVelocity, METH_NOARGS}, {"setLinearVelocity", (PyCFunction) KX_ObjectActuator::sPySetLinearVelocity, METH_VARARGS}, - {"getAngularVelocity", (PyCFunction) KX_ObjectActuator::sPyGetAngularVelocity, METH_VARARGS}, + {"getAngularVelocity", (PyCFunction) KX_ObjectActuator::sPyGetAngularVelocity, METH_NOARGS}, {"setAngularVelocity", (PyCFunction) KX_ObjectActuator::sPySetAngularVelocity, METH_VARARGS}, {"setDamping", (PyCFunction) KX_ObjectActuator::sPySetDamping, METH_VARARGS}, - {"getDamping", (PyCFunction) KX_ObjectActuator::sPyGetDamping, METH_VARARGS}, + {"getDamping", (PyCFunction) KX_ObjectActuator::sPyGetDamping, METH_NOARGS}, {"setForceLimitX", (PyCFunction) KX_ObjectActuator::sPySetForceLimitX, METH_VARARGS}, - {"getForceLimitX", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitX, METH_VARARGS}, + {"getForceLimitX", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitX, METH_NOARGS}, {"setForceLimitY", (PyCFunction) KX_ObjectActuator::sPySetForceLimitY, METH_VARARGS}, - {"getForceLimitY", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitY, METH_VARARGS}, + {"getForceLimitY", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitY, METH_NOARGS}, {"setForceLimitZ", (PyCFunction) KX_ObjectActuator::sPySetForceLimitZ, METH_VARARGS}, - {"getForceLimitZ", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitZ, METH_VARARGS}, - {"setPID", (PyCFunction) KX_ObjectActuator::sPyGetPID, METH_VARARGS}, + {"getForceLimitZ", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitZ, METH_NOARGS}, + {"setPID", (PyCFunction) KX_ObjectActuator::sPyGetPID, METH_NOARGS}, {"getPID", (PyCFunction) KX_ObjectActuator::sPySetPID, METH_VARARGS}, @@ -340,9 +340,7 @@ PyObject* KX_ObjectActuator::_getattr(const STR_String& attr) { /* Removed! */ /* 2. getForce */ -PyObject* KX_ObjectActuator::PyGetForce(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_ObjectActuator::PyGetForce(PyObject* self) { PyObject *retVal = PyList_New(4); @@ -362,6 +360,7 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_force.setValue(vecArg); @@ -371,9 +370,7 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* self, } /* 4. getTorque */ -PyObject* KX_ObjectActuator::PyGetTorque(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_ObjectActuator::PyGetTorque(PyObject* self) { PyObject *retVal = PyList_New(4); @@ -393,6 +390,7 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_torque.setValue(vecArg); @@ -402,9 +400,7 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* self, } /* 6. getDLoc */ -PyObject* KX_ObjectActuator::PyGetDLoc(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_ObjectActuator::PyGetDLoc(PyObject* self) { PyObject *retVal = PyList_New(4); @@ -424,6 +420,7 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* self, int bToggle = 0; if(!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_dloc.setValue(vecArg); @@ -433,9 +430,7 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* self, } /* 8. getDRot */ -PyObject* KX_ObjectActuator::PyGetDRot(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_ObjectActuator::PyGetDRot(PyObject* self) { PyObject *retVal = PyList_New(4); @@ -455,6 +450,7 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_drot.setValue(vecArg); @@ -464,9 +460,7 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* self, } /* 10. getLinearVelocity */ -PyObject* KX_ObjectActuator::PyGetLinearVelocity(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_ObjectActuator::PyGetLinearVelocity(PyObject* self) { PyObject *retVal = PyList_New(4); PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0])); @@ -485,6 +479,7 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_linear_velocity.setValue(vecArg); @@ -495,9 +490,7 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* self, /* 12. getAngularVelocity */ -PyObject* KX_ObjectActuator::PyGetAngularVelocity(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_ObjectActuator::PyGetAngularVelocity(PyObject* self) { PyObject *retVal = PyList_New(4); PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0])); @@ -515,6 +508,7 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_angular_velocity.setValue(vecArg); @@ -529,6 +523,7 @@ PyObject* KX_ObjectActuator::PySetDamping(PyObject* self, PyObject* kwds) { int damping = 0; if (!PyArg_ParseTuple(args, "i", &damping) || damping < 0 || damping > 1000) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_damping = damping; @@ -536,15 +531,11 @@ PyObject* KX_ObjectActuator::PySetDamping(PyObject* self, } /* 13. getVelocityDamping */ -PyObject* KX_ObjectActuator::PyGetDamping(PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* KX_ObjectActuator::PyGetDamping(PyObject* self) { return Py_BuildValue("i",m_damping); } /* 6. getForceLimitX */ -PyObject* KX_ObjectActuator::PyGetForceLimitX(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_ObjectActuator::PyGetForceLimitX(PyObject* self) { PyObject *retVal = PyList_New(3); @@ -562,6 +553,7 @@ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* self, float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_drot[0] = vecArg[0]; @@ -571,9 +563,7 @@ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* self, } /* 6. getForceLimitY */ -PyObject* KX_ObjectActuator::PyGetForceLimitY(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_ObjectActuator::PyGetForceLimitY(PyObject* self) { PyObject *retVal = PyList_New(3); @@ -591,6 +581,7 @@ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* self, float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_drot[1] = vecArg[0]; @@ -600,9 +591,7 @@ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* self, } /* 6. getForceLimitZ */ -PyObject* KX_ObjectActuator::PyGetForceLimitZ(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_ObjectActuator::PyGetForceLimitZ(PyObject* self) { PyObject *retVal = PyList_New(3); @@ -620,6 +609,7 @@ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* self, float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_drot[2] = vecArg[0]; @@ -629,9 +619,7 @@ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* self, } /* 4. getPID */ -PyObject* KX_ObjectActuator::PyGetPID(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_ObjectActuator::PyGetPID(PyObject* self) { PyObject *retVal = PyList_New(3); @@ -648,6 +636,7 @@ PyObject* KX_ObjectActuator::PySetPID(PyObject* self, { float vecArg[3]; if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2])) { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_torque.setValue(vecArg); diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h index bb74756551f..aa686f41233 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.h +++ b/source/gameengine/Ketsji/KX_ObjectActuator.h @@ -155,27 +155,27 @@ public: virtual PyObject* _getattr(const STR_String& attr); - KX_PYMETHOD(KX_ObjectActuator,GetForce); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForce); KX_PYMETHOD(KX_ObjectActuator,SetForce); - KX_PYMETHOD(KX_ObjectActuator,GetTorque); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetTorque); KX_PYMETHOD(KX_ObjectActuator,SetTorque); - KX_PYMETHOD(KX_ObjectActuator,GetDLoc); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDLoc); KX_PYMETHOD(KX_ObjectActuator,SetDLoc); - KX_PYMETHOD(KX_ObjectActuator,GetDRot); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDRot); KX_PYMETHOD(KX_ObjectActuator,SetDRot); - KX_PYMETHOD(KX_ObjectActuator,GetLinearVelocity); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetLinearVelocity); KX_PYMETHOD(KX_ObjectActuator,SetLinearVelocity); - KX_PYMETHOD(KX_ObjectActuator,GetAngularVelocity); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetAngularVelocity); KX_PYMETHOD(KX_ObjectActuator,SetAngularVelocity); KX_PYMETHOD(KX_ObjectActuator,SetDamping); - KX_PYMETHOD(KX_ObjectActuator,GetDamping); - KX_PYMETHOD(KX_ObjectActuator,GetForceLimitX); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDamping); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitX); KX_PYMETHOD(KX_ObjectActuator,SetForceLimitX); - KX_PYMETHOD(KX_ObjectActuator,GetForceLimitY); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitY); KX_PYMETHOD(KX_ObjectActuator,SetForceLimitY); - KX_PYMETHOD(KX_ObjectActuator,GetForceLimitZ); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitZ); KX_PYMETHOD(KX_ObjectActuator,SetForceLimitZ); - KX_PYMETHOD(KX_ObjectActuator,GetPID); + KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetPID); KX_PYMETHOD(KX_ObjectActuator,SetPID); }; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 61ed8b6a8e4..b66c3e42606 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -756,6 +756,15 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX); KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY); KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY); + KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ); /* 4. Ipo actuator, simple part */ KX_MACRO_addTypesToDict(d, KX_IPOACT_PLAY, KX_IpoActuator::KX_ACT_IPO_PLAY); diff --git a/source/gameengine/PyDoc/BL_ShapeActionActuator.py b/source/gameengine/PyDoc/BL_ShapeActionActuator.py new file mode 100644 index 00000000000..63cce253fa4 --- /dev/null +++ b/source/gameengine/PyDoc/BL_ShapeActionActuator.py @@ -0,0 +1,158 @@ +# $Id$ +# Documentation for BL_ShapeActionActuator +from SCA_IActuator import * + +class BL_ShapeActionActuator(SCA_IActuator): + """ + ShapeAction Actuators apply an shape action to an mesh object. + """ + def setAction(action, reset = True): + """ + Sets the current action. + + @param action: The name of the action to set as the current action. + @type action: string + @param reset: Optional parameter indicating whether to reset the + blend timer or not. A value of 1 indicates that the + timer should be reset. A value of 0 will leave it + unchanged. If reset is not specified, the timer will + be reset. + """ + + def setStart(start): + """ + Specifies the starting frame of the animation. + + @param start: the starting frame of the animation + @type start: float + """ + + def setEnd(end): + """ + Specifies the ending frame of the animation. + + @param end: the ending frame of the animation + @type end: float + """ + def setBlendin(blendin): + """ + Specifies the number of frames of animation to generate + when making transitions between actions. + + @param blendin: the number of frames in transition. + @type blendin: float + """ + + def setPriority(priority): + """ + Sets the priority of this actuator. + + @param priority: Specifies the new priority. Actuators will lower + priority numbers will override actuators with higher + numbers. + @type priority: integer + """ + def setFrame(frame): + """ + Sets the current frame for the animation. + + @param frame: Specifies the new current frame for the animation + @type frame: float + """ + + def setProperty(prop): + """ + Sets the property to be used in FromProp playback mode. + + @param prop: the name of the property to use. + @type prop: string. + """ + + def setBlendtime(blendtime): + """ + Sets the internal frame timer. + + Allows the script to directly modify the internal timer + used when generating transitions between actions. + + @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0. + @type blendtime: float + """ + + def setType(mode): + """ + Sets the operation mode of the actuator + + @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND + @type mode: integer + """ + + def setContinue(cont): + """ + Set the actions continue option True or False. see getContinue. + + @param cont: The continue option. + @type cont: bool + """ + + def getType(): + """ + Returns the operation mode of the actuator + + @rtype: integer + @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND + """ + + def getContinue(): + """ + When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame. + + @rtype: bool + """ + + def getAction(): + """ + getAction() returns the name of the action associated with this actuator. + + @rtype: string + """ + + def getStart(): + """ + Returns the starting frame of the action. + + @rtype: float + """ + def getEnd(): + """ + Returns the last frame of the action. + + @rtype: float + """ + def getBlendin(): + """ + Returns the number of interpolation animation frames to be generated when this actuator is triggered. + + @rtype: float + """ + def getPriority(): + """ + Returns the priority for this actuator. Actuators with lower Priority numbers will + override actuators with higher numbers. + + @rtype: integer + """ + def getFrame(): + """ + Returns the current frame number. + + @rtype: float + """ + def getProperty(): + """ + Returns the name of the property to be used in FromProp mode. + + @rtype: string + """ + + diff --git a/source/gameengine/PyDoc/KX_ActuatorSensor.py b/source/gameengine/PyDoc/KX_ActuatorSensor.py new file mode 100644 index 00000000000..f9aef86f7f0 --- /dev/null +++ b/source/gameengine/PyDoc/KX_ActuatorSensor.py @@ -0,0 +1,24 @@ +# $Id$ +# Documentation for KX_ActuatorSensor +from SCA_IActuator import * + +class KX_ActuatorSensor(SCA_ISensor): + """ + Actuator sensor detect change in actuator state of the parent object. + It generates a positive pulse if the corresponding actuator is activated + and a negative pulse if the actuator is deactivated. + """ + def getActuator(): + """ + Return the Actuator with which the sensor operates. + + @rtype: string + """ + def setActuator(name): + """ + Sets the Actuator with which to operate. If there is no Actuator + of this name, the function has no effect. + + @param name: actuator name + @type name: string + """ diff --git a/source/gameengine/PyDoc/KX_ConstraintActuator.py b/source/gameengine/PyDoc/KX_ConstraintActuator.py index 9630690e572..b1c6f3c0f4e 100644 --- a/source/gameengine/PyDoc/KX_ConstraintActuator.py +++ b/source/gameengine/PyDoc/KX_ConstraintActuator.py @@ -4,7 +4,7 @@ from SCA_IActuator import * class KX_ConstraintActuator(SCA_IActuator): """ - A constraint actuator limits the position or orientation of an object. + A constraint actuator limits the position, rotation, distance or orientation of an object. """ def setDamp(time): """ @@ -24,7 +24,7 @@ class KX_ConstraintActuator(SCA_IActuator): """ Sets the lower bound of the constraint. - For rotational constraints, lower is specified in degrees. + For rotational and orientation constraints, lower is specified in degrees. @type lower: float """ @@ -32,7 +32,7 @@ class KX_ConstraintActuator(SCA_IActuator): """ Gets the lower bound of the constraint. - For rotational constraints, the lower bound is returned in radians. + For rotational and orientation constraints, the lower bound is returned in radians. @rtype: float """ @@ -40,7 +40,7 @@ class KX_ConstraintActuator(SCA_IActuator): """ Sets the upper bound of the constraint. - For rotational constraints, upper is specified in degrees. + For rotational and orientation constraints, upper is specified in degrees. @type upper: float """ @@ -48,7 +48,7 @@ class KX_ConstraintActuator(SCA_IActuator): """ Gets the upper bound of the constraint. - For rotational constraints, the upper bound is returned in radians. + For rotational and orientation constraints, the upper bound is returned in radians. @rtype: float """ @@ -60,6 +60,9 @@ class KX_ConstraintActuator(SCA_IActuator): @param limit: Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ, Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ + Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, + KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ, + Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ """ def getLimit(): """ @@ -68,5 +71,110 @@ class KX_ConstraintActuator(SCA_IActuator): See module L{GameLogic} for valid constraints. @return: Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ, - Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ + Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ, + Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, + KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ, + Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ """ + def setRotDamp(duration): + """ + Sets the time constant of the orientation constraint. + + @param duration: If the duration is negative, it is set to 0. + @type duration: integer + """ + def getRotDamp(): + """ + Returns the damping time for application of the constraint. + + @rtype: integer + """ + def setDirection(vector): + """ + Sets the reference direction in world coordinate for the orientation constraint + + @type vector: 3-tuple + """ + def getDirection(): + """ + Returns the reference direction of the orientation constraint in world coordinate. + + @rtype: 3-tuple + """ + def setOption(option): + """ + Sets several options of the distance constraint. + + @type option: integer + @param option: Binary combination of the following values: + 64 : Activate alignment to surface + 128 : Detect material rather than property + 256 : No deactivation if ray does not hit target + 512 : Activate distance control + """ + def getOption(): + """ + Returns the option parameter. + + @rtype: integer + """ + def setTime(duration): + """ + Sets the activation time of the actuator. + + @type duration: integer + @param duration: The actuator disables itself after this many frame. + If set to 0 or negative, the actuator is not limited in time. + """ + def getTime(): + """ + Returns the time parameter. + + @rtype: integer + """ + def setProperty(property): + """ + Sets the name of the property or material for the ray detection of the distance constraint. + + @type property: string + @param property: If empty, the ray will detect any collisioning object. + """ + def getProperty(): + """ + Returns the property parameter. + + @rtype: string + """ + def setDistance(distance): + """ + Sets the target distance in distance constraint. + + @type distance: float + """ + def getDistance(): + """ + Returns the distance parameter. + + @rtype: float + """ + def setRayLength(length): + """ + Sets the maximum ray length of the distance constraint. + + @type length: float + """ + def getRayLength(): + """ + Returns the length of the ray + + @rtype: float + """ + + + + + + + + + diff --git a/source/gameengine/PyDoc/KX_IpoActuator.py b/source/gameengine/PyDoc/KX_IpoActuator.py index da8d05ddd5e..1cdab829385 100644 --- a/source/gameengine/PyDoc/KX_IpoActuator.py +++ b/source/gameengine/PyDoc/KX_IpoActuator.py @@ -6,7 +6,7 @@ class KX_IpoActuator(SCA_IActuator): """ IPO actuator activates an animation. """ - def set(mode, startframe, endframe, force): + def set(mode, startframe, endframe, mode): """ Sets the properties of the actuator. @@ -16,8 +16,8 @@ class KX_IpoActuator(SCA_IActuator): @type startframe: integer @param endframe: last frame to use @type endframe: integer - @param force: interpret this ipo as a force - @type force: boolean (KX_TRUE, KX_FALSE) + @param mode: special mode + @type mode: integer (0=normal, 1=interpret location as force, 2=additive) """ def setProperty(property): """ @@ -60,6 +60,19 @@ class KX_IpoActuator(SCA_IActuator): """ Returns whether to interpret the ipo as a force rather than a displacement. + @rtype: boolean + """ + def setIpoAdd(add): + """ + Set whether to interpret the ipo as additive rather than absolute. + + @type add: boolean + @param add: KX_TRUE or KX_FALSE + """ + def getIpoAdd(): + """ + Returns whether to interpret the ipo as additive rather than absolute. + @rtype: boolean """ def setType(mode): diff --git a/source/gameengine/PyDoc/KX_ObjectActuator.py b/source/gameengine/PyDoc/KX_ObjectActuator.py index 532c18eea5c..db577d21e6f 100644 --- a/source/gameengine/PyDoc/KX_ObjectActuator.py +++ b/source/gameengine/PyDoc/KX_ObjectActuator.py @@ -6,6 +6,7 @@ class KX_ObjectActuator(SCA_IActuator): """ The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement, velocity, or angular velocity to an object. + Servo control allows to regulate force to achieve a certain speed target. """ def getForce(): """ @@ -107,15 +108,17 @@ class KX_ObjectActuator(SCA_IActuator): def getLinearVelocity(): """ Returns the linear velocity applied by the actuator. + For the servo control actuator, this is the target speed. @rtype: list [vx, vy, vz, local] @return: A four item list, containing the vector velocity, and whether the velocity is applied in local coordinates (True) or world - coordinates (False) + coordinates (False) """ def setLinearVelocity(vx, vy, vz, local): """ Sets the linear velocity applied by the actuator. + For the servo control actuator, sets the target speed. @type vx: float @param vx: the x component of the velocity vector. @@ -124,8 +127,8 @@ class KX_ObjectActuator(SCA_IActuator): @type vz: float @param vz: the z component of the velocity vector. @type local: boolean - @param local: - False: the velocity vector is applied in world coordinates. - - True: the velocity vector is applied in local coordinates. + @param local: - False: the velocity vector is in world coordinates. + - True: the velocity vector is in local coordinates. """ def getAngularVelocity(): """ @@ -150,5 +153,100 @@ class KX_ObjectActuator(SCA_IActuator): @param local: - False: the velocity vector is applied in world coordinates. - True: the velocity vector is applied in local coordinates. """ + def getDamping(): + """ + Returns the damping parameter of the servo controller. + + @rtype: integer + @return: the time constant of the servo controller in frame unit. + """ + def setDamping(damp): + """ + Sets the damping parameter of the servo controller. + + @type damp: integer + @param damp: the damping parameter in frame unit. + """ + def getForceLimitX(): + """ + Returns the min/max force limit along the X axis used by the servo controller. + + @rtype: list [min, max, enabled] + @return: A three item list, containing the min and max limits of the force as float + and whether the limits are active(true) or inactive(true) + """ + def setForceLimitX(min, max, enable): + """ + Sets the min/max force limit along the X axis and activates or deactivates the limits in the servo controller. + + @type min: float + @param min: the minimum value of the force along the X axis. + @type max: float + @param max: the maximum value of the force along the X axis. + @type enable: boolean + @param enable: - True: the force will be limited to the min/max + - False: the force will not be limited + """ + def getForceLimitY(): + """ + Returns the min/max force limit along the Y axis used by the servo controller. + + @rtype: list [min, max, enabled] + @return: A three item list, containing the min and max limits of the force as float + and whether the limits are active(true) or inactive(true) + """ + def setForceLimitY(min, max, enable): + """ + Sets the min/max force limit along the Y axis and activates or deactivates the limits in the servo controller. + + @type min: float + @param min: the minimum value of the force along the Y axis. + @type max: float + @param max: the maximum value of the force along the Y axis. + @type enable: boolean + @param enable: - True: the force will be limited to the min/max + - False: the force will not be limited + """ + def getForceLimitZ(): + """ + Returns the min/max force limit along the Z axis used by the servo controller. + + @rtype: list [min, max, enabled] + @return: A three item list, containing the min and max limits of the force as float + and whether the limits are active(true) or inactive(true) + """ + def setForceLimitZ(min, max, enable): + """ + Sets the min/max force limit along the Z axis and activates or deactivates the limits in the servo controller. + + @type min: float + @param min: the minimum value of the force along the Z axis. + @type max: float + @param max: the maximum value of the force along the Z axis. + @type enable: boolean + @param enable: - True: the force will be limited to the min/max + - False: the force will not be limited + """ + def getPID(): + """ + Returns the PID coefficient of the servo controller. + + @rtype: list [P, I, D] + @return: A three item list, containing the PID coefficient as floats: + P : proportional coefficient + I : Integral coefficient + D : Derivate coefficient + """ + def setPID(P, I, D): + """ + Sets the PID coefficients of the servo controller. + + @type P: flat + @param P: proportional coefficient + @type I: float + @param I: Integral coefficient + @type D: float + @param D: Derivate coefficient + """ diff --git a/source/gameengine/PyDoc/KX_StateActuator.py b/source/gameengine/PyDoc/KX_StateActuator.py new file mode 100644 index 00000000000..fb6ae5a3621 --- /dev/null +++ b/source/gameengine/PyDoc/KX_StateActuator.py @@ -0,0 +1,26 @@ +# $Id$ +# Documentation for KX_StateActuator +from SCA_IActuator import * + +class KX_StateActuator(SCA_IActuator): + """ + State actuator changes the state mask of parent object. + """ + def setOperation(op): + """ + Set the type of bit operation to be applied on object state mask. + Use setMask() to specify the bits that will be modified. + + @param op: bit operation (0=Copy, 1=Add, 2=Substract, 3=Invert) + @type op: integer + """ + def setMask(mask): + """ + Set the value that defines the bits that will be modified by the operation. + The bits that are 1 in the value will be updated in the object state, + the bits that are 0 are will be left unmodified expect for the Copy operation + which copies the value to the object state. + + @param mask: bits that will be modified + @type mask: integer + """ diff --git a/source/gameengine/PyDoc/SCA_ISensor.py b/source/gameengine/PyDoc/SCA_ISensor.py index b96d8c8c075..0ebc2debb31 100644 --- a/source/gameengine/PyDoc/SCA_ISensor.py +++ b/source/gameengine/PyDoc/SCA_ISensor.py @@ -59,4 +59,22 @@ class SCA_ISensor(SCA_ILogicBrick): @type invert: boolean @param invert: true if activates on negative events; false if activates on positive events. """ + def getLevel(): + """ + Returns whether this sensor is a level detector or a edge detector. + It makes a difference only in case of logic state transition (state actuator). + A level detector will immediately generate a pulse, negative or positive + depending on the sensor condition, as soon as the state is activated. + A edge detector will wait for a state change before generating a pulse. + + @rtype: boolean + @return: true if sensor is level sensitive, false if it is edge sensitive + """ + def setLevel(level): + """ + Set whether to detect level or edge transition when entering a state. + + @param level: Detect level instead of edge? (KX_TRUE, KX_FALSE) + @type level: boolean + """ -- cgit v1.2.3 From ab44742cf36639b73f1aa2c18aa55b14ff059acd Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 25 Jul 2008 10:52:10 +0000 Subject: BGE bug fix: approve patch #17297: Track To Actuator bug fix --- source/gameengine/Ketsji/KX_TrackToActuator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index c580aa4d4e5..d4bd109de1a 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -146,19 +146,19 @@ void compatible_eulFast(float *eul, float *oldrot) { float dx, dy, dz; - /* verschillen van ong 360 graden corrigeren */ + /* angular difference of 360 degrees */ dx= eul[0] - oldrot[0]; dy= eul[1] - oldrot[1]; dz= eul[2] - oldrot[2]; - if( fabs(dx) > 5.1) { + if( fabs(dx) > MT_PI) { if(dx > 0.0) eul[0] -= MT_2_PI; else eul[0]+= MT_2_PI; } - if( fabs(dy) > 5.1) { + if( fabs(dy) > MT_PI) { if(dy > 0.0) eul[1] -= MT_2_PI; else eul[1]+= MT_2_PI; } - if( fabs(dz) > 5.1 ) { + if( fabs(dz) > MT_PI ) { if(dz > 0.0) eul[2] -= MT_2_PI; else eul[2]+= MT_2_PI; } } -- cgit v1.2.3 From a7f951f25ef47a4ac98de0270b651dc74a27670d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 25 Jul 2008 13:45:57 +0000 Subject: BGE patch: approve patch #17312: Multiple material IPOs per mesh in BGE. --- .../Converter/BL_BlenderDataConversion.cpp | 10 ++-- source/gameengine/Converter/KX_IpoConvert.cpp | 59 ++++++++++++++++------ source/gameengine/Converter/KX_IpoConvert.h | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 22 +++++++- source/gameengine/Ketsji/KX_GameObject.h | 1 + .../gameengine/Ketsji/KX_MaterialIpoController.cpp | 1 + .../gameengine/Ketsji/KX_MaterialIpoController.h | 8 ++- .../gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 5 ++ .../gameengine/Rasterizer/RAS_IPolygonMaterial.h | 1 + source/gameengine/Rasterizer/RAS_MeshObject.cpp | 15 +++++- source/gameengine/Rasterizer/RAS_MeshObject.h | 1 + 11 files changed, 96 insertions(+), 29 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 1f1ac6da119..ce37ea5907f 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1989,10 +1989,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, gameobj->NodeUpdateGS(0,true); BL_ConvertIpos(blenderobject,gameobj,converter); - // TODO: expand to multiple ipos per mesh - Material *mat = give_current_material(blenderobject, 1); - if(mat) BL_ConvertMaterialIpos(mat, gameobj, converter); - + BL_ConvertMaterialIpos(blenderobject, gameobj, converter); + sumolist->Add(gameobj->AddRef()); BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer); @@ -2171,9 +2169,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, gameobj->NodeUpdateGS(0,true); BL_ConvertIpos(blenderobject,gameobj,converter); - // TODO: expand to multiple ipos per mesh - Material *mat = give_current_material(blenderobject, 1); - if(mat) BL_ConvertMaterialIpos(mat, gameobj, converter); + BL_ConvertMaterialIpos(blenderobject,gameobj, converter); sumolist->Add(gameobj->AddRef()); diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 75ca59d01e7..7410beecaf4 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -36,6 +36,7 @@ #pragma warning (disable:4786) #endif +#include "BKE_material.h" /* give_current_material */ #include "KX_GameObject.h" #include "KX_IpoConvert.h" @@ -68,6 +69,8 @@ #include "SG_Node.h" +#include "STR_HashedString.h" + static BL_InterpolatorList *GetIpoList(struct Ipo *for_ipo, KX_BlenderSceneConverter *converter) { BL_InterpolatorList *ipoList= converter->FindInterpolatorList(for_ipo); @@ -560,16 +563,15 @@ void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *co } } - -void BL_ConvertMaterialIpos( - Material* blendermaterial, +static void ConvertMaterialIpos( + Material* blendermaterial, + dword matname_hash, KX_GameObject* gameobj, KX_BlenderSceneConverter *converter ) { if (blendermaterial->ipo) { - - KX_MaterialIpoController* ipocontr = new KX_MaterialIpoController(); + KX_MaterialIpoController* ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); @@ -596,7 +598,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_COL_R); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -610,7 +612,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_COL_G); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -624,7 +626,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_COL_B); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -638,7 +640,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_ALPHA); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -653,7 +655,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_SPEC_R ); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -667,7 +669,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_SPEC_G); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -681,7 +683,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_SPEC_B); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -696,7 +698,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_HARD); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -710,7 +712,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_SPEC); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -725,7 +727,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_REF); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -739,7 +741,7 @@ void BL_ConvertMaterialIpos( ipo = ipoList->GetScalarInterpolator(MA_EMIT); if (ipo) { if (!ipocontr) { - ipocontr = new KX_MaterialIpoController(); + ipocontr = new KX_MaterialIpoController(matname_hash); gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); } @@ -752,3 +754,28 @@ void BL_ConvertMaterialIpos( } } +void BL_ConvertMaterialIpos( + struct Object* blenderobject, + KX_GameObject* gameobj, + KX_BlenderSceneConverter *converter + ) +{ + if (blenderobject->totcol==1) + { + Material *mat = give_current_material(blenderobject, 1); + // if there is only one material attached to the mesh then set material_index in BL_ConvertMaterialIpos to NULL + // --> this makes the UpdateMaterialData function in KX_GameObject.cpp use the old hack of using SetObjectColor + // because this yields a better performance as not all the vertex colors need to be edited + if(mat) ConvertMaterialIpos(mat, NULL, gameobj, converter); + } + else + { + for (int material_index=1; material_index <= blenderobject->totcol; material_index++) + { + Material *mat = give_current_material(blenderobject, material_index); + STR_HashedString matname = mat->id.name; + if(mat) ConvertMaterialIpos(mat, matname.hash(), gameobj, converter); + } + } +} + diff --git a/source/gameengine/Converter/KX_IpoConvert.h b/source/gameengine/Converter/KX_IpoConvert.h index afcb1b22821..4ec9bd31062 100644 --- a/source/gameengine/Converter/KX_IpoConvert.h +++ b/source/gameengine/Converter/KX_IpoConvert.h @@ -46,7 +46,7 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera, class KX_GameObject* cameraobj, class KX_BlenderSceneConverter *converter); -void BL_ConvertMaterialIpos(struct Material* blendermaterial, +void BL_ConvertMaterialIpos(struct Object* blenderobject, class KX_GameObject* materialobj, class KX_BlenderSceneConverter *converter); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6c8b32b6d24..3d9c7aafd70 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -442,6 +442,7 @@ void KX_GameObject::UpdateIPO(float curframetime, // IPO update void KX_GameObject::UpdateMaterialData( + dword matname_hash, MT_Vector4 rgba, MT_Vector3 specrgb, MT_Scalar hard, @@ -460,9 +461,26 @@ KX_GameObject::UpdateMaterialData( RAS_IPolyMaterial* poly = (*mit)->GetPolyMaterial(); if(poly->GetFlag() & RAS_BLENDERMAT ) { - SetObjectColor(rgba); KX_BlenderMaterial *m = static_cast(poly); - m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); + + if (matname_hash == NULL) + { + m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); + // if mesh has only one material attached to it then use original hack with no need to edit vertices (better performance) + SetObjectColor(rgba); + } + else + { + if (matname_hash == poly->GetMaterialNameHash()) + { + m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); + m_meshes[mesh]->SetVertexColor(poly,rgba); + + // no break here, because one blender material can be split into several game engine materials + // (e.g. one uvsphere material is split into one material at poles with ras_mode TRIANGLE and one material for the body + // if here was a break then would miss some vertices if material was split + } + } } } } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 6051cf850b5..1d36798b12f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -521,6 +521,7 @@ public: */ void UpdateMaterialData( + dword matname_hash, MT_Vector4 rgba, MT_Vector3 specrgb, MT_Scalar hard, diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp index c0757a32b9c..2ce5d469380 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp @@ -37,6 +37,7 @@ bool KX_MaterialIpoController::Update(double currentTime) //kxgameobj->SetObjectColor(m_rgba); kxgameobj->UpdateMaterialData( + m_matname_hash, m_rgba, m_specrgb, m_hard, diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.h b/source/gameengine/Ketsji/KX_MaterialIpoController.h index e76ddeefb04..4d2e258bf94 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.h +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.h @@ -7,6 +7,8 @@ #include "SG_Spatial.h" #include "KX_IInterpolator.h" +#include "STR_String.h" //typedef dword + class KX_MaterialIpoController : public SG_Controller { public: @@ -23,10 +25,12 @@ private: bool m_modified; double m_ipotime; + dword m_matname_hash; public: - KX_MaterialIpoController() : + KX_MaterialIpoController(dword matname_hash) : m_modified(true), - m_ipotime(0.0) + m_ipotime(0.0), + m_matname_hash(matname_hash) {} virtual ~KX_MaterialIpoController(); virtual SG_Controller* GetReplica(class SG_Node* destnode); diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index cb10ba6bf37..31bdd8638c2 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -139,6 +139,11 @@ const STR_String& RAS_IPolyMaterial::GetMaterialName() const return m_materialname; } +dword RAS_IPolyMaterial::GetMaterialNameHash() const +{ + return m_materialname.hash(); +} + const STR_String& RAS_IPolyMaterial::GetTextureName() const { return m_texturename; diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index d2d1dba99d9..6d90d260a23 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -138,6 +138,7 @@ public: unsigned int hash() const; int GetDrawingMode() const; const STR_String& GetMaterialName() const; + dword GetMaterialNameHash() const; const STR_String& GetTextureName() const; const unsigned int GetFlag() const; diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 4420f16c56d..5087f62500e 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -201,7 +201,20 @@ void RAS_MeshObject::DebugColor(unsigned int abgr) m_debugcolor = abgr; } - +void RAS_MeshObject::SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba) +{ + RAS_TexVert* vertex = NULL; + const vecVertexArray & vertexvec = GetVertexCache(mat); + + for (vector::const_iterator it = vertexvec.begin(); it != vertexvec.end(); ++it) + { + KX_VertexArray::iterator vit; + for (vit=(*it)->begin(); vit != (*it)->end(); vit++) + { + vit->SetRGBA(rgba); + } + } +} void RAS_MeshObject::SchedulePoly(const KX_VertexIndex& idx, int numverts, diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index 0d06748f91f..44ad508d1e8 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -189,6 +189,7 @@ public: ); void DebugColor(unsigned int abgr); + void SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba); /** * Sorts the polygons by their transformed z values. -- cgit v1.2.3 From 229a5809bbbe3221cd69b05b640d7596c85ed909 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Jul 2008 21:14:23 +0000 Subject: added exception messages to game engine matrix and vector conversions. also removed own unneeded defines in arithb.c --- source/gameengine/Ketsji/KX_PyMath.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h index e1715c9275f..4e383e9b3d4 100644 --- a/source/gameengine/Ketsji/KX_PyMath.h +++ b/source/gameengine/Ketsji/KX_PyMath.h @@ -84,7 +84,10 @@ bool PyMatTo(PyObject* pymat, T& mat) } } else noerror = false; - + + if (noerror==false) + PyErr_SetString(PyExc_TypeError, "could not be converted to a matrix (sequence of sequences)"); + return noerror; } @@ -97,9 +100,13 @@ bool PyVecTo(PyObject* pyval, T& vec) if (PySequence_Check(pyval)) { unsigned int numitems = PySequence_Size(pyval); - if (numitems != Size(vec)) + if (numitems != Size(vec)) { + char err[128]; + sprintf(err, "error setting vector, %d args, should be %d", numitems, Size(vec)); + PyErr_SetString(PyExc_AttributeError, err); return false; - + } + for (unsigned int x = 0; x < numitems; x++) { PyObject *item = PySequence_GetItem(pyval, x); /* new ref */ @@ -107,7 +114,17 @@ bool PyVecTo(PyObject* pyval, T& vec) Py_DECREF(item); } + if (PyErr_Occurred()) { + PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float"); + return false; + } + return true; + } else + { + char err[128]; + sprintf(err, "not a sequence type, expected a sequence of numbers size %d", Size(vec)); + PyErr_SetString(PyExc_AttributeError, err); } return false; -- cgit v1.2.3 From c4116a7f8de3738d9e771d8b1358d4e033c4e8fd Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 26 Jul 2008 11:00:21 +0000 Subject: BGE patch: support runtime duplication of groups. Adding an object with Dupligroup option set will cause the group to be instantiated. No special actuator is needed for this feature, just put dupligroup objects in inactive layers and add them dynamically --- .../Converter/BL_BlenderDataConversion.cpp | 14 +++++++------- source/gameengine/GameLogic/SCA_LogicManager.cpp | 17 +++++++++++------ source/gameengine/GameLogic/SCA_LogicManager.h | 7 ++++--- source/gameengine/Ketsji/KX_Scene.cpp | 22 +++++++++++++++++++++- 4 files changed, 43 insertions(+), 17 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index ce37ea5907f..31a055fc734 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2027,8 +2027,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, // needed for python scripting logicmgr->RegisterGameObjectName(gameobj->GetName(),gameobj); - // needed for dynamic object morphing - logicmgr->RegisterGameObj(gameobj, blenderobject); + // needed for group duplication + logicmgr->RegisterGameObj(blenderobject, gameobj); for (int i = 0; i < gameobj->GetMeshCount(); i++) logicmgr->RegisterGameMeshName(gameobj->GetMesh(i)->GetName(), blenderobject); @@ -2050,8 +2050,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie, gameobj->NodeUpdateGS(0,true); gameobj->Bucketize(); - if (gameobj->IsDupliGroup()) - grouplist.insert(blenderobject->dup_group); } else { @@ -2059,6 +2057,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, //at the end of this function if it is not a root object inactivelist->Add(gameobj->AddRef()); } + if (gameobj->IsDupliGroup()) + grouplist.insert(blenderobject->dup_group); if (converter->addInitFromFrame){ gameobj->NodeSetLocalPosition(posPrev); gameobj->NodeSetLocalOrientation(angor); @@ -2109,7 +2109,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, blenderscene); // this code is copied from above except that - // object from groups are never is active layer + // object from groups are never in active layer bool isInActiveLayer = false; bool addobj=true; @@ -2207,8 +2207,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, // needed for python scripting logicmgr->RegisterGameObjectName(gameobj->GetName(),gameobj); - // needed for dynamic object morphing - logicmgr->RegisterGameObj(gameobj, blenderobject); + // needed for group duplication + logicmgr->RegisterGameObj(blenderobject, gameobj); for (int i = 0; i < gameobj->GetMeshCount(); i++) logicmgr->RegisterGameMeshName(gameobj->GetMesh(i)->GetName(), blenderobject); diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index f50161cbecb..d1c5917f0ce 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -127,12 +127,17 @@ void SCA_LogicManager::RegisterGameMeshName(const STR_String& gamemeshname, void -void SCA_LogicManager::RegisterGameObj(CValue* gameobj, void* blendobj) +void SCA_LogicManager::RegisterGameObj(void* blendobj, CValue* gameobj) { - m_map_gameobj_to_blendobj.insert(CHashedPtr(gameobj), blendobj); + m_map_blendobj_to_gameobj.insert(CHashedPtr(blendobj), gameobj); } - +void SCA_LogicManager::UnregisterGameObj(void* blendobj, CValue* gameobj) +{ + void **obp = m_map_blendobj_to_gameobj[CHashedPtr(blendobj)]; + if (obp && (CValue*)(*obp) == gameobj) + m_map_blendobj_to_gameobj.remove(CHashedPtr(blendobj)); +} CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname) { @@ -146,10 +151,10 @@ CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname) } -void* SCA_LogicManager::FindBlendObjByGameObj(CValue* gameobject) +CValue* SCA_LogicManager::FindGameObjByBlendObj(void* blendobj) { - void **obp= m_map_gameobj_to_blendobj[CHashedPtr(gameobject)]; - return obp?*obp:NULL; + void **obp= m_map_blendobj_to_gameobj[CHashedPtr(blendobj)]; + return obp?(CValue*)(*obp):NULL; } diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index 39d8b865977..e0d3d506702 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -109,7 +109,7 @@ class SCA_LogicManager GEN_Map m_mapStringToActions; GEN_Map m_map_gamemeshname_to_blendobj; - GEN_Map m_map_gameobj_to_blendobj; + GEN_Map m_map_blendobj_to_gameobj; vector m_removedActuators; public: @@ -152,8 +152,9 @@ public: void RegisterGameMeshName(const STR_String& gamemeshname, void* blendobj); void* FindBlendObjByGameMeshName(const STR_String& gamemeshname); - void RegisterGameObj(CValue* gameobj, void* blendobj); - void* FindBlendObjByGameObj(CValue* gameobj); + void RegisterGameObj(void* blendobj, CValue* gameobj); + void UnregisterGameObj(void* blendobj, CValue* gameobj); + CValue* FindGameObjByBlendObj(void* blendobj); }; #endif //__KX_LOGICMANAGER diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index c374b9d6fd1..2d84d8f035d 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -650,7 +650,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) if (blgroupobj == blenderobj) // this check is also in group_duplilist() continue; - gameobj = m_sceneConverter->FindGameObject(blenderobj); + gameobj = (KX_GameObject*)m_logicmgr->FindGameObjByBlendObj(blenderobj); if (gameobj == NULL) { // this object has not been converted!!! @@ -860,6 +860,20 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, replica->GetSGNode()->UpdateWorldData(0); replica->GetSGNode()->SetBBox(originalobj->GetSGNode()->BBox()); replica->GetSGNode()->SetRadius(originalobj->GetSGNode()->Radius()); + // check if there are objects with dupligroup in the hierarchy + vector duplilist; + for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) + { + if ((*git)->IsDupliGroup()) + { + // separate list as m_logicHierarchicalGameObjects is also used by DupliGroupRecurse() + duplilist.push_back(*git); + } + } + for (git = duplilist.begin();!(git==duplilist.end());++git) + { + DupliGroupRecurse(*git, 0); + } // don't release replica here because we are returning it, not done with it... return replica; } @@ -906,6 +920,12 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) int ret; KX_GameObject* newobj = (KX_GameObject*) gameobj; + // keep the blender->game object association up to date + // note that all the replicas of an object will have the same + // blender object, that's why we need to check the game object + // as only the deletion of the original object must be recorded + m_logicmgr->UnregisterGameObj(newobj->GetBlenderObject(), gameobj); + //todo: look at this //GetPhysicsEnvironment()->RemovePhysicsController(gameobj->getPhysicsController()); -- cgit v1.2.3 From bc85f11e68d1c1af9e5d48afbe38c26686badcf3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 28 Jul 2008 14:28:19 +0000 Subject: Bugfix: game engine does not support non-camera type objects as a camera, would crash, so disabled using the object as a camera then. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 31a055fc734..320921722e1 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2258,7 +2258,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, } } - if (blenderscene->camera) { + // non-camera objects not supported as camera currently + if (blenderscene->camera && blenderscene->camera->type == OB_CAMERA) { KX_Camera *gamecamera= (KX_Camera*) converter->FindGameObject(blenderscene->camera); if(gamecamera) -- cgit v1.2.3 From b0c513e83a638533b117d8b14b169b4fdd7a0369 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 28 Jul 2008 22:36:27 +0000 Subject: BGE patch: fix support of group hidden layer in dupli group instantiation: only the objects in layers matching the group layer mask will be instantiated. This is equivalent to the 3D view --- source/gameengine/Ketsji/KX_Scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 2d84d8f035d..648a6ca31d5 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -657,7 +657,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) // Should not happen as dupli group are created automatically continue; } - if (blenderobj->lay & group->layer==0) + if ((blenderobj->lay & group->layer)==0) { // object is not visible in the 3D view, will not be instantiated continue; -- cgit v1.2.3 From 908337bee11f6b55c34a5880ea241b3975c35287 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 29 Jul 2008 15:48:31 +0000 Subject: Game Engine: alpha blending and sorting ======================================= Alpha blending + sorting was revised, to fix bugs and get it to work more predictable. * A new per texture face "Sort" setting defines if the face is alpha sorted or not, instead of abusing the "ZTransp" setting as it did before. * Existing files are converted to hopefully match the old behavior as much as possible with a version patch. * On new meshes the Sort flag is disabled by the default, to avoid unexpected and hard to find slowdowns. * Alpha sorting for faces was incredibly slow. Sorting faces in a mesh with 600 faces lowered the framerate from 200 to 70 fps in my test.. the sorting there case goes about 15x faster now, but it is still advised to use Clip Alpha if possible instead of regular Alpha. * There still various limitations in the alpha sorting code, I've added some comments to the code about this. Some docs at the bottom of the page: http://www.blender.org/development/current-projects/changes-since-246/realtime-glsl-materials/ Merged some fixes from the apricot branch, most important change is that tangents are now exactly the same as the rest of Blender, instead of being computed in the game engine with a different algorithm. Also, the subversion was bumped to 1. --- source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 1 + .../BlenderRoutines/KX_BlenderPolyMaterial.cpp | 114 ---- .../BlenderRoutines/KX_BlenderPolyMaterial.h | 99 ---- .../BlenderRoutines/KX_BlenderRenderTools.cpp | 1 - .../Converter/BL_BlenderDataConversion.cpp | 637 +++++++++------------ source/gameengine/Ketsji/BL_BlenderShader.cpp | 85 ++- source/gameengine/Ketsji/BL_BlenderShader.h | 14 +- source/gameengine/Ketsji/BL_Material.h | 5 +- source/gameengine/Ketsji/BL_Texture.cpp | 2 - source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 121 ++-- source/gameengine/Ketsji/KX_BlenderMaterial.h | 9 +- source/gameengine/Ketsji/KX_GameObject.cpp | 12 +- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 3 +- source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 10 +- source/gameengine/Ketsji/KX_PolygonMaterial.h | 3 +- source/gameengine/Ketsji/KX_Scene.cpp | 22 +- source/gameengine/Rasterizer/RAS_BucketManager.cpp | 43 +- source/gameengine/Rasterizer/RAS_BucketManager.h | 3 +- .../gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 14 +- .../gameengine/Rasterizer/RAS_IPolygonMaterial.h | 10 +- source/gameengine/Rasterizer/RAS_IRasterizer.h | 10 +- .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 24 +- source/gameengine/Rasterizer/RAS_MaterialBucket.h | 7 +- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 186 +++--- source/gameengine/Rasterizer/RAS_MeshObject.h | 29 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 48 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 9 +- source/gameengine/Rasterizer/RAS_Polygon.cpp | 18 - 28 files changed, 673 insertions(+), 866 deletions(-) delete mode 100644 source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp delete mode 100644 source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index ed6ea7c5f6a..da52be56d1b 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -170,6 +170,7 @@ void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface void DisableForText() { if(glIsEnabled(GL_BLEND)) glDisable(GL_BLEND); + if(glIsEnabled(GL_ALPHA_TEST)) glDisable(GL_ALPHA_TEST); if(glIsEnabled(GL_LIGHTING)) { glDisable(GL_LIGHTING); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp deleted file mode 100644 index d173b1c66d9..00000000000 --- a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/** - * $Id$ - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -#include "KX_BlenderPolyMaterial.h" -#include "BKE_mesh.h" - -#ifdef HAVE_CONFIG_H -#include -#endif -#if 0 -KX_BlenderPolyMaterial::KX_BlenderPolyMaterial(const STR_String &texname, - bool ba, - const STR_String& matname, - int tile, - int tilexrep, - int tileyrep, - int mode, - bool transparant, - bool zsort, - int lightlayer, - bool bIsTriangle, - void* clientobject, - struct MTFace* tface) - : RAS_IPolyMaterial(texname, - false, - matname, - tile, - tilexrep, - tileyrep, - mode, - transparant, - zsort, - lightlayer, - bIsTriangle, - clientobject), - m_tface(tface) -{ -} - -void KX_BlenderPolyMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const -{ - - - if (GetCachingInfo() != cachingInfo) - { - if (!cachingInfo) - { - set_tpage(NULL); - } - cachingInfo = GetCachingInfo(); - - if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)) - { - update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime()); - set_tpage(m_tface); - rasty->EnableTextures(true); - } - else - { - set_tpage(NULL); - rasty->EnableTextures(false); - } - - if(m_drawingmode & RAS_IRasterizer::KX_TWOSIDE) - { - rasty->SetCullFace(false); - } - else - { - rasty->SetCullFace(true); - } - - if (m_drawingmode & RAS_IRasterizer::KX_LINES) { - rasty->SetLines(true); - } - else { - rasty->SetLines(false); - } - } - - rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity); - rasty->SetShinyness(m_shininess); - rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0); -} - - -#endif - - diff --git a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h deleted file mode 100644 index 35823b2125b..00000000000 --- a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ -#ifndef __KX_BLENDERPOLYMATERIAL -#define __KX_BLENDERPOLYMATERIAL - -#include "RAS_MaterialBucket.h" -#include "RAS_IRasterizer.h" - -struct MTFace; -extern "C" int set_tpage(MTFace* tface); /* Worst hack ever */ - -#if 0 -class KX_BlenderPolyMaterial : public RAS_IPolyMaterial -{ - /** Blender texture face structure. */ - MTFace* m_tface; - -public: - - KX_BlenderPolyMaterial(const STR_String &texname, - bool ba, - const STR_String& matname, - int tile, - int tilexrep, - int tileyrep, - int mode, - bool transparant, - bool zsort, - int lightlayer, - bool bIsTriangle, - void* clientobject, - struct MTFace* tface); - - /** - * Returns the caching information for this material, - * This can be used to speed up the rasterizing process. - * @return The caching information. - */ - virtual TCachingInfo GetCachingInfo(void) const; - - /** - * Activates the material in the (OpenGL) rasterizer. - * On entry, the cachingInfo contains info about the last activated material. - * On exit, the cachingInfo should contain updated info about this material. - * @param rasty The rasterizer in which the material should be active. - * @param cachingInfo The information about the material used to speed up rasterizing. - */ - virtual void Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const; - - /** - * Returns the Blender texture face structure that is used for this material. - * @return The material's texture face. - */ - MTFace* GetMTFace(void) const; -protected: -private: -}; - - -inline MTFace* KX_BlenderPolyMaterial::GetMTFace(void) const -{ - return m_tface; -} - -inline RAS_IPolyMaterial::TCachingInfo KX_BlenderPolyMaterial::GetCachingInfo(void) const -{ - return GetMTFace(); -} - -#endif - -#endif // __KX_BLENDERPOLYMATERIAL - diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 220d174d464..e4eff163d5b 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -40,7 +40,6 @@ // it needs the gameobject and the sumo physics scene for a raycast #include "KX_GameObject.h" -#include "KX_BlenderPolyMaterial.h" #include "KX_PolygonMaterial.h" #include "KX_BlenderMaterial.h" diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 320921722e1..2cc5cfda84c 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -136,8 +136,12 @@ #include "BKE_mesh.h" #include "MT_Point3.h" +#include "BLI_arithb.h" + extern "C" { - #include "BKE_customdata.h" +#include "BKE_customdata.h" +#include "BKE_cdderivedmesh.h" +#include "BKE_DerivedMesh.h" } #include "BKE_material.h" /* give_current_material */ @@ -309,7 +313,6 @@ typedef struct MTF_localLayer // ------------------------------------ BL_Material* ConvertMaterial( - Mesh* mesh, Material *mat, MTFace* tface, const char *tfaceName, @@ -323,15 +326,16 @@ BL_Material* ConvertMaterial( //this needs some type of manager BL_Material *material = new BL_Material(); - int numchan = -1; + int numchan = -1, texalpha = 0; bool validmat = (mat!=0); - bool validface = (mesh->mtface && tface); + bool validface = (tface!=0); short type = 0; if( validmat ) type = 1; // material color material->IdMode = DEFAULT_BLENDER; + material->glslmat = (validmat)? glslmat: false; // -------------------------------- if(validmat) { @@ -367,12 +371,13 @@ BL_Material* ConvertMaterial( if(i==0 && facetex ) { Image*tmp = (Image*)(tface->tpage); + if(tmp) { material->img[i] = tmp; material->texname[i] = material->img[i]->id.name; material->flag[i] |= ( tface->transp &TF_ALPHA )?USEALPHA:0; material->flag[i] |= ( tface->transp &TF_ADD )?CALCALPHA:0; - material->ras_mode|= ( tface->transp &(TF_ADD | TF_ALPHA))?TRANSP:0; + if(material->img[i]->flag & IMA_REFLECT) material->mapping[i].mapping |= USEREFL; else @@ -430,6 +435,8 @@ BL_Material* ConvertMaterial( material->flag[i] |= ( mttmp->mapto & MAP_ALPHA )?TEXALPHA:0; material->flag[i] |= ( mttmp->texflag& MTEX_NEGATIVE )?TEXNEG:0; + if(!glslmat && (material->flag[i] & TEXALPHA)) + texalpha = 1; } } else if(mttmp->tex->type == TEX_ENVMAP) { @@ -546,17 +553,7 @@ BL_Material* ConvertMaterial( material->ref = mat->ref; material->amb = mat->amb; - // set alpha testing without z-sorting - if( ( validface && (!(tface->transp &~ TF_CLIP))) && mat->mode & MA_ZTRA) { - // sets the RAS_IPolyMaterial::m_flag |RAS_FORCEALPHA - // this is so we don't have the overhead of the z-sorting code - material->ras_mode|=ALPHA_TEST; - } - else{ - // use regular z-sorting - material->ras_mode |= ((mat->mode & MA_ZTRA) != 0)?ZSORT:0; - } - material->ras_mode |= ((mat->mode & MA_WIRE) != 0)?WIRE:0; + material->ras_mode |= (mat->mode & MA_WIRE)? WIRE: 0; } else { int valid = 0; @@ -574,7 +571,6 @@ BL_Material* ConvertMaterial( material->mapping[0].mapping |= ( (material->img[0]->flag & IMA_REFLECT)!=0 )?USEREFL:0; material->flag[0] |= ( tface->transp &TF_ALPHA )?USEALPHA:0; material->flag[0] |= ( tface->transp &TF_ADD )?CALCALPHA:0; - material->ras_mode|= ( tface->transp & (TF_ADD|TF_ALPHA))?TRANSP:0; valid++; } } @@ -607,10 +603,6 @@ BL_Material* ConvertMaterial( material->ras_mode |= ( (tface->mode & TF_DYNAMIC)!= 0 )?COLLIDER:0; material->transp = tface->transp; - - if(tface->transp&~TF_CLIP) - material->ras_mode |= TRANSP; - material->tile = tface->tile; material->mode = tface->mode; @@ -631,7 +623,15 @@ BL_Material* ConvertMaterial( material->tile = 0; } + // with ztransp enabled, enforce alpha blending mode + if(validmat && (mat->mode & MA_ZTRA) && (material->transp == TF_SOLID)) + material->transp = TF_ALPHA; + // always zsort alpha + add + if(material->transp == TF_ALPHA || material->transp == TF_ADD || texalpha) { + material->ras_mode |= ALPHA; + material->ras_mode |= (material->mode & TF_ALPHASORT)? ZSORT: 0; + } // get uv sets if(validmat) @@ -711,132 +711,54 @@ BL_Material* ConvertMaterial( } -static void BL_ComputeTriTangentSpace(const MT_Vector3 &v1, const MT_Vector3 &v2, const MT_Vector3 &v3, - const MT_Vector2 &uv1, const MT_Vector2 &uv2, const MT_Vector2 &uv3, - MFace* mface, MT_Vector3 *tan1, MT_Vector3 *tan2) -{ - MT_Vector3 dx1(v2 - v1), dx2(v3 - v1); - MT_Vector2 duv1(uv2 - uv1), duv2(uv3 - uv1); - - MT_Scalar r = 1.0 / (duv1.x() * duv2.y() - duv2.x() * duv1.y()); - duv1 *= r; - duv2 *= r; - MT_Vector3 sdir(duv2.y() * dx1 - duv1.y() * dx2); - MT_Vector3 tdir(duv1.x() * dx2 - duv2.x() * dx1); - - tan1[mface->v1] += sdir; - tan1[mface->v2] += sdir; - tan1[mface->v3] += sdir; - - tan2[mface->v1] += tdir; - tan2[mface->v2] += tdir; - tan2[mface->v3] += tdir; -} - -static MT_Vector4* BL_ComputeMeshTangentSpace(Mesh* mesh) -{ - MFace* mface = static_cast(mesh->mface); - MTFace* tface = static_cast(mesh->mtface); - - MT_Vector3 *tan1 = new MT_Vector3[mesh->totvert]; - MT_Vector3 *tan2 = new MT_Vector3[mesh->totvert]; - - int v; - for (v = 0; v < mesh->totvert; v++) - { - tan1[v] = MT_Vector3(0.0, 0.0, 0.0); - tan2[v] = MT_Vector3(0.0, 0.0, 0.0); - } - - for (int p = 0; p < mesh->totface; p++, mface++, tface++) - { - MT_Vector3 v1(mesh->mvert[mface->v1].co), - v2(mesh->mvert[mface->v2].co), - v3(mesh->mvert[mface->v3].co); - - MT_Vector2 uv1(tface->uv[0]), - uv2(tface->uv[1]), - uv3(tface->uv[2]); - - BL_ComputeTriTangentSpace(v1, v2, v3, uv1, uv2, uv3, mface, tan1, tan2); - if (mface->v4) - { - MT_Vector3 v4(mesh->mvert[mface->v4].co); - MT_Vector2 uv4(tface->uv[3]); - - BL_ComputeTriTangentSpace(v1, v3, v4, uv1, uv3, uv4, mface, tan1, tan2); - } - } - - MT_Vector4 *tangent = new MT_Vector4[mesh->totvert]; - for (v = 0; v < mesh->totvert; v++) - { - const MT_Vector3 no(mesh->mvert[v].no[0]/32767.0, - mesh->mvert[v].no[1]/32767.0, - mesh->mvert[v].no[2]/32767.0); - // Gram-Schmidt orthogonalize - MT_Vector3 t(tan1[v] - no.cross(no.cross(tan1[v]))); - if (!MT_fuzzyZero(t)) - t /= t.length(); - - tangent[v].x() = t.x(); - tangent[v].y() = t.y(); - tangent[v].z() = t.z(); - // Calculate handedness - tangent[v].w() = no.dot(tan1[v].cross(tan2[v])) < 0.0 ? -1.0 : 1.0; - } - - delete [] tan1; - delete [] tan2; - - return tangent; -} - RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* rendertools, KX_Scene* scene, KX_BlenderSceneConverter *converter) { RAS_MeshObject *meshobj; - bool skinMesh = false; - + bool skinMesh = false; int lightlayer = blenderobj->lay; - - MFace* mface = static_cast(mesh->mface); - MTFace* tface = static_cast(mesh->mtface); + + // Get DerivedMesh data + DerivedMesh *dm = CDDM_from_mesh(mesh, blenderobj); + + MVert *mvert = dm->getVertArray(dm); + int totvert = dm->getNumVerts(dm); + + MFace *mface = dm->getFaceArray(dm); + MTFace *tface = static_cast(dm->getFaceDataArray(dm, CD_MTFACE)); + MCol *mcol = static_cast(dm->getFaceDataArray(dm, CD_MCOL)); + float (*tangent)[3] = NULL; + int totface = dm->getNumFaces(dm); const char *tfaceName = ""; - MCol* mmcol = mesh->mcol; - MT_assert(mface || mesh->totface == 0); + if(tface) { + DM_add_tangent_layer(dm); + tangent = (float(*)[3])dm->getFaceDataArray(dm, CD_TANGENT); + } // Determine if we need to make a skinned mesh - if (mesh->dvert || mesh->key){ + if (mesh->dvert || mesh->key) { meshobj = new BL_SkinMeshObject(mesh, lightlayer); skinMesh = true; } - else { + else meshobj = new RAS_MeshObject(mesh, lightlayer); - } - MT_Vector4 *tangent = 0; - if (tface) - tangent = BL_ComputeMeshTangentSpace(mesh); - // Extract avaiable layers MTF_localLayer *layers = new MTF_localLayer[MAX_MTFACE]; - for (int lay=0; layfdata.totlayer; i++) + for (int i=0; ifaceData.totlayer; i++) { - if (mesh->fdata.layers[i].type == CD_MTFACE) + if (dm->faceData.layers[i].type == CD_MTFACE) { assert(validLayers <= 8); - layers[validLayers].face = (MTFace*)mesh->fdata.layers[i].data;; - layers[validLayers].name = mesh->fdata.layers[i].name; + layers[validLayers].face = (MTFace*)(dm->faceData.layers[i].data); + layers[validLayers].name = dm->faceData.layers[i].name; if(tface == layers[validLayers].face) tfaceName = layers[validLayers].name; validLayers++; @@ -844,271 +766,269 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* } meshobj->SetName(mesh->id.name); - meshobj->m_xyz_index_to_vertex_index_mapping.resize(mesh->totvert); - for (int f=0;ftotface;f++,mface++) + meshobj->m_xyz_index_to_vertex_index_mapping.resize(totvert); + + for (int f=0;fv3) - { - MT_Point2 uv0(0.0,0.0),uv1(0.0,0.0),uv2(0.0,0.0),uv3(0.0,0.0); - MT_Point2 uv20(0.0,0.0),uv21(0.0,0.0),uv22(0.0,0.0),uv23(0.0,0.0); - // rgb3 is set from the adjoint face in a square - unsigned int rgb0,rgb1,rgb2,rgb3 = 0; - MT_Vector3 no0(mesh->mvert[mface->v1].no[0], mesh->mvert[mface->v1].no[1], mesh->mvert[mface->v1].no[2]), - no1(mesh->mvert[mface->v2].no[0], mesh->mvert[mface->v2].no[1], mesh->mvert[mface->v2].no[2]), - no2(mesh->mvert[mface->v3].no[0], mesh->mvert[mface->v3].no[1], mesh->mvert[mface->v3].no[2]), - no3(0.0, 0.0, 0.0); - MT_Point3 pt0(mesh->mvert[mface->v1].co), - pt1(mesh->mvert[mface->v2].co), - pt2(mesh->mvert[mface->v3].co), - pt3(0.0, 0.0, 0.0); - MT_Vector4 tan0(0.0, 0.0, 0.0, 0.0), - tan1(0.0, 0.0, 0.0, 0.0), - tan2(0.0, 0.0, 0.0, 0.0), - tan3(0.0, 0.0, 0.0, 0.0); - - no0 /= 32767.0; - no1 /= 32767.0; - no2 /= 32767.0; - if (mface->v4) - { - pt3 = MT_Point3(mesh->mvert[mface->v4].co); - no3 = MT_Vector3(mesh->mvert[mface->v4].no[0], mesh->mvert[mface->v4].no[1], mesh->mvert[mface->v4].no[2]); - no3 /= 32767.0; + MT_Point2 uv0(0.0,0.0),uv1(0.0,0.0),uv2(0.0,0.0),uv3(0.0,0.0); + MT_Point2 uv20(0.0,0.0),uv21(0.0,0.0),uv22(0.0,0.0),uv23(0.0,0.0); + unsigned int rgb0,rgb1,rgb2,rgb3 = 0; + + MT_Vector3 no0, no1, no2, no3; + MT_Point3 pt0, pt1, pt2, pt3; + MT_Vector4 tan0, tan1, tan2, tan3; + + /* get coordinates, normals and tangents */ + pt0 = MT_Point3(mvert[mface->v1].co); + pt1 = MT_Point3(mvert[mface->v2].co); + pt2 = MT_Point3(mvert[mface->v3].co); + pt3 = (mface->v4)? MT_Point3(mvert[mface->v4].co): MT_Point3(0.0, 0.0, 0.0); + + if(mface->flag & ME_SMOOTH) { + float n0[3], n1[3], n2[3], n3[3]; + + NormalShortToFloat(n0, mvert[mface->v1].no); + NormalShortToFloat(n1, mvert[mface->v2].no); + NormalShortToFloat(n2, mvert[mface->v3].no); + no0 = n0; + no1 = n1; + no2 = n2; + + if(mface->v4) { + NormalShortToFloat(n3, mvert[mface->v4].no); + no3 = n3; } + else + no3 = MT_Vector3(0.0, 0.0, 0.0); + } + else { + float fno[3]; + + if(mface->v4) + CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co, + mvert[mface->v3].co, mvert[mface->v4].co, fno); + else + CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co, + mvert[mface->v3].co, fno); + + no0 = no1 = no2 = no3 = MT_Vector3(fno); + } + + if(tangent) { + tan0 = tangent[f*4 + 0]; + tan1 = tangent[f*4 + 1]; + tan2 = tangent[f*4 + 2]; + + if (mface->v4) + tan3 = tangent[f*4 + 3]; + } + + /* get material */ + ma = give_current_material(blenderobj, mface->mat_nr+1); - if(!(mface->flag & ME_SMOOTH)) - { - MT_Vector3 norm = ((pt1-pt0).cross(pt2-pt0)).safe_normalized(); - norm[0] = ((int) (10*norm[0]))/10.0; - norm[1] = ((int) (10*norm[1]))/10.0; - norm[2] = ((int) (10*norm[2]))/10.0; - no0=no1=no2=no3= norm; - + { + bool polyvisible = true; + RAS_IPolyMaterial* polymat = NULL; + BL_Material *bl_mat = NULL; + + if(converter->GetMaterials()) { + /* do Blender Multitexture and Blender GLSL materials */ + unsigned int rgb[4]; + MT_Point2 uv[4]; + + /* first is the BL_Material */ + bl_mat = ConvertMaterial(ma, tface, tfaceName, mface, mcol, + lightlayer, blenderobj, layers, converter->GetGLSLMaterials()); + + bl_mat->material_index = (int)mface->mat_nr; + + polyvisible = ((bl_mat->ras_mode & POLY_VIS)!=0); + collider = ((bl_mat->ras_mode & COLLIDER)!=0); + + /* vertex colors and uv's were stored in bl_mat temporarily */ + bl_mat->GetConversionRGB(rgb); + rgb0 = rgb[0]; rgb1 = rgb[1]; + rgb2 = rgb[2]; rgb3 = rgb[3]; + + bl_mat->GetConversionUV(uv); + uv0 = uv[0]; uv1 = uv[1]; + uv2 = uv[2]; uv3 = uv[3]; + + bl_mat->GetConversionUV2(uv); + uv20 = uv[0]; uv21 = uv[1]; + uv22 = uv[2]; uv23 = uv[3]; + + /* then the KX_BlenderMaterial */ + polymat = new KX_BlenderMaterial(scene, bl_mat, skinMesh, lightlayer, blenderobj ); } + else { + /* do Texture Face materials */ + Image* bima = (tface)? (Image*)tface->tpage: NULL; + STR_String imastr = (tface)? (bima? (bima)->id.name : "" ) : ""; - { - Material* ma = 0; - bool polyvisible = true; - RAS_IPolyMaterial* polymat = NULL; - BL_Material *bl_mat = NULL; - - if(converter->GetMaterials()) - { - if(mesh->totcol > 1) - ma = mesh->mat[mface->mat_nr]; - else - ma = give_current_material(blenderobj, 1); - - bl_mat = ConvertMaterial(mesh, ma, tface, tfaceName, mface, mmcol, lightlayer, blenderobj, layers, converter->GetGLSLMaterials()); - // set the index were dealing with - bl_mat->material_index = (int)mface->mat_nr; - - polyvisible = ((bl_mat->ras_mode & POLY_VIS)!=0); - collider = ((bl_mat->ras_mode & COLLIDER)!=0); + char transp=0; + short mode=0, tile=0; + int tilexrep=4,tileyrep = 4; + + if (bima) { + tilexrep = bima->xrep; + tileyrep = bima->yrep; + } + + /* get tface properties if available */ + if(tface) { + /* TF_DYNAMIC means the polygon is a collision face */ + collider = ((tface->mode & TF_DYNAMIC) != 0); + transp = tface->transp; + tile = tface->tile; + mode = tface->mode; - polymat = new KX_BlenderMaterial(scene, bl_mat, skinMesh, lightlayer, blenderobj ); + polyvisible = !((mface->flag & ME_HIDE)||(tface->mode & TF_INVISIBLE)); - unsigned int rgb[4]; - bl_mat->GetConversionRGB(rgb); - rgb0 = rgb[0]; rgb1 = rgb[1]; - rgb2 = rgb[2]; rgb3 = rgb[3]; - MT_Point2 uv[4]; - bl_mat->GetConversionUV(uv); - uv0 = uv[0]; uv1 = uv[1]; - uv2 = uv[2]; uv3 = uv[3]; - - bl_mat->GetConversionUV2(uv); - uv20 = uv[0]; uv21 = uv[1]; - uv22 = uv[2]; uv23 = uv[3]; - - if(tangent){ - tan0 = tangent[mface->v1]; - tan1 = tangent[mface->v2]; - tan2 = tangent[mface->v3]; - if (mface->v4) - tan3 = tangent[mface->v4]; - } + uv0 = MT_Point2(tface->uv[0]); + uv1 = MT_Point2(tface->uv[1]); + uv2 = MT_Point2(tface->uv[2]); + + if (mface->v4) + uv3 = MT_Point2(tface->uv[3]); + } + else { + /* no texfaces, set COLLSION true and everything else FALSE */ + mode = default_face_mode; + transp = TF_SOLID; + tile = 0; } - else - { - ma = give_current_material(blenderobj, 1); - Image* bima = ((mesh->mtface && tface) ? (Image*) tface->tpage : NULL); - - STR_String imastr = - ((mesh->mtface && tface) ? - (bima? (bima)->id.name : "" ) : "" ); - - char transp=0; - short mode=0, tile=0; - int tilexrep=4,tileyrep = 4; + /* get vertex colors */ + if (mcol) { + /* we have vertex colors */ + rgb0 = KX_Mcol2uint_new(mcol[0]); + rgb1 = KX_Mcol2uint_new(mcol[1]); + rgb2 = KX_Mcol2uint_new(mcol[2]); - if (bima) - { - tilexrep = bima->xrep; - tileyrep = bima->yrep; - - } + if (mface->v4) + rgb3 = KX_Mcol2uint_new(mcol[3]); + } + else { + /* no vertex colors, take from material, otherwise white */ + unsigned int color = 0xFFFFFFFFL; - if (mesh->mtface && tface) + if (ma) { - // Use texface colors if available - //TF_DYNAMIC means the polygon is a collision face - collider = ((tface->mode & TF_DYNAMIC) != 0); - transp = tface->transp &~ TF_CLIP; - tile = tface->tile; - mode = tface->mode; - - polyvisible = !((mface->flag & ME_HIDE)||(tface->mode & TF_INVISIBLE)); + union + { + unsigned char cp[4]; + unsigned int integer; + } col_converter; - uv0 = MT_Point2(tface->uv[0]); - uv1 = MT_Point2(tface->uv[1]); - uv2 = MT_Point2(tface->uv[2]); - - if (mface->v4) - uv3 = MT_Point2(tface->uv[3]); - } - else - { - // no texfaces, set COLLSION true and everything else FALSE + col_converter.cp[3] = (unsigned char) (ma->r*255.0); + col_converter.cp[2] = (unsigned char) (ma->g*255.0); + col_converter.cp[1] = (unsigned char) (ma->b*255.0); + col_converter.cp[0] = (unsigned char) (ma->alpha*255.0); - mode = default_face_mode; - transp = TF_SOLID; - tile = 0; + color = col_converter.integer; } - if (mmcol) - { - // Use vertex colors - rgb0 = KX_Mcol2uint_new(mmcol[0]); - rgb1 = KX_Mcol2uint_new(mmcol[1]); - rgb2 = KX_Mcol2uint_new(mmcol[2]); - - if (mface->v4) - rgb3 = KX_Mcol2uint_new(mmcol[3]); - } - else { - // no vertex colors: take from material if we have one, - // otherwise set to white - unsigned int color = 0xFFFFFFFFL; + rgb0 = KX_rgbaint2uint_new(color); + rgb1 = KX_rgbaint2uint_new(color); + rgb2 = KX_rgbaint2uint_new(color); + + if (mface->v4) + rgb3 = KX_rgbaint2uint_new(color); + } + + bool istriangle = (mface->v4==0); - if (ma) - { - union - { - unsigned char cp[4]; - unsigned int integer; - } col_converter; - - col_converter.cp[3] = (unsigned char) (ma->r*255.0); - col_converter.cp[2] = (unsigned char) (ma->g*255.0); - col_converter.cp[1] = (unsigned char) (ma->b*255.0); - col_converter.cp[0] = (unsigned char) (ma->alpha*255.0); - - color = col_converter.integer; - } + // only zsort alpha + add + bool alpha = (transp == TF_ALPHA || transp == TF_ADD); + bool zsort = (mode & TF_ALPHASORT)? alpha: 0; + + polymat = new KX_PolygonMaterial(imastr, ma, + tile, tilexrep, tileyrep, + mode, transp, alpha, zsort, lightlayer, istriangle, blenderobj, tface, (unsigned int*)mcol); - rgb0 = KX_rgbaint2uint_new(color); - rgb1 = KX_rgbaint2uint_new(color); - rgb2 = KX_rgbaint2uint_new(color); - - if (mface->v4) - rgb3 = KX_rgbaint2uint_new(color); - } - - bool istriangle = (mface->v4==0); - bool zsort = ma?(ma->mode & MA_ZTRA) != 0:false; - - polymat = new KX_PolygonMaterial(imastr, ma, - tile, tilexrep, tileyrep, - mode, transp, zsort, lightlayer, istriangle, blenderobj, tface, (unsigned int*)mmcol); - - if (ma) - { - polymat->m_specular = MT_Vector3(ma->specr, ma->specg, ma->specb)*ma->spec; - polymat->m_shininess = (float)ma->har/4.0; // 0 < ma->har <= 512 - polymat->m_diffuse = MT_Vector3(ma->r, ma->g, ma->b)*(ma->emit + ma->ref); + if (ma) { + polymat->m_specular = MT_Vector3(ma->specr, ma->specg, ma->specb)*ma->spec; + polymat->m_shininess = (float)ma->har/4.0; // 0 < ma->har <= 512 + polymat->m_diffuse = MT_Vector3(ma->r, ma->g, ma->b)*(ma->emit + ma->ref); + } + else { + polymat->m_specular = MT_Vector3(0.0f,0.0f,0.0f); + polymat->m_shininess = 35.0; + } + } - } else - { - polymat->m_specular = MT_Vector3(0.0f,0.0f,0.0f); - polymat->m_shininess = 35.0; - } + // see if a bucket was reused or a new one was created + // this way only one KX_BlenderMaterial object has to exist per bucket + bool bucketCreated; + RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated); + if (bucketCreated) { + // this is needed to free up memory afterwards + converter->RegisterPolyMaterial(polymat); + if(converter->GetMaterials()) { + converter->RegisterBlenderMaterial(bl_mat); } - - // see if a bucket was reused or a new one was created - // this way only one KX_BlenderMaterial object has to exist per bucket - bool bucketCreated; - RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated); - if (bucketCreated) { - // this is needed to free up memory afterwards - converter->RegisterPolyMaterial(polymat); - if(converter->GetMaterials()) { - converter->RegisterBlenderMaterial(bl_mat); - } - } else { - // delete the material objects since they are no longer needed - // from now on, use the polygon material from the material bucket - delete polymat; - if(converter->GetMaterials()) { - delete bl_mat; - } - polymat = bucket->GetPolyMaterial(); + } else { + // delete the material objects since they are no longer needed + // from now on, use the polygon material from the material bucket + delete polymat; + if(converter->GetMaterials()) { + delete bl_mat; } - - int nverts = mface->v4?4:3; - int vtxarray = meshobj->FindVertexArray(nverts,polymat); - RAS_Polygon* poly = new RAS_Polygon(bucket,polyvisible,nverts,vtxarray); + polymat = bucket->GetPolyMaterial(); + } + + int nverts = mface->v4?4:3; + int vtxarray = meshobj->FindVertexArray(nverts,polymat); + RAS_Polygon* poly = new RAS_Polygon(bucket,polyvisible,nverts,vtxarray); - bool flat; + bool flat; - if (skinMesh) { - /* If the face is set to solid, all fnors are the same */ - if (mface->flag & ME_SMOOTH) - flat = false; - else - flat = true; - } - else + if (skinMesh) { + /* If the face is set to solid, all fnors are the same */ + if (mface->flag & ME_SMOOTH) flat = false; + else + flat = true; + } + else + flat = false; - poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,flat,polymat,mface->v1)); - poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,flat,polymat,mface->v2)); - poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,flat,polymat,mface->v3)); - if (nverts==4) - poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,flat,polymat,mface->v4)); + poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,flat,polymat,mface->v1)); + poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,flat,polymat,mface->v2)); + poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,flat,polymat,mface->v3)); + if (nverts==4) + poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,flat,polymat,mface->v4)); - meshobj->AddPolygon(poly); - if (poly->IsCollider()) + meshobj->AddPolygon(poly); + if (poly->IsCollider()) + { + RAS_TriangleIndex idx; + idx.m_index[0] = mface->v1; + idx.m_index[1] = mface->v2; + idx.m_index[2] = mface->v3; + idx.m_collider = collider; + meshobj->m_triangle_indices.push_back(idx); + if (nverts==4) { - RAS_TriangleIndex idx; - idx.m_index[0] = mface->v1; - idx.m_index[1] = mface->v2; - idx.m_index[2] = mface->v3; - idx.m_collider = collider; - meshobj->m_triangle_indices.push_back(idx); - if (nverts==4) - { - idx.m_index[0] = mface->v1; - idx.m_index[1] = mface->v3; - idx.m_index[2] = mface->v4; - idx.m_collider = collider; - meshobj->m_triangle_indices.push_back(idx); - } + idx.m_index[0] = mface->v1; + idx.m_index[1] = mface->v3; + idx.m_index[2] = mface->v4; + idx.m_collider = collider; + meshobj->m_triangle_indices.push_back(idx); } - -// poly->SetVisibleWireframeEdges(mface->edcode); - poly->SetCollider(collider); } + +// poly->SetVisibleWireframeEdges(mface->edcode); + poly->SetCollider(collider); } + if (tface) tface++; - if (mmcol) - mmcol+=4; + if (mcol) + mcol+=4; for (int lay=0; layGetPolyMaterial()->OnConstruction(); } - if(tangent) - delete [] tangent; - if (layers) delete []layers; + + dm->release(dm); return meshobj; } @@ -1819,7 +1738,7 @@ KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist){ return 0; } -#include "BLI_arithb.h" + // convert blender objects into ketsji gameobjects void BL_ConvertBlenderObjects(struct Main* maggie, const STR_String& scenename, diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index dd45d522b9f..a9a0771936c 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -1,6 +1,10 @@ #include "DNA_customdata_types.h" #include "DNA_material_types.h" +#include "DNA_scene_types.h" + +#include "BKE_global.h" +#include "BKE_main.h" #include "BL_BlenderShader.h" #include "BL_Material.h" @@ -10,30 +14,51 @@ #include "GPU_material.h" #endif +#include "RAS_BucketManager.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" + + /* this is evil, but we need the scene to create materials with + * lights from the correct scene .. */ +static struct Scene *GetSceneForName(const STR_String& scenename) +{ + Scene *sce; + + for (sce= (Scene*)G.main->scene.first; sce; sce= (Scene*)sce->id.next) + if (scenename == (sce->id.name+2)) + return sce; -const bool BL_BlenderShader::Ok()const + return (Scene*)G.main->scene.first; +} + +bool BL_BlenderShader::Ok() { #ifdef BLENDER_GLSL - return (mGPUMat != 0); + VerifyShader(); + + return (mMat && mMat->gpumaterial); #else return 0; #endif } -BL_BlenderShader::BL_BlenderShader(struct Material *ma, int lightlayer) +BL_BlenderShader::BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer) : #ifdef BLENDER_GLSL - mGPUMat(0), + mScene(scene), + mMat(ma), + mGPUMat(NULL), #endif mBound(false), mLightLayer(lightlayer) { #ifdef BLENDER_GLSL - if(ma) { - GPU_material_from_blender(ma); - mGPUMat = ma->gpumaterial; + mBlenderScene = GetSceneForName(scene->GetName()); + mBlendMode = GPU_BLEND_SOLID; + + if(mMat) { + GPU_material_from_blender(mBlenderScene, mMat); + mGPUMat = mMat->gpumaterial; } #endif } @@ -41,17 +66,29 @@ BL_BlenderShader::BL_BlenderShader(struct Material *ma, int lightlayer) BL_BlenderShader::~BL_BlenderShader() { #ifdef BLENDER_GLSL - if(mGPUMat) { - GPU_material_unbind(mGPUMat); - mGPUMat = 0; - } + if(mMat && mMat->gpumaterial) + GPU_material_unbind(mMat->gpumaterial); +#endif +} + +bool BL_BlenderShader::VerifyShader() +{ +#ifdef BLENDER_GLSL + if(mMat && !mMat->gpumaterial) + GPU_material_from_blender(mBlenderScene, mMat); + + mGPUMat = mMat->gpumaterial; + + return (mMat && mGPUMat); +#else + return false; #endif } void BL_BlenderShader::SetProg(bool enable) { #ifdef BLENDER_GLSL - if(mGPUMat) { + if(VerifyShader()) { if(enable) { GPU_material_bind(mGPUMat, mLightLayer); mBound = true; @@ -70,7 +107,7 @@ int BL_BlenderShader::GetAttribNum() GPUVertexAttribs attribs; int i, enabled = 0; - if(!mGPUMat) + if(!VerifyShader()) return enabled; GPU_material_vertex_attributes(mGPUMat, &attribs); @@ -96,7 +133,7 @@ void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat) ras->SetAttribNum(0); - if(!mGPUMat) + if(!VerifyShader()) return; if(ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) { @@ -142,9 +179,11 @@ void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat) void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) { #ifdef BLENDER_GLSL - float obmat[4][4], viewmat[4][4], viewinvmat[4][4]; + float obmat[4][4], viewmat[4][4], viewinvmat[4][4], obcol[4]; + + VerifyShader(); - if(!mGPUMat || !mBound) + if(!mGPUMat) // || !mBound) return; MT_Matrix4x4 model; @@ -158,10 +197,22 @@ void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) view.invert(); view.getValue((float*)viewinvmat); - GPU_material_bind_uniforms(mGPUMat, obmat, viewmat, viewinvmat); + if(ms.m_bObjectColor) + ms.m_RGBAcolor.getValue((float*)obcol); + else + obcol[0]= obcol[1]= obcol[2]= obcol[3]= 1.0f; + + GPU_material_bind_uniforms(mGPUMat, obmat, viewmat, viewinvmat, obcol); + + mBlendMode = GPU_material_blend_mode(mGPUMat, obcol); #endif } +int BL_BlenderShader::GetBlendMode() +{ + return mBlendMode; +} + bool BL_BlenderShader::Equals(BL_BlenderShader *blshader) { #ifdef BLENDER_GLSL diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index b758d1a9cba..da9765dafa4 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -14,7 +14,10 @@ #include "RAS_IPolygonMaterial.h" +#include "KX_Scene.h" + struct Material; +struct Scene; class BL_Material; #define BL_MAX_ATTRIB 16 @@ -27,21 +30,28 @@ class BL_BlenderShader { private: #ifdef BLENDER_GLSL + KX_Scene *mScene; + struct Scene *mBlenderScene; + struct Material *mMat; GPUMaterial *mGPUMat; #endif bool mBound; int mLightLayer; + int mBlendMode; + + bool VerifyShader(); public: - BL_BlenderShader(struct Material *ma, int lightlayer); + BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer); virtual ~BL_BlenderShader(); - const bool Ok()const; + bool Ok(); void SetProg(bool enable); int GetAttribNum(); void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat); void Update(const class KX_MeshSlot & ms, class RAS_IRasterizer* rasty); + int GetBlendMode(); bool Equals(BL_BlenderShader *blshader); }; diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index 568f7e171de..dcb66ea2579 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -129,8 +129,7 @@ enum BL_flag TEXALPHA=8, // use alpha combiner functions TEXNEG=16, // negate blending HASIPO=32, - USENEGALPHA=64, - ALPHA_TEST=128 + USENEGALPHA=64 }; // BL_Material::ras_mode @@ -139,7 +138,7 @@ enum BL_ras_mode POLY_VIS=1, COLLIDER=2, ZSORT=4, - TRANSP=8, + ALPHA=8, TRIANGLE=16, USE_LIGHT=32, WIRE=64 diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index f24ef4322f0..f0ef84032f7 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -384,8 +384,6 @@ void BL_Texture::DisableUnit() void BL_Texture::DisableAllTextures() { - glDisable(GL_BLEND); - for(int i=0; itilexrep[0], data->tileyrep[0], data->mode, - ((data->ras_mode &TRANSP)!=0), + data->transp, + ((data->ras_mode &ALPHA)!=0), ((data->ras_mode &ZSORT)!=0), lightlayer, ((data->ras_mode &TRIANGLE)!=0), @@ -79,7 +81,6 @@ KX_BlenderMaterial::KX_BlenderMaterial( m_flag |=RAS_BLENDERMAT; m_flag |=(mMaterial->IdMode>=ONETEX)?RAS_MULTITEX:0; m_flag |=(mMaterial->ras_mode & USE_LIGHT)!=0?RAS_MULTILIGHT:0; - m_flag |=(mMaterial->ras_mode &ALPHA_TEST)!=0?RAS_FORCEALPHA:0; // figure max int enabled = mMaterial->num_enabled; @@ -158,12 +159,29 @@ void KX_BlenderMaterial::OnConstruction() mConstructed = true; } +void KX_BlenderMaterial::EndFrame() +{ + if(mLastBlenderShader) { + mLastBlenderShader->SetProg(false); + mLastBlenderShader = NULL; + } + + if(mLastShader) { + mLastShader->SetProg(false); + mLastShader = NULL; + } +} + void KX_BlenderMaterial::OnExit() { if( mShader ) { - //note, the shader here is allocated, per unique material - //and this function is called per face - mShader->SetProg(false); + //note, the shader here is allocated, per unique material + //and this function is called per face + if(mShader == mLastShader) { + mShader->SetProg(false); + mLastShader = NULL; + } + delete mShader; mShader = 0; } @@ -197,13 +215,19 @@ void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras) int i; if( !enable || !mShader->Ok() ) { // frame cleanup. - mShader->SetProg(false); + if(mShader == mLastShader) { + mShader->SetProg(false); + mLastShader = NULL; + } + + ras->SetBlendingMode(TF_SOLID); BL_Texture::DisableAllTextures(); return; } BL_Texture::DisableAllTextures(); mShader->SetProg(true); + mLastShader = mShader; BL_Texture::ActivateFirst(); @@ -217,9 +241,12 @@ void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras) } if(!mUserDefBlend) { - setDefaultBlending(); + ras->SetBlendingMode(mMaterial->transp); } else { + ras->SetBlendingMode(TF_SOLID); + ras->SetBlendingMode(-1); // indicates custom mode + // tested to be valid enums glEnable(GL_BLEND); glBlendFunc(mBlendFunc[0], mBlendFunc[1]); @@ -234,11 +261,14 @@ void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras mLastBlenderShader->SetProg(false); mLastBlenderShader= NULL; } + + ras->SetBlendingMode(TF_SOLID); BL_Texture::DisableAllTextures(); return; } if(!mBlenderShader->Equals(mLastBlenderShader)) { + ras->SetBlendingMode(mMaterial->transp); BL_Texture::DisableAllTextures(); if(mLastBlenderShader) @@ -251,17 +281,17 @@ void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) { - if(GLEW_ARB_shader_objects && mShader) - mShader->SetProg(false); - BL_Texture::DisableAllTextures(); - if( !enable ) + + if( !enable ) { + ras->SetBlendingMode(TF_SOLID); return; + } BL_Texture::ActivateFirst(); if( mMaterial->IdMode == DEFAULT_BLENDER ) { - setDefaultBlending(); + ras->SetBlendingMode(mMaterial->transp); return; } @@ -271,7 +301,7 @@ void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) mTextures[0].ActivateTexture(); mTextures[0].setTexEnv(0, true); mTextures[0].SetMapping(mMaterial->mapping[0].mapping); - setDefaultBlending(); + ras->SetBlendingMode(mMaterial->transp); } return; } @@ -294,9 +324,12 @@ void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras) } if(!mUserDefBlend) { - setDefaultBlending(); + ras->SetBlendingMode(mMaterial->transp); } else { + ras->SetBlendingMode(TF_SOLID); + ras->SetBlendingMode(-1); // indicates custom mode + glEnable(GL_BLEND); glBlendFunc(mBlendFunc[0], mBlendFunc[1]); } @@ -356,6 +389,11 @@ KX_BlenderMaterial::ActivateBlenderShaders( { KX_BlenderMaterial *tmp = const_cast(this); + if(mLastShader) { + mLastShader->SetProg(false); + mLastShader= NULL; + } + // reset... if(tmp->mMaterial->IsShared()) cachingInfo =0; @@ -402,6 +440,11 @@ KX_BlenderMaterial::ActivateMat( { KX_BlenderMaterial *tmp = const_cast(this); + if(mLastShader) { + mLastShader->SetProg(false); + mLastShader= NULL; + } + if(mLastBlenderShader) { mLastBlenderShader->SetProg(false); mLastBlenderShader= NULL; @@ -451,7 +494,10 @@ KX_BlenderMaterial::Activate( return dopass; } else { - mShader->SetProg(false); + if(mShader == mLastShader) { + mShader->SetProg(false); + mLastShader = NULL; + } mPass = 0; dopass = false; return dopass; @@ -499,10 +545,22 @@ bool KX_BlenderMaterial::UsesLighting(RAS_IRasterizer *rasty) const void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterizer* rasty) const { - if(mShader && GLEW_ARB_shader_objects) + if(mShader && GLEW_ARB_shader_objects) { mShader->Update(ms, rasty); - else if(mBlenderShader && GLEW_ARB_shader_objects) + } + else if(mBlenderShader && GLEW_ARB_shader_objects) { + int blendmode; + mBlenderShader->Update(ms, rasty); + + /* we do blend modes here, because they can change per object + * with the same material due to obcolor */ + blendmode = mBlenderShader->GetBlendMode(); + if((blendmode == TF_SOLID || blendmode == TF_ALPHA) && mMaterial->transp != TF_SOLID) + blendmode = mMaterial->transp; + + rasty->SetBlendingMode(blendmode); + } } void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const @@ -582,31 +640,6 @@ void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const ras->EnableTextures(false); } -bool KX_BlenderMaterial::setDefaultBlending() -{ - if( mMaterial->transp &TF_ADD) { - glEnable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ONE); - glDisable ( GL_ALPHA_TEST ); - return true; - } - - if( mMaterial->transp & TF_ALPHA ) { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDisable ( GL_ALPHA_TEST ); - return true; - } - - if( mMaterial->transp & TF_CLIP ) { - glDisable(GL_BLEND); - glEnable ( GL_ALPHA_TEST ); - glAlphaFunc(GL_GREATER, 0.5f); - return false; - } - return false; -} - void KX_BlenderMaterial::setTexMatrixData(int i) { glMatrixMode(GL_TEXTURE); @@ -831,12 +864,14 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") void KX_BlenderMaterial::SetBlenderGLSLShader(void) { if(!mBlenderShader) - mBlenderShader = new BL_BlenderShader(mMaterial->material, m_lightlayer); + mBlenderShader = new BL_BlenderShader(mScene, mMaterial->material, m_lightlayer); if(!mBlenderShader->Ok()) { delete mBlenderShader; mBlenderShader = 0; } + else + m_flag |= RAS_BLENDERGLSL; } KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()") diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index bf6d2095e7c..0d7657b8cdb 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -90,11 +90,13 @@ public: // -------------------------------- // pre calculate to avoid pops/lag at startup virtual void OnConstruction( ); + + static void EndFrame(); + private: BL_Material* mMaterial; BL_Shader* mShader; BL_BlenderShader* mBlenderShader; - static BL_BlenderShader *mLastBlenderShader; KX_Scene* mScene; BL_Texture mTextures[MAXTEX]; // texture array bool mUserDefBlend; @@ -114,7 +116,6 @@ private: void setBlenderShaderData( bool enable, RAS_IRasterizer *ras); void setShaderData( bool enable, RAS_IRasterizer *ras); - bool setDefaultBlending(); void setObjectMatrixData(int i, RAS_IRasterizer *ras); void setTexMatrixData(int i); @@ -123,6 +124,10 @@ private: // cleanup stuff void OnExit(); + // shader chacing + static BL_BlenderShader *mLastBlenderShader; + static BL_Shader *mLastShader; + mutable int mPass; }; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 3d9c7aafd70..df478be5ca2 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -77,10 +77,10 @@ KX_GameObject::KX_GameObject( SCA_IObject(T), m_bDyna(false), m_layer(0), + m_pBlenderObject(NULL), m_bSuspendDynamics(false), m_bUseObjectColor(false), m_bIsNegativeScaling(false), - m_pBlenderObject(NULL), m_bVisible(true), m_pPhysicsController1(NULL), m_pPhysicsEnvironment(NULL), @@ -96,12 +96,9 @@ KX_GameObject::KX_GameObject( KX_NormalParentRelation * parent_relation = KX_NormalParentRelation::New(); m_pSGNode->SetParentRelation(parent_relation); - - }; - KX_GameObject::~KX_GameObject() { // is this delete somewhere ? @@ -165,6 +162,7 @@ STR_String KX_GameObject::GetName() void KX_GameObject::SetName(STR_String name) { m_name = name; + }; // Set the name of the value @@ -454,12 +452,13 @@ KX_GameObject::UpdateMaterialData( ) { int mesh = 0; + if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0) { RAS_MaterialBucket::Set::iterator mit = m_meshes[mesh]->GetFirstMaterial(); for(; mit != m_meshes[mesh]->GetLastMaterial(); ++mit) { RAS_IPolyMaterial* poly = (*mit)->GetPolyMaterial(); - if(poly->GetFlag() & RAS_BLENDERMAT ) + if(poly->GetFlag() & RAS_BLENDERMAT) { KX_BlenderMaterial *m = static_cast(poly); @@ -467,7 +466,8 @@ KX_GameObject::UpdateMaterialData( { m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); // if mesh has only one material attached to it then use original hack with no need to edit vertices (better performance) - SetObjectColor(rgba); + if(!(poly->GetFlag() & RAS_BLENDERGLSL)) + SetObjectColor(rgba); } else { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index db099d56b55..1d6cc975ab5 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -118,7 +118,6 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_bInitialized(false), m_activecam(0), m_bFixedTime(false), - m_game2ipo(false), m_firstframe(true), @@ -148,6 +147,8 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_showBackground(false), m_show_debug_properties(false), + m_game2ipo(false), + // Default behavior is to hide the cursor every frame. m_hideCursor(false), diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 93d6d5bb70d..144f74a1a4c 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -59,7 +59,8 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname, int tilexrep, int tileyrep, int mode, - bool transparant, + int transp, + bool alpha, bool zsort, int lightlayer, bool bIsTriangle, @@ -74,7 +75,8 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname, tilexrep, tileyrep, mode, - transparant, + transp, + alpha, zsort, lightlayer, bIsTriangle, @@ -245,7 +247,7 @@ PyObject* KX_PolygonMaterial::_getattr(const STR_String& attr) if (attr == "drawingmode") return PyInt_FromLong(m_drawingmode); if (attr == "transparent") - return PyInt_FromLong(m_transparant); + return PyInt_FromLong(m_alpha); if (attr == "zsort") return PyInt_FromLong(m_zsort); if (attr == "lightlayer") @@ -312,7 +314,7 @@ int KX_PolygonMaterial::_setattr(const STR_String &attr, PyObject *pyvalue) if (attr == "transparent") { - m_transparant = value; + m_alpha = value; return 0; } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index 19015494e06..11c8baa8b1f 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -64,7 +64,8 @@ public: int tilexrep, int tileyrep, int mode, - bool transparant, + int transp, + bool alpha, bool zsort, int lightlayer, bool bIsTriangle, diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 648a6ca31d5..ad476e492d0 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -37,6 +37,7 @@ #include "MT_assert.h" #include "KX_KetsjiEngine.h" +#include "KX_BlenderMaterial.h" #include "RAS_IPolygonMaterial.h" #include "ListValue.h" #include "SCA_LogicManager.h" @@ -116,13 +117,13 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, PyObjectPlus(&KX_Scene::Type), m_keyboardmgr(NULL), m_mousemgr(NULL), + m_sceneConverter(NULL), m_physicsEnvironment(0), m_sceneName(sceneName), m_adi(adi), m_networkDeviceInterface(ndi), m_active_camera(NULL), - m_ueberExecutionPriority(0), - m_sceneConverter(NULL) + m_ueberExecutionPriority(0) { m_suspendedtime = 0.0; m_suspendeddelta = 0.0; @@ -984,6 +985,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) //m_active_camera->Release(); m_active_camera = NULL; } + // in case this is a camera m_cameras.remove((KX_Camera*)newobj); @@ -1240,14 +1242,10 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi if (visible) { int nummeshes = gameobj->GetMeshCount(); - MT_Transform t( cam->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform()); - + // this adds the vertices to the display list for (int m=0;mGetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode()); - } + (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode()); } gameobj->MarkVisible(visible); } @@ -1304,12 +1302,11 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam if (vis) { int nummeshes = gameobj->GetMeshCount(); - MT_Transform t(cam->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform()); for (int m=0;mGetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode()); + (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode()); } // Visibility/ non-visibility are marked // elsewhere now. @@ -1422,7 +1419,7 @@ void KX_Scene::UpdateParents(double curtime) RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool &bucketCreated) { - return m_bucketmanager->RAS_BucketManagerFindBucket(polymat, bucketCreated); + return m_bucketmanager->FindBucket(polymat, bucketCreated); } @@ -1432,10 +1429,9 @@ void KX_Scene::RenderBuckets(const MT_Transform & cameratransform, class RAS_IRenderTools* rendertools) { m_bucketmanager->Renderbuckets(cameratransform,rasty,rendertools); + KX_BlenderMaterial::EndFrame(); } - - void KX_Scene::UpdateObjectActivity(void) { if (m_activity_culling) { diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index b4492ca03a9..82bdce44519 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -94,7 +94,6 @@ void RAS_BucketManager::RenderAlphaBuckets( const MT_Scalar cam_origin = cameratrans.getOrigin()[2]; for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) { - (*bit)->ClearScheduledPolygons(); for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) { if ((*mit).m_bVisible) @@ -133,28 +132,15 @@ void RAS_BucketManager::Renderbuckets( rasty->ClearCachingInfo(); RAS_MaterialBucket::StartFrame(); - for (bucket = m_MaterialBuckets.begin(); bucket != m_MaterialBuckets.end(); ++bucket) - { - (*bucket)->ClearScheduledPolygons(); - } for (bucket = m_MaterialBuckets.begin(); bucket != m_MaterialBuckets.end(); ++bucket) - { - RAS_IPolyMaterial *tmp = (*bucket)->GetPolyMaterial(); - if(tmp->IsZSort() || tmp->GetFlag() &RAS_FORCEALPHA ) - rasty->SetAlphaTest(true); - else - rasty->SetAlphaTest(false); - (*bucket)->Render(cameratrans,rasty,rendertools); - } - rasty->SetAlphaTest(false); RenderAlphaBuckets(cameratrans, rasty, rendertools); RAS_MaterialBucket::EndFrame(); } -RAS_MaterialBucket* RAS_BucketManager::RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material, bool &bucketCreated) +RAS_MaterialBucket* RAS_BucketManager::FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated) { bucketCreated = false; BucketList::iterator it; @@ -172,7 +158,7 @@ RAS_MaterialBucket* RAS_BucketManager::RAS_BucketManagerFindBucket(RAS_IPolyMate RAS_MaterialBucket *bucket = new RAS_MaterialBucket(material); bucketCreated = true; - if (bucket->IsTransparant()) + if (bucket->IsAlpha()) m_AlphaBuckets.push_back(bucket); else m_MaterialBuckets.push_back(bucket); @@ -195,3 +181,28 @@ void RAS_BucketManager::RAS_BucketManagerClearAll() m_MaterialBuckets.clear(); m_AlphaBuckets.clear(); } + +void RAS_BucketManager::ReleaseDisplayLists() +{ + BucketList::iterator bit; + RAS_MaterialBucket::T_MeshSlotList::iterator mit; + + for (bit = m_MaterialBuckets.begin(); bit != m_MaterialBuckets.end(); ++bit) { + for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) { + if(mit->m_DisplayList) { + mit->m_DisplayList->Release(); + mit->m_DisplayList = NULL; + } + } + } + + for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) { + for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) { + if(mit->m_DisplayList) { + mit->m_DisplayList->Release(); + mit->m_DisplayList = NULL; + } + } + } +} + diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index 010478b1d5b..08b67ed022f 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -58,8 +58,9 @@ public: RAS_IRasterizer* rasty, class RAS_IRenderTools* rendertools); - RAS_MaterialBucket* RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material, bool &bucketCreated); + RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated); + void ReleaseDisplayLists(); private: void RAS_BucketManagerClearAll(); diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index 31bdd8638c2..4ee06d96603 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -39,7 +39,8 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, int tilexrep, int tileyrep, int mode, - bool transparant, + int transp, + bool alpha, bool zsort, int lightlayer, bool bIsTriangle, @@ -51,7 +52,8 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, m_tilexrep(tilexrep), m_tileyrep(tileyrep), m_drawingmode (mode), - m_transparant(transparant), + m_transp(transp), + m_alpha(alpha), m_zsort(zsort), m_lightlayer(lightlayer), m_bIsTriangle(bIsTriangle), @@ -74,6 +76,7 @@ bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const this->m_multimode == lhs.m_multimode && this->m_flag == lhs.m_flag && this->m_drawingmode == lhs.m_drawingmode && + this->m_transp == lhs.m_transp && this->m_lightlayer == lhs.m_lightlayer && this->m_texturename.hash() == lhs.m_texturename.hash() && this->m_materialname.hash() == lhs.m_materialname.hash() @@ -85,7 +88,8 @@ bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const this->m_tile == lhs.m_tile && this->m_tilexrep == lhs.m_tilexrep && this->m_tileyrep == lhs.m_tileyrep && - this->m_transparant == lhs.m_transparant && + this->m_transp == lhs.m_transp && + this->m_alpha == lhs.m_alpha && this->m_zsort == lhs.m_zsort && this->m_drawingmode == lhs.m_drawingmode && this->m_bIsTriangle == lhs.m_bIsTriangle && @@ -109,9 +113,9 @@ int RAS_IPolyMaterial::GetLightLayer() const return m_lightlayer; } -bool RAS_IPolyMaterial::IsTransparant() const +bool RAS_IPolyMaterial::IsAlpha() const { - return m_transparant; + return m_alpha || m_zsort; } bool RAS_IPolyMaterial::IsZSort() const diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 6d90d260a23..8fc53e6b038 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -52,7 +52,7 @@ enum MaterialProps RAS_AUTOGEN =128, RAS_NORMAL =256, RAS_DEFMULTI =512, - RAS_FORCEALPHA =1024 + RAS_BLENDERGLSL =1024 }; /** @@ -67,7 +67,8 @@ protected: int m_tile; int m_tilexrep,m_tileyrep; int m_drawingmode; // tface->mode - bool m_transparant; + int m_transp; + bool m_alpha; bool m_zsort; int m_lightlayer; bool m_bIsTriangle; @@ -102,7 +103,8 @@ public: int tilexrep, int tileyrep, int mode, - bool transparant, + int transp, + bool alpha, bool zsort, int lightlayer, bool bIsTriangle, @@ -132,7 +134,7 @@ public: virtual bool Equals(const RAS_IPolyMaterial& lhs) const; bool Less(const RAS_IPolyMaterial& rhs) const; int GetLightLayer() const; - bool IsTransparant() const; + bool IsAlpha() const; bool IsZSort() const; bool UsesTriangles() const; unsigned int hash() const; diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index d4a9177a85d..9e03212283e 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -372,10 +372,6 @@ public: virtual void SetAmbientColor(float red, float green, float blue)=0; virtual void SetAmbient(float factor)=0; - /** - * Sets alpha testing - */ - virtual void SetAlphaTest(bool enable)=0; /** * Sets a polygon offset. z depth will be: z1 = mult*z0 + add @@ -398,8 +394,10 @@ public: virtual void DisableMotionBlur()=0; virtual float GetMotionBlurValue()=0; - virtual int GetMotionBlurState()=0; - virtual void SetMotionBlurState(int newstate)=0; + virtual int GetMotionBlurState()=0; + virtual void SetMotionBlurState(int newstate)=0; + + virtual void SetBlendingMode(int blendmode)=0; }; #endif //__RAS_IRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index e295d69e48e..0015b6a251f 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -76,26 +76,11 @@ KX_MeshSlot::~KX_MeshSlot() RAS_MaterialBucket::RAS_MaterialBucket(RAS_IPolyMaterial* mat) :m_bModified(true) { - m_bScheduled=true; m_material = mat; } -void RAS_MaterialBucket::SchedulePolygons(int drawingmode) -{ - m_bScheduled = true; -} - - - -void RAS_MaterialBucket::ClearScheduledPolygons() -{ - m_bScheduled = false; -} - - - RAS_IPolyMaterial* RAS_MaterialBucket::GetPolyMaterial() const { return m_material; @@ -134,9 +119,14 @@ void RAS_MaterialBucket::MarkVisibleMeshSlot(KX_MeshSlot& ms, (*it).m_RGBAcolor= rgbavec; } -bool RAS_MaterialBucket::IsTransparant() const +bool RAS_MaterialBucket::IsAlpha() const +{ + return (m_material->IsAlpha()); +} + +bool RAS_MaterialBucket::IsZSort() const { - return (m_material->IsTransparant()); + return (m_material->IsZSort()); } diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index 13d8a53714a..4eef889c533 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -125,11 +125,9 @@ public: class RAS_IRasterizer* rasty, class RAS_IRenderTools* rendertools); - void SchedulePolygons(int drawingmode); - void ClearScheduledPolygons(); - RAS_IPolyMaterial* GetPolyMaterial() const; - bool IsTransparant() const; + bool IsAlpha() const; + bool IsZSort() const; static void StartFrame(); static void EndFrame(); @@ -162,7 +160,6 @@ public: private: T_MeshSlotList m_meshSlots; - bool m_bScheduled; bool m_bModified; RAS_IPolyMaterial* m_material; double* m_pOGLMatrix; diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 5087f62500e..9c0460aad2d 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -203,7 +203,6 @@ void RAS_MeshObject::DebugColor(unsigned int abgr) void RAS_MeshObject::SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba) { - RAS_TexVert* vertex = NULL; const vecVertexArray & vertexvec = GetVertexCache(mat); for (vector::const_iterator it = vertexvec.begin(); it != vertexvec.end(); ++it) @@ -220,22 +219,17 @@ void RAS_MeshObject::SchedulePoly(const KX_VertexIndex& idx, int numverts, RAS_IPolyMaterial* mat) { - //int indexpos = m_IndexArrayCount[idx.m_vtxarray]; - //m_IndexArrayCount[idx.m_vtxarray] = indexpos + 3; - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); + ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[0]); ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[1]); ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[2]); - if (!mat->UsesTriangles()) //if (!m_bUseTriangles) - { - //m_IndexArrayCount[idx.m_vtxarray] = indexpos+4; + + if (!mat->UsesTriangles()) ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[3]); - } } - void RAS_MeshObject::ScheduleWireframePoly(const KX_VertexIndex& idx, int numverts, int edgecode, @@ -422,7 +416,6 @@ void RAS_MeshObject::Bucketize(double* oglmatrix, for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it) { RAS_MaterialBucket* bucket = *it; - bucket->SchedulePolygons(0); // KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial()); bucket->SetMeshSlot(ms); } @@ -447,7 +440,6 @@ void RAS_MeshObject::MarkVisible(double* oglmatrix, for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it) { RAS_MaterialBucket* bucket = *it; - bucket->SchedulePolygons(0); // KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial()); bucket->MarkVisibleMeshSlot(ms,visible,useObjectColor,rgbavec); } @@ -466,7 +458,6 @@ void RAS_MeshObject::RemoveFromBuckets(double* oglmatrix, { RAS_MaterialBucket* bucket = *it; // RAS_IPolyMaterial* polymat = bucket->GetPolyMaterial(); - bucket->SchedulePolygons(0); //KX_ArrayOptimizer* oa = GetArrayOptimizer(polymat); bucket->RemoveMeshSlot(ms); } @@ -585,31 +576,36 @@ void RAS_MeshObject::UpdateMaterialList() struct RAS_MeshObject::polygonSlot { - float m_z; - RAS_Polygon *m_poly; - - polygonSlot(float z, RAS_Polygon* poly) : - m_z(z), - m_poly(poly) - {} - /** - * pnorm and pval form the plane equation that the distance from is used to - * sort against. - */ - polygonSlot(const MT_Vector3 &pnorm, const MT_Scalar &pval, RAS_MeshObject *mesh, RAS_Polygon* poly) : - m_poly(poly) + float m_z; + int m_index[4]; + + polygonSlot() {} + + /* pnorm is the normal from the plane equation that the distance from is + * used to sort again. */ + void get(const KX_VertexArray& vertexarray, const KX_IndexArray& indexarray, + int offset, int nvert, const MT_Vector3& pnorm) { - const KX_VertexIndex &base = m_poly->GetIndexBase(); - RAS_TexVert *vert = mesh->GetVertex(base.m_vtxarray, base.m_indexarray[0], poly->GetMaterial()->GetPolyMaterial()); - m_z = MT_dot(pnorm, vert->getLocalXYZ()) + pval; - - for(int i = 1; i < m_poly->VertexCount(); i++) - { - vert = mesh->GetVertex(base.m_vtxarray, base.m_indexarray[i], poly->GetMaterial()->GetPolyMaterial()); - float z = MT_dot(pnorm, vert->getLocalXYZ()) + pval; - m_z += z; + MT_Vector3 center(0, 0, 0); + int i; + + for(i=0; iVertexCount(); + + /* note we don't divide center by the number of vertices, since all + * polygons have the same number of vertices, and that we leave out + * the 4-th component of the plane equation since it is constant. */ + m_z = MT_dot(pnorm, center); + } + + void set(KX_IndexArray& indexarray, int offset, int nvert) + { + int i; + + for(i=0; i alphapolyset; - std::multiset solidpolyset; - - for (unsigned int p = 0; p < numpolys; p++) - { - RAS_Polygon* poly = m_Polygons[p]; - if (poly->IsVisible()) - { - if (poly->GetMaterial()->GetPolyMaterial()->IsTransparant()) - { - alphapolyset.insert(polygonSlot(pnorm, pval, this, poly)); - } else { - solidpolyset.insert(polygonSlot(pnorm, pval, this, poly)); - } - } - } - - // Clear current array data. + // unneeded: const MT_Scalar pval = transform.getOrigin()[2]; + for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it) { - vector *indexcache = &GetArrayOptimizer((*it)->GetPolyMaterial())->m_IndexArrayCache1; - for (vector::iterator iit = indexcache->begin(); iit != indexcache->end(); ++iit) - (*iit)->clear(); - } + if(!(*it)->IsZSort()) + continue; - std::multiset::iterator sit = solidpolyset.begin(); - for (; sit != solidpolyset.end(); ++sit) - SchedulePoly((*sit).m_poly->GetVertexIndexBase(), (*sit).m_poly->VertexCount(), (*sit).m_poly->GetMaterial()->GetPolyMaterial()); - - std::multiset::iterator ait = alphapolyset.begin(); - for (; ait != alphapolyset.end(); ++ait) - SchedulePoly((*ait).m_poly->GetVertexIndexBase(), (*ait).m_poly->VertexCount(), (*ait).m_poly->GetMaterial()->GetPolyMaterial()); + RAS_IPolyMaterial *mat = (*it)->GetPolyMaterial(); + KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); + + vecIndexArrays& indexarrays = ao->m_IndexArrayCache1; + vecVertexArray& vertexarrays = ao->m_VertexArrayCache1; + unsigned int i, j, nvert = (mat->UsesTriangles())? 3: 4; + + for(i=0; i slots(totpoly); + + /* get indices and z into temporary array */ + for(j=0; jSchedulePolygons(drawingmode); - if (bucket->GetPolyMaterial()->IsZSort()) + for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it) + if ((*it)->IsZSort()) m_zsort = true; - } - - int numpolys = m_Polygons.size(); - if ((drawingmode > RAS_IRasterizer::KX_BOUNDINGBOX) && - (drawingmode < RAS_IRasterizer::KX_SOLID)) + if (drawingmode == RAS_IRasterizer::KX_WIREFRAME) { for (i=0;iIsVisible()) - ScheduleWireframePoly(poly->GetVertexIndexBase(),poly->VertexCount(),poly->GetEdgeCode() - ,poly->GetMaterial()->GetPolyMaterial()); + ScheduleWireframePoly(poly->GetVertexIndexBase(),poly->VertexCount(),poly->GetEdgeCode(), + poly->GetMaterial()->GetPolyMaterial()); } m_zsort = false; } else { - if (!m_zsort) + for (i=0;iIsVisible()) - { - SchedulePoly(poly->GetVertexIndexBase(),poly->VertexCount(),poly->GetMaterial()->GetPolyMaterial()); - } - } + RAS_Polygon* poly = m_Polygons[i]; + if (poly->IsVisible()) + SchedulePoly(poly->GetVertexIndexBase(),poly->VertexCount(), + poly->GetMaterial()->GetPolyMaterial()); } } m_bModified = false; - m_MeshMod = true; } } + diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index 44ad508d1e8..99806666fa6 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -137,6 +137,18 @@ class RAS_MeshObject struct backtofront; struct fronttoback; + void SchedulePoly( + const KX_VertexIndex& idx, + int numverts, + RAS_IPolyMaterial* mat + ); + + void ScheduleWireframePoly( + const KX_VertexIndex& idx, + int numverts, + int edgecode, + RAS_IPolyMaterial* mat + ); protected: enum { BUCKET_MAX_INDICES = 65535 };//2048};//8192}; @@ -196,10 +208,7 @@ public: */ void SortPolygons(const MT_Transform &transform); - void SchedulePolygons( - const MT_Transform &transform, - int drawingmode - ); + void SchedulePolygons(int drawingmode); void ClearArrayData(); @@ -216,19 +225,7 @@ public: int numverts, RAS_IPolyMaterial* polymat ); - - void SchedulePoly( - const KX_VertexIndex& idx, - int numverts, - RAS_IPolyMaterial* mat - ); - void ScheduleWireframePoly( - const KX_VertexIndex& idx, - int numverts, - int edgecode, - RAS_IPolyMaterial* mat - ); // find (and share) or add vertices // for some speedup, only the last 20 added vertices are searched for equality diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index dcc36bf5a39..1dcc6e70934 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -67,6 +67,7 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas) m_motionblurvalue(-1.0), m_texco_num(0), m_attrib_num(0), + m_last_blendmode(0), m_materialCachingInfo(0) { m_viewmatrix.Identity(); @@ -171,6 +172,8 @@ bool RAS_OpenGLRasterizer::Init() m_ambg = 0.0f; m_ambb = 0.0f; + SetBlendingMode(0); + glClearColor(m_redback,m_greenback,m_blueback,m_alphaback); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -189,18 +192,6 @@ void RAS_OpenGLRasterizer::SetAmbientColor(float red, float green, float blue) } -void RAS_OpenGLRasterizer::SetAlphaTest(bool enable) -{ - if (enable) - { - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.6f); - } - else glDisable(GL_ALPHA_TEST); -} - - - void RAS_OpenGLRasterizer::SetAmbient(float factor) { float ambient[] = { m_ambr*factor, m_ambg*factor, m_ambb*factor, 1.0f }; @@ -353,6 +344,8 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time) glEnable (GL_CULL_FACE); } + SetBlendingMode(0); + glShadeModel(GL_SMOOTH); m_2DCanvas->BeginFrame(); @@ -1389,3 +1382,34 @@ void RAS_OpenGLRasterizer::DisableMotionBlur() m_motionblur = 0; m_motionblurvalue = -1.0; } + +void RAS_OpenGLRasterizer::SetBlendingMode(int blendmode) +{ + if(blendmode == m_last_blendmode) + return; + + if(blendmode == 0) { + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + else if(blendmode == 1) { + glBlendFunc(GL_ONE, GL_ONE); + glEnable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + } + else if(blendmode == 2) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.0f); + } + else if(blendmode == 4) { + glDisable(GL_BLEND); + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.5f); + } + + m_last_blendmode = blendmode; +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 0d54552db05..02056cce446 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -99,6 +99,7 @@ protected: TexCoGen m_attrib[RAS_MAX_ATTRIB]; int m_texco_num; int m_attrib_num; + int m_last_blendmode; /** Stores the caching information for the last material activated. */ RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo; @@ -142,8 +143,6 @@ public: virtual void SetFocalLength(const float focallength); virtual float GetFocalLength(); - virtual void SetAlphaTest(bool enable); - virtual void SwapBuffers(); virtual void IndexPrimitives( const vecVertexArray& vertexarrays, @@ -282,8 +281,8 @@ public: virtual void EnableMotionBlur(float motionblurvalue); virtual void DisableMotionBlur(); virtual float GetMotionBlurValue(){return m_motionblurvalue;}; - virtual int GetMotionBlurState(){return m_motionblur;}; - virtual void SetMotionBlurState(int newstate) + virtual int GetMotionBlurState(){return m_motionblur;}; + virtual void SetMotionBlurState(int newstate) { if(newstate<0) m_motionblur = 0; @@ -292,6 +291,8 @@ public: else m_motionblur = newstate; }; + + virtual void SetBlendingMode(int blendmode); }; #endif //__RAS_OPENGLRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp index 852c94def3f..b74cb9cfcac 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.cpp +++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp @@ -37,24 +37,6 @@ #include "RAS_Polygon.h" -/* -RAS_TexVert* RAS_Polygon::GetVertex(int index) -{ - if (m_bucket) - return m_bucket->GetVertex(m_vertexindexbase.m_vtxarray, m_vertexindexbase.m_indexarray[index]); - else - return NULL; -} -*/ - -/*void RAS_Polygon::Bucketize(double* oglmatrix) -{ - //Transform(trans); - if (m_bucket) - m_bucket->AddPolygon(this,oglmatrix); -} -*/ - RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, bool visible, int numverts, -- cgit v1.2.3 From ca951b3627b48beab9ddf14ac18040e2f24d959b Mon Sep 17 00:00:00 2001 From: Mal Duffin Date: Tue, 29 Jul 2008 20:28:11 +0000 Subject: Am teaching a GE course this week, and am finding some small issues that I'm hoping to patch. This one deals with the very small default clipend value ( 100.0 ) when pressing P to run the GE from a non-camera view. ( ie if the user zooms out a bit from the default box area, the box will get clipped out of view, so it's a WFT from the user ) To see what this fixes, load up Blender default scene, go into perspective, and press P. Everything looks grand. Now, zoom out until the box is about 10 pixels high, and press P again. The box will disappear / be clipped out. I've set the clip end to the maximum ( 5000 ) as defined in Camera.h. This should be suitable for inclusion in 2.47 branch also. --- source/gameengine/Rasterizer/RAS_CameraData.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index 0327a3f4763..e3af43fb839 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -42,7 +42,7 @@ struct RAS_CameraData int m_viewporttop; float m_focallength; - RAS_CameraData(float lens = 35., float clipstart = 0.1, float clipend = 100., bool perspective = true, + RAS_CameraData(float lens = 35.0, float clipstart = 0.1, float clipend = 5000.0, bool perspective = true, float focallength = 0.0f, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, int viewportright = 0, int viewporttop = 0) : m_lens(lens), -- cgit v1.2.3 From e04c48df86babc18ed49ef8d33a3cfefcb28ed32 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 29 Jul 2008 21:56:50 +0000 Subject: * making sure BGE compiles after brecht's big commit (r15867). Needed to compile with msvc. --- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 9c0460aad2d..adef998acc2 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -35,6 +35,8 @@ #include "MT_MinMax.h" #include "MT_Point3.h" +#include + STR_String RAS_MeshObject::s_emptyname = ""; -- cgit v1.2.3 From 7f170c18bbc3ef3cc8e3b459b8bcc8a789ba0438 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 30 Jul 2008 16:15:15 +0000 Subject: Bugfixes: fix for two memory leaks related to dupligroups, and a missing reference count in the trackto actuator. This showed up as leaked pose data, but actually the whole object was not being freed. --- source/gameengine/Converter/BL_ActionActuator.cpp | 24 ++++++---------------- source/gameengine/Converter/BL_ArmatureObject.cpp | 9 ++++---- .../Converter/BL_BlenderDataConversion.cpp | 5 +++-- source/gameengine/Ketsji/KX_Scene.cpp | 9 +++++++- source/gameengine/Ketsji/KX_TrackToActuator.cpp | 10 +++++++++ 5 files changed, 31 insertions(+), 26 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 5d6dd694765..2ee8b54a014 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -57,24 +57,12 @@ BL_ActionActuator::~BL_ActionActuator() { - - if (m_pose) { - free_pose_channels(m_pose); - MEM_freeN(m_pose); - m_pose = NULL; - }; - - if (m_userpose){ - free_pose_channels(m_userpose); - MEM_freeN(m_userpose); - m_userpose=NULL; - } - if (m_blendpose) { - free_pose_channels(m_blendpose); - MEM_freeN(m_blendpose); - m_blendpose = NULL; - }; - + if (m_pose) + free_pose(m_pose); + if (m_userpose) + free_pose(m_userpose); + if (m_blendpose) + free_pose(m_blendpose); } void BL_ActionActuator::ProcessReplica(){ diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index f73d5b42a01..09f1d9d4d87 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -82,10 +82,8 @@ void BL_ArmatureObject::ProcessReplica(BL_ArmatureObject *replica) BL_ArmatureObject::~BL_ArmatureObject() { - if (m_mrdPose){ - free_pose_channels(m_mrdPose); - MEM_freeN(m_mrdPose); - } + if (m_mrdPose) + free_pose(m_mrdPose); } /* note, you can only call this for exisiting Armature objects, and not mix it with other Armatures */ @@ -172,12 +170,13 @@ void BL_ArmatureObject::GetMRDPose(bPose **pose) // copy_pose (&m_mrdPose, m_pose, 0); //} - if (!*pose) + if (!*pose) { // must duplicate the constraints too otherwise we have corruption in free_pose_channels() // because it will free the blender constraints. // Ideally, blender should rememeber that the constraints were not copied so that // free_pose_channels() would not free them. copy_pose(pose, m_objArma->pose, 1); + } else extract_pose_from_pose(*pose, m_objArma->pose); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 2cc5cfda84c..da1767793bb 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -628,7 +628,8 @@ BL_Material* ConvertMaterial( material->transp = TF_ALPHA; // always zsort alpha + add - if(material->transp == TF_ALPHA || material->transp == TF_ADD || texalpha) { + if((material->transp == TF_ALPHA || material->transp == TF_ADD || texalpha) + && (material->transp != TF_CLIP)) { material->ras_mode |= ALPHA; material->ras_mode |= (material->mode & TF_ALPHASORT)? ZSORT: 0; } @@ -1856,7 +1857,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (converter->addInitFromFrame) if (!isInActiveLayer) addobj=false; - + if (gameobj&&addobj) { MT_Point3 posPrev; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index ad476e492d0..2828663c63d 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -93,6 +93,9 @@ void* KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene) { KX_GameObject* replica = ((KX_Scene*)scene)->AddNodeReplicaObject(node,(KX_GameObject*)gameobj); + if(replica) + replica->Release(); + return (void*)replica; } @@ -670,8 +673,12 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) for (oit=m_groupGameObjects.begin(); oit != m_groupGameObjects.end(); oit++) { gameobj = (KX_GameObject*)(*oit); - if (gameobj->GetParent() != NULL) + + KX_GameObject *parent = gameobj->GetParent(); + if (parent != NULL) { + parent->Release(); // GetParent() increased the refcount + // this object is not a top parent. Either it is the child of another // object in the group and it will be added automatically when the parent // is added. Or it is the child of an object outside the group and the group diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index d4bd109de1a..f5b463abf02 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -195,6 +195,8 @@ void KX_TrackToActuator::ProcessReplica() // the replica is tracking the same object => register it if (m_object) m_object->RegisterActuator(this); + if (m_parentobj) + m_parentobj->AddRef(); SCA_IActuator::ProcessReplica(); } @@ -219,6 +221,14 @@ void KX_TrackToActuator::Relink(GEN_Map *obj_map) m_object = (SCA_IObject*)(*h_obj); m_object->RegisterActuator(this); } + + void **h_parobj = (*obj_map)[m_parentobj]; + if (h_parobj) { + if (m_parentobj) + m_parentobj->Release(); + m_parentobj= (KX_GameObject*)(*h_parobj); + m_parentobj->AddRef(); + } } -- cgit v1.2.3 From 8a8a12ed846dc86b2f9b21582fd34d941beed7ed Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 30 Jul 2008 17:41:47 +0000 Subject: BGE patch: logic optimization part 2: remove inactive sensors from logic manager. With this patch, only sensors that are connected to active states are actually registered in the logic manager. Inactive sensors won't take any CPU, especially the Radar and Near sensors that use a physical object for the detection: these objects are removed from the physics engine. To take advantage of this optimization patch, you need to define very light idle state when the objects are inactive: make them transparent, suspend the physics, keep few sensors active (e,g a message sensor to wake up), etc. --- .../Converter/BL_BlenderDataConversion.cpp | 10 +-- source/gameengine/Converter/KX_ConvertSensors.cpp | 6 +- .../GameLogic/SCA_ActuatorEventManager.cpp | 13 +-- .../GameLogic/SCA_ActuatorEventManager.h | 1 - .../GameLogic/SCA_AlwaysEventManager.cpp | 11 +-- .../gameengine/GameLogic/SCA_AlwaysEventManager.h | 1 - source/gameengine/GameLogic/SCA_EventManager.cpp | 13 ++- source/gameengine/GameLogic/SCA_EventManager.h | 6 +- source/gameengine/GameLogic/SCA_IObject.cpp | 27 +++++- source/gameengine/GameLogic/SCA_ISensor.cpp | 9 +- source/gameengine/GameLogic/SCA_ISensor.h | 4 +- .../gameengine/GameLogic/SCA_JoystickManager.cpp | 11 +-- source/gameengine/GameLogic/SCA_JoystickManager.h | 1 - .../gameengine/GameLogic/SCA_KeyboardManager.cpp | 15 +--- source/gameengine/GameLogic/SCA_KeyboardManager.h | 1 - source/gameengine/GameLogic/SCA_LogicManager.cpp | 7 +- source/gameengine/GameLogic/SCA_MouseManager.cpp | 14 +--- source/gameengine/GameLogic/SCA_MouseManager.h | 1 - .../GameLogic/SCA_PropertyEventManager.cpp | 11 +-- .../GameLogic/SCA_PropertyEventManager.h | 1 - .../GameLogic/SCA_RandomEventManager.cpp | 11 +-- .../gameengine/GameLogic/SCA_RandomEventManager.h | 1 - .../gameengine/GameLogic/SCA_TimeEventManager.cpp | 5 ++ source/gameengine/GameLogic/SCA_TimeEventManager.h | 1 + .../Ketsji/KXNetwork/KX_NetworkEventManager.cpp | 17 +--- .../Ketsji/KXNetwork/KX_NetworkEventManager.h | 3 - source/gameengine/Ketsji/KX_GameObject.cpp | 1 + source/gameengine/Ketsji/KX_NearSensor.cpp | 8 ++ source/gameengine/Ketsji/KX_NearSensor.h | 1 + source/gameengine/Ketsji/KX_RayEventManager.cpp | 9 +- source/gameengine/Ketsji/KX_RayEventManager.h | 1 - source/gameengine/Ketsji/KX_TouchEventManager.cpp | 31 +++---- source/gameengine/Ketsji/KX_TouchEventManager.h | 2 +- source/gameengine/Ketsji/KX_TouchSensor.cpp | 8 ++ source/gameengine/Ketsji/KX_TouchSensor.h | 1 + .../Physics/BlOde/OdePhysicsEnvironment.h | 1 + .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 97 ++++++---------------- .../Physics/Bullet/CcdPhysicsEnvironment.h | 11 +-- .../Physics/Dummy/DummyPhysicsEnvironment.h | 1 + .../Physics/Sumo/Fuzzics/src/SM_Scene.cpp | 17 ++-- .../Physics/Sumo/SumoPhysicsEnvironment.cpp | 6 ++ .../Physics/Sumo/SumoPhysicsEnvironment.h | 1 + .../Physics/common/PHY_IPhysicsEnvironment.h | 1 + 43 files changed, 157 insertions(+), 241 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index da1767793bb..f44318120e8 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2441,13 +2441,13 @@ void BL_ConvertBlenderObjects(struct Main* maggie, int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,keydev,executePriority,layerMask,isInActiveLayer,canvas,converter); + // set the init state to all objects + gameobj->SetInitState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state); } - // apply the initial state to controllers - for ( i=0;iGetCount();i++) + // apply the initial state to controllers, only on the active objects as this registers the sensors + for ( i=0;iGetCount();i++) { - KX_GameObject* gameobj = static_cast(logicbrick_conversionlist->GetValue(i)); - struct Object* blenderobj = converter->FindBlenderObject(gameobj); - gameobj->SetInitState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state); + KX_GameObject* gameobj = static_cast(objectlist->GetValue(i)); gameobj->ResetState(); } diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 7c9df688d45..5e433bb821b 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -733,9 +733,9 @@ void BL_ConvertSensors(struct Object* blenderobject, gameobj->AddSensor(gamesensor); // only register to manager if it's in an active layer - - if (isInActiveLayer) - gamesensor->RegisterToManager(); + // Make registration dynamic: only when sensor is activated + //if (isInActiveLayer) + // gamesensor->RegisterToManager(); for (int i=0;itotlinks;i++) diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp index 28ca1fd673f..768a3a45937 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp @@ -48,19 +48,10 @@ SCA_ActuatorEventManager::~SCA_ActuatorEventManager() } - - -void SCA_ActuatorEventManager::RegisterSensor(SCA_ISensor* sensor) -{ - m_sensors.push_back(sensor); -} - - - void SCA_ActuatorEventManager::NextFrame() { // check for changed actuator - for (vector::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++) + for (set::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++) { (*it)->Activate(m_logicmgr,NULL); } @@ -69,7 +60,7 @@ void SCA_ActuatorEventManager::NextFrame() void SCA_ActuatorEventManager::UpdateFrame() { // update the state of actuator before executing them - for (vector::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++) + for (set::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++) { ((SCA_ActuatorSensor*)(*it))->Update(); } diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h index b5108764197..a7d61627c23 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h +++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h @@ -44,7 +44,6 @@ public: virtual ~SCA_ActuatorEventManager(); virtual void NextFrame(); virtual void UpdateFrame(); - virtual void RegisterSensor(SCA_ISensor* sensor); //SCA_LogicManager* GetLogicManager() { return m_logicmgr;} }; diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp index ab3bc2cc4ee..4cd2dfba994 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp @@ -51,16 +51,9 @@ SCA_AlwaysEventManager::SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr) void SCA_AlwaysEventManager::NextFrame() { - for (vector::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++) + for (set::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++) { - SCA_ISensor* sensor = *i; - sensor->Activate(m_logicmgr, NULL); + (*i)->Activate(m_logicmgr, NULL); } } - - -void SCA_AlwaysEventManager::RegisterSensor(SCA_ISensor* sensor) -{ - m_sensors.push_back(sensor); -} diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h index 28c71512875..a619eecddd4 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h +++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h @@ -39,7 +39,6 @@ class SCA_AlwaysEventManager : public SCA_EventManager public: SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr); virtual void NextFrame(); - virtual void RegisterSensor(SCA_ISensor* sensor); }; diff --git a/source/gameengine/GameLogic/SCA_EventManager.cpp b/source/gameengine/GameLogic/SCA_EventManager.cpp index 0169864a133..e4fd0379597 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.cpp +++ b/source/gameengine/GameLogic/SCA_EventManager.cpp @@ -45,17 +45,14 @@ SCA_EventManager::~SCA_EventManager() { } - +void SCA_EventManager::RegisterSensor(class SCA_ISensor* sensor) +{ + m_sensors.insert(sensor); +} void SCA_EventManager::RemoveSensor(class SCA_ISensor* sensor) { - std::vector::iterator i = - std::find(m_sensors.begin(), m_sensors.end(), sensor); - if (!(i == m_sensors.end())) - { - std::swap(*i, m_sensors.back()); - m_sensors.pop_back(); - } + m_sensors.erase(sensor); } void SCA_EventManager::NextFrame(double curtime, double fixedtime) diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h index 9cc1718cd1e..9dbb5a6d24f 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.h +++ b/source/gameengine/GameLogic/SCA_EventManager.h @@ -30,12 +30,14 @@ #define __KX_EVENTMANAGER #include +#include #include class SCA_EventManager { protected: - std::vector m_sensors; + // use a set to speed-up insertion/removal + std::set m_sensors; public: enum EVENT_MANAGER_TYPE { @@ -61,7 +63,7 @@ public: virtual void NextFrame(); virtual void UpdateFrame(); virtual void EndFrame(); - virtual void RegisterSensor(class SCA_ISensor* sensor)=0; + virtual void RegisterSensor(class SCA_ISensor* sensor); int GetType(); protected: diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp index 25b4af696ea..b0f8decee26 100644 --- a/source/gameengine/GameLogic/SCA_IObject.cpp +++ b/source/gameengine/GameLogic/SCA_IObject.cpp @@ -337,12 +337,31 @@ void SCA_IObject::Resume(void) void SCA_IObject::SetState(unsigned int state) { - m_state = state; - // update the status of the controllers + unsigned int tmpstate; SCA_ControllerList::iterator contit; - for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++) + + // we will update the state in two steps: + // 1) set the new state bits that are 1 + // 2) clr the new state bits that are 0 + // This to ensure continuity if a sensor is attached to two states + // that are switching state: no need to deactive and reactive the sensor + + tmpstate = m_state | state; + if (tmpstate != m_state) + { + // update the status of the controllers + for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++) + { + (*contit)->ApplyState(tmpstate); + } + } + m_state = state; + if (m_state != tmpstate) { - (*contit)->ApplyState(m_state); + for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++) + { + (*contit)->ApplyState(m_state); + } } } diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index f11c8047fac..2dc49924062 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -41,7 +41,8 @@ void SCA_ISensor::ReParent(SCA_IObject* parent) { SCA_ILogicBrick::ReParent(parent); - m_eventmgr->RegisterSensor(this); + // will be done when the sensor is activated + //m_eventmgr->RegisterSensor(this); this->SetActive(false); } @@ -133,6 +134,7 @@ void SCA_ISensor::DecLink() { { // sensor is detached from all controllers, initialize it so that it // is fresh as at startup when it is reattached again. + UnregisterToManager(); Init(); } } @@ -203,6 +205,11 @@ void SCA_ISensor::RegisterToManager() m_eventmgr->RegisterSensor(this); } +void SCA_ISensor::UnregisterToManager() +{ + m_eventmgr->RemoveSensor(this); +} + void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event) { diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 51837755ba4..d5dabbce3ee 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -115,6 +115,8 @@ public: void SetLevel(bool lvl); void RegisterToManager(); + void UnregisterToManager(); + virtual float GetNumber(); /** Stop sensing for a while. */ @@ -129,7 +131,7 @@ public: void ClrLink() { m_links = 0; } void IncLink() - { m_links++; } + { if (!m_links++) RegisterToManager(); } void DecLink(); bool IsNoLink() const { return !m_links; } diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp index 7bf2049e56e..8ff28ba0b51 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp @@ -52,9 +52,10 @@ SCA_JoystickManager::~SCA_JoystickManager() void SCA_JoystickManager::NextFrame(double curtime,double deltatime) { - for (unsigned int i = 0; i < m_sensors.size(); i++) + set::iterator it; + for (it = m_sensors.begin(); it != m_sensors.end(); it++) { - SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*) m_sensors[i]; + SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it); if(!joysensor->IsSuspended()) { m_joystick->HandleEvents(); @@ -64,12 +65,6 @@ void SCA_JoystickManager::NextFrame(double curtime,double deltatime) } -void SCA_JoystickManager::RegisterSensor(SCA_ISensor* sensor) -{ - m_sensors.push_back(sensor); -} - - SCA_Joystick *SCA_JoystickManager::GetJoystickDevice() { /* diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h index 3c4df64677e..f2bb27965fa 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.h +++ b/source/gameengine/GameLogic/SCA_JoystickManager.h @@ -45,7 +45,6 @@ public: SCA_JoystickManager(class SCA_LogicManager* logicmgr); virtual ~SCA_JoystickManager(); virtual void NextFrame(double curtime,double deltatime); - virtual void RegisterSensor(SCA_ISensor* sensor); SCA_Joystick* GetJoystickDevice(void); }; diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp index 259b06134d7..6a96442b124 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp @@ -62,23 +62,14 @@ void SCA_KeyboardManager::NextFrame() { //const SCA_InputEvent& event = GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0; // cerr << "SCA_KeyboardManager::NextFrame"<< endl; - for (unsigned int i=0;i::iterator it; + for (it=m_sensors.begin(); it != m_sensors.end(); it++) { - SCA_KeyboardSensor* keysensor = (SCA_KeyboardSensor*)m_sensors[i]; - keysensor->Activate(m_logicmanager,NULL); + (*it)->Activate(m_logicmanager,NULL); } } - - -void SCA_KeyboardManager::RegisterSensor(SCA_ISensor* keysensor) -{ - m_sensors.push_back(keysensor); -} - - - bool SCA_KeyboardManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode) { return false; diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h index b4a50f56025..8f3cc0ab715 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.h +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h @@ -55,7 +55,6 @@ public: bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode); virtual void NextFrame(); - virtual void RegisterSensor(class SCA_ISensor* sensor); SCA_IInputDevice* GetInputDevice(); }; diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index d1c5917f0ce..91e66aea359 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -176,12 +176,7 @@ void SCA_LogicManager::RemoveSensor(SCA_ISensor* sensor) (*c)->UnlinkSensor(sensor); } m_sensorcontrollermapje.erase(sensor); - - for (vector::const_iterator ie=m_eventmanagers.begin(); - !(ie==m_eventmanagers.end());ie++) - { - (*ie)->RemoveSensor(sensor); - } + sensor->UnregisterToManager(); } void SCA_LogicManager::RemoveController(SCA_IController* controller) diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp index b4251d8ab53..ca875dad07c 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.cpp +++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp @@ -75,9 +75,10 @@ void SCA_MouseManager::NextFrame() { if (m_mousedevice) { - for (unsigned int i = 0; i < m_sensors.size(); i++) + set::iterator it; + for (it=m_sensors.begin(); it!=m_sensors.end(); it++) { - SCA_MouseSensor* mousesensor = (SCA_MouseSensor*) m_sensors[i]; + SCA_MouseSensor* mousesensor = (SCA_MouseSensor*)(*it); // (0,0) is the Upper Left corner in our local window // coordinates if (!mousesensor->IsSuspended()) @@ -98,15 +99,6 @@ void SCA_MouseManager::NextFrame() } } - - -void SCA_MouseManager::RegisterSensor(SCA_ISensor* keysensor) -{ - m_sensors.push_back(keysensor); -} - - - bool SCA_MouseManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode) { /* We should guard for non-mouse events maybe? A rather silly side */ diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h index bc8254486ad..efa4c639ce7 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.h +++ b/source/gameengine/GameLogic/SCA_MouseManager.h @@ -62,7 +62,6 @@ public: */ bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode); virtual void NextFrame(); - virtual void RegisterSensor(class SCA_ISensor* sensor); SCA_IInputDevice* GetInputDevice(); }; diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp index fc56d101728..e5e3f9cced5 100644 --- a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp @@ -47,19 +47,10 @@ SCA_PropertyEventManager::~SCA_PropertyEventManager() } - - -void SCA_PropertyEventManager::RegisterSensor(SCA_ISensor* sensor) -{ - m_sensors.push_back(sensor); -} - - - void SCA_PropertyEventManager::NextFrame() { // check for changed properties - for (vector::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++) + for (set::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++) { (*it)->Activate(m_logicmgr,NULL); } diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h index aaa303a52c8..f166065b198 100644 --- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h +++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h @@ -43,7 +43,6 @@ public: SCA_PropertyEventManager(class SCA_LogicManager* logicmgr); virtual ~SCA_PropertyEventManager(); virtual void NextFrame(); - virtual void RegisterSensor(SCA_ISensor* sensor); //SCA_LogicManager* GetLogicManager() { return m_logicmgr;} }; diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp index 02020a52a17..156478d866d 100644 --- a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp @@ -50,16 +50,9 @@ SCA_RandomEventManager::SCA_RandomEventManager(class SCA_LogicManager* logicmgr) void SCA_RandomEventManager::NextFrame() { - for (vector::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++) + for (set::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++) { - SCA_ISensor *sensor = *i; - sensor->Activate(m_logicmgr, NULL); + (*i)->Activate(m_logicmgr, NULL); } } - - -void SCA_RandomEventManager::RegisterSensor(SCA_ISensor* sensor) -{ - m_sensors.push_back(sensor); -}; diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h index 8c75ef665fa..79138c23c62 100644 --- a/source/gameengine/GameLogic/SCA_RandomEventManager.h +++ b/source/gameengine/GameLogic/SCA_RandomEventManager.h @@ -45,7 +45,6 @@ public: SCA_RandomEventManager(class SCA_LogicManager* logicmgr); virtual void NextFrame(); - virtual void RegisterSensor(SCA_ISensor* sensor); }; #endif //__KX_RANDOMEVENTMGR diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp index 643f1247a52..b7fadd3d62c 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp @@ -65,6 +65,11 @@ void SCA_TimeEventManager::RegisterSensor(SCA_ISensor* sensor) // not yet } +void SCA_TimeEventManager::RemoveSensor(SCA_ISensor* sensor) +{ + // empty +} + void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime) diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h index 2fd39661a2d..bd57e12eb44 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.h +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.h @@ -45,6 +45,7 @@ public: virtual void NextFrame(double curtime, double fixedtime); virtual void RegisterSensor(class SCA_ISensor* sensor); + virtual void RemoveSensor(class SCA_ISensor* sensor); void AddTimeProperty(CValue* timeval); void RemoveTimeProperty(CValue* timeval); }; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp index 7b5b7fdf78c..eee8e9f6827 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp @@ -55,28 +55,13 @@ KX_NetworkEventManager::~KX_NetworkEventManager() //printf("KX_NetworkEventManager destructor\n"); } -void KX_NetworkEventManager::RegisterSensor(class SCA_ISensor* sensor) -{ - //printf("KX_NetworkEventManager RegisterSensor\n"); - m_sensors.push_back(sensor); -} - -void KX_NetworkEventManager::RemoveSensor(class SCA_ISensor* sensor) -{ - //printf("KX_NetworkEventManager RemoveSensor\n"); - // Network specific RemoveSensor stuff goes here - - // parent - SCA_EventManager::RemoveSensor(sensor); -} - void KX_NetworkEventManager::NextFrame() { // printf("KX_NetworkEventManager::proceed %.2f - %.2f\n", curtime, deltatime); // each frame, the logicmanager will call the network // eventmanager to look for network events, and process it's // 'network' sensors - vector::iterator it; + set::iterator it; for (it = m_sensors.begin(); !(it==m_sensors.end()); it++) { // printf("KX_NetworkEventManager::proceed sensor %.2f\n", curtime); diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h index 0b097ba2ef6..ae88f1d4987 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h @@ -42,9 +42,6 @@ public: class NG_NetworkDeviceInterface *ndi); virtual ~KX_NetworkEventManager (); - virtual void RegisterSensor(class SCA_ISensor* sensor); - virtual void RemoveSensor(class SCA_ISensor* sensor); - virtual void NextFrame(); virtual void EndFrame(); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index df478be5ca2..02d1ad1b12b 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -275,6 +275,7 @@ void KX_GameObject::ProcessReplica(KX_GameObject* replica) replica->m_pSGNode = NULL; replica->m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info); replica->m_pClient_info->m_gameobject = replica; + replica->m_state = 0; } diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 89699d80031..140dd37f5c6 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -98,6 +98,14 @@ void KX_NearSensor::RegisterSumo(KX_TouchEventManager *touchman) } } +void KX_NearSensor::UnregisterSumo(KX_TouchEventManager* touchman) +{ + if (m_physCtrl) + { + touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl); + } +} + CValue* KX_NearSensor::GetReplica() { KX_NearSensor* replica = new KX_NearSensor(*this); diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index c6724caccc3..3f7078ef9fd 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -77,6 +77,7 @@ public: const PHY_CollData * coll_data); virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2); virtual void RegisterSumo(KX_TouchEventManager *touchman); + virtual void UnregisterSumo(KX_TouchEventManager* touchman); virtual PyObject* _getattr(const STR_String& attr); diff --git a/source/gameengine/Ketsji/KX_RayEventManager.cpp b/source/gameengine/Ketsji/KX_RayEventManager.cpp index 4101c6b547e..1af29151adf 100644 --- a/source/gameengine/Ketsji/KX_RayEventManager.cpp +++ b/source/gameengine/Ketsji/KX_RayEventManager.cpp @@ -44,14 +44,9 @@ using namespace std; void KX_RayEventManager::NextFrame() { - for (vector::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++) + for (set::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++) { - SCA_ISensor *sensor = *i; - sensor->Activate(m_logicmgr, NULL); + (*i)->Activate(m_logicmgr, NULL); } } -void KX_RayEventManager::RegisterSensor(SCA_ISensor* sensor) -{ - m_sensors.push_back(sensor); -}; diff --git a/source/gameengine/Ketsji/KX_RayEventManager.h b/source/gameengine/Ketsji/KX_RayEventManager.h index 3630f9682b9..b816d4d5250 100644 --- a/source/gameengine/Ketsji/KX_RayEventManager.h +++ b/source/gameengine/Ketsji/KX_RayEventManager.h @@ -45,7 +45,6 @@ public: m_logicmgr(logicmgr) {} virtual void NextFrame(); - virtual void RegisterSensor(SCA_ISensor* sensor); }; #endif //__KX_RAYEVENTMGR diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index 423543eef5c..7528fdbbc34 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -100,16 +100,24 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data, void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor) { KX_TouchSensor* touchsensor = static_cast(sensor); - m_sensors.push_back(touchsensor); + m_sensors.insert(touchsensor); touchsensor->RegisterSumo(this); } +void KX_TouchEventManager::RemoveSensor(SCA_ISensor* sensor) +{ + KX_TouchSensor* touchsensor = static_cast(sensor); + m_sensors.erase(touchsensor); + + touchsensor->UnregisterSumo(this); +} + void KX_TouchEventManager::EndFrame() { - vector::iterator it; + set::iterator it; for ( it = m_sensors.begin(); !(it==m_sensors.end());it++) { @@ -124,7 +132,7 @@ void KX_TouchEventManager::NextFrame() { if (m_sensors.size() > 0) { - vector::iterator it; + set::iterator it; for (it = m_sensors.begin();!(it==m_sensors.end());++it) static_cast(*it)->SynchronizeTransform(); @@ -157,20 +165,3 @@ void KX_TouchEventManager::NextFrame() (*it)->Activate(m_logicmgr,NULL); } } - - - -void KX_TouchEventManager::RemoveSensor(class SCA_ISensor* sensor) -{ - std::vector::iterator i = - std::find(m_sensors.begin(), m_sensors.end(), sensor); - if (!(i == m_sensors.end())) - { - std::swap(*i, m_sensors.back()); - m_sensors.pop_back(); - } - - // remove the sensor forever :) - SCA_EventManager::RemoveSensor(sensor); -} - diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h index 20ed6126bd0..cc77bccfc31 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.h +++ b/source/gameengine/Ketsji/KX_TouchEventManager.h @@ -71,8 +71,8 @@ public: PHY_IPhysicsEnvironment* physEnv); virtual void NextFrame(); virtual void EndFrame(); - virtual void RemoveSensor(class SCA_ISensor* sensor); virtual void RegisterSensor(SCA_ISensor* sensor); + virtual void RemoveSensor(SCA_ISensor* sensor); SCA_LogicManager* GetLogicManager() { return m_logicmgr;} PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; } diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index ce3aa1de2ef..60e1d87d318 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -153,6 +153,14 @@ void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman) } } +void KX_TouchSensor::UnregisterSumo(KX_TouchEventManager* touchman) +{ + if (m_physCtrl) + { + touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl); + } +} + bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_CollData* colldata) { // KX_TouchEventManager* toucheventmgr = (KX_TouchEventManager*)m_eventmgr; diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index 056440ccd6c..b611d296939 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -76,6 +76,7 @@ public: virtual void ReParent(SCA_IObject* parent); virtual void RegisterSumo(KX_TouchEventManager* touchman); + virtual void UnregisterSumo(KX_TouchEventManager* touchman); // virtual DT_Bool HandleCollision(void* obj1,void* obj2, // const DT_CollData * coll_data); diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h index ec1b7702ffd..7c61902f8e2 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h +++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h @@ -65,6 +65,7 @@ public: { } virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl) {} + virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl) {} virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;} virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;} diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index b773f40650b..ea14c5430e2 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -368,7 +368,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) body->setUserPointer(ctrl); body->setGravity( m_gravity ); - m_controllers.push_back(ctrl); + m_controllers.insert(ctrl); //use explicit group/filter for finer control over collision in bullet => near/radar sensor m_dynamicsWorld->addRigidBody(body, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask()); @@ -434,36 +434,13 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctrl) { - //also remove constraint - - m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody()); - - - { - std::vector::iterator i = - std::find(m_controllers.begin(), m_controllers.end(), ctrl); - if (!(i == m_controllers.end())) - { - std::swap(*i, m_controllers.back()); - m_controllers.pop_back(); - } - } + m_controllers.erase(ctrl); //remove it from the triggers - { - std::vector::iterator i = - std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl); - if (!(i == m_triggerControllers.end())) - { - std::swap(*i, m_triggerControllers.back()); - m_triggerControllers.pop_back(); - } - } - - + m_triggerControllers.erase(ctrl); } void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask) @@ -487,11 +464,10 @@ void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctr void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctrl) { - std::vector::iterator i = - std::find(m_controllers.begin(), m_controllers.end(), ctrl); - if (i == m_controllers.end()) + if (m_controllers.insert(ctrl).second) { btRigidBody* body = ctrl->GetRigidBody(); + body->setUserPointer(ctrl); m_dynamicsWorld->addCollisionObject(body, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask()); } @@ -507,12 +483,12 @@ void CcdPhysicsEnvironment::beginFrame() bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) { + std::set::iterator it; + int i; - int i,numCtrl = GetNumControllers(); - for (i=0;iSynchronizeMotionStates(timeStep); + (*it)->SynchronizeMotionStates(timeStep); } float subStep = timeStep / float(m_numTimeSubSteps); @@ -521,11 +497,9 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) m_dynamicsWorld->stepSimulation(subStep,0);//perform always a full simulation step } - numCtrl = GetNumControllers(); - for (i=0;iSynchronizeMotionStates(timeStep); + (*it)->SynchronizeMotionStates(timeStep); } for (i=0;i::iterator i = - std::find(m_controllers.begin(), m_controllers.end(), ctrl); - if ((i == m_controllers.end())) - { - addCcdPhysicsController(ctrl1); - } + // addSensor() is a "light" function for bullet because it is used + // dynamically when the sensor is activated. Use enableCcdPhysicsController() instead + //if (m_controllers.insert(ctrl1).second) + //{ + // addCcdPhysicsController(ctrl1); + //} + enableCcdPhysicsController(ctrl1); + //Collision filter/mask is now set at the time of the creation of the controller //force collision detection with everything, including static objects (might hurt performance!) //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask = btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::SensorTrigger; @@ -923,21 +885,15 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl) void CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl) { - std::vector::iterator i = - std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl); - if (!(i == m_triggerControllers.end())) - { - std::swap(*i, m_triggerControllers.back()); - m_triggerControllers.pop_back(); - } + m_triggerControllers.erase((CcdPhysicsController*)ctrl); } void CcdPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl) { - removeCollisionCallback(ctrl); - //printf("removeSensor\n"); + removeCcdPhysicsController((CcdPhysicsController*)ctrl); } + void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user) { /* printf("addTouchCallback\n(response class = %i)\n",response_class); @@ -975,10 +931,9 @@ void CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctr CcdPhysicsController* ccdCtrl = static_cast(ctrl); //printf("requestCollisionCallback\n"); - m_triggerControllers.push_back(ccdCtrl); + m_triggerControllers.insert(ccdCtrl); } - void CcdPhysicsEnvironment::CallbackTriggers() { @@ -1011,11 +966,10 @@ void CcdPhysicsEnvironment::CallbackTriggers() CcdPhysicsController* ctrl0 = static_cast(obj0->getUserPointer()); CcdPhysicsController* ctrl1 = static_cast(obj1->getUserPointer()); - std::vector::iterator i = - std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl0); + std::set::const_iterator i = m_triggerControllers.find(ctrl0); if (i == m_triggerControllers.end()) { - i = std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl1); + i = m_triggerControllers.find(ctrl1); } if (!(i == m_triggerControllers.end())) @@ -1125,7 +1079,6 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi CcdPhysicsController* sphereController = new CcdPhysicsController(cinfo); - return sphereController; } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 453749b27b3..fd96522037e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -18,6 +18,7 @@ subject to the following restrictions: #include "PHY_IPhysicsEnvironment.h" #include +#include class CcdPhysicsController; #include "LinearMath/btVector3.h" #include "LinearMath/btTransform.h" @@ -209,12 +210,6 @@ protected: } - int GetNumControllers(); - - CcdPhysicsController* GetPhysicsController( int index); - - - const btPersistentManifold* GetManifold(int index) const; @@ -229,9 +224,9 @@ protected: - std::vector m_controllers; + std::set m_controllers; - std::vector m_triggerControllers; + std::set m_triggerControllers; PHY_ResponseCallback m_triggerCallbacks[PHY_NUM_RESPONSE]; void* m_triggerCallbacksUserPtrs[PHY_NUM_RESPONSE]; diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index f0761618e4e..b5a61f72e4a 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -80,6 +80,7 @@ public: { } virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl) {} + virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl) {} virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;} virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;} diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp index b5bf67b14ea..f0791bbf89f 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp @@ -98,12 +98,17 @@ void SM_Scene::addTouchCallback(int response_class, DT_ResponseCallback callback void SM_Scene::addSensor(SM_Object& object) { - object.calcXform(); - m_objectList.push_back(&object); - DT_AddObject(m_scene, object.getObjectHandle()); - DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[SENSOR_RESPONSE]); - DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[SENSOR_RESPONSE]); - DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[SENSOR_RESPONSE]); + T_ObjectList::iterator i = + std::find(m_objectList.begin(), m_objectList.end(), &object); + if (i == m_objectList.end()) + { + object.calcXform(); + m_objectList.push_back(&object); + DT_AddObject(m_scene, object.getObjectHandle()); + DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[SENSOR_RESPONSE]); + DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass [SENSOR_RESPONSE]); + DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[SENSOR_RESPONSE]); + } } void SM_Scene::add(SM_Object& object) { diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp index 16ba45a0be5..65018d2523e 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp @@ -228,6 +228,12 @@ void SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ct m_sumoScene->requestCollisionCallback(*smObject); } } + +void SumoPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl) +{ + // intentionally empty +} + PHY_IPhysicsController* SumoPhysicsEnvironment::CreateSphereController(float radius,const PHY__Vector3& position) { DT_ShapeHandle shape = DT_NewSphere(0.0); diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h index ce5cd70e8cc..8b9fb463034 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h @@ -84,6 +84,7 @@ public: virtual void removeSensor(PHY_IPhysicsController* ctrl); virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user); virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl); + virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl); virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position); virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight); diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index c148210903f..5b275066665 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -104,6 +104,7 @@ class PHY_IPhysicsEnvironment virtual void removeSensor(PHY_IPhysicsController* ctrl)=0; virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0; virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl)=0; + virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl)=0; //These two methods are *solely* used to create controllers for sensor! Don't use for anything else virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) =0; virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0; -- cgit v1.2.3 From 01b1bd49015ee0f0389a28b62669aa2414d2d46d Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 30 Jul 2008 20:45:04 +0000 Subject: * another commit adding std:: to the sort call (older msvc [<9] choked?) --- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index adef998acc2..af5228e4c35 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -676,7 +676,7 @@ void RAS_MeshObject::SortPolygons(const MT_Transform &transform) slots[j].get(vertexarray, indexarray, j*nvert, nvert, pnorm); /* sort (stable_sort might be better, if flickering happens?) */ - sort(slots.begin(), slots.end(), backtofront()); + std::sort(slots.begin(), slots.end(), backtofront()); /* get indices from temporary array again */ for(j=0; j Date: Sat, 2 Aug 2008 22:11:22 +0000 Subject: Small update to get the BlenderPlayer compiling (also needed for 2.47) --- source/gameengine/GamePlayer/common/windows/GPW_Canvas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h index bb1abd71505..bf8cb720811 100644 --- a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h +++ b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h @@ -36,7 +36,7 @@ #include #include -#include +//#include #include "GPC_Canvas.h" -- cgit v1.2.3 From ae762bec91a75a3e66ac7876bb4f0eb23472f7e4 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 3 Aug 2008 21:59:36 +0000 Subject: BGE patch #17398 approved: implementation of BGE method getVectTo(). --- source/gameengine/Ketsji/KX_GameObject.cpp | 52 ++++++++++++++++++++++++++++++ source/gameengine/Ketsji/KX_GameObject.h | 1 + source/gameengine/PyDoc/KX_GameObject.py | 10 ++++++ 3 files changed, 63 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 02d1ad1b12b..6e922e421ac 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -914,6 +914,7 @@ PyMethodDef KX_GameObject::Methods[] = { KX_PYMETHODTABLE(KX_GameObject, rayCastTo), KX_PYMETHODTABLE(KX_GameObject, rayCast), KX_PYMETHODTABLE(KX_GameObject, getDistanceTo), + KX_PYMETHODTABLE(KX_GameObject, getVectTo), {NULL,NULL} //Sentinel }; @@ -1555,6 +1556,57 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo, return NULL; } +KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo, +"getVectTo(other): get vector and the distance to another point/KX_GameObject\n" +"Returns a 3-tuple with (distance,worldVector,localVector)\n") +{ + MT_Point3 toPoint, fromPoint; + MT_Vector3 toDir, locToDir; + MT_Scalar distance; + + PyObject *returnValue = PyTuple_New(3); + PyObject *pyother; + + if (!returnValue) + { + PyErr_SetString(PyExc_MemoryError, "PyTuple_New() failed"); + return NULL; + } + if (!PyVecArgTo(args, toPoint)) + { + PyErr_Clear(); + if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &pyother)) + { + KX_GameObject *other = static_cast(pyother); + toPoint = other->NodeGetWorldPosition(); + }else + { + PyErr_SetString(PyExc_TypeError, "Invalid arguments"); + return NULL; + } + } + + fromPoint = NodeGetWorldPosition(); + toDir = toPoint-fromPoint; + distance = toDir.length(); + + if (MT_fuzzyZero(distance)) + { + //cout << "getVectTo() Error: Null vector!\n"; + locToDir = toDir = MT_Vector3(0.0,0.0,0.0); + distance = 0.0; + } else { + toDir.normalize(); + locToDir = toDir * NodeGetWorldOrientation(); + } + + PyTuple_SET_ITEM(returnValue, 0, PyFloat_FromDouble(distance)); + PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(toDir)); + PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(locToDir)); + + return returnValue; +} + bool KX_GameObject::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) { diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 1d36798b12f..4e435e9ddf4 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -756,6 +756,7 @@ public: KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); KX_PYMETHOD_DOC(KX_GameObject,rayCast); KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo); + KX_PYMETHOD_DOC(KX_GameObject,getVectTo); private : diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 8f17cf26f15..a5ba5b1d634 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -253,6 +253,16 @@ class KX_GameObject: @type other: L{KX_GameObject} or list [x, y, z] @rtype: float """ + def getVectTo(other): + """ + Returns the vector and the distance to another object or point. + The vector is normalized unless the distance is 0, in which a NULL vector is returned. + + @param other: a point or another L{KX_GameObject} to get the vector and distance to. + @type other: L{KX_GameObject} or list [x, y, z] + @rtype: 3-tuple (float, 3-tuple (x,y,z), 3-tuple (x,y,z)) + @return: (distance, globalVector(3), localVector(3)) + """ def rayCastTo(other,dist,prop): """ Look towards another point/object and find first object hit within dist that matches prop. -- cgit v1.2.3 From 3598dcd2796f819bd762f88c2d275816fed0e0d6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Aug 2008 01:57:22 +0000 Subject: * KX_GameObject.cpp - error with getMesh(), was returning None rather then an error with invalid args. also memory leak with getVectTo() if invalid args were given. * Material.c - functions for get/setRayTransGlossSamples were not being used. * BPY_interface.c - removed function GetName(), since everything else just uses id->name+2. * header_info.c - added ifdef win32 around copy_game_dll since its not needed for other os's yet --- source/gameengine/Ketsji/KX_GameObject.cpp | 50 +++++++++++++----------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6e922e421ac..6fcd3df2afc 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1368,14 +1368,15 @@ PyObject* KX_GameObject::PyGetMesh(PyObject* self, { int mesh = 0; - if (PyArg_ParseTuple(args, "|i", &mesh)) + if (!PyArg_ParseTuple(args, "|i", &mesh)) + return NULL; // python sets a simple error + + if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0) { - if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0) - { - KX_MeshProxy* meshproxy = new KX_MeshProxy(m_meshes[mesh]); - return meshproxy; - } + KX_MeshProxy* meshproxy = new KX_MeshProxy(m_meshes[mesh]); + return meshproxy; } + Py_RETURN_NONE; } @@ -1564,14 +1565,9 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo, MT_Vector3 toDir, locToDir; MT_Scalar distance; - PyObject *returnValue = PyTuple_New(3); + PyObject *returnValue; PyObject *pyother; - if (!returnValue) - { - PyErr_SetString(PyExc_MemoryError, "PyTuple_New() failed"); - return NULL; - } if (!PyVecArgTo(args, toPoint)) { PyErr_Clear(); @@ -1581,7 +1577,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo, toPoint = other->NodeGetWorldPosition(); }else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); + PyErr_SetString(PyExc_TypeError, "Expected a 3D Vector or GameObject type"); return NULL; } } @@ -1599,11 +1595,13 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo, toDir.normalize(); locToDir = toDir * NodeGetWorldOrientation(); } - - PyTuple_SET_ITEM(returnValue, 0, PyFloat_FromDouble(distance)); - PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(toDir)); - PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(locToDir)); - + + returnValue = PyTuple_New(3); + if (returnValue) { // very unlikely to fail, python sets a memory error here. + PyTuple_SET_ITEM(returnValue, 0, PyFloat_FromDouble(distance)); + PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(toDir)); + PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(locToDir)); + } return returnValue; } @@ -1640,8 +1638,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, char *propName = NULL; if (!PyArg_ParseTuple(args,"O|fs", &pyarg, &dist, &propName)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); - return NULL; + return NULL; // python sets simple error } if (!PyVecTo(pyarg, toPoint)) @@ -1706,8 +1703,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, KX_GameObject *other; if (!PyArg_ParseTuple(args,"O|Ofs", &pyto, &pyfrom, &dist, &propName)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); - return NULL; + return NULL; // Python sets a simple error } if (!PyVecTo(pyto, toPoint)) @@ -1766,13 +1762,11 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, if (m_pHitObject) { PyObject* returnValue = PyTuple_New(3); - if (!returnValue) { - PyErr_SetString(PyExc_TypeError, "PyTuple_New() failed"); - return NULL; + if (returnValue) { // unlikely this would ever fail, if it does python sets an error + PyTuple_SET_ITEM(returnValue, 0, m_pHitObject->AddRef()); + PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(resultPoint)); + PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(resultNormal)); } - PyTuple_SET_ITEM(returnValue, 0, m_pHitObject->AddRef()); - PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(resultPoint)); - PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(resultNormal)); return returnValue; } return Py_BuildValue("OOO", Py_None, Py_None, Py_None); -- cgit v1.2.3 From cd1d46c61d937f63684216f284777f75038f5ed3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Aug 2008 09:35:46 +0000 Subject: Added GameLogic.Mathutils so Mathutils and its types can be accessed from blenderplayer. also changed importText so it dosnt do a malloc --- source/gameengine/Ketsji/KX_PythonInit.cpp | 9 ++++++++- source/gameengine/Ketsji/SConscript | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index b66c3e42606..57ee52f9880 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -62,6 +62,10 @@ #include "KX_PyMath.h" +extern "C" { + #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. +} + #include "PHY_IPhysicsEnvironment.h" // FIXME: Enable for access to blender python modules. This is disabled because // python has dependencies on a lot of other modules and is a pain to link. @@ -733,7 +737,10 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook ErrorObject = PyString_FromString("GameLogic.error"); PyDict_SetItemString(d, "error", ErrorObject); - + + // Add Blender.Mathutils module, duplicate code :/ + PyDict_SetItemString(d, "Mathutils", Mathutils_Init("GameLogic.Mathutils")); + // XXXX Add constants here /* To use logic bricks, we need some sort of constants. Here, we associate */ /* constants and sumbolic names. Add them to dictionary d. */ diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index fdac5a71071..f6f744b199a 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -5,7 +5,21 @@ Import ('env') sources = env.Glob('*.cpp') -incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc' +# Mathutils C files. +sources.extend([\ + '#source/blender/python/api2_2x/Mathutils.c',\ + '#source/blender/python/api2_2x/constant.c',\ + '#source/blender/python/api2_2x/euler.c',\ + '#source/blender/python/api2_2x/gen_utils.c',\ + '#source/blender/python/api2_2x/matrix.c',\ + '#source/blender/python/api2_2x/point.c',\ + '#source/blender/python/api2_2x/quat.c',\ + '#source/blender/python/api2_2x/vector.c',\ +]) + +incs = '. #source/blender/python/api2_2x' # Only for Mathutils! - no other deps + +incs += ' #source/kernel/gen_system #intern/string #intern/guardedalloc' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #intern/bmfont' incs += ' #intern/SoundSystem #intern/SoundSystem/include #intern/SoundSystem/openal' incs += ' #intern/SoundSystem/dummy #intern/SoundSystem/intern #source/gameengine/Converter' -- cgit v1.2.3 From 553694b614be5d20d8be77bea93149ae69da39b9 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 5 Aug 2008 16:23:33 +0000 Subject: BGE fix bug #17430: BGE Collide/Touch Sensor interfearing with other unrelated sensor states. The bug was introduced in the recent logic optimization patch. It only affects collision and touch sensors. The bug is fixed by keeping track of registration count. --- source/gameengine/Ketsji/KX_TouchEventManager.cpp | 12 ++++++------ .../Physics/Bullet/CcdPhysicsController.cpp | 5 +++-- .../Physics/Bullet/CcdPhysicsController.h | 9 ++++++++- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 22 ++++++++++++++++++---- .../Physics/Bullet/CcdPhysicsEnvironment.h | 5 +---- 5 files changed, 36 insertions(+), 17 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp index 7528fdbbc34..48d4cf59a2b 100644 --- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp +++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp @@ -100,17 +100,17 @@ bool KX_TouchEventManager::newBroadphaseResponse(void *client_data, void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor) { KX_TouchSensor* touchsensor = static_cast(sensor); - m_sensors.insert(touchsensor); - - touchsensor->RegisterSumo(this); + if (m_sensors.insert(touchsensor).second) + // the sensor was effectively inserted, register it + touchsensor->RegisterSumo(this); } void KX_TouchEventManager::RemoveSensor(SCA_ISensor* sensor) { KX_TouchSensor* touchsensor = static_cast(sensor); - m_sensors.erase(touchsensor); - - touchsensor->UnregisterSumo(this); + if (m_sensors.erase(touchsensor)) + // the sensor was effectively removed, unregister it + touchsensor->UnregisterSumo(this); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 5c70b071661..b872fae6138 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -42,7 +42,8 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) { m_collisionDelay = 0; m_newClientInfo = 0; - + m_registerCount = 0; + m_MotionState = ci.m_MotionState; m_bulletMotionState = 0; @@ -217,7 +218,7 @@ void CcdPhysicsController::WriteDynamicsToMotionState() void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl) { m_MotionState = motionstate; - + m_registerCount = 0; m_body = 0; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 64f1876e199..448e5622eff 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -110,12 +110,19 @@ class CcdPhysicsController : public PHY_IPhysicsController void* m_newClientInfo; - + int m_registerCount; // needed when multiple sensors use the same controller CcdConstructionInfo m_cci;//needed for replication void GetWorldOrientation(btMatrix3x3& mat); void CreateRigidbody(); + bool Register() { + return (m_registerCount++ == 0) ? true : false; + } + bool Unregister() { + return (--m_registerCount == 0) ? true : false; + } + protected: void setWorldOrientation(const btMatrix3x3& mat); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index ea14c5430e2..08f40424323 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -439,6 +439,9 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody()); m_controllers.erase(ctrl); + if (ctrl->m_registerCount != 0) + printf("Warning: removing controller with non-zero m_registerCount: %d\n", ctrl->m_registerCount); + //remove it from the triggers m_triggerControllers.erase(ctrl); } @@ -473,6 +476,13 @@ void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctr } } +void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ctrl) +{ + if (m_controllers.erase(ctrl)) + { + m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody()); + } +} void CcdPhysicsEnvironment::beginFrame() @@ -885,13 +895,17 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl) void CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl) { - m_triggerControllers.erase((CcdPhysicsController*)ctrl); + CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl; + if (ccdCtrl->Unregister()) + m_triggerControllers.erase(ccdCtrl); } void CcdPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl) { - removeCcdPhysicsController((CcdPhysicsController*)ctrl); + removeCollisionCallback(ctrl); + + disableCcdPhysicsController((CcdPhysicsController*)ctrl); } void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user) @@ -930,8 +944,8 @@ void CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctr { CcdPhysicsController* ccdCtrl = static_cast(ctrl); - //printf("requestCollisionCallback\n"); - m_triggerControllers.insert(ccdCtrl); + if (ccdCtrl->Register()) + m_triggerControllers.insert(ccdCtrl); } void CcdPhysicsEnvironment::CallbackTriggers() diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index fd96522037e..825a5e525f2 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -186,10 +186,7 @@ protected: void updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask); - void disableCcdPhysicsController(CcdPhysicsController* ctrl) - { - removeCcdPhysicsController(ctrl); - } + void disableCcdPhysicsController(CcdPhysicsController* ctrl); void enableCcdPhysicsController(CcdPhysicsController* ctrl); -- cgit v1.2.3 From a86609af8e2c057307fa59a1e73c0ba0866580aa Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Tue, 5 Aug 2008 21:20:14 +0000 Subject: Fix segmentation faul in GE. We assign the material name before check the pointer. Please Benoit check this and also I have a compiler warning about the second argument in the previous call of ConvertMaterialIpos, the argument is NULL but the function need a dword. --- source/gameengine/Converter/KX_IpoConvert.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 7410beecaf4..61b095d93b1 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -773,8 +773,11 @@ void BL_ConvertMaterialIpos( for (int material_index=1; material_index <= blenderobject->totcol; material_index++) { Material *mat = give_current_material(blenderobject, material_index); - STR_HashedString matname = mat->id.name; - if(mat) ConvertMaterialIpos(mat, matname.hash(), gameobj, converter); + STR_HashedString matname; + if(mat) { + matname= mat->id.name; + ConvertMaterialIpos(mat, matname.hash(), gameobj, converter); + } } } } -- cgit v1.2.3 From 028d44c0751ca8bec0a404e0738b5b563222bf84 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Aug 2008 22:26:00 +0000 Subject: Made Mathutils its own module rather then GanmeLogic.Mathutils --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 3 ++- source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 2 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 10 ++++++---- source/gameengine/Ketsji/KX_PythonInit.h | 1 + 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index b3a3a47152a..7de3056e382 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -335,7 +335,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module. initGameKeys(); initPythonConstraintBinding(); - + initMathutils(); if (sceneconverter) { @@ -602,6 +602,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); + initMathutils(); if (sceneconverter) { diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index b5ebffb9378..ab91f0cd43d 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -647,7 +647,7 @@ bool GPG_Application::startEngine(void) PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); - + initMathutils(); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 57ee52f9880..db4793de23d 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -738,9 +738,6 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook ErrorObject = PyString_FromString("GameLogic.error"); PyDict_SetItemString(d, "error", ErrorObject); - // Add Blender.Mathutils module, duplicate code :/ - PyDict_SetItemString(d, "Mathutils", Mathutils_Init("GameLogic.Mathutils")); - // XXXX Add constants here /* To use logic bricks, we need some sort of constants. Here, we associate */ /* constants and sumbolic names. Add them to dictionary d. */ @@ -883,7 +880,7 @@ PyObject *KXpy_import(PyObject *self, PyObject *args) /* quick hack for GamePython modules TODO: register builtin modules properly by ExtendInittab */ if (!strcmp(name, "GameLogic") || !strcmp(name, "GameKeys") || !strcmp(name, "PhysicsConstraints") || - !strcmp(name, "Rasterizer")) { + !strcmp(name, "Rasterizer") || !strcmp(name, "Mathutils")) { return PyImport_ImportModuleEx(name, globals, locals, fromlist); } @@ -1176,6 +1173,11 @@ PyObject* initGameKeys() return d; } +PyObject* initMathutils() +{ + return Mathutils_Init("Mathutils"); // Use as a top level module in BGE +} + void PHY_SetActiveScene(class KX_Scene* scene) { gp_KetsjiScene = scene; diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 41cf7fd67b3..f094a1ca575 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -44,6 +44,7 @@ PyObject* initGameLogic(class KX_Scene* ketsjiscene); PyObject* initGameKeys(); PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas); PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level); +PyObject* initMathutils(); void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level); void exitGamePythonScripting(); -- cgit v1.2.3 From 553e35e36f53c881712e86c6c98f49f9e0291f04 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 6 Aug 2008 04:09:10 +0000 Subject: * blenderplayer wasnt useing the scenes frame rate. * GBE Python API's alignToVect wasnt clamping the align ammount from 0.0-1.0 * Generated images arnt animated - use for a test to see if the textures animated. --- source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 6 ++++++ source/gameengine/Ketsji/KX_GameObject.cpp | 3 +++ 2 files changed, 9 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index ab91f0cd43d..7be3b94d8ae 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -56,6 +56,7 @@ extern "C" #include "BLO_readfile.h" #include "BKE_global.h" #include "BKE_main.h" +#include "DNA_scene_types.h" #ifdef __cplusplus } #endif // __cplusplus @@ -669,6 +670,11 @@ bool GPG_Application::startEngine(void) m_ketsjiengine->StartEngine(true); m_engineRunning = 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 + m_ketsjiengine->SetAnimFrameRate( (((double) G.scene->r.frs_sec) / G.scene->r.frs_sec_base) ); + } if (!m_engineRunning) diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6fcd3df2afc..661bf17ef23 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1490,6 +1490,9 @@ PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, MT_Vector3 vect; if (PyVecTo(pyvect, vect)) { + if (fac<=0.0) Py_RETURN_NONE; // Nothing to do. + if (fac< 1.0) fac= 1.0; + AlignAxisToVect(vect,axis,fac); NodeUpdateGS(0.f,true); Py_RETURN_NONE; -- cgit v1.2.3 From 8102217b9cc1d35b082cd2deed803ed699653908 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 6 Aug 2008 10:23:47 +0000 Subject: BGE fix: confirm fix for segmentation fault by Diego and remove warning in calling ConvertMaterial Ipos. --- source/gameengine/Converter/KX_IpoConvert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 61b095d93b1..ce004fa0504 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -766,7 +766,7 @@ void BL_ConvertMaterialIpos( // if there is only one material attached to the mesh then set material_index in BL_ConvertMaterialIpos to NULL // --> this makes the UpdateMaterialData function in KX_GameObject.cpp use the old hack of using SetObjectColor // because this yields a better performance as not all the vertex colors need to be edited - if(mat) ConvertMaterialIpos(mat, NULL, gameobj, converter); + if(mat) ConvertMaterialIpos(mat, 0, gameobj, converter); } else { -- cgit v1.2.3 From ba12aa09622be28c3345b934080129cb4c27eab2 Mon Sep 17 00:00:00 2001 From: Chris Want Date: Wed, 6 Aug 2008 20:37:15 +0000 Subject: Getting the blenderplayer to compile/link with CMake. Note: yuck, this is a horrible way to do it -- python devs should think about splitting the python stuff into separate libs if they only want to partially include it in the game engine. --- source/gameengine/Ketsji/CMakeLists.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 3b907d8d530..be009d94701 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -25,6 +25,17 @@ # ***** END GPL LICENSE BLOCK ***** FILE(GLOB SRC *.cpp) +SET(SRC + ${SRC} + ../../../source/blender/python/api2_2x/Mathutils.c + ../../../source/blender/python/api2_2x/constant.c + ../../../source/blender/python/api2_2x/euler.c + ../../../source/blender/python/api2_2x/gen_utils.c + ../../../source/blender/python/api2_2x/matrix.c + ../../../source/blender/python/api2_2x/point.c + ../../../source/blender/python/api2_2x/quat.c + ../../../source/blender/python/api2_2x/vector.c +) SET(INC . @@ -39,7 +50,8 @@ SET(INC ../../../intern/moto/include ../../../source/gameengine/Ketsji ../../../source/blender/blenlib - ../../../source/blender/blenkernel + ../../../source/blender/blenkernel + ../../../source/blender/python/api2_2x ../../../source/blender ../../../source/blender/include ../../../source/blender/makesdna -- cgit v1.2.3 From 3adf5dda97b9e3df88857091a393244d9d5321a6 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 7 Aug 2008 11:25:45 +0000 Subject: BGE fix: alignToVect() fac parameter clamping should obviously be done the other way round --- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 661bf17ef23..989cdabd491 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1491,7 +1491,7 @@ PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, if (PyVecTo(pyvect, vect)) { if (fac<=0.0) Py_RETURN_NONE; // Nothing to do. - if (fac< 1.0) fac= 1.0; + if (fac> 1.0) fac= 1.0; AlignAxisToVect(vect,axis,fac); NodeUpdateGS(0.f,true); -- cgit v1.2.3 From 15952fb26caccc5207234b768bf542070c0ec404 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 7 Aug 2008 11:31:24 +0000 Subject: BGE bug #17409 fixed: BGE Near Sensor Incorrect once inside the radius. The bug is located in Bullet: the manifold contact points for non-response objects (sensor, ghost) are not refreshed and stay in the cash as long as the objects overlap in the broad phase. Instead of fixing Bullet, I put a work around in the BGE. This may need review when a new Bullet library is integrated --- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 08f40424323..0a37a461c59 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -956,13 +956,25 @@ void CcdPhysicsEnvironment::CallbackTriggers() if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints))) { //walk over all overlapping pairs, and if one of the involved bodies is registered for trigger callback, perform callback - int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds(); + btDispatcher* dispatcher = m_dynamicsWorld->getDispatcher(); + int numManifolds = dispatcher->getNumManifolds(); for (int i=0;igetDispatcher()->getManifoldByIndexInternal(i); + btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i); int numContacts = manifold->getNumContacts(); if (numContacts) { + btRigidBody* rb0 = static_cast(manifold->getBody0()); + btRigidBody* rb1 = static_cast(manifold->getBody1()); + // Bullet does not refresh the manifold contact point for object without contact response + // may need to remove this when a newer Bullet version is integrated + if (!dispatcher->needsResponse(rb0, rb1)) + { + manifold->refreshContactPoints(rb0->getCenterOfMassTransform(),rb1->getCenterOfMassTransform()); + numContacts = manifold->getNumContacts(); + if (!numContacts) + continue; + } if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)) { for (int j=0;jdrawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),color); } } - btRigidBody* obj0 = static_cast(manifold->getBody0()); - btRigidBody* obj1 = static_cast(manifold->getBody1()); + btRigidBody* obj0 = rb0; + btRigidBody* obj1 = rb1; //m_internalOwner is set in 'addPhysicsController' CcdPhysicsController* ctrl0 = static_cast(obj0->getUserPointer()); -- cgit v1.2.3 From 36ef95eff5ef188dcc9ece88996fb2e245730829 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 7 Aug 2008 17:29:06 +0000 Subject: BGE bug #17408 fixed: Radar sensor is oriented the wrong way when the set along negative axis. Improve reliability of Radar detection by clearing the manifold cache instead of updating it. --- source/gameengine/Ketsji/KX_RadarSensor.cpp | 14 +++++++------- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 18 +++++++++--------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index de4979ac4c9..d371626b597 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -147,23 +147,23 @@ void KX_RadarSensor::SynchronizeTransform() }; case 3: // -X Axis { - MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90)); + 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 4: // -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)); + //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180)); + //trans.rotate(rotquatje); + trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0)); break; }; case 5: // -Z Axis { - MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90)); + 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: diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 0a37a461c59..dfbcf115fd7 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -966,15 +966,6 @@ void CcdPhysicsEnvironment::CallbackTriggers() { btRigidBody* rb0 = static_cast(manifold->getBody0()); btRigidBody* rb1 = static_cast(manifold->getBody1()); - // Bullet does not refresh the manifold contact point for object without contact response - // may need to remove this when a newer Bullet version is integrated - if (!dispatcher->needsResponse(rb0, rb1)) - { - manifold->refreshContactPoints(rb0->getCenterOfMassTransform(),rb1->getCenterOfMassTransform()); - numContacts = manifold->getNumContacts(); - if (!numContacts) - continue; - } if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)) { for (int j=0;jneedsResponse(rb0, rb1)) + { + // Refresh algorithm fails sometimes when there is penetration + // (usuall the case with ghost and sensor objects) + // Let's just clear the manifold, in any case, it is recomputed on each frame. + manifold->clearManifold(); //refreshContactPoints(rb0->getCenterOfMassTransform(),rb1->getCenterOfMassTransform()); + } } } -- cgit v1.2.3 From 62f9ba67c0970ef6a7fa2a9feae4784a94d675dc Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 8 Aug 2008 09:57:17 +0000 Subject: BGE bug #17450 fixed: When we have parented objects with no scale-applyed objects the ray hit system doesn't work properly. Fix by separating rotation and scaling in the parent inverse node to keep scaling correct down to the leaf objects. Only isotropric scaling should be used, as always with the BGE. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index f44318120e8..a6337403cd1 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1939,7 +1939,17 @@ void BL_ConvertBlenderObjects(struct Main* maggie, float* fl = (float*) blenderobject->parentinv; MT_Transform parinvtrans(fl); parentinversenode->SetLocalPosition(parinvtrans.getOrigin()); - parentinversenode->SetLocalOrientation(parinvtrans.getBasis()); + // problem here: the parent inverse transform combines scaling and rotation + // in the basis but the scenegraph needs separate rotation and scaling. + // This is not important for OpenGL (it uses 4x4 matrix) but it is important + // for the physic engine that needs a separate scaling + //parentinversenode->SetLocalOrientation(parinvtrans.getBasis()); + + // Extract the rotation and the scaling from the basis + MT_Matrix3x3 inverseOrientation(parinvtrans.getRotation()); + parentinversenode->SetLocalOrientation(inverseOrientation); + MT_Matrix3x3 scale(inverseOrientation.transposed()*parinvtrans.getBasis()); + parentinversenode->SetLocalScale(MT_Vector3(scale[0][0], scale[1][1], scale[2][2])); parentinversenode->AddChild(gameobj->GetSGNode()); } -- cgit v1.2.3 From 234575774668d4e6b6e3b9943586d690786a6b31 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Aug 2008 12:32:54 +0000 Subject: raise an error when assigning properties to a game object that cant be converted. also use python apis functions for converting floats and int types (faster then PyArg_Parse) --- source/gameengine/Expressions/Value.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 48136eb9dc3..b4694740679 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -700,9 +700,7 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj) CValue* vallie = NULL; - PyTypeObject* type = pyobj->ob_type; - - if (type == &PyList_Type) + if (PyList_Check(pyobj)) { CListValue* listval = new CListValue(); bool error = false; @@ -732,26 +730,25 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj) } } else - if (type == &PyFloat_Type) + if (PyFloat_Check(pyobj)) { - float fl; - PyArg_Parse(pyobj,"f",&fl); - vallie = new CFloatValue(fl); + vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) ); } else - if (type==&PyInt_Type) + if (PyInt_Check(pyobj)) { - int innie; - PyArg_Parse(pyobj,"i",&innie); - vallie = new CIntValue(innie); + vallie = new CIntValue( (int)PyInt_AS_LONG(pyobj) ); } else - - if (type==&PyString_Type) + if (PyString_Check(pyobj)) { vallie = new CStringValue(PyString_AsString(pyobj),""); } else - if (type==&CValue::Type || type==&CListValue::Type) + if (pyobj->ob_type==&CValue::Type || pyobj->ob_type==&CListValue::Type) { vallie = ((CValue*) pyobj)->AddRef(); + } else + { + /* return an error value from the caller */ + PyErr_SetString(PyExc_TypeError, "This python value could not be assigned to a game engine property"); } return vallie; @@ -778,6 +775,9 @@ int CValue::_setattr(const STR_String& attr,PyObject* pyobj) SetProperty(attr,vallie); } vallie->Release(); + } else + { + return 1; /* ConvertPythonToValue sets the error message */ } //PyObjectPlus::_setattr(attr,value); -- cgit v1.2.3 From d60025e95fd8b9f8ce46ce2bb65d2be8dec3cc85 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 13 Aug 2008 10:19:47 +0000 Subject: Bugfix: in the game engine, errors in a particular python script caused somewhat random crashes, which I think was caused by the error print using python objects that were freed too soon. Now it frees the dictionary after the print. --- .../gameengine/GameLogic/SCA_PythonController.cpp | 31 ++++++---------------- 1 file changed, 8 insertions(+), 23 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 01ae4072335..cd1b029fc34 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -273,36 +273,16 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) * break it by hand, then DECREF (which in this case * should always ensure excdict is cleared). */ -/* PyObject *excdict= myPyDict_Copy(m_pythondictionary); - struct _object* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, - excdict, - excdict - ); - PyDict_Clear(excdict); - Py_DECREF(excdict);*/ - -#if 1 PyObject *excdict= PyDict_Copy(m_pythondictionary); PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, - excdict, - excdict - ); - PyDict_Clear(excdict); - Py_DECREF(excdict); -#else - - PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode, - m_pythondictionary, - m_pythondictionary - ); - -#endif + excdict, excdict); if (resultobj) { Py_DECREF(resultobj); - } else + } + else { // something is wrong, tell the user what went wrong printf("PYTHON SCRIPT ERROR:\n"); @@ -310,6 +290,11 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) //PyRun_SimpleString(m_scriptText.Ptr()); } + // clear after PyErrPrint - seems it can be using + // something in this dictionary and crash? + PyDict_Clear(excdict); + Py_DECREF(excdict); + m_sCurrentController = NULL; } -- cgit v1.2.3 From 3f2cb6e87855e4afc2e26d87f36817a92490429e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Aug 2008 03:23:36 +0000 Subject: game engine python api * removed macros that were not used much, some misleading. * removed error string setting calls that overwrote the error set by PyArg_ParseTuple with a less useful one. * use python macros Py_RETURN_NONE, Py_RETURN_TRUE, Py_RETURN_FALSE --- source/gameengine/Converter/BL_ActionActuator.cpp | 44 ++++++------------- .../Converter/BL_ShapeActionActuator.cpp | 44 +++++-------------- source/gameengine/Expressions/InputParser.cpp | 5 ++- source/gameengine/Expressions/ListValue.cpp | 13 +++--- source/gameengine/Expressions/PyObjectPlus.cpp | 12 +++--- source/gameengine/Expressions/PyObjectPlus.h | 15 ------- source/gameengine/Expressions/Value.cpp | 16 +++---- source/gameengine/Expressions/Value.h | 2 +- source/gameengine/GameLogic/SCA_ActuatorSensor.cpp | 1 - source/gameengine/GameLogic/SCA_ILogicBrick.cpp | 3 +- source/gameengine/Ketsji/BL_Shader.cpp | 50 ++++++++-------------- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 9 ---- source/gameengine/Ketsji/KX_ConstraintWrapper.cpp | 3 +- source/gameengine/Ketsji/KX_IpoActuator.cpp | 8 ---- source/gameengine/Ketsji/KX_MeshProxy.cpp | 2 +- source/gameengine/Ketsji/KX_ObjectActuator.cpp | 11 ----- .../gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp | 8 ++-- .../gameengine/Ketsji/KX_PyConstraintBinding.cpp | 36 ++++++++-------- source/gameengine/Ketsji/KX_PythonInit.cpp | 3 +- source/gameengine/Ketsji/KX_VehicleWrapper.cpp | 27 ++++-------- 20 files changed, 100 insertions(+), 212 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 2ee8b54a014..d8b2e063a9d 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -484,17 +484,10 @@ char BL_ActionActuator::GetAction_doc[] = PyObject* BL_ActionActuator::PyGetAction(PyObject* self, PyObject* args, PyObject* kwds) { - PyObject *result; - if (m_action){ - result = Py_BuildValue("s", m_action->id.name+2); - } - else{ - Py_INCREF(Py_None); - result = Py_None; + return PyString_FromString(m_action->id.name+2); } - - return result; + Py_RETURN_NONE; } /* getProperty */ @@ -640,8 +633,7 @@ PyObject* BL_ActionActuator::PySetAction(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setStart */ @@ -662,8 +654,7 @@ PyObject* BL_ActionActuator::PySetStart(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setEnd */ @@ -684,8 +675,7 @@ PyObject* BL_ActionActuator::PySetEnd(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setBlendin */ @@ -707,8 +697,7 @@ PyObject* BL_ActionActuator::PySetBlendin(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setBlendtime */ @@ -735,8 +724,7 @@ PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setPriority */ @@ -759,8 +747,7 @@ PyObject* BL_ActionActuator::PySetPriority(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setFrame */ @@ -785,8 +772,7 @@ PyObject* BL_ActionActuator::PySetFrame(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setProperty */ @@ -808,8 +794,7 @@ PyObject* BL_ActionActuator::PySetProperty(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setFrameProperty */ @@ -830,8 +815,7 @@ PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* @@ -848,8 +832,7 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self, return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } */ @@ -934,8 +917,7 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self, } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* getType */ diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 242d648b062..942e3b502e0 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -464,17 +464,10 @@ char BL_ShapeActionActuator::GetAction_doc[] = "\tReturns a string containing the name of the current action.\n"; PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) { - PyObject *result; - if (m_action){ - result = Py_BuildValue("s", m_action->id.name+2); - } - else{ - Py_INCREF(Py_None); - result = Py_None; + return PyString_FromString(m_action->id.name+2); } - - return result; + Py_RETURN_NONE; } /* getProperty */ @@ -591,12 +584,10 @@ PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self, } } else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setStart */ @@ -614,12 +605,10 @@ PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self, m_startframe = start; } else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setEnd */ @@ -637,12 +626,10 @@ PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self, m_endframe = end; } else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setBlendin */ @@ -661,12 +648,10 @@ PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self, m_blendin = blendin; } else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setBlendtime */ @@ -690,12 +675,10 @@ PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self, m_blendframe = m_blendin; } else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setPriority */ @@ -715,12 +698,10 @@ PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, m_priority = priority; } else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setFrame */ @@ -742,12 +723,10 @@ PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self, m_localtime=m_endframe; } else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* setProperty */ @@ -766,12 +745,10 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, m_propname = string; } else { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* getType */ @@ -793,7 +770,6 @@ PyObject* BL_ShapeActionActuator::PySetType(PyObject* self, short typeArg; if (!PyArg_ParseTuple(args, "h", &typeArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp index 24033dd21a2..32a9de32e21 100644 --- a/source/gameengine/Expressions/InputParser.cpp +++ b/source/gameengine/Expressions/InputParser.cpp @@ -631,7 +631,8 @@ void CParser::SetContext(CValue* context) PyObject* CParserPyMake(PyObject* ignored,PyObject* args) { char* txt; - Py_Try(PyArg_ParseTuple(args,"s",&txt)); + if (!PyArg_ParseTuple(args,"s",&txt)) + return NULL; CParser parser; CExpression* expr = parser.ProcessText(txt); CValue* val = expr->Calculate(); @@ -641,7 +642,7 @@ PyObject* CParserPyMake(PyObject* ignored,PyObject* args) static PyMethodDef CParserMethods[] = { - { "calc", CParserPyMake , Py_NEWARGS}, + { "calc", CParserPyMake , METH_VARARGS}, { NULL,NULL} // Sentinel }; diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index bbf58a8a06e..9ffdbb1223c 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -43,7 +43,7 @@ PyObject* listvalue_buffer_item(PyObject* list,Py_ssize_t index) return ((CListValue*) list)->GetValue(index)->AddRef(); } - Py_Error(PyExc_IndexError, "Python ListIndex out of range"); + PyErr_SetString(PyExc_IndexError, "Python ListIndex out of range"); return NULL; } @@ -130,9 +130,10 @@ listvalue_buffer_concat(PyObject * self, PyObject * other) } } - if (error) - Py_Error(PyExc_SystemError, "Python Error: couldn't add one or more items to a list"); - + if (error) { + PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add one or more items to a list"); + return NULL; + } } else { @@ -155,8 +156,8 @@ listvalue_buffer_concat(PyObject * self, PyObject * other) listval->Add(objval); } else { - Py_Error(PyExc_SystemError, "Python Error: couldn't add item to a list"); - // bad luck + PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add item to a list"); + return NULL; } } } diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index aabcd6cb71d..8937f481922 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -94,7 +94,7 @@ PyObjectPlus::PyObjectPlus(PyTypeObject *T) // constructor * PyObjectPlus Methods -- Every class, even the abstract one should have a Methods ------------------------------*/ PyMethodDef PyObjectPlus::Methods[] = { - {"isA", (PyCFunction) sPy_isA, Py_NEWARGS}, + {"isA", (PyCFunction) sPy_isA, METH_VARARGS}, {NULL, NULL} /* Sentinel */ }; @@ -134,7 +134,8 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value) ------------------------------*/ PyObject *PyObjectPlus::_repr(void) { - Py_Error(PyExc_SystemError, "Representation not overridden by object."); + PyErr_SetString(PyExc_SystemError, "Representation not overridden by object."); + return NULL; } /*------------------------------ @@ -164,11 +165,12 @@ bool PyObjectPlus::isA(const char *mytypename) // check typename of each parent PyObject *PyObjectPlus::Py_isA(PyObject *args) // Python wrapper for isA { char *mytypename; - Py_Try(PyArg_ParseTuple(args, "s", &mytypename)); + if (!PyArg_ParseTuple(args, "s", &mytypename)) + return NULL; if(isA(mytypename)) - {Py_INCREF(Py_True); return Py_True;} + Py_RETURN_TRUE; else - {Py_INCREF(Py_False); return Py_False;}; + Py_RETURN_FALSE; } #endif //NO_EXP_PYTHON_EMBEDDING diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 2bcb604dd23..595940274c4 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -44,22 +44,7 @@ ------------------------------*/ // some basic python macros -#define Py_NEWARGS 1 #define Py_Return { Py_INCREF(Py_None); return Py_None;} -static inline PyObject* Py_Success(bool truth) -{ - if (truth) - { - Py_INCREF(Py_True); - return Py_True; - } - Py_INCREF(Py_False); - return Py_False; -} - -#define Py_Error(E, M) {PyErr_SetString(E, M); return NULL;} -#define Py_Try(F) {if (!(F)) return NULL;} -#define Py_Assert(A,E,M) {if (!(A)) {PyErr_SetString(E, M); return NULL;}} static inline void Py_Fatal(char *M) { //cout << M << endl; diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index b4694740679..7bcb45228db 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -158,15 +158,14 @@ PyParentObject CValue::Parents[] = { }; PyMethodDef CValue::Methods[] = { -// { "printHello", (PyCFunction) CValue::sPyPrintHello, Py_NEWARGS}, - { "getName", (PyCFunction) CValue::sPyGetName, Py_NEWARGS}, +// { "printHello", (PyCFunction) CValue::sPyPrintHello, METH_VARARGS}, + { "getName", (PyCFunction) CValue::sPyGetName, METH_NOARGS}, {NULL,NULL} //Sentinel }; -PyObject* CValue::PyGetName(PyObject* self,PyObject* args,PyObject* kwds) +PyObject* CValue::PyGetName(PyObject* self) { - PyObject* pyname = PyString_FromString(this->GetName()); - return pyname; + return PyString_FromString(this->GetName()); } /*#define CVALUE_DEBUG*/ @@ -662,7 +661,7 @@ CValue* CValue::FindIdentifier(const STR_String& identifiername) static PyMethodDef CValueMethods[] = { - //{ "new", CValue::PyMake , Py_NEWARGS}, + //{ "new", CValue::PyMake , METH_VARARGS}, { NULL,NULL} // Sentinel }; @@ -806,9 +805,8 @@ PyObject* CValue::ConvertKeysToPython( void ) PyObject* CValue::PyMake(PyObject* ignored,PyObject* args) { - //Py_Try(PyArg_ParseTuple(args,"s",&name)); - Py_INCREF(Py_None); - return Py_None;//new CValue(); + //if (!PyArg_ParseTuple(args,"s",&name)) return NULL; + Py_RETURN_NONE;//new CValue(); } */ diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h index bcf231cf4f0..74fcdae5756 100644 --- a/source/gameengine/Expressions/Value.h +++ b/source/gameengine/Expressions/Value.h @@ -255,7 +255,7 @@ public: virtual PyObject* ConvertKeysToPython( void ); - KX_PYMETHOD(CValue,GetName); + KX_PYMETHOD_NOARGS(CValue,GetName); #else CValue(); diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index 099cb8eebd0..44a488fa719 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -180,7 +180,6 @@ PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyOb char *actNameArg = NULL; if (!PyArg_ParseTuple(args, "s", &actNameArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index e73358bc1e8..f5512664d8f 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -271,8 +271,7 @@ PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self) } printf("ERROR: Python scriptblock without owner\n"); - Py_INCREF(Py_None); - return Py_None;//Int_FromLong(IsPositiveTrigger()); + Py_RETURN_NONE; //Int_FromLong(IsPositiveTrigger()); } diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index f6f9a29b0e2..57d0fe4140f 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -846,8 +846,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" ) KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if(mShader==0) { PyErr_Format(PyExc_TypeError, "invalid shader object"); @@ -877,8 +876,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()") KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" ) { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; @@ -900,7 +898,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" ) //else // spit("Invalid texture sample index: " << index); } - Py_Return; + Py_RETURN_NONE; } return NULL; } @@ -919,8 +917,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setNumberOfPasses, "setNumberOfPasses( max-pass ) KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" ) { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; @@ -945,8 +942,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" ) KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; float array[2]={ 0,0 }; @@ -970,8 +966,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)") KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; float array[3]={0,0,0}; @@ -996,8 +991,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ") KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) ") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; float array[4]={0,0,0,0}; @@ -1021,8 +1015,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) " KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" ) { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; int value=0; @@ -1046,8 +1039,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" ) KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; int array[2]={ 0,0 }; @@ -1071,8 +1063,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)") KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; @@ -1096,8 +1087,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ") KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) ") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; int array[4]={0,0,0, 0}; @@ -1120,8 +1110,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) " KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char*uniform = ""; PyObject *listPtr =0; @@ -1190,8 +1179,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or lis KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( int (list2 or list3 or list4) )") { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char*uniform = ""; PyObject *listPtr =0; @@ -1263,8 +1251,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4, "setUniformMatrix4(uniform-name, mat-4x4, transpose(row-major=true, col-major=false)" ) { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } float matr[16] = { @@ -1306,8 +1293,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3, "setUniformMatrix3(uniform-name, list[3x3], transpose(row-major=true, col-major=false)" ) { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } float matr[9] = { @@ -1347,8 +1333,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3, KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } int attr=0; if(PyArg_ParseTuple(args, "i", &attr )) { @@ -1368,8 +1353,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" ) KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" ) { if(mError) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } char *uniform=""; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 2401d69d3a3..e00ec68ad33 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -476,7 +476,6 @@ PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self, PyObject* kwds) { int dampArg; if(!PyArg_ParseTuple(args, "i", &dampArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -504,7 +503,6 @@ PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* self, PyObject* kwds) { int dampArg; if(!PyArg_ParseTuple(args, "i", &dampArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -534,7 +532,6 @@ PyObject* KX_ConstraintActuator::PySetDirection(PyObject* self, MT_Vector3 dir; if(!PyArg_ParseTuple(args, "(fff)", &x, &y, &z)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } dir[0] = x; @@ -577,7 +574,6 @@ PyObject* KX_ConstraintActuator::PySetOption(PyObject* self, PyObject* kwds) { int option; if(!PyArg_ParseTuple(args, "i", &option)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -605,7 +601,6 @@ PyObject* KX_ConstraintActuator::PySetTime(PyObject* self, PyObject* kwds) { int t; if(!PyArg_ParseTuple(args, "i", &t)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -634,7 +629,6 @@ PyObject* KX_ConstraintActuator::PySetProperty(PyObject* self, PyObject* kwds) { char *property; if (!PyArg_ParseTuple(args, "s", &property)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } if (property == NULL) { @@ -670,7 +664,6 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self, PyObject* kwds) { float minArg; if(!PyArg_ParseTuple(args, "f", &minArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -716,7 +709,6 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self, PyObject* kwds){ float maxArg; if(!PyArg_ParseTuple(args, "f", &maxArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -770,7 +762,6 @@ PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self, PyObject* kwds) { int locrotArg; if(!PyArg_ParseTuple(args, "i", &locrotArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index 987125ca9ba..b54da6eb753 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -53,8 +53,7 @@ PyObject* KX_ConstraintWrapper::PyTestMethod(PyObject* self, PyObject* kwds) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* self, diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index af3add8a323..a203ea6a6ff 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -480,7 +480,6 @@ PyObject* KX_IpoActuator::PySet(PyObject* self, int startFrame, stopFrame; if(!PyArg_ParseTuple(args, "siii", &mode, &startFrame, &stopFrame, &forceToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } modenum = string2mode(mode); @@ -516,7 +515,6 @@ PyObject* KX_IpoActuator::PySetProperty(PyObject* self, /* args: property */ char *propertyName; if(!PyArg_ParseTuple(args, "s", &propertyName)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -535,7 +533,6 @@ PyObject* KX_IpoActuator::PySetStart(PyObject* self, PyObject* kwds) { float startArg; if(!PyArg_ParseTuple(args, "f", &startArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -561,7 +558,6 @@ PyObject* KX_IpoActuator::PySetEnd(PyObject* self, PyObject* kwds) { float endArg; if(!PyArg_ParseTuple(args, "f", &endArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -588,7 +584,6 @@ PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self, int boolArg; if (!PyArg_ParseTuple(args, "i", &boolArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -617,7 +612,6 @@ PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self, int boolArg; if (!PyArg_ParseTuple(args, "i", &boolArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -646,7 +640,6 @@ PyObject* KX_IpoActuator::PySetType(PyObject* self, int typeArg; if (!PyArg_ParseTuple(args, "i", &typeArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } @@ -678,7 +671,6 @@ PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* self, int boolArg; if (!PyArg_ParseTuple(args, "i", &boolArg)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index c7a251751cd..7bffb5ac854 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -238,5 +238,5 @@ KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh, "Reinstance the physics mesh.") { //this needs to be reviewed, it is dependend on Sumo/Solid. Who is using this ? - return Py_None;//Py_Success(KX_ReInstanceShapeFromMesh(m_meshobj)); + return Py_None;//(KX_ReInstanceShapeFromMesh(m_meshobj)) ? Py_RETURN_TRUE : Py_RETURN_FALSE; } diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 5cd4d089c14..98e73d4f0d7 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -360,7 +360,6 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_force.setValue(vecArg); @@ -390,7 +389,6 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_torque.setValue(vecArg); @@ -420,7 +418,6 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* self, int bToggle = 0; if(!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_dloc.setValue(vecArg); @@ -450,7 +447,6 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_drot.setValue(vecArg); @@ -479,7 +475,6 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_linear_velocity.setValue(vecArg); @@ -508,7 +503,6 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* self, int bToggle = 0; if (!PyArg_ParseTuple(args, "fffi", &vecArg[0], &vecArg[1], &vecArg[2], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_angular_velocity.setValue(vecArg); @@ -523,7 +517,6 @@ PyObject* KX_ObjectActuator::PySetDamping(PyObject* self, PyObject* kwds) { int damping = 0; if (!PyArg_ParseTuple(args, "i", &damping) || damping < 0 || damping > 1000) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_damping = damping; @@ -553,7 +546,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* self, float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_drot[0] = vecArg[0]; @@ -581,7 +573,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* self, float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_drot[1] = vecArg[0]; @@ -609,7 +600,6 @@ PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* self, float vecArg[2]; int bToggle = 0; if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_drot[2] = vecArg[0]; @@ -636,7 +626,6 @@ PyObject* KX_ObjectActuator::PySetPID(PyObject* self, { float vecArg[3]; if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2])) { - PyErr_SetString(PyExc_TypeError, "Invalid arguments"); return NULL; } m_torque.setValue(vecArg); diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index 2df4c6a9980..9291199d859 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -61,7 +61,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -78,7 +78,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self, @@ -94,7 +94,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self, @@ -109,7 +109,7 @@ PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index c01d6a632a3..26243c7dba1 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -91,7 +91,7 @@ static PyObject* gPySetGravity(PyObject* self, return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } static PyObject* gPySetDebugMode(PyObject* self, @@ -112,7 +112,7 @@ static PyObject* gPySetDebugMode(PyObject* self, return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -132,7 +132,7 @@ static PyObject* gPySetNumTimeSubSteps(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -151,7 +151,7 @@ static PyObject* gPySetNumIterations(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -171,7 +171,7 @@ static PyObject* gPySetDeactivationTime(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -190,7 +190,7 @@ static PyObject* gPySetDeactivationLinearTreshold(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -209,7 +209,7 @@ static PyObject* gPySetDeactivationAngularTreshold(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } static PyObject* gPySetContactBreakingTreshold(PyObject* self, @@ -227,7 +227,7 @@ static PyObject* gPySetContactBreakingTreshold(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -246,7 +246,7 @@ static PyObject* gPySetCcdMode(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } static PyObject* gPySetSorConstant(PyObject* self, @@ -264,7 +264,7 @@ static PyObject* gPySetSorConstant(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } static PyObject* gPySetSolverTau(PyObject* self, @@ -282,7 +282,7 @@ static PyObject* gPySetSolverTau(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -301,7 +301,7 @@ static PyObject* gPySetSolverDamping(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } static PyObject* gPySetLinearAirDamping(PyObject* self, @@ -319,7 +319,7 @@ static PyObject* gPySetLinearAirDamping(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -338,7 +338,7 @@ static PyObject* gPySetUseEpa(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } static PyObject* gPySetSolverType(PyObject* self, PyObject* args, @@ -355,7 +355,7 @@ static PyObject* gPySetSolverType(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -388,7 +388,7 @@ static PyObject* gPyGetVehicleConstraint(PyObject* self, return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -448,7 +448,7 @@ static PyObject* gPyCreateConstraint(PyObject* self, return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } @@ -502,7 +502,7 @@ static PyObject* gPyRemoveConstraint(PyObject* self, return NULL; } - Py_INCREF(Py_None); return Py_None; + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index db4793de23d..868439546c3 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -355,8 +355,7 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) if(!count) pprint("No extenstions are used in this build"); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index 7e8160a4d67..f5a2b5e02fe 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -71,8 +71,7 @@ PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* self, } else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -157,8 +156,7 @@ PyObject* KX_VehicleWrapper::PyApplyEngineForce(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self, @@ -175,8 +173,7 @@ PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self, @@ -193,8 +190,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self, @@ -210,8 +206,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self, } else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self, @@ -227,8 +222,7 @@ PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self, } else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self, @@ -245,8 +239,7 @@ PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -264,8 +257,7 @@ PyObject* KX_VehicleWrapper::PyApplyBraking(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -285,8 +277,7 @@ PyObject* KX_VehicleWrapper::PySetSteeringValue(PyObject* self, else { return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -- cgit v1.2.3 From 29668ba2d03b7c81e12331d86adee4034991725a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Aug 2008 05:06:59 +0000 Subject: bugfix (good for 2.47) - 2 cases of returning Py_None without increfing it. this can crash blender. --- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- source/gameengine/Ketsji/KX_MeshProxy.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 989cdabd491..ed05cd98ed0 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -942,7 +942,7 @@ PyObject* KX_GameObject::PyEndObject(PyObject* self) KX_Scene *scene = PHY_GetActiveScene(); scene->DelayedRemoveObject(this); - return Py_None; + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 7bffb5ac854..a0ac9cfd4ff 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -238,5 +238,5 @@ KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh, "Reinstance the physics mesh.") { //this needs to be reviewed, it is dependend on Sumo/Solid. Who is using this ? - return Py_None;//(KX_ReInstanceShapeFromMesh(m_meshobj)) ? Py_RETURN_TRUE : Py_RETURN_FALSE; + Py_RETURN_NONE;//(KX_ReInstanceShapeFromMesh(m_meshobj)) ? Py_RETURN_TRUE : Py_RETURN_FALSE; } -- cgit v1.2.3 From 47c2271d673173ee93b9d91926de9ea41415d411 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Aug 2008 08:58:25 +0000 Subject: Python API get/setObject update for Actuators. (SetParent, AddObject, Camera and TrackTo) * bugfix for BGE python api - SetParent actuator getObject would segfault if the object was not set. * Added utility function ConvertPythonToGameObject() that can take a GameObject, string or None and set the game object from this since it was being done in a number of places. * allow setObject(None), since no object is valid for actuators, Python should be able to set this. * added optional argument for getObject() so it returns the KX_GameObject rather then its name, would prefer this be default but it could break existing games. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 13 +++- source/gameengine/Expressions/PyObjectPlus.h | 7 ++ source/gameengine/Ketsji/KX_CameraActuator.cpp | 67 ++++++++--------- source/gameengine/Ketsji/KX_CameraActuator.h | 4 +- source/gameengine/Ketsji/KX_GameObject.cpp | 84 ++++++++++++++++++---- source/gameengine/Ketsji/KX_GameObject.h | 4 ++ source/gameengine/Ketsji/KX_ParentActuator.cpp | 68 +++++++++--------- source/gameengine/Ketsji/KX_ParentActuator.h | 4 +- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 71 ++++++++---------- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.h | 4 +- source/gameengine/Ketsji/KX_TrackToActuator.cpp | 60 ++++++++-------- source/gameengine/Ketsji/KX_TrackToActuator.h | 4 +- source/gameengine/PyDoc/KX_CameraActuator.py | 8 ++- source/gameengine/PyDoc/KX_ParentActuator.py | 9 +-- .../gameengine/PyDoc/KX_SCA_AddObjectActuator.py | 13 ++-- source/gameengine/PyDoc/KX_TrackToActuator.py | 8 +-- 16 files changed, 242 insertions(+), 186 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 53ac730d203..cb2521de9a4 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -540,9 +540,16 @@ void BL_ConvertActuators(char* maggiename, // does the 'original' for replication exists, and // is it in a non-active layer ? SCA_IObject* originalval = NULL; - if (editobact->ob && !(editobact->ob->lay & activeLayerBitInfo)) - originalval = converter->FindGameObject(editobact->ob); - + if (editobact->ob) + { + if (editobact->ob->lay & activeLayerBitInfo) + { + fprintf(stderr, "Warning, object \"%s\" from AddObject actuator \"%s\" is not in a hidden layer.\n", objectname.Ptr(), uniquename.Ptr()); + } + else { + originalval = converter->FindGameObject(editobact->ob); + } + } MT_Vector3 linvelvec ( KX_BLENDERTRUNC(editobact->linVelocity[0]), KX_BLENDERTRUNC(editobact->linVelocity[1]), KX_BLENDERTRUNC(editobact->linVelocity[2])); diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 595940274c4..f433a08faba 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -121,6 +121,13 @@ static inline void Py_Fatal(char *M) { }; \ static char method_name##_doc[]; \ +#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \ + PyObject* Py##method_name(PyObject* self, PyObject* args); \ + static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \ + return ((class_name*) self)->Py##method_name(self, args); \ + }; \ + static char method_name##_doc[]; \ + #define KX_PYMETHOD_DOC_O(class_name, method_name) \ PyObject* Py##method_name(PyObject* self, PyObject* value); \ static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \ diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 0a97b6f0a2f..42b909927fd 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -395,8 +395,8 @@ PyParentObject KX_CameraActuator::Parents[] = { }; PyMethodDef KX_CameraActuator::Methods[] = { - {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_VARARGS, SetObject_doc}, - {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_NOARGS, GetObject_doc}, + {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, SetObject_doc}, + {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, SetMin_doc}, {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, GetMin_doc}, {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, SetMax_doc}, @@ -413,50 +413,43 @@ PyObject* KX_CameraActuator::_getattr(const STR_String& attr) { } /* get obj ---------------------------------------------------------- */ char KX_CameraActuator::GetObject_doc[] = -"getObject\n" +"getObject(name_only = 1)\n" +"name_only - optional arg, when true will return the KX_GameObject rather then its name\n" "\tReturns the object this sensor reacts to.\n"; -PyObject* KX_CameraActuator::PyGetObject(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* args) { - return PyString_FromString(m_ob->GetName()); + int ret_name_only = 1; + if (!PyArg_ParseTuple(args, "|i", &ret_name_only)) + return NULL; + + if (!m_ob) + Py_RETURN_NONE; + + if (ret_name_only) + return PyString_FromString(m_ob->GetName()); + else + return m_ob->AddRef(); } /* set obj ---------------------------------------------------------- */ char KX_CameraActuator::SetObject_doc[] = -"setObject\n" +"setObject(object)\n" +"\t- object: KX_GameObject, string or None\n" "\tSets the object this sensor reacts to.\n"; -PyObject* KX_CameraActuator::PySetObject(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* value) { - - PyObject* gameobj; - if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) - { - if (m_ob) - m_ob->UnregisterActuator(this); - m_ob = (SCA_IObject*)gameobj; - if (m_ob) - m_ob->RegisterActuator(this); - Py_Return; - } - PyErr_Clear(); + KX_GameObject *gameobj; - char* objectname; - if (PyArg_ParseTuple(args, "s", &objectname)) - { - SCA_IObject *object = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)); - if(object) - { - if (m_ob != NULL) - m_ob->UnregisterActuator(this); - m_ob = object; - m_ob->RegisterActuator(this); - Py_Return; - } - } + if (!ConvertPythonToGameObject(value, &gameobj, true)) + return NULL; // ConvertPythonToGameObject sets the error - return NULL; + if (m_ob != NULL) + m_ob->UnregisterActuator(this); + + m_ob = (SCA_IObject*)gameobj; + if (m_ob) + m_ob->RegisterActuator(this); + + Py_RETURN_NONE; } /* get min ---------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h index 488b36922b0..d53d12b3b82 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.h +++ b/source/gameengine/Ketsji/KX_CameraActuator.h @@ -123,9 +123,9 @@ private : virtual PyObject* _getattr(const STR_String& attr); /* set object to look at */ - KX_PYMETHOD_DOC(KX_CameraActuator,SetObject); + KX_PYMETHOD_DOC_O(KX_CameraActuator,SetObject); /* get current object */ - KX_PYMETHOD_DOC(KX_CameraActuator,GetObject); + KX_PYMETHOD_DOC_VARARGS(KX_CameraActuator,GetObject); KX_PYMETHOD_DOC(KX_CameraActuator,SetMin); KX_PYMETHOD_DOC(KX_CameraActuator,GetMin); KX_PYMETHOD_DOC(KX_CameraActuator,SetMax); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index ed05cd98ed0..700cc00e996 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1551,9 +1551,9 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo, PyErr_Clear(); PyObject *pyother; - if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &pyother)) + KX_GameObject *other; + if (PyArg_ParseTuple(args, "O", &pyother) && ConvertPythonToGameObject(pyother, &other, false)) { - KX_GameObject *other = static_cast(pyother); return PyFloat_FromDouble(NodeGetWorldPosition().distance(other->NodeGetWorldPosition())); } @@ -1574,11 +1574,12 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo, if (!PyVecArgTo(args, toPoint)) { PyErr_Clear(); - if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &pyother)) + + KX_GameObject *other; + if (PyArg_ParseTuple(args, "O", &pyother) && ConvertPythonToGameObject(pyother, &other, false)) { - KX_GameObject *other = static_cast(pyother); toPoint = other->NodeGetWorldPosition(); - }else + } else { PyErr_SetString(PyExc_TypeError, "Expected a 3D Vector or GameObject type"); return NULL; @@ -1648,12 +1649,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, { KX_GameObject *other; PyErr_Clear(); - if (!PyType_IsSubtype(pyarg->ob_type, &KX_GameObject::Type)) { + + if (ConvertPythonToGameObject(pyarg, &other, false)) + { + toPoint = other->NodeGetWorldPosition(); + } else + { PyErr_SetString(PyExc_TypeError, "the first argument to rayCastTo must be a vector or a KX_GameObject"); return NULL; } - other = static_cast(pyarg); - toPoint = other->NodeGetWorldPosition(); } MT_Point3 fromPoint = NodeGetWorldPosition(); if (dist != 0.0f) @@ -1712,12 +1716,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, if (!PyVecTo(pyto, toPoint)) { PyErr_Clear(); - if (!PyType_IsSubtype(pyto->ob_type, &KX_GameObject::Type)) { + + if (ConvertPythonToGameObject(pyto, &other, false)) + { + toPoint = other->NodeGetWorldPosition(); + } else + { PyErr_SetString(PyExc_TypeError, "the first argument to rayCast must be a vector or a KX_GameObject"); return NULL; } - other = static_cast(pyto); - toPoint = other->NodeGetWorldPosition(); } if (!pyfrom || pyfrom == Py_None) { @@ -1726,12 +1733,15 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, else if (!PyVecTo(pyfrom, fromPoint)) { PyErr_Clear(); - if (!PyType_IsSubtype(pyfrom->ob_type, &KX_GameObject::Type)) { + + if (ConvertPythonToGameObject(pyfrom, &other, false)) + { + fromPoint = other->NodeGetWorldPosition(); + } else + { PyErr_SetString(PyExc_TypeError, "the second optional argument to rayCast must be a vector or a KX_GameObject"); return NULL; } - other = static_cast(pyfrom); - fromPoint = other->NodeGetWorldPosition(); } if (dist != 0.0f) { @@ -1798,3 +1808,49 @@ void KX_GameObject::Relink(GEN_Map *map_parameter) } } +bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok) +{ + if (value==NULL) { + PyErr_SetString(PyExc_TypeError, "Error in ConvertPythonToGameObject, python pointer NULL, should never happen"); + *object = NULL; + return false; + } + + if (value==Py_None) { + *object = NULL; + + if (py_none_ok) { + return true; + } else { + PyErr_SetString(PyExc_TypeError, "Expected KX_GameObject or a string for a name of a KX_GameObject, None is invalid"); + return false; + } + return (py_none_ok ? true : false); + } + + if (PyString_Check(value)) { + *object = (KX_GameObject *)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( PyString_AsString(value) )); + + if (*object) { + return true; + } else { + PyErr_SetString(PyExc_ValueError, "Requested name did not match any KX_GameObject"); + return false; + } + } + + if (PyObject_TypeCheck(value, &KX_GameObject::Type)) { + *object = static_cast(value); + return true; + } + + *object = NULL; + + if (py_none_ok) { + PyErr_SetString(PyExc_TypeError, "Expect a KX_GameObject, a string or None"); + } else { + PyErr_SetString(PyExc_TypeError, "Expect a KX_GameObject or a string"); + } + + return false; +} diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 4e435e9ddf4..a7ac2d75a93 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -48,6 +48,7 @@ #include "KX_KetsjiEngine.h" /* for m_anim_framerate */ #include "KX_IPhysicsController.h" /* for suspend/resume */ #include "DNA_object_types.h" +#include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */ #define KX_OB_DYNAMIC 1 @@ -775,5 +776,8 @@ private : }; +/* utility conversion function */ +bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok); + #endif //__KX_GAMEOBJECT diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index fd1b56838e2..344e0fccc35 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -164,7 +164,7 @@ PyParentObject KX_ParentActuator::Parents[] = { }; PyMethodDef KX_ParentActuator::Methods[] = { - {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_VARARGS, SetObject_doc}, + {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_O, SetObject_doc}, {"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, {NULL,NULL} //Sentinel }; @@ -176,44 +176,44 @@ PyObject* KX_ParentActuator::_getattr(const STR_String& attr) { /* 1. setObject */ char KX_ParentActuator::SetObject_doc[] = "setObject(object)\n" -"\tSet the object to set as parent.\n" -"\tCan be an object name or an object\n"; -PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* args, PyObject* kwds) { - PyObject* gameobj; - if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) - { - if (m_ob != NULL) - m_ob->UnregisterActuator(this); - m_ob = (SCA_IObject*)gameobj; - if (m_ob) - m_ob->RegisterActuator(this); - Py_Return; - } - PyErr_Clear(); +"\t- object: KX_GameObject, string or None\n" +"\tSet the object to set as parent.\n"; +PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* value) { + KX_GameObject *gameobj; - char* objectname; - if (PyArg_ParseTuple(args, "s", &objectname)) - { - SCA_IObject *object = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)); - if(object) - { - if (m_ob != NULL) - m_ob->UnregisterActuator(this); - m_ob = object; - m_ob->RegisterActuator(this); - Py_Return; - } - } + if (!ConvertPythonToGameObject(value, &gameobj, true)) + return NULL; // ConvertPythonToGameObject sets the error + + if (m_ob != NULL) + m_ob->UnregisterActuator(this); + + m_ob = (SCA_IObject*)gameobj; + if (m_ob) + m_ob->RegisterActuator(this); - return NULL; + Py_RETURN_NONE; } /* 2. getObject */ -char KX_ParentActuator::GetObject_doc[] = -"getObject()\n" + +/* get obj ---------------------------------------------------------- */ +char KX_ParentActuator::GetObject_doc[] = +"getObject(name_only = 1)\n" +"name_only - optional arg, when true will return the KX_GameObject rather then its name\n" "\tReturns the object that is set to.\n"; -PyObject* KX_ParentActuator::PyGetObject(PyObject* self, PyObject* args, PyObject* kwds) { - return PyString_FromString(m_ob->GetName()); -} +PyObject* KX_ParentActuator::PyGetObject(PyObject* self, PyObject* args) +{ + int ret_name_only = 1; + if (!PyArg_ParseTuple(args, "|i", &ret_name_only)) + return NULL; + + if (!m_ob) + Py_RETURN_NONE; + if (ret_name_only) + return PyString_FromString(m_ob->GetName()); + else + return m_ob->AddRef(); +} + /* eof */ diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h index 93b07cd424b..e2b30ba2d0f 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.h +++ b/source/gameengine/Ketsji/KX_ParentActuator.h @@ -79,9 +79,9 @@ class KX_ParentActuator : public SCA_IActuator virtual PyObject* _getattr(const STR_String& attr); /* 1. setObject */ - KX_PYMETHOD_DOC(KX_ParentActuator,SetObject); + KX_PYMETHOD_DOC_O(KX_ParentActuator,SetObject); /* 2. getObject */ - KX_PYMETHOD_DOC(KX_ParentActuator,GetObject); + KX_PYMETHOD_DOC_VARARGS(KX_ParentActuator,GetObject); }; /* end of class KX_ParentActuator : public SCA_PropertyActuator */ diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index e36891b56f4..ca0106d64d9 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -180,7 +180,7 @@ PyParentObject KX_SCA_AddObjectActuator::Parents[] = { NULL }; PyMethodDef KX_SCA_AddObjectActuator::Methods[] = { - {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_VARARGS, SetObject_doc}, + {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, SetObject_doc}, {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_VARARGS, SetTime_doc}, {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_VARARGS, GetTime_doc}, @@ -200,41 +200,25 @@ PyObject* KX_SCA_AddObjectActuator::_getattr(const STR_String& attr) /* 1. setObject */ char KX_SCA_AddObjectActuator::SetObject_doc[] = -"setObject(name)\n" -"\t- name: string\n" +"setObject(object)\n" +"\t- object: KX_GameObject, string or None\n" "\tSets the object that will be added. There has to be an object\n" "\tof this name. If not, this function does nothing.\n"; - - - -PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self, - PyObject* args, - PyObject* kwds) -{ - PyObject* gameobj; - if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) - { - if (m_OriginalObject != NULL) - m_OriginalObject->UnregisterActuator(this); - m_OriginalObject = (SCA_IObject*)gameobj; - if (m_OriginalObject) - m_OriginalObject->RegisterActuator(this); - Py_Return; - } - PyErr_Clear(); +PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self, PyObject* value) +{ + KX_GameObject *gameobj; - char* objectname; - if (PyArg_ParseTuple(args, "s", &objectname)) - { - if (m_OriginalObject != NULL) - m_OriginalObject->UnregisterActuator(this); - m_OriginalObject = (SCA_IObject*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));; - if (m_OriginalObject) - m_OriginalObject->RegisterActuator(this); - Py_Return; - } + if (!ConvertPythonToGameObject(value, &gameobj, true)) + return NULL; // ConvertPythonToGameObject sets the error - return NULL; + if (m_OriginalObject != NULL) + m_OriginalObject->UnregisterActuator(this); + + m_OriginalObject = (SCA_IObject*)gameobj; + if (m_OriginalObject) + m_OriginalObject->RegisterActuator(this); + + Py_RETURN_NONE; } @@ -280,19 +264,22 @@ PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self, /* 4. getObject */ char KX_SCA_AddObjectActuator::GetObject_doc[] = -"getObject()\n" +"getObject(name_only = 1)\n" +"name_only - optional arg, when true will return the KX_GameObject rather then its name\n" "\tReturns the name of the object that will be added.\n"; - - - -PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* self, PyObject* args) { + int ret_name_only = 1; + if (!PyArg_ParseTuple(args, "|i", &ret_name_only)) + return NULL; + if (!m_OriginalObject) - Py_Return; - - return PyString_FromString(m_OriginalObject->GetName()); + Py_RETURN_NONE; + + if (ret_name_only) + return PyString_FromString(m_OriginalObject->GetName()); + else + return m_OriginalObject->AddRef(); } diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 1359f39278d..e7fdb2fbfbc 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -113,13 +113,13 @@ public: void InstantAddObject(); /* 1. setObject */ - KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetObject); + KX_PYMETHOD_DOC_O(KX_SCA_AddObjectActuator,SetObject); /* 2. setTime */ KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetTime); /* 3. getTime */ KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetTime); /* 4. getObject */ - KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetObject); + KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,GetObject); /* 5. getLinearVelocity */ KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetLinearVelocity); /* 6. setLinearVelocity */ diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index f5b463abf02..67937d5c579 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -454,7 +454,7 @@ PyParentObject KX_TrackToActuator::Parents[] = { PyMethodDef KX_TrackToActuator::Methods[] = { - {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_VARARGS, SetObject_doc}, + {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, SetObject_doc}, {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, SetTime_doc}, {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_VARARGS, GetTime_doc}, @@ -475,47 +475,45 @@ PyObject* KX_TrackToActuator::_getattr(const STR_String& attr) /* 1. setObject */ char KX_TrackToActuator::SetObject_doc[] = "setObject(object)\n" -"\t- object: string\n" +"\t- object: KX_GameObject, string or None\n" "\tSet the object to track with the parent of this actuator.\n"; -PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* args, PyObject* kwds) { - PyObject* gameobj; - if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj)) - { - if (m_object != NULL) - m_object->UnregisterActuator(this); - m_object = (SCA_IObject*)gameobj; - if (m_object) - m_object->RegisterActuator(this); - Py_Return; - } - PyErr_Clear(); +PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* value) +{ + KX_GameObject *gameobj; - char* objectname; - if (PyArg_ParseTuple(args, "s", &objectname)) - { - if (m_object != NULL) - m_object->UnregisterActuator(this); - m_object= static_cast(SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname))); - if (m_object) - m_object->RegisterActuator(this); - Py_Return; - } + if (!ConvertPythonToGameObject(value, &gameobj, true)) + return NULL; // ConvertPythonToGameObject sets the error - return NULL; + if (m_object != NULL) + m_object->UnregisterActuator(this); + + m_object = (SCA_IObject*)gameobj; + if (m_object) + m_object->RegisterActuator(this); + + Py_RETURN_NONE; } /* 2. getObject */ char KX_TrackToActuator::GetObject_doc[] = -"getObject()\n" -"\tReturns the object to track with the parent of this actuator.\n"; -PyObject* KX_TrackToActuator::PyGetObject(PyObject* self, PyObject* args, PyObject* kwds) +"getObject(name_only = 1)\n" +"name_only - optional arg, when true will return the KX_GameObject rather then its name\n" +"\tReturns the object to track with the parent of this actuator\n"; +PyObject* KX_TrackToActuator::PyGetObject(PyObject* self, PyObject* args) { + int ret_name_only = 1; + if (!PyArg_ParseTuple(args, "|i", &ret_name_only)) + return NULL; + if (!m_object) - Py_Return; - - return PyString_FromString(m_object->GetName()); + Py_RETURN_NONE; + + if (ret_name_only) + return PyString_FromString(m_object->GetName()); + else + return m_object->AddRef(); } diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index 1d1cf46d21b..445132a6094 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -75,9 +75,9 @@ class KX_TrackToActuator : public SCA_IActuator virtual PyObject* _getattr(const STR_String& attr); /* 1. setObject */ - KX_PYMETHOD_DOC(KX_TrackToActuator,SetObject); + KX_PYMETHOD_DOC_O(KX_TrackToActuator,SetObject); /* 2. getObject */ - KX_PYMETHOD_DOC(KX_TrackToActuator,GetObject); + KX_PYMETHOD_DOC_VARARGS(KX_TrackToActuator,GetObject); /* 3. setTime */ KX_PYMETHOD_DOC(KX_TrackToActuator,SetTime); /* 4. getTime */ diff --git a/source/gameengine/PyDoc/KX_CameraActuator.py b/source/gameengine/PyDoc/KX_CameraActuator.py index 032fc7338ac..9a9abaf3d57 100644 --- a/source/gameengine/PyDoc/KX_CameraActuator.py +++ b/source/gameengine/PyDoc/KX_CameraActuator.py @@ -8,11 +8,13 @@ class KX_CameraActuator(SCA_IActuator): @author: snail """ - def getObject(): + def getObject(name_only = 1): """ Returns the name of the object this actuator tracks. - rtype: string + @type name_only: bool + @param name_only: optional argument, when 0 return a KX_GameObject + @rtype: string, KX_GameObject or None if no object is set """ def setObject(target): @@ -20,7 +22,7 @@ class KX_CameraActuator(SCA_IActuator): Sets the object this actuator tracks. @param target: the object to track. - @type target: string or L{KX_GameObject} + @type target: L{KX_GameObject}, string or None """ def getMin(): diff --git a/source/gameengine/PyDoc/KX_ParentActuator.py b/source/gameengine/PyDoc/KX_ParentActuator.py index f45bb5d20b1..6d6e0937257 100644 --- a/source/gameengine/PyDoc/KX_ParentActuator.py +++ b/source/gameengine/PyDoc/KX_ParentActuator.py @@ -12,11 +12,12 @@ class KX_ParentActuator(SCA_IActuator): Object can be either a L{KX_GameObject} or the name of the object. - @type object: L{KX_GameObject} or string + @type object: L{KX_GameObject}, string or None """ - def getObject(): + def getObject(name_only = 1): """ Returns the name of the object to change to. - - @rtype: string + @type name_only: bool + @param name_only: optional argument, when 0 return a KX_GameObject + @rtype: string, KX_GameObject or None if no object is set """ diff --git a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py index 44f9e051c8c..4f2bf85bff3 100644 --- a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py +++ b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py @@ -13,7 +13,7 @@ class KX_SCA_AddObjectActuator(SCA_IActuator): C{ERROR: GameObject I{OBName} has a AddObjectActuator I{ActuatorName} without object (in 'nonactive' layer)} """ - def setObject(obj): + def setObject(object): """ Sets the game object to add. @@ -21,17 +21,18 @@ class KX_SCA_AddObjectActuator(SCA_IActuator): If the object does not exist, this function is ignored. - obj can either be a L{KX_GameObject} or the name of an object. + object can either be a L{KX_GameObject} or the name of an object or None. - @type obj: L{KX_GameObject} or string + @type object: L{KX_GameObject}, string or None """ - def getObject(): + def getObject(name_only = 0): """ Returns the name of the game object to be added. Returns None if no game object has been assigned to be added. - - @rtype: string + @type name_only: bool + @param name_only: optional argument, when 0 return a KX_GameObject + @rtype: string, KX_GameObject or None if no object is set """ def setTime(time): """ diff --git a/source/gameengine/PyDoc/KX_TrackToActuator.py b/source/gameengine/PyDoc/KX_TrackToActuator.py index 39fb99ec2e2..2ecd94f38ae 100644 --- a/source/gameengine/PyDoc/KX_TrackToActuator.py +++ b/source/gameengine/PyDoc/KX_TrackToActuator.py @@ -18,16 +18,16 @@ class KX_TrackToActuator(SCA_IActuator): """ Sets the object to track. - @type object: L{KX_GameObject} or string + @type object: L{KX_GameObject}, string or None @param object: Either a reference to a game object or the name of the object to track. """ def getObject(): """ Returns the name of the object to track. - Returns None if no object has been set to track. - - @rtype: string + @type name_only: bool + @param name_only: optional argument, when 0 return a KX_GameObject + @rtype: string, KX_GameObject or None if no object is set """ def setTime(time): """ -- cgit v1.2.3 From 528722f4726908ff47653b39a8a16589e5401003 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 15 Aug 2008 22:17:50 +0000 Subject: BGE bug fix: the fix in revision 16022 for bug #17450 was wrong: the formula used to extract scaling and rotation was giving incorrect results for some type of rotation, leading to wrong position and orientation for parented objects with no scale applied. The new formula follows Blender's internal math. --- .../Converter/BL_BlenderDataConversion.cpp | 39 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index a6337403cd1..edc14dabc70 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1946,10 +1946,22 @@ void BL_ConvertBlenderObjects(struct Main* maggie, //parentinversenode->SetLocalOrientation(parinvtrans.getBasis()); // Extract the rotation and the scaling from the basis - MT_Matrix3x3 inverseOrientation(parinvtrans.getRotation()); - parentinversenode->SetLocalOrientation(inverseOrientation); - MT_Matrix3x3 scale(inverseOrientation.transposed()*parinvtrans.getBasis()); - parentinversenode->SetLocalScale(MT_Vector3(scale[0][0], scale[1][1], scale[2][2])); + MT_Matrix3x3 ori(parinvtrans.getBasis()); + MT_Vector3 x(ori.getColumn(0)); + MT_Vector3 y(ori.getColumn(1)); + MT_Vector3 z(ori.getColumn(2)); + MT_Vector3 scale(x.length(), y.length(), z.length()); + if (!MT_fuzzyZero(scale[0])) + x /= scale[0]; + if (!MT_fuzzyZero(scale[1])) + y /= scale[1]; + if (!MT_fuzzyZero(scale[2])) + z /= scale[2]; + ori.setColumn(0, x); + ori.setColumn(1, y); + ori.setColumn(2, z); + parentinversenode->SetLocalOrientation(ori); + parentinversenode->SetLocalScale(scale); parentinversenode->AddChild(gameobj->GetSGNode()); } @@ -2129,7 +2141,24 @@ void BL_ConvertBlenderObjects(struct Main* maggie, float* fl = (float*) blenderobject->parentinv; MT_Transform parinvtrans(fl); parentinversenode->SetLocalPosition(parinvtrans.getOrigin()); - parentinversenode->SetLocalOrientation(parinvtrans.getBasis()); + + // Extract the rotation and the scaling from the basis + MT_Matrix3x3 ori(parinvtrans.getBasis()); + MT_Vector3 x(ori.getColumn(0)); + MT_Vector3 y(ori.getColumn(1)); + MT_Vector3 z(ori.getColumn(2)); + MT_Vector3 scale(x.length(), y.length(), z.length()); + if (!MT_fuzzyZero(scale[0])) + x /= scale[0]; + if (!MT_fuzzyZero(scale[1])) + y /= scale[1]; + if (!MT_fuzzyZero(scale[2])) + z /= scale[2]; + ori.setColumn(0, x); + ori.setColumn(1, y); + ori.setColumn(2, z); + parentinversenode->SetLocalOrientation(ori); + parentinversenode->SetLocalScale(scale); parentinversenode->AddChild(gameobj->GetSGNode()); } -- cgit v1.2.3 From 1ffede887211c748d4426d6e68f179dac5a5bcfd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Aug 2008 00:06:51 +0000 Subject: SCA_PythonController.cpp - Made errors in python print the controller name, useful when blender crashes on printing the python error which happens frequently. buttons_logic.c - NULL checks for game logic buttons, linking in groups with some logic links to objects outsude the group could crash blender. There are NULL checks for this case elsewhere so I assume it should be supported. CMakeLists.txt - remove YESIAMSTUPID option, is not used anymore. --- source/gameengine/GameLogic/SCA_PythonController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index cd1b029fc34..f9081c90288 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -248,7 +248,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) { // didn't compile, so instead of compile, complain // something is wrong, tell the user what went wrong - printf("PYTHON SCRIPT ERROR:\n"); + printf("Python compile error from controller \"%s\": \n", GetName().Ptr()); //PyRun_SimpleString(m_scriptText.Ptr()); PyErr_Print(); return; @@ -285,7 +285,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) else { // something is wrong, tell the user what went wrong - printf("PYTHON SCRIPT ERROR:\n"); + printf("Python script error from controller \"%s\": \n", GetName().Ptr()); PyErr_Print(); //PyRun_SimpleString(m_scriptText.Ptr()); } -- cgit v1.2.3 From a5d414c29855cc4f999b28781393bcee036950ff Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Aug 2008 12:42:34 +0000 Subject: warning message for when sensors loose their controllers, has been a problem recently with linking in groups that contain game logic. - also useful for testing bug [#17485] Sensors lost when loading objects from a group (apricot showstopper) --- source/gameengine/Converter/KX_ConvertSensors.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 5e433bb821b..76a12fb7f42 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -741,10 +741,24 @@ void BL_ConvertSensors(struct Object* blenderobject, for (int i=0;itotlinks;i++) { bController* linkedcont = (bController*) sens->links[i]; - SCA_IController* gamecont = converter->FindGameController(linkedcont); + if (linkedcont) { + SCA_IController* gamecont = converter->FindGameController(linkedcont); - if (gamecont) { - logicmgr->RegisterToSensor(gamecont,gamesensor); + if (gamecont) { + logicmgr->RegisterToSensor(gamecont,gamesensor); + } else { + printf( + "Warning, sensor \"%s\" could not find its controller" + "(link %d of %d)\n" + "\tthere has been an error converting the blender controller for the game engine," + "logic may be incorrect\n", sens->name, i+1, sens->totlinks); + } + } else { + printf( + "Warning, sensor \"%s\" has lost a link to a controller" + "(link %d of %d)\n" + "\tpossible causes are partially appended objects or an error reading the file," + "logic may be incorrect\n", sens->name, i+1, sens->totlinks); } } // done with gamesensor -- cgit v1.2.3 From fda00bc034de33371c4c7471467889f7d33c780b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 16 Aug 2008 20:45:37 +0000 Subject: BGE patch: New Delay sensor (derived from patch #17472) Introduction of a new Delay sensor that can be used to generate positive and negative triggers at precise time, expressed in number of frames. The delay parameter defines the length of the initial OFF period. A positive trigger is generated at the end of this period. The duration parameter defines the length of the ON period following the OFF period. A negative trigger is generated at the end of the ON period. If duration is 0, the sensor stays ON and there is no negative trigger. The sensor runs the OFF-ON cycle once unless the repeat option is set: the OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0). The new generic SCA_ISensor::reset() Python function can be used at any time to restart the sensor: the current cycle is interrupted and no trigger is generated. --- source/gameengine/Converter/KX_ConvertSensors.cpp | 17 ++ source/gameengine/GameLogic/SCA_DelaySensor.cpp | 257 ++++++++++++++++++++++ source/gameengine/GameLogic/SCA_DelaySensor.h | 77 +++++++ source/gameengine/GameLogic/SCA_ISensor.cpp | 13 ++ source/gameengine/GameLogic/SCA_ISensor.h | 1 + source/gameengine/PyDoc/GameLogic.py | 1 + source/gameengine/PyDoc/SCA_DelaySensor.py | 56 +++++ source/gameengine/PyDoc/SCA_ISensor.py | 6 + 8 files changed, 428 insertions(+) create mode 100644 source/gameengine/GameLogic/SCA_DelaySensor.cpp create mode 100644 source/gameengine/GameLogic/SCA_DelaySensor.h create mode 100644 source/gameengine/PyDoc/SCA_DelaySensor.py (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 76a12fb7f42..4806df36090 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -65,6 +65,7 @@ probably misplaced */ #include "SCA_JoystickSensor.h" #include "KX_NetworkMessageSensor.h" #include "SCA_ActuatorSensor.h" +#include "SCA_DelaySensor.h" #include "SCA_PropertySensor.h" @@ -281,6 +282,22 @@ void BL_ConvertSensors(struct Object* blenderobject, break; } + case SENS_DELAY: + { + // we can reuse the Always event manager for the delay sensor + SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::ALWAYS_EVENTMGR); + if (eventmgr) + { + bDelaySensor* delaysensor = (bDelaySensor*)sens->data; + gamesensor = new SCA_DelaySensor(eventmgr, + gameobj, + delaysensor->delay, + delaysensor->duration, + (delaysensor->flag & SENS_DELAY_REPEAT) != 0); + } + break; + } + case SENS_COLLISION: { SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR); diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp new file mode 100644 index 00000000000..4d05250e91c --- /dev/null +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -0,0 +1,257 @@ +/** + * Delay trigger + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef WIN32 +// This warning tells us about truncation of __long__ stl-generated names. +// It can occasionally cause DevStudio to have internal compiler warnings. +#pragma warning( disable : 4786 ) +#endif + +#include "SCA_DelaySensor.h" +#include "SCA_LogicManager.h" +#include "SCA_EventManager.h" + +/* ------------------------------------------------------------------------- */ +/* Native functions */ +/* ------------------------------------------------------------------------- */ + +SCA_DelaySensor::SCA_DelaySensor(class SCA_EventManager* eventmgr, + SCA_IObject* gameobj, + int delay, + int duration, + bool repeat, + PyTypeObject* T) + : SCA_ISensor(gameobj,eventmgr, T), + m_delay(delay), + m_duration(duration), + m_repeat(repeat) +{ + Init(); +} + +void SCA_DelaySensor::Init() +{ + m_lastResult = false; + m_frameCount = -1; + m_reset = true; +} + +SCA_DelaySensor::~SCA_DelaySensor() +{ + /* intentionally empty */ +} + +CValue* SCA_DelaySensor::GetReplica() +{ + CValue* replica = new SCA_DelaySensor(*this); + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + + return replica; +} + + + +bool SCA_DelaySensor::IsPositiveTrigger() +{ + return (m_invert ? !m_lastResult : m_lastResult); +} + +bool SCA_DelaySensor::Evaluate(CValue* event) +{ + bool trigger = false; + bool result; + + if (m_frameCount==-1) { + // this is needed to ensure ON trigger in case delay==0 + // and avoid spurious OFF trigger when duration==0 + m_lastResult = false; + m_frameCount = 0; + } + + if (m_frameCount 0) { + if (m_frameCount < m_delay+m_duration) { + m_frameCount++; + result = true; + } else { + result = false; + if (m_repeat) + m_frameCount = -1; + } + } else { + result = true; + if (m_repeat) + m_frameCount = -1; + } + if ((m_reset && m_level) || result != m_lastResult) + trigger = true; + m_reset = false; + m_lastResult = result; + return trigger; +} + +/* ------------------------------------------------------------------------- */ +/* Python functions */ +/* ------------------------------------------------------------------------- */ + +/* Integration hooks ------------------------------------------------------- */ +PyTypeObject SCA_DelaySensor::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "SCA_DelaySensor", + sizeof(SCA_DelaySensor), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject SCA_DelaySensor::Parents[] = { + &SCA_DelaySensor::Type, + &SCA_ISensor::Type, + &SCA_ILogicBrick::Type, + &CValue::Type, + NULL +}; + +PyMethodDef SCA_DelaySensor::Methods[] = { + /* setProperty */ + {"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, SetDelay_doc}, + {"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, SetDuration_doc}, + {"setRepeat", (PyCFunction) SCA_DelaySensor::sPySetRepeat, METH_VARARGS, SetRepeat_doc}, + /* getProperty */ + {"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, GetDelay_doc}, + {"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, GetDuration_doc}, + {"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, GetRepeat_doc}, + {NULL,NULL} //Sentinel +}; + +PyObject* SCA_DelaySensor::_getattr(const STR_String& attr) { + _getattr_up(SCA_ISensor); +} + +char SCA_DelaySensor::SetDelay_doc[] = +"setDelay(delay)\n" +"\t- delay: length of the initial OFF period as number of frame\n" +"\t 0 for immediate trigger\n" +"\tSet the initial delay before the positive trigger\n"; +PyObject* SCA_DelaySensor::PySetDelay(PyObject* self, PyObject* args, PyObject* kwds) +{ + int delay; + + if(!PyArg_ParseTuple(args, "i", &delay)) { + return NULL; + } + if (delay < 0) { + PyErr_SetString(PyExc_ValueError, "Delay cannot be negative"); + return NULL; + } + m_delay = delay; + Py_Return; +} + +char SCA_DelaySensor::SetDuration_doc[] = +"setDuration(duration)\n" +"\t- duration: length of the ON period in number of frame after the initial off period\n" +"\t 0 for no ON period\n" +"\tSet the duration of the ON pulse after initial delay.\n" +"\tIf > 0, a negative trigger is fired at the end of the ON pulse.\n"; +PyObject* SCA_DelaySensor::PySetDuration(PyObject* self, PyObject* args, PyObject* kwds) +{ + int duration; + + if(!PyArg_ParseTuple(args, "i", &duration)) { + return NULL; + } + if (duration < 0) { + PyErr_SetString(PyExc_ValueError, "Duration cannot be negative"); + return NULL; + } + m_duration = duration; + Py_Return; +} + +char SCA_DelaySensor::SetRepeat_doc[] = +"setRepeat(repeat)\n" +"\t- repeat: 1 if the initial OFF-ON cycle should be repeated indefinately\n" +"\t 0 if the initial OFF-ON cycle should run only once\n" +"\tSet the sensor repeat mode\n"; +PyObject* SCA_DelaySensor::PySetRepeat(PyObject* self, PyObject* args, PyObject* kwds) +{ + int repeat; + + if(!PyArg_ParseTuple(args, "i", &repeat)) { + return NULL; + } + m_repeat = (repeat != 0); + Py_Return; +} + +char SCA_DelaySensor::GetDelay_doc[] = +"getDelay()\n" +"\tReturn the delay parameter value\n"; +PyObject* SCA_DelaySensor::PyGetDelay(PyObject* self) +{ + return PyInt_FromLong(m_delay); +} + +char SCA_DelaySensor::GetDuration_doc[] = +"getDuration()\n" +"\tReturn the duration parameter value\n"; +PyObject* SCA_DelaySensor::PyGetDuration(PyObject* self) +{ + return PyInt_FromLong(m_duration); +} + +char SCA_DelaySensor::GetRepeat_doc[] = +"getRepeat()\n" +"\tReturn the repeat parameter value\n"; +PyObject* SCA_DelaySensor::PyGetRepeat(PyObject* self) +{ + return BoolToPyArg(m_repeat); +} + +/* eof */ diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h new file mode 100644 index 00000000000..a997fabe3cd --- /dev/null +++ b/source/gameengine/GameLogic/SCA_DelaySensor.h @@ -0,0 +1,77 @@ +/** + * SCA_DelaySensor.h + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __KX_DELAYSENSOR +#define __KX_DELAYSENSOR +#include "SCA_ISensor.h" + +class SCA_DelaySensor : public SCA_ISensor +{ + Py_Header; + bool m_lastResult; + bool m_repeat; + int m_delay; + int m_duration; + int m_frameCount; + +public: + SCA_DelaySensor(class SCA_EventManager* eventmgr, + SCA_IObject* gameobj, + int delay, + int duration, + bool repeat, + PyTypeObject* T =&Type); + virtual ~SCA_DelaySensor(); + virtual CValue* GetReplica(); + virtual bool Evaluate(CValue* event); + virtual bool IsPositiveTrigger(); + virtual void Init(); + + + /* --------------------------------------------------------------------- */ + /* Python interface ---------------------------------------------------- */ + /* --------------------------------------------------------------------- */ + + virtual PyObject* _getattr(const STR_String& attr); + + /* setProperty */ + KX_PYMETHOD_DOC(SCA_DelaySensor,SetDelay); + KX_PYMETHOD_DOC(SCA_DelaySensor,SetDuration); + KX_PYMETHOD_DOC(SCA_DelaySensor,SetRepeat); + /* getProperty */ + KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetDelay); + KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetDuration); + KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetRepeat); + +}; + +#endif //__KX_ALWAYSSENSOR + diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 2dc49924062..f99b9b789d7 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -189,6 +189,8 @@ PyMethodDef SCA_ISensor::Methods[] = { METH_NOARGS, GetLevel_doc}, {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel, METH_VARARGS, SetLevel_doc}, + {"reset", (PyCFunction) SCA_ISensor::sPyReset, + METH_NOARGS, Reset_doc}, {NULL,NULL} //Sentinel }; @@ -390,4 +392,15 @@ PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyOb Py_Return; } +char SCA_ISensor::Reset_doc[] = +"reset()\n" +"\tReset sensor internal state, effect depends on the type of sensor and settings.\n" +"\tThe sensor is put in its initial state as if it was just activated.\n"; +PyObject* SCA_ISensor::PyReset(PyObject* self) +{ + Init(); + Py_Return; +} + + /* eof */ diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index d5dabbce3ee..fc8f0bd0011 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -148,6 +148,7 @@ public: KX_PYMETHOD_DOC(SCA_ISensor,SetInvert); KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetLevel); KX_PYMETHOD_DOC(SCA_ISensor,SetLevel); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,Reset); }; diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index 965c0522bd7..c911ce8ec60 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -42,6 +42,7 @@ Documentation for the GameLogic Module. - L{SCA_MouseSensor} - L{SCA_PropertySensor} - L{SCA_RandomSensor} + - L{SCA_DelaySensor} You can also access actuators linked to the controller:: # To get an actuator attached to the controller: diff --git a/source/gameengine/PyDoc/SCA_DelaySensor.py b/source/gameengine/PyDoc/SCA_DelaySensor.py new file mode 100644 index 00000000000..46b74f461a7 --- /dev/null +++ b/source/gameengine/PyDoc/SCA_DelaySensor.py @@ -0,0 +1,56 @@ +# $Id$ +# Documentation for SCA_DelaySensor +from SCA_IActuator import * + +class SCA_DelaySensor(SCA_ISensor): + """ + The Delay sensor generates positive and negative triggers at precise time, + expressed in number of frames. The delay parameter defines the length + of the initial OFF period. A positive trigger is generated at the end of this period. + The duration parameter defines the length of the ON period following the OFF period. + There is a negative trigger at the end of the ON period. If duration is 0, the sensor + stays ON and there is no negative trigger. + The sensor runs the OFF-ON cycle once unless the repeat option is set: the + OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0). + Use SCA_ISensor::reset() at any time to restart sensor. + """ + def setDelay(delay): + """ + Set the initial delay before the positive trigger. + + @param delay: length of the initial OFF period as number of frame, 0 for immediate trigger + @type delay: integer + """ + def setDuration(duration): + """ + Set the duration of the ON pulse after initial delay and the generation of the positive trigger. + If duration is greater than 0, a negative trigger is sent at the end of the ON pulse. + + @param duration: length of the ON period in number of frame after the initial OFF period + @type duration: integer + """ + def setRepeat(repeat): + """ + Set if the sensor repeat mode. + + @param repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once. + @type repeat: integer + """ + def getDelay(): + """ + Return the delay parameter value. + + @rtype: integer + """ + def getDuration(): + """ + Return the duration parameter value + + @rtype: integer + """ + def getRepeat(): + """ + Return the repeat parameter value + + @rtype: KX_TRUE or KX_FALSE + """ diff --git a/source/gameengine/PyDoc/SCA_ISensor.py b/source/gameengine/PyDoc/SCA_ISensor.py index 0ebc2debb31..33f0e976284 100644 --- a/source/gameengine/PyDoc/SCA_ISensor.py +++ b/source/gameengine/PyDoc/SCA_ISensor.py @@ -77,4 +77,10 @@ class SCA_ISensor(SCA_ILogicBrick): @param level: Detect level instead of edge? (KX_TRUE, KX_FALSE) @type level: boolean """ + def reset(): + """ + Reset sensor internal state, effect depends on the type of sensor and settings. + + The sensor is put in its initial state as if it was just activated. + """ -- cgit v1.2.3 From fd0072e77cd28d52e00ea77542ba6d11018889b5 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Sun, 17 Aug 2008 17:08:00 +0000 Subject: Win64: please check my changes if you ran across them ;) But should be fine since no additional crashes were reported! --- source/gameengine/Ketsji/KX_MaterialIpoController.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp index 2ce5d469380..85d514bd22f 100644 --- a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp +++ b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp @@ -3,6 +3,8 @@ #include "KX_ScalarInterpolator.h" #include "KX_GameObject.h" +#include "BLO_sys_types.h" // for intptr_t support + #ifdef HAVE_CONFIG_H #include #endif @@ -76,10 +78,10 @@ SG_Controller* KX_MaterialIpoController::GetReplica(class SG_Node* destnode) iporeplica->AddInterpolator(copyipo); MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget(); - long orgbase = (long)this; - long orgloc = (long)scaal; - long offset = orgloc-orgbase; - long newaddrbase = (long)iporeplica + offset; + intptr_t orgbase = (intptr_t)this; + intptr_t orgloc = (intptr_t)scaal; + intptr_t offset = orgloc-orgbase; + intptr_t newaddrbase = (intptr_t)iporeplica + offset; MT_Scalar* blaptr = (MT_Scalar*) newaddrbase; copyipo->SetNewTarget((MT_Scalar*)blaptr); } -- cgit v1.2.3 From a7f5109f23ea4f362bdf7dbd6c4482634bc65b6b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Aug 2008 23:48:59 +0000 Subject: BGE Blend file loading was using BLO_read_from_memory which meant relative linked libraries could not be found. This is odd because BLO_read_from_file was commented out with """//this doesn't work anymore for relative paths, so use BLO_read_from_memory instead""" Undoing Erwins changes from r7497, just use normal file loading. From the commit log its not clear if he means relative filenames or relative linked libs but from testing both work now. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 25 +--------------------- 1 file changed, 1 insertion(+), 24 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 7de3056e382..c8ba96ac722 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -90,33 +90,10 @@ void update_for_newframe(); static BlendFileData *load_game_data(char *filename) { BlendReadError error; - //this doesn't work anymore for relative paths, so use BLO_read_from_memory instead - //BlendFileData *bfd= BLO_read_from_file(filename, &error); - FILE* file = fopen(filename,"rb"); - BlendFileData *bfd = 0; - if (file) - { - fseek(file, 0L, SEEK_END); - int len= ftell(file); - fseek(file, 0L, SEEK_SET); - char* filebuffer= new char[len];//MEM_mallocN(len, "text_buffer"); - int sizeread = fread(filebuffer,len,1,file); - if (sizeread==1){ - bfd = BLO_read_from_memory(filebuffer, len, &error); - } else { - error = BRE_UNABLE_TO_READ; - } - fclose(file); - // the memory is not released in BLO_read_from_memory, must do it here - delete filebuffer; - } else { - error = BRE_UNABLE_TO_OPEN; - } - + BlendFileData *bfd= BLO_read_from_file(filename, &error); if (!bfd) { printf("Loading %s failed: %s\n", filename, BLO_bre_as_string(error)); } - return bfd; } -- cgit v1.2.3 From 812583f1fa7a85406b55083ef3876ff506bebe7c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Aug 2008 11:53:24 +0000 Subject: Added GameLogic.globalDict, this is a place where data can be stored even when new blend files are loaded. Using for apricot so frankie can go into levels in new blendfiles keeping his inventory, currently it dosnt work for the blenderplayer which stops python before loading new blend files. --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 6 +++++- source/gameengine/Ketsji/KX_PythonInit.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index c8ba96ac722..16f8ae0095a 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -116,7 +116,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, // Acquire Python's GIL (global interpreter lock) // so we can safely run Python code and API calls PyGILState_STATE gilstate = PyGILState_Ensure(); - + + PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */ + bgl::InitExtensions(true); do @@ -310,6 +312,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, initRasterizer(rasterizer, canvas); PyObject *gameLogic = initGameLogic(startscene); PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module. + PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. initGameKeys(); initPythonConstraintBinding(); initMathutils(); @@ -384,6 +387,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, // which allows the scene to safely delete them :) // see: (space.c)->start_game PyDict_Clear(PyModule_GetDict(gameLogic)); + PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); ketsjiengine->StopEngine(); exitGamePythonScripting(); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 868439546c3..472ae759d65 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -733,6 +733,10 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook // Add some symbolic constants to the module d = PyModule_GetDict(m); + + // can be overwritten later for gameEngine instances that can load new blend files and re-initialize this module + // for now its safe to make sure it exists for other areas such as the web plugin + PyDict_SetItemString(d, "globalDict", PyDict_New()); ErrorObject = PyString_FromString("GameLogic.error"); PyDict_SetItemString(d, "error", ErrorObject); -- cgit v1.2.3 From 7608dcfc51fd74af9617b83c66a11e7ca3fb5df5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Aug 2008 06:11:11 +0000 Subject: GameLogic.globalDict blenderplayer now keeps settings when loading new blend files. workaround for python stopping and starting by storing the dictionary as marshal'd data. this means only python types are supported. This feature is needed so when switching from a menu to a level blendfile, the configuration isnt lost. --- .../GamePlayer/ghost/GPG_Application.cpp | 49 +++++++++++++++++++--- .../gameengine/GamePlayer/ghost/GPG_Application.h | 31 +++++++++++++- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 19 ++++++++- 3 files changed, 91 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 7be3b94d8ae..f859193ef7a 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -97,7 +97,7 @@ extern "C" #include "GHOST_IEventConsumer.h" #include "GHOST_IWindow.h" #include "GHOST_Rect.h" - +#include "marshal.h" static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time); @@ -125,7 +125,9 @@ GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR m_networkdevice(0), m_audiodevice(0), m_blendermat(0), - m_blenderglslmat(0) + m_blenderglslmat(0), + m_pyGlobalDictString(0), + m_pyGlobalDictString_Length(0) { fSystem = system; } @@ -645,14 +647,23 @@ bool GPG_Application::startEngine(void) PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest); m_ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(m_rasterizer, m_canvas); - PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module + PyObject *gameLogic = initGameLogic(startscene); + PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); initMathutils(); - - - + /* Restore the dict */ + if (m_pyGlobalDictString) { + PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(m_pyGlobalDictString, m_pyGlobalDictString_Length); + if (pyGlobalDict) { + PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + } else { + PyErr_Clear(); + printf("Error could not marshall string\n"); + } + } + m_sceneconverter->ConvertScene( startscenename, startscene, @@ -688,6 +699,32 @@ bool GPG_Application::startEngine(void) void GPG_Application::stopEngine() { + // get the python dict and convert to a string for future use + { + SetPyGlobalDictMarshal(NULL, 0); + + PyObject* gameLogic = PyImport_ImportModule("GameLogic"); + if (gameLogic) { + PyObject* pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module + if (pyGlobalDict) { + PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5 + if (pyGlobalDictMarshal) { + m_pyGlobalDictString_Length = PyString_Size(pyGlobalDictMarshal); + PyObject_Print(pyGlobalDictMarshal, stderr, 0); + m_pyGlobalDictString = static_cast (malloc(m_pyGlobalDictString_Length)); + memcpy(m_pyGlobalDictString, PyString_AsString(pyGlobalDictMarshal), m_pyGlobalDictString_Length); + } else { + printf("Error, GameLogic.globalDict could not be marshal'd\n"); + } + } else { + printf("Error, GameLogic.globalDict was removed\n"); + } + } else { + printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); + } + } + + // when exiting the mainloop exitGamePythonScripting(); m_ketsjiengine->StopEngine(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 17f5add8b19..31f5eb75e52 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -72,6 +72,29 @@ public: bool StartGameEngine(int stereoMode); void StopGameEngine(); + char* + GetPyGlobalDictMarshal() + { + return m_pyGlobalDictString; + }; + + void + SetPyGlobalDictMarshal( char* pyGlobalDictString, int length ) + { + if (m_pyGlobalDictString && m_pyGlobalDictString != pyGlobalDictString) + free(m_pyGlobalDictString); + + m_pyGlobalDictString = pyGlobalDictString; + m_pyGlobalDictString_Length = length; + }; + + int + GetPyGlobalDictMarshalLength() + { + return m_pyGlobalDictString_Length; + }; + + protected: bool handleWheel(GHOST_IEvent* event); bool handleButton(GHOST_IEvent* event, bool isDown); @@ -142,6 +165,12 @@ protected: bool m_blendermat; bool m_blenderglslmat; - + + /* + * GameLogic.globalDict as a string so that loading new blend files can use the same dict. + * Do this because python starts/stops when loading blend files. + */ + char* m_pyGlobalDictString; + int m_pyGlobalDictString_Length; }; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 8222e5c8bac..26a85128025 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -293,7 +293,9 @@ int main(int argc, char** argv) GHOST_TUns32 fullScreenHeight= 0; int fullScreenBpp = 32; int fullScreenFrequency = 60; - + char* pyGlobalDictString = NULL; /* store python dict data between blend file loading */ + int pyGlobalDictString_Length = 0; + #ifdef __linux__ #ifdef __alpha__ signal (SIGFPE, SIG_IGN); @@ -625,6 +627,10 @@ int main(int argc, char** argv) titlename = maggie->name; + // Set the GameLogic.globalDict from marshal'd data, so we can load new blend files + // abd keep data in GameLogic.globalDict + app.SetPyGlobalDictMarshal(pyGlobalDictString, pyGlobalDictString_Length); + // Check whether the game should be displayed full-screen if ((!fullScreenParFound) && (!windowParFound)) { @@ -750,6 +756,12 @@ int main(int argc, char** argv) } } app.StopGameEngine(); + + // GameLogic.globalDict has been converted into a buffer + // store in pyGlobalDictString so we can restore after python has stopped and started. + pyGlobalDictString = app.GetPyGlobalDictMarshal(); + pyGlobalDictString_Length = app.GetPyGlobalDictMarshalLength(); + BLO_blendfiledata_free(bfd); #ifdef __APPLE__ @@ -772,6 +784,11 @@ int main(int argc, char** argv) } } + if (pyGlobalDictString) { + free(pyGlobalDictString); + pyGlobalDictString = NULL; + } + return error ? -1 : 0; } -- cgit v1.2.3 From e912ca9331d7f9637664e4588bdb72b0ebe76e5c Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 21 Aug 2008 15:19:54 +0000 Subject: BGE bug #17491 fixed: BGE, Dupli instance with different scale, massive slowdown. The root cause of this bug is the fact that Bullet shapes are shared between duplicated game objects. As the physics object scale is stored in the shape, all duplicas must have the same scale otherwise the physics representation is incorrect. This fix introduces a mechanism to duplicate shapes at runtime so that Bullet shapes are not shared anymore. The drawback is an increased memory consuption. A reference count mechanism will be introduced in a later revision to keep Bullet shape shared between duplicas that have the same scale. --- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 338 ++++----------------- source/gameengine/Ketsji/KX_Scene.cpp | 31 -- source/gameengine/Ketsji/KX_Scene.h | 6 - .../Physics/Bullet/CcdPhysicsController.cpp | 287 ++++++++++++++++- .../Physics/Bullet/CcdPhysicsController.h | 69 +++++ .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 5 +- .../gameengine/Physics/common/PHY_DynamicTypes.h | 12 + 7 files changed, 419 insertions(+), 329 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index e0cd5a3bc9e..c95ab954022 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -680,188 +680,6 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, // forward declarations -static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool polytope) -{ - if (!meshobj) - return 0; - - btCollisionShape* collisionMeshShape = 0; - btConvexHullShape* convexHullShape = 0; - btTriangleMeshShape* concaveShape = 0; - - btTriangleMesh* collisionMeshData = 0; - - //see if there is any polygons, if not, bail out. - - int numPoints = 0; - btVector3* points = 0; - - // Mesh has no polygons! - int numpolys = meshobj->NumPolygons(); - if (!numpolys) - { - return NULL; - } - - // Count the number of collision polygons and check they all come from the same - // vertex array - int numvalidpolys = 0; - int vtxarray = -1; - RAS_IPolyMaterial *poly_material = NULL; - bool reinstance = true; - - for (int p=0; pGetPolygon(p); - - // only add polygons that have the collisionflag set - if (poly->IsCollider()) - { - // check polygon is from the same vertex array - if (poly->GetVertexIndexBase().m_vtxarray != vtxarray) - { - if (vtxarray < 0) - vtxarray = poly->GetVertexIndexBase().m_vtxarray; - else - { - reinstance = false; - vtxarray = -1; - } - } - - // check poly is from the same material - if (poly->GetMaterial()->GetPolyMaterial() != poly_material) - { - if (poly_material) - { - reinstance = false; - poly_material = NULL; - } - else - poly_material = poly->GetMaterial()->GetPolyMaterial(); - } - - // count the number of collision polys - numvalidpolys++; - - // We have one collision poly, and we can't reinstance, so we - // might as well break here. - if (!reinstance) - break; - } - } - - // No collision polygons - if (numvalidpolys < 1) - return NULL; - - - if (polytope) - { - convexHullShape = new btConvexHullShape(&points[0].getX(),numPoints); - collisionMeshShape = convexHullShape; - } else - { - collisionMeshData = new btTriangleMesh(); -// concaveShape = new btTriangleMeshShape(collisionMeshData); - //collisionMeshShape = concaveShape; - - } - - - numvalidpolys = 0; - - for (int p2=0; p2GetPolygon(p2); - - // only add polygons that have the collisionflag set - if (poly->IsCollider()) - { - //Bullet can raycast any shape, so - if (polytope) - { - for (int i=0;iVertexCount();i++) - { - const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[i], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); - btPoint3 point(vtx[0],vtx[1],vtx[2]); - convexHullShape->addPoint(point); - } - if (poly->VertexCount()) - numvalidpolys++; - - } else - { - { - const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[2], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); - btPoint3 vertex0(vtx[0],vtx[1],vtx[2]); - vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[1], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); - btPoint3 vertex1(vtx[0],vtx[1],vtx[2]); - vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[0], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); - btPoint3 vertex2(vtx[0],vtx[1],vtx[2]); - collisionMeshData->addTriangle(vertex0,vertex1,vertex2); - numvalidpolys++; - } - if (poly->VertexCount() == 4) - { - const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[3], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); - btPoint3 vertex0(vtx[0],vtx[1],vtx[2]); - vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[2], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); - btPoint3 vertex1(vtx[0],vtx[1],vtx[2]); - vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[0], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); - btPoint3 vertex2(vtx[0],vtx[1],vtx[2]); - collisionMeshData->addTriangle(vertex0,vertex1,vertex2); - numvalidpolys++; - } - - } - } - } - - - - if (numvalidpolys > 0) - { - - if (!polytope) - { - bool useQuantization = true; - concaveShape = new btBvhTriangleMeshShape( collisionMeshData, useQuantization ); - //concaveShape = new btTriangleMeshShape( collisionMeshData ); - - concaveShape->recalcLocalAabb(); - if (collisionMeshShape) - delete collisionMeshShape; - collisionMeshShape = concaveShape; - - } - - - - return collisionMeshShape; - } - if (collisionMeshShape) - delete collisionMeshShape; - if (collisionMeshData) - delete collisionMeshData; - return NULL; - -} - void KX_ConvertBulletObject( class KX_GameObject* gameobj, class RAS_MeshObject* meshobj, @@ -878,6 +696,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, bool isbulletdyna = false; CcdConstructionInfo ci; class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode()); + class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo(); @@ -894,120 +713,80 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_gravity = btVector3(0,0,0); ci.m_localInertiaTensor =btVector3(0,0,0); ci.m_mass = objprop->m_dyna ? shapeprops->m_mass : 0.f; + shapeInfo->m_radius = objprop->m_radius; isbulletdyna = objprop->m_dyna; ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f); - btTransform trans; - trans.setIdentity(); - btCollisionShape* bm = 0; switch (objprop->m_boundclass) { case KX_BOUNDSPHERE: { - float radius = objprop->m_radius; - btVector3 inertiaHalfExtents ( - radius, - radius, - radius); + //float radius = objprop->m_radius; + //btVector3 inertiaHalfExtents ( + // radius, + // radius, + // radius); //blender doesn't support multisphere, but for testing: //bm = new MultiSphereShape(inertiaHalfExtents,,&trans.getOrigin(),&radius,1); - bm = new btSphereShape(objprop->m_radius); - bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); + shapeInfo->m_shapeType = PHY_SHAPE_SPHERE; + bm = shapeInfo->CreateBulletShape(); break; }; case KX_BOUNDBOX: { - MT_Vector3 halfExtents ( + shapeInfo->m_halfExtend.setValue( objprop->m_boundobject.box.m_extends[0], - objprop->m_boundobject.box.m_extends[1], - objprop->m_boundobject.box.m_extends[2]); - - halfExtents /= 2.f; - - //btVector3 he (halfExtents[0]-CONVEX_DISTANCE_MARGIN ,halfExtents[1]-CONVEX_DISTANCE_MARGIN ,halfExtents[2]-CONVEX_DISTANCE_MARGIN ); - //he = he.absolute(); - - btVector3 he (halfExtents[0],halfExtents[1],halfExtents[2]); - he = he.absolute(); - + objprop->m_boundobject.box.m_extends[1], + objprop->m_boundobject.box.m_extends[2]); - bm = new btBoxShape(he); - bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); + shapeInfo->m_halfExtend /= 2.0; + shapeInfo->m_halfExtend = shapeInfo->m_halfExtend.absolute(); + shapeInfo->m_shapeType = PHY_SHAPE_BOX; + bm = shapeInfo->CreateBulletShape(); break; }; case KX_BOUNDCYLINDER: { - btVector3 halfExtents ( + shapeInfo->m_halfExtend.setValue( objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_height * 0.5f ); - bm = new btCylinderShapeZ(halfExtents); - bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); - + shapeInfo->m_shapeType = PHY_SHAPE_CYLINDER; + bm = shapeInfo->CreateBulletShape(); break; } - case KX_BOUNDCONE: + case KX_BOUNDCONE: { - btVector3 halfExtents (objprop->m_boundobject.box.m_extends[0], - objprop->m_boundobject.box.m_extends[1], - objprop->m_boundobject.box.m_extends[2]); - - - halfExtents /= 2.f; - - bm = new btConeShapeZ(objprop->m_boundobject.c.m_radius,objprop->m_boundobject.c.m_height); - bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); - + shapeInfo->m_radius = objprop->m_boundobject.c.m_radius; + shapeInfo->m_height = objprop->m_boundobject.c.m_height; + shapeInfo->m_shapeType = PHY_SHAPE_CONE; + bm = shapeInfo->CreateBulletShape(); break; } - case KX_BOUNDPOLYTOPE: - { - bm = CreateBulletShapeFromMesh(meshobj,true); - if (bm) - { - bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); - } - break; - } - case KX_BOUNDMESH: - { - if (!ci.m_mass) - { - bm = CreateBulletShapeFromMesh(meshobj,false); - ci.m_localInertiaTensor.setValue(0.f,0.f,0.f); - //no moving concave meshes, so don't bother calculating inertia - //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); - } - - break; - } - - default: - //interpret the shape as a concave triangle-mesh + case KX_BOUNDPOLYTOPE: { - if (meshobj) - { - bm = CreateBulletShapeFromMesh(meshobj,false); - ci.m_localInertiaTensor.setValue(0.f,0.f,0.f); - - // assert(0); - - /* - meshobj->ScheduleCollisionPolygons(); - - KX_DeformableMesh* gfxmesh = new KX_DeformableMesh(meshobj); - gfxmesh->sendFixedMapping(); - //trianglemesh - bm = new TriangleMeshInterface(gfxmesh,trans); - */ + shapeInfo->SetMesh(meshobj, true); + bm = shapeInfo->CreateBulletShape(); + break; + } + case KX_BOUNDMESH: + { + if (!ci.m_mass) + { + shapeInfo->SetMesh(meshobj, false); + bm = shapeInfo->CreateBulletShape(); + //no moving concave meshes, so don't bother calculating inertia + //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); } + + break; } } @@ -1017,10 +796,13 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, if (!bm) { delete motionstate; + delete shapeInfo; return; } bm->setMargin(0.06); + if (objprop->m_dyna) + bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); @@ -1030,31 +812,28 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, //take relative transform into account! KX_BulletPhysicsController* parentCtrl = (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController(); assert(parentCtrl); + CcdShapeConstructionInfo* parentShapeInfo = parentCtrl->GetShapeInfo(); btRigidBody* rigidbody = parentCtrl->GetRigidBody(); btCollisionShape* colShape = rigidbody->getCollisionShape(); assert(colShape->isCompound()); btCompoundShape* compoundShape = (btCompoundShape*)colShape; - btTransform childTrans; - childTrans.setIdentity(); - NodeList& children = objprop->m_dynamic_parent->GetSGNode()->GetSGChildren(); MT_Point3 childPos = gameobj->GetSGNode()->GetLocalPosition(); MT_Matrix3x3 childRot = gameobj->GetSGNode()->GetLocalOrientation(); MT_Vector3 childScale = gameobj->GetSGNode()->GetLocalScale(); bm->setLocalScaling(btVector3(childScale.x(),childScale.y(),childScale.z())); - childTrans.setOrigin(btVector3(childPos.x(),childPos.y(),childPos.z())); + shapeInfo->m_childTrans.setOrigin(btVector3(childPos.x(),childPos.y(),childPos.z())); float rotval[12]; childRot.getValue(rotval); btMatrix3x3 newRot; newRot.setValue(rotval[0],rotval[1],rotval[2],rotval[4],rotval[5],rotval[6],rotval[8],rotval[9],rotval[10]); newRot = newRot.transpose(); - childTrans.setBasis(newRot); - - - compoundShape->addChildShape(childTrans,bm); - kxscene->AddShape(bm); + shapeInfo->m_childTrans.setBasis(newRot); + parentShapeInfo->AddShape(shapeInfo); + + compoundShape->addChildShape(shapeInfo->m_childTrans,bm); //do some recalc? //recalc inertia for rigidbody if (!rigidbody->isStaticOrKinematicObject()) @@ -1069,15 +848,16 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, if (objprop->m_hasCompoundChildren) { - //replace shape by compoundShape + // create a compound shape info + CcdShapeConstructionInfo *compoundShapeInfo = new CcdShapeConstructionInfo(); + compoundShapeInfo->m_shapeType = PHY_SHAPE_COMPOUND; + compoundShapeInfo->AddShape(shapeInfo); + // create the compound shape manually as we already have the child shape btCompoundShape* compoundShape = new btCompoundShape(); - btTransform identTrans; - identTrans.setIdentity(); - compoundShape->addChildShape(identTrans,bm); - //note abount compoundShape: Bullet does not delete the child shapes when - //the compound shape is deleted, so insert also the child shapes - kxscene->AddShape(bm); + compoundShape->addChildShape(shapeInfo->m_childTrans,bm); + // now replace the shape bm = compoundShape; + shapeInfo = compoundShapeInfo; } @@ -1113,6 +893,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_collisionShape = bm; + ci.m_shapeInfo = shapeInfo; ci.m_friction = smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice ci.m_restitution = smmaterial->m_restitution; ci.m_physicsEnv = env; @@ -1125,8 +906,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody; KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); - //remember that we created a shape so that we can delete it when the scene is removed (bullet will not delete it) - kxscene->AddShape(bm); + // shapeInfo is reference counted, decrement now as we don't use it anymore + if (shapeInfo) + shapeInfo->Release(); if (objprop->m_in_active_layer) { diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 2828663c63d..ab3692d2411 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -234,40 +234,9 @@ KX_Scene::~KX_Scene() { delete m_bucketmanager; } -#ifdef USE_BULLET - // This is a fix for memory leaks in bullet: the collision shapes is not destroyed - // when the physical controllers are destroyed. The reason is that shapes are shared - // between replicas of an object. There is no reference count in Bullet so the - // only workaround that does not involve changes in Bullet is to save in this array - // the list of shapes that are created when the scene is created (see KX_ConvertPhysicsObjects.cpp) - class btCollisionShape* shape; - class btTriangleMeshShape* meshShape; - vector::iterator it = m_shapes.begin(); - while (it != m_shapes.end()) { - shape = *it; - if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) - { - meshShape = static_cast(shape); - // shapes based on meshes use an interface that contains the vertices. - // Again the idea is to be able to share the interface between shapes but - // this is not used in Blender: each base object will have its own interface - btStridingMeshInterface* meshInterface = meshShape->getMeshInterface(); - if (meshInterface) - delete meshInterface; - } - delete shape; - it++; - } -#endif //Py_DECREF(m_attrlist); } -void KX_Scene::AddShape(class btCollisionShape*shape) -{ - m_shapes.push_back(shape); -} - - void KX_Scene::SetProjectionMatrix(MT_CmMatrix4x4& pmat) { m_projectionmat = pmat; diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 80a2abe287a..1c56dd1ee55 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -121,11 +121,6 @@ protected: * The set of cameras for this scene */ list m_cameras; - /** - * The set of bullet shapes that must be deleted at the end of the scene - * to avoid memory leak (not deleted by bullet because shape are shared between replicas) - */ - vector m_shapes; /** * Various SCA managers used by the scene */ @@ -322,7 +317,6 @@ public: int NewRemoveObject(CValue* gameobj); void ReplaceMesh(CValue* gameobj, void* meshobj); - void AddShape(class btCollisionShape* shape); /** * @section Logic stuff * Initiate an update of the logic system. diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index b872fae6138..a28af5f9635 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -18,6 +18,7 @@ subject to the following restrictions: #include "PHY_IMotionState.h" #include "CcdPhysicsEnvironment.h" +#include "RAS_MeshObject.h" class BP_Proxy; @@ -44,7 +45,14 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) m_newClientInfo = 0; m_registerCount = 0; + // copy pointers locally to allow smart release m_MotionState = ci.m_MotionState; + m_collisionShape = ci.m_collisionShape; + // shape info is shared, increment ref count + m_shapeInfo = ci.m_shapeInfo; + if (m_shapeInfo) + m_shapeInfo->AddRef(); + m_bulletMotionState = 0; @@ -116,7 +124,7 @@ void CcdPhysicsController::CreateRigidbody() m_body = new btRigidBody(m_cci.m_mass, m_bulletMotionState, - m_cci.m_collisionShape, + m_collisionShape, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor, m_cci.m_linearDamping,m_cci.m_angularDamping, m_cci.m_friction,m_cci.m_restitution); @@ -144,6 +152,19 @@ void CcdPhysicsController::CreateRigidbody() } } +static void DeleteBulletShape(btCollisionShape* shape) +{ + if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) + { + // shapes based on meshes use an interface that contains the vertices. + btTriangleMeshShape* meshShape = static_cast(shape); + btStridingMeshInterface* meshInterface = meshShape->getMeshInterface(); + if (meshInterface) + delete meshInterface; + } + delete shape; +} + CcdPhysicsController::~CcdPhysicsController() { //will be reference counted, due to sharing @@ -155,6 +176,27 @@ CcdPhysicsController::~CcdPhysicsController() if (m_bulletMotionState) delete m_bulletMotionState; delete m_body; + + if (m_collisionShape) + { + // collision shape is always unique to the controller, can delete it here + if (m_collisionShape->isCompound()) + { + // bullet does not delete the child shape, must do it here + btCompoundShape* compoundShape = (btCompoundShape*)m_collisionShape; + int numChild = compoundShape->getNumChildShapes(); + for (int i=numChild-1 ; i >= 0; i--) + { + btCollisionShape* childShape = compoundShape->getChildShape(i); + DeleteBulletShape(childShape); + } + } + DeleteBulletShape(m_collisionShape); + } + if (m_shapeInfo) + { + m_shapeInfo->Release(); + } } @@ -219,11 +261,33 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta { m_MotionState = motionstate; m_registerCount = 0; - + m_collisionShape = NULL; + + // always create a new shape to avoid scaling bug + if (m_shapeInfo) + { + m_shapeInfo->AddRef(); + m_collisionShape = m_shapeInfo->CreateBulletShape(); + + if (m_collisionShape) + { + // new shape has no scaling, apply initial scaling + m_collisionShape->setLocalScaling(m_cci.m_scaling); + if (m_cci.m_mass) + m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); + } + } m_body = 0; CreateRigidbody(); - + + if (m_body) + { + if (m_cci.m_mass) + { + m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); + } + } m_cci.m_physicsEnv->addCcdPhysicsController(this); @@ -597,29 +661,32 @@ bool CcdPhysicsController::wantsSleeping() PHY_IPhysicsController* CcdPhysicsController::GetReplica() { - //very experimental, shape sharing is not implemented yet. - //just support btSphereShape/ConeShape for now - + // This is used only to replicate Near and Radar sensor controllers + // The replication of object physics controller is done in KX_BulletPhysicsController::GetReplica() CcdConstructionInfo cinfo = m_cci; - if (cinfo.m_collisionShape) + if (m_shapeInfo) + { + // This situation does not normally happen + cinfo.m_collisionShape = m_shapeInfo->CreateBulletShape(); + } + else if (m_collisionShape) { - switch (cinfo.m_collisionShape->getShapeType()) + switch (m_collisionShape->getShapeType()) { case SPHERE_SHAPE_PROXYTYPE: { - btSphereShape* orgShape = (btSphereShape*)cinfo.m_collisionShape; + btSphereShape* orgShape = (btSphereShape*)m_collisionShape; cinfo.m_collisionShape = new btSphereShape(*orgShape); break; } - case CONE_SHAPE_PROXYTYPE: + case CONE_SHAPE_PROXYTYPE: { - btConeShape* orgShape = (btConeShape*)cinfo.m_collisionShape; + btConeShape* orgShape = (btConeShape*)m_collisionShape; cinfo.m_collisionShape = new btConeShape(*orgShape); break; } - default: { return 0; @@ -628,6 +695,7 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplica() } cinfo.m_MotionState = new DefaultMotionState(); + cinfo.m_shapeInfo = m_shapeInfo; CcdPhysicsController* replica = new CcdPhysicsController(cinfo); return replica; @@ -689,3 +757,198 @@ void DefaultMotionState::calculateWorldTransformations() } +// Shape constructor +bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) +{ + // assume no shape information + m_shapeType = PHY_SHAPE_NONE; + m_vertexArray.clear(); + + if (!meshobj) + return false; + + // Mesh has no polygons! + int numpolys = meshobj->NumPolygons(); + if (!numpolys) + { + return false; + } + + // check that we have at least one colliding polygon + int numvalidpolys = 0; + + for (int p=0; pGetPolygon(p); + + // only add polygons that have the collisionflag set + if (poly->IsCollider()) + { + numvalidpolys++; + break; + } + } + + // No collision polygons + if (numvalidpolys < 1) + return false; + + m_shapeType = (polytope) ? PHY_SHAPE_POLYTOPE : PHY_SHAPE_MESH; + + numvalidpolys = 0; + + for (int p2=0; p2GetPolygon(p2); + + // only add polygons that have the collisionflag set + if (poly->IsCollider()) + { + //Bullet can raycast any shape, so + if (polytope) + { + for (int i=0;iVertexCount();i++) + { + const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, + poly->GetVertexIndexBase().m_indexarray[i], + poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + btPoint3 point(vtx[0],vtx[1],vtx[2]); + m_vertexArray.push_back(point); + numvalidpolys++; + } + } else + { + { + const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, + poly->GetVertexIndexBase().m_indexarray[2], + poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + btPoint3 vertex0(vtx[0],vtx[1],vtx[2]); + vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, + poly->GetVertexIndexBase().m_indexarray[1], + poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + btPoint3 vertex1(vtx[0],vtx[1],vtx[2]); + vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, + poly->GetVertexIndexBase().m_indexarray[0], + poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + btPoint3 vertex2(vtx[0],vtx[1],vtx[2]); + m_vertexArray.push_back(vertex0); + m_vertexArray.push_back(vertex1); + m_vertexArray.push_back(vertex2); + numvalidpolys++; + } + if (poly->VertexCount() == 4) + { + const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, + poly->GetVertexIndexBase().m_indexarray[3], + poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + btPoint3 vertex0(vtx[0],vtx[1],vtx[2]); + vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, + poly->GetVertexIndexBase().m_indexarray[2], + poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + btPoint3 vertex1(vtx[0],vtx[1],vtx[2]); + vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, + poly->GetVertexIndexBase().m_indexarray[0], + poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + btPoint3 vertex2(vtx[0],vtx[1],vtx[2]); + m_vertexArray.push_back(vertex0); + m_vertexArray.push_back(vertex1); + m_vertexArray.push_back(vertex2); + numvalidpolys++; + } + } + } + } + + if (!numvalidpolys) + { + // should not happen + m_shapeType = PHY_SHAPE_NONE; + return false; + } + return true; +} + +btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() +{ + btCollisionShape* collisionShape = 0; + btTriangleMeshShape* concaveShape = 0; + btTriangleMesh* collisionMeshData = 0; + btCompoundShape* compoundShape = 0; + CcdShapeConstructionInfo* nextShapeInfo; + + switch (m_shapeType) + { + case PHY_SHAPE_BOX: + collisionShape = new btBoxShape(m_halfExtend); + break; + + case PHY_SHAPE_SPHERE: + collisionShape = new btSphereShape(m_radius); + break; + + case PHY_SHAPE_CYLINDER: + collisionShape = new btCylinderShapeZ(m_halfExtend); + break; + + case PHY_SHAPE_CONE: + collisionShape = new btConeShapeZ(m_radius, m_height); + break; + + case PHY_SHAPE_POLYTOPE: + collisionShape = new btConvexHullShape(&m_vertexArray.begin()->getX(), m_vertexArray.size()); + break; + + case PHY_SHAPE_MESH: + collisionMeshData = new btTriangleMesh(); + // m_vertexArray is necessarily a multiple of 3 + for (std::vector::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) + { + collisionMeshData->addTriangle(*it++,*it++,*it++); + } + concaveShape = new btBvhTriangleMeshShape( collisionMeshData, true ); + concaveShape->recalcLocalAabb(); + collisionShape = concaveShape; + break; + + case PHY_SHAPE_COMPOUND: + if (m_nextShape) + { + compoundShape = new btCompoundShape(); + for (nextShapeInfo=m_nextShape; nextShapeInfo; nextShapeInfo = nextShapeInfo->m_nextShape) + { + collisionShape = nextShapeInfo->CreateBulletShape(); + if (collisionShape) + { + compoundShape->addChildShape(nextShapeInfo->m_childTrans, collisionShape); + } + } + collisionShape = compoundShape; + } + } + return collisionShape; +} + +void CcdShapeConstructionInfo::AddShape(CcdShapeConstructionInfo* shapeInfo) +{ + CcdShapeConstructionInfo* nextShape = this; + while (nextShape->m_nextShape != NULL) + nextShape = nextShape->m_nextShape; + nextShape->m_nextShape = shapeInfo; +} + +CcdShapeConstructionInfo::~CcdShapeConstructionInfo() +{ + CcdShapeConstructionInfo* childShape = m_nextShape; + + while (childShape) + { + CcdShapeConstructionInfo* nextShape = childShape->m_nextShape; + childShape->m_nextShape = NULL; + childShape->Release(); + childShape = nextShape; + } + + m_vertexArray.clear(); +} + + diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 448e5622eff..1e1a38aa2a6 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -17,11 +17,14 @@ subject to the following restrictions: #ifndef BULLET2_PHYSICSCONTROLLER_H #define BULLET2_PHYSICSCONTROLLER_H +#include + #include "PHY_IPhysicsController.h" /// PHY_IPhysicsController is the abstract simplified Interface to a physical object. /// It contains the IMotionState and IDeformableMesh Interfaces. #include "btBulletDynamicsCommon.h" +#include "LinearMath/btTransform.h" #include "PHY_IMotionState.h" @@ -31,8 +34,66 @@ extern float gAngularSleepingTreshold; extern bool gDisableDeactivation; class CcdPhysicsEnvironment; class btMotionState; +class RAS_MeshObject; +class btCollisionShape; + +// Shape contructor +// It contains all the information needed to create a simple bullet shape at runtime +class CcdShapeConstructionInfo +{ +public: + CcdShapeConstructionInfo() : + m_shapeType(PHY_SHAPE_NONE), + m_radius(1.0), + m_height(1.0), + m_halfExtend(0.f,0.f,0.f), + m_nextShape(NULL), + m_refCount(1) + { + m_childTrans.setIdentity(); + } + ~CcdShapeConstructionInfo(); + CcdShapeConstructionInfo* AddRef() + { + m_refCount++; + return this; + } + + int Release() + { + if (--m_refCount > 0) + return m_refCount; + delete this; + return 0; + } + + void AddShape(CcdShapeConstructionInfo* shapeInfo); + + CcdShapeConstructionInfo* GetNextShape() + { + return m_nextShape; + } + + bool SetMesh(RAS_MeshObject* mesh, bool polytope); + + btCollisionShape* CreateBulletShape(); + + // member variables + PHY_ShapeType m_shapeType; + btScalar m_radius; + btScalar m_height; + btVector3 m_halfExtend; + btTransform m_childTrans; + std::vector m_vertexArray; // Contains both vertex array for polytope shape and + // triangle array for concave mesh shape. + // In this case a triangle is made of 3 consecutive points +protected: + CcdShapeConstructionInfo* m_nextShape; // for compound shape + int m_refCount; // this class is shared between replicas + // keep track of users so that we can release it +}; struct CcdConstructionInfo { @@ -65,6 +126,7 @@ struct CcdConstructionInfo m_collisionFilterMask(AllFilter), m_collisionShape(0), m_MotionState(0), + m_shapeInfo(0), m_physicsEnv(0), m_inertiaFactor(1.f) { @@ -89,8 +151,11 @@ struct CcdConstructionInfo short int m_collisionFilterGroup; short int m_collisionFilterMask; + ///these pointers are used as argument passing for the CcdPhysicsController constructor + ///and not anymore after that class btCollisionShape* m_collisionShape; class PHY_IMotionState* m_MotionState; + class CcdShapeConstructionInfo* m_shapeInfo; CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication float m_inertiaFactor;//tweak the inertia (hooked up to Blender 'formfactor' @@ -106,6 +171,9 @@ class CcdPhysicsController : public PHY_IPhysicsController btRigidBody* m_body; class PHY_IMotionState* m_MotionState; btMotionState* m_bulletMotionState; + class btCollisionShape* m_collisionShape; + class CcdShapeConstructionInfo* m_shapeInfo; + friend class CcdPhysicsEnvironment; // needed when updating the controller @@ -137,6 +205,7 @@ class CcdPhysicsController : public PHY_IPhysicsController btRigidBody* GetRigidBody() { return m_body;} + CcdShapeConstructionInfo* GetShapeInfo() { return m_shapeInfo; } btCollisionShape* GetCollisionShape() { return m_body->getCollisionShape(); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index dfbcf115fd7..d8e05fab839 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1370,8 +1370,9 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float coneradius,float coneheight) { CcdConstructionInfo cinfo; - //This is a memory leak: Bullet does not delete the shape and it cannot be added to - //the KX_Scene.m_shapes list -- too bad but that's not a lot of data + + // we don't need a CcdShapeConstructionInfo for this shape: + // it is simple enough for the standard copy constructor (see CcdPhysicsController::GetReplica) cinfo.m_collisionShape = new btConeShape(coneradius,coneheight); cinfo.m_MotionState = 0; cinfo.m_physicsEnv = this; diff --git a/source/gameengine/Physics/common/PHY_DynamicTypes.h b/source/gameengine/Physics/common/PHY_DynamicTypes.h index c289b9d8bcb..3b3e42c38d2 100644 --- a/source/gameengine/Physics/common/PHY_DynamicTypes.h +++ b/source/gameengine/Physics/common/PHY_DynamicTypes.h @@ -87,6 +87,18 @@ typedef enum PHY_ConstraintType { } PHY_ConstraintType; +typedef enum PHY_ShapeType { + PHY_SHAPE_NONE, + PHY_SHAPE_BOX, + PHY_SHAPE_SPHERE, + PHY_SHAPE_CYLINDER, + PHY_SHAPE_CONE, + PHY_SHAPE_MESH, + PHY_SHAPE_POLYTOPE, + PHY_SHAPE_COMPOUND +} PHY_ShapeType; + + typedef float PHY_Vector3[3]; #endif //__PHY_DYNAMIC_TYPES -- cgit v1.2.3 From ca1182ff5696a8a656a4d5a693d1476a94b170c0 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 21 Aug 2008 19:00:24 +0000 Subject: fix warning in previous revision, update MSVC project files, scons files in source/gameengine/Physics/Bullet must be updated by adding these directories in the include list: intern/string/include, source/gameengine/Rasterizer, source/kernel/gen_system. I leave it up to more expert than me. --- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index a28af5f9635..312e3258f61 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -878,6 +878,9 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() switch (m_shapeType) { + case PHY_SHAPE_NONE: + break; + case PHY_SHAPE_BOX: collisionShape = new btBoxShape(m_halfExtend); break; -- cgit v1.2.3 From 3d3527eb6dc44a386ed5ac486af3e087af3c7be0 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 21 Aug 2008 21:04:42 +0000 Subject: BGE bug #17411 fixed: the always sensor is called before the the scale of the object is applied. The scale is now applied to the shape before the creation of the rigid body. --- source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 5 ++--- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index c95ab954022..d6997ee29a8 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -801,9 +801,6 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, } bm->setMargin(0.06); - if (objprop->m_dyna) - bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); - if (objprop->m_isCompoundChild) @@ -905,6 +902,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter); ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody; + MT_Vector3 scaling = gameobj->NodeGetWorldScaling(); + ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]); KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); // shapeInfo is reference counted, decrement now as we don't use it anymore if (shapeInfo) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 312e3258f61..d6a32dfd9c0 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -48,6 +48,10 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) // copy pointers locally to allow smart release m_MotionState = ci.m_MotionState; m_collisionShape = ci.m_collisionShape; + // apply scaling before creating rigid body + m_collisionShape->setLocalScaling(m_cci.m_scaling); + if (m_cci.m_mass) + m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); // shape info is shared, increment ref count m_shapeInfo = ci.m_shapeInfo; if (m_shapeInfo) -- cgit v1.2.3 From f0d58a8b99aa817824e677c3d246750ca1f25dc7 Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Thu, 21 Aug 2008 21:14:08 +0000 Subject: Update scons files in source/gameengine/Physics/Bullet. Please Nathan double check this, but all compile fine here :) --- source/gameengine/Physics/Bullet/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript index dd6eab0f018..0936d45197a 100644 --- a/source/gameengine/Physics/Bullet/SConscript +++ b/source/gameengine/Physics/Bullet/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = 'CcdPhysicsEnvironment.cpp CcdPhysicsController.cpp' -incs = '. ../common' +incs = '. ../common #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer' incs += ' ' + env['BF_BULLET_INC'] -- cgit v1.2.3 From 9b298109126bd77b5ee219d5e456cdbb96cc6bb9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Aug 2008 06:02:01 +0000 Subject: BGE Python API - GameLogic.getBlendFileList(path='//') to return a list of blend's in the current directory. Needed for creating a level selector that lists all files in the level directory. CMakeFile include path to compile with recent changes. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 128 ++++++++++++------------ source/gameengine/Physics/Bullet/CMakeLists.txt | 4 + source/gameengine/PyDoc/GameLogic.py | 13 ++- 3 files changed, 77 insertions(+), 68 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 472ae759d65..6179d614e8c 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -31,6 +31,7 @@ #include "GL/glew.h" #include +#include // directory header for py function getBlendFileList #ifdef WIN32 #pragma warning (disable : 4786) @@ -112,9 +113,7 @@ static PyObject* gPyGetRandomFloat(PyObject*) return PyFloat_FromDouble(MT_random()); } -static PyObject* gPySetGravity(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetGravity(PyObject*, PyObject* args) { MT_Vector3 vec = MT_Vector3(0., 0., 0.); if (PyVecArgTo(args, vec)) @@ -138,9 +137,7 @@ file to make a full path name (doesn't change during the game, even if you load\ other .blend).\n\ The function also converts the directory separator to the local file system format."; -static PyObject* gPyExpandPath(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyExpandPath(PyObject*, PyObject* args) { char expanded[FILE_MAXDIR + FILE_MAXFILE]; char* filename; @@ -185,9 +182,7 @@ static PyObject* gPyGetSpectrum(PyObject*) -static PyObject* gPyStartDSP(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyStartDSP(PyObject*, PyObject* args) { SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); @@ -205,9 +200,7 @@ static PyObject* gPyStartDSP(PyObject*, -static PyObject* gPyStopDSP(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyStopDSP(PyObject*, PyObject* args) { SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); @@ -223,9 +216,7 @@ static PyObject* gPyStopDSP(PyObject*, return NULL; } -static PyObject* gPySetLogicTicRate(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args) { float ticrate; if (PyArg_ParseTuple(args, "f", &ticrate)) @@ -242,9 +233,7 @@ static PyObject* gPyGetLogicTicRate(PyObject*) return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate()); } -static PyObject* gPySetPhysicsTicRate(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args) { float ticrate; if (PyArg_ParseTuple(args, "f", &ticrate)) @@ -257,9 +246,7 @@ static PyObject* gPySetPhysicsTicRate(PyObject*, return NULL; } -static PyObject* gPySetPhysicsDebug(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetPhysicsDebug(PyObject*, PyObject* args) { int debugMode; if (PyArg_ParseTuple(args, "i", &debugMode)) @@ -278,6 +265,44 @@ static PyObject* gPyGetPhysicsTicRate(PyObject*) return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep()); } +static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) +{ + char cpath[sizeof(G.sce)]; + char *searchpath = NULL; + PyObject* list; + + DIR *dp; + struct dirent *dirp; + + if (!PyArg_ParseTuple(args, "|s", &searchpath)) + return NULL; + + list = PyList_New(0); + + if (searchpath) { + BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE); + BLI_convertstringcode(cpath, G.sce); + } else { + /* Get the dir only */ + BLI_split_dirfile_basic(G.sce, cpath, NULL); + } + + if((dp = opendir(cpath)) == NULL) { + /* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */ + fprintf(stderr, "Could not read directoty () failed, code %d (%s)\n", cpath, errno, strerror(errno)); + return list; + } + + while ((dirp = readdir(dp)) != NULL) { + if (BLI_testextensie(dirp->d_name, ".blend")) { + PyList_Append(list, PyString_FromString(dirp->d_name)); + } + } + + closedir(dp); + return list; +} + static STR_String gPyGetCurrentScene_doc = "getCurrentScene()\n" "Gets a reference to the current scene.\n"; @@ -377,14 +402,13 @@ static struct PyMethodDef game_methods[] = { {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"}, {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, "Gets the physics tic rate"}, {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"}, + {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, "Gets a list of blend files in the same directory as the current blend file"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, "Prints GL Extension Info"}, {NULL, (PyCFunction) NULL, 0, NULL } }; -static PyObject* gPyGetWindowHeight(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyGetWindowHeight(PyObject*, PyObject* args) { int height = (gp_Canvas ? gp_Canvas->GetHeight() : 0); @@ -394,9 +418,7 @@ static PyObject* gPyGetWindowHeight(PyObject*, -static PyObject* gPyGetWindowWidth(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyGetWindowWidth(PyObject*, PyObject* args) { @@ -411,9 +433,7 @@ static PyObject* gPyGetWindowWidth(PyObject*, // temporarility visibility thing, will be moved to rasterizer/renderer later bool gUseVisibilityTemp = false; -static PyObject* gPyEnableVisibility(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyEnableVisibility(PyObject*, PyObject* args) { int visible; if (PyArg_ParseTuple(args,"i",&visible)) @@ -429,9 +449,7 @@ static PyObject* gPyEnableVisibility(PyObject*, -static PyObject* gPyShowMouse(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyShowMouse(PyObject*, PyObject* args) { int visible; if (PyArg_ParseTuple(args,"i",&visible)) @@ -455,9 +473,7 @@ static PyObject* gPyShowMouse(PyObject*, -static PyObject* gPySetMousePosition(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetMousePosition(PyObject*, PyObject* args) { int x,y; if (PyArg_ParseTuple(args,"ii",&x,&y)) @@ -472,9 +488,7 @@ static PyObject* gPySetMousePosition(PyObject*, Py_Return; } -static PyObject* gPySetEyeSeparation(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args) { float sep; if (PyArg_ParseTuple(args, "f", &sep)) @@ -496,9 +510,7 @@ static PyObject* gPyGetEyeSeparation(PyObject*, PyObject*, PyObject*) return NULL; } -static PyObject* gPySetFocalLength(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetFocalLength(PyObject*, PyObject* args) { float focus; if (PyArg_ParseTuple(args, "f", &focus)) @@ -518,9 +530,7 @@ static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*) return NULL; } -static PyObject* gPySetBackgroundColor(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetBackgroundColor(PyObject*, PyObject* args) { MT_Vector4 vec = MT_Vector4(0., 0., 0.3, 0.); @@ -538,9 +548,7 @@ static PyObject* gPySetBackgroundColor(PyObject*, -static PyObject* gPySetMistColor(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetMistColor(PyObject*, PyObject* args) { MT_Vector3 vec = MT_Vector3(0., 0., 0.); @@ -558,9 +566,7 @@ static PyObject* gPySetMistColor(PyObject*, -static PyObject* gPySetMistStart(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetMistStart(PyObject*, PyObject* args) { float miststart; @@ -579,9 +585,7 @@ static PyObject* gPySetMistStart(PyObject*, -static PyObject* gPySetMistEnd(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetMistEnd(PyObject*, PyObject* args) { float mistend; @@ -599,9 +603,7 @@ static PyObject* gPySetMistEnd(PyObject*, } -static PyObject* gPySetAmbientColor(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPySetAmbientColor(PyObject*, PyObject* args) { MT_Vector3 vec = MT_Vector3(0., 0., 0.); @@ -620,9 +622,7 @@ static PyObject* gPySetAmbientColor(PyObject*, -static PyObject* gPyMakeScreenshot(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyMakeScreenshot(PyObject*, PyObject* args) { char* filename; if (PyArg_ParseTuple(args,"s",&filename)) @@ -638,9 +638,7 @@ static PyObject* gPyMakeScreenshot(PyObject*, Py_Return; } -static PyObject* gPyEnableMotionBlur(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args) { float motionblurvalue; if (PyArg_ParseTuple(args,"f",&motionblurvalue)) @@ -656,9 +654,7 @@ static PyObject* gPyEnableMotionBlur(PyObject*, Py_Return; } -static PyObject* gPyDisableMotionBlur(PyObject*, - PyObject* args, - PyObject*) +static PyObject* gPyDisableMotionBlur(PyObject*, PyObject* args) { if(gp_Rasterizer) { diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt index b610fd1bbb0..6c733786caf 100644 --- a/source/gameengine/Physics/Bullet/CMakeLists.txt +++ b/source/gameengine/Physics/Bullet/CMakeLists.txt @@ -30,6 +30,10 @@ SET(INC . ../common ../../../../extern/bullet2/src + ../../../../intern/moto/include + ../../../kernel/gen_system + ../../../../intern/string + ../../Rasterizer ) BLENDERLIB(bf_bullet "${SRC}" "${INC}") diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index c911ce8ec60..b65bc0f3ce8 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -14,8 +14,7 @@ Documentation for the GameLogic Module. Examples:: # To get a controller: - import GameLogic - co = GameLogic.getCurrentController() + co = GameLogic.getCurrentController() # GameLogic is automatically imported # To get the game object associated with this controller: obj = co.getOwner() @@ -237,3 +236,13 @@ def expandPath(path): @return: The converted string @rtype: string """ + +def getBlendFileList(path = "//"): + """ + Returns a list of blend files in the same directory as the open blend file, or from using the option argument. + + @param path: Optional directory argument, will be expanded (like expandPath) into the full path. + @type path: string + @return: A list of filenames, with no directory prefix + @rtype: list + """ \ No newline at end of file -- cgit v1.2.3 From f88dabae8a611c4fd13f441abb51f0e11d6454c3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Aug 2008 10:27:16 +0000 Subject: BGE data conversion was making sound paths absolute, modify a copy rather then the original. --- source/gameengine/Converter/KX_ConvertActuators.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index cb2521de9a4..b1f86afa4ee 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -384,8 +384,12 @@ void BL_ConvertActuators(char* maggiename, else { /* but we need to convert the samplename into absolute pathname first */ - BLI_convertstringcode(soundact->sound->name, maggiename); - samplename = soundact->sound->name; + char fullpath[sizeof(soundact->sound->name)]; + + /* dont modify soundact->sound->name, only change a copy */ + BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath)); + BLI_convertstringcode(fullpath, maggiename); + samplename = fullpath; /* and now we can load it */ if (soundscene->LoadSample(samplename, NULL, 0) > -1) -- cgit v1.2.3 From 7630539fe88b3c0dc353ae194baea8d757b79cae Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 22 Aug 2008 15:00:30 +0000 Subject: Fix Windows compilation problem and update MSVC project files --- source/gameengine/Ketsji/KX_PythonInit.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 6179d614e8c..5d2126ca37a 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -30,8 +30,13 @@ #include "GL/glew.h" +// directory header for py function getBlendFileList #include -#include // directory header for py function getBlendFileList +#ifndef WIN32 + #include +#else + #include "BLI_winstuff.h" +#endif #ifdef WIN32 #pragma warning (disable : 4786) -- cgit v1.2.3 From bc8f002a4c68235db766fbd72bc383feb7836341 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 23 Aug 2008 11:54:27 +0000 Subject: BGE state system improvement: the sensor with Level option enabled will trigger the controller of a newly activated state, even if the sensor is already connected to an active state; new isTriggered() python function to determine which sensor triggered the current controller. Previously, this behaviour was available only for sensors that were not connected to any active state, which was forcing the game designer to duplicate sensors in some cases. For example the Always sensors used to initialize the states needed to be duplicated for each state. With this patch, a single Always sensor with Level option enabled will suffice to initialize all the states. A Python controller can determine which sensor did trigger with the new SCA_ISensor::isTriggered() function. Notes: - When a sensor with level option enabled is connected to multiple controllers, only those of newly activated states will be triggered. The controllers of already activated states will receive no trigger, unless the sensor internal state toggled, in which case all the controllers are triggered as always. - The old isPositive() function returns the internal state of the sensor, positive or negative; the new isTriggered() function returns 1 only for sensors that generated an event in the current frame. --- source/gameengine/GameLogic/SCA_IController.cpp | 2 + source/gameengine/GameLogic/SCA_ISensor.cpp | 45 +++++++++++++++++++--- source/gameengine/GameLogic/SCA_ISensor.h | 13 +++++-- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 2 +- source/gameengine/GameLogic/SCA_LogicManager.cpp | 31 ++++++++++++--- source/gameengine/GameLogic/SCA_LogicManager.h | 2 + .../gameengine/GameLogic/SCA_PythonController.cpp | 11 +++++- source/gameengine/GameLogic/SCA_PythonController.h | 6 +++ source/gameengine/PyDoc/SCA_ISensor.py | 7 +++- 9 files changed, 100 insertions(+), 19 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index 8f156cc63e7..0bd20117f31 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -188,6 +188,8 @@ void SCA_IController::ApplyState(unsigned int state) for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit) { (*sensit)->IncLink(); + // remember that this controller just activated that sensor + (*sensit)->AddNewController(this); } SetActive(true); } diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index f99b9b789d7..c96eb82e29e 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -32,6 +32,8 @@ #include "SCA_ISensor.h" #include "SCA_EventManager.h" #include "SCA_LogicManager.h" +// needed for IsTriggered() +#include "SCA_PythonController.h" #ifdef HAVE_CONFIG_H #include @@ -132,10 +134,8 @@ void SCA_ISensor::DecLink() { } if (!m_links) { - // sensor is detached from all controllers, initialize it so that it - // is fresh as at startup when it is reattached again. + // sensor is detached from all controllers, remove it from manager UnregisterToManager(); - Init(); } } @@ -168,7 +168,9 @@ PyParentObject SCA_ISensor::Parents[] = { }; PyMethodDef SCA_ISensor::Methods[] = { {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive, - METH_VARARGS, IsPositive_doc}, + METH_NOARGS, IsPositive_doc}, + {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered, + METH_VARARGS, IsTriggered_doc}, {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode, METH_NOARGS, GetUsePosPulseMode_doc}, {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode, @@ -204,6 +206,9 @@ SCA_ISensor::_getattr(const STR_String& attr) void SCA_ISensor::RegisterToManager() { + // sensor is just activated, initialize it + Init(); + m_newControllers.erase(m_newControllers.begin(), m_newControllers.end()); m_eventmgr->RegisterSensor(this); } @@ -249,19 +254,47 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event) } } } + if (!m_newControllers.empty()) + { + if (!IsActive() && m_level) + { + // This level sensor is connected to at least one controller that was just made + // active but it did not generate an event yet, do it now to those controllers only + for (std::vector::iterator ci=m_newControllers.begin(); + ci != m_newControllers.end(); ci++) + { + logicmgr->AddTriggeredController(*ci, this); + } + } + // clear the list. Instead of using clear, which also release the memory, + // use erase, which keeps the memory available for next time. + m_newControllers.erase(m_newControllers.begin(), m_newControllers.end()); + } } } /* Python functions: */ char SCA_ISensor::IsPositive_doc[] = "isPositive()\n" -"\tReturns whether the sensor is registered a positive event.\n"; -PyObject* SCA_ISensor::PyIsPositive(PyObject* self, PyObject* args, PyObject* kwds) +"\tReturns whether the sensor is in an active state.\n"; +PyObject* SCA_ISensor::PyIsPositive(PyObject* self) { int retval = IsPositiveTrigger(); return PyInt_FromLong(retval); } +char SCA_ISensor::IsTriggered_doc[] = +"isTriggered()\n" +"\tReturns whether the sensor has triggered the current controller.\n"; +PyObject* SCA_ISensor::PyIsTriggered(PyObject* self) +{ + // check with the current controller + int retval = 0; + if (SCA_PythonController::m_sCurrentController) + retval = SCA_PythonController::m_sCurrentController->IsTriggered(this); + return PyInt_FromLong(retval); +} + /** * getUsePulseMode: getter for the pulse mode (KX_TRUE = on) */ diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index fc8f0bd0011..0d65270dc7b 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -34,6 +34,8 @@ #include "SCA_ILogicBrick.h" +#include + /** * Interface Class for all logic Sensors. Implements * pulsemode,pulsefrequency */ @@ -73,9 +75,9 @@ class SCA_ISensor : public SCA_ILogicBrick /** number of connections to controller */ int m_links; - /** Pass the activation on to the logic manager.*/ - void SignalActivation(class SCA_LogicManager* logicmgr); - + /** list of controllers that have just activated this sensor because of a state change */ + std::vector m_newControllers; + public: SCA_ISensor(SCA_IObject* gameobj, class SCA_EventManager* eventmgr, @@ -128,6 +130,8 @@ public: /** Resume sensing. */ void Resume(); + void AddNewController(class SCA_IController* controller) + { m_newControllers.push_back(controller); } void ClrLink() { m_links = 0; } void IncLink() @@ -137,7 +141,8 @@ public: { return !m_links; } /* Python functions: */ - KX_PYMETHOD_DOC(SCA_ISensor,IsPositive); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive); + KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsTriggered); KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUsePosPulseMode); KX_PYMETHOD_DOC(SCA_ISensor,SetUsePosPulseMode); KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetFrequency); diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index a7a6fa93db4..fba1162993d 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -505,7 +505,7 @@ PyObject* SCA_KeyboardSensor::sPySetAllMode(PyObject* self, PyObject* kwds) { // printf("sPyIsPositive\n"); - return ((SCA_KeyboardSensor*) self)->PyIsPositive(self, args, kwds); + return ((SCA_KeyboardSensor*) self)->PyIsPositive(self); } diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 91e66aea359..b584b37180f 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -33,6 +33,7 @@ #include "SCA_IController.h" #include "SCA_IActuator.h" #include "SCA_EventManager.h" +#include "SCA_PythonController.h" #include #ifdef HAVE_CONFIG_H @@ -232,8 +233,6 @@ void SCA_LogicManager::BeginFrame(double curtime, double fixedtime) // for this frame, look up for activated sensors, and build the collection of triggered controllers // int numsensors = this->m_activatedsensors.size(); /*unused*/ - set triggeredControllerSet; - for (vector::const_iterator is=m_activatedsensors.begin(); !(is==m_activatedsensors.end());is++) { @@ -244,19 +243,28 @@ void SCA_LogicManager::BeginFrame(double curtime, double fixedtime) { SCA_IController* contr = *c;//controllerarray->at(c); if (contr->IsActive()) - triggeredControllerSet.insert(SmartControllerPtr(contr,0)); + { + m_triggeredControllerSet.insert(SmartControllerPtr(contr,0)); + // So that the controller knows which sensor has activited it. + // Only needed for the python controller though. + if (contr->GetType() == &SCA_PythonController::Type) + { + SCA_PythonController* pythonController = (SCA_PythonController*)contr; + pythonController->AddTriggeredSensor(sensor); + } + } } //sensor->SetActive(false); } // int numtriggered = triggeredControllerSet.size(); /*unused*/ - for (set::iterator tit=triggeredControllerSet.begin(); - !(tit==triggeredControllerSet.end());tit++) + for (set::iterator tit=m_triggeredControllerSet.begin(); + !(tit==m_triggeredControllerSet.end());tit++) { (*tit)->Trigger(this); } - triggeredControllerSet.clear(); + m_triggeredControllerSet.clear(); } @@ -382,6 +390,17 @@ void SCA_LogicManager::AddActivatedSensor(SCA_ISensor* sensor) } } +void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor) +{ + m_triggeredControllerSet.insert(SmartControllerPtr(controller,0)); + // so that the controller knows which sensor has activited it + // only needed for python controller + if (controller->GetType() == &SCA_PythonController::Type) + { + SCA_PythonController* pythonController = (SCA_PythonController*)controller; + pythonController->AddTriggeredSensor(sensor); + } +} void SCA_LogicManager::AddActiveActuator(SCA_IActuator* actua,CValue* event) diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index e0d3d506702..50383879d8f 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -99,6 +99,7 @@ class SCA_LogicManager vector m_activatedsensors; set m_activeActuators; + set m_triggeredControllerSet; map m_sensorcontrollermapje; @@ -127,6 +128,7 @@ public: void EndFrame(); void AddActivatedSensor(SCA_ISensor* sensor); void AddActiveActuator(SCA_IActuator* sensor,class CValue* event); + void AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor); SCA_EventManager* FindEventManager(int eventmgrtype); void RemoveGameObject(const STR_String& gameobjname); diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index f9081c90288..e6f7b1dd143 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -35,6 +35,7 @@ #include "SCA_IActuator.h" #include "compile.h" #include "eval.h" +#include #ifdef HAVE_CONFIG_H #include @@ -139,6 +140,14 @@ void SCA_PythonController::SetDictionary(PyObject* pythondictionary) m_pythondictionary = PyDict_Copy(pythondictionary); /* new reference */ } +int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor) +{ + if (std::find(m_triggeredSensors.begin(), m_triggeredSensors.end(), sensor) != + m_triggeredSensors.end()) + return 1; + return 0; +} + #if 0 static char* sPyGetCurrentController__doc__; #endif @@ -294,7 +303,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) // something in this dictionary and crash? PyDict_Clear(excdict); Py_DECREF(excdict); - + m_triggeredSensors.erase(m_triggeredSensors.begin(), m_triggeredSensors.end()); m_sCurrentController = NULL; } diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 39b6c68c359..1b62e7ecb53 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -36,6 +36,8 @@ #include "SCA_LogicManager.h" #include "BoolValue.h" +#include + class SCA_IObject; class SCA_PythonController : public SCA_IController { @@ -47,6 +49,7 @@ class SCA_PythonController : public SCA_IController STR_String m_scriptText; STR_String m_scriptName; PyObject* m_pythondictionary; + std::vector m_triggeredSensors; public: static SCA_PythonController* m_sCurrentController; // protected !!! @@ -64,6 +67,9 @@ class SCA_PythonController : public SCA_IController void SetScriptText(const STR_String& text); void SetScriptName(const STR_String& name); void SetDictionary(PyObject* pythondictionary); + void AddTriggeredSensor(class SCA_ISensor* sensor) + { m_triggeredSensors.push_back(sensor); } + int IsTriggered(class SCA_ISensor* sensor); static char* sPyGetCurrentController__doc__; static PyObject* sPyGetCurrentController(PyObject* self); diff --git a/source/gameengine/PyDoc/SCA_ISensor.py b/source/gameengine/PyDoc/SCA_ISensor.py index 33f0e976284..14858505e24 100644 --- a/source/gameengine/PyDoc/SCA_ISensor.py +++ b/source/gameengine/PyDoc/SCA_ISensor.py @@ -9,7 +9,12 @@ class SCA_ISensor(SCA_ILogicBrick): def isPositive(): """ - True if this sensor brick has been activated. + True if this sensor brick is in a positive state. + """ + + def isTriggered(): + """ + True if this sensor brick has triggered the current controller. """ def getUsePosPulseMode(): -- cgit v1.2.3 From b5d254445ceb889dfb146a134b8ec5b638b4a9d2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 25 Aug 2008 09:52:38 +0000 Subject: getting the last created object would return an object that had no SG_Node which would crash whenever python tried to get its location. since the object was removed from the scene anyway, there is no reason to return it. --- source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index ca0106d64d9..7e0d0df1ab7 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -377,7 +377,10 @@ PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self, PyObject* kwds) { SCA_IObject* result = this->GetLastCreatedObject(); - if (result) + + // if result->GetSGNode() is NULL + // it means the object has ended, The BGE python api crashes in many places if the object is returned. + if (result && (static_cast(result))->GetSGNode()) { result->AddRef(); return result; -- cgit v1.2.3 From b81bdfdc7c7aea0daea5a5c3549ef7ccf757d49e Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 25 Aug 2008 19:50:17 +0000 Subject: TLC needed for Makefiles to get gameengine compiling again. Sorry it took me so long to do this :) Kent --- source/gameengine/Ketsji/Makefile | 4 +++- source/gameengine/Physics/Bullet/Makefile | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index 47a4855b00c..59cc6c8ca7e 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -38,7 +38,9 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += $(OGL_CPPFLAGS) CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) -CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -I../../blender/python +CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) +CPPFLAGS += -I../../blender/python +CPPFLAGS += -I../../blender/python/api2_2x CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include diff --git a/source/gameengine/Physics/Bullet/Makefile b/source/gameengine/Physics/Bullet/Makefile index 49259d0a67c..d5570e75833 100644 --- a/source/gameengine/Physics/Bullet/Makefile +++ b/source/gameengine/Physics/Bullet/Makefile @@ -37,5 +37,10 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I$(NAN_BULLET2)/include CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include +CPPFLAGS += -I$(NAN_STRING)/include +CPPFLAGS += -I$(NAN_MOTO)/include +CPPFLAGS += -I../../../kernel/gen_system CPPFLAGS += -I../../Physics/common CPPFLAGS += -I../../Physics/Dummy +CPPFLAGS += -I../../Rasterizer + -- cgit v1.2.3 From 6778c8dc2914e5714f0211d0643c1ade34864d02 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 27 Aug 2008 01:03:55 +0000 Subject: BGE: allow sound actuators to be converted even when they have invalid samples without this, an incorrect sound path could cause scripts to to fail, making some functionality not work at all. This also fixes a problem where samples would be loaded multiple times. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 139 ++++++++++++--------- source/gameengine/Converter/KX_ConvertSensors.cpp | 12 +- 2 files changed, 85 insertions(+), 66 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index b1f86afa4ee..e71928b8cee 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -355,22 +355,26 @@ void BL_ConvertActuators(char* maggiename, if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF) { - SND_SoundObject* sndobj = NULL; + SND_Scene* soundscene = scene->GetSoundScene(); + STR_String samplename = ""; + bool sampleisloaded = false; - if (soundact->sound) - { - SND_Scene* soundscene = scene->GetSoundScene(); - STR_String samplename = soundact->sound->name; + if (soundact->sound) { + /* Need to convert the samplename into absolute path + * before checking if its loaded */ + char fullpath[sizeof(soundact->sound->name)]; - bool sampleisloaded = false; + /* dont modify soundact->sound->name, only change a copy */ + BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath)); + BLI_convertstringcode(fullpath, maggiename); + samplename = fullpath; /* let's see if the sample was already loaded */ if (soundscene->IsSampleLoaded(samplename)) { sampleisloaded = true; } - else - { + else { /* if not, make it so */ PackedFile* pf = soundact->sound->newpackedfile; @@ -383,65 +387,80 @@ void BL_ConvertActuators(char* maggiename, /* or else load it from disk */ else { - /* but we need to convert the samplename into absolute pathname first */ - char fullpath[sizeof(soundact->sound->name)]; - - /* dont modify soundact->sound->name, only change a copy */ - BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath)); - BLI_convertstringcode(fullpath, maggiename); - samplename = fullpath; - - /* and now we can load it */ - if (soundscene->LoadSample(samplename, NULL, 0) > -1) + if (soundscene->LoadSample(samplename, NULL, 0) > -1) { sampleisloaded = true; + } + else { + std::cout << "WARNING: Sound actuator \"" << bact->name << + "\" from object \"" << blenderobject->id.name+2 << + "\" failed to load sample." << std::endl; + } } } - - if (sampleisloaded) + } else { + std::cout << "WARNING: Sound actuator \"" << bact->name << + "\" from object \"" << blenderobject->id.name+2 << + "\" has no sound datablock." << std::endl; + } + + /* Note, allowing actuators for sounds that are not there was added since 2.47 + * This is because python may expect the actuator and raise an exception if it dosnt find it + * better just to add a dummy sound actuator. */ + /*if (sampleisloaded)*/ + + /* setup the SND_SoundObject */ + SND_SoundObject* sndobj = new SND_SoundObject(); + sndobj->SetSampleName(samplename.Ptr()); + sndobj->SetObjectName(bact->name); + if (soundact->sound) { + sndobj->SetRollOffFactor(soundact->sound->attenuation); + sndobj->SetGain(soundact->sound->volume); + sndobj->SetPitch(exp((soundact->sound->pitch / 12.0) * log(2.0))); + // sndobj->SetLoopStart(soundact->sound->loopstart); + // sndobj->SetLoopStart(soundact->sound->loopend); + if (soundact->sound->flags & SOUND_FLAGS_LOOP) { - sndobj = new SND_SoundObject(); - sndobj->SetSampleName(samplename.Ptr()); - sndobj->SetObjectName(bact->name); - sndobj->SetRollOffFactor(soundact->sound->attenuation); - sndobj->SetGain(soundact->sound->volume); - sndobj->SetPitch(exp((soundact->sound->pitch / 12.0) * log(2.0))); - // sndobj->SetLoopStart(soundact->sound->loopstart); - // sndobj->SetLoopStart(soundact->sound->loopend); - if (soundact->sound->flags & SOUND_FLAGS_LOOP) - { - if (soundact->sound->flags & SOUND_FLAGS_BIDIRECTIONAL_LOOP) - sndobj->SetLoopMode(SND_LOOP_BIDIRECTIONAL); - else - sndobj->SetLoopMode(SND_LOOP_NORMAL); - } - else - sndobj->SetLoopMode(SND_LOOP_OFF); - - if (soundact->sound->flags & SOUND_FLAGS_PRIORITY) - sndobj->SetHighPriority(true); + if (soundact->sound->flags & SOUND_FLAGS_BIDIRECTIONAL_LOOP) + sndobj->SetLoopMode(SND_LOOP_BIDIRECTIONAL); else - sndobj->SetHighPriority(false); - - if (soundact->sound->flags & SOUND_FLAGS_3D) - sndobj->Set3D(true); - else - sndobj->Set3D(false); - - KX_SoundActuator* tmpsoundact = - new KX_SoundActuator(gameobj, - sndobj, - scene->GetSoundScene(), // needed for replication! - soundActuatorType, - startFrame, - stopFrame); - - tmpsoundact->SetName(bact->name); - baseact = tmpsoundact; - soundscene->AddObject(sndobj); - } else { - std::cout << "WARNING: Sound actuator " << bact->name << " failed to load sample." << std::endl; + sndobj->SetLoopMode(SND_LOOP_NORMAL); + } + else { + sndobj->SetLoopMode(SND_LOOP_OFF); } + + if (soundact->sound->flags & SOUND_FLAGS_PRIORITY) + sndobj->SetHighPriority(true); + else + sndobj->SetHighPriority(false); + + if (soundact->sound->flags & SOUND_FLAGS_3D) + sndobj->Set3D(true); + else + sndobj->Set3D(false); } + else { + /* dummy values for a NULL sound + * see editsound.c - defaults are unlikely to change soon */ + sndobj->SetRollOffFactor(1.0); + sndobj->SetGain(1.0); + sndobj->SetPitch(1.0); + sndobj->SetLoopMode(SND_LOOP_OFF); + sndobj->SetHighPriority(false); + sndobj->Set3D(false); + } + + KX_SoundActuator* tmpsoundact = + new KX_SoundActuator(gameobj, + sndobj, + scene->GetSoundScene(), // needed for replication! + soundActuatorType, + startFrame, + stopFrame); + + tmpsoundact->SetName(bact->name); + baseact = tmpsoundact; + soundscene->AddObject(sndobj); } break; } diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 4806df36090..98e078ccf8d 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -765,17 +765,17 @@ void BL_ConvertSensors(struct Object* blenderobject, logicmgr->RegisterToSensor(gamecont,gamesensor); } else { printf( - "Warning, sensor \"%s\" could not find its controller" - "(link %d of %d)\n" + "Warning, sensor \"%s\" could not find its controller " + "(link %d of %d) from object \"%s\"\n" "\tthere has been an error converting the blender controller for the game engine," - "logic may be incorrect\n", sens->name, i+1, sens->totlinks); + "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2); } } else { printf( - "Warning, sensor \"%s\" has lost a link to a controller" - "(link %d of %d)\n" + "Warning, sensor \"%s\" has lost a link to a controller " + "(link %d of %d) from object \"%s\"\n" "\tpossible causes are partially appended objects or an error reading the file," - "logic may be incorrect\n", sens->name, i+1, sens->totlinks); + "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2); } } // done with gamesensor -- cgit v1.2.3 From d5667656353a6ce8247d1e1c125471688c679bd8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 27 Aug 2008 03:34:53 +0000 Subject: get/set Angular velocity for KX_GameObjects python api and for the AddObject actuator. Needed so objects created in an explosion could start spinning without having motion actuators and collision sensors on each item. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 14 ++- source/gameengine/Expressions/PyObjectPlus.h | 6 ++ source/gameengine/Ketsji/KX_GameObject.cpp | 55 ++++++---- source/gameengine/Ketsji/KX_GameObject.h | 14 +-- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 115 ++++++++++++++------- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.h | 30 ++++-- source/gameengine/PyDoc/KX_GameObject.py | 20 ++++ .../gameengine/PyDoc/KX_SCA_AddObjectActuator.py | 17 +++ 8 files changed, 194 insertions(+), 77 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index e71928b8cee..9ec8bdd91fc 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -573,10 +573,16 @@ void BL_ConvertActuators(char* maggiename, originalval = converter->FindGameObject(editobact->ob); } } - MT_Vector3 linvelvec ( KX_BLENDERTRUNC(editobact->linVelocity[0]), + MT_Vector3 linvelvec ( + KX_BLENDERTRUNC(editobact->linVelocity[0]), KX_BLENDERTRUNC(editobact->linVelocity[1]), KX_BLENDERTRUNC(editobact->linVelocity[2])); - + + MT_Vector3 angvelvec ( + KX_BLENDERTRUNC(editobact->angVelocity[0]), + KX_BLENDERTRUNC(editobact->angVelocity[1]), + KX_BLENDERTRUNC(editobact->angVelocity[2])); + KX_SCA_AddObjectActuator* tmpaddact = new KX_SCA_AddObjectActuator( gameobj, @@ -584,7 +590,9 @@ void BL_ConvertActuators(char* maggiename, editobact->time, scene, linvelvec.getValue(), - editobact->localflag!=0 + (editobact->localflag & ACT_EDOB_LOCAL_LINV)!=0, + angvelvec.getValue(), + (editobact->localflag & ACT_EDOB_LOCAL_ANGV)!=0 ); //editobact->ob to gameobj diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index f433a08faba..deb47322d49 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -102,6 +102,12 @@ static inline void Py_Fatal(char *M) { return ((class_name*) self)->Py##method_name(self, args, kwds); \ }; \ +#define KX_PYMETHOD_VARARGS(class_name, method_name) \ + PyObject* Py##method_name(PyObject* self, PyObject* args); \ + static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \ + return ((class_name*) self)->Py##method_name(self, args); \ + }; \ + #define KX_PYMETHOD_NOARGS(class_name, method_name) \ PyObject* Py##method_name(PyObject* self); \ static PyObject* sPy##method_name( PyObject* self) { \ diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 700cc00e996..010ee1ebae9 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -885,6 +885,8 @@ PyMethodDef KX_GameObject::Methods[] = { {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_O}, {"getLinearVelocity", (PyCFunction) KX_GameObject::sPyGetLinearVelocity, METH_VARARGS}, {"setLinearVelocity", (PyCFunction) KX_GameObject::sPySetLinearVelocity, METH_VARARGS}, + {"getAngularVelocity", (PyCFunction) KX_GameObject::sPyGetAngularVelocity, METH_VARARGS}, + {"setAngularVelocity", (PyCFunction) KX_GameObject::sPySetAngularVelocity, METH_VARARGS}, {"getVelocity", (PyCFunction) KX_GameObject::sPyGetVelocity, METH_VARARGS}, {"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_NOARGS}, {"getReactionForce", (PyCFunction) KX_GameObject::sPyGetReactionForce, METH_NOARGS}, @@ -1146,9 +1148,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr } -PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, PyObject* args) { // only can get the velocity if we have a physics object connected to us... int local = 0; @@ -1162,9 +1162,7 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, } } -PyObject* KX_GameObject::PySetLinearVelocity(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PySetLinearVelocity(PyObject* self, PyObject* args) { int local = 0; PyObject* pyvect; @@ -1179,6 +1177,35 @@ PyObject* KX_GameObject::PySetLinearVelocity(PyObject* self, return NULL; } +PyObject* KX_GameObject::PyGetAngularVelocity(PyObject* self, PyObject* args) +{ + // only can get the velocity if we have a physics object connected to us... + int local = 0; + if (PyArg_ParseTuple(args,"|i",&local)) + { + return PyObjectFrom(GetAngularVelocity((local!=0))); + } + else + { + return NULL; + } +} + +PyObject* KX_GameObject::PySetAngularVelocity(PyObject* self, PyObject* args) +{ + int local = 0; + PyObject* pyvect; + + if (PyArg_ParseTuple(args,"O|i",&pyvect,&local)) { + MT_Vector3 velocity; + if (PyVecTo(pyvect, velocity)) { + setAngularVelocity(velocity, (local!=0)); + Py_RETURN_NONE; + } + } + return NULL; +} + PyObject* KX_GameObject::PySetVisible(PyObject* self, PyObject* value) { int visible = PyInt_AsLong(value); @@ -1228,9 +1255,7 @@ PyObject* KX_GameObject::PySetState(PyObject* self, PyObject* value) -PyObject* KX_GameObject::PyGetVelocity(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetVelocity(PyObject* self, PyObject* args) { // only can get the velocity if we have a physics object connected to us... MT_Vector3 velocity(0.0,0.0,0.0); @@ -1362,9 +1387,7 @@ PyObject* KX_GameObject::PyGetChildrenRecursive(PyObject* self) return list; } -PyObject* KX_GameObject::PyGetMesh(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyGetMesh(PyObject* self, PyObject* args) { int mesh = 0; @@ -1404,9 +1427,7 @@ PyObject* KX_GameObject::PySetCollisionMargin(PyObject* self, PyObject* value) -PyObject* KX_GameObject::PyApplyImpulse(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyApplyImpulse(PyObject* self, PyObject* args) { PyObject* pyattach; PyObject* pyimpulse; @@ -1477,9 +1498,7 @@ PyObject* KX_GameObject::PySetOrientation(PyObject* self, PyObject* value) return NULL; } -PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, PyObject* args) { PyObject* pyvect; int axis = 2; //z axis is the default diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index a7ac2d75a93..06171905220 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -726,9 +726,11 @@ public: KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition); KX_PYMETHOD_O(KX_GameObject,SetPosition); - KX_PYMETHOD(KX_GameObject,GetLinearVelocity); - KX_PYMETHOD(KX_GameObject,SetLinearVelocity); - KX_PYMETHOD(KX_GameObject,GetVelocity); + KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity); + KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity); + KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity); + KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity); + KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity); KX_PYMETHOD_NOARGS(KX_GameObject,GetMass); KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce); KX_PYMETHOD_NOARGS(KX_GameObject,GetOrientation); @@ -737,20 +739,20 @@ public: KX_PYMETHOD_O(KX_GameObject,SetVisible); KX_PYMETHOD_NOARGS(KX_GameObject,GetState); KX_PYMETHOD_O(KX_GameObject,SetState); - KX_PYMETHOD(KX_GameObject,AlignAxisToVect); + KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect); KX_PYMETHOD_O(KX_GameObject,GetAxisVect); KX_PYMETHOD_NOARGS(KX_GameObject,SuspendDynamics); KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics); KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody); KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody); - KX_PYMETHOD(KX_GameObject,ApplyImpulse); + KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse); KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin); KX_PYMETHOD_NOARGS(KX_GameObject,GetParent); KX_PYMETHOD_O(KX_GameObject,SetParent); KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent); KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren); KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive); - KX_PYMETHOD(KX_GameObject,GetMesh); + KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh); KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId); KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames); KX_PYMETHOD_NOARGS(KX_GameObject,EndObject); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 7e0d0df1ab7..a7330b9a20a 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -52,14 +52,20 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj, int time, SCA_IScene* scene, const MT_Vector3& linvel, - bool local, + bool linv_local, + const MT_Vector3& angvel, + bool angv_local, PyTypeObject* T) : SCA_IActuator(gameobj, T), m_OriginalObject(original), m_scene(scene), + m_linear_velocity(linvel), - m_localFlag(local) + m_localLinvFlag(linv_local), + + m_angular_velocity(angvel), + m_localAngvFlag(angv_local) { if (m_OriginalObject) m_OriginalObject->RegisterActuator(this); @@ -181,13 +187,15 @@ PyParentObject KX_SCA_AddObjectActuator::Parents[] = { }; PyMethodDef KX_SCA_AddObjectActuator::Methods[] = { {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, SetObject_doc}, - {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_VARARGS, SetTime_doc}, + {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, SetTime_doc}, {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, - {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_VARARGS, GetTime_doc}, - {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_VARARGS, GetLinearVelocity_doc}, + {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, GetTime_doc}, + {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, GetLinearVelocity_doc}, {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, SetLinearVelocity_doc}, - {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_VARARGS,"getLastCreatedObject() : get the object handle to the last created object\n"}, - {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_VARARGS,"instantAddObject() : immediately add object without delay\n"}, + {"getAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetAngularVelocity, METH_NOARGS, GetAngularVelocity_doc}, + {"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, SetAngularVelocity_doc}, + {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_NOARGS,"getLastCreatedObject() : get the object handle to the last created object\n"}, + {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS,"instantAddObject() : immediately add object without delay\n"}, {NULL,NULL} //Sentinel }; @@ -231,19 +239,18 @@ char KX_SCA_AddObjectActuator::SetTime_doc[] = "\tIf the duration is negative, it is set to 0.\n"; -PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self, PyObject* value) { - int deltatime; - - if (!PyArg_ParseTuple(args, "i", &deltatime)) + int deltatime = PyInt_AsLong(value); + if (deltatime==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_TypeError, "expected an int"); return NULL; + } m_timeProp = deltatime; if (m_timeProp < 0) m_timeProp = 0; - Py_Return; + Py_RETURN_NONE; } @@ -254,9 +261,7 @@ char KX_SCA_AddObjectActuator::GetTime_doc[] = "\tReturns the lifetime of the object that will be added.\n"; -PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self) { return PyInt_FromLong(m_timeProp); } @@ -290,17 +295,13 @@ char KX_SCA_AddObjectActuator::GetLinearVelocity_doc[] = "\tReturns the linear velocity that will be assigned to \n" "\tthe created object.\n"; - - -PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self) { PyObject *retVal = PyList_New(3); - PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0])); - PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1])); - PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2])); + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2])); return retVal; } @@ -313,12 +314,10 @@ char KX_SCA_AddObjectActuator::SetLinearVelocity_doc[] = "\t- vx: float\n" "\t- vy: float\n" "\t- vz: float\n" +"\t- local: bool\n" "\tAssign this velocity to the created object. \n"; - -PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, PyObject* args) { float vecArg[3]; @@ -326,7 +325,46 @@ PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, return NULL; m_linear_velocity.setValue(vecArg); - Py_Return; + Py_RETURN_NONE; +} + +/* 7. getAngularVelocity */ +char KX_SCA_AddObjectActuator::GetAngularVelocity_doc[] = +"GetAngularVelocity()\n" +"\tReturns the angular velocity that will be assigned to \n" +"\tthe created object.\n"; + +PyObject* KX_SCA_AddObjectActuator::PyGetAngularVelocity(PyObject* self) +{ + PyObject *retVal = PyList_New(3); + + PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0])); + PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1])); + PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2])); + + return retVal; +} + + + +/* 8. setAngularVelocity */ +char KX_SCA_AddObjectActuator::SetAngularVelocity_doc[] = +"setAngularVelocity(vx, vy, vz)\n" +"\t- vx: float\n" +"\t- vy: float\n" +"\t- vz: float\n" +"\t- local: bool\n" +"\tAssign this angular velocity to the created object. \n"; + +PyObject* KX_SCA_AddObjectActuator::PySetAngularVelocity(PyObject* self, PyObject* args) +{ + + float vecArg[3]; + if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2])) + return NULL; + + m_angular_velocity.setValue(vecArg); + Py_RETURN_NONE; } void KX_SCA_AddObjectActuator::InstantAddObject() @@ -337,8 +375,9 @@ 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(replica); - game_obj->setLinearVelocity(m_linear_velocity,m_localFlag); - game_obj->ResolveCombinedVelocities(m_linear_velocity, MT_Vector3(0., 0., 0.), m_localFlag, false); + 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); // keep a copy of the last object, to allow python scripters to change it if (m_lastCreatedObject) @@ -355,13 +394,11 @@ void KX_SCA_AddObjectActuator::InstantAddObject() } } -PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self) { InstantAddObject(); - Py_Return; + Py_RETURN_NONE; } @@ -372,9 +409,7 @@ char KX_SCA_AddObjectActuator::GetLastCreatedObject_doc[] = "\tReturn the last created object. \n"; -PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self) { SCA_IObject* result = this->GetLastCreatedObject(); @@ -386,5 +421,5 @@ PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self, return result; } // don't return NULL to python anymore, it gives trouble in the scripts - Py_Return; + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index e7fdb2fbfbc..278d4180284 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -60,9 +60,13 @@ class KX_SCA_AddObjectActuator : public SCA_IActuator /// Linear velocity upon creation of the object. MT_Vector3 m_linear_velocity; + + /// Angular velocity upon creation of the object. + MT_Vector3 m_angular_velocity; /// Apply the velocity locally - bool m_localFlag; + bool m_localLinvFlag; + bool m_localAngvFlag; SCA_IObject* m_lastCreatedObject; @@ -79,7 +83,9 @@ public: int time, SCA_IScene* scene, const MT_Vector3& linvel, - bool local, + bool linv_local, + const MT_Vector3& angvel, + bool angv_local, PyTypeObject* T=&Type ); @@ -115,19 +121,23 @@ public: /* 1. setObject */ KX_PYMETHOD_DOC_O(KX_SCA_AddObjectActuator,SetObject); /* 2. setTime */ - KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetTime); + KX_PYMETHOD_DOC_O(KX_SCA_AddObjectActuator,SetTime); /* 3. getTime */ - KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetTime); + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetTime); /* 4. getObject */ KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,GetObject); /* 5. getLinearVelocity */ - KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetLinearVelocity); + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetLinearVelocity); /* 6. setLinearVelocity */ - KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetLinearVelocity); - /* 7. getLastCreatedObject */ - KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetLastCreatedObject); - /* 8. instantAddObject*/ - KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,InstantAddObject); + KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,SetLinearVelocity); + /* 7. getAngularVelocity */ + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetAngularVelocity); + /* 8. setAngularVelocity */ + KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,SetAngularVelocity); + /* 9. getLastCreatedObject */ + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetLastCreatedObject); + /* 10. instantAddObject*/ + KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,InstantAddObject); }; /* end of class KX_SCA_AddObjectActuator : public KX_EditObjectActuator */ diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index a5ba5b1d634..033b2864351 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -135,6 +135,26 @@ class KX_GameObject: @param local: - False: you get the "global" velocity ie: relative to world orientation (default). - True: you get the "local" velocity ie: relative to object orientation. """ + def getAngularVelocity(local = 0): + """ + Gets the game object's angular velocity. + + @type local: boolean + @param local: - False: you get the "global" velocity ie: relative to world orientation (default). + - True: you get the "local" velocity ie: relative to object orientation. + @rtype: list [vx, vy, vz] + @return: the object's angular velocity. + """ + def setAngularVelocity(velocity, local = 0): + """ + Sets the game object's angular velocity. + + @type velocity: 3d vector. + @param velocity: angular velocity vector. + @type local: boolean + @param local: - False: you get the "global" velocity ie: relative to world orientation (default). + - True: you get the "local" velocity ie: relative to object orientation. + """ def getVelocity(point): """ Gets the game object's velocity at the specified point. diff --git a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py index 4f2bf85bff3..c3b2e947ddb 100644 --- a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py +++ b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py @@ -64,6 +64,23 @@ class KX_SCA_AddObjectActuator(SCA_IActuator): """ Returns the initial linear velocity of added objects. + @rtype: list [vx, vy, vz] + """ + def setAngularVelocity(vx, vy, vz): + """ + Sets the initial angular velocity of added objects. + + @type vx: float + @param vx: the x component of the initial angular velocity. + @type vy: float + @param vy: the y component of the initial angular velocity. + @type vz: float + @param vz: the z component of the initial angular velocity. + """ + def getAngularVelocity(): + """ + Returns the initial angular velocity of added objects. + @rtype: list [vx, vy, vz] """ def getLastCreatedObject(): -- cgit v1.2.3 From 6cccdf0cb2602b46e9c1e0a0a7f40853626735cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 27 Aug 2008 06:02:10 +0000 Subject: BGE bugfix, ipo actuator's foce option didnt check that the object was dynamic. --- source/gameengine/Ketsji/KX_IPO_SGController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index d3aa924665e..6223643f75a 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -143,7 +143,7 @@ bool KX_IpoSGController::Update(double currentTime) { if (m_ipo_as_force == true) { - if (m_game_object && ob) + if (m_game_object && ob && m_game_object->GetPhysicsController()) { m_game_object->GetPhysicsController()->ApplyForce(m_ipo_local ? ob->GetWorldOrientation() * m_ipo_xform.GetPosition() : -- cgit v1.2.3 From becd467be8613b1f71278d8a58337186a3f79170 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 27 Aug 2008 19:34:19 +0000 Subject: BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information. rayCast(to,from,dist,prop,face,xray,poly): The face paremeter determines the orientation of the normal: 0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside) 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect) The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray. The prop and xray parameters interact as follow: prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray. prop off, xray on : idem. prop on, xray off: return closest hit if it matches prop, no hit otherwise. prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray. if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit. if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element. The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc. Attributes (read-only): matname: The name of polygon material, empty if no material. material: The material of the polygon texture: The texture name of the polygon. matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex use this to retrieve vertex proxy from mesh proxy visible: visible state of the polygon: 1=visible, 0=invisible collide: collide state of the polygon: 1=receives collision, 0=collision free. Methods: getMaterialName(): Returns the polygon material name with MA prefix getMaterial(): Returns the polygon material getTextureName(): Returns the polygon texture name getMaterialIndex(): Returns the material bucket index of the polygon. getNumVertex(): Returns the number of vertex of the polygon. isVisible(): Returns whether the polygon is visible or not isCollider(): Returns whether the polygon is receives collision or not getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex getMesh(): Returns a mesh proxy New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects: getNumPolygons(): Returns the number of polygon in the mesh. getPolygon(index): Gets the specified polygon from the mesh. More details in PyDoc. --- .../BlenderRoutines/KX_BlenderRenderTools.cpp | 10 +- .../BlenderRoutines/KX_BlenderRenderTools.h | 4 +- source/gameengine/Expressions/PyObjectPlus.h | 6 + .../GamePlayer/common/GPC_RenderTools.cpp | 10 +- .../gameengine/GamePlayer/common/GPC_RenderTools.h | 5 +- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 50 ++-- source/gameengine/Ketsji/KX_ConstraintActuator.h | 5 +- source/gameengine/Ketsji/KX_GameObject.cpp | 101 ++++++-- source/gameengine/Ketsji/KX_GameObject.h | 5 +- source/gameengine/Ketsji/KX_MeshProxy.cpp | 31 +++ source/gameengine/Ketsji/KX_MeshProxy.h | 2 + source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 16 +- source/gameengine/Ketsji/KX_MouseFocusSensor.h | 6 +- source/gameengine/Ketsji/KX_PolyProxy.cpp | 265 +++++++++++++++++++++ source/gameengine/Ketsji/KX_PolyProxy.h | 71 ++++++ source/gameengine/Ketsji/KX_RayCast.cpp | 85 ++++--- source/gameengine/Ketsji/KX_RayCast.h | 60 +++-- source/gameengine/Ketsji/KX_RaySensor.cpp | 41 ++-- source/gameengine/Ketsji/KX_RaySensor.h | 4 +- .../Physics/BlOde/OdePhysicsEnvironment.cpp | 3 +- .../Physics/BlOde/OdePhysicsEnvironment.h | 3 +- .../Physics/Bullet/CcdPhysicsController.cpp | 5 + .../Physics/Bullet/CcdPhysicsController.h | 15 ++ .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 95 ++++++-- .../Physics/Bullet/CcdPhysicsEnvironment.h | 3 +- .../Physics/Dummy/DummyPhysicsEnvironment.cpp | 3 +- .../Physics/Dummy/DummyPhysicsEnvironment.h | 3 +- .../Physics/Sumo/SumoPhysicsEnvironment.cpp | 31 ++- .../Physics/Sumo/SumoPhysicsEnvironment.h | 3 +- .../Physics/common/PHY_IPhysicsEnvironment.h | 47 +++- source/gameengine/PyDoc/KX_GameObject.py | 33 ++- source/gameengine/PyDoc/KX_MeshProxy.py | 15 ++ source/gameengine/PyDoc/KX_PolyProxy.py | 100 ++++++++ source/gameengine/Rasterizer/RAS_MeshObject.cpp | 2 +- source/gameengine/Rasterizer/RAS_MeshObject.h | 2 +- 35 files changed, 929 insertions(+), 211 deletions(-) create mode 100644 source/gameengine/Ketsji/KX_PolyProxy.cpp create mode 100644 source/gameengine/Ketsji/KX_PolyProxy.h create mode 100644 source/gameengine/PyDoc/KX_PolyProxy.py (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index e4eff163d5b..f4a1f3a5b26 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -131,11 +131,11 @@ void KX_BlenderRenderTools::SetClientObject(void* obj) } } -bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) +bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data) { double* const oglmatrix = (double* const) data; - MT_Point3 resultpoint(hit_point); - MT_Vector3 resultnormal(hit_normal); + MT_Point3 resultpoint(result->m_hitPoint); + MT_Vector3 resultnormal(result->m_hitNormal); MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]); MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized(); left = (dir.cross(resultnormal)).safe_normalized(); @@ -236,9 +236,7 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat if (parent) parent->Release(); - MT_Point3 resultpoint; - MT_Vector3 resultnormal; - if (!KX_RayCast::RayTest(physics_controller, physics_environment, frompoint, topoint, resultpoint, resultnormal, KX_RayCast::Callback(this, oglmatrix))) + if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, KX_RayCast::Callback(this, physics_controller, oglmatrix))) { // couldn't find something to cast the shadow on... glMultMatrixd(oglmatrix); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 8abce1b8c3e..8027136aa52 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -37,6 +37,7 @@ #include "RAS_IRenderTools.h" struct KX_ClientObjectInfo; +class KX_RayCast; /** BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which are not @@ -97,7 +98,8 @@ public: void* clientobject, void* tface); - bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); + bool RayHit(KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data); + bool NeedRayCast(KX_ClientObjectInfo*) { return true; } virtual void MotionBlur(RAS_IRasterizer* rasterizer); diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index deb47322d49..65cd4e890f7 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -156,6 +156,9 @@ static inline void Py_Fatal(char *M) { #define KX_PYMETHODTABLE(class_name, method_name) \ {#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, class_name::method_name##_doc} +#define KX_PYMETHODTABLE_NOARG(class_name, method_name) \ + {#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, class_name::method_name##_doc} + /** * Function implementation macro */ @@ -163,6 +166,9 @@ static inline void Py_Fatal(char *M) { char class_name::method_name##_doc[] = doc_string; \ PyObject* class_name::Py##method_name(PyObject*, PyObject* args, PyObject*) +#define KX_PYMETHODDEF_DOC_NOARG(class_name, method_name, doc_string) \ +char class_name::method_name##_doc[] = doc_string; \ +PyObject* class_name::Py##method_name(PyObject*) /*------------------------------ * PyObjectPlus diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 8b828393c67..246466f59b8 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -470,11 +470,11 @@ void GPC_RenderTools::SetClientObject(void* obj) } } -bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) +bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data) { double* const oglmatrix = (double* const) data; - MT_Point3 resultpoint(hit_point); - MT_Vector3 resultnormal(hit_normal); + MT_Point3 resultpoint(result->m_hitPoint); + MT_Vector3 resultnormal(result->m_hitNormal); MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]); MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized(); left = (dir.cross(resultnormal)).safe_normalized(); @@ -563,9 +563,7 @@ void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,in if (parent) parent->Release(); - MT_Point3 resultpoint; - MT_Vector3 resultnormal; - if (!KX_RayCast::RayTest(physics_controller, physics_environment, frompoint, topoint, resultpoint, resultnormal, KX_RayCast::Callback(this, oglmatrix))) + if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, KX_RayCast::Callback(this, physics_controller, oglmatrix))) { // couldn't find something to cast the shadow on... glMultMatrixd(oglmatrix); diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index 8fae3d2b305..9f70f67caf2 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -41,7 +41,7 @@ #include "BMF_Api.h" struct KX_ClientObjectInfo; - +class KX_RayCast; class GPC_RenderTools : public RAS_IRenderTools { @@ -138,7 +138,8 @@ public: int applyLights(int objectlayer); - bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); + bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); + bool NeedRayCast(KX_ClientObjectInfo* client) { return true; } virtual void MotionBlur(RAS_IRasterizer* rasterizer); diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index e00ec68ad33..4b57b0e8c54 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -109,16 +109,11 @@ KX_ConstraintActuator::~KX_ConstraintActuator() // there's nothing to be done here, really.... } /* end of destructor */ -bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) +bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data) { KX_GameObject* hitKXObj = client->m_gameobject; - if (client->m_type > KX_ClientObjectInfo::ACTOR) - { - // false hit - return false; - } bool bFound = false; if (m_property[0] == 0) @@ -139,8 +134,26 @@ bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_p bFound = hitKXObj->GetProperty(m_property) != NULL; } } + // update the hit status + result->m_hitFound = bFound; + // stop looking + return true; +} - return bFound; +/* this function is used to pre-filter the object before casting the ray on them. + This is useful for "X-Ray" option when we want to see "through" unwanted object. + */ +bool KX_ConstraintActuator::NeedRayCast(KX_ClientObjectInfo* client) +{ + if (client->m_type > KX_ClientObjectInfo::ACTOR) + { + // Unknown type of object, skip it. + // Should not occur as the sensor objects are filtered in RayTest() + printf("Invalid client type %d found in ray casting\n", client->m_type); + return false; + } + // no X-Ray function yet + return true; } bool KX_ConstraintActuator::Update(double curtime, bool frame) @@ -287,8 +300,6 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) direction.normalize(); { MT_Point3 topoint = position + (m_maximumBound) * direction; - MT_Point3 resultpoint; - MT_Vector3 resultnormal; PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment(); KX_IPhysicsController *spc = obj->GetPhysicsController(); @@ -304,9 +315,10 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) parent->Release(); } } - result = KX_RayCast::RayTest(spc, pe, position, topoint, resultpoint, resultnormal, KX_RayCast::Callback(this)); - + KX_RayCast::Callback callback(this,spc); + result = KX_RayCast::RayTest(pe, position, topoint, callback); if (result) { + MT_Vector3 newnormal = callback.m_hitNormal; // compute new position & orientation if ((m_option & (KX_ACT_CONSTRAINT_NORMAL|KX_ACT_CONSTRAINT_DISTANCE)) == 0) { // if none option is set, the actuator does nothing but detect ray @@ -316,27 +328,27 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) if (m_option & KX_ACT_CONSTRAINT_NORMAL) { // the new orientation must be so that the axis is parallel to normal if (sign) - resultnormal = -resultnormal; + newnormal = -newnormal; // apply damping on the direction if (m_rotDampTime) { MT_Scalar rotFilter = 1.0/(1.0+m_rotDampTime); - resultnormal = (-m_rotDampTime*rotFilter)*direction + rotFilter*resultnormal; + newnormal = (-m_rotDampTime*rotFilter)*direction + rotFilter*newnormal; } else if (m_posDampTime) { - resultnormal = -filter*direction + (1.0-filter)*resultnormal; + newnormal = -filter*direction + (1.0-filter)*newnormal; } - obj->AlignAxisToVect(resultnormal, axis); - direction = -resultnormal; + obj->AlignAxisToVect(newnormal, axis); + direction = -newnormal; } if (m_option & KX_ACT_CONSTRAINT_DISTANCE) { if (m_posDampTime) { - newdistance = filter*(position-resultpoint).length()+(1.0-filter)*m_minimumBound; + newdistance = filter*(position-callback.m_hitPoint).length()+(1.0-filter)*m_minimumBound; } else { newdistance = m_minimumBound; } } else { - newdistance = (position-resultpoint).length(); + newdistance = (position-callback.m_hitPoint).length(); } - newposition = resultpoint-newdistance*direction; + newposition = callback.m_hitPoint-newdistance*direction; } else if (m_option & KX_ACT_CONSTRAINT_PERMANENT) { // no contact but still keep running result = true; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index d9f39124cac..6ec4de9aad9 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -37,6 +37,8 @@ #include "MT_Vector3.h" #include "KX_ClientObjectInfo.h" +class KX_RayCast; + class KX_ConstraintActuator : public SCA_IActuator { Py_Header; @@ -100,7 +102,8 @@ protected: KX_ACT_CONSTRAINT_DISTANCE = 512 }; bool IsValidMode(KX_CONSTRAINTTYPE m); - bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); + bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); + bool NeedRayCast(KX_ClientObjectInfo*); KX_ConstraintActuator(SCA_IObject* gameobj, int posDamptime, diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 010ee1ebae9..51322f8429e 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -51,6 +51,7 @@ typedef unsigned long uint_ptr; #include "KX_GameObject.h" #include "RAS_MeshObject.h" #include "KX_MeshProxy.h" +#include "KX_PolyProxy.h" #include // printf #include "SG_Controller.h" #include "KX_IPhysicsController.h" @@ -84,6 +85,7 @@ KX_GameObject::KX_GameObject( m_bVisible(true), m_pPhysicsController1(NULL), m_pPhysicsEnvironment(NULL), + m_xray(false), m_pHitObject(NULL), m_isDeformable(false) { @@ -1628,25 +1630,45 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo, return returnValue; } -bool KX_GameObject::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) +bool KX_GameObject::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data) { + KX_GameObject* hitKXObj = client->m_gameobject; + + // if X-ray option is selected, the unwnted objects were not tested, so get here only with true hit + // if not, all objects were tested and the front one may not be the correct one. + if (m_xray || m_testPropName.Length() == 0 || hitKXObj->GetProperty(m_testPropName) != NULL) + { + m_pHitObject = hitKXObj; + return true; + } + // return true to stop RayCast::RayTest from looping, the above test was decisive + // We would want to loop only if we want to get more than one hit point + return true; +} +/* this function is used to pre-filter the object before casting the ray on them. + This is useful for "X-Ray" option when we want to see "through" unwanted object. + */ +bool KX_GameObject::NeedRayCast(KX_ClientObjectInfo* client) +{ KX_GameObject* hitKXObj = client->m_gameobject; if (client->m_type > KX_ClientObjectInfo::ACTOR) { - // false hit + // Unknown type of object, skip it. + // Should not occur as the sensor objects are filtered in RayTest() + printf("Invalid client type %d found in ray casting\n", client->m_type); return false; } - - if (m_testPropName.Length() == 0 || hitKXObj->GetProperty(m_testPropName) != NULL) + + // if X-Ray option is selected, skip object that don't match the criteria as we see through them + // if not, test all objects because we don't know yet which one will be on front + if (!m_xray || m_testPropName.Length() == 0 || hitKXObj->GetProperty(m_testPropName) != NULL) { - m_pHitObject = hitKXObj; return true; } - + // skip the object return false; - } KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, @@ -1686,8 +1708,6 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, toPoint = fromPoint + (dist) * toDir; } - MT_Point3 resultPoint; - MT_Vector3 resultNormal; PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); @@ -1701,7 +1721,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, m_testPropName = propName; else m_testPropName.SetLength(0); - KX_RayCast::RayTest(spc, pe, fromPoint, toPoint, resultPoint, resultNormal, KX_RayCast::Callback(this)); + KX_RayCast::RayTest(pe, fromPoint, toPoint, KX_RayCast::Callback(this,spc)); if (m_pHitObject) { @@ -1712,13 +1732,24 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, } KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, - "rayCast(to,from,dist,prop): cast a ray and return tuple (object,hit,normal) of contact point with object within dist that matches prop or (None,None,None) tuple if no hit\n" -" prop = property name that object must have; can be omitted => detect any object\n" -" dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to to\n" + "rayCast(to,from,dist,prop,face,xray,poly): cast a ray and return 3-tuple (object,hit,normal) or 4-tuple (object,hit,normal,polygon) of contact point with object within dist that matches prop.\n" + " If no hit, return (None,None,None) or (None,None,None,None).\n" +" to = 3-tuple or object reference for destination of ray (if object, use center of object)\n" " from = 3-tuple or object reference for origin of ray (if object, use center of object)\n" " Can be None or omitted => start from self object center\n" -" to = 3-tuple or object reference for destination of ray (if object, use center of object)\n" -"Note: the object on which you call this method matters: the ray will ignore it if it goes through it\n") +" dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to to\n" +" prop = property name that object must have; can be omitted => detect any object\n" +" face = normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin\n" +" xray = X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object\n" +" poly = polygon option: 1=>return value is a 4-tuple and the 4th element is a KX_PolyProxy object\n" +" which can be None if hit object has no mesh or if there is no hit\n" +" If 0 or omitted, return value is a 3-tuple\n" +"Note: The object on which you call this method matters: the ray will ignore it.\n" +" prop and xray option interact as follow:\n" +" prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray\n" +" prop off, xray on : idem\n" +" prop on, xray off: return closest hit if it matches prop, no hit otherwise\n" +" prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray\n") { MT_Point3 toPoint; MT_Point3 fromPoint; @@ -1727,8 +1758,9 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, float dist = 0.0f; char *propName = NULL; KX_GameObject *other; + int face=0, xray=0, poly=0; - if (!PyArg_ParseTuple(args,"O|Ofs", &pyto, &pyfrom, &dist, &propName)) { + if (!PyArg_ParseTuple(args,"O|Ofsiii", &pyto, &pyfrom, &dist, &propName, &face, &xray, &poly)) { return NULL; // Python sets a simple error } @@ -1774,8 +1806,6 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, return Py_BuildValue("OOO", Py_None, Py_None, Py_None); } - MT_Point3 resultPoint; - MT_Vector3 resultNormal; PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent(); @@ -1789,20 +1819,41 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCast, m_testPropName = propName; else m_testPropName.SetLength(0); - KX_RayCast::RayTest(spc, pe, fromPoint, toPoint, resultPoint, resultNormal, KX_RayCast::Callback(this)); + m_xray = xray; + // to get the hit results + KX_RayCast::Callback callback(this,spc,NULL,face); + KX_RayCast::RayTest(pe, fromPoint, toPoint, callback); - if (m_pHitObject) + if (m_pHitObject) { - PyObject* returnValue = PyTuple_New(3); + PyObject* returnValue = (poly) ? PyTuple_New(4) : PyTuple_New(3); if (returnValue) { // unlikely this would ever fail, if it does python sets an error PyTuple_SET_ITEM(returnValue, 0, m_pHitObject->AddRef()); - PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(resultPoint)); - PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(resultNormal)); + PyTuple_SET_ITEM(returnValue, 1, PyObjectFrom(callback.m_hitPoint)); + PyTuple_SET_ITEM(returnValue, 2, PyObjectFrom(callback.m_hitNormal)); + if (poly) + { + if (callback.m_hitMesh) + { + // if this field is set, then we can trust that m_hitPolygon is a valid polygon + RAS_Polygon* poly = callback.m_hitMesh->GetPolygon(callback.m_hitPolygon); + KX_PolyProxy* polyproxy = new KX_PolyProxy(callback.m_hitMesh, poly); + PyTuple_SET_ITEM(returnValue, 3, polyproxy); + } + else + { + Py_INCREF(Py_None); + PyTuple_SET_ITEM(returnValue, 3, Py_None); + } + } } return returnValue; } - return Py_BuildValue("OOO", Py_None, Py_None, Py_None); - //Py_RETURN_NONE; + // no hit + if (poly) + return Py_BuildValue("OOOO", Py_None, Py_None, Py_None, Py_None); + else + return Py_BuildValue("OOO", Py_None, Py_None, Py_None); } /* --------------------------------------------------------------------- diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 06171905220..508bc7cdfd0 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -54,6 +54,7 @@ //Forward declarations. struct KX_ClientObjectInfo; +class KX_RayCast; class RAS_MeshObject; class KX_IPhysicsController; class PHY_IPhysicsEnvironment; @@ -88,6 +89,7 @@ protected: // used for ray casting PHY_IPhysicsEnvironment* m_pPhysicsEnvironment; STR_String m_testPropName; + bool m_xray; KX_GameObject* m_pHitObject; SG_Node* m_pSGNode; @@ -428,7 +430,8 @@ public: return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent()); } - bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); + bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); + bool NeedRayCast(KX_ClientObjectInfo* client); /** diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index a0ac9cfd4ff..29842af7fb6 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -35,6 +35,7 @@ #include "RAS_MeshObject.h" #include "KX_VertexProxy.h" +#include "KX_PolyProxy.h" #include "KX_PolygonMaterial.h" #include "KX_BlenderMaterial.h" @@ -71,10 +72,12 @@ PyParentObject KX_MeshProxy::Parents[] = { PyMethodDef KX_MeshProxy::Methods[] = { {"getNumMaterials", (PyCFunction)KX_MeshProxy::sPyGetNumMaterials,METH_VARARGS}, +{"getNumPolygons", (PyCFunction)KX_MeshProxy::sPyGetNumPolygons,METH_NOARGS}, {"getMaterialName", (PyCFunction)KX_MeshProxy::sPyGetMaterialName,METH_VARARGS}, {"getTextureName", (PyCFunction)KX_MeshProxy::sPyGetTextureName,METH_VARARGS}, {"getVertexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetVertexArrayLength,METH_VARARGS}, {"getVertex", (PyCFunction)KX_MeshProxy::sPyGetVertex,METH_VARARGS}, +{"getPolygon", (PyCFunction)KX_MeshProxy::sPyGetPolygon,METH_VARARGS}, KX_PYMETHODTABLE(KX_MeshProxy, reinstancePhysicsMesh), //{"getIndexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetIndexArrayLength,METH_VARARGS}, @@ -146,6 +149,12 @@ PyObject* KX_MeshProxy::PyGetNumMaterials(PyObject* self, return PyInt_FromLong(num); } +PyObject* KX_MeshProxy::PyGetNumPolygons(PyObject* self) +{ + int num = m_meshobj->NumPolygons(); + return PyInt_FromLong(num); +} + PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* self, PyObject* args, PyObject* kwds) @@ -234,6 +243,28 @@ PyObject* KX_MeshProxy::PyGetVertex(PyObject* self, } +PyObject* KX_MeshProxy::PyGetPolygon(PyObject* self, + PyObject* args, + PyObject* kwds) +{ + int polyindex= 1; + PyObject* polyob = NULL; + + if (!PyArg_ParseTuple(args,"i",&polyindex)) + return NULL; + + RAS_Polygon* polygon = m_meshobj->GetPolygon(polyindex); + if (polygon) + { + polyob = new KX_PolyProxy(m_meshobj, polygon); + } + else + { + PyErr_SetString(PyExc_AttributeError, "Invalid polygon index"); + } + return polyob; +} + KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh, "Reinstance the physics mesh.") { diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h index 7c6202c15a4..3335c349673 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.h +++ b/source/gameengine/Ketsji/KX_MeshProxy.h @@ -57,10 +57,12 @@ public: KX_PYMETHOD(KX_MeshProxy,GetNumMaterials); KX_PYMETHOD(KX_MeshProxy,GetMaterialName); KX_PYMETHOD(KX_MeshProxy,GetTextureName); + KX_PYMETHOD_NOARGS(KX_MeshProxy,GetNumPolygons); // both take materialid (int) KX_PYMETHOD(KX_MeshProxy,GetVertexArrayLength); KX_PYMETHOD(KX_MeshProxy,GetVertex); + KX_PYMETHOD(KX_MeshProxy,GetPolygon); KX_PYMETHOD_DOC(KX_MeshProxy, reinstancePhysicsMesh); }; diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index db0bef8b7e1..721bd4d44d6 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -122,16 +122,10 @@ bool KX_MouseFocusSensor::Evaluate(CValue* event) return result; } -bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) +bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, KX_RayCast* result, void * const data) { KX_GameObject* hitKXObj = client_info->m_gameobject; - if (client_info->m_type > KX_ClientObjectInfo::ACTOR) - { - // false hit - return false; - } - /* Is this me? In the ray test, there are a lot of extra checks * for aliasing artefacts from self-hits. That doesn't happen * here, so a simple test suffices. Or does the camera also get @@ -142,8 +136,8 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, MT_Point3& hi if ((m_focusmode == 2) || hitKXObj == thisObj) { m_hitObject = hitKXObj; - m_hitPosition = hit_point; - m_hitNormal = hit_normal; + m_hitPosition = result->m_hitPoint; + m_hitNormal = result->m_hitNormal; return true; } @@ -158,8 +152,6 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void) m_hitObject = 0; m_hitPosition = MT_Vector3(0,0,0); m_hitNormal = MT_Vector3(1,0,0); - MT_Point3 resultpoint; - MT_Vector3 resultnormal; /* All screen handling in the gameengine is done by GL, * specifically the model/view and projection parts. The viewport @@ -280,7 +272,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void) bool result = false; - result = KX_RayCast::RayTest(physics_controller, physics_environment, frompoint3, topoint3, resultpoint, resultnormal, KX_RayCast::Callback(this)); + KX_RayCast::RayTest(physics_environment, frompoint3, topoint3, KX_RayCast::Callback(this,physics_controller)); result = (m_hitObject!=0); diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index b011ebe1288..a6cc39d66eb 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -33,6 +33,8 @@ #include "SCA_MouseSensor.h" +class KX_RayCast; + /** * The mouse focus sensor extends the basic SCA_MouseSensor. It has * been placed in KX because it needs access to the rasterizer and @@ -76,7 +78,9 @@ class KX_MouseFocusSensor : public SCA_MouseSensor return result; }; - bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); + bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); + bool NeedRayCast(KX_ClientObjectInfo* client) { return true; } + /* --------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp new file mode 100644 index 00000000000..658c8a98e4f --- /dev/null +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -0,0 +1,265 @@ +/** + * $Id$ + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "KX_PolyProxy.h" +#include "KX_MeshProxy.h" +#include "RAS_MeshObject.h" +#include "KX_BlenderMaterial.h" +#include "KX_PolygonMaterial.h" + +#include "KX_PyMath.h" + +PyTypeObject KX_PolyProxy::Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "KX_PolyProxy", + sizeof(KX_PolyProxy), + 0, + PyDestructor, + 0, + __getattr, + __setattr, + 0, //&MyPyCompare, + __repr, + 0, //&cvalue_as_number, + 0, + 0, + 0, + 0 +}; + +PyParentObject KX_PolyProxy::Parents[] = { + &KX_PolyProxy::Type, + &SCA_IObject::Type, + &CValue::Type, + NULL +}; + +PyMethodDef KX_PolyProxy::Methods[] = { + KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterialIndex), + KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getNumVertex), + KX_PYMETHODTABLE_NOARG(KX_PolyProxy,isVisible), + KX_PYMETHODTABLE_NOARG(KX_PolyProxy,isCollider), + KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterialName), + KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getTextureName), + KX_PYMETHODTABLE(KX_PolyProxy,getVertexIndex), + KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMesh), + KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterial), + {NULL,NULL} //Sentinel +}; + +PyObject* +KX_PolyProxy::_getattr(const STR_String& attr) +{ + if (attr == "matname") + { + return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName()); + } + if (attr == "texture") + { + return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName()); + } + if (attr == "material") + { + RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial(); + if(polymat->GetFlag() & RAS_BLENDERMAT) + { + KX_BlenderMaterial* mat = static_cast(polymat); + Py_INCREF(mat); + return mat; + } + else + { + KX_PolygonMaterial* mat = static_cast(polymat); + Py_INCREF(mat); + return mat; + } + } + if (attr == "matid") + { + // we'll have to scan through the material bucket of the mes and compare with + // the one of the polygon + RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial(); + unsigned int matid; + for (matid=0; matidNumMaterials(); matid++) + { + RAS_MaterialBucket* meshBucket = m_mesh->GetMaterialBucket(matid); + if (meshBucket == polyBucket) + // found it + break; + } + return PyInt_FromLong(matid); + } + if (attr == "v1") + { + return PyInt_FromLong(m_polygon->GetVertexIndexBase().m_indexarray[0]); + } + if (attr == "v2") + { + return PyInt_FromLong(m_polygon->GetVertexIndexBase().m_indexarray[1]); + } + if (attr == "v3") + { + return PyInt_FromLong(m_polygon->GetVertexIndexBase().m_indexarray[2]); + } + if (attr == "v4") + { + return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexIndexBase().m_indexarray[3]:0)); + } + if (attr == "visible") + { + return PyInt_FromLong(m_polygon->IsVisible()); + } + if (attr == "collide") + { + return PyInt_FromLong(m_polygon->IsCollider()); + } + _getattr_up(SCA_IObject); +} + +KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon) +: m_mesh((RAS_MeshObject*)mesh), + m_polygon(polygon) +{ +} + +KX_PolyProxy::~KX_PolyProxy() +{ +} + + +// stuff for cvalue related things +CValue* KX_PolyProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;} +CValue* KX_PolyProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;} +STR_String sPolyName="polygone"; +const STR_String & KX_PolyProxy::GetText() {return sPolyName;}; +float KX_PolyProxy::GetNumber() { return -1;} +STR_String KX_PolyProxy::GetName() { return sPolyName;} +void KX_PolyProxy::SetName(STR_String) { }; +CValue* KX_PolyProxy::GetReplica() { return NULL;} +void KX_PolyProxy::ReplicaSetName(STR_String) {}; + + +// stuff for python integration + +KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialIndex, +"getMaterialIndex() : return the material index of the polygon in the mesh\n") +{ + RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial(); + unsigned int matid; + for (matid=0; matidNumMaterials(); matid++) + { + RAS_MaterialBucket* meshBucket = m_mesh->GetMaterialBucket(matid); + if (meshBucket == polyBucket) + // found it + break; + } + return PyInt_FromLong(matid); +} + +KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getNumVertex, +"getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n") +{ + return PyInt_FromLong(m_polygon->VertexCount()); +} + +KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, isVisible, +"isVisible() : returns whether the polygon is visible or not\n") +{ + return PyInt_FromLong(m_polygon->IsVisible()); +} + +KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, isCollider, +"isCollider() : returns whether the polygon is receives collision or not\n") +{ + return PyInt_FromLong(m_polygon->IsCollider()); +} + +KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialName, +"getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n") +{ + return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName()); +} + +KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getTextureName, +"getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n") +{ + return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName()); +} + +KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex, +"getVertexIndex(vertex) : returns the mesh vertex index of a polygon vertex\n" +"vertex: index of the vertex in the polygon: 0->3\n" +"return value can be used to retrieve the vertex details through mesh proxy\n" +"Note: getVertexIndex(3) on a triangle polygon returns 0\n") +{ + int index; + if (!PyArg_ParseTuple(args,"i",&index)) + { + return NULL; + } + if (index < 0 || index > 3) + { + PyErr_SetString(PyExc_AttributeError, "Valid range for index is 0-3"); + return NULL; + } + if (index < m_polygon->VertexCount()) + { + return PyInt_FromLong(m_polygon->GetVertexIndexBase().m_indexarray[index]); + } + return PyInt_FromLong(0); +} + +KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMesh, +"getMesh() : returns a mesh proxy\n") +{ + KX_MeshProxy* meshproxy = new KX_MeshProxy((RAS_MeshObject*)m_mesh); + return meshproxy; +} + +KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterial, +"getMaterial() : returns a material\n") +{ + RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial(); + if(polymat->GetFlag() & RAS_BLENDERMAT) + { + KX_BlenderMaterial* mat = static_cast(polymat); + Py_INCREF(mat); + return mat; + } + else + { + KX_PolygonMaterial* mat = static_cast(polymat); + Py_INCREF(mat); + return mat; + } +} diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h new file mode 100644 index 00000000000..506e2c2a656 --- /dev/null +++ b/source/gameengine/Ketsji/KX_PolyProxy.h @@ -0,0 +1,71 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __KX_POLYROXY +#define __KX_POLYPROXY + +#include "SCA_IObject.h" + +class KX_PolyProxy : public SCA_IObject +{ + Py_Header; +protected: + class RAS_Polygon* m_polygon; + class RAS_MeshObject* m_mesh; +public: + KX_PolyProxy(const class RAS_MeshObject*mesh, class RAS_Polygon* polygon); + virtual ~KX_PolyProxy(); + + // stuff for cvalue related things + CValue* Calc(VALUE_OPERATOR op, CValue *val) ; + CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val); + const STR_String & GetText(); + float GetNumber(); + STR_String GetName(); + void SetName(STR_String name); // Set the name of the value + void ReplicaSetName(STR_String name); + CValue* GetReplica(); + + +// stuff for python integration + virtual PyObject* _getattr(const STR_String& attr); + + KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex) + KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex) + KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,isVisible) + KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,isCollider) + KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialName) + KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getTextureName) + KX_PYMETHOD_DOC(KX_PolyProxy,getVertexIndex) + KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMesh) + KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterial) + +}; + +#endif //__KX_POLYPROXY + diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index 89e2d645d54..974d4b992a6 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -40,7 +40,21 @@ #include "PHY_IPhysicsEnvironment.h" #include "PHY_IPhysicsController.h" -bool KX_RayCast::RayTest(KX_IPhysicsController* ignore_controller, PHY_IPhysicsEnvironment* physics_environment, const MT_Point3& _frompoint, const MT_Point3& topoint, MT_Point3& result_point, MT_Vector3& result_normal, const KX_RayCast& callback) +KX_RayCast::KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal) + :PHY_IRayCastFilterCallback(dynamic_cast(ignoreController), faceNormal) +{ +} + +void KX_RayCast::reportHit(PHY_RayCastResult* result) +{ + m_hitFound = true; + m_hitPoint.setValue((const float*)result->m_hitPoint); + m_hitNormal.setValue((const float*)result->m_hitNormal); + m_hitMesh = result->m_meshObject; + m_hitPolygon = result->m_polygon; +} + +bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_Point3& _frompoint, const MT_Point3& topoint, KX_RayCast& callback) { // Loops over all physics objects between frompoint and topoint, // calling callback.RayHit for each one. @@ -50,58 +64,51 @@ bool KX_RayCast::RayTest(KX_IPhysicsController* ignore_controller, PHY_IPhysicsE // returns true if an object was found, false if not. MT_Point3 frompoint(_frompoint); const MT_Vector3 todir( (topoint - frompoint).safe_normalized() ); + MT_Point3 prevpoint(_frompoint+todir*(-1.f)); PHY_IPhysicsController* hit_controller; - PHY__Vector3 phy_pos; - PHY__Vector3 phy_normal; - while((hit_controller = physics_environment->rayTest(dynamic_cast(ignore_controller), + while((hit_controller = physics_environment->rayTest(callback, frompoint.x(),frompoint.y(),frompoint.z(), - topoint.x(),topoint.y(),topoint.z(), - phy_pos[0],phy_pos[1],phy_pos[2], - phy_normal[0],phy_normal[1],phy_normal[2]))) + topoint.x(),topoint.y(),topoint.z())) != NULL) { - result_point = MT_Point3(phy_pos); - result_normal = MT_Vector3(phy_normal); KX_ClientObjectInfo* info = static_cast(hit_controller->getNewClientInfo()); if (!info) { printf("no info!\n"); MT_assert(info && "Physics controller with no client object info"); - return false; + break; } - if (callback.RayHit(info, result_point, result_normal)) - return true; - - // There is a bug in the code below: the delta is computed with the wrong - // sign on the face opposite to the center, resulting in infinite looping. - // In Blender 2.45 this code was never executed because callback.RayHit() always - // returned true, causing the ray sensor to stop on the first object. - // To avoid changing the behaviour will simply return false here. - // It should be discussed if we want the ray sensor to "see" through objects - // that don't have the required property/material (condition to get here) - return false; - - // skip past the object and keep tracing - /* We add 0.01 of fudge, so that if the margin && radius == 0., we don't endless loop. */ - MT_Scalar marg = 0.01 + hit_controller->GetMargin(); - marg += 2.f * hit_controller->GetMargin(); + // The biggest danger to to endless loop, prevent this by checking that the + // hit point always progresses along the ray direction.. + prevpoint -= callback.m_hitPoint; + if (prevpoint.length2() < MT_EPSILON) + break; + + if (callback.RayHit(info)) + // caller may decide to stop the loop and still cancel the hit + return callback.m_hitFound; + + // Skip past the object and keep tracing. + // Note that retrieving in a single shot multiple hit points would be possible + // but it would require some change in Bullet. + prevpoint = callback.m_hitPoint; + /* We add 0.001 of fudge, so that if the margin && radius == 0., we don't endless loop. */ + MT_Scalar marg = 0.001 + hit_controller->GetMargin(); + marg *= 2.f; /* Calculate the other side of this object */ - PHY__Vector3 hitpos; - hit_controller->getPosition(hitpos); - MT_Point3 hitObjPos(hitpos); - - MT_Vector3 hitvector = hitObjPos - result_point; - if (hitvector.dot(hitvector) > MT_EPSILON) - { - hitvector.normalize(); - marg *= 2.*todir.dot(hitvector); - } - frompoint = result_point + marg * todir; + MT_Scalar h = MT_abs(todir.dot(callback.m_hitNormal)); + if (h <= 0.01) + // the normal is almost orthogonal to the ray direction, cannot compute the other side + break; + marg /= h; + frompoint = callback.m_hitPoint + marg * todir; + // verify that we are not passed the to point + if ((topoint - frompoint).dot(todir) < 0.f) + break; } - - return hit_controller; + return false; } diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h index 607dabd8afc..c3084c997a1 100644 --- a/source/gameengine/Ketsji/KX_RayCast.h +++ b/source/gameengine/Ketsji/KX_RayCast.h @@ -30,12 +30,14 @@ #ifndef __KX_RAYCAST_H__ #define __KX_RAYCAST_H__ -class MT_Point3; -class MT_Vector3; -class KX_IPhysicsController; -class PHY_IPhysicsEnvironment; +#include "PHY_IPhysicsEnvironment.h" +#include "PHY_IPhysicsController.h" +#include "MT_Point3.h" +#include "MT_Vector3.h" +class RAS_MeshObject; struct KX_ClientObjectInfo; +class KX_IPhysicsController; /** * Defines a function for doing a ray cast. @@ -49,17 +51,27 @@ struct KX_ClientObjectInfo; * * Returns true if a client was accepted, false if nothing found. */ -class KX_RayCast +class KX_RayCast : public PHY_IRayCastFilterCallback { -protected: - KX_RayCast() {}; public: + bool m_hitFound; + MT_Point3 m_hitPoint; + MT_Vector3 m_hitNormal; + const RAS_MeshObject* m_hitMesh; + int m_hitPolygon; + + KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal); virtual ~KX_RayCast() {} + /** + * The physic environment returns the ray casting result through this function + */ + virtual void reportHit(PHY_RayCastResult* result); + /** ray test callback. * either override this in your class, or use a callback wrapper. */ - virtual bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal) const = 0; + virtual bool RayHit(KX_ClientObjectInfo* client) = 0; /** * Callback wrapper. @@ -71,13 +83,11 @@ public: /// Public interface. /// Implement bool RayHit in your class to receive ray callbacks. - static bool RayTest(KX_IPhysicsController* physics_controller, + static bool RayTest( PHY_IPhysicsEnvironment* physics_environment, - const MT_Point3& _frompoint, + const MT_Point3& frompoint, const MT_Point3& topoint, - MT_Point3& result_point, - MT_Vector3& result_normal, - const KX_RayCast& callback); + KX_RayCast& callback); }; @@ -86,18 +96,32 @@ template class KX_RayCast::Callback : public KX_RayCast T *self; void *data; public: - Callback(T *_self, void *_data = NULL) - : self(_self), + Callback(T *_self, KX_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false) + : KX_RayCast(controller, faceNormal), + self(_self), data(_data) { } ~Callback() {} - - virtual bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal) const + + virtual bool RayHit(KX_ClientObjectInfo* client) { - return self->RayHit(client, hit_point, hit_normal, data); + return self->RayHit(client, this, data); } + + virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller) + { + KX_ClientObjectInfo* info = static_cast(controller->getNewClientInfo()); + + if (!info) + { + MT_assert(info && "Physics controller with no client object info"); + return false; + } + return self->NeedRayCast(info); + } + }; diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index a416c8c9f89..f62df542be5 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -104,16 +104,10 @@ bool KX_RaySensor::IsPositiveTrigger() return result; } -bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data) +bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data) { KX_GameObject* hitKXObj = client->m_gameobject; - - if (client->m_type > KX_ClientObjectInfo::ACTOR) - { - // false hit - return false; - } bool bFound = false; if (m_propertyname.Length() == 0) @@ -139,16 +133,29 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_ { m_rayHit = true; m_hitObject = hitKXObj; - m_hitPosition = hit_point; - m_hitNormal = hit_normal; + m_hitPosition = result->m_hitPoint; + m_hitNormal = result->m_hitNormal; } - - return bFound; - + // no multi-hit search yet + return true; } - +/* this function is used to pre-filter the object before casting the ray on them. + This is useful for "X-Ray" option when we want to see "through" unwanted object. + */ +bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo* client) +{ + if (client->m_type > KX_ClientObjectInfo::ACTOR) + { + // Unknown type of object, skip it. + // Should not occur as the sensor objects are filtered in RayTest() + printf("Invalid client type %d found ray casting\n", client->m_type); + return false; + } + // no X-Ray function yet + return true; +} bool KX_RaySensor::Evaluate(CValue* event) { @@ -215,8 +222,6 @@ bool KX_RaySensor::Evaluate(CValue* event) m_rayDirection = todir; MT_Point3 topoint = frompoint + (m_distance) * todir; - MT_Point3 resultpoint; - MT_Vector3 resultnormal; PHY_IPhysicsEnvironment* pe = m_scene->GetPhysicsEnvironment(); if (!pe) @@ -238,7 +243,7 @@ bool KX_RaySensor::Evaluate(CValue* event) PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment(); - result = KX_RayCast::RayTest(spc, physics_environment, frompoint, topoint, resultpoint, resultnormal, KX_RayCast::Callback(this)); + KX_RayCast::RayTest(physics_environment, frompoint, topoint, KX_RayCast::Callback(this, spc)); /* now pass this result to some controller */ @@ -265,6 +270,10 @@ bool KX_RaySensor::Evaluate(CValue* event) // notify logicsystem that ray JUST left the Object result = true; } + else + { + result = false; + } } if (reset) diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index f4305b053d1..9e53f80b69c 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -36,6 +36,7 @@ #include "MT_Point3.h" struct KX_ClientObjectInfo; +class KX_RayCast; class KX_RaySensor : public SCA_ISensor { @@ -68,7 +69,8 @@ public: virtual bool IsPositiveTrigger(); virtual void Init(); - bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data); + bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); + bool NeedRayCast(KX_ClientObjectInfo* client); KX_PYMETHOD_DOC(KX_RaySensor,GetHitObject); KX_PYMETHOD_DOC(KX_RaySensor,GetHitPosition); diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp index a04560aaf09..6d9b41e08d2 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp +++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp @@ -206,8 +206,7 @@ void ODEPhysicsEnvironment::removeConstraint(int constraintid) } } -PHY_IPhysicsController* ODEPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ) +PHY_IPhysicsController* ODEPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ) { //m_OdeWorld diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h index 7c61902f8e2..dcc87d614c0 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h +++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h @@ -54,8 +54,7 @@ public: float axisX,float axisY,float axisZ); virtual void removeConstraint(void * constraintid); - virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ); + virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ); //gamelogic callbacks diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index d6a32dfd9c0..2ec96c75a68 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -767,6 +767,8 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) // assume no shape information m_shapeType = PHY_SHAPE_NONE; m_vertexArray.clear(); + m_polygonIndexArray.clear(); + m_meshObject = NULL; if (!meshobj) return false; @@ -838,6 +840,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) m_vertexArray.push_back(vertex0); m_vertexArray.push_back(vertex1); m_vertexArray.push_back(vertex2); + m_polygonIndexArray.push_back(p2); numvalidpolys++; } if (poly->VertexCount() == 4) @@ -857,6 +860,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) m_vertexArray.push_back(vertex0); m_vertexArray.push_back(vertex1); m_vertexArray.push_back(vertex2); + m_polygonIndexArray.push_back(p2); numvalidpolys++; } } @@ -869,6 +873,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) m_shapeType = PHY_SHAPE_NONE; return false; } + m_meshObject = meshobj; return true; } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 1e1a38aa2a6..8a7f1062f53 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -75,6 +75,16 @@ public: { return m_nextShape; } + CcdShapeConstructionInfo* GetChildShape(int i) + { + CcdShapeConstructionInfo* shape = m_nextShape; + while (i > 0 && shape != NULL) + { + shape = shape->m_nextShape; + i--; + } + return shape; + } bool SetMesh(RAS_MeshObject* mesh, bool polytope); @@ -89,6 +99,11 @@ public: std::vector m_vertexArray; // Contains both vertex array for polytope shape and // triangle array for concave mesh shape. // In this case a triangle is made of 3 consecutive points + std::vector m_polygonIndexArray; // Contains the array of polygon index in the + // original mesh that correspond to shape triangles. + // only set for concave mesh shape. + const RAS_MeshObject* m_meshObject; // Keep a pointer to the original mesh + protected: CcdShapeConstructionInfo* m_nextShape; // for compound shape int m_refCount; // this class is shared between replicas diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index d8e05fab839..a34c70143e5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -709,35 +709,51 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId) struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResultCallback { - PHY_IPhysicsController* m_ignoreClient; + PHY_IRayCastFilterCallback& m_phyRayFilter; + const btCollisionShape* m_hitTriangleShape; + int m_hitTriangleIndex; - FilterClosestRayResultCallback (PHY_IPhysicsController* ignoreClient,const btVector3& rayFrom,const btVector3& rayTo) + FilterClosestRayResultCallback (PHY_IRayCastFilterCallback& phyRayFilter,const btVector3& rayFrom,const btVector3& rayTo) : btCollisionWorld::ClosestRayResultCallback(rayFrom,rayTo), - m_ignoreClient(ignoreClient) + m_phyRayFilter(phyRayFilter), + m_hitTriangleShape(NULL), + m_hitTriangleIndex(0) { - } virtual ~FilterClosestRayResultCallback() { } + virtual bool NeedRayCast(btCollisionObject* object) + { + CcdPhysicsController* phyCtrl = static_cast(object->getUserPointer()); + if (phyCtrl != m_phyRayFilter.m_ignoreController) + { + return m_phyRayFilter.needBroadphaseRayCast(phyCtrl); + } + return false; + } + virtual float AddSingleResult( btCollisionWorld::LocalRayResult& rayResult) { CcdPhysicsController* curHit = static_cast(rayResult.m_collisionObject->getUserPointer()); - //ignore client... - if (curHit != m_ignoreClient) - { - //if valid - return ClosestRayResultCallback::AddSingleResult(rayResult); + // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it + if (rayResult.m_localShapeInfo) + { + m_hitTriangleShape = rayResult.m_localShapeInfo->m_triangleShape; + m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex; + } else + { + m_hitTriangleShape = NULL; + m_hitTriangleIndex = 0; } - return m_closestHitFraction; + return ClosestRayResultCallback::AddSingleResult(rayResult); } }; -PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ) +PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ) { @@ -751,18 +767,21 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i //Either Ray Cast with or without filtering //btCollisionWorld::ClosestRayResultCallback rayCallback(rayFrom,rayTo); - FilterClosestRayResultCallback rayCallback(ignoreClient,rayFrom,rayTo); + FilterClosestRayResultCallback rayCallback(filterCallback,rayFrom,rayTo); - PHY_IPhysicsController* nearestHit = 0; + PHY_RayCastResult result; + memset(&result, 0, sizeof(result)); + // don't collision with sensor object - m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback, CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter); + m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback, CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter,filterCallback.m_faceNormal); if (rayCallback.HasHit()) { - nearestHit = static_cast(rayCallback.m_collisionObject->getUserPointer()); - hitX = rayCallback.m_hitPointWorld.getX(); - hitY = rayCallback.m_hitPointWorld.getY(); - hitZ = rayCallback.m_hitPointWorld.getZ(); + CcdPhysicsController* controller = static_cast(rayCallback.m_collisionObject->getUserPointer()); + result.m_controller = controller; + result.m_hitPoint[0] = rayCallback.m_hitPointWorld.getX(); + result.m_hitPoint[1] = rayCallback.m_hitPointWorld.getY(); + result.m_hitPoint[2] = rayCallback.m_hitPointWorld.getZ(); if (rayCallback.m_hitNormalWorld.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { @@ -771,14 +790,42 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i { rayCallback.m_hitNormalWorld.setValue(1,0,0); } - normalX = rayCallback.m_hitNormalWorld.getX(); - normalY = rayCallback.m_hitNormalWorld.getY(); - normalZ = rayCallback.m_hitNormalWorld.getZ(); - + result.m_hitNormal[0] = rayCallback.m_hitNormalWorld.getX(); + result.m_hitNormal[1] = rayCallback.m_hitNormalWorld.getY(); + result.m_hitNormal[2] = rayCallback.m_hitNormalWorld.getZ(); + if (rayCallback.m_hitTriangleShape != NULL) + { + // identify the mesh polygon + CcdShapeConstructionInfo* shapeInfo = controller->m_shapeInfo; + if (shapeInfo) + { + btCollisionShape* shape = controller->GetRigidBody()->getCollisionShape(); + if (shape->isCompound()) + { + btCompoundShape* compoundShape = (btCompoundShape*)shape; + CcdShapeConstructionInfo* compoundShapeInfo = shapeInfo; + // need to search which sub-shape has been hit + for (int i=0; igetNumChildShapes(); i++) + { + shapeInfo = compoundShapeInfo->GetChildShape(i); + shape=compoundShape->getChildShape(i); + if (shape == rayCallback.m_hitTriangleShape) + break; + } + } + if (shape == rayCallback.m_hitTriangleShape && + rayCallback.m_hitTriangleIndex < shapeInfo->m_polygonIndexArray.size()) + { + result.m_meshObject = shapeInfo->m_meshObject; + result.m_polygon = shapeInfo->m_polygonIndexArray.at(rayCallback.m_hitTriangleIndex); + } + } + } + filterCallback.reportHit(&result); } - return nearestHit; + return result.m_controller; } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 825a5e525f2..667e310dcb3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -157,8 +157,7 @@ protected: btTypedConstraint* getConstraintById(int constraintId); - virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ); + virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); //Methods for gamelogic collision/physics callbacks diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp index f512d44c9f2..d78958b746c 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp @@ -109,8 +109,7 @@ void DummyPhysicsEnvironment::removeConstraint(int constraintid) } } -PHY_IPhysicsController* DummyPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ) +PHY_IPhysicsController* DummyPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ) { //collision detection / raytesting return NULL; diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index b5a61f72e4a..975be84f2a7 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -69,8 +69,7 @@ public: return 0; } - virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ); + virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); //gamelogic callbacks diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp index 65018d2523e..80e4dc4044e 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp @@ -26,6 +26,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ +#include // memset #include "SumoPhysicsEnvironment.h" #include "PHY_IMotionState.h" #include "SumoPhysicsController.h" @@ -125,37 +126,35 @@ void SumoPhysicsEnvironment::removeConstraint(int constraintid) } } -PHY_IPhysicsController* SumoPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClientCtrl, +PHY_IPhysicsController* SumoPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, - float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ, - float& normalX,float& normalY,float& normalZ) + float toX,float toY,float toZ) { - SumoPhysicsController* ignoreCtr = static_cast (ignoreClientCtrl); + SumoPhysicsController* ignoreCtr = static_cast (filterCallback.m_ignoreController); //collision detection / raytesting MT_Point3 hit, normal; - PHY_IPhysicsController *ret = 0; + PHY_RayCastResult result; SM_Object* sm_ignore = 0; if (ignoreCtr) sm_ignore = ignoreCtr->GetSumoObject(); + memset(&result, 0, sizeof(result)); SM_Object* smOb = m_sumoScene->rayTest(sm_ignore,MT_Point3(fromX, fromY, fromZ),MT_Point3(toX, toY, toZ), hit, normal); if (smOb) { - ret = (PHY_IPhysicsController *) smOb->getPhysicsClientObject(); + result.m_controller = (PHY_IPhysicsController *) smOb->getPhysicsClientObject(); + result.m_hitPoint[0] = hit[0]; + result.m_hitPoint[1] = hit[1]; + result.m_hitPoint[2] = hit[2]; + result.m_hitNormal[0] = normal[0]; + result.m_hitNormal[1] = normal[1]; + result.m_hitNormal[2] = normal[2]; + filterCallback.reportHit(&result); } - hitX = hit[0]; - hitY = hit[1]; - hitZ = hit[2]; - - normalX = normal[0]; - normalY = normal[1]; - normalZ = normal[2]; - - return ret; + return result.m_controller; } //gamelogic callbacks void SumoPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl) diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h index 8b9fb463034..100adf969d5 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h @@ -75,8 +75,7 @@ public: return 0; } - virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ); + virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ); //gamelogic callbacks diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index 5b275066665..98496fb7f9e 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -33,6 +33,50 @@ #include #include "PHY_DynamicTypes.h" class PHY_IVehicle; +class RAS_MeshObject; +class PHY_IPhysicsController; + +/** + * pass back information from rayTest + */ +struct PHY_RayCastResult +{ + PHY_IPhysicsController* m_controller; + PHY__Vector3 m_hitPoint; + PHY__Vector3 m_hitNormal; + const RAS_MeshObject* m_meshObject; // !=NULL for mesh object (only for Bullet controllers) + int m_polygon; // index of the polygon hit by the ray, + // only if m_meshObject != NULL +}; + +/** + * This class replaces the ignoreController parameter of rayTest function. + * It allows more sophisticated filtering on the physics controller before computing the ray intersection to save CPU. + * It is only used to its full extend by the Ccd physics environement (Bullet). + */ +class PHY_IRayCastFilterCallback +{ +public: + PHY_IPhysicsController* m_ignoreController; + bool m_faceNormal; + + virtual ~PHY_IRayCastFilterCallback() + { + } + + virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller) + { + return true; + } + + virtual void reportHit(PHY_RayCastResult* result) = 0; + + PHY_IRayCastFilterCallback(PHY_IPhysicsController* ignoreController, bool faceNormal=false) + :m_ignoreController(ignoreController), + m_faceNormal(faceNormal) + { + } +}; /** * Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.) @@ -94,8 +138,7 @@ class PHY_IPhysicsEnvironment //complex constraint for vehicles virtual PHY_IVehicle* getVehicleConstraint(int constraintId) =0; - virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ, - float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)=0; + virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0; //Methods for gamelogic collision/physics callbacks diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 033b2864351..2136ce54e30 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -300,10 +300,11 @@ class KX_GameObject: @rtype: L{KX_GameObject} @return: the first object hit or None if no object or object does not match prop """ - def rayCast(to,from,dist,prop): + def rayCast(to,from,dist,prop,face,xray,poly): """ Look from a point/object to another point/object and find first object hit within dist that matches prop. - Returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit. + if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit. + if poly is 1, returns a 4-tuple with in addition a L{KX_PolyProxy} as 4th element. Ex: # shoot along the axis gun-gunAim (gunAim should be collision-free) ob,point,normal = gun.rayCast(gunAim,None,50) @@ -312,9 +313,18 @@ class KX_GameObject: Notes: The ray ignores the object on which the method is called. - If is casted from/to object center or explicit [x,y,z] points. - The ray does not have X-Ray capability: the first object hit (other than self object) stops the ray - If a property was specified and the first object hit does not have that property, there is no hit + It is casted from/to object center or explicit [x,y,z] points. + The face paremeter determines the orientation of the normal: + 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside) + 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect) + The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray. + The prop and xray parameters interact as follow: + prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray. + prop off, xray on : idem. + prop on, xray off: return closest hit if it matches prop, no hit otherwise. + prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray. + The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray. + If there is no hit or the hit object is not a static mesh, None is returned as 4th element. The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects. @param to: [x,y,z] or object to which the ray is casted @@ -325,8 +335,17 @@ class KX_GameObject: @type dist: float @param prop: property name that object must have; can be omitted => detect any object @type prop: string - @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz)) - @return: (object,hitpoint,hitnormal) or (None,None,None) + @param face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin + @type face: int + @param xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object + @type xray: int + @param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy} + @type poly: int + @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz)) + or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy)) + @return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon) + If no hit, returns (None,None,None) or (None,None,None,None) + If the object hit is not a static mesh, polygon is None """ diff --git a/source/gameengine/PyDoc/KX_MeshProxy.py b/source/gameengine/PyDoc/KX_MeshProxy.py index e43fa3598f0..03bc36b6ac1 100644 --- a/source/gameengine/PyDoc/KX_MeshProxy.py +++ b/source/gameengine/PyDoc/KX_MeshProxy.py @@ -95,6 +95,21 @@ class KX_MeshProxy: @rtype: L{KX_VertexProxy} @return: a vertex object. """ + def getNumPolygons(): + """ + Returns the number of polygon in the mesh. + + @rtype: integer + """ + def getPolygon(index): + """ + Gets the specified polygon from the mesh. + + @type index: integer + @param index: polygon number + @rtype: L{KX_PolyProxy} + @return: a polygon object. + """ def reinstancePhysicsMesh(): """ Updates the physics system with the changed mesh. diff --git a/source/gameengine/PyDoc/KX_PolyProxy.py b/source/gameengine/PyDoc/KX_PolyProxy.py new file mode 100644 index 00000000000..45ae30a13dd --- /dev/null +++ b/source/gameengine/PyDoc/KX_PolyProxy.py @@ -0,0 +1,100 @@ +# $Id$ +# Documentation for the polygon proxy class + +class KX_PolyProxy: + """ + A polygon holds the index of the vertex forming the poylgon. + + Note: + The polygon attributes are read-only, you need to retrieve the vertex proxy if you want + to change the vertex settings. + + @ivar matname: The name of polygon material, empty if no material. + @type matname: string + @ivar material: The material of the polygon + @type material: L{KX_PolygonMaterial} or KX_BlenderMaterial + @ivar texture: The texture name of the polygon. + @type texture: string + @ivar matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy + @type matid: integer + @ivar v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy + @type v1: integer + @ivar v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy + @type v2: integer + @ivar v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy + @type v3: integer + @ivar v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex + use this to retrieve vertex proxy from mesh proxy + @type v4: integer + @ivar visible: visible state of the polygon: 1=visible, 0=invisible + @type visible: integer + @ivar collide: collide state of the polygon: 1=receives collision, 0=collision free. + @type collide: integer + """ + + def getMaterialName(): + """ + Returns the polygon material name with MA prefix + + @rtype: string + @return: material name + """ + def getMaterial(): + """ + Returns the polygon material + + @rtype: L{KX_PolygonMaterial} or KX_BlenderMaterial + """ + def getTextureName(): + """ + Returns the polygon texture name + + @rtype: string + @return: texture name + """ + def getMaterialIndex(): + """ + Returns the material bucket index of the polygon. + This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}. + + @rtype: integer + @return: the material index in the mesh + + def getNumVertex(): + """ + Returns the number of vertex of the polygon. + + @rtype: integer + @return: number of vertex, 3 or 4. + """ + def isVisible(): + """ + Returns whether the polygon is visible or not + + @rtype: integer + @return: 0=invisible, 1=visible + """ + def isCollider(): + """ + Returns whether the polygon is receives collision or not + + @rtype: integer + @return: 0=collision free, 1=receives collision + """ + def getVertexIndex(vertex): + """ + Returns the mesh vertex index of a polygon vertex + This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}. + + @type vertex: integer + @param vertex: index of the vertex in the polygon: 0->3 + @rtype: integer + @return: mesh vertex index + """ + def getMesh(): + """ + Returns a mesh proxy + + @rtype: L{KX_MeshProxy} + @return: mesh proxy + """ diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index af5228e4c35..a4f7f3f01dd 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -134,7 +134,7 @@ int RAS_MeshObject::NumPolygons() -RAS_Polygon* RAS_MeshObject::GetPolygon(int num) +RAS_Polygon* RAS_MeshObject::GetPolygon(int num) const { return m_Polygons[num]; } diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index 99806666fa6..9a46d89c393 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -178,7 +178,7 @@ public: void UpdateMaterialList(); int NumPolygons(); - RAS_Polygon* GetPolygon(int num); + RAS_Polygon* GetPolygon(int num) const; virtual void Bucketize( double* oglmatrix, -- cgit v1.2.3 From 2934e78a863116bbb3192f64dce7ac7a55732fe6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 28 Aug 2008 05:45:20 +0000 Subject: remove more python functions from builtins that could allow scripts to do bad stuff. - reload, file, execfile, compile These are only removed when running in higher security mode thats not default in blender. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 53 ++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 5d2126ca37a..0634b4df945 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -852,13 +852,30 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook // override builtin functions import() and open() -PyObject *KXpy_open(PyObject *self, PyObject *args) -{ +PyObject *KXpy_open(PyObject *self, PyObject *args) { PyErr_SetString(PyExc_RuntimeError, "Sandbox: open() function disabled!\nGame Scripts should not use this function."); return NULL; } +PyObject *KXpy_reload(PyObject *self, PyObject *args) { + PyErr_SetString(PyExc_RuntimeError, "Sandbox: reload() function disabled!\nGame Scripts should not use this function."); + return NULL; +} + +PyObject *KXpy_file(PyObject *self, PyObject *args) { + PyErr_SetString(PyExc_RuntimeError, "Sandbox: file() function disabled!\nGame Scripts should not use this function."); + return NULL; +} +PyObject *KXpy_execfile(PyObject *self, PyObject *args) { + PyErr_SetString(PyExc_RuntimeError, "Sandbox: execfile() function disabled!\nGame Scripts should not use this function."); + return NULL; +} + +PyObject *KXpy_compile(PyObject *self, PyObject *args) { + PyErr_SetString(PyExc_RuntimeError, "Sandbox: compile() function disabled!\nGame Scripts should not use this function."); + return NULL; +} PyObject *KXpy_import(PyObject *self, PyObject *args) { @@ -895,19 +912,13 @@ PyObject *KXpy_import(PyObject *self, PyObject *args) } +static PyMethodDef meth_open[] = {{ "open", KXpy_open, METH_VARARGS, "(disabled)"}}; +static PyMethodDef meth_reload[] = {{ "reload", KXpy_reload, METH_VARARGS, "(disabled)"}}; +static PyMethodDef meth_file[] = {{ "file", KXpy_file, METH_VARARGS, "(disabled)"}}; +static PyMethodDef meth_execfile[] = {{ "execfile", KXpy_execfile, METH_VARARGS, "(disabled)"}}; +static PyMethodDef meth_compile[] = {{ "compile", KXpy_compile, METH_VARARGS, "(disabled)"}}; -static PyMethodDef meth_open[] = { - { "open", KXpy_open, METH_VARARGS, - "(disabled)"} -}; - - -static PyMethodDef meth_import[] = { - { "import", KXpy_import, METH_VARARGS, - "our own import"} -}; - - +static PyMethodDef meth_import[] = {{ "import", KXpy_import, METH_VARARGS, "our own import"}}; //static PyObject *g_oldopen = 0; //static PyObject *g_oldimport = 0; @@ -918,15 +929,21 @@ void setSandbox(TPythonSecurityLevel level) { PyObject *m = PyImport_AddModule("__builtin__"); PyObject *d = PyModule_GetDict(m); - PyObject *meth = PyCFunction_New(meth_open, NULL); switch (level) { case psl_Highest: //if (!g_security) { //g_oldopen = PyDict_GetItemString(d, "open"); - PyDict_SetItemString(d, "open", meth); - meth = PyCFunction_New(meth_import, NULL); - PyDict_SetItemString(d, "__import__", meth); + + // functions we cant trust + PyDict_SetItemString(d, "open", PyCFunction_New(meth_open, NULL)); + PyDict_SetItemString(d, "reload", PyCFunction_New(meth_reload, NULL)); + PyDict_SetItemString(d, "file", PyCFunction_New(meth_file, NULL)); + PyDict_SetItemString(d, "execfile", PyCFunction_New(meth_execfile, NULL)); + PyDict_SetItemString(d, "compile", PyCFunction_New(meth_compile, NULL)); + + // our own import + PyDict_SetItemString(d, "__import__", PyCFunction_New(meth_import, NULL)); //g_security = level; //} break; -- cgit v1.2.3 From f88c5d972130e7bcde3fdd289e91546c5946c888 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 28 Aug 2008 07:03:23 +0000 Subject: BGE Bugfix, lights were not being removed when their gameobject was removed causing odd shadows to hang about the scene. --- source/gameengine/Ketsji/KX_Scene.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index ab3692d2411..e0a7ebb5423 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -944,6 +944,8 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) newobj->RemoveMeshes(); ret = 1; + if (newobj->IsLight() && m_lightlist->RemoveValue(newobj)) + ret = newobj->Release(); if (m_objectlist->RemoveValue(newobj)) ret = newobj->Release(); if (m_tempObjectList->RemoveValue(newobj)) -- cgit v1.2.3 From c8d0a540f5372850237ac699dce753d7bba9c6df Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 28 Aug 2008 08:13:58 +0000 Subject: BGE patch: fix division by 0 error when sound sample cannot be loaded in sound actuator. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 78 +++++++++++----------- source/gameengine/Ketsji/KX_SoundActuator.cpp | 64 ++++++++++++------ 2 files changed, 82 insertions(+), 60 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 9ec8bdd91fc..7e976beaf44 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -406,50 +406,51 @@ void BL_ConvertActuators(char* maggiename, /* Note, allowing actuators for sounds that are not there was added since 2.47 * This is because python may expect the actuator and raise an exception if it dosnt find it * better just to add a dummy sound actuator. */ - /*if (sampleisloaded)*/ - - /* setup the SND_SoundObject */ - SND_SoundObject* sndobj = new SND_SoundObject(); - sndobj->SetSampleName(samplename.Ptr()); - sndobj->SetObjectName(bact->name); - if (soundact->sound) { - sndobj->SetRollOffFactor(soundact->sound->attenuation); - sndobj->SetGain(soundact->sound->volume); - sndobj->SetPitch(exp((soundact->sound->pitch / 12.0) * log(2.0))); - // sndobj->SetLoopStart(soundact->sound->loopstart); - // sndobj->SetLoopStart(soundact->sound->loopend); - if (soundact->sound->flags & SOUND_FLAGS_LOOP) - { - if (soundact->sound->flags & SOUND_FLAGS_BIDIRECTIONAL_LOOP) - sndobj->SetLoopMode(SND_LOOP_BIDIRECTIONAL); + SND_SoundObject* sndobj = NULL; + if (sampleisloaded) + { + /* setup the SND_SoundObject */ + sndobj = new SND_SoundObject(); + sndobj->SetSampleName(samplename.Ptr()); + sndobj->SetObjectName(bact->name); + if (soundact->sound) { + sndobj->SetRollOffFactor(soundact->sound->attenuation); + sndobj->SetGain(soundact->sound->volume); + sndobj->SetPitch(exp((soundact->sound->pitch / 12.0) * log(2.0))); + // sndobj->SetLoopStart(soundact->sound->loopstart); + // sndobj->SetLoopStart(soundact->sound->loopend); + if (soundact->sound->flags & SOUND_FLAGS_LOOP) + { + if (soundact->sound->flags & SOUND_FLAGS_BIDIRECTIONAL_LOOP) + sndobj->SetLoopMode(SND_LOOP_BIDIRECTIONAL); + else + sndobj->SetLoopMode(SND_LOOP_NORMAL); + } + else { + sndobj->SetLoopMode(SND_LOOP_OFF); + } + + if (soundact->sound->flags & SOUND_FLAGS_PRIORITY) + sndobj->SetHighPriority(true); else - sndobj->SetLoopMode(SND_LOOP_NORMAL); + sndobj->SetHighPriority(false); + + if (soundact->sound->flags & SOUND_FLAGS_3D) + sndobj->Set3D(true); + else + sndobj->Set3D(false); } else { + /* dummy values for a NULL sound + * see editsound.c - defaults are unlikely to change soon */ + sndobj->SetRollOffFactor(1.0); + sndobj->SetGain(1.0); + sndobj->SetPitch(1.0); sndobj->SetLoopMode(SND_LOOP_OFF); - } - - if (soundact->sound->flags & SOUND_FLAGS_PRIORITY) - sndobj->SetHighPriority(true); - else sndobj->SetHighPriority(false); - - if (soundact->sound->flags & SOUND_FLAGS_3D) - sndobj->Set3D(true); - else sndobj->Set3D(false); + } } - else { - /* dummy values for a NULL sound - * see editsound.c - defaults are unlikely to change soon */ - sndobj->SetRollOffFactor(1.0); - sndobj->SetGain(1.0); - sndobj->SetPitch(1.0); - sndobj->SetLoopMode(SND_LOOP_OFF); - sndobj->SetHighPriority(false); - sndobj->Set3D(false); - } - KX_SoundActuator* tmpsoundact = new KX_SoundActuator(gameobj, sndobj, @@ -460,7 +461,8 @@ void BL_ConvertActuators(char* maggiename, tmpsoundact->SetName(bact->name); baseact = tmpsoundact; - soundscene->AddObject(sndobj); + if (sndobj) + soundscene->AddObject(sndobj); } break; } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index 34a3baec093..f75a1ee5c62 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -69,11 +69,11 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj, KX_SoundActuator::~KX_SoundActuator() { - //m_soundScene->RemoveObject(this->m_soundObject); - //(this->m_soundObject)->DeleteWhenFinished(); - m_soundScene->RemoveActiveObject(m_soundObject); -// m_soundScene->DeleteObjectWhenFinished(m_soundObject); - m_soundScene->DeleteObject(m_soundObject); + if (m_soundObject) + { + m_soundScene->RemoveActiveObject(m_soundObject); + m_soundScene->DeleteObject(m_soundObject); + } } @@ -82,9 +82,12 @@ CValue* KX_SoundActuator::GetReplica() { KX_SoundActuator* replica = new KX_SoundActuator(*this); replica->ProcessReplica(); - SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject); - replica->setSoundObject(soundobj); - m_soundScene->AddObject(soundobj); + if (m_soundObject) + { + SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject); + replica->setSoundObject(soundobj); + m_soundScene->AddObject(soundobj); + } // this will copy properties and so on... CValue::AddDataToReplica(replica); @@ -104,6 +107,9 @@ bool KX_SoundActuator::Update(double curtime, bool frame) RemoveAllEvents(); + if (!m_soundObject) + return false; + if (m_pino) { bNegativeEvent = true; @@ -287,6 +293,10 @@ PyObject* KX_SoundActuator::PySetFilename(PyObject* self, PyObject* args, PyObje PyObject* KX_SoundActuator::PyGetFilename(PyObject* self, PyObject* args, PyObject* kwds) { + if (!m_soundObject) + { + return PyString_FromString(""); + } STR_String objectname = m_soundObject->GetObjectName(); char* name = objectname.Ptr(); @@ -301,7 +311,8 @@ PyObject* KX_SoundActuator::PyGetFilename(PyObject* self, PyObject* args, PyObje PyObject* KX_SoundActuator::PyStartSound(PyObject* self, PyObject* args, PyObject* kwds) { - m_soundObject->StartSound(); + if (m_soundObject) + m_soundObject->StartSound(); Py_Return; } @@ -309,7 +320,8 @@ PyObject* KX_SoundActuator::PyStartSound(PyObject* self, PyObject* args, PyObjec PyObject* KX_SoundActuator::PyPauseSound(PyObject* self, PyObject* args, PyObject* kwds) { - m_soundObject->PauseSound(); + if (m_soundObject) + m_soundObject->PauseSound(); Py_Return; } @@ -317,7 +329,8 @@ PyObject* KX_SoundActuator::PyPauseSound(PyObject* self, PyObject* args, PyObjec PyObject* KX_SoundActuator::PyStopSound(PyObject* self, PyObject* args, PyObject* kwds) { - m_soundObject->StopSound(); + if (m_soundObject) + m_soundObject->StopSound(); Py_Return; } @@ -329,7 +342,8 @@ PyObject* KX_SoundActuator::PySetGain(PyObject* self, PyObject* args, PyObject* if (!PyArg_ParseTuple(args, "f", &gain)) return NULL; - m_soundObject->SetGain(gain); + if (m_soundObject) + m_soundObject->SetGain(gain); Py_Return; } @@ -338,7 +352,7 @@ PyObject* KX_SoundActuator::PySetGain(PyObject* self, PyObject* args, PyObject* PyObject* KX_SoundActuator::PyGetGain(PyObject* self, PyObject* args, PyObject* kwds) { - float gain = m_soundObject->GetGain(); + float gain = (m_soundObject) ? m_soundObject->GetGain() : 1.0f; PyObject* result = PyFloat_FromDouble(gain); return result; @@ -352,7 +366,8 @@ PyObject* KX_SoundActuator::PySetPitch(PyObject* self, PyObject* args, PyObject* if (!PyArg_ParseTuple(args, "f", &pitch)) return NULL; - m_soundObject->SetPitch(pitch); + if (m_soundObject) + m_soundObject->SetPitch(pitch); Py_Return; } @@ -361,7 +376,7 @@ PyObject* KX_SoundActuator::PySetPitch(PyObject* self, PyObject* args, PyObject* PyObject* KX_SoundActuator::PyGetPitch(PyObject* self, PyObject* args, PyObject* kwds) { - float pitch = m_soundObject->GetPitch(); + float pitch = (m_soundObject) ? m_soundObject->GetPitch() : 1.0; PyObject* result = PyFloat_FromDouble(pitch); return result; @@ -375,7 +390,8 @@ PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* self, PyObject* args, P if (!PyArg_ParseTuple(args, "f", &rollofffactor)) return NULL; - m_soundObject->SetRollOffFactor(rollofffactor); + if (m_soundObject) + m_soundObject->SetRollOffFactor(rollofffactor); Py_Return; } @@ -384,7 +400,7 @@ PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* self, PyObject* args, P PyObject* KX_SoundActuator::PyGetRollOffFactor(PyObject* self, PyObject* args, PyObject* kwds) { - float rollofffactor = m_soundObject->GetRollOffFactor(); + float rollofffactor = (m_soundObject) ? m_soundObject->GetRollOffFactor() : 1.0; PyObject* result = PyFloat_FromDouble(rollofffactor); return result; @@ -398,7 +414,8 @@ PyObject* KX_SoundActuator::PySetLooping(PyObject* self, PyObject* args, PyObjec if (!PyArg_ParseTuple(args, "i", &looping)) return NULL; - m_soundObject->SetLoopMode(looping); + if (m_soundObject) + m_soundObject->SetLoopMode(looping); Py_Return; } @@ -407,7 +424,7 @@ PyObject* KX_SoundActuator::PySetLooping(PyObject* self, PyObject* args, PyObjec PyObject* KX_SoundActuator::PyGetLooping(PyObject* self, PyObject* args, PyObject* kwds) { - int looping = m_soundObject->GetLoopMode(); + int looping = (m_soundObject) ? m_soundObject->GetLoopMode() : SND_LOOP_OFF; PyObject* result = PyInt_FromLong(looping); return result; @@ -425,7 +442,8 @@ PyObject* KX_SoundActuator::PySetPosition(PyObject* self, PyObject* args, PyObje if (!PyArg_ParseTuple(args, "fff", &pos[0], &pos[1], &pos[2])) return NULL; - m_soundObject->SetPosition(pos); + if (m_soundObject) + m_soundObject->SetPosition(pos); Py_Return; } @@ -442,7 +460,8 @@ PyObject* KX_SoundActuator::PySetVelocity(PyObject* self, PyObject* args, PyObje if (!PyArg_ParseTuple(args, "fff", &vel[0], &vel[1], &vel[2])) return NULL; - m_soundObject->SetVelocity(vel); + if (m_soundObject) + m_soundObject->SetVelocity(vel); Py_Return; } @@ -465,7 +484,8 @@ PyObject* KX_SoundActuator::PySetOrientation(PyObject* self, PyObject* args, PyO if (!PyArg_ParseTuple(args, "fffffffff", &ori[0][0], &ori[0][1], &ori[0][2], &ori[1][0], &ori[1][1], &ori[1][2], &ori[2][0], &ori[2][1], &ori[2][2])) return NULL; - m_soundObject->SetOrientation(ori); + if (m_soundObject) + m_soundObject->SetOrientation(ori); Py_Return; } -- cgit v1.2.3 From 794ffdcd2c0a659c076cf0b644a67ecaa4a6e853 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 28 Aug 2008 09:02:04 +0000 Subject: didnt build before committiong this small change :/ isLight() is apricot only. Add this back when GLSL is merged to avoid conflicts. --- source/gameengine/Ketsji/KX_Scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index e0a7ebb5423..1c37fcea77e 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -944,7 +944,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) newobj->RemoveMeshes(); ret = 1; - if (newobj->IsLight() && m_lightlist->RemoveValue(newobj)) + if (m_lightlist->RemoveValue(newobj)) // TODO - use newobj->IsLight() test when its merged in from apricot. - Campbell ret = newobj->Release(); if (m_objectlist->RemoveValue(newobj)) ret = newobj->Release(); -- cgit v1.2.3 From 84d1dfb89b3f90ac656aca7f0c3d901351d4ea88 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 28 Aug 2008 10:28:06 +0000 Subject: patch for compilation problem around KX_RayCast::Callback template with gcc --- source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp | 3 ++- source/gameengine/GamePlayer/common/GPC_RenderTools.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index f4a1f3a5b26..dafc2599850 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -236,7 +236,8 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat if (parent) parent->Release(); - if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, KX_RayCast::Callback(this, physics_controller, oglmatrix))) + KX_RayCast::Callback callback(this, physics_controller, oglmatrix); + if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback)) { // couldn't find something to cast the shadow on... glMultMatrixd(oglmatrix); diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 246466f59b8..a64c85f6c17 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -563,7 +563,8 @@ void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,in if (parent) parent->Release(); - if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, KX_RayCast::Callback(this, physics_controller, oglmatrix))) + KX_RayCast::Callback callback(this, physics_controller, oglmatrix); + if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback)) { // couldn't find something to cast the shadow on... glMultMatrixd(oglmatrix); -- cgit v1.2.3 From 116001ac34ca468bb49451f995cca3158c7e7c1b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 28 Aug 2008 11:06:46 +0000 Subject: more fix for compilation problem with KX_RayCast::Callback template in gcc --- source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 3 ++- source/gameengine/Ketsji/KX_RaySensor.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 721bd4d44d6..3156f543ed5 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -272,7 +272,8 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void) bool result = false; - KX_RayCast::RayTest(physics_environment, frompoint3, topoint3, KX_RayCast::Callback(this,physics_controller)); + KX_RayCast::Callback callback(this,physics_controller); + KX_RayCast::RayTest(physics_environment, frompoint3, topoint3, callback); result = (m_hitObject!=0); diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index f62df542be5..57101b769ea 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -243,7 +243,8 @@ bool KX_RaySensor::Evaluate(CValue* event) PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment(); - KX_RayCast::RayTest(physics_environment, frompoint, topoint, KX_RayCast::Callback(this, spc)); + KX_RayCast::Callback callback(this, spc); + KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback); /* now pass this result to some controller */ -- cgit v1.2.3 From 6a98b9215cc039f6c6fe0cba011d6783fbd6d7ab Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 28 Aug 2008 11:13:04 +0000 Subject: final fix for compilation problem with KX_RayCast::Callback template in gcc --- source/gameengine/Ketsji/KX_GameObject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 51322f8429e..c1b228e8d26 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1721,7 +1721,8 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, m_testPropName = propName; else m_testPropName.SetLength(0); - KX_RayCast::RayTest(pe, fromPoint, toPoint, KX_RayCast::Callback(this,spc)); + KX_RayCast::Callback callback(this,spc); + KX_RayCast::RayTest(pe, fromPoint, toPoint, callback); if (m_pHitObject) { -- cgit v1.2.3 From 9f89f4cf340d25f38be5239651849832a714a880 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 28 Aug 2008 12:12:56 +0000 Subject: compilation problem with gcc, memset undeclared --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index a34c70143e5..d14ddf8f65c 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -53,6 +53,7 @@ void DrawRasterizerLine(const float* from,const float* to,int color); #include +#include // for memset #ifdef NEW_BULLET_VEHICLE_SUPPORT class WrapperVehicle : public PHY_IVehicle -- cgit v1.2.3 From 272132888f09b9dd4e0b1e519aab5a38380752b2 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 28 Aug 2008 19:37:49 +0000 Subject: BGE patch: add X-Ray option to ray sensor. The option is effective only if a property is set: the sensor will ignore the objects that don't have the property. --- source/gameengine/Converter/KX_ConvertSensors.cpp | 2 ++ source/gameengine/Ketsji/KX_RaySensor.cpp | 18 +++++++++++++++++- source/gameengine/Ketsji/KX_RaySensor.h | 4 +++- 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 98e078ccf8d..db47dc2dd3d 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -633,6 +633,7 @@ void BL_ConvertSensors(struct Object* blenderobject, if (eventmgr) { bool bFindMaterial = (blenderraysensor->mode & SENS_COLLISION_MATERIAL); + bool bXRay = (blenderraysensor->mode & SENS_RAY_XRAY); STR_String checkname = (bFindMaterial? blenderraysensor->matname : blenderraysensor->propname); @@ -645,6 +646,7 @@ void BL_ConvertSensors(struct Object* blenderobject, gameobj, checkname, bFindMaterial, + bXRay, distance, axis, kxscene); diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 57101b769ea..8dc22fe13c1 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -51,6 +51,7 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, const STR_String& propname, bool bFindMaterial, + bool bXRay, double distance, int axis, KX_Scene* ketsjiScene, @@ -58,6 +59,7 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr, : SCA_ISensor(gameobj,eventmgr, T), m_propertyname(propname), m_bFindMaterial(bFindMaterial), + m_bXRay(bXRay), m_distance(distance), m_scene(ketsjiScene), m_axis(axis) @@ -153,7 +155,21 @@ bool KX_RaySensor::NeedRayCast(KX_ClientObjectInfo* client) printf("Invalid client type %d found ray casting\n", client->m_type); return false; } - // no X-Ray function yet + if (m_bXRay && m_propertyname.Length() != 0) + { + if (m_bFindMaterial) + { + // not quite correct: an object may have multiple material + // should check all the material and not only the first one + if (!client->m_auxilary_info || (m_propertyname != ((char*)client->m_auxilary_info))) + return false; + } + else + { + if (client->m_gameobject->GetProperty(m_propertyname) == NULL) + return false; + } + } return true; } diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h index 9e53f80b69c..02a755fedc1 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.h +++ b/source/gameengine/Ketsji/KX_RaySensor.h @@ -43,6 +43,7 @@ class KX_RaySensor : public SCA_ISensor Py_Header; STR_String m_propertyname; bool m_bFindMaterial; + bool m_bXRay; double m_distance; class KX_Scene* m_scene; bool m_bTriggered; @@ -57,7 +58,8 @@ public: KX_RaySensor(class SCA_EventManager* eventmgr, SCA_IObject* gameobj, const STR_String& propname, - bool fFindMaterial, + bool bFindMaterial, + bool bXRay, double distance, int axis, class KX_Scene* ketsjiScene, -- cgit v1.2.3 From f60992daae876182800ab2adf8f24fd90a13b240 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Aug 2008 03:15:17 +0000 Subject: BGE Py API - GameKeys.EventToString() utility function, makes key configuration menu's easier to write. own error with blenderplayer, wasnt decreffing the GameLogic module, probably didnt matter since python was restarted anyway, but is incorrect. --- .../GamePlayer/ghost/GPG_Application.cpp | 1 + source/gameengine/Ketsji/KX_PythonInit.cpp | 29 ++++++++++++++++++++++ source/gameengine/PyDoc/GameKeys.py | 9 +++++++ 3 files changed, 39 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index f859193ef7a..c56a6d0da23 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -716,6 +716,7 @@ void GPG_Application::stopEngine() } else { printf("Error, GameLogic.globalDict could not be marshal'd\n"); } + Py_DECREF(gameLogic); } else { printf("Error, GameLogic.globalDict was removed\n"); } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 0634b4df945..8a19039a337 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1048,9 +1048,38 @@ static char GameKeys_module_documentation[] = "This modules provides defines for key-codes" ; +static char gPyEventToString_doc[] = +"Take a valid event from the GameKeys module or Keyboard Sensor and return a name" +; +static PyObject* gPyEventToString(PyObject*, PyObject* value) +{ + PyObject* mod, *dict, *key, *val, *ret = NULL; + int pos = 0; + + mod = PyImport_ImportModule( "GameKeys" ); + if (!mod) + return NULL; + + dict = PyModule_GetDict(mod); + + while (PyDict_Next(dict, &pos, &key, &val)) { + if (PyObject_Compare(value, val)==0) { + ret = key; + break; + } + } + + PyErr_Clear(); // incase there was an error clearing + Py_DECREF(mod); + if (!ret) PyErr_SetString(PyExc_ValueError, "expected a valid int keyboard event"); + else Py_INCREF(ret); + + return ret; +} static struct PyMethodDef gamekeys_methods[] = { + {"EventToString", (PyCFunction)gPyEventToString, METH_O, gPyEventToString_doc}, { NULL, (PyCFunction) NULL, 0, NULL } }; diff --git a/source/gameengine/PyDoc/GameKeys.py b/source/gameengine/PyDoc/GameKeys.py index 268fb9cc172..1a0a737718e 100644 --- a/source/gameengine/PyDoc/GameKeys.py +++ b/source/gameengine/PyDoc/GameKeys.py @@ -164,3 +164,12 @@ Example:: # Activate Right! """ + +def EventToString(event): + """ + Return the string name of a key event. Will raise a ValueError error if its invalid. + + @type event: int + @param event: key event from GameKeys or the keyboard sensor. + @rtype: string + """ -- cgit v1.2.3 From e21b3d81c54b81723cf6438669b94e89449d3a66 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Aug 2008 06:32:42 +0000 Subject: Use Py_ssize_t rather then int, broke building on 64bt linux --- source/gameengine/Ketsji/KX_PythonInit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 8a19039a337..e9fb0278d76 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1055,7 +1055,7 @@ static char gPyEventToString_doc[] = static PyObject* gPyEventToString(PyObject*, PyObject* value) { PyObject* mod, *dict, *key, *val, *ret = NULL; - int pos = 0; + Py_ssize_t pos = 0; mod = PyImport_ImportModule( "GameKeys" ); if (!mod) -- cgit v1.2.3 From 74339c639a7dee831cb54bd056c111a4c37a40e4 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 31 Aug 2008 18:42:58 +0000 Subject: BGE patch approved: BGE Multiple Joysticks --- source/gameengine/Converter/KX_ConvertSensors.cpp | 1 + .../gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 95 +++++++++++----------- .../gameengine/GameLogic/Joystick/SCA_Joystick.h | 23 ++---- .../GameLogic/Joystick/SCA_JoystickDefines.h | 2 + .../gameengine/GameLogic/SCA_JoystickManager.cpp | 17 ++-- source/gameengine/GameLogic/SCA_JoystickManager.h | 4 +- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 14 ++-- source/gameengine/GameLogic/SCA_JoystickSensor.h | 9 ++ 8 files changed, 85 insertions(+), 80 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index db47dc2dd3d..74819431858 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -713,6 +713,7 @@ void BL_ConvertSensors(struct Object* blenderobject, gamesensor = new SCA_JoystickSensor( eventmgr, gameobj, + bjoy->joyindex, joysticktype, axis,axisf, prec, diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 18d7b6ffcd0..b244bddcacd 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -29,9 +29,9 @@ #include "SCA_Joystick.h" #include "SCA_JoystickPrivate.h" - -SCA_Joystick::SCA_Joystick() +SCA_Joystick::SCA_Joystick(short int index) : + m_joyindex(index), m_axis10(0), m_axis11(0), m_axis20(0), @@ -52,50 +52,53 @@ SCA_Joystick::~SCA_Joystick() delete m_private; } -SCA_Joystick *SCA_Joystick::m_instance = NULL; +SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX]; int SCA_Joystick::m_refCount = 0; -SCA_Joystick *SCA_Joystick::GetInstance() +SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) { - if (m_instance == 0) + if (joyindex < 0 || joyindex >= JOYINDEX_MAX) { + echo("Error-invalid joystick index: " << joyindex); + return NULL; + } + + if (m_refCount == 0) { - m_instance = new SCA_Joystick(); - m_instance->CreateJoystickDevice(); + int i; + // do this once only + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO ) == -1 ){ + echo("Error-Initializing-SDL: " << SDL_GetError()); + return NULL; + } + for (i=0; iCreateJoystickDevice(); + } m_refCount = 1; } else { m_refCount++; } - return m_instance; + return m_instance[joyindex]; } void SCA_Joystick::ReleaseInstance() { if (--m_refCount == 0) { - DestroyJoystickDevice(); - delete m_instance; - m_instance = NULL; + int i; + for (i=0; iDestroyJoystickDevice(); + delete m_instance[i]; + } + m_instance[i]= NULL; + } + SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO ); } } - -bool SCA_Joystick::CreateJoystickDevice() -{ - bool init = false; - init = pCreateJoystickDevice(); - return init; -} - - -void SCA_Joystick::DestroyJoystickDevice() -{ - if(m_isinit) - pDestroyJoystickDevice(); -} - - void SCA_Joystick::HandleEvents() { if(m_isinit) @@ -334,40 +337,34 @@ int SCA_Joystick::GetNumberOfHats() return -1; } -bool SCA_Joystick::pCreateJoystickDevice() +bool SCA_Joystick::CreateJoystickDevice(void) { if(m_isinit == false){ - if(SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO ) == -1 ){ - echo("Error-Initializing-SDL: " << SDL_GetError()); - return false; - } - if(SDL_NumJoysticks() > 0){ - for(int i=0; im_joystick = SDL_JoystickOpen(i); - SDL_JoystickEventState(SDL_ENABLE); - m_numjoys = i; - } - echo("Joystick-initialized"); - m_isinit = true; - return true; - }else{ - echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)"); + if (m_joyindex>=SDL_NumJoysticks()) { + // don't print a message, because this is done anyway + //echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)"); return false; } + + m_private->m_joystick = SDL_JoystickOpen(m_joyindex); + SDL_JoystickEventState(SDL_ENABLE); + + echo("Joystick " << m_joyindex << " initialized"); + m_isinit = true; } - return false; + return true; } -void SCA_Joystick::pDestroyJoystickDevice() +void SCA_Joystick::DestroyJoystickDevice(void) { - echo("Closing-"); - for(int i=0; im_joystick); } + m_isinit = false; } - SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO ); } diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index 1e853070b09..689efc72975 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -76,7 +76,7 @@ class SCA_Joystick { - static SCA_Joystick *m_instance; + static SCA_Joystick *m_instance[JOYINDEX_MAX]; static int m_refCount; class PrivateData; @@ -85,14 +85,6 @@ class SCA_Joystick int m_joyindex; - /*! - - * the number of avail joysticks - - */ - - int m_numjoys; - /* *support for 2 axes @@ -185,7 +177,7 @@ class SCA_Joystick */ - bool pCreateJoystickDevice(void); + bool CreateJoystickDevice(void); /* @@ -193,7 +185,7 @@ class SCA_Joystick */ - void pDestroyJoystickDevice(void); + void DestroyJoystickDevice(void); @@ -259,18 +251,13 @@ class SCA_Joystick int pGetHat(int direction); - SCA_Joystick(); + SCA_Joystick(short int index); ~SCA_Joystick(); - bool CreateJoystickDevice(void); - - void DestroyJoystickDevice(void); - - public: - static SCA_Joystick *GetInstance(); + static SCA_Joystick *GetInstance( short int joyindex ); void ReleaseInstance(); diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h index 15a421188b9..8d8f88ecaf2 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h @@ -38,6 +38,8 @@ #define echo(x) std::cout << x << std::endl; #endif +#define JOYINDEX_MAX 8 + /* function callbacks */ #define HANDLE_AXISMOTION(fn) ((fn)(), 0L) #define HANDLE_HATMOTION(fn) ((fn)(), 0L) diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp index 8ff28ba0b51..08c36326712 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp @@ -40,13 +40,20 @@ SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr) : SCA_EventManager(JOY_EVENTMGR), m_logicmgr(logicmgr) { - m_joystick = SCA_Joystick::GetInstance(); + int i; + for (i=0; iReleaseInstance(); + int i; + for (i=0; iReleaseInstance(); + } } @@ -58,17 +65,17 @@ void SCA_JoystickManager::NextFrame(double curtime,double deltatime) SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it); if(!joysensor->IsSuspended()) { - m_joystick->HandleEvents(); + m_joystick[joysensor->GetJoyIndex()]->HandleEvents(); joysensor->Activate(m_logicmgr, NULL); } } } -SCA_Joystick *SCA_JoystickManager::GetJoystickDevice() +SCA_Joystick *SCA_JoystickManager::GetJoystickDevice( short int joyindex) { /* *Return the instance of SCA_Joystick for use */ - return m_joystick; + return m_joystick[joyindex]; } diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h index f2bb27965fa..d3a7ac95bea 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.h +++ b/source/gameengine/GameLogic/SCA_JoystickManager.h @@ -40,12 +40,12 @@ class SCA_JoystickManager : public SCA_EventManager /** * SDL Joystick Class Instance */ - SCA_Joystick *m_joystick; + SCA_Joystick *m_joystick[JOYINDEX_MAX]; public: SCA_JoystickManager(class SCA_LogicManager* logicmgr); virtual ~SCA_JoystickManager(); virtual void NextFrame(double curtime,double deltatime); - SCA_Joystick* GetJoystickDevice(void); + SCA_Joystick* GetJoystickDevice(short int joyindex); }; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 3fb439eb25b..4362a896f61 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -39,6 +39,7 @@ SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr, SCA_IObject* gameobj, + short int joyindex, short int joymode, int axis, int axisf,int prec, int button, int buttonf, @@ -53,7 +54,8 @@ SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr, m_hat(hat), m_hatf(hatf), m_precision(prec), - m_joymode(joymode) + m_joymode(joymode), + m_joyindex(joyindex) { /* std::cout << " axis " << m_axis << std::endl; @@ -99,7 +101,7 @@ bool SCA_JoystickSensor::IsPositiveTrigger() bool SCA_JoystickSensor::Evaluate(CValue* event) { - SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice(); + SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice(m_joyindex); bool result = false; bool reset = m_reset && m_level; @@ -351,7 +353,7 @@ PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self, PyObject* args, PyObject* kwds) { int a,b,c,d; - SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); a = joy->GetAxis10(); b = joy->GetAxis11(); c = joy->GetAxis20(); @@ -451,7 +453,7 @@ PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self, PyObject* args, PyObject* kwds) { int num; - SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); num = joy->GetNumberOfAxes(); return Py_BuildValue("i",num); } @@ -464,7 +466,7 @@ PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self, PyObject* args, PyObject* kwds) { int num; - SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); num = joy->GetNumberOfButtons(); return Py_BuildValue("i",num); } @@ -477,7 +479,7 @@ PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self, PyObject* args, PyObject* kwds) { int num; - SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(); + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); num = joy->GetNumberOfHats(); return Py_BuildValue("i",num); } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index 69068da6494..e499d8cd0dc 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -72,6 +72,10 @@ class SCA_JoystickSensor :public SCA_ISensor * The mode to determine axis,button or hat */ short int m_joymode; + /** + * Select which joystick to use + */ + short int m_joyindex; enum KX_JOYSENSORMODE { KX_JOYSENSORMODE_NODEF = 0, @@ -85,6 +89,7 @@ class SCA_JoystickSensor :public SCA_ISensor public: SCA_JoystickSensor(class SCA_JoystickManager* eventmgr, SCA_IObject* gameobj, + short int joyindex, short int joymode, int axis, int axisf,int prec, int button, int buttonf, @@ -97,6 +102,10 @@ public: virtual bool IsPositiveTrigger(); virtual void Init(); + short int GetJoyIndex(void){ + return m_joyindex; + } + /* --------------------------------------------------------------------- */ /* Python interface ---------------------------------------------------- */ /* --------------------------------------------------------------------- */ -- cgit v1.2.3 From 7f257df5b41841fcafbc48324d4522e9e4e1cc2e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 31 Aug 2008 19:07:10 +0000 Subject: BGE patch 17547 applied in trunk: Cleaned up pydoc for BGE, compiles now error free --- source/gameengine/PyDoc/KX_GameObject.py | 12 ++++++------ source/gameengine/PyDoc/KX_ObjectActuator.py | 4 +--- source/gameengine/PyDoc/KX_PolyProxy.py | 2 +- source/gameengine/PyDoc/KX_TrackToActuator.py | 2 +- source/gameengine/PyDoc/Rasterizer.py | 3 ++- source/gameengine/PyDoc/SCA_DelaySensor.py | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 2136ce54e30..916851fa2a2 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -30,11 +30,11 @@ class KX_GameObject: Delete this object, can be used inpace of the EndObject Actuator. The actual removal of the object from the scene is delayed. """ - def getVisible(visible): + def getVisible(): """ Gets the game object's visible flag. - @type visible: boolean + @rtype: boolean """ def setVisible(visible): """ @@ -49,12 +49,12 @@ class KX_GameObject: @rtype: int @return: the objects state. """ - def setState(): + def setState(state): """ - Sets the game object's visible flag. + Sets the game object's state flag. The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29) - @type visible: boolean + @type state: integer """ def setPosition(pos): """ @@ -342,7 +342,7 @@ class KX_GameObject: @param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy} @type poly: int @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz)) - or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy)) + or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy}) @return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon) If no hit, returns (None,None,None) or (None,None,None,None) If the object hit is not a static mesh, polygon is None diff --git a/source/gameengine/PyDoc/KX_ObjectActuator.py b/source/gameengine/PyDoc/KX_ObjectActuator.py index db577d21e6f..b7b76473292 100644 --- a/source/gameengine/PyDoc/KX_ObjectActuator.py +++ b/source/gameengine/PyDoc/KX_ObjectActuator.py @@ -111,9 +111,7 @@ class KX_ObjectActuator(SCA_IActuator): For the servo control actuator, this is the target speed. @rtype: list [vx, vy, vz, local] - @return: A four item list, containing the vector velocity, and whether - the velocity is applied in local coordinates (True) or world - coordinates (False) + @return: A four item list, containing the vector velocity, and whether the velocity is applied in local coordinates (True) or world coordinates (False) """ def setLinearVelocity(vx, vy, vz, local): """ diff --git a/source/gameengine/PyDoc/KX_PolyProxy.py b/source/gameengine/PyDoc/KX_PolyProxy.py index 45ae30a13dd..bcd42c2ac2e 100644 --- a/source/gameengine/PyDoc/KX_PolyProxy.py +++ b/source/gameengine/PyDoc/KX_PolyProxy.py @@ -59,7 +59,7 @@ class KX_PolyProxy: @rtype: integer @return: the material index in the mesh - + """ def getNumVertex(): """ Returns the number of vertex of the polygon. diff --git a/source/gameengine/PyDoc/KX_TrackToActuator.py b/source/gameengine/PyDoc/KX_TrackToActuator.py index 2ecd94f38ae..948302991b7 100644 --- a/source/gameengine/PyDoc/KX_TrackToActuator.py +++ b/source/gameengine/PyDoc/KX_TrackToActuator.py @@ -21,7 +21,7 @@ class KX_TrackToActuator(SCA_IActuator): @type object: L{KX_GameObject}, string or None @param object: Either a reference to a game object or the name of the object to track. """ - def getObject(): + def getObject(name_only): """ Returns the name of the object to track. diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py index f0e48b6ed43..3711ac63b3e 100644 --- a/source/gameengine/PyDoc/Rasterizer.py +++ b/source/gameengine/PyDoc/Rasterizer.py @@ -84,7 +84,8 @@ def setMousePosition(x, y): """ Sets the mouse cursor position. - @type x, y: integer + @type x: integer + @type y: integer """ def setBackgroundColor(rgba): diff --git a/source/gameengine/PyDoc/SCA_DelaySensor.py b/source/gameengine/PyDoc/SCA_DelaySensor.py index 46b74f461a7..19df589ea7b 100644 --- a/source/gameengine/PyDoc/SCA_DelaySensor.py +++ b/source/gameengine/PyDoc/SCA_DelaySensor.py @@ -1,6 +1,6 @@ # $Id$ # Documentation for SCA_DelaySensor -from SCA_IActuator import * +from SCA_ISensor import * class SCA_DelaySensor(SCA_ISensor): """ -- cgit v1.2.3 From 234b616078ab5de7c6ef2a96c8a201a7552ae96c Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 31 Aug 2008 21:53:39 +0000 Subject: BGE bug #17459 fixed: action actuators depending on their order in the actuator list. --- source/gameengine/Converter/BL_ArmatureObject.cpp | 6 ++++++ source/gameengine/Converter/BL_ArmatureObject.h | 1 + 2 files changed, 7 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 09f1d9d4d87..cdfce321713 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -54,6 +54,7 @@ BL_ArmatureObject::BL_ArmatureObject( : KX_GameObject(sgReplicationInfo,callbacks), m_objArma(armature), m_mrdPose(NULL), + m_framePose(NULL), m_lastframe(0.), m_activeAct(NULL), m_activePriority(999) @@ -114,10 +115,15 @@ bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, m_activePriority = 9999; m_lastframe= curtime; m_activeAct = NULL; + // remember the pose at the start of the frame + m_framePose = m_pose; } if (priority<=m_activePriority) { + if (prioritySetBlendTime(0.0); /* Reset the blend timer */ m_activeAct = act; diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 752bd5eb365..a612ca77ec0 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -80,6 +80,7 @@ protected: struct bArmature *m_armature; struct bPose *m_pose; struct bPose *m_mrdPose; + struct bPose *m_framePose; double m_lastframe; class BL_ActionActuator *m_activeAct; short m_activePriority; -- cgit v1.2.3 From e8049903ac8d44973ba7c30da0f4f1d02c790d8f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 1 Sep 2008 00:12:39 +0000 Subject: BGE python api for get/setting the joystick index, minor cleanup also. --- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 105 ++++++++++----------- source/gameengine/GameLogic/SCA_JoystickSensor.h | 27 +++--- 2 files changed, 63 insertions(+), 69 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 4362a896f61..f77272b0974 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -295,6 +295,8 @@ PyParentObject SCA_JoystickSensor::Parents[] = { PyMethodDef SCA_JoystickSensor::Methods[] = { + {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, GetIndex_doc}, + {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, SetIndex_doc}, {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, GetAxis_doc}, {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, SetAxis_doc}, {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetRealAxis, METH_NOARGS, GetRealAxis_doc}, @@ -316,14 +318,36 @@ PyObject* SCA_JoystickSensor::_getattr(const STR_String& attr) { } +/* get index ---------------------------------------------------------- */ +char SCA_JoystickSensor::GetIndex_doc[] = +"getIndex\n" +"\tReturns the joystick index to use.\n"; +PyObject* SCA_JoystickSensor::PyGetIndex( PyObject* self ) { + return PyInt_FromLong(m_joyindex); +} + + +/* set index ---------------------------------------------------------- */ +char SCA_JoystickSensor::SetIndex_doc[] = +"setIndex\n" +"\tSets the joystick index to use.\n"; +PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) { + int index = PyInt_AsLong( value ); /* -1 on error, will raise an error in this case */ + if (index < 0 or index >= JOYINDEX_MAX) { + PyErr_SetString(PyExc_ValueError, "joystick index out of range or not an int"); + return NULL; + } + + m_joyindex = index; + Py_RETURN_NONE; +} + /* get axis ---------------------------------------------------------- */ char SCA_JoystickSensor::GetAxis_doc[] = "getAxis\n" "\tReturns the current state of the axis.\n"; -PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self, - PyObject* args, - PyObject* kwds) { - return Py_BuildValue("[ii]",m_axis, m_axisf); +PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) { + return PyInt_FromLong(m_joyindex); } @@ -331,9 +355,7 @@ PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self, char SCA_JoystickSensor::SetAxis_doc[] = "setAxis\n" "\tSets the current state of the axis.\n"; -PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) { int axis,axisflag; if(!PyArg_ParseTuple(args, "ii", &axis, &axisflag)){ @@ -341,7 +363,7 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, } m_axis = axis; m_axisf = axisflag; - Py_Return; + Py_RETURN_NONE; } @@ -349,16 +371,9 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, char SCA_JoystickSensor::GetRealAxis_doc[] = "getAxisValue\n" "\tReturns a list of the values for each axis .\n"; -PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self, - PyObject* args, - PyObject* kwds) { - int a,b,c,d; +PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - a = joy->GetAxis10(); - b = joy->GetAxis11(); - c = joy->GetAxis20(); - d = joy->GetAxis21(); - return Py_BuildValue("[iiii]",a,b,c,d); + return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21()); } @@ -366,10 +381,8 @@ PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self, char SCA_JoystickSensor::GetThreshold_doc[] = "getThreshold\n" "\tReturns the threshold of the axis.\n"; -PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self, - PyObject* args, - PyObject* kwds) { - return Py_BuildValue("i", m_precision); +PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self) { + return PyInt_FromLong(m_precision); } @@ -377,15 +390,13 @@ PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self, char SCA_JoystickSensor::SetThreshold_doc[] = "setThreshold\n" "\tSets the threshold of the axis.\n"; -PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, PyObject* args ) { int thresh; if(!PyArg_ParseTuple(args, "i", &thresh)){ return NULL; } m_precision = thresh; - Py_Return; + Py_RETURN_NONE; } @@ -393,9 +404,7 @@ PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, char SCA_JoystickSensor::GetButton_doc[] = "getButton\n" "\tReturns the currently pressed button.\n"; -PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self) { return Py_BuildValue("[ii]",m_button, m_buttonf); } @@ -404,16 +413,14 @@ PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self, char SCA_JoystickSensor::SetButton_doc[] = "setButton\n" "\tSets the button the sensor reacts to.\n"; -PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* args ) { int button,buttonflag; if(!PyArg_ParseTuple(args, "ii", &button, &buttonflag)){ return NULL; } m_button = button; m_buttonf = buttonflag; - Py_Return; + Py_RETURN_NONE; } @@ -421,9 +428,7 @@ PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, char SCA_JoystickSensor::GetHat_doc[] = "getHat\n" "\tReturns the current direction of the hat.\n"; -PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self ) { return Py_BuildValue("[ii]",m_hat, m_hatf); } @@ -432,16 +437,14 @@ PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self, char SCA_JoystickSensor::SetHat_doc[] = "setHat\n" "\tSets the hat the sensor reacts to.\n"; -PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, - PyObject* args, - PyObject* kwds) { +PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, PyObject* args ) { int hat,hatflag; if(!PyArg_ParseTuple(args, "ii", &hat, &hatflag)){ return NULL; } m_hat = hat; m_hatf = hatflag; - Py_Return; + Py_RETURN_NONE; } @@ -449,37 +452,25 @@ PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, char SCA_JoystickSensor::NumberOfAxes_doc[] = "getNumAxes\n" "\tReturns the number of axes .\n"; -PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self, - PyObject* args, - PyObject* kwds) { - int num; +PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - num = joy->GetNumberOfAxes(); - return Py_BuildValue("i",num); + return PyInt_FromLong( joy->GetNumberOfAxes() ); } char SCA_JoystickSensor::NumberOfButtons_doc[] = "getNumButtons\n" "\tReturns the number of buttons .\n"; -PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self, - PyObject* args, - PyObject* kwds) { - int num; +PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - num = joy->GetNumberOfButtons(); - return Py_BuildValue("i",num); + return PyInt_FromLong( joy->GetNumberOfButtons() ); } char SCA_JoystickSensor::NumberOfHats_doc[] = "getNumHats\n" "\tReturns the number of hats .\n"; -PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self, - PyObject* args, - PyObject* kwds) { - int num; +PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - num = joy->GetNumberOfHats(); - return Py_BuildValue("i",num); + return PyInt_FromLong( joy->GetNumberOfHats() ); } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index e499d8cd0dc..504c4eaa497 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -112,22 +112,25 @@ public: virtual PyObject* _getattr(const STR_String& attr); + /* Joystick Index */ + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex); + KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetIndex); /* Axes*/ - KX_PYMETHOD_DOC(SCA_JoystickSensor,GetAxis); - KX_PYMETHOD_DOC(SCA_JoystickSensor,SetAxis); - KX_PYMETHOD_DOC(SCA_JoystickSensor,GetRealAxis); - KX_PYMETHOD_DOC(SCA_JoystickSensor,GetThreshold); - KX_PYMETHOD_DOC(SCA_JoystickSensor,SetThreshold); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetAxis); + KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetAxis); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetRealAxis); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetThreshold); + KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetThreshold); /* Buttons */ - KX_PYMETHOD_DOC(SCA_JoystickSensor,GetButton); - KX_PYMETHOD_DOC(SCA_JoystickSensor,SetButton); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButton); + KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetButton); /* Hats */ - KX_PYMETHOD_DOC(SCA_JoystickSensor,GetHat); - KX_PYMETHOD_DOC(SCA_JoystickSensor,SetHat); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetHat); + KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetHat); /* number of */ - KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfAxes); - KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfButtons); - KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfHats); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfAxes); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfButtons); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfHats); }; -- cgit v1.2.3 From 7b9ee57c0bff50f812c00bc16801e8e2da12e253 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 1 Sep 2008 06:25:13 +0000 Subject: BGE joystick sensor py api function 'getConnected()', returns true if the joystick is connected and working. SCA_Joystick.h seemed to have twice as many newlines as needed. --- .../gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 10 ++ .../gameengine/GameLogic/Joystick/SCA_Joystick.h | 147 +-------------------- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 13 +- source/gameengine/GameLogic/SCA_JoystickSensor.h | 1 + 4 files changed, 28 insertions(+), 143 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index b244bddcacd..ec0b0303b68 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -367,6 +367,16 @@ void SCA_Joystick::DestroyJoystickDevice(void) } } +int SCA_Joystick::Connected(void) +{ + if (m_isinit){ + if(SDL_JoystickOpened(m_joyindex)){ + return 1; + } + } + + return 0; +} void SCA_Joystick::pFillAxes() { diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index 689efc72975..d318d28e0f7 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -1,72 +1,36 @@ /** - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - - - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): snailrose. - * - * ***** END GPL LICENSE BLOCK ***** - */ #ifndef _SCA_JOYSTICK_H_ - #define _SCA_JOYSTICK_H_ - - #include "SCA_JoystickDefines.h" - - - - /* - * Basic Joystick class * I will make this class a singleton because there should be only one joystick * even if there are more than one scene using it and count how many scene are using it. @@ -86,169 +50,105 @@ class SCA_Joystick int m_joyindex; /* - *support for 2 axes - */ int m_axis10,m_axis11; - int m_axis20,m_axis21; - /* - + /* * Precision or range of the axes - */ - int m_prec; /* - * multiple axis values stored here - */ - int m_axisnum; - int m_axisvalue; /* - * max # of axes avail - */ - /*disabled - int m_axismax; - */ /* - * button values stored here - */ - int m_buttonnum; /* - * max # of buttons avail - */ int m_buttonmax; - /* - * hat values stored here - */ - int m_hatnum; - int m_hatdir; /* * max # of hats avail - disabled - int m_hatmax; - */ - /* is the joystick initialized ?*/ - bool m_isinit; - /* is triggered */ - bool m_istrig; /* - * Open the joystick - */ - bool CreateJoystickDevice(void); /* - * Close the joystick - */ - void DestroyJoystickDevice(void); - - /* - * event callbacks - */ void OnAxisMotion(void); - void OnHatMotion(void); - void OnButtonUp(void); - void OnButtonDown(void); - void OnNothing(void); - void OnBallMotion(void){} /* - * fills the axis mnember values - */ - void pFillAxes(void); - - - void pFillButtons(void); /* - * returns m_axis10,m_axis11... - */ - int pGetAxis(int axisnum, int udlr); - + /* - * gets the current button - */ int pGetButtonPress(int button); /* - * returns if no button is pressed - */ - int pGetButtonRelease(int button); /* - * gets the current hat direction - */ - int pGetHat(int direction); SCA_Joystick(short int index); @@ -258,40 +158,27 @@ class SCA_Joystick public: static SCA_Joystick *GetInstance( short int joyindex ); - void ReleaseInstance(); - void HandleEvents(); /* - */ bool aUpAxisIsPositive(int axis); - bool aDownAxisIsPositive(int axis); - bool aLeftAxisIsPositive(int axis); - bool aRightAxisIsPositive(int axis); - bool aButtonPressIsPositive(int button); - bool aButtonReleaseIsPositive(int button); - bool aHatIsPositive(int dir); /* - * precision is default '3200' which is overridden by input - */ void cSetPrecision(int val); - - int GetAxis10(void){ return m_axis10; @@ -299,77 +186,55 @@ public: } int GetAxis11(void){ - return m_axis11; - } int GetAxis20(void){ - return m_axis20; - } int GetAxis21(void){ - return m_axis21; - } int GetButton(void){ - return m_buttonnum; - } int GetHat(void){ - return m_hatdir; - } int GetThreshold(void){ - return m_prec; - } bool IsTrig(void){ - return m_istrig; - } - /* - * returns true if an event is being processed - */ bool GetJoyAxisMotion(void); - bool GetJoyButtonPress(void); - bool GetJoyButtonRelease(void); - bool GetJoyHatMotion(void); /* - * returns the # of... - */ int GetNumberOfAxes(void); - int GetNumberOfButtons(void); - int GetNumberOfHats(void); - - + /* + * Test if the joystick is connected + */ + int Connected(void); }; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index f77272b0974..325657cbc7f 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -296,7 +296,7 @@ PyParentObject SCA_JoystickSensor::Parents[] = { PyMethodDef SCA_JoystickSensor::Methods[] = { {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, GetIndex_doc}, - {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, SetIndex_doc}, + {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, SetIndex_doc}, {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, GetAxis_doc}, {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, SetAxis_doc}, {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetRealAxis, METH_NOARGS, GetRealAxis_doc}, @@ -309,6 +309,7 @@ PyMethodDef SCA_JoystickSensor::Methods[] = { {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, NumberOfAxes_doc}, {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, NumberOfButtons_doc}, {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, NumberOfHats_doc}, + {"getConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, Connected_doc}, {NULL,NULL} //Sentinel }; @@ -333,7 +334,7 @@ char SCA_JoystickSensor::SetIndex_doc[] = "\tSets the joystick index to use.\n"; PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) { int index = PyInt_AsLong( value ); /* -1 on error, will raise an error in this case */ - if (index < 0 or index >= JOYINDEX_MAX) { + if (index < 0 || index >= JOYINDEX_MAX) { PyErr_SetString(PyExc_ValueError, "joystick index out of range or not an int"); return NULL; } @@ -474,3 +475,11 @@ PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); return PyInt_FromLong( joy->GetNumberOfHats() ); } + +char SCA_JoystickSensor::Connected_doc[] = +"getConnected\n" +"\tReturns True if a joystick is connected at this joysticks index.\n"; +PyObject* SCA_JoystickSensor::PyConnected( PyObject* self ) { + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); + return PyBool_FromLong( joy->Connected() ); +} diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index 504c4eaa497..a21146b568b 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -131,6 +131,7 @@ public: KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfAxes); KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfButtons); KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfHats); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,Connected); }; -- cgit v1.2.3 From 81ad271d157c70433b36af31581261ae8c2098a4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 2 Sep 2008 02:03:03 +0000 Subject: BGE joystick sensor bugfix, was sending true events logic tick (as if the true pulse option was enabled). --- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 24 ++++++++++++++++++++-- source/gameengine/GameLogic/SCA_JoystickSensor.h | 6 ++++++ 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 325657cbc7f..456401d48df 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -120,7 +120,7 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) js->cSetPrecision(m_precision); if(m_axisf == 1){ if(js->aUpAxisIsPositive(m_axis)){ - m_istrig =1; + m_istrig = 1; result = true; }else{ if(m_istrig){ @@ -243,11 +243,31 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) printf("Error invalid switch statement\n"); break; } - if(!js->IsTrig()){ + + if (js->IsTrig()) { + /* This test detects changes with the joystick trigger state. + * js->IsTrig() will stay true as long as the key is held. + * even though the event from SDL will only be sent once. + * istrig_js && m_istrig_lastjs - when this is true it means this sensor + * had the same joystick trigger state last time, + * Setting the result false this time means it wont run the sensors + * controller every time (like a pulse sensor) + * + * This is not done with the joystick its self incase other sensors use + * it or become active. + */ + if (m_istrig_lastjs) { + result = false; + } + m_istrig_lastjs = true; + } else { m_istrig = 0; + m_istrig_lastjs = false; } + if (reset) result = true; + return result; } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index a21146b568b..8b74f6e0296 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -68,6 +68,12 @@ class SCA_JoystickSensor :public SCA_ISensor * Is an event triggered ? */ bool m_istrig; + /** + * Last trigger state for this sensors joystick, + * Otherwise it will trigger all the time + * this is used to see if the trigger state changes. + */ + bool m_istrig_lastjs; /** * The mode to determine axis,button or hat */ -- cgit v1.2.3 From 84dcfa181b0722655ceba3930a2daa0e27e72f93 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 2 Sep 2008 06:12:19 +0000 Subject: BGE Bugfix, SDL joysticks arrow keys didnt work when 2 joysticks were being used at the same time. The event queue was running for every joystick sensor without checking if the events were for that joystick. seperating the event queue for each joystick is overkill so instead deal with all joysticks events in once function. Also removed some unused functions --- .../gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 102 --------------------- .../gameengine/GameLogic/Joystick/SCA_Joystick.h | 36 +++----- .../GameLogic/Joystick/SCA_JoystickDefines.h | 8 -- .../GameLogic/Joystick/SCA_JoystickEvents.cpp | 56 ++++++++--- .../GameLogic/Joystick/SCA_JoystickPrivate.h | 4 - .../gameengine/GameLogic/SCA_JoystickManager.cpp | 22 +++-- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 4 +- 7 files changed, 74 insertions(+), 158 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index ec0b0303b68..06002060bf1 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -99,38 +99,6 @@ void SCA_Joystick::ReleaseInstance() } } -void SCA_Joystick::HandleEvents() -{ - if(m_isinit) - { - if(SDL_PollEvent(&m_private->m_event)) - { - switch(m_private->m_event.type) - { - case SDL_JOYAXISMOTION: - HANDLE_AXISMOTION(OnAxisMotion); - break; - case SDL_JOYHATMOTION: - HANDLE_HATMOTION(OnHatMotion); - break; - case SDL_JOYBUTTONUP: - HANDLE_BUTTONUP(OnButtonUp); - break; - case SDL_JOYBUTTONDOWN: - HANDLE_BUTTONDOWN(OnButtonDown); - break; - case SDL_JOYBALLMOTION: - HANDLE_BALLMOTION(OnBallMotion); - break; - default: - HANDLE_NOEVENT(OnNothing); - break; - } - } - } -} - - void SCA_Joystick::cSetPrecision(int val) { m_prec = val; @@ -229,76 +197,6 @@ int SCA_Joystick::pGetHat(int direction) return 0; } - -bool SCA_Joystick::GetJoyAxisMotion() -{ - bool result = false; - if(m_isinit){ - if(SDL_PollEvent(&m_private->m_event)){ - switch(m_private->m_event.type) - { - case SDL_JOYAXISMOTION: - result = true; - break; - } - } - } - return result; -} - - -bool SCA_Joystick::GetJoyButtonPress() -{ - bool result = false; - if(m_isinit){ - if(SDL_PollEvent(&m_private->m_event)){ - switch(m_private->m_event.type) - { - case SDL_JOYBUTTONDOWN: - result = true; - break; - } - } - } - return result; -} - - -bool SCA_Joystick::GetJoyButtonRelease() -{ - bool result = false; - if(m_isinit) - { - if(SDL_PollEvent(&m_private->m_event)){ - switch(m_private->m_event.type) - { - case SDL_JOYBUTTONUP: - result = true; - break; - } - } - } - return result; -} - - -bool SCA_Joystick::GetJoyHatMotion() -{ - bool result = false; - if(m_isinit){ - if(SDL_PollEvent(&m_private->m_event)){ - switch(m_private->m_event.type) - { - case SDL_JOYHATMOTION: - result = true; - break; - } - } - } - return 0; -} - - int SCA_Joystick::GetNumberOfAxes() { int number; diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index d318d28e0f7..bcbb43241c2 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -29,6 +29,7 @@ #define _SCA_JOYSTICK_H_ #include "SCA_JoystickDefines.h" +#include "SDL.h" /* * Basic Joystick class @@ -103,6 +104,16 @@ class SCA_Joystick /* is triggered */ bool m_istrig; + /* + * event callbacks + */ + void OnAxisMotion(SDL_Event *sdl_event); + void OnHatMotion(SDL_Event *sdl_event); + void OnButtonUp(SDL_Event *sdl_event); + void OnButtonDown(SDL_Event *sdl_event); + void OnNothing(SDL_Event *sdl_event); + void OnBallMotion(SDL_Event *sdl_event){} + /* * Open the joystick */ @@ -112,17 +123,6 @@ class SCA_Joystick * Close the joystick */ void DestroyJoystickDevice(void); - - /* - * event callbacks - */ - - void OnAxisMotion(void); - void OnHatMotion(void); - void OnButtonUp(void); - void OnButtonDown(void); - void OnNothing(void); - void OnBallMotion(void){} /* * fills the axis mnember values @@ -158,9 +158,9 @@ class SCA_Joystick public: static SCA_Joystick *GetInstance( short int joyindex ); + static void HandleEvents( void ); void ReleaseInstance(); - void HandleEvents(); /* */ @@ -212,16 +212,6 @@ public: bool IsTrig(void){ return m_istrig; } - - - /* - * returns true if an event is being processed - */ - - bool GetJoyAxisMotion(void); - bool GetJoyButtonPress(void); - bool GetJoyButtonRelease(void); - bool GetJoyHatMotion(void); /* * returns the # of... @@ -237,7 +227,7 @@ public: int Connected(void); }; - +void Joystick_HandleEvents( void ); #endif diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h index 8d8f88ecaf2..73ffe1406d9 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h @@ -40,12 +40,4 @@ #define JOYINDEX_MAX 8 -/* function callbacks */ -#define HANDLE_AXISMOTION(fn) ((fn)(), 0L) -#define HANDLE_HATMOTION(fn) ((fn)(), 0L) -#define HANDLE_BUTTONUP(fn) ((fn)(), 0L) -#define HANDLE_BUTTONDOWN(fn) ((fn)(), 0L) -#define HANDLE_BALLMOTION(fn) ((fn)(), 0L) -#define HANDLE_NOEVENT(fn) ((fn)(), 0L) - #endif diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp index ab523470e21..1e064f55397 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp @@ -30,41 +30,75 @@ -void SCA_Joystick::OnAxisMotion(void) +void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event) { pFillAxes(); - m_axisnum = m_private->m_event.jaxis.axis; - m_axisvalue = m_private->m_event.jaxis.value; + m_axisnum = sdl_event->jaxis.axis; + m_axisvalue = sdl_event->jaxis.value; m_istrig = 1; } -void SCA_Joystick::OnHatMotion(void) +void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event) { - m_hatdir = m_private->m_event.jhat.value; - m_hatnum = m_private->m_event.jhat.hat; + m_hatdir = sdl_event->jhat.value; + m_hatnum = sdl_event->jhat.hat; m_istrig = 1; } -void SCA_Joystick::OnButtonUp(void) +void SCA_Joystick::OnButtonUp(SDL_Event* sdl_event) { m_buttonnum = -2; } -void SCA_Joystick::OnButtonDown(void) +void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event) { m_buttonmax = GetNumberOfButtons(); - if(m_private->m_event.jbutton.button >= 1 || m_private->m_event.jbutton.button <= m_buttonmax) + if(sdl_event->jbutton.button >= 1 || sdl_event->jbutton.button <= m_buttonmax) { m_istrig = 1; - m_buttonnum = m_private->m_event.jbutton.button; + m_buttonnum = sdl_event->jbutton.button; } } -void SCA_Joystick::OnNothing(void) +void SCA_Joystick::OnNothing(SDL_Event* sdl_event) { m_istrig = 0; } + +/* only handle events for 1 joystick */ + +void SCA_Joystick::HandleEvents(void) +{ + SDL_Event sdl_event; + + if(SDL_PollEvent(&sdl_event)) + { + /* Note! m_instance[sdl_event.jaxis.which] + * will segfault if over JOYINDEX_MAX, not too nice but what are the chances? */ + switch(sdl_event.type) + { + case SDL_JOYAXISMOTION: + SCA_Joystick::m_instance[sdl_event.jaxis.which]->OnAxisMotion(&sdl_event); + break; + case SDL_JOYHATMOTION: + SCA_Joystick::m_instance[sdl_event.jhat.which]->OnHatMotion(&sdl_event); + break; + case SDL_JOYBUTTONUP: + SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonUp(&sdl_event); + break; + case SDL_JOYBUTTONDOWN: + SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonDown(&sdl_event); + break; + case SDL_JOYBALLMOTION: + SCA_Joystick::m_instance[sdl_event.jball.which]->OnBallMotion(&sdl_event); + break; + default: + printf("SCA_Joystick::HandleEvents, Unknown SDL event, this should not happen\n"); + break; + } + } +} diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h index 23fad3cd55d..bb6bfe2d4cc 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h @@ -32,10 +32,6 @@ class SCA_Joystick::PrivateData { public: - /* - * SDL events structure - */ - SDL_Event m_event; /* * The Joystick */ diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp index 08c36326712..a86770a6e0a 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp @@ -44,7 +44,6 @@ SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr) for (i=0; i::iterator it; - for (it = m_sensors.begin(); it != m_sensors.end(); it++) - { - SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it); - if(!joysensor->IsSuspended()) + if (m_sensors.size()==0) { + return; + } + else { + set::iterator it; + + SCA_Joystick::HandleEvents(); /* Handle all SDL Joystick events */ + + for (it = m_sensors.begin(); it != m_sensors.end(); it++) { - m_joystick[joysensor->GetJoyIndex()]->HandleEvents(); - joysensor->Activate(m_logicmgr, NULL); + SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it); + if(!joysensor->IsSuspended()) + { + joysensor->Activate(m_logicmgr, NULL); + } } } } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 456401d48df..b32cbd83285 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -245,10 +245,10 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) } if (js->IsTrig()) { - /* This test detects changes with the joystick trigger state. + /* The if below detects changes with the joystick trigger state. * js->IsTrig() will stay true as long as the key is held. * even though the event from SDL will only be sent once. - * istrig_js && m_istrig_lastjs - when this is true it means this sensor + * (js->IsTrig() && m_istrig_lastjs) - when true it means this sensor * had the same joystick trigger state last time, * Setting the result false this time means it wont run the sensors * controller every time (like a pulse sensor) -- cgit v1.2.3 From 0fe906f49e259f5c2042070d2201291f32ad3223 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 2 Sep 2008 18:34:54 +0000 Subject: BGE patch: simple fix to synchronize sensor pulse mode with sensor state transitions. --- source/gameengine/GameLogic/SCA_ISensor.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index c96eb82e29e..084b1395159 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -226,6 +226,9 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event) bool result = this->Evaluate(event); if (result) { logicmgr->AddActivatedSensor(this); + // reset these counters so that pulse are synchronized with transition + m_pos_ticks = 0; + m_neg_ticks = 0; } else { /* First, the pulsing behaviour, if pulse mode is -- cgit v1.2.3 From fe93743518b32fbb43ec8f3b11640672867a3937 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 2 Sep 2008 22:13:07 +0000 Subject: BGE patch 17547 approved: Cleaned up pydoc for BGE, compiles now error free --- source/gameengine/PyDoc/KX_GameObject.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 916851fa2a2..9729b14a43f 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -300,12 +300,13 @@ class KX_GameObject: @rtype: L{KX_GameObject} @return: the first object hit or None if no object or object does not match prop """ - def rayCast(to,from,dist,prop,face,xray,poly): + def rayCast(objto,objfrom,dist,prop,face,xray,poly): """ Look from a point/object to another point/object and find first object hit within dist that matches prop. if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit. if poly is 1, returns a 4-tuple with in addition a L{KX_PolyProxy} as 4th element. - Ex: + + Ex:: # shoot along the axis gun-gunAim (gunAim should be collision-free) ob,point,normal = gun.rayCast(gunAim,None,50) if ob: @@ -314,23 +315,26 @@ class KX_GameObject: Notes: The ray ignores the object on which the method is called. It is casted from/to object center or explicit [x,y,z] points. - The face paremeter determines the orientation of the normal: + + The face paremeter determines the orientation of the normal:: 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside) 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect) + The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray. - The prop and xray parameters interact as follow: + The prop and xray parameters interact as follow:: prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray. prop off, xray on : idem. prop on, xray off: return closest hit if it matches prop, no hit otherwise. prop on, xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray. The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray. If there is no hit or the hit object is not a static mesh, None is returned as 4th element. - The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects. + + The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects. - @param to: [x,y,z] or object to which the ray is casted - @type to: L{KX_GameObject} or 3-tuple - @param from: [x,y,z] or object from which the ray is casted; None or omitted => use self object center - @type from: L{KX_GameObject} or 3-tuple or None + @param objto: [x,y,z] or object to which the ray is casted + @type objto: L{KX_GameObject} or 3-tuple + @param objfrom: [x,y,z] or object from which the ray is casted; None or omitted => use self object center + @type objfrom: L{KX_GameObject} or 3-tuple or None @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to @type dist: float @param prop: property name that object must have; can be omitted => detect any object -- cgit v1.2.3 From 1926e846500212d11061c23cacdbd08d88e375da Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 3 Sep 2008 02:27:16 +0000 Subject: Finally upgraded to latest Bullet subversion, about to release 2.71. Some recent changes in extern/bullet2 need to be re-applied, will check with Benoit. Ray tests in 0_FPS_Template.blend is broken, didn't figure out why yet. HELP BUILD SYSTEM MAINTAINERS: Please help with updating all build systems: the newly added files need to be added. Note that the src/SoftBody has been added for future extension of real-time soft bodies. --- .../Converter/KX_BlenderSceneConverter.cpp | 5 ++ .../Physics/Bullet/CcdPhysicsController.cpp | 15 +++--- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 61 ++++++++++++---------- .../Physics/Bullet/CcdPhysicsEnvironment.h | 4 ++ 4 files changed, 51 insertions(+), 34 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index de91bce2ab1..f5fb8ce852d 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -245,6 +245,11 @@ struct BlenderDebugDraw : public btIDebugDraw { return m_debugMode; } + ///todo: find out if Blender can do this + virtual void draw3dText(const btVector3& location,const char* textString) + { + + } }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 2ec96c75a68..e85238b49c3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -126,13 +126,14 @@ void CcdPhysicsController::CreateRigidbody() m_bulletMotionState = new BlenderBulletMotionState(m_MotionState); - m_body = new btRigidBody(m_cci.m_mass, - m_bulletMotionState, - m_collisionShape, - m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor, - m_cci.m_linearDamping,m_cci.m_angularDamping, - m_cci.m_friction,m_cci.m_restitution); - + btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); + rbci.m_linearDamping = m_cci.m_linearDamping; + rbci.m_angularDamping = m_cci.m_angularDamping; + rbci.m_friction = m_cci.m_friction; + rbci.m_restitution = m_cci.m_restitution; + + m_body = new btRigidBody(rbci); + // // init the rigidbody properly // diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index d14ddf8f65c..f9242e6876f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -330,30 +330,21 @@ m_filterCallback(NULL) { m_triggerCallbacks[i] = 0; } + m_collisionConfiguration = new btDefaultCollisionConfiguration(); + if (!dispatcher) { - dispatcher = new btCollisionDispatcher(); + dispatcher = new btCollisionDispatcher(m_collisionConfiguration); m_ownDispatcher = dispatcher; } - if(!pairCache) - { - - //todo: calculate/let user specify this world sizes - btVector3 worldMin(-10000,-10000,-10000); - btVector3 worldMax(10000,10000,10000); - - pairCache = new btAxisSweep3(worldMin,worldMax); - // remember that this was allocated by us so that we can release it - m_ownPairCache = pairCache; - //broadphase = new btSimpleBroadphase(); - } + m_broadphase = new btDbvtBroadphase(); m_filterCallback = new CcdOverlapFilterCallBack(this); - pairCache->setOverlapFilterCallback(m_filterCallback); + m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback); setSolverType(1);//issues with quickstep and memory allocations - m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,m_solver); + m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); m_debugDrawer = 0; m_gravity = btVector3(0.f,-10.f,0.f); m_dynamicsWorld->setGravity(m_gravity); @@ -519,6 +510,9 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) veh->SyncWheels(); } + m_dynamicsWorld->debugDrawWorld(); + + CallbackTriggers(); return true; @@ -579,7 +573,7 @@ void CcdPhysicsEnvironment::setSolverDamping(float damping) void CcdPhysicsEnvironment::setLinearAirDamping(float damping) { - gLinearAirDamping = damping; + //gLinearAirDamping = damping; } void CcdPhysicsEnvironment::setUseEpa(bool epa) @@ -598,7 +592,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType) { m_solver = new btSequentialImpulseConstraintSolver(); - ((btSequentialImpulseConstraintSolver*)m_solver)->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); +// ((btSequentialImpulseConstraintSolver*)m_solver)->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); break; } } @@ -660,9 +654,10 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( { + bool useReferenceFrameA = true; genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, - frameInA,frameInB); + frameInA,frameInB,useReferenceFrameA); genericConstraint->setLinearLowerLimit(linearMinLimits); genericConstraint->setLinearUpperLimit(linearMaxLimits); genericConstraint->setAngularLowerLimit(angularMinLimits); @@ -742,14 +737,15 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it if (rayResult.m_localShapeInfo) { - m_hitTriangleShape = rayResult.m_localShapeInfo->m_triangleShape; - m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex; + m_hitTriangleShape = NULL;//rayResult.m_localShapeInfo->m_triangleShape; + m_hitTriangleIndex = 0;//rayResult.m_localShapeInfo->m_triangleIndex; } else { m_hitTriangleShape = NULL; m_hitTriangleIndex = 0; } - return ClosestRayResultCallback::AddSingleResult(rayResult); + bool normalInWorldspace = true; + return ClosestRayResultCallback::addSingleResult(rayResult,normalInWorldspace); } }; @@ -775,8 +771,11 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac memset(&result, 0, sizeof(result)); // don't collision with sensor object - m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback, CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter,filterCallback.m_faceNormal); - if (rayCallback.HasHit()) + rayCallback.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter; + //, ,filterCallback.m_faceNormal); + + m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback); + if (rayCallback.hasHit()) { CcdPhysicsController* controller = static_cast(rayCallback.m_collisionObject->getUserPointer()); result.m_controller = controller; @@ -881,6 +880,12 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment() if (NULL != m_filterCallback) delete m_filterCallback; + + if (NULL != m_collisionConfiguration) + delete m_collisionConfiguration; + + if (NULL != m_broadphase) + delete m_broadphase; } @@ -893,7 +898,7 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float { //param = 1..12, min0,max0,min1,max1...min6,max6 btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint; - genCons->SetLimit(param,value0,value1); + genCons->setLimit(param,value0,value1); break; }; default: @@ -1239,10 +1244,11 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA; frameInB = inv * globalFrameA; - + bool useReferenceFrameA = true; + genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, - frameInA,frameInB); + frameInA,frameInB,useReferenceFrameA); } else @@ -1263,9 +1269,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl ///frameInB in worldspace frameInB = rb0->getCenterOfMassTransform() * frameInA; + bool useReferenceFrameA = true; genericConstraint = new btGeneric6DofConstraint( *rb0,s_fixedObject2, - frameInA,frameInB); + frameInA,frameInB,useReferenceFrameA); } if (genericConstraint) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 667e310dcb3..3cf5a943e3f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -56,6 +56,10 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment protected: btIDebugDraw* m_debugDrawer; + + class btDefaultCollisionConfiguration* m_collisionConfiguration; + class btBroadphaseInterface* m_broadphase; + //solver iterations int m_numIterations; -- cgit v1.2.3 From cfa07e8d2bdc0a8db15082a692ce25c2fb010ae6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 3 Sep 2008 06:43:07 +0000 Subject: BGE Py api, deleting properties didnt raise an error when the property wasnt there. also added some exception messages and renamed joystick getConnected() to isConnected() --- source/gameengine/Expressions/PyObjectPlus.cpp | 4 ++- source/gameengine/Expressions/Value.cpp | 30 ++++++++++++++-------- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 10 +++++--- 4 files changed, 30 insertions(+), 16 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 8937f481922..1eca527151a 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -119,6 +119,7 @@ PyObject *PyObjectPlus::_getattr(const STR_String& attr) int PyObjectPlus::_delattr(const STR_String& attr) { + PyErr_SetString(PyExc_AttributeError, "attribute cant be deleted"); return 1; } @@ -126,7 +127,8 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value) { //return PyObject::_setattr(attr,value); //cerr << "Unknown attribute" << endl; - return 1; + PyErr_SetString(PyExc_AttributeError, "attribute cant be set"); + return 1; } /*------------------------------ diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp index 7bcb45228db..7296dfbec10 100644 --- a/source/gameengine/Expressions/Value.cpp +++ b/source/gameengine/Expressions/Value.cpp @@ -391,16 +391,23 @@ float CValue::GetPropertyNumber(const STR_String& inName,float defnumber) bool CValue::RemoveProperty(const STR_String & inName) { // Check if there are properties at all which can be removed - if (m_pNamedPropertyArray == NULL) - return false; - - CValue* val = GetProperty(inName); - if (NULL != val) - { - val->Release(); - m_pNamedPropertyArray->erase(inName); - return true; - } + if (m_pNamedPropertyArray) { + CValue* val = GetProperty(inName); + if (NULL != val) + { + val->Release(); + m_pNamedPropertyArray->erase(inName); + return true; + } + } + + char err[128]; + if (m_pNamedPropertyArray) + sprintf(err, "attribute \"%s\" dosnt exist", inName.ReadPtr()); + else + sprintf(err, "attribute \"%s\" dosnt exist (no property array)", inName.ReadPtr()); + + PyErr_SetString(PyExc_AttributeError, err); return false; } @@ -755,7 +762,8 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj) int CValue::_delattr(const STR_String& attr) { - RemoveProperty(attr); + if (!RemoveProperty(attr)) /* sets error */ + return 1; return 0; } diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index b32cbd83285..645afc8964b 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -329,7 +329,7 @@ PyMethodDef SCA_JoystickSensor::Methods[] = { {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, NumberOfAxes_doc}, {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, NumberOfButtons_doc}, {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, NumberOfHats_doc}, - {"getConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, Connected_doc}, + {"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, Connected_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index c1b228e8d26..cc2956813c1 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1036,11 +1036,15 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr) int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr method { - if (attr == "mass") + if (attr == "mass") { + PyErr_SetString(PyExc_AttributeError, "attribute \"mass\" is read only"); return 1; + } - if (attr == "parent") + if (attr == "parent") { + PyErr_SetString(PyExc_AttributeError, "attribute \"mass\" is read only\nUse setParent()"); return 1; + } if (PyInt_Check(value)) { @@ -1106,7 +1110,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr } return 1; } - + PyErr_SetString(PyExc_AttributeError, "could not set the orientation from a 3x3 matrix, quaternion or euler sequence"); return 1; } -- cgit v1.2.3 From 096b4638c461cba2e97d336553225e3001da438f Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Wed, 3 Sep 2008 11:11:11 +0000 Subject: Revert rev16344 on trunk, bullet work is done in sim_physics branch as discussed on sunday meeting --- .../Converter/KX_BlenderSceneConverter.cpp | 5 -- .../Physics/Bullet/CcdPhysicsController.cpp | 15 +++--- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 61 ++++++++++------------ .../Physics/Bullet/CcdPhysicsEnvironment.h | 4 -- 4 files changed, 34 insertions(+), 51 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index f5fb8ce852d..de91bce2ab1 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -245,11 +245,6 @@ struct BlenderDebugDraw : public btIDebugDraw { return m_debugMode; } - ///todo: find out if Blender can do this - virtual void draw3dText(const btVector3& location,const char* textString) - { - - } }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index e85238b49c3..2ec96c75a68 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -126,14 +126,13 @@ void CcdPhysicsController::CreateRigidbody() m_bulletMotionState = new BlenderBulletMotionState(m_MotionState); - btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); - rbci.m_linearDamping = m_cci.m_linearDamping; - rbci.m_angularDamping = m_cci.m_angularDamping; - rbci.m_friction = m_cci.m_friction; - rbci.m_restitution = m_cci.m_restitution; - - m_body = new btRigidBody(rbci); - + m_body = new btRigidBody(m_cci.m_mass, + m_bulletMotionState, + m_collisionShape, + m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor, + m_cci.m_linearDamping,m_cci.m_angularDamping, + m_cci.m_friction,m_cci.m_restitution); + // // init the rigidbody properly // diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index f9242e6876f..d14ddf8f65c 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -330,21 +330,30 @@ m_filterCallback(NULL) { m_triggerCallbacks[i] = 0; } - m_collisionConfiguration = new btDefaultCollisionConfiguration(); - if (!dispatcher) { - dispatcher = new btCollisionDispatcher(m_collisionConfiguration); + dispatcher = new btCollisionDispatcher(); m_ownDispatcher = dispatcher; } - m_broadphase = new btDbvtBroadphase(); + if(!pairCache) + { + + //todo: calculate/let user specify this world sizes + btVector3 worldMin(-10000,-10000,-10000); + btVector3 worldMax(10000,10000,10000); + + pairCache = new btAxisSweep3(worldMin,worldMax); + // remember that this was allocated by us so that we can release it + m_ownPairCache = pairCache; + //broadphase = new btSimpleBroadphase(); + } m_filterCallback = new CcdOverlapFilterCallBack(this); - m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback); + pairCache->setOverlapFilterCallback(m_filterCallback); setSolverType(1);//issues with quickstep and memory allocations - m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); + m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,m_solver); m_debugDrawer = 0; m_gravity = btVector3(0.f,-10.f,0.f); m_dynamicsWorld->setGravity(m_gravity); @@ -510,9 +519,6 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) veh->SyncWheels(); } - m_dynamicsWorld->debugDrawWorld(); - - CallbackTriggers(); return true; @@ -573,7 +579,7 @@ void CcdPhysicsEnvironment::setSolverDamping(float damping) void CcdPhysicsEnvironment::setLinearAirDamping(float damping) { - //gLinearAirDamping = damping; + gLinearAirDamping = damping; } void CcdPhysicsEnvironment::setUseEpa(bool epa) @@ -592,7 +598,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType) { m_solver = new btSequentialImpulseConstraintSolver(); -// ((btSequentialImpulseConstraintSolver*)m_solver)->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); + ((btSequentialImpulseConstraintSolver*)m_solver)->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER); break; } } @@ -654,10 +660,9 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( { - bool useReferenceFrameA = true; genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, - frameInA,frameInB,useReferenceFrameA); + frameInA,frameInB); genericConstraint->setLinearLowerLimit(linearMinLimits); genericConstraint->setLinearUpperLimit(linearMaxLimits); genericConstraint->setAngularLowerLimit(angularMinLimits); @@ -737,15 +742,14 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it if (rayResult.m_localShapeInfo) { - m_hitTriangleShape = NULL;//rayResult.m_localShapeInfo->m_triangleShape; - m_hitTriangleIndex = 0;//rayResult.m_localShapeInfo->m_triangleIndex; + m_hitTriangleShape = rayResult.m_localShapeInfo->m_triangleShape; + m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex; } else { m_hitTriangleShape = NULL; m_hitTriangleIndex = 0; } - bool normalInWorldspace = true; - return ClosestRayResultCallback::addSingleResult(rayResult,normalInWorldspace); + return ClosestRayResultCallback::AddSingleResult(rayResult); } }; @@ -771,11 +775,8 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac memset(&result, 0, sizeof(result)); // don't collision with sensor object - rayCallback.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter; - //, ,filterCallback.m_faceNormal); - - m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback); - if (rayCallback.hasHit()) + m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback, CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter,filterCallback.m_faceNormal); + if (rayCallback.HasHit()) { CcdPhysicsController* controller = static_cast(rayCallback.m_collisionObject->getUserPointer()); result.m_controller = controller; @@ -880,12 +881,6 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment() if (NULL != m_filterCallback) delete m_filterCallback; - - if (NULL != m_collisionConfiguration) - delete m_collisionConfiguration; - - if (NULL != m_broadphase) - delete m_broadphase; } @@ -898,7 +893,7 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float { //param = 1..12, min0,max0,min1,max1...min6,max6 btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint; - genCons->setLimit(param,value0,value1); + genCons->SetLimit(param,value0,value1); break; }; default: @@ -1244,11 +1239,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA; frameInB = inv * globalFrameA; - bool useReferenceFrameA = true; - + genericConstraint = new btGeneric6DofConstraint( *rb0,*rb1, - frameInA,frameInB,useReferenceFrameA); + frameInA,frameInB); } else @@ -1269,10 +1263,9 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl ///frameInB in worldspace frameInB = rb0->getCenterOfMassTransform() * frameInA; - bool useReferenceFrameA = true; genericConstraint = new btGeneric6DofConstraint( *rb0,s_fixedObject2, - frameInA,frameInB,useReferenceFrameA); + frameInA,frameInB); } if (genericConstraint) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 3cf5a943e3f..667e310dcb3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -56,10 +56,6 @@ class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment protected: btIDebugDraw* m_debugDrawer; - - class btDefaultCollisionConfiguration* m_collisionConfiguration; - class btBroadphaseInterface* m_broadphase; - //solver iterations int m_numIterations; -- cgit v1.2.3 From 961a26d50058de81ca27a9465320c0177e5eeeb4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 3 Sep 2008 23:51:55 +0000 Subject: fix for 2 python refcounting errors --- source/gameengine/Ketsji/KX_PythonInit.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index e9fb0278d76..4b6a38f18c0 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -274,7 +274,7 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) { char cpath[sizeof(G.sce)]; char *searchpath = NULL; - PyObject* list; + PyObject* list, *value; DIR *dp; struct dirent *dirp; @@ -300,7 +300,9 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) while ((dirp = readdir(dp)) != NULL) { if (BLI_testextensie(dirp->d_name, ".blend")) { - PyList_Append(list, PyString_FromString(dirp->d_name)); + value = PyString_FromString(dirp->d_name); + PyList_Append(list, value); + Py_DECREF(value); } } -- cgit v1.2.3 From f0eaf424ab7488b93f18c634ba825c3b734ad913 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Thu, 4 Sep 2008 15:29:43 +0000 Subject: Added SDL headers so gamestuff compiles with Makefiles again. Kent --- source/gameengine/Ketsji/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index 59cc6c8ca7e..995237adf2c 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -35,6 +35,7 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) +CPPFLAGS += $(NAN_SDLCFLAGS) CPPFLAGS += $(OGL_CPPFLAGS) CPPFLAGS += -I$(NAN_GLEW)/include CPPFLAGS += -I$(OPENGL_HEADERS) -- cgit v1.2.3 From cb89decfdcf5e6b2f26376d416633f4ccf0c532d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 4 Sep 2008 20:51:28 +0000 Subject: Merge of first part of changes from the apricot branch, especially the features that are needed to run the game. Compile tested with scons, make, but not cmake, that seems to have an issue not related to these changes. The changes include: * GLSL support in the viewport and game engine, enable in the game menu in textured draw mode. * Synced and merged part of the duplicated blender and gameengine/ gameplayer drawing code. * Further refactoring of game engine drawing code, especially mesh storage changed a lot. * Optimizations in game engine armatures to avoid recomputations. * A python function to get the framerate estimate in game. * An option take object color into account in materials. * An option to restrict shadow casters to a lamp's layers. * Increase from 10 to 18 texture slots for materials, lamps, word. An extra texture slot shows up once the last slot is used. * Memory limit for undo, not enabled by default yet because it needs the .B.blend to be changed. * Multiple undo for image painting. * An offset for dupligroups, so not all objects in a group have to be at the origin. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 20 +- source/gameengine/BlenderRoutines/CMakeLists.txt | 1 + source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 75 --- source/gameengine/BlenderRoutines/KX_BlenderGL.h | 3 - .../BlenderRoutines/KX_BlenderRenderTools.cpp | 251 +++---- .../BlenderRoutines/KX_BlenderRenderTools.h | 67 +- source/gameengine/BlenderRoutines/Makefile | 5 +- source/gameengine/BlenderRoutines/SConscript | 5 +- source/gameengine/Converter/BL_ArmatureObject.cpp | 74 +- source/gameengine/Converter/BL_ArmatureObject.h | 8 +- .../Converter/BL_BlenderDataConversion.cpp | 140 ++-- .../Converter/BL_DeformableGameObject.cpp | 8 +- source/gameengine/Converter/BL_MeshDeformer.cpp | 89 +-- source/gameengine/Converter/BL_MeshDeformer.h | 3 +- .../Converter/BL_ShapeActionActuator.cpp | 1 - source/gameengine/Converter/BL_ShapeDeformer.cpp | 3 - source/gameengine/Converter/BL_ShapeDeformer.h | 11 - source/gameengine/Converter/BL_SkinDeformer.cpp | 47 +- source/gameengine/Converter/BL_SkinDeformer.h | 16 +- source/gameengine/Converter/BL_SkinMeshObject.cpp | 74 +- source/gameengine/Converter/BL_SkinMeshObject.h | 45 +- source/gameengine/Converter/CMakeLists.txt | 1 + .../Converter/KX_BlenderSceneConverter.cpp | 25 +- .../Converter/KX_BlenderSceneConverter.h | 2 + .../gameengine/Converter/KX_ConvertActuators.cpp | 2 +- source/gameengine/Converter/Makefile | 1 + source/gameengine/Converter/SConscript | 2 +- source/gameengine/GamePlayer/common/CMakeLists.txt | 2 +- .../GamePlayer/common/GPC_RenderTools.cpp | 537 ++++++--------- .../gameengine/GamePlayer/common/GPC_RenderTools.h | 163 ++--- source/gameengine/GamePlayer/common/Makefile | 5 +- source/gameengine/GamePlayer/common/SConscript | 2 +- .../GamePlayer/common/unix/GPU_PolygonMaterial.h | 4 +- source/gameengine/GamePlayer/ghost/CMakeLists.txt | 1 + .../GamePlayer/ghost/GPG_Application.cpp | 34 +- .../gameengine/GamePlayer/ghost/GPG_Application.h | 6 +- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 16 +- source/gameengine/GamePlayer/ghost/Makefile | 5 +- source/gameengine/GamePlayer/ghost/SConscript | 4 +- source/gameengine/Ketsji/BL_BlenderShader.cpp | 124 +--- source/gameengine/Ketsji/BL_BlenderShader.h | 10 +- source/gameengine/Ketsji/BL_Material.h | 6 +- source/gameengine/Ketsji/BL_Shader.cpp | 12 +- source/gameengine/Ketsji/BL_Shader.h | 2 +- source/gameengine/Ketsji/CMakeLists.txt | 1 + source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 126 ++-- source/gameengine/Ketsji/KX_BlenderMaterial.h | 3 +- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 136 ++-- source/gameengine/Ketsji/KX_GameObject.cpp | 98 ++- source/gameengine/Ketsji/KX_GameObject.h | 77 ++- source/gameengine/Ketsji/KX_ISceneConverter.h | 4 + source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 32 +- source/gameengine/Ketsji/KX_KetsjiEngine.h | 7 + source/gameengine/Ketsji/KX_Light.cpp | 57 +- source/gameengine/Ketsji/KX_Light.h | 11 +- source/gameengine/Ketsji/KX_MeshProxy.cpp | 13 +- source/gameengine/Ketsji/KX_PolyProxy.cpp | 18 +- source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 50 +- source/gameengine/Ketsji/KX_PolygonMaterial.h | 2 - source/gameengine/Ketsji/KX_PythonInit.cpp | 89 ++- source/gameengine/Ketsji/KX_PythonInit.h | 2 +- .../Ketsji/KX_SG_BoneParentNodeRelationship.cpp | 2 +- source/gameengine/Ketsji/KX_Scene.cpp | 31 +- source/gameengine/Ketsji/KX_Scene.h | 10 +- source/gameengine/Ketsji/KX_VertexProxy.cpp | 14 +- source/gameengine/Ketsji/KX_VisibilityActuator.cpp | 2 +- source/gameengine/Ketsji/Makefile | 6 +- source/gameengine/Ketsji/SConscript | 5 +- .../Physics/Bullet/CcdPhysicsController.cpp | 34 +- .../Physics/Bullet/CcdPhysicsController.h | 3 +- source/gameengine/PyDoc/GameLogic.py | 9 +- source/gameengine/PyDoc/Rasterizer.py | 17 + source/gameengine/Rasterizer/Makefile | 4 - source/gameengine/Rasterizer/RAS_BucketManager.cpp | 257 ++++--- source/gameengine/Rasterizer/RAS_BucketManager.h | 21 +- .../gameengine/Rasterizer/RAS_IPolygonMaterial.cpp | 25 +- .../gameengine/Rasterizer/RAS_IPolygonMaterial.h | 9 +- source/gameengine/Rasterizer/RAS_IRasterizer.h | 44 +- source/gameengine/Rasterizer/RAS_IRenderTools.cpp | 24 +- source/gameengine/Rasterizer/RAS_IRenderTools.h | 39 +- .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 554 +++++++++++---- source/gameengine/Rasterizer/RAS_MaterialBucket.h | 213 +++--- source/gameengine/Rasterizer/RAS_MeshObject.cpp | 723 +++++++------------- source/gameengine/Rasterizer/RAS_MeshObject.h | 240 ++----- .../Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt | 1 + .../Rasterizer/RAS_OpenGLRasterizer/Makefile | 5 +- .../RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp | 84 +-- .../RAS_OpenGLRasterizer/RAS_ListRasterizer.h | 24 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 748 +++++---------------- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 46 +- .../RAS_VAOpenGLRasterizer.cpp | 216 +++--- .../RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h | 18 +- .../Rasterizer/RAS_OpenGLRasterizer/SConscript | 5 +- source/gameengine/Rasterizer/RAS_Polygon.cpp | 83 +-- source/gameengine/Rasterizer/RAS_Polygon.h | 56 +- source/gameengine/Rasterizer/RAS_TexVert.cpp | 30 +- source/gameengine/Rasterizer/RAS_TexVert.h | 28 +- source/gameengine/Rasterizer/SConscript | 5 +- 98 files changed, 2731 insertions(+), 3542 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 16f8ae0095a..1f66335c749 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -79,6 +79,8 @@ #include "DNA_scene_types.h" /***/ +#include "GPU_extensions.h" + #ifdef __cplusplus extern "C" { #endif @@ -138,6 +140,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 0) != 0); + if(GPU_extensions_minimum_support()) + useglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 0) != 0); + // create the canvas, rasterizer and rendertools RAS_ICanvas* canvas = new KX_BlenderCanvas(area); canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); @@ -304,13 +309,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, mousedevice, networkdevice, audiodevice, - startscenename); + startscenename, + blscene); // some python things PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest); ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(rasterizer, canvas); - PyObject *gameLogic = initGameLogic(startscene); + PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module. PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. initGameKeys(); @@ -526,8 +532,6 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, // create the ketsjiengine KX_KetsjiEngine* ketsjiengine = new KX_KetsjiEngine(kxsystem); - int i; - Scene *blscene = NULL; if (!bfd) { @@ -543,7 +547,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, } else { blscene = bfd->curscene; } - int cframe,startFrame; + int cframe = 1, startFrame; if (blscene) { cframe=blscene->r.cfra; @@ -574,12 +578,14 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, mousedevice, networkdevice, audiodevice, - startscenename); + startscenename, + blscene); + // some python things PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest); ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(rasterizer, canvas); - PyObject *gameLogic = initGameLogic(startscene); + PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index 1d72fb9cde1..340a1ae310b 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -31,6 +31,7 @@ SET(INC ../../../intern/SoundSystem ../../../source/blender/misc ../../../source/blender/blenloader + ../../../source/blender/gpu ../../../extern/bullet2/src ../../../extern/solid ../../../extern/glew/include diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index da52be56d1b..669e7bd1b3f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -26,7 +26,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include "GL/glew.h" #include "KX_BlenderGL.h" #ifdef HAVE_CONFIG_H @@ -93,80 +92,6 @@ void BL_SwapBuffers() myswapbuffers(); } -void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface, - unsigned int *col,float v1[3],float v2[3],float v3[3],float v4[3]) -{ - Image* ima; - - if(mode & TF_BMFONT) { - //char string[MAX_PROPSTRING]; - int characters, index, character; - float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance; - -// bProperty *prop; - - // string = "Frank van Beek"; - - characters = textlen; - - ima = (struct Image*) tface->tpage; - if (ima == NULL) { - characters = 0; - } - - /* When OBCOL flag is on the color is set in IndexPrimitives_3DText */ - if (tface->mode & TF_OBCOL) { /* Color has been set */ - col= NULL; - } else { - if(!col) glColor3f(1.0f, 1.0f, 1.0f); - } - - glPushMatrix(); - for (index = 0; index < characters; index++) { - // lets calculate offset stuff - character = textstr[index]; - - // space starts at offset 1 - // character = character - ' ' + 1; - - matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, ¢ery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance); - - glBegin(GL_POLYGON); - // printf(" %c %f %f %f %f\n", character, tface->uv[0][0], tface->uv[0][1], ); - // glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy); - glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy); - - if(col) spack(col[0]); - // glVertex3fv(v1); - glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]); - - glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy); - if(col) spack(col[1]); - // glVertex3fv(v2); - glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]); - - glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy); - if(col) spack(col[2]); - // glVertex3fv(v3); - glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]); - - if(v4) { - // glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, 1.0 - (1.0 - tface->uv[3][1]) * sizey - transy); - glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy); - if(col) spack(col[3]); - // glVertex3fv(v4); - glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]); - } - glEnd(); - - glTranslatef(advance, 0.0, 0.0); - } - glPopMatrix(); - - } -} - - void DisableForText() { if(glIsEnabled(GL_BLEND)) glDisable(GL_BLEND); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h index c8e0d47afb6..b891a7343c2 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h @@ -46,9 +46,6 @@ void BL_HideMouse(); void BL_NormalMouse(); void BL_WaitMouse(); -void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface, - unsigned int *col,float v1[3],float v2[3],float v3[3],float v4[3]); - void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height); void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int height); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index dafc2599850..1797d6c1a0f 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -26,8 +26,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include "KX_BlenderRenderTools.h" - #include "GL/glew.h" #include "RAS_IRenderTools.h" @@ -36,23 +34,22 @@ #include "RAS_ICanvas.h" #include "RAS_GLExtensionManager.h" -// next two includes/dependencies come from the shadow feature -// it needs the gameobject and the sumo physics scene for a raycast #include "KX_GameObject.h" - #include "KX_PolygonMaterial.h" #include "KX_BlenderMaterial.h" +#include "KX_RayCast.h" +#include "KX_IPhysicsController.h" -#include "Value.h" +#include "PHY_IPhysicsEnvironment.h" -#include "KX_BlenderGL.h" // for text printing #include "STR_String.h" -#include "RAS_BucketManager.h" // for polymaterial (needed for textprinting) -#include "KX_RayCast.h" -#include "KX_IPhysicsController.h" -#include "PHY_IPhysicsEnvironment.h" -#include "KX_Scene.h" +#include "GPU_draw.h" + +#include "KX_BlenderGL.h" // for text printing +#include "KX_BlenderRenderTools.h" + +unsigned int KX_BlenderRenderTools::m_numgllights; KX_BlenderRenderTools::KX_BlenderRenderTools() { @@ -61,73 +58,90 @@ KX_BlenderRenderTools::KX_BlenderRenderTools() m_numgllights = 8; } -/** -ProcessLighting performs lighting on objects. the layer is a bitfield that contains layer information. -There are 20 'official' layers in blender. -A light is applied on an object only when they are in the same layer. -OpenGL has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in a scene. -*/ +KX_BlenderRenderTools::~KX_BlenderRenderTools() +{ +} -int KX_BlenderRenderTools::ProcessLighting(int layer) +void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty) { - - int result = false; + m_clientobject = NULL; + m_lastlightlayer = -1; + m_lastlighting = false; + DisableOpenGLLights(); +} - if (layer < 0) - { - DisableOpenGLLights(); - result = false; - } else +void KX_BlenderRenderTools::EndFrame(RAS_IRasterizer* rasty) +{ +} + +/* ProcessLighting performs lighting on objects. the layer is a bitfield that + * contains layer information. There are 20 'official' layers in blender. A + * light is applied on an object only when they are in the same layer. OpenGL + * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in + * a scene. */ + +void KX_BlenderRenderTools::ProcessLighting(int layer, const MT_Transform& viewmat) +{ + if(m_lastlightlayer == layer) + return; + + m_lastlightlayer = layer; + + bool enable = false; + + if (layer >= 0) { if (m_clientobject) { if (layer == RAS_LIGHT_OBJECT_LAYER) - { layer = static_cast(m_clientobject)->GetLayer(); - } - if (applyLights(layer)) - { - EnableOpenGLLights(); - result = true; - } else - { - DisableOpenGLLights(); - result = false; - } + + enable = applyLights(layer, viewmat); } } - return result; - - + + if(enable) + EnableOpenGLLights(); + else + DisableOpenGLLights(); } +void KX_BlenderRenderTools::EnableOpenGLLights() +{ + if(m_lastlighting == true) + return; -void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty) + glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true); + if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); + + m_lastlighting = true; +} + +void KX_BlenderRenderTools::DisableOpenGLLights() { - m_clientobject = NULL; - m_lastblenderobject = NULL; - m_lastblenderlights = false; - m_lastlayer = -1; - m_lastlighting = false; - m_modified = true; - DisableOpenGLLights(); + if(m_lastlighting == false) + return; + glDisable(GL_LIGHTING); + glDisable(GL_COLOR_MATERIAL); + m_lastlighting = false; } -void KX_BlenderRenderTools::SetClientObject(void* obj) + +void KX_BlenderRenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj) { if (m_clientobject != obj) { - if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()) - { - glFrontFace(GL_CCW); - } else - { - glFrontFace(GL_CW); - } + bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()); + rasty->SetFrontFace(ccw); + m_clientobject = obj; - m_modified = true; } } @@ -182,7 +196,7 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat MT_Vector3 dir = (campos - objpos).safe_normalized(); MT_Vector3 up(0,0,1.0); - KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject; + KX_GameObject* gameobj = (KX_GameObject*)m_clientobject; // get scaling of halo object MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale(); @@ -218,7 +232,7 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat { // shadow must be cast to the ground, physics system needed here! MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]); - KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject; + KX_GameObject *gameobj = (KX_GameObject*)m_clientobject; MT_Vector3 direction = MT_Vector3(0,0,-1); direction.normalize(); @@ -252,13 +266,29 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat } -/** -Render Text renders text into a (series of) polygon, using a texture font, -Each character consists of one polygon (one quad or two triangles) -*/ -void KX_BlenderRenderTools::RenderText(int mode,RAS_IPolyMaterial* polymat,float v1[3],float v2[3],float v3[3],float v4[3]) +void KX_BlenderRenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, + const char* text, + int xco, + int yco, + int width, + int height) +{ + STR_String tmpstr(text); + + if(mode == RAS_IRenderTools::RAS_TEXT_PADDED) + BL_print_gamedebug_line_padded(tmpstr.Ptr(), xco, yco, width, height); + else + BL_print_gamedebug_line(tmpstr.Ptr(), xco, yco, width, height); +} + +/* Render Text renders text into a (series of) polygon, using a texture font, + * Each character consists of one polygon (one quad or two triangles) */ + +void KX_BlenderRenderTools::RenderText( + int mode, + RAS_IPolyMaterial* polymat, + float v1[3], float v2[3], float v3[3], float v4[3], int glattrib) { - STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text"); const unsigned int flag = polymat->GetFlag(); @@ -275,67 +305,9 @@ void KX_BlenderRenderTools::RenderText(int mode,RAS_IPolyMaterial* polymat,float col = blenderpoly->GetMCol(); } - BL_RenderText( mode,mytext,mytext.Length(),tface,col,v1,v2,v3,v4); - -} - - - -KX_BlenderRenderTools::~KX_BlenderRenderTools() -{ -}; - - -void KX_BlenderRenderTools::EndFrame(RAS_IRasterizer* rasty) -{ + GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib); } - - -void KX_BlenderRenderTools::DisableOpenGLLights() -{ - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); -} - - -void KX_BlenderRenderTools::EnableOpenGLLights() -{ - glEnable(GL_LIGHTING); - - glEnable(GL_COLOR_MATERIAL); - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true); - if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); - -} - - -/** - * Rendering text using 2D bitmap functionality. - */ -void KX_BlenderRenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, - const char* text, - int xco, - int yco, - int width, - int height) -{ - switch (mode) { - case RAS_IRenderTools::RAS_TEXT_PADDED: { - STR_String tmpstr(text); - BL_print_gamedebug_line_padded(tmpstr.Ptr(),xco,yco,width,height); - break; - } - default: { - STR_String tmpstr(text); - BL_print_gamedebug_line(tmpstr.Ptr(),xco,yco,width,height); - } - } -} - - void KX_BlenderRenderTools::PushMatrix() { @@ -348,14 +320,13 @@ void KX_BlenderRenderTools::PopMatrix() } - -int KX_BlenderRenderTools::applyLights(int objectlayer) +int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) { -// taken from blender source, incompatibility between Blender Object / GameObject - + // taken from blender source, incompatibility between Blender Object / GameObject + float glviewmat[16]; unsigned int count; float vec[4]; - + vec[3]= 1.0; for(count=0; count m_lights; std::vector::iterator lit = m_lights.begin(); + + viewmat.getValue(glviewmat); glPushMatrix(); - glLoadMatrixf(m_viewmat); + glLoadMatrixf(glviewmat); for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); @@ -433,7 +406,6 @@ int KX_BlenderRenderTools::applyLights(int objectlayer) glEnable((GLenum)(GL_LIGHT0+count)); count++; - } } glPopMatrix(); @@ -442,22 +414,6 @@ int KX_BlenderRenderTools::applyLights(int objectlayer) } - - -RAS_IPolyMaterial* KX_BlenderRenderTools::CreateBlenderPolyMaterial( - const STR_String &texname, - bool ba,const STR_String& matname,int tile,int tilexrep,int tileyrep,int mode,bool transparant,bool zsort, int lightlayer - ,bool bIsTriangle,void* clientobject,void* tface) -{ - assert(!"Deprecated"); -/* return new KX_BlenderPolyMaterial( - - texname, - ba,matname,tile,tilexrep,tileyrep,mode,transparant,zsort, lightlayer - ,bIsTriangle,clientobject,(struct MTFace*)tface);*/ - return NULL; -} - void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer) { int state = rasterizer->GetMotionBlurState(); @@ -491,4 +447,3 @@ void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas) m_filtermanager.RenderFilters(canvas); } -unsigned int KX_BlenderRenderTools::m_numgllights; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h index 8027136aa52..a7618462c9b 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h @@ -26,6 +26,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ + #ifndef __KX_BLENDERRENDERTOOLS #define __KX_BLENDERRENDERTOOLS @@ -39,65 +40,50 @@ struct KX_ClientObjectInfo; class KX_RayCast; -/** -BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which are not -part of the (polygon) Rasterizer. -Effects like 2D text, 3D (polygon) text, lighting. -*/ +/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which + * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon) + * text, lighting. + * + * Most of this code is duplicated in GPC_RenderTools, so this should be + * moved to some common location to avoid duplication. */ class KX_BlenderRenderTools : public RAS_IRenderTools { - bool m_lastblenderlights; - void* m_lastblenderobject; - int m_lastlayer; + int m_lastlightlayer; bool m_lastlighting; static unsigned int m_numgllights; - - + public: - KX_BlenderRenderTools(); virtual ~KX_BlenderRenderTools(); - virtual void EndFrame(class RAS_IRasterizer* rasty); - virtual void BeginFrame(class RAS_IRasterizer* rasty); - void DisableOpenGLLights(); + void EndFrame(RAS_IRasterizer* rasty); + void BeginFrame(RAS_IRasterizer* rasty); + void EnableOpenGLLights(); - int ProcessLighting(int layer); + void DisableOpenGLLights(); + void ProcessLighting(int layer, const MT_Transform& viewmat); - virtual void RenderText2D(RAS_TEXT_RENDER_MODE mode, + void RenderText2D(RAS_TEXT_RENDER_MODE mode, const char* text, int xco, int yco, int width, int height); - virtual void RenderText(int mode, + void RenderText(int mode, class RAS_IPolyMaterial* polymat, float v1[3], float v2[3], float v3[3], - float v4[3]); - void applyTransform(class RAS_IRasterizer* rasty, - double* oglmatrix, - int objectdrawmode ); - int applyLights(int objectlayer); - virtual void PushMatrix(); - virtual void PopMatrix(); - - virtual class RAS_IPolyMaterial* CreateBlenderPolyMaterial(const STR_String &texname, - bool ba, - const STR_String& matname, - int tile, - int tilexrep, - int tileyrep, - int mode, - bool transparant, - bool zsort, - int lightlayer, - bool bIsTriangle, - void* clientobject, - void* tface); - + float v4[3], + int glattrib); + + void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode); + int applyLights(int objectlayer, const MT_Transform& viewmat); + + void PushMatrix(); + void PopMatrix(); + bool RayHit(KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data); bool NeedRayCast(KX_ClientObjectInfo*) { return true; } @@ -107,8 +93,7 @@ public: virtual void Render2DFilters(RAS_ICanvas* canvas); - virtual void SetClientObject(void* obj); - + virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj); }; #endif //__KX_BLENDERRENDERTOOLS diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile index a7394158a20..4b9a2a3af17 100644 --- a/source/gameengine/BlenderRoutines/Makefile +++ b/source/gameengine/BlenderRoutines/Makefile @@ -54,6 +54,7 @@ CPPFLAGS += -I../../blender/blenkernel CPPFLAGS += -I../../blender/render/extern/include CPPFLAGS += -I../../blender/blenloader CPPFLAGS += -I../../blender/blenkernel +CPPFLAGS += -I../../blender/gpu CPPFLAGS += -I../Converter CPPFLAGS += -I../Expressions CPPFLAGS += -I../GameLogic @@ -72,9 +73,5 @@ ifeq ($(OS),windows) CPPFLAGS += -I../../blender endif -ifeq ($(WITH_BF_GLEXT),true) - CPPFLAGS += -DWITH_GLEXT -endif - CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index 327f4798e04..78adbc83d9b 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -15,7 +15,7 @@ incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common' incs += ' #source/gameengine/Physics/Bullet #source/gameengine/Physics/Sumo' incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork' incs += ' #intern/SoundSystem #source/blender/misc #source/blender/blenloader' -incs += ' #extern/glew/include' +incs += ' #extern/glew/include #source/blender/gpu' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_SOLID_INC'] @@ -26,7 +26,4 @@ cxxflags = [] if env['OURPLATFORM']=='win32-vc': cxxflags.append ('/GR') -if env['WITH_BF_GLEXT'] == 1: - env['CPPFLAGS'].append('-DWITH_GLEXT') - env.BlenderLib ( 'bf_bloutines', sources, Split(incs), [], libtype=['game', 'game2', 'player'], priority=[0, 0, 55] , compileflags=cxxflags) diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index cdfce321713..bf774bf7568 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -53,16 +53,20 @@ BL_ArmatureObject::BL_ArmatureObject( : KX_GameObject(sgReplicationInfo,callbacks), m_objArma(armature), - m_mrdPose(NULL), m_framePose(NULL), - m_lastframe(0.), + m_lastframe(0.0), m_activeAct(NULL), - m_activePriority(999) + m_activePriority(999), + m_lastapplyframe(0.0) { m_armature = get_armature(m_objArma); - m_pose = m_objArma->pose; -} + /* we make a copy of blender object's pose, and then always swap it with + * the original pose before calling into blender functions, to deal with + * replica's or other objects using the same blender object */ + m_pose = NULL; + copy_pose(&m_pose, m_objArma->pose, 1 /* copy_constraint_channels_hack */); +} CValue* BL_ArmatureObject::GetReplica() { @@ -79,34 +83,39 @@ void BL_ArmatureObject::ProcessReplica(BL_ArmatureObject *replica) { KX_GameObject::ProcessReplica(replica); + replica->m_pose = NULL; + copy_pose(&replica->m_pose, m_pose, 1 /* copy_constraint_channels_hack */); } BL_ArmatureObject::~BL_ArmatureObject() { - if (m_mrdPose) - free_pose(m_mrdPose); + if (m_pose) + free_pose(m_pose); } -/* note, you can only call this for exisiting Armature objects, and not mix it with other Armatures */ -/* there is only 1 unique Pose per Armature */ -void BL_ArmatureObject::ApplyPose() +bool BL_ArmatureObject::VerifyPose() { - if (m_pose) { - // copy to armature object - if (m_objArma->pose != m_pose)/* This should never happen but it does - Campbell */ - extract_pose_from_pose(m_objArma->pose, m_pose); - - // is this needed anymore? - //if (!m_mrdPose) - // copy_pose (&m_mrdPose, m_pose, 0); - //else - // extract_pose_from_pose(m_mrdPose, m_pose); + if(m_lastapplyframe != m_lastframe) { + extract_pose_from_pose(m_objArma->pose, m_pose); + where_is_pose(m_objArma); + m_lastapplyframe = m_lastframe; + extract_pose_from_pose(m_pose, m_objArma->pose); + return false; } + else + return true; +} + +void BL_ArmatureObject::ApplyPose() +{ + if(VerifyPose()) + extract_pose_from_pose(m_objArma->pose, m_pose); } void BL_ArmatureObject::SetPose(bPose *pose) { - m_pose = pose; + extract_pose_from_pose(m_pose, pose); + m_lastapplyframe = -1.0; } bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, double curtime) @@ -162,6 +171,7 @@ void BL_ArmatureObject::GetPose(bPose **pose) if (*pose == m_pose) // no need to copy if the pointers are the same return; + extract_pose_from_pose(*pose, m_pose); } } @@ -171,20 +181,16 @@ void BL_ArmatureObject::GetMRDPose(bPose **pose) /* If the caller supplies a null pose, create a new one. */ /* Otherwise, copy the armature's pose channels into the caller-supplied pose */ - // is this needed anymore? - //if (!m_mrdPose){ - // copy_pose (&m_mrdPose, m_pose, 0); - //} - if (!*pose) { // must duplicate the constraints too otherwise we have corruption in free_pose_channels() // because it will free the blender constraints. // Ideally, blender should rememeber that the constraints were not copied so that // free_pose_channels() would not free them. - copy_pose(pose, m_objArma->pose, 1); + copy_pose(pose, m_pose, 1); + } + else { + extract_pose_from_pose(*pose, m_pose); } - else - extract_pose_from_pose(*pose, m_objArma->pose); } @@ -198,16 +204,18 @@ double BL_ArmatureObject::GetLastFrame() return m_lastframe; } -bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) const +bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) { - Object* par_arma = m_objArma; - where_is_pose(par_arma); - bPoseChannel *pchan= get_pose_channel(par_arma->pose, bone->name); + bPoseChannel *pchan; + + ApplyPose(); + pchan = get_pose_channel(m_objArma->pose, bone->name); if(pchan) { matrix.setValue(&pchan->pose_mat[0][0]); return true; } + return false; } diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index a612ca77ec0..6f2c0d2f4c9 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -59,7 +59,10 @@ public: void GetMRDPose(struct bPose **pose); void GetPose(struct bPose **pose); void SetPose (struct bPose *pose); + void ApplyPose(); + bool VerifyPose(); + bool SetActiveAction(class BL_ActionActuator *act, short priority, double curtime); struct bArmature * GetArmature() { return m_armature; } @@ -69,7 +72,7 @@ public: /// Retrieve the pose matrix for the specified bone. /// Returns true on success. - bool GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) const; + bool GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix); /// Returns the bone length. The end of the bone is in the local y direction. float GetBoneLength(Bone* bone) const; @@ -79,11 +82,12 @@ protected: Object *m_objArma; struct bArmature *m_armature; struct bPose *m_pose; - struct bPose *m_mrdPose; struct bPose *m_framePose; double m_lastframe; class BL_ActionActuator *m_activeAct; short m_activePriority; + + double m_lastapplyframe; }; #endif diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index edc14dabc70..def4938b053 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -601,7 +601,6 @@ BL_Material* ConvertMaterial( (tface->mode & TF_INVISIBLE) )?POLY_VIS:0; - material->ras_mode |= ( (tface->mode & TF_DYNAMIC)!= 0 )?COLLIDER:0; material->transp = tface->transp; material->tile = tface->tile; material->mode = tface->mode; @@ -617,7 +616,7 @@ BL_Material* ConvertMaterial( } else { // nothing at all - material->ras_mode |= (COLLIDER|POLY_VIS| (validmat?0:USE_LIGHT)); + material->ras_mode |= (POLY_VIS| (validmat?0:USE_LIGHT)); material->mode = default_face_mode; material->transp = TF_SOLID; material->tile = 0; @@ -627,13 +626,19 @@ BL_Material* ConvertMaterial( if(validmat && (mat->mode & MA_ZTRA) && (material->transp == TF_SOLID)) material->transp = TF_ALPHA; - // always zsort alpha + add - if((material->transp == TF_ALPHA || material->transp == TF_ADD || texalpha) - && (material->transp != TF_CLIP)) { + // always zsort alpha + add + if((material->transp == TF_ALPHA || texalpha) && (material->transp != TF_CLIP)) { material->ras_mode |= ALPHA; material->ras_mode |= (material->mode & TF_ALPHASORT)? ZSORT: 0; } + // collider or not? + material->ras_mode |= (material->mode & TF_DYNAMIC)? COLLIDER: 0; + + // these flags are irrelevant at this point, remove so they + // don't hurt material bucketing + material->mode &= ~(TF_DYNAMIC|TF_ALPHASORT|TF_TEX); + // get uv sets if(validmat) { @@ -644,6 +649,7 @@ BL_Material* ConvertMaterial( for (int vind = 0; vindnum_enabled; vind++) { BL_Mapping &map = material->mapping[vind]; + if (map.uvCoName.IsEmpty()) isFirstSet = false; else @@ -673,7 +679,7 @@ BL_Material* ConvertMaterial( isFirstSet = false; uvName = layer.name; } - else + else if(strcmp(layer.name, uvName) != 0) { uv2[0] = uvSet[0]; uv2[1] = uvSet[1]; uv2[2] = uvSet[2]; uv2[3] = uvSet[3]; @@ -702,7 +708,6 @@ BL_Material* ConvertMaterial( material->SetConversionUV(uvName, uv); material->SetConversionUV2(uv2Name, uv2); - material->ras_mode |= (mface->v4==0)?TRIANGLE:0; if(validmat) material->matname =(mat->id.name); @@ -767,7 +772,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* } meshobj->SetName(mesh->id.name); - meshobj->m_xyz_index_to_vertex_index_mapping.resize(totvert); + meshobj->m_sharedvertex_map.resize(totvert); for (int f=0;fmat_nr+1); { - bool polyvisible = true; + bool visible = true; RAS_IPolyMaterial* polymat = NULL; BL_Material *bl_mat = NULL; @@ -845,7 +850,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* bl_mat->material_index = (int)mface->mat_nr; - polyvisible = ((bl_mat->ras_mode & POLY_VIS)!=0); + visible = ((bl_mat->ras_mode & POLY_VIS)!=0); collider = ((bl_mat->ras_mode & COLLIDER)!=0); /* vertex colors and uv's were stored in bl_mat temporarily */ @@ -862,7 +867,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* uv22 = uv[2]; uv23 = uv[3]; /* then the KX_BlenderMaterial */ - polymat = new KX_BlenderMaterial(scene, bl_mat, skinMesh, lightlayer, blenderobj ); + polymat = new KX_BlenderMaterial(scene, bl_mat, skinMesh, lightlayer); } else { /* do Texture Face materials */ @@ -886,7 +891,7 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* tile = tface->tile; mode = tface->mode; - polyvisible = !((mface->flag & ME_HIDE)||(tface->mode & TF_INVISIBLE)); + visible = !((mface->flag & ME_HIDE)||(tface->mode & TF_INVISIBLE)); uv0 = MT_Point2(tface->uv[0]); uv1 = MT_Point2(tface->uv[1]); @@ -940,15 +945,13 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* rgb3 = KX_rgbaint2uint_new(color); } - bool istriangle = (mface->v4==0); - // only zsort alpha + add bool alpha = (transp == TF_ALPHA || transp == TF_ADD); bool zsort = (mode & TF_ALPHASORT)? alpha: 0; polymat = new KX_PolygonMaterial(imastr, ma, tile, tilexrep, tileyrep, - mode, transp, alpha, zsort, lightlayer, istriangle, blenderobj, tface, (unsigned int*)mcol); + mode, transp, alpha, zsort, lightlayer, tface, (unsigned int*)mcol); if (ma) { polymat->m_specular = MT_Vector3(ma->specr, ma->specg, ma->specb)*ma->spec; @@ -961,6 +964,9 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* } } + /* mark face as flat, so vertices are split */ + bool flat = (mface->flag & ME_SMOOTH) == 0; + // see if a bucket was reused or a new one was created // this way only one KX_BlenderMaterial object has to exist per bucket bool bucketCreated; @@ -981,49 +987,19 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* polymat = bucket->GetPolyMaterial(); } - int nverts = mface->v4?4:3; - int vtxarray = meshobj->FindVertexArray(nverts,polymat); - RAS_Polygon* poly = new RAS_Polygon(bucket,polyvisible,nverts,vtxarray); - - bool flat; - - if (skinMesh) { - /* If the face is set to solid, all fnors are the same */ - if (mface->flag & ME_SMOOTH) - flat = false; - else - flat = true; - } - else - flat = false; + int nverts = (mface->v4)? 4: 3; + RAS_Polygon *poly = meshobj->AddPolygon(bucket, nverts); - poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,flat,polymat,mface->v1)); - poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,flat,polymat,mface->v2)); - poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,flat,polymat,mface->v3)); - if (nverts==4) - poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,flat,polymat,mface->v4)); - - meshobj->AddPolygon(poly); - if (poly->IsCollider()) - { - RAS_TriangleIndex idx; - idx.m_index[0] = mface->v1; - idx.m_index[1] = mface->v2; - idx.m_index[2] = mface->v3; - idx.m_collider = collider; - meshobj->m_triangle_indices.push_back(idx); - if (nverts==4) - { - idx.m_index[0] = mface->v1; - idx.m_index[1] = mface->v3; - idx.m_index[2] = mface->v4; - idx.m_collider = collider; - meshobj->m_triangle_indices.push_back(idx); - } - } - -// poly->SetVisibleWireframeEdges(mface->edcode); + poly->SetVisible(visible); poly->SetCollider(collider); + //poly->SetEdgeCode(mface->edcode); + + meshobj->AddVertex(poly,0,pt0,uv0,uv20,tan0,rgb0,no0,flat,mface->v1); + meshobj->AddVertex(poly,1,pt1,uv1,uv21,tan1,rgb1,no1,flat,mface->v2); + meshobj->AddVertex(poly,2,pt2,uv2,uv22,tan2,rgb2,no2,flat,mface->v3); + + if (nverts==4) + meshobj->AddVertex(poly,3,pt3,uv3,uv23,tan3,rgb3,no3,flat,mface->v4); } if (tface) @@ -1039,13 +1015,12 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* layer.face++; } } - meshobj->m_xyz_index_to_vertex_index_mapping.clear(); - meshobj->UpdateMaterialList(); + meshobj->m_sharedvertex_map.clear(); // pre calculate texture generation - for(RAS_MaterialBucket::Set::iterator mit = meshobj->GetFirstMaterial(); + for(list::iterator mit = meshobj->GetFirstMaterial(); mit != meshobj->GetLastMaterial(); ++ mit) { - (*mit)->GetPolyMaterial()->OnConstruction(); + mit->m_bucket->GetPolyMaterial()->OnConstruction(); } if (layers) @@ -1490,14 +1465,9 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l lightobj.m_type = RAS_LightObject::LIGHT_NORMAL; } -#ifdef BLENDER_GLSL - if(converter->GetGLSLMaterials()) - GPU_lamp_from_blender(ob, la); - - gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj, ob->gpulamp); -#else - gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj, NULL); -#endif + gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, + lightobj, converter->GetGLSLMaterials()); + BL_ConvertLampIpos(la, gamelight, converter); return gamelight; @@ -1534,7 +1504,7 @@ static KX_GameObject *gameobject_from_blenderobject( gamelight->AddRef(); kxscene->GetLightList()->Add(gamelight); - + break; } @@ -1643,20 +1613,6 @@ struct parentChildLink { SG_Node* m_gamechildnode; }; - /** - * Find the specified scene by name, or the first - * scene if nothing matches (shouldn't happen). - */ -static struct Scene *GetSceneForName(struct Main *maggie, const STR_String& scenename) { - Scene *sce; - - for (sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next) - if (scenename == (sce->id.name+2)) - return sce; - - return (Scene*) maggie->scene.first; -} - #include "DNA_constraint_types.h" #include "BIF_editconstraint.h" @@ -1755,7 +1711,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, ) { - Scene *blenderscene = GetSceneForName(maggie, scenename); + Scene *blenderscene = converter->GetBlenderSceneForName(scenename); // for SETLOOPER Scene *sce; Base *base; @@ -1990,7 +1946,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, //tf.Add(gameobj->GetSGNode()); gameobj->NodeUpdateGS(0,true); - gameobj->Bucketize(); + gameobj->AddMeshUser(); } else @@ -2187,7 +2143,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, //tf.Add(gameobj->GetSGNode()); gameobj->NodeUpdateGS(0,true); - gameobj->Bucketize(); + gameobj->AddMeshUser(); } else @@ -2273,8 +2229,11 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { // parent this to a bone Bone *parent_bone = get_named_bone(get_armature(blenderchild->parent), blenderchild->parsubstr); - KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone); - pcit->m_gamechildnode->SetParentRelation(bone_parent_relation); + + if(parent_bone) { + KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone); + pcit->m_gamechildnode->SetParentRelation(bone_parent_relation); + } break; } @@ -2511,5 +2470,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie, kxscene->DupliGroupRecurse(gameobj, 0); } } + + KX_Camera *activecam = kxscene->GetActiveCamera(); + MT_Scalar distance = (activecam)? activecam->GetCameraFar() - activecam->GetCameraNear(): 100.0f; + RAS_BucketManager *bucketmanager = kxscene->GetBucketManager(); + bucketmanager->OptimizeBuckets(distance); } diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp index d23274324ee..1d62a41cce9 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.cpp +++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp @@ -41,12 +41,14 @@ BL_DeformableGameObject::~BL_DeformableGameObject() delete m_pDeformer; // __NLA : Temporary until we decide where to put this } -void BL_DeformableGameObject::ProcessReplica(KX_GameObject* replica) +void BL_DeformableGameObject::ProcessReplica(KX_GameObject* replica) { + BL_MeshDeformer *deformer; KX_GameObject::ProcessReplica(replica); - if (m_pDeformer){ - ((BL_DeformableGameObject*)replica)->m_pDeformer = m_pDeformer->GetReplica(); + if (m_pDeformer) { + deformer = (BL_MeshDeformer*)m_pDeformer->GetReplica(); + ((BL_DeformableGameObject*)replica)->m_pDeformer = deformer; } } diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index 39d66a90e92..fa3b8185fe2 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -50,26 +50,26 @@ bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*) { - size_t i, j; + size_t i; float *co; // only apply once per frame if the mesh is actually modified if(m_pMeshObject->MeshModified() && m_lastDeformUpdate != m_gameobj->GetLastFrame()) { // For each material - for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); + for(list::iterator mit= m_pMeshObject->GetFirstMaterial(); mit != m_pMeshObject->GetLastMaterial(); ++ mit) { - RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); + if(!mit->m_slots[(void*)m_gameobj]) + continue; - vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); - - // For each array - for (i=0; im_slots[(void*)m_gameobj]; + RAS_MeshSlot::iterator it; + // for each array + for(slot->begin(it); !slot->end(it); slot->next(it)) { // For each vertex - for (j=0; jmvert[v.getOrigIndex()].co; v.SetXYZ(MT_Point3(co)); } @@ -90,7 +90,17 @@ BL_MeshDeformer::~BL_MeshDeformer() delete [] m_transverts; if (m_transnors) delete [] m_transnors; -}; +} + +void BL_MeshDeformer::Relink(GEN_Map*map) +{ + void **h_obj = (*map)[m_gameobj]; + + if (h_obj) + m_gameobj = (BL_DeformableGameObject*)(*h_obj); + else + m_gameobj = NULL; +} /** * @warning This function is expensive! @@ -101,41 +111,41 @@ void BL_MeshDeformer::RecalcNormals() * gives area-weight normals which often look better anyway, and use * GL_NORMALIZE so we don't have to do per vertex normalization either * since the GPU can do it faster */ - size_t i, j; + list::iterator mit; + RAS_MeshSlot::iterator it; + size_t i; /* set vertex normals to zero */ memset(m_transnors, 0, sizeof(float)*3*m_bmesh->totvert); /* add face normals to vertices. */ - for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); + for(mit = m_pMeshObject->GetFirstMaterial(); mit != m_pMeshObject->GetLastMaterial(); ++ mit) { - RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); + if(!mit->m_slots[(void*)m_gameobj]) + continue; - const vecIndexArrays& indexarrays = m_pMeshObject->GetIndexCache(mat); - vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); + RAS_MeshSlot *slot = *mit->m_slots[(void*)m_gameobj]; - for (i=0; iUsesTriangles()? 3: 4; + for(slot->begin(it); !slot->end(it); slot->next(it)) { + int nvert = (int)it.array->m_type; - for(j=0; jgetLocalXYZ(); + v4 = &it.vertex[it.index[i+3]]; + co4 = v4->getXYZ(); n1[0]= co1[0]-co3[0]; n1[1]= co1[1]-co3[1]; @@ -174,7 +184,7 @@ void BL_MeshDeformer::RecalcNormals() } /* in case of flat - just assign, the vertices are split */ - if(v1.getFlag() & TV_CALCFACENORMAL) { + if(v1.getFlag() & RAS_TexVert::FLAT) { v1.SetNormal(fnor); v2.SetNormal(fnor); v3.SetNormal(fnor); @@ -186,19 +196,18 @@ void BL_MeshDeformer::RecalcNormals() } /* assign smooth vertex normals */ - for(RAS_MaterialBucket::Set::iterator mit = m_pMeshObject->GetFirstMaterial(); + for(mit = m_pMeshObject->GetFirstMaterial(); mit != m_pMeshObject->GetLastMaterial(); ++ mit) { - RAS_IPolyMaterial *mat = (*mit)->GetPolyMaterial(); + if(!mit->m_slots[(void*)m_gameobj]) + continue; - vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); + RAS_MeshSlot *slot = *mit->m_slots[(void*)m_gameobj]; - for (i=0; ibegin(it); !slot->end(it); slot->next(it)) { + for(i=it.startvertex; itotvert; } } - + diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index e9f7f0b192f..9d3d2e78123 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -47,7 +47,7 @@ class BL_MeshDeformer : public RAS_Deformer public: void VerifyStorage(); void RecalcNormals(); - virtual void Relink(GEN_Map*map){}; + virtual void Relink(GEN_Map*map); BL_MeshDeformer(BL_DeformableGameObject *gameobj, struct Object* obj, class BL_SkinMeshObject *meshobj ): @@ -67,6 +67,7 @@ public: virtual RAS_Deformer* GetReplica(){return NULL;}; struct Mesh* GetMesh() { return m_bmesh; }; // virtual void InitDeform(double time){}; + protected: class BL_SkinMeshObject* m_pMeshObject; struct Mesh* m_bmesh; diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 942e3b502e0..799b6b74b66 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -134,7 +134,6 @@ void BL_ShapeActionActuator::BlendShape(Key* key, float srcweight) { vector::const_iterator it; float dstweight; - int i; KeyBlock *kb; dstweight = 1.0F - srcweight; diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index b2e54539b19..236cd1a6667 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -111,10 +111,7 @@ bool BL_ShapeDeformer::ExecuteShapeDrivers(void) int type; // the shape drivers use the bone matrix as input. Must // update the matrix now - Object* par_arma = m_armobj->GetArmatureObject(); m_armobj->ApplyPose(); - where_is_pose( par_arma ); - PoseApplied(true); for (it=m_shapeDrivers.begin(); it!=m_shapeDrivers.end(); it++) { // no need to set a specific time: this curve has a driver diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 5f0188e3a42..1465bb01e22 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -43,17 +43,6 @@ struct IpoCurve; class BL_ShapeDeformer : public BL_SkinDeformer { public: - virtual void Relink(GEN_Map*map) - { - void **h_obj = (*map)[m_gameobj]; - if (h_obj){ - m_gameobj = (BL_DeformableGameObject*)(*h_obj); - } - else - m_gameobj=NULL; - // relink the underlying skin deformer - BL_SkinDeformer::Relink(map); - }; BL_ShapeDeformer(BL_DeformableGameObject *gameobj, Object *bmeshobj, BL_SkinMeshObject *mesh) diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index f96c40c098f..d8e7a9cdadf 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -99,9 +99,26 @@ BL_SkinDeformer::~BL_SkinDeformer() m_armobj->Release(); } +void BL_SkinDeformer::Relink(GEN_Map*map) +{ + if (m_armobj) { + void **h_obj = (*map)[m_armobj]; + + if (h_obj) + SetArmature( (BL_ArmatureObject*)(*h_obj) ); + else + m_armobj=NULL; + } + + BL_MeshDeformer::Relink(map); +} + bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) { - size_t i, j; + RAS_MeshSlot::iterator it; + RAS_MeshMaterial *mmat; + RAS_MeshSlot *slot; + size_t i; // update the vertex in m_transverts Update(); @@ -110,16 +127,18 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) // share the same mesh (=the same cache). As the rendering is done per polymaterial // cycling through the objects, the entire mesh cache cannot be updated in one shot. - vecVertexArray& vertexarrays = m_pMeshObject->GetVertexCache(mat); + mmat = m_pMeshObject->GetMeshMaterial(mat); + if(!mmat->m_slots[(void*)m_gameobj]) + return true; - // For each array - for (i=0; im_slots[(void*)m_gameobj]; - // For each vertex + // for each array + for(slot->begin(it); !slot->end(it); slot->next(it)) { + // for each vertex // copy the untransformed data from the original mvert - for (j=0; jGetArmatureObject(); - if (!PoseApplied()){ - m_armobj->ApplyPose(); - where_is_pose( par_arma ); - } /* store verts locally */ VerifyStorage(); @@ -163,6 +178,8 @@ bool BL_SkinDeformer::Update(void) for (int v =0; vtotvert; v++) VECCOPY(m_transverts[v], m_bmesh->mvert[v].co); + m_armobj->ApplyPose(); + // save matrix first Mat4CpyMat4(obmat, m_objMesh->obmat); // set reference matrix @@ -179,11 +196,11 @@ bool BL_SkinDeformer::Update(void) /* Update the current frame */ m_lastArmaUpdate=m_armobj->GetLastFrame(); - /* reset for next frame */ - PoseApplied(false); + /* indicate that the m_transverts and normals are up to date */ return true; } + return false; } diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index d3fc5ae2a81..e08de8c478a 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -50,17 +50,7 @@ class BL_SkinDeformer : public BL_MeshDeformer { public: // void SetArmatureController (BL_ArmatureController *cont); - virtual void Relink(GEN_Map*map) - { - if (m_armobj){ - void **h_obj = (*map)[m_armobj]; - if (h_obj){ - SetArmature( (BL_ArmatureObject*)(*h_obj) ); - } - else - m_armobj=NULL; - } - } + virtual void Relink(GEN_Map*map); void SetArmature (class BL_ArmatureObject *armobj); BL_SkinDeformer(BL_DeformableGameObject *gameobj, @@ -81,10 +71,6 @@ public: virtual ~BL_SkinDeformer(); bool Update (void); bool Apply (class RAS_IPolyMaterial *polymat); - bool PoseApplied() - { return m_poseApplied; } - void PoseApplied(bool applied) - { m_poseApplied = applied; } bool PoseUpdated(void) { if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) { diff --git a/source/gameengine/Converter/BL_SkinMeshObject.cpp b/source/gameengine/Converter/BL_SkinMeshObject.cpp index fa215df1e1c..4f9f1a434b5 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.cpp +++ b/source/gameengine/Converter/BL_SkinMeshObject.cpp @@ -28,42 +28,69 @@ * Deformer that supports armature skinning */ -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef WIN32 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 -#include "RAS_IPolygonMaterial.h" -#include "BL_SkinMeshObject.h" -#include "BL_DeformableGameObject.h" + +#include "MEM_guardedalloc.h" + +#include "DNA_key_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "KX_GameObject.h" + #include "RAS_BucketManager.h" +#include "RAS_IPolygonMaterial.h" -//void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,RAS_BucketManager* bucketmgr) -void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec) -{ +#include "KX_GameObject.h" + +#include "BL_SkinMeshObject.h" +#include "BL_DeformableGameObject.h" - KX_MeshSlot ms; - ms.m_clientObj = clientobj; - ms.m_mesh = this; - ms.m_OpenGLMatrix = oglmatrix; - ms.m_bObjectColor = useObjectColor; - ms.m_RGBAcolor = rgbavec; - ms.m_pDeformer = ((BL_DeformableGameObject*)clientobj)->m_pDeformer; - - for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();it++) +BL_SkinMeshObject::BL_SkinMeshObject(Mesh* mesh, int lightlayer) + : RAS_MeshObject (mesh, lightlayer) +{ + m_bDeformed = true; + + if (m_mesh && m_mesh->key) { + KeyBlock *kb; + int count=0; + // initialize weight cache for shape objects + // count how many keys in this mesh + for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next) + count++; + m_cacheWeightIndex.resize(count,-1); + } +} - RAS_MaterialBucket* materialbucket = (*it); +BL_SkinMeshObject::~BL_SkinMeshObject() +{ + if (m_mesh && m_mesh->key) + { + KeyBlock *kb; + // remove the weight cache to avoid memory leak + for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next) { + if(kb->weights) + MEM_freeN(kb->weights); + kb->weights= NULL; + } + } +} + +void BL_SkinMeshObject::UpdateBuckets(void* clientobj,double* oglmatrix,bool useObjectColor,const MT_Vector4& rgbavec, bool visible, bool culled) +{ + list::iterator it; + list::iterator sit; + + for(it = m_materials.begin();it!=m_materials.end();++it) { + if(!it->m_slots[clientobj]) + continue; -// KX_ArrayOptimizer* oa = GetArrayOptimizer(materialbucket->GetPolyMaterial()); - materialbucket->SetMeshSlot(ms); + RAS_MeshSlot *slot = *it->m_slots[clientobj]; + slot->m_pDeformer = ((BL_DeformableGameObject*)clientobj)->m_pDeformer; } + RAS_MeshObject::UpdateBuckets(clientobj, oglmatrix, useObjectColor, rgbavec, visible, culled); } static int get_def_index(Object* ob, const char* vgroup) @@ -74,6 +101,7 @@ static int get_def_index(Object* ob, const char* vgroup) for (curdef = (bDeformGroup*)ob->defbase.first; curdef; curdef=(bDeformGroup*)curdef->next, index++) if (!strcmp(curdef->name, vgroup)) return index; + return -1; } diff --git a/source/gameengine/Converter/BL_SkinMeshObject.h b/source/gameengine/Converter/BL_SkinMeshObject.h index c21fb64204b..8544a2b958c 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.h +++ b/source/gameengine/Converter/BL_SkinMeshObject.h @@ -33,62 +33,27 @@ #ifdef WIN32 #pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning #endif //WIN32 -#include "MEM_guardedalloc.h" + #include "RAS_MeshObject.h" #include "RAS_Deformer.h" #include "RAS_IPolygonMaterial.h" #include "BL_MeshDeformer.h" -#include "DNA_mesh_types.h" -#include "DNA_key_types.h" -#include "DNA_meshdata_types.h" - class BL_SkinMeshObject : public RAS_MeshObject { - -// enum { BUCKET_MAX_INDICES = 16384};//2048};//8192}; -// enum { BUCKET_MAX_TRIANGLES = 4096}; - protected: vector m_cacheWeightIndex; public: - void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec); -// void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,class RAS_BucketManager* bucketmgr); - - BL_SkinMeshObject(Mesh* mesh, int lightlayer) : RAS_MeshObject (mesh, lightlayer) - { - m_class = 1; - if (m_mesh && m_mesh->key) - { - KeyBlock *kb; - int count=0; - // initialize weight cache for shape objects - // count how many keys in this mesh - for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next) - count++; - m_cacheWeightIndex.resize(count,-1); - } - }; + BL_SkinMeshObject(Mesh* mesh, int lightlayer); + ~BL_SkinMeshObject(); - virtual ~BL_SkinMeshObject() - { - if (m_mesh && m_mesh->key) - { - KeyBlock *kb; - // remove the weight cache to avoid memory leak - for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next) { - if(kb->weights) - MEM_freeN(kb->weights); - kb->weights= NULL; - } - } - }; + void UpdateBuckets(void* clientobj, double* oglmatrix, + bool useObjectColor, const MT_Vector4& rgbavec, bool visible, bool culled); // for shape keys, void CheckWeightCache(struct Object* obj); - }; #endif diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index adb7304b10e..217bdb30907 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -64,6 +64,7 @@ SET(INC ../../../source/gameengine/Network/LoopBackNetwork ../../../source/blender/misc ../../../source/blender/blenloader + ../../../source/blender/gpu ../../../extern/bullet2/src ../../../extern/solid ${PYTHON_INC} diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index de91bce2ab1..1f5b578d441 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -184,20 +184,21 @@ bool KX_BlenderSceneConverter::TryAndLoadNewFile() return result; } - +Scene *KX_BlenderSceneConverter::GetBlenderSceneForName(const STR_String& name) +{ + Scene *sce; /** * Find the specified scene by name, or the first * scene if nothing matches (shouldn't happen). */ -static struct Scene *GetSceneForName2(struct Main *maggie, const STR_String& scenename) { - Scene *sce; - for (sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next) - if (scenename == (sce->id.name+2)) + for (sce= (Scene*) m_maggie->scene.first; sce; sce= (Scene*) sce->id.next) + if (name == (sce->id.name+2)) return sce; - return (Scene*) maggie->scene.first; + return (Scene*)m_maggie->scene.first; + } #include "KX_PythonInit.h" @@ -258,7 +259,7 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename, class RAS_ICanvas* canvas) { //find out which physics engine - Scene *blenderscene = GetSceneForName2(m_maggie, scenename); + Scene *blenderscene = GetBlenderSceneForName(scenename); e_PhysicsEngine physics_engine = UseBullet; // hook for registration function during conversion. @@ -818,7 +819,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g); if (gameObj->IsDynamic()) { - KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); + //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); Object* blenderObject = FindBlenderObject(gameObj); if (blenderObject) @@ -846,7 +847,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) - const MT_Vector3& scale = gameObj->NodeGetWorldScaling(); + //const MT_Vector3& scale = gameObj->NodeGetWorldScaling(); const MT_Point3& position = gameObj->NodeGetWorldPosition(); Ipo* ipo = blenderObject->ipo; @@ -974,7 +975,7 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g); if (gameObj->IsDynamic()) { - KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); + //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController(); Object* blenderObject = FindBlenderObject(gameObj); if (blenderObject) @@ -1002,8 +1003,8 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() - const MT_Vector3& scale = gameObj->NodeGetWorldScaling(); - const MT_Point3& position = gameObj->NodeGetWorldPosition(); + //const MT_Vector3& scale = gameObj->NodeGetWorldScaling(); + //const MT_Point3& position = gameObj->NodeGetWorldPosition(); Ipo* ipo = blenderObject->ipo; if (ipo) diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index e5d6ccc5caf..2317e952a0a 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -45,6 +45,7 @@ class BL_Material; struct IpoCurve; struct Main; struct SpaceIpo; +struct Scene; class KX_BlenderSceneConverter : public KX_ISceneConverter { @@ -151,6 +152,7 @@ public: virtual void SetGLSLMaterials(bool val); virtual bool GetGLSLMaterials(); + struct Scene* GetBlenderSceneForName(const STR_String& name); }; #endif //__KX_BLENDERSCENECONVERTER_H diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 7e976beaf44..321fc325bb8 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -1064,7 +1064,7 @@ void BL_ConvertActuators(char* maggiename, { bParentActuator *parAct = (bParentActuator *) bact->data; int mode = KX_ParentActuator::KX_PARENT_NODEF; - KX_GameObject *tmpgob; + KX_GameObject *tmpgob = NULL; switch(parAct->type) { diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile index f312fc13221..4dd63e428bd 100644 --- a/source/gameengine/Converter/Makefile +++ b/source/gameengine/Converter/Makefile @@ -51,6 +51,7 @@ CPPFLAGS += -I../../blender/include CPPFLAGS += -I../../blender/blenlib CPPFLAGS += -I../../blender/blenkernel CPPFLAGS += -I../../blender/render/extern/include +CPPFLAGS += -I../../blender/gpu CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../Expressions -I../Rasterizer -I../GameLogic CPPFLAGS += -I../Ketsji -I../BlenderRoutines -I../SceneGraph diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript index f5e382b471e..3be352c568b 100644 --- a/source/gameengine/Converter/SConscript +++ b/source/gameengine/Converter/SConscript @@ -16,7 +16,7 @@ incs += ' #source/gameengine/Expressions #source/gameengine/Network #source/game incs += ' #source/gameengine/Physics/common #source/gameengine/Physics/Bullet #source/gameengine/Physics/BlOde' incs += ' #source/gameengine/Physics/Dummy #source/gameengine/Physics/Sumo' incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork' -incs += ' #source/blender/misc #source/blender/blenloader' +incs += ' #source/blender/misc #source/blender/blenloader #source/blender/gpu' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_SOLID_INC'] diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt index e26f8b9d69a..0c6c4179e2d 100644 --- a/source/gameengine/GamePlayer/common/CMakeLists.txt +++ b/source/gameengine/GamePlayer/common/CMakeLists.txt @@ -30,7 +30,6 @@ SET(SRC GPC_Engine.cpp GPC_KeyboardDevice.cpp GPC_MouseDevice.cpp - GPC_PolygonMaterial.cpp GPC_RawImage.cpp GPC_RawLoadDotBlendArray.cpp GPC_RawLogoArrays.cpp @@ -69,6 +68,7 @@ SET(INC ../../../../source/gameengine/GamePlayer/ghost ../../../../source/blender/misc ../../../../source/blender/blenloader + ../../../../source/blender/gpu ../../../../extern/glew/include ${PYTHON_INC} ${SOLID_INC} diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index a64c85f6c17..78d8eaf2aa3 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -27,141 +27,256 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include - -#ifdef WIN32 -#pragma warning (disable : 4786) -#include -#endif - #include "GL/glew.h" -#include - -#include "GPC_RenderTools.h" - #include "RAS_IRenderTools.h" #include "RAS_IRasterizer.h" #include "RAS_LightObject.h" #include "RAS_ICanvas.h" #include "RAS_GLExtensionManager.h" -// next two includes/dependencies come from the shadow feature -// it needs the gameobject and the sumo physics scene for a raycast #include "KX_GameObject.h" - -#include "GPC_PolygonMaterial.h" #include "KX_PolygonMaterial.h" -#include "Value.h" +#include "KX_BlenderMaterial.h" +#include "KX_RayCast.h" +#include "KX_IPhysicsController.h" + +#include "PHY_IPhysicsEnvironment.h" -//#include "KX_BlenderGL.h" // for text printing -//#include "KX_BlenderClientObject.h" #include "STR_String.h" -#include "RAS_BucketManager.h" // for polymaterial (needed for textprinting) - - -// Blender includes -/* This list includes only data type definitions */ -#include "DNA_object_types.h" -#include "DNA_material_types.h" -#include "DNA_image_types.h" -#include "DNA_lamp_types.h" -#include "DNA_group_types.h" -#include "DNA_scene_types.h" -#include "DNA_camera_types.h" -#include "DNA_property_types.h" -#include "DNA_text_types.h" -#include "DNA_sensor_types.h" -#include "DNA_controller_types.h" -#include "DNA_actuator_types.h" -#include "DNA_mesh_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_view3d_types.h" -#include "DNA_world_types.h" - -#include "BKE_global.h" -#include "BKE_image.h" -#include "BKE_bmfont.h" + +#include "GPU_draw.h" + +#include "BKE_bmfont.h" // for text printing #include "BKE_bmfont_types.h" -#include "BKE_main.h" -#include "IMB_imbuf_types.h" -// End of Blender includes +#include "GPC_RenderTools.h" -#include "KX_Scene.h" -#include "KX_RayCast.h" -#include "KX_IPhysicsController.h" -#include "PHY_IPhysicsEnvironment.h" -#include "KX_BlenderMaterial.h" +unsigned int GPC_RenderTools::m_numgllights; GPC_RenderTools::GPC_RenderTools() { m_font = BMF_GetFont(BMF_kHelvetica10); + glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights); if (m_numgllights < 8) m_numgllights = 8; } - GPC_RenderTools::~GPC_RenderTools() { } +void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty) +{ + m_clientobject = NULL; + m_lastlightlayer = -1; + m_lastlighting = false; + DisableOpenGLLights(); +} void GPC_RenderTools::EndFrame(RAS_IRasterizer* rasty) { } +/* ProcessLighting performs lighting on objects. the layer is a bitfield that + * contains layer information. There are 20 'official' layers in blender. A + * light is applied on an object only when they are in the same layer. OpenGL + * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in + * a scene. */ -void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty) +void GPC_RenderTools::ProcessLighting(int layer, const MT_Transform& viewmat) { - m_clientobject=NULL; - m_modified=true; - DisableOpenGLLights(); + if(m_lastlightlayer == layer) + return; -} + m_lastlightlayer = layer; -int GPC_RenderTools::ProcessLighting(int layer) -{ - int result = false; + bool enable = false; - if (layer < 0) - { - DisableOpenGLLights(); - result = false; - } else + if (layer >= 0) { if (m_clientobject) - { - if (applyLights(layer)) - { - EnableOpenGLLights(); - result = true; - } else - { - DisableOpenGLLights(); - result = false; - } + { + if (layer == RAS_LIGHT_OBJECT_LAYER) + layer = static_cast(m_clientobject)->GetLayer(); + + enable = applyLights(layer, viewmat); } } - return result; + + if(enable) + EnableOpenGLLights(); + else + DisableOpenGLLights(); } void GPC_RenderTools::EnableOpenGLLights() { + if(m_lastlighting == true) + return; + glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); - glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE); + + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true); if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2) glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); + + m_lastlighting = true; } -void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, - const char* text, - int xco, - int yco, - int width, - int height) +void GPC_RenderTools::DisableOpenGLLights() +{ + if(m_lastlighting == false) + return; + + glDisable(GL_LIGHTING); + glDisable(GL_COLOR_MATERIAL); + + m_lastlighting = false; +} + + +void GPC_RenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj) +{ + if (m_clientobject != obj) + { + bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()); + rasty->SetFrontFace(ccw); + + m_clientobject = obj; + } +} + +bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data) +{ + double* const oglmatrix = (double* const) data; + MT_Point3 resultpoint(result->m_hitPoint); + MT_Vector3 resultnormal(result->m_hitNormal); + MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]); + MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized(); + left = (dir.cross(resultnormal)).safe_normalized(); + // for the up vector, we take the 'resultnormal' returned by the physics + + double maat[16]={ + left[0], left[1], left[2], 0, + dir[0], dir[1], dir[2], 0, + resultnormal[0],resultnormal[1],resultnormal[2], 0, + 0, 0, 0, 1}; + glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]); + //glMultMatrixd(oglmatrix); + glMultMatrixd(maat); + return true; +} + +void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode ) +{ + /* FIXME: + blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const + MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed. + + Program received signal SIGABRT, Aborted. + [Switching to Thread 16384 (LWP 1519)] + 0x40477571 in kill () from /lib/libc.so.6 + (gdb) bt + #7 0x08334368 in MT_Vector3::normalized() const () + #8 0x0833e6ec in GPC_RenderTools::applyTransform(RAS_IRasterizer*, double*, int) () + */ + + if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED || + objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED) + { + // rotate the billboard/halo + //page 360/361 3D Game Engine Design, David Eberly for a discussion + // on screen aligned and axis aligned billboards + // assumed is that the preprocessor transformed all billboard polygons + // so that their normal points into the positive x direction (1.0 , 0.0 , 0.0) + // when new parenting for objects is done, this rotation + // will be moved into the object + + MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]); + MT_Point3 campos = rasty->GetCameraPosition(); + MT_Vector3 dir = (campos - objpos).safe_normalized(); + MT_Vector3 up(0,0,1.0); + + KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject; + // get scaling of halo object + MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale(); + + bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned + if (screenaligned) + { + up = (up - up.dot(dir) * dir).safe_normalized(); + } else + { + dir = (dir - up.dot(dir)*up).safe_normalized(); + } + + MT_Vector3 left = dir.normalized(); + dir = (left.cross(up)).normalized(); + + // we have calculated the row vectors, now we keep + // local scaling into account: + + left *= size[0]; + dir *= size[1]; + up *= size[2]; + double maat[16]={ + left[0], left[1],left[2], 0, + dir[0], dir[1],dir[2],0, + up[0],up[1],up[2],0, + 0,0,0,1}; + glTranslated(objpos[0],objpos[1],objpos[2]); + glMultMatrixd(maat); + + } else + { + if (objectdrawmode & RAS_IPolyMaterial::SHADOW) + { + // shadow must be cast to the ground, physics system needed here! + MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]); + KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject; + MT_Vector3 direction = MT_Vector3(0,0,-1); + + direction.normalize(); + direction *= 100000; + + MT_Point3 topoint = frompoint + direction; + + KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo; + PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment(); + KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController(); + + KX_GameObject *parent = gameobj->GetParent(); + if (!physics_controller && parent) + physics_controller = parent->GetPhysicsController(); + if (parent) + parent->Release(); + + KX_RayCast::Callback callback(this, physics_controller, oglmatrix); + if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback)) + { + // couldn't find something to cast the shadow on... + glMultMatrixd(oglmatrix); + } + } else + { + + // 'normal' object + glMultMatrixd(oglmatrix); + } + } +} + + +void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, + const char* text, + int xco, + int yco, + int width, + int height) { STR_String tmpstr(text); int lines; @@ -234,21 +349,19 @@ void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, glDisable(GL_LIGHTING); } -/** - * Copied from KX_BlenderRenderTools.cpp in KX_blenderhook - * Renders text into a (series of) polygon(s), using a texture font, - * Each character consists of one polygon (one quad or two triangles) - */ +/* Render Text renders text into a (series of) polygon, using a texture font, + * Each character consists of one polygon (one quad or two triangles) */ + void GPC_RenderTools::RenderText( int mode, RAS_IPolyMaterial* polymat, - float v1[3], float v2[3], float v3[3], float v4[3]) + float v1[3], float v2[3], float v3[3], float v4[3], int glattrib) { STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text"); const unsigned int flag = polymat->GetFlag(); struct MTFace* tface = 0; - unsigned int* col = 0; + unsigned int *col = 0; if(flag & RAS_BLENDERMAT) { KX_BlenderMaterial *bl_mat = static_cast(polymat); @@ -259,110 +372,29 @@ void GPC_RenderTools::RenderText( tface = blenderpoly->GetMTFace(); col = blenderpoly->GetMCol(); } - - BL_RenderText(mode, mytext, mytext.Length(), tface, col, v1, v2, v3, v4); + + GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib); } - -/** - * Copied from KX_BlenderGL.cpp in KX_blenderhook - */ -void GPC_RenderTools::BL_RenderText( - int mode, - const char* textstr, - int textlen, - struct MTFace* tface, - unsigned int* col, - float v1[3],float v2[3],float v3[3],float v4[3]) +void GPC_RenderTools::PushMatrix() { - struct Image* ima; - - if (mode & TF_BMFONT) { - //char string[MAX_PROPSTRING]; -// float tmat[4][4]; - int characters, index, character; - float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance; - -// bProperty *prop; - - // string = "Frank van Beek"; - - characters = textlen; - - ima = (struct Image*) tface->tpage; - if (ima == NULL) { - characters = 0; - } - - if(!col) glColor3f(1.0f, 1.0f, 1.0f); - - glPushMatrix(); - for (index = 0; index < characters; index++) { - // lets calculate offset stuff - character = textstr[index]; - - // space starts at offset 1 - // character = character - ' ' + 1; - - matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, ¢ery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance); - - glBegin(GL_POLYGON); - // printf(" %c %f %f %f %f\n", character, tface->uv[0][0], tface->uv[0][1], ); - // glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy); - glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy); - - if(col) BL_spack(col[0]); - // glVertex3fv(v1); - glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]); - - glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy); - if(col) BL_spack(col[1]); - // glVertex3fv(v2); - glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]); - - glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy); - if(col) BL_spack(col[2]); - // glVertex3fv(v3); - glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]); - - if(v4) { - // glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, 1.0 - (1.0 - tface->uv[3][1]) * sizey - transy); - glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy); - if(col) BL_spack(col[3]); - // glVertex3fv(v4); - glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]); - } - glEnd(); - - glTranslatef(advance, 0.0, 0.0); - } - glPopMatrix(); - - } + glPushMatrix(); } - -RAS_IPolyMaterial* GPC_RenderTools::CreateBlenderPolyMaterial( - const STR_String &texname, - bool ba,const STR_String& matname,int tile,int tilexrep,int tileyrep,int mode,bool transparant, bool zsort, - int lightlayer,bool bIsTriangle,void* clientobject,void* tface) +void GPC_RenderTools::PopMatrix() { - assert(!"Deprecated"); -/* return new GPC_PolygonMaterial(texname, ba,matname,tile,tilexrep,tileyrep, - mode,transparant,zsort,lightlayer,bIsTriangle,clientobject,tface); - */ - return NULL; + glPopMatrix(); } -int GPC_RenderTools::applyLights(int objectlayer) +int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat) { -// taken from blender source, incompatibility between Blender Object / GameObject - - int count; + // taken from blender source, incompatibility between Blender Object / GameObject + float glviewmat[16]; + unsigned int count; float vec[4]; - + vec[3]= 1.0; for(count=0; count m_lights; std::vector::iterator lit = m_lights.begin(); + viewmat.getValue(glviewmat); + glPushMatrix(); + glLoadMatrixf(glviewmat); for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit) { RAS_LightObject* lightdata = (*lit); if (lightdata->m_layer & objectlayer) { - - glPushMatrix(); - glLoadMatrixf(m_viewmat); - - vec[0] = (*(lightdata->m_worldmatrix))(0,3); vec[1] = (*(lightdata->m_worldmatrix))(1,3); vec[2] = (*(lightdata->m_worldmatrix))(2,3); vec[3] = 1; - if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) { vec[0] = (*(lightdata->m_worldmatrix))(0,2); @@ -443,141 +472,16 @@ int GPC_RenderTools::applyLights(int objectlayer) } glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec); glEnable((GLenum)(GL_LIGHT0+count)); - - count++; - glPopMatrix(); + count++; } } + glPopMatrix(); return count; } -void GPC_RenderTools::SetClientObject(void* obj) -{ - if (m_clientobject != obj) - { - if (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling()) - { - glFrontFace(GL_CCW); - } else - { - glFrontFace(GL_CW); - } - m_clientobject = obj; - m_modified = true; - } -} - -bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data) -{ - double* const oglmatrix = (double* const) data; - MT_Point3 resultpoint(result->m_hitPoint); - MT_Vector3 resultnormal(result->m_hitNormal); - MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]); - MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized(); - left = (dir.cross(resultnormal)).safe_normalized(); - // for the up vector, we take the 'resultnormal' returned by the physics - - double maat[16]={ - left[0], left[1], left[2], 0, - dir[0], dir[1], dir[2], 0, - resultnormal[0],resultnormal[1],resultnormal[2], 0, - 0, 0, 0, 1}; - glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]); - //glMultMatrixd(oglmatrix); - glMultMatrixd(maat); - return true; -} - -void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode ) -{ - if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED || - objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED) - { - // rotate the billboard/halo - //page 360/361 3D Game Engine Design, David Eberly for a discussion - // on screen aligned and axis aligned billboards - // assumed is that the preprocessor transformed all billboard polygons - // so that their normal points into the positive x direction (1.0 , 0.0 , 0.0) - // when new parenting for objects is done, this rotation - // will be moved into the object - - MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]); - MT_Point3 campos = rasty->GetCameraPosition(); - MT_Vector3 dir = (campos - objpos).safe_normalized(); - MT_Vector3 up(0,0,1.0); - - KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject; - // get scaling of halo object - MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale(); - - bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned - if (screenaligned) - { - up = (up - up.dot(dir) * dir).safe_normalized(); - } else - { - dir = (dir - up.dot(dir)*up).safe_normalized(); - } - - MT_Vector3 left = dir.normalized(); - dir = (left.cross(up)).normalized(); - - // we have calculated the row vectors, now we keep - // local scaling into account: - - left *= size[0]; - dir *= size[1]; - up *= size[2]; - double maat[16]={ - left[0], left[1],left[2], 0, - dir[0], dir[1],dir[2],0, - up[0],up[1],up[2],0, - 0,0,0,1}; - glTranslated(objpos[0],objpos[1],objpos[2]); - glMultMatrixd(maat); - - } else - { - if (objectdrawmode & RAS_IPolyMaterial::SHADOW) - { - // shadow must be cast to the ground, physics system needed here! - MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]); - KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject; - MT_Vector3 direction = MT_Vector3(0,0,-1); - - direction.normalize(); - direction *= 100000; - - MT_Point3 topoint = frompoint + direction; - - KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo; - PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment(); - KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController(); - - KX_GameObject *parent = gameobj->GetParent(); - if (!physics_controller && parent) - physics_controller = parent->GetPhysicsController(); - if (parent) - parent->Release(); - - KX_RayCast::Callback callback(this, physics_controller, oglmatrix); - if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback)) - { - // couldn't find something to cast the shadow on... - glMultMatrixd(oglmatrix); - } - } else - { - - // 'normal' object - glMultMatrixd(oglmatrix); - } - } -} - void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer) { int state = rasterizer->GetMotionBlurState(); @@ -608,7 +512,6 @@ void GPC_RenderTools::Update2DFilter(vector& propNames, void* gameOb void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas) { - m_filtermanager.RenderFilters( canvas); + m_filtermanager.RenderFilters(canvas); } -unsigned int GPC_RenderTools::m_numgllights; diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h index 9f70f67caf2..382956e73ea 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h @@ -31,11 +31,11 @@ #define __GPC_RENDERTOOLS_H #ifdef WIN32 - #include +// don't show stl-warnings +#pragma warning (disable:4786) +#include #endif // WIN32 -#include "GL/glew.h" - #include "RAS_IRenderTools.h" #include "BMF_Api.h" @@ -43,100 +43,52 @@ struct KX_ClientObjectInfo; class KX_RayCast; +/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which + * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon) + * text, lighting. + * + * Most of this code is duplicated in KX_BlenderRenderTools, so this should be + * moved to some common location to avoid duplication. */ + class GPC_RenderTools : public RAS_IRenderTools { + int m_lastlightlayer; + bool m_lastlighting; + static unsigned int m_numgllights; + + BMF_Font* m_font; + public: - GPC_RenderTools(); - virtual ~GPC_RenderTools(); - - virtual void EndFrame(RAS_IRasterizer* rasty); - virtual void BeginFrame(RAS_IRasterizer* rasty); - - void DisableOpenGLLights() - { - glDisable(GL_LIGHTING); - glDisable(GL_COLOR_MATERIAL); - } - - void EnableOpenGLLights(); - - int ProcessLighting(int layer); - - void Perspective(int a, int width, int height, float mat[4][4], float viewmat[4][4]) - { - if(a== 0) - { - glMatrixMode(GL_PROJECTION); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - } - else - { - if(a== 1) - { - glMatrixMode(GL_PROJECTION); - glMatrixMode(GL_MODELVIEW); - } - } - } - - /** - * @attention mode is ignored here - */ - virtual void RenderText2D( - RAS_TEXT_RENDER_MODE mode, - const char* text, - int xco, - int yco, - int width, - int height); - - /** - * Renders text into a (series of) polygon(s), using a texture font, - * Each character consists of one polygon (one quad or two triangles) - */ - virtual void RenderText( - int mode, - RAS_IPolyMaterial* polymat, - float v1[3], - float v2[3], - float v3[3], - float v4[3]); - - void Render(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode) - { - glPopMatrix(); - glPushMatrix(); - glMultMatrixd(oglmatrix); - } - - void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode); - - virtual void PushMatrix() - { - glPushMatrix(); - } - - virtual void PopMatrix() - { - glPopMatrix(); - } - - virtual class RAS_IPolyMaterial* CreateBlenderPolyMaterial( - const STR_String &texname, - bool ba, - const STR_String& matname, - int tile, - int tilexrep,int tileyrep, - int mode, - bool transparant, - bool zsort, - int lightlayer, - bool bIsTriangle, - void* clientobject, - void* tface); - - int applyLights(int objectlayer); + GPC_RenderTools(); + virtual ~GPC_RenderTools(); + + void EndFrame(RAS_IRasterizer* rasty); + void BeginFrame(RAS_IRasterizer* rasty); + + void EnableOpenGLLights(); + void DisableOpenGLLights(); + void ProcessLighting(int layer, const MT_Transform& viewmat); + + /* @attention mode is ignored here */ + void RenderText2D(RAS_TEXT_RENDER_MODE mode, + const char* text, + int xco, + int yco, + int width, + int height); + void RenderText(int mode, + class RAS_IPolyMaterial* polymat, + float v1[3], + float v2[3], + float v3[3], + float v4[3], + int glattrib); + + void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode); + int applyLights(int objectlayer, const MT_Transform& viewmat); + + void PushMatrix(); + void PopMatrix(); bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); bool NeedRayCast(KX_ClientObjectInfo* client) { return true; } @@ -147,28 +99,7 @@ public: virtual void Render2DFilters(RAS_ICanvas* canvas); - virtual void SetClientObject(void* obj); - -protected: - /** - * Copied from KX_BlenderGL.cpp in KX_blenderhook - */ - void BL_RenderText( - int mode, - const char* textstr, - int textlen, - struct MTFace* tface, - unsigned int* col, - float v1[3],float v2[3],float v3[3],float v4[3]); - void BL_spack(unsigned int ucol) - { - char *cp = (char *)&ucol; - glColor3ub(cp[3], cp[2], cp[1]); - } - - - BMF_Font* m_font; - static unsigned int m_numgllights; + virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj); }; #endif // __GPC_RENDERTOOLS_H diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile index 19d792ddbdb..6a12e659be6 100644 --- a/source/gameengine/GamePlayer/common/Makefile +++ b/source/gameengine/GamePlayer/common/Makefile @@ -43,6 +43,7 @@ CPPFLAGS += -I../../../blender/blenloader CPPFLAGS += -I../../../blender/blenlib CPPFLAGS += -I../../../blender/imbuf CPPFLAGS += -I../../../blender/makesdna +CPPFLAGS += -I../../../blender/gpu CPPFLAGS += -I../../../kernel/gen_system CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include @@ -72,10 +73,6 @@ CPPFLAGS += -I../../../gameengine/Rasterizer/RAS_OpenGLRasterizer CPPFLAGS += -I../../../gameengine/Physics/Sumo CPPFLAGS += -I../../../gameengine/Physics/common -ifeq ($(WITH_BF_GLEXT),true) - CPPFLAGS += -DWITH_GLEXT -endif - ############################### SOURCEDIR = source/gameengine/GamePlayer/common diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript index 3b2367d2592..30f20a670d3 100644 --- a/source/gameengine/GamePlayer/common/SConscript +++ b/source/gameengine/GamePlayer/common/SConscript @@ -8,7 +8,6 @@ source_files = ['bmfont.cpp', 'GPC_Engine.cpp', 'GPC_KeyboardDevice.cpp', 'GPC_MouseDevice.cpp', - 'GPC_PolygonMaterial.cpp', 'GPC_RawImage.cpp', 'GPC_RawLoadDotBlendArray.cpp', 'GPC_RawLogoArrays.cpp', @@ -46,6 +45,7 @@ incs = ['.', '#source/gameengine/GamePlayer/ghost', '#source/blender/misc', '#source/blender/blenloader', + '#source/blender/gpu', '#extern/glew/include'] #This is all plugin stuff! diff --git a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h index fee729a84ac..e5ed7f39811 100644 --- a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h +++ b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h @@ -37,9 +37,9 @@ class GPU_PolygonMaterial : public BP_PolygonMaterial public: GPUPolygonMaterial(const STR_String& texname, bool ba,const STR_String& matname, int tile, int tileXrep, int tileYrep, int mode, int transparant, - int lightlayer,bool bIsTriangle,void* clientobject,void* tpage) : + int lightlayer,,void* tpage) : BP_PolygonMaterial(texname, ba,matname, tile, tileXrep, tileYrep, - mode, transparant, lightlayer, bIsTriangle, clientobject), + mode, transparant, lightlayer), m_tface(tpage) { } diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt index d9f0675001f..5e0ca93ac06 100644 --- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt +++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt @@ -64,6 +64,7 @@ SET(INC ../../../../source/gameengine/GamePlayer/common ../../../../source/blender/misc ../../../../source/blender/blenloader + ../../../../source/blender/gpu ../../../../extern/solid ../../../../extern/glew/include ${PYTHON_INC} diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index c56a6d0da23..a690beb9f38 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -38,6 +38,7 @@ #endif #include "GL/glew.h" +#include "GPU_extensions.h" #include "GPG_Application.h" @@ -104,9 +105,10 @@ static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time); static GHOST_ISystem* fSystem = 0; static const int kTimerFreq = 10; -GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR_String startSceneName) - : m_startSceneName(startSceneName), - m_maggie(maggie), +GPG_Application::GPG_Application(GHOST_ISystem* system) + : m_startSceneName(""), + m_startScene(0), + m_maggie(0), m_exitRequested(0), m_system(system), m_mainWindow(0), @@ -142,15 +144,16 @@ GPG_Application::~GPG_Application(void) -bool GPG_Application::SetGameEngineData(struct Main* maggie, STR_String startSceneName) +bool GPG_Application::SetGameEngineData(struct Main* maggie, Scene *scene) { bool result = false; - if (maggie != NULL && startSceneName != "") + if (maggie != NULL && scene != NULL) { - G.scene = (Scene*)maggie->scene.first; + G.scene = scene; m_maggie = maggie; - m_startSceneName = startSceneName; + m_startSceneName = scene->id.name+2; + m_startScene = scene; result = true; } @@ -480,7 +483,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) { if (!m_engineInitialized) { - glewInit(); + GPU_extensions_init(); bgl::InitExtensions(true); // get and set the preferences @@ -499,12 +502,18 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixed_framerate", fixedFr) != 0); bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); - bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DIAPLAY_LISTS) != 0); + bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DISPLAY_LISTS) != 0); if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) { int gameflag =(G.fileflags & G_FILE_GAME_MAT); m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0); } + + if(GPU_extensions_minimum_support()) { + int gameflag = (G.fileflags & G_FILE_GAME_MAT_GLSL); + + m_blenderglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", gameflag) != 0); + } // create the canvas, rasterizer and rendertools m_canvas = new GPG_Canvas(window); @@ -640,14 +649,15 @@ bool GPG_Application::startEngine(void) m_mouse, m_networkdevice, m_audiodevice, - startscenename); + startscenename, + m_startScene); // some python things PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest); m_ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(m_rasterizer, m_canvas); - PyObject *gameLogic = initGameLogic(startscene); + PyObject *gameLogic = initGameLogic(m_ketsjiengine, startscene); PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module initGameKeys(); initPythonConstraintBinding(); @@ -745,6 +755,8 @@ void GPG_Application::stopEngine() void GPG_Application::exitEngine() { + GPU_extensions_exit(); + if (m_ketsjiengine) { stopEngine(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 31f5eb75e52..5242a419808 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -50,14 +50,15 @@ class GPG_Canvas; class GPG_KeyboardDevice; class GPG_System; struct Main; +struct Scene; class GPG_Application : public GHOST_IEventConsumer { public: - GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR_String startSceneName); + GPG_Application(GHOST_ISystem* system); ~GPG_Application(void); - bool SetGameEngineData(struct Main* maggie,STR_String startSceneName); + bool SetGameEngineData(struct Main* maggie, struct Scene* scene); bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight, const bool stereoVisual, const int stereoMode); bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode); @@ -123,6 +124,7 @@ protected: /* The game data */ STR_String m_startSceneName; + struct Scene* m_startScene; struct Main* m_maggie; /* Exit state. */ diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 26a85128025..cc781a38bbb 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -64,13 +64,15 @@ extern "C" #ifdef __cplusplus } #endif // __cplusplus + +#include "GPU_draw.h" + /********************************** * End Blender include block **********************************/ #include "SYS_System.h" #include "GPG_Application.h" -#include "GPC_PolygonMaterial.h" #include "GHOST_ISystem.h" #include "RAS_IRasterizer.h" @@ -282,7 +284,7 @@ int main(int argc, char** argv) bool fullScreenParFound = false; bool windowParFound = false; bool closeConsole = true; - RAS_IRasterizer::StereoMode stereomode; + RAS_IRasterizer::StereoMode stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO; bool stereoWindow = false; bool stereoParFound = false; int windowLeft = 100; @@ -525,8 +527,6 @@ int main(int argc, char** argv) return 0; } - if (!stereoParFound) stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO; - #ifdef WIN32 if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION) #endif @@ -539,7 +539,7 @@ int main(int argc, char** argv) if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0)) { - GPC_PolygonMaterial::SetMipMappingEnabled(0); + GPU_set_mipmap(0); } // Create the system @@ -561,7 +561,7 @@ int main(int argc, char** argv) { int exitcode = KX_EXIT_REQUEST_NO_REQUEST; STR_String exitstring = ""; - GPG_Application app(system, NULL, exitstring); + GPG_Application app(system); bool firstTimeRunning = true; char *filename = get_filename(argc, argv); char *titlename; @@ -619,7 +619,7 @@ int main(int argc, char** argv) #endif // WIN32 Main *maggie = bfd->main; Scene *scene = bfd->curscene; - char *startscenename = scene->id.name + 2; + G.main = maggie; G.fileflags = bfd->fileflags; //Seg Fault; icon.c gIcons == 0 @@ -661,7 +661,7 @@ int main(int argc, char** argv) } // GPG_Application app (system, maggie, startscenename); - app.SetGameEngineData(maggie, startscenename); + app.SetGameEngineData(maggie, scene); if (firstTimeRunning) { diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index 13940ac3fc8..0b187791734 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -69,6 +69,7 @@ CPPFLAGS += -I../../../blender/blenloader CPPFLAGS += -I../../../blender/imbuf CPPFLAGS += -I../../../blender/makesdna CPPFLAGS += -I../../../blender/readblenfile +CPPFLAGS += -I../../../blender/gpu CPPFLAGS += -I../../../gameengine/BlenderRoutines @@ -80,7 +81,3 @@ CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_GHOST)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -ifeq ($(WITH_BF_GLEXT),true) - CPPFLAGS += -DWITH_GLEXT -endif - diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript index f3cce6c7443..33cf07b6211 100644 --- a/source/gameengine/GamePlayer/ghost/SConscript +++ b/source/gameengine/GamePlayer/ghost/SConscript @@ -40,6 +40,7 @@ incs = ['.', '#source/gameengine/GamePlayer/common', '#source/blender/misc', '#source/blender/blenloader', + '#source/blender/gpu', '#extern/glew/include'] incs += Split(env['BF_PYTHON_INC']) @@ -48,8 +49,5 @@ cflags = [] if env['OURPLATFORM']=='win32-vc': cflags = ['/GR'] -if env['WITH_BF_GLEXT'] == 1: - env['CPPFLAGS'].append('-DWITH_GLEXT') - env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = [], libtype='player',priority=0, compileflags=cflags) diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index a9a0771936c..13b8235687b 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -9,108 +9,64 @@ #include "BL_BlenderShader.h" #include "BL_Material.h" -#ifdef BLENDER_GLSL #include "GPU_extensions.h" #include "GPU_material.h" -#endif #include "RAS_BucketManager.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" - /* this is evil, but we need the scene to create materials with - * lights from the correct scene .. */ -static struct Scene *GetSceneForName(const STR_String& scenename) -{ - Scene *sce; - - for (sce= (Scene*)G.main->scene.first; sce; sce= (Scene*)sce->id.next) - if (scenename == (sce->id.name+2)) - return sce; - - return (Scene*)G.main->scene.first; -} - -bool BL_BlenderShader::Ok() -{ -#ifdef BLENDER_GLSL - VerifyShader(); - - return (mMat && mMat->gpumaterial); -#else - return 0; -#endif -} - BL_BlenderShader::BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer) : -#ifdef BLENDER_GLSL mScene(scene), mMat(ma), - mGPUMat(NULL), -#endif - mBound(false), mLightLayer(lightlayer) { -#ifdef BLENDER_GLSL - mBlenderScene = GetSceneForName(scene->GetName()); + mBlenderScene = scene->GetBlenderScene(); //GetSceneForName(scene->GetName()); mBlendMode = GPU_BLEND_SOLID; - if(mMat) { + if(mMat) GPU_material_from_blender(mBlenderScene, mMat); - mGPUMat = mMat->gpumaterial; - } -#endif } BL_BlenderShader::~BL_BlenderShader() { -#ifdef BLENDER_GLSL - if(mMat && mMat->gpumaterial) - GPU_material_unbind(mMat->gpumaterial); -#endif + if(mMat && GPU_material_from_blender(mBlenderScene, mMat)) + GPU_material_unbind(GPU_material_from_blender(mBlenderScene, mMat)); } -bool BL_BlenderShader::VerifyShader() +bool BL_BlenderShader::Ok() { -#ifdef BLENDER_GLSL - if(mMat && !mMat->gpumaterial) - GPU_material_from_blender(mBlenderScene, mMat); + return VerifyShader(); +} - mGPUMat = mMat->gpumaterial; - - return (mMat && mGPUMat); -#else - return false; -#endif +bool BL_BlenderShader::VerifyShader() +{ + if(mMat) + return (GPU_material_from_blender(mBlenderScene, mMat) != 0); + else + return false; } -void BL_BlenderShader::SetProg(bool enable) +void BL_BlenderShader::SetProg(bool enable, double time) { -#ifdef BLENDER_GLSL if(VerifyShader()) { - if(enable) { - GPU_material_bind(mGPUMat, mLightLayer); - mBound = true; - } - else { - GPU_material_unbind(mGPUMat); - mBound = false; - } + if(enable) + GPU_material_bind(GPU_material_from_blender(mBlenderScene, mMat), mLightLayer, time); + else + GPU_material_unbind(GPU_material_from_blender(mBlenderScene, mMat)); } -#endif } int BL_BlenderShader::GetAttribNum() { -#ifdef BLENDER_GLSL GPUVertexAttribs attribs; int i, enabled = 0; if(!VerifyShader()) return enabled; - GPU_material_vertex_attributes(mGPUMat, &attribs); + GPU_material_vertex_attributes(GPU_material_from_blender(mBlenderScene, mMat), &attribs); for(i = 0; i < attribs.totlayer; i++) if(attribs.layer[i].glindex+1 > enabled) @@ -120,24 +76,23 @@ int BL_BlenderShader::GetAttribNum() enabled = BL_MAX_ATTRIB; return enabled; -#else - return 0; -#endif } void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat) { -#ifdef BLENDER_GLSL GPUVertexAttribs attribs; + GPUMaterial *gpumat; int i, attrib_num; ras->SetAttribNum(0); if(!VerifyShader()) return; + + gpumat = GPU_material_from_blender(mBlenderScene, mMat); if(ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) { - GPU_material_vertex_attributes(mGPUMat, &attribs); + GPU_material_vertex_attributes(gpumat, &attribs); attrib_num = GetAttribNum(); ras->SetTexCoordNum(0); @@ -168,44 +123,37 @@ void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat) else ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, attribs.layer[i].glindex); } - - ras->EnableTextures(true); } - else - ras->EnableTextures(false); -#endif } -void BL_BlenderShader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) +void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) { -#ifdef BLENDER_GLSL float obmat[4][4], viewmat[4][4], viewinvmat[4][4], obcol[4]; + GPUMaterial *gpumat; - VerifyShader(); + gpumat = GPU_material_from_blender(mBlenderScene, mMat); - if(!mGPUMat) // || !mBound) + if(!gpumat || !GPU_material_bound(gpumat)) return; MT_Matrix4x4 model; model.setValue(ms.m_OpenGLMatrix); - MT_Matrix4x4 view; - rasty->GetViewMatrix(view); + const MT_Matrix4x4& view = rasty->GetViewMatrix(); + const MT_Matrix4x4& viewinv = rasty->GetViewInvMatrix(); + // note: getValue gives back column major as needed by OpenGL model.getValue((float*)obmat); view.getValue((float*)viewmat); - - view.invert(); - view.getValue((float*)viewinvmat); + viewinv.getValue((float*)viewinvmat); if(ms.m_bObjectColor) ms.m_RGBAcolor.getValue((float*)obcol); else obcol[0]= obcol[1]= obcol[2]= obcol[3]= 1.0f; - GPU_material_bind_uniforms(mGPUMat, obmat, viewmat, viewinvmat, obcol); + GPU_material_bind_uniforms(gpumat, obmat, viewmat, viewinvmat, obcol); - mBlendMode = GPU_material_blend_mode(mGPUMat, obcol); -#endif + mBlendMode = GPU_material_blend_mode(gpumat, obcol); } int BL_BlenderShader::GetBlendMode() @@ -215,12 +163,8 @@ int BL_BlenderShader::GetBlendMode() bool BL_BlenderShader::Equals(BL_BlenderShader *blshader) { -#ifdef BLENDER_GLSL /* to avoid unneeded state switches */ - return (blshader && mGPUMat == blshader->mGPUMat && mLightLayer == blshader->mLightLayer); -#else - return true; -#endif + return (blshader && mMat == blshader->mMat && mLightLayer == blshader->mLightLayer); } // eof diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index da9765dafa4..5c1f59f94ad 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -2,9 +2,7 @@ #ifndef __BL_GPUSHADER_H__ #define __BL_GPUSHADER_H__ -#ifdef BLENDER_GLSL #include "GPU_material.h" -#endif #include "MT_Matrix4x4.h" #include "MT_Matrix3x3.h" @@ -29,13 +27,9 @@ class BL_Material; class BL_BlenderShader { private: -#ifdef BLENDER_GLSL KX_Scene *mScene; struct Scene *mBlenderScene; struct Material *mMat; - GPUMaterial *mGPUMat; -#endif - bool mBound; int mLightLayer; int mBlendMode; @@ -46,11 +40,11 @@ public: virtual ~BL_BlenderShader(); bool Ok(); - void SetProg(bool enable); + void SetProg(bool enable, double time=0.0); int GetAttribNum(); void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat); - void Update(const class KX_MeshSlot & ms, class RAS_IRasterizer* rasty); + void Update(const class RAS_MeshSlot & ms, class RAS_IRasterizer* rasty); int GetBlendMode(); bool Equals(BL_BlenderShader *blshader); diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h index dcb66ea2579..0eaa234566c 100644 --- a/source/gameengine/Ketsji/BL_Material.h +++ b/source/gameengine/Ketsji/BL_Material.h @@ -18,9 +18,9 @@ struct EnvMap; this will default to users available units to build with more available, just increment this value although the more you add the slower the search time will be. - we will go for three, which should be enough + we will go for eight, which should be enough */ -#define MAXTEX 3 //match in RAS_TexVert & RAS_OpenGLRasterizer +#define MAXTEX 8 //match in RAS_TexVert & RAS_OpenGLRasterizer // different mapping modes class BL_Mapping @@ -139,7 +139,7 @@ enum BL_ras_mode COLLIDER=2, ZSORT=4, ALPHA=8, - TRIANGLE=16, + // TRIANGLE=16, USE_LIGHT=32, WIRE=64 }; diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index 57d0fe4140f..f28d3fa2912 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -433,7 +433,7 @@ void BL_Shader::SetProg(bool enable) } } -void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) +void BL_Shader::Update( const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) { if(!Ok() || !mPreDef.size()) return; @@ -445,8 +445,7 @@ void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) { MT_Matrix4x4 model; model.setValue(ms.m_OpenGLMatrix); - MT_Matrix4x4 view; - rasty->GetViewMatrix(view); + const MT_Matrix4x4& view = rasty->GetViewMatrix(); if(mAttr==SHD_TANGENT) ms.m_mesh->SetMeshModified(true); @@ -525,13 +524,15 @@ void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty ) } case VIEWMATRIX_INVERSE: { - view.invert(); + MT_Matrix4x4 viewinv = view; + viewinv.invert(); SetUniform(uni->mLoc, view); break; } case VIEWMATRIX_INVERSETRANSPOSE: { - view.invert(); + MT_Matrix4x4 viewinv = view; + viewinv.invert(); SetUniform(uni->mLoc, view, true); break; } @@ -670,6 +671,7 @@ void BL_Shader::SetUniform(int uniform, const MT_Matrix4x4& vec, bool transpose) ) { float value[16]; + // note: getValue gives back column major as needed by OpenGL vec.getValue(value); glUniformMatrix4fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value); } diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index 8f303454087..c7fae31ba03 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -177,7 +177,7 @@ public: void UnloadShader(); // Update predefined uniforms each render call - void Update(const class KX_MeshSlot & ms, class RAS_IRasterizer* rasty); + void Update(const class RAS_MeshSlot & ms, class RAS_IRasterizer* rasty); //// Set sampler units (copied) //void InitializeSampler(int unit, BL_Texture* texture ); diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index be009d94701..58411f6d25e 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -69,6 +69,7 @@ SET(INC ../../../intern/SoundSystem ../../../source/blender/misc ../../../source/blender/blenloader + ../../../source/blender/gpu ../../../extern/bullet2/src ../../../extern/solid ../../../extern/glew/include diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index a67e5b26667..f92200780d5 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -19,13 +19,12 @@ #include "MT_Vector4.h" #include "MT_Matrix4x4.h" +#include "RAS_BucketManager.h" #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" #include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" -extern "C" { -#include "BDR_drawmesh.h" -} +#include "GPU_draw.h" #include "STR_HashedString.h" @@ -48,7 +47,6 @@ KX_BlenderMaterial::KX_BlenderMaterial( BL_Material *data, bool skin, int lightlayer, - void *clientobject, PyTypeObject *T ) : PyObjectPlus(T), @@ -62,9 +60,7 @@ KX_BlenderMaterial::KX_BlenderMaterial( data->transp, ((data->ras_mode &ALPHA)!=0), ((data->ras_mode &ZSORT)!=0), - lightlayer, - ((data->ras_mode &TRIANGLE)!=0), - clientobject + lightlayer ), mMaterial(data), mShader(0), @@ -78,9 +74,10 @@ KX_BlenderMaterial::KX_BlenderMaterial( { // -------------------------------- // RAS_IPolyMaterial variables... - m_flag |=RAS_BLENDERMAT; - m_flag |=(mMaterial->IdMode>=ONETEX)?RAS_MULTITEX:0; - m_flag |=(mMaterial->ras_mode & USE_LIGHT)!=0?RAS_MULTILIGHT:0; + m_flag |= RAS_BLENDERMAT; + m_flag |= (mMaterial->IdMode>=ONETEX)? RAS_MULTITEX: 0; + m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0; + m_flag |= (mMaterial->glslmat)? RAS_BLENDERGLSL: 0; // figure max int enabled = mMaterial->num_enabled; @@ -97,7 +94,7 @@ KX_BlenderMaterial::KX_BlenderMaterial( mMaterial->blend_mode[i] ); } - m_multimode += mMaterial->IdMode+mMaterial->ras_mode; + m_multimode += mMaterial->IdMode+ (mMaterial->ras_mode & ~(COLLIDER|USE_LIGHT)); } @@ -204,7 +201,7 @@ void KX_BlenderMaterial::OnExit() } if( mMaterial->tface ) - set_tpage(mMaterial->tface); + GPU_set_tpage(mMaterial->tface); } @@ -256,25 +253,28 @@ void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras) void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras) { if( !enable || !mBlenderShader->Ok() ) { + ras->SetBlendingMode(TF_SOLID); + // frame cleanup. if(mLastBlenderShader) { mLastBlenderShader->SetProg(false); mLastBlenderShader= NULL; } + else + BL_Texture::DisableAllTextures(); - ras->SetBlendingMode(TF_SOLID); - BL_Texture::DisableAllTextures(); return; } if(!mBlenderShader->Equals(mLastBlenderShader)) { ras->SetBlendingMode(mMaterial->transp); - BL_Texture::DisableAllTextures(); if(mLastBlenderShader) mLastBlenderShader->SetProg(false); + else + BL_Texture::DisableAllTextures(); - mBlenderShader->SetProg(true); + mBlenderShader->SetProg(true, ras->GetTime()); mLastBlenderShader= mBlenderShader; } } @@ -354,21 +354,22 @@ KX_BlenderMaterial::ActivatShaders( if (GetCachingInfo() != cachingInfo) { if (!cachingInfo) - tmp->setShaderData( false, rasty); + tmp->setShaderData(false, rasty); cachingInfo = GetCachingInfo(); if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) - tmp->setShaderData( true, rasty); + tmp->setShaderData(true, rasty); else - tmp->setShaderData( false, rasty); + tmp->setShaderData(false, rasty); if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE) rasty->SetCullFace(false); else rasty->SetCullFace(true); - if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES) + if (((mMaterial->ras_mode &WIRE)!=0) || (mMaterial->mode & RAS_IRasterizer::KX_LINES) || + (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) { if((mMaterial->ras_mode &WIRE)!=0) rasty->SetCullFace(false); @@ -394,31 +395,24 @@ KX_BlenderMaterial::ActivateBlenderShaders( mLastShader= NULL; } - // reset... - if(tmp->mMaterial->IsShared()) - cachingInfo =0; - if (GetCachingInfo() != cachingInfo) { if (!cachingInfo) tmp->setBlenderShaderData(false, rasty); cachingInfo = GetCachingInfo(); - if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) { + if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) tmp->setBlenderShaderData(true, rasty); - rasty->EnableTextures(true); - } - else { + else tmp->setBlenderShaderData(false, rasty); - rasty->EnableTextures(false); - } if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE) rasty->SetCullFace(false); else rasty->SetCullFace(true); - if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES) + if (((mMaterial->ras_mode & WIRE)!=0) || (mMaterial->mode & RAS_IRasterizer::KX_LINES) || + (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) { if((mMaterial->ras_mode &WIRE)!=0) rasty->SetCullFace(false); @@ -426,10 +420,10 @@ KX_BlenderMaterial::ActivateBlenderShaders( } else rasty->SetLines(false); - } - ActivatGLMaterials(rasty); - mBlenderShader->SetAttribs(rasty, mMaterial); + ActivatGLMaterials(rasty); + mBlenderShader->SetAttribs(rasty, mMaterial); + } } void @@ -466,7 +460,8 @@ KX_BlenderMaterial::ActivateMat( else rasty->SetCullFace(true); - if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES) + if (((mMaterial->ras_mode &WIRE)!=0) || (mMaterial->mode & RAS_IRasterizer::KX_LINES) || + (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) { if((mMaterial->ras_mode &WIRE)!=0) rasty->SetCullFace(false); @@ -486,12 +481,10 @@ KX_BlenderMaterial::Activate( TCachingInfo& cachingInfo )const { - bool dopass = false; - if( GLEW_ARB_shader_objects && ( mShader && mShader->Ok() ) ) { - if( (mPass++) < mShader->getNumPass() ) { + if(GLEW_ARB_shader_objects && (mShader && mShader->Ok())) { + if((mPass++) < mShader->getNumPass() ) { ActivatShaders(rasty, cachingInfo); - dopass = true; - return dopass; + return true; } else { if(mShader == mLastShader) { @@ -499,36 +492,29 @@ KX_BlenderMaterial::Activate( mLastShader = NULL; } mPass = 0; - dopass = false; - return dopass; + return false; } } - else if( GLEW_ARB_shader_objects && ( mBlenderShader && mBlenderShader->Ok() ) ) { - if( (mPass++) == 0 ) { + else if( GLEW_ARB_shader_objects && (mBlenderShader && mBlenderShader->Ok() ) ) { + if(mPass++ == 0) { ActivateBlenderShaders(rasty, cachingInfo); - dopass = true; - return dopass; + return true; } else { mPass = 0; - dopass = false; - return dopass; + return false; } } else { - switch (mPass++) - { - case 0: - ActivateMat(rasty, cachingInfo); - dopass = true; - break; - default: - mPass = 0; - dopass = false; - break; + if(mPass++ == 0) { + ActivateMat(rasty, cachingInfo); + return true; + } + else { + mPass = 0; + return false; } } - return dopass; } bool KX_BlenderMaterial::UsesLighting(RAS_IRasterizer *rasty) const @@ -536,14 +522,15 @@ bool KX_BlenderMaterial::UsesLighting(RAS_IRasterizer *rasty) const if(!RAS_IPolyMaterial::UsesLighting(rasty)) return false; - if(mShader && mShader->Ok()); + if(mShader && mShader->Ok()) + return true; else if(mBlenderShader && mBlenderShader->Ok()) return false; - - return true; + else + return true; } -void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterizer* rasty) const +void KX_BlenderMaterial::ActivateMeshSlot(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty) const { if(mShader && GLEW_ARB_shader_objects) { mShader->Update(ms, rasty); @@ -554,7 +541,7 @@ void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterize mBlenderShader->Update(ms, rasty); /* we do blend modes here, because they can change per object - * with the same material due to obcolor */ + * with the same material due to obcolor/obalpha */ blendmode = mBlenderShader->GetBlendMode(); if((blendmode == TF_SOLID || blendmode == TF_ALPHA) && mMaterial->transp != TF_SOLID) blendmode = mMaterial->transp; @@ -633,11 +620,7 @@ void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const else ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_DISABLE, i); } - - ras->EnableTextures(true); } - else - ras->EnableTextures(false); } void KX_BlenderMaterial::setTexMatrixData(int i) @@ -712,8 +695,7 @@ void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras) glEnable(GL_TEXTURE_GEN_T); glEnable(GL_TEXTURE_GEN_R); - MT_Matrix4x4 mvmat; - ras->GetViewMatrix(mvmat); + const MT_Matrix4x4& mvmat = ras->GetViewMatrix(); glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -835,7 +817,9 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()") } if(mShader && !mShader->GetError()) { + m_flag &= ~RAS_BLENDERGLSL; mMaterial->SetSharedMaterial(true); + mScene->GetBucketManager()->ReleaseDisplayLists(this); Py_INCREF(mShader); return mShader; }else @@ -870,8 +854,6 @@ void KX_BlenderMaterial::SetBlenderGLSLShader(void) delete mBlenderShader; mBlenderShader = 0; } - else - m_flag |= RAS_BLENDERGLSL; } KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()") diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 0d7657b8cdb..4ddf5a924df 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -28,7 +28,6 @@ public: BL_Material* mat, bool skin, int lightlayer, - void* clientobject, PyTypeObject* T=&Type ); @@ -47,7 +46,7 @@ public: virtual void ActivateMeshSlot( - const KX_MeshSlot & ms, + const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) const; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index d6997ee29a8..9607489497d 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -76,16 +76,16 @@ struct KX_PhysicsInstance { DT_VertexBaseHandle m_vertexbase; - int m_vtxarray; + RAS_DisplayArray* m_darray; RAS_IPolyMaterial* m_material; - - KX_PhysicsInstance(DT_VertexBaseHandle vertex_base, int vtxarray, RAS_IPolyMaterial* mat) + + KX_PhysicsInstance(DT_VertexBaseHandle vertex_base, RAS_DisplayArray *darray, RAS_IPolyMaterial* mat) : m_vertexbase(vertex_base), - m_vtxarray(vtxarray), - m_material(mat) + m_darray(darray), + m_material(mat) { } - + ~KX_PhysicsInstance() { DT_DeleteVertexBase(m_vertexbase); @@ -100,11 +100,11 @@ static void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoSce static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope); void KX_ConvertSumoObject( KX_GameObject* gameobj, - RAS_MeshObject* meshobj, - KX_Scene* kxscene, - PHY_ShapeProps* kxshapeprops, - PHY_MaterialProps* kxmaterial, - struct KX_ObjectProperties* objprop) + RAS_MeshObject* meshobj, + KX_Scene* kxscene, + PHY_ShapeProps* kxshapeprops, + PHY_MaterialProps* kxmaterial, + struct KX_ObjectProperties* objprop) { @@ -150,23 +150,23 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj, objprop->m_boundobject.box.m_extends[1], objprop->m_boundobject.box.m_extends[2]); smprop->m_inertia.scale(objprop->m_boundobject.box.m_extends[0]*objprop->m_boundobject.box.m_extends[0], - objprop->m_boundobject.box.m_extends[1]*objprop->m_boundobject.box.m_extends[1], - objprop->m_boundobject.box.m_extends[2]*objprop->m_boundobject.box.m_extends[2]); + objprop->m_boundobject.box.m_extends[1]*objprop->m_boundobject.box.m_extends[1], + objprop->m_boundobject.box.m_extends[2]*objprop->m_boundobject.box.m_extends[2]); smprop->m_inertia *= smprop->m_mass/MT_Vector3(objprop->m_boundobject.box.m_extends).length(); break; case KX_BOUNDCYLINDER: shape = DT_NewCylinder(smprop->m_radius, objprop->m_boundobject.c.m_height); smprop->m_inertia.scale(smprop->m_mass*smprop->m_radius*smprop->m_radius, - smprop->m_mass*smprop->m_radius*smprop->m_radius, - smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height); + smprop->m_mass*smprop->m_radius*smprop->m_radius, + smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height); break; case KX_BOUNDCONE: shape = DT_NewCone(objprop->m_radius, objprop->m_boundobject.c.m_height); smprop->m_inertia.scale(smprop->m_mass*smprop->m_radius*smprop->m_radius, - smprop->m_mass*smprop->m_radius*smprop->m_radius, - smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height); + smprop->m_mass*smprop->m_radius*smprop->m_radius, + smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height); break; - /* Dynamic mesh objects. WARNING! slow. */ + /* Dynamic mesh objects. WARNING! slow. */ case KX_BOUNDPOLYTOPE: polytope = true; // fall through @@ -186,15 +186,15 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj, shape = DT_NewSphere(objprop->m_radius); smprop->m_inertia *= smprop->m_mass*smprop->m_radius*smprop->m_radius; break; - + } - + sumoObj = new SM_Object(shape, !objprop->m_ghost?smmaterial:NULL,smprop,NULL); - + sumoObj->setRigidBody(objprop->m_angular_rigidbody?true:false); - + BL_RegisterSumoObject(gameobj,sceneptr,sumoObj,"",true, true); - + } else { // non physics object @@ -320,12 +320,11 @@ static void BL_RegisterSumoObject( physicscontroller->SetObject(gameobj->GetSGNode()); } -static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, int vtxarray, RAS_IPolyMaterial *mat) +static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, RAS_DisplayArray *darray, RAS_IPolyMaterial *mat) { // instance a mesh from a single vertex array & material - const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(mat)[vtxarray])[0]); - //const KX_IndexArray &index_array = *meshobj->GetIndexCache(mat)[vtxarray]; - DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getLocalXYZ(), sizeof(RAS_TexVert)); + const RAS_TexVert *vertex_array = &darray->m_vertex[0]; + DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getXYZ(), sizeof(RAS_TexVert)); DT_ShapeHandle shape = DT_NewComplexShape(vertex_base); @@ -337,15 +336,19 @@ static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, int vtxarr // only add polygons that have the collisionflag set if (poly->IsCollider()) { - DT_VertexIndices(3, poly->GetVertexIndexBase().m_indexarray); + DT_Begin(); + DT_VertexIndex(poly->GetVertexOffset(0)); + DT_VertexIndex(poly->GetVertexOffset(1)); + DT_VertexIndex(poly->GetVertexOffset(2)); + DT_End(); // tesselate if (poly->VertexCount() == 4) { DT_Begin(); - DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[0]); - DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[2]); - DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[3]); + DT_VertexIndex(poly->GetVertexOffset(0)); + DT_VertexIndex(poly->GetVertexOffset(2)); + DT_VertexIndex(poly->GetVertexOffset(3)); DT_End(); } } @@ -354,16 +357,15 @@ static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, int vtxarr //DT_VertexIndices(indices.size(), &indices[0]); DT_EndComplexShape(); - map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, vtxarray, mat)); + map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, darray, mat)); return shape; } -static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, int vtxarray, RAS_IPolyMaterial *mat) +static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, RAS_DisplayArray *darray, RAS_IPolyMaterial *mat) { // instance a mesh from a single vertex array & material - const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(mat)[vtxarray])[0]); - //const KX_IndexArray &index_array = *meshobj->GetIndexCache(mat)[vtxarray]; - DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getLocalXYZ(), sizeof(RAS_TexVert)); + const RAS_TexVert *vertex_array = &darray->m_vertex[0]; + DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getXYZ(), sizeof(RAS_TexVert)); std::vector indices; for (int p = 0; p < meshobj->NumPolygons(); p++) @@ -373,12 +375,12 @@ static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, int vtxar // only add polygons that have the collisionflag set if (poly->IsCollider()) { - indices.push_back(poly->GetVertexIndexBase().m_indexarray[0]); - indices.push_back(poly->GetVertexIndexBase().m_indexarray[1]); - indices.push_back(poly->GetVertexIndexBase().m_indexarray[2]); + indices.push_back(poly->GetVertexOffset(0)); + indices.push_back(poly->GetVertexOffset(1)); + indices.push_back(poly->GetVertexOffset(2)); if (poly->VertexCount() == 4) - indices.push_back(poly->GetVertexIndexBase().m_indexarray[3]); + indices.push_back(poly->GetVertexOffset(3)); } } @@ -386,7 +388,7 @@ static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, int vtxar DT_VertexIndices(indices.size(), &indices[0]); DT_EndPolytope(); - map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, vtxarray, mat)); + map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, darray, mat)); return shape; } @@ -398,8 +400,8 @@ bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj) KX_PhysicsInstance *instance = *map_gamemesh_to_instance[GEN_HashedPtr(meshobj)]; if (instance) { - const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(instance->m_material)[instance->m_vtxarray])[0]); - DT_ChangeVertexBase(instance->m_vertexbase, vertex_array[0].getLocalXYZ()); + const RAS_TexVert *vertex_array = &instance->m_darray->m_vertex[0]; + DT_ChangeVertexBase(instance->m_vertexbase, vertex_array[0].getXYZ()); return true; } return false; @@ -425,7 +427,7 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope // Count the number of collision polygons and check they all come from the same // vertex array int numvalidpolys = 0; - int vtxarray = -1; + RAS_DisplayArray *darray = NULL; RAS_IPolyMaterial *poly_material = NULL; bool reinstance = true; @@ -437,14 +439,14 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope if (poly->IsCollider()) { // check polygon is from the same vertex array - if (poly->GetVertexIndexBase().m_vtxarray != vtxarray) + if (poly->GetDisplayArray() != darray) { - if (vtxarray < 0) - vtxarray = poly->GetVertexIndexBase().m_vtxarray; + if (darray == NULL) + darray = poly->GetDisplayArray(); else { reinstance = false; - vtxarray = -1; + darray = NULL; } } @@ -478,9 +480,9 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope if (reinstance) { if (polytope) - shape = InstancePhysicsPolytope(meshobj, vtxarray, poly_material); + shape = InstancePhysicsPolytope(meshobj, darray, poly_material); else - shape = InstancePhysicsComplex(meshobj, vtxarray, poly_material); + shape = InstancePhysicsComplex(meshobj, darray, poly_material); } else { @@ -489,7 +491,7 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope std::cout << "CreateShapeFromMesh: " << meshobj->GetName() << " is not suitable for polytope." << std::endl; if (!poly_material) std::cout << " Check mesh materials." << std::endl; - if (vtxarray < 0) + if (darray == NULL) std::cout << " Check number of vertices." << std::endl; } @@ -505,18 +507,10 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope if (poly->IsCollider()) { /* We have to tesselate here because SOLID can only raycast triangles */ DT_Begin(); - /* V1 */ - DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[2], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ()); - /* V2 */ - DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[1], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ()); - /* V3 */ - DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[0], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ()); + /* V1, V2, V3 */ + DT_Vertex(poly->GetVertex(2)->getXYZ()); + DT_Vertex(poly->GetVertex(1)->getXYZ()); + DT_Vertex(poly->GetVertex(0)->getXYZ()); numvalidpolys++; DT_End(); @@ -524,18 +518,10 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope if (poly->VertexCount() == 4) { DT_Begin(); - /* V1 */ - DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[3], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ()); - /* V3 */ - DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[2], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ()); - /* V4 */ - DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[0], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ()); + /* V1, V3, V4 */ + DT_Vertex(poly->GetVertex(3)->getXYZ()); + DT_Vertex(poly->GetVertex(2)->getXYZ()); + DT_Vertex(poly->GetVertex(0)->getXYZ()); numvalidpolys++; DT_End(); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index cc2956813c1..bec5d188f06 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -79,10 +79,12 @@ KX_GameObject::KX_GameObject( m_bDyna(false), m_layer(0), m_pBlenderObject(NULL), + m_pBlenderGroupObject(NULL), m_bSuspendDynamics(false), m_bUseObjectColor(false), m_bIsNegativeScaling(false), m_bVisible(true), + m_bCulled(true), m_pPhysicsController1(NULL), m_pPhysicsEnvironment(NULL), m_xray(false), @@ -101,8 +103,11 @@ KX_GameObject::KX_GameObject( }; + KX_GameObject::~KX_GameObject() { + RemoveMeshes(); + // is this delete somewhere ? //if (m_sumoObj) // delete m_sumoObj; @@ -164,7 +169,6 @@ STR_String KX_GameObject::GetName() void KX_GameObject::SetName(STR_String name) { m_name = name; - }; // Set the name of the value @@ -285,11 +289,11 @@ void KX_GameObject::ProcessReplica(KX_GameObject* replica) CValue* KX_GameObject::GetReplica() { KX_GameObject* replica = new KX_GameObject(*this); - + // this will copy properties and so on... CValue::AddDataToReplica(replica); ProcessReplica(replica); - + return replica; } @@ -355,24 +359,26 @@ double* KX_GameObject::GetOpenGLMatrix() return fl; } +void KX_GameObject::AddMeshUser() +{ + for (size_t i=0;iAddMeshUser(this); + + UpdateBuckets(); +} - -void KX_GameObject::Bucketize() +void KX_GameObject::UpdateBuckets() { double* fl = GetOpenGLMatrix(); for (size_t i=0;iBucketize(fl, this, m_bUseObjectColor, m_objectColor); + m_meshes[i]->UpdateBuckets(this, fl, m_bUseObjectColor, m_objectColor, m_bVisible, m_bCulled); } - - void KX_GameObject::RemoveMeshes() { - double* fl = GetOpenGLMatrix(); - for (size_t i=0;iRemoveFromBuckets(fl, this); + m_meshes[i]->RemoveFromBuckets(this); //note: meshes can be shared, and are deleted by KX_BlenderSceneConverter @@ -455,13 +461,14 @@ KX_GameObject::UpdateMaterialData( ) { int mesh = 0; - if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0) { - RAS_MaterialBucket::Set::iterator mit = m_meshes[mesh]->GetFirstMaterial(); + list::iterator mit = m_meshes[mesh]->GetFirstMaterial(); + for(; mit != m_meshes[mesh]->GetLastMaterial(); ++mit) { - RAS_IPolyMaterial* poly = (*mit)->GetPolyMaterial(); - if(poly->GetFlag() & RAS_BLENDERMAT) + RAS_IPolyMaterial* poly = mit->m_bucket->GetPolyMaterial(); + + if(poly->GetFlag() & RAS_BLENDERMAT ) { KX_BlenderMaterial *m = static_cast(poly); @@ -469,8 +476,7 @@ KX_GameObject::UpdateMaterialData( { m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); // if mesh has only one material attached to it then use original hack with no need to edit vertices (better performance) - if(!(poly->GetFlag() & RAS_BLENDERGLSL)) - SetObjectColor(rgba); + SetObjectColor(rgba); } else { @@ -504,60 +510,39 @@ KX_GameObject::SetVisible( m_bVisible = v; } -void -KX_GameObject::SetLayer( - int l +bool +KX_GameObject::GetCulled( + void ) { - m_layer = l; + return m_bCulled; } -int -KX_GameObject::GetLayer( - void +void +KX_GameObject::SetCulled( + bool c ) { - return m_layer; + m_bCulled = c; } -// used by Python, and the actuatorshould _not_ be misused by the -// scene! -void -KX_GameObject::MarkVisible( - bool visible + +void +KX_GameObject::SetLayer( + int l ) { - /* If explicit visibility settings are used, this is - * determined on this level. Maybe change this to mesh level - * later on? */ - - double* fl = GetOpenGLMatrixPtr()->getPointer(); - for (size_t i=0;iMarkVisible(fl,this,visible,m_bUseObjectColor,m_objectColor); - } + m_layer = l; } - -// Always use the flag? -void -KX_GameObject::MarkVisible( +int +KX_GameObject::GetLayer( void ) { - double* fl = GetOpenGLMatrixPtr()->getPointer(); - for (size_t i=0;iMarkVisible(fl, - this, - m_bVisible, - m_bUseObjectColor, - m_objectColor - ); - } + return m_layer; } - void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local) { if (m_pPhysicsController1) @@ -1052,6 +1037,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr if (attr == "visible") { SetVisible(val != 0); + UpdateBuckets(); return 0; } } @@ -1221,8 +1207,8 @@ PyObject* KX_GameObject::PySetVisible(PyObject* self, PyObject* value) return NULL; } - MarkVisible(visible!=0); - m_bVisible = (visible!=0); + SetVisible(visible != 0); + UpdateBuckets(); Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 508bc7cdfd0..9dcf6526448 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -75,15 +75,17 @@ protected: int m_layer; std::vector m_meshes; struct Object* m_pBlenderObject; + struct Object* m_pBlenderGroupObject; bool m_bSuspendDynamics; bool m_bUseObjectColor; bool m_bIsNegativeScaling; MT_Vector4 m_objectColor; - // Is this object set to be visible? Only useful for the - // visibility subsystem right now. - bool m_bVisible; + // visible = user setting + // culled = while rendering, depending on camera + bool m_bVisible; + bool m_bCulled; KX_IPhysicsController* m_pPhysicsController1; // used for ray casting @@ -395,6 +397,16 @@ public: { m_pBlenderObject = obj; } + + struct Object* GetBlenderGroupObject( ) + { + return m_pBlenderGroupObject; + } + + void SetBlenderGroupObject( struct Object* obj) + { + m_pBlenderGroupObject = obj; + } bool IsDupliGroup() { @@ -538,18 +550,22 @@ public: /** * @section Mesh accessor functions. */ + + /** + * Update buckets to indicate that there is a new + * user of this object's meshes. + */ + void + AddMeshUser( + ); /** - * Run through the meshes associated with this - * object and bucketize them. See RAS_Mesh for - * more details on this function. Interesting to - * note that polygon bucketizing seems to happen on a per - * object basis. Which may explain why there is such - * a big performance gain when all static objects - * are joined into 1. + * Update buckets with data about the mesh after + * creating or duplicating the object, changing + * visibility, object color, .. . */ void - Bucketize( + UpdateBuckets( ); /** @@ -610,38 +626,37 @@ public: ResetDebugColor( ); - /** - * Set the visibility of the meshes associated with this - * object. + /** + * Was this object marked visible? (only for the explicit + * visibility system). */ - void - MarkVisible( - bool visible + bool + GetVisible( + void ); - /** - * Set the visibility according to the visibility flag. + /** + * Set visibility flag of this object */ - void - MarkVisible( void + SetVisible( + bool b ); /** - * Was this object marked visible? (only for the ewxplicit - * visibility system). + * Was this object culled? */ bool - GetVisible( + GetCulled( void ); /** - * Set visibility flag of this object + * Set culled flag of this object */ void - SetVisible( - bool b + SetCulled( + bool c ); /** @@ -669,6 +684,14 @@ public: void ) { return m_bIsNegativeScaling; } + /** + * Is this a light? + */ + virtual bool + IsLight( + void + ) { return false; } + /** * @section Logic bubbling methods. */ diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h index f069048cd3d..3709fa8c784 100644 --- a/source/gameengine/Ketsji/KX_ISceneConverter.h +++ b/source/gameengine/Ketsji/KX_ISceneConverter.h @@ -32,6 +32,8 @@ #include "STR_String.h" #include "KX_Python.h" +struct Scene; + class KX_ISceneConverter { @@ -77,6 +79,8 @@ public: // use blender glsl materials virtual void SetGLSLMaterials(bool val) =0; virtual bool GetGLSLMaterials()=0; + + virtual struct Scene* GetBlenderSceneForName(const STR_String& name)=0; }; #endif //__KX_ISCENECONVERTER_H diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 1d6cc975ab5..cf98bb72601 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -96,6 +96,7 @@ 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; +double KX_KetsjiEngine::m_average_framerate = 0.0; /** @@ -310,6 +311,12 @@ void KX_KetsjiEngine::EndFrame() { RenderDebugProperties(); } + + m_average_framerate = m_logger->GetAverage(); + if (m_average_framerate < 1e-6) + m_average_framerate = 1e-6; + m_average_framerate = 1.0/m_average_framerate; + // Go to next profiling measurement, time spend after this call is shown in the next frame. m_logger->NextMeasurement(m_kxsystem->GetTimeInSeconds()); @@ -321,8 +328,6 @@ void KX_KetsjiEngine::EndFrame() m_canvas->EndDraw(); - - } //#include "PIL_time.h" @@ -897,11 +902,18 @@ void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam) void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) { - CListValue *lightlist = scene->GetLightList(); + CListValue *objectlist = scene->GetObjectList(); int i, drawmode; - for(i=0; iGetCount(); i++) { - KX_LightObject *light = (KX_LightObject*)lightlist->GetValue(i); + m_rendertools->SetAuxilaryClientInfo(scene); + + for(i=0; iGetCount(); i++) { + KX_GameObject *gameobj = (KX_GameObject*)objectlist->GetValue(i); + + if(!gameobj->IsLight()) + continue; + + KX_LightObject *light = (KX_LightObject*)gameobj; light->Update(); @@ -1281,12 +1293,13 @@ void KX_KetsjiEngine::RemoveScheduledScenes() KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename) { - + Scene *scene = m_sceneconverter->GetBlenderSceneForName(scenename); KX_Scene* tmpscene = new KX_Scene(m_keyboarddevice, m_mousedevice, m_networkdevice, m_audiodevice, - scenename); + scenename, + scene); m_sceneconverter->ConvertScene(scenename, tmpscene, @@ -1442,6 +1455,11 @@ void KX_KetsjiEngine::SetAnimFrameRate(double framerate) m_anim_framerate = framerate; } +double KX_KetsjiEngine::GetAverageFrameRate() +{ + return m_average_framerate; +} + void KX_KetsjiEngine::SetTimingDisplay(bool frameRate, bool profile, bool properties) { m_show_framerate = frameRate; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 77b69ec2d9e..97458362f0f 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -149,6 +149,8 @@ private: /** Labels for profiling display. */ static const char m_profileLabels[tc_numCategories][15]; + /** Last estimated framerate */ + static double m_average_framerate; /** Show the framerate on the game display? */ bool m_show_framerate; /** Show profiling info on the game display? */ @@ -271,6 +273,11 @@ public: */ static void SetAnimFrameRate(double framerate); + /** + * Gets the last estimated average framerate + */ + static double GetAverageFrameRate(); + /** * Activates or deactivates timing information display. * @param frameRate Display for frame rate on or off. diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 4e3d6180d22..6cfe5610863 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -42,14 +42,13 @@ #include "KX_PyMath.h" -#ifdef BLENDER_GLSL +#include "DNA_object_types.h" #include "GPU_material.h" -#endif KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, class RAS_IRenderTools* rendertools, const RAS_LightObject& lightobj, - struct GPULamp *gpulamp, + bool glsl, PyTypeObject* T ) : @@ -59,7 +58,8 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, m_lightobj = lightobj; m_lightobj.m_worldmatrix = GetOpenGLMatrixPtr(); m_rendertools->AddLight(&m_lightobj); - m_gpulamp = gpulamp; + m_glsl = glsl; + m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene(); }; @@ -73,7 +73,7 @@ CValue* KX_LightObject::GetReplica() { KX_LightObject* replica = new KX_LightObject(*this); - + // this will copy properties and so on... CValue::AddDataToReplica(replica); @@ -81,13 +81,23 @@ CValue* KX_LightObject::GetReplica() replica->m_lightobj.m_worldmatrix = replica->GetOpenGLMatrixPtr(); m_rendertools->AddLight(&replica->m_lightobj); + return replica; } +GPULamp *KX_LightObject::GetGPULamp() +{ + if(m_glsl) + return GPU_lamp_from_blender(m_blenderscene, GetBlenderObject(), GetBlenderGroupObject()); + else + return false; +} + void KX_LightObject::Update() { -#ifdef BLENDER_GLSL - if(m_gpulamp) { + GPULamp *lamp; + + if((lamp = GetGPULamp())) { float obmat[4][4]; double *dobmat = GetOpenGLMatrixPtr()->getPointer(); @@ -95,38 +105,39 @@ void KX_LightObject::Update() for(int j=0; j<4; j++, dobmat++) obmat[i][j] = (float)*dobmat; - GPU_lamp_update(m_gpulamp, obmat); + GPU_lamp_update(lamp, obmat); } -#endif } bool KX_LightObject::HasShadowBuffer() { -#ifdef BLENDER_GLSL - return (m_gpulamp && GPU_lamp_has_shadow_buffer(m_gpulamp)); -#else - return false; -#endif + GPULamp *lamp; + + if((lamp = GetGPULamp())) + return GPU_lamp_has_shadow_buffer(lamp); + else + return false; } int KX_LightObject::GetShadowLayer() { -#ifdef BLENDER_GLSL - if(m_gpulamp) - return GPU_lamp_shadow_layer(m_gpulamp); + GPULamp *lamp; + + if((lamp = GetGPULamp())) + return GPU_lamp_shadow_layer(lamp); else -#endif return 0; } void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_Transform& camtrans) { -#ifdef BLENDER_GLSL + GPULamp *lamp; float viewmat[4][4], winmat[4][4]; int winsize; /* bind framebuffer */ - GPU_lamp_shadow_buffer_bind(m_gpulamp, viewmat, &winsize, winmat); + lamp = GetGPULamp(); + GPU_lamp_shadow_buffer_bind(lamp, viewmat, &winsize, winmat); /* setup camera transformation */ MT_Matrix4x4 modelviewmat((float*)viewmat); @@ -146,14 +157,12 @@ void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_T ras->SetProjectionMatrix(projectionmat); ras->SetViewMatrix(modelviewmat, cam->NodeGetWorldPosition(), cam->GetCameraLocation(), cam->GetCameraOrientation()); -#endif } void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras) { -#ifdef BLENDER_GLSL - GPU_lamp_shadow_buffer_unbind(m_gpulamp); -#endif + GPULamp *lamp = GetGPULamp(); + GPU_lamp_shadow_buffer_unbind(lamp); } PyObject* KX_LightObject::_getattr(const STR_String& attr) diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h index 62eb26c61a8..e5dbf0b7f4a 100644 --- a/source/gameengine/Ketsji/KX_Light.h +++ b/source/gameengine/Ketsji/KX_Light.h @@ -33,6 +33,7 @@ #include "KX_GameObject.h" struct GPULamp; +struct Scene; class KX_Camera; class RAS_IRasterizer; class RAS_IRenderTools; @@ -44,16 +45,18 @@ class KX_LightObject : public KX_GameObject protected: RAS_LightObject m_lightobj; class RAS_IRenderTools* m_rendertools; //needed for registering and replication of lightobj - struct GPULamp *m_gpulamp; - static char doc[]; + bool m_glsl; + Scene* m_blenderscene; + static char doc[]; public: - KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, struct GPULamp *gpulamp, PyTypeObject *T = &Type); + KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, bool glsl, PyTypeObject *T = &Type); virtual ~KX_LightObject(); virtual CValue* GetReplica(); RAS_LightObject* GetLightData() { return &m_lightobj;} /* GLSL shadow */ + struct GPULamp *GetGPULamp(); bool HasShadowBuffer(); int GetShadowLayer(); void BindShadowBuffer(class RAS_IRasterizer *ras, class KX_Camera *cam, class MT_Transform& camtrans); @@ -62,6 +65,8 @@ public: virtual PyObject* _getattr(const STR_String& attr); /* lens, near, far, projection_matrix */ virtual int _setattr(const STR_String& attr, PyObject *pyvalue); + + virtual bool IsLight(void) { return true; } }; #endif //__KX_LIGHT diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 29842af7fb6..5bfe8c70cba 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -96,10 +96,11 @@ KX_MeshProxy::_getattr(const STR_String& attr) if (attr == "materials") { PyObject *materials = PyList_New(0); - RAS_MaterialBucket::Set::iterator mit = m_meshobj->GetFirstMaterial(); + list::iterator mit = m_meshobj->GetFirstMaterial(); for(; mit != m_meshobj->GetLastMaterial(); ++mit) { - RAS_IPolyMaterial *polymat = (*mit)->GetPolyMaterial(); + RAS_IPolyMaterial *polymat = mit->m_bucket->GetPolyMaterial(); + if(polymat->GetFlag() & RAS_BLENDERMAT) { KX_BlenderMaterial *mat = static_cast(polymat); @@ -204,11 +205,11 @@ PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* self, if (PyArg_ParseTuple(args,"i",&matid)) { - RAS_IPolyMaterial* mat = m_meshobj->GetMaterialBucket(matid)->GetPolyMaterial(); + RAS_MeshMaterial *mmat = m_meshobj->GetMeshMaterial(matid); + RAS_IPolyMaterial* mat = mmat->m_bucket->GetPolyMaterial(); + if (mat) - { - length = m_meshobj->GetVertexArrayLength(mat); - } + length = m_meshobj->NumVertices(mat); } else { return NULL; diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 658c8a98e4f..c6f6bc2db01 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -112,8 +112,8 @@ KX_PolyProxy::_getattr(const STR_String& attr) unsigned int matid; for (matid=0; matidNumMaterials(); matid++) { - RAS_MaterialBucket* meshBucket = m_mesh->GetMaterialBucket(matid); - if (meshBucket == polyBucket) + RAS_MeshMaterial* meshMat = m_mesh->GetMeshMaterial(matid); + if (meshMat->m_bucket == polyBucket) // found it break; } @@ -121,19 +121,19 @@ KX_PolyProxy::_getattr(const STR_String& attr) } if (attr == "v1") { - return PyInt_FromLong(m_polygon->GetVertexIndexBase().m_indexarray[0]); + return PyInt_FromLong(m_polygon->GetVertexOffset(0)); } if (attr == "v2") { - return PyInt_FromLong(m_polygon->GetVertexIndexBase().m_indexarray[1]); + return PyInt_FromLong(m_polygon->GetVertexOffset(1)); } if (attr == "v3") { - return PyInt_FromLong(m_polygon->GetVertexIndexBase().m_indexarray[2]); + return PyInt_FromLong(m_polygon->GetVertexOffset(2)); } if (attr == "v4") { - return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexIndexBase().m_indexarray[3]:0)); + return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0)); } if (attr == "visible") { @@ -178,8 +178,8 @@ KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialIndex, unsigned int matid; for (matid=0; matidNumMaterials(); matid++) { - RAS_MaterialBucket* meshBucket = m_mesh->GetMaterialBucket(matid); - if (meshBucket == polyBucket) + RAS_MeshMaterial* meshMat = m_mesh->GetMeshMaterial(matid); + if (meshMat->m_bucket == polyBucket) // found it break; } @@ -234,7 +234,7 @@ KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex, } if (index < m_polygon->VertexCount()) { - return PyInt_FromLong(m_polygon->GetVertexIndexBase().m_indexarray[index]); + return PyInt_FromLong(m_polygon->GetVertexOffset(index)); } return PyInt_FromLong(0); } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 144f74a1a4c..c9180bf3a80 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -35,10 +35,6 @@ #include "BKE_global.h" #include "BKE_image.h" -extern "C" { -#include "BDR_drawmesh.h" -} - #include "DNA_material_types.h" #include "DNA_texture_types.h" #include "DNA_image_types.h" @@ -46,6 +42,8 @@ extern "C" { #include "IMB_imbuf_types.h" +#include "GPU_draw.h" + #include "MEM_guardedalloc.h" #include "RAS_LightObject.h" @@ -63,8 +61,6 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname, bool alpha, bool zsort, int lightlayer, - bool bIsTriangle, - void* clientobject, struct MTFace* tface, unsigned int* mcol, PyTypeObject *T) @@ -78,9 +74,7 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname, transp, alpha, zsort, - lightlayer, - bIsTriangle, - clientobject), + lightlayer), m_tface(tface), m_mcol(mcol), m_material(material), @@ -140,38 +134,29 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c if (GetCachingInfo() != cachingInfo) { if (!cachingInfo) - { - set_tpage(NULL); - } + GPU_set_tpage(NULL); + cachingInfo = GetCachingInfo(); if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)) { - update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime()); - set_tpage(m_tface); - rasty->EnableTextures(true); + Image *ima = (Image*)m_tface->tpage; + GPU_update_image_time(ima, rasty->GetTime()); + GPU_set_tpage(m_tface); } else - { - set_tpage(NULL); - rasty->EnableTextures(false); - } + GPU_set_tpage(NULL); if(m_drawingmode & RAS_IRasterizer::KX_TWOSIDE) - { rasty->SetCullFace(false); - } else - { rasty->SetCullFace(true); - } - if (m_drawingmode & RAS_IRasterizer::KX_LINES) { + if ((m_drawingmode & RAS_IRasterizer::KX_LINES) || + (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) rasty->SetLines(true); - } - else { + else rasty->SetLines(false); - } } rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity); @@ -253,7 +238,8 @@ PyObject* KX_PolygonMaterial::_getattr(const STR_String& attr) if (attr == "lightlayer") return PyInt_FromLong(m_lightlayer); if (attr == "triangle") - return PyInt_FromLong(m_bIsTriangle); + // deprecated, triangle/quads shouldn't have been a material property + return 0; if (attr == "diffuse") return PyObjectFrom(m_diffuse); @@ -333,7 +319,7 @@ int KX_PolygonMaterial::_setattr(const STR_String &attr, PyObject *pyvalue) // This probably won't work... if (attr == "triangle") { - m_bIsTriangle = value; + // deprecated, triangle/quads shouldn't have been a material property return 0; } } @@ -386,7 +372,9 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, updateTexture, "updateTexture(tface, rast { MTFace *tface = (MTFace*) PyCObject_AsVoidPtr(pytface); RAS_IRasterizer *rasty = (RAS_IRasterizer*) PyCObject_AsVoidPtr(pyrasty); - update_realtime_texture(tface, rasty->GetTime()); + Image *ima = (Image*)tface->tpage; + GPU_update_image_time(ima, rasty->GetTime()); + Py_Return; } @@ -399,7 +387,7 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setTexture, "setTexture(tface)") if (PyArg_ParseTuple(args, "O!", &PyCObject_Type, &pytface)) { MTFace *tface = (MTFace*) PyCObject_AsVoidPtr(pytface); - set_tpage(tface); + GPU_set_tpage(tface); Py_Return; } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h index 11c8baa8b1f..fe116f757db 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.h +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h @@ -68,8 +68,6 @@ public: bool alpha, bool zsort, int lightlayer, - bool bIsTriangle, - void* clientobject, struct MTFace* tface, unsigned int* mcol, PyTypeObject *T = &Type); diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 4b6a38f18c0..120311fb967 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -57,13 +57,13 @@ #include "BL_ActionActuator.h" #include "RAS_IRasterizer.h" #include "RAS_ICanvas.h" +#include "RAS_BucketManager.h" #include "MT_Vector3.h" #include "MT_Point3.h" #include "ListValue.h" #include "KX_Scene.h" #include "SND_DeviceManager.h" -#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h" #include "BL_Shader.h" #include "KX_PyMath.h" @@ -83,6 +83,7 @@ extern "C" { #include "BKE_utildefines.h" #include "BKE_global.h" #include "BLI_blenlib.h" +#include "GPU_material.h" static void setSandbox(TPythonSecurityLevel level); @@ -90,6 +91,7 @@ static void setSandbox(TPythonSecurityLevel level); // 'local' copy of canvas ptr, for window height/width python scripts static RAS_ICanvas* gp_Canvas = NULL; static KX_Scene* gp_KetsjiScene = NULL; +static KX_KetsjiEngine* gp_KetsjiEngine = NULL; static RAS_IRasterizer* gp_Rasterizer = NULL; void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color) @@ -270,6 +272,11 @@ static PyObject* gPyGetPhysicsTicRate(PyObject*) return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep()); } +static PyObject* gPyGetAverageFrameRate(PyObject*) +{ + return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate()); +} + static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) { char cpath[sizeof(G.sce)]; @@ -409,6 +416,7 @@ static struct PyMethodDef game_methods[] = { {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"}, {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, "Gets the physics tic rate"}, {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"}, + {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, "Gets the estimated average frame rate"}, {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, "Gets a list of blend files in the same directory as the current blend file"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, "Prints GL Extension Info"}, {NULL, (PyCFunction) NULL, 0, NULL } @@ -670,6 +678,76 @@ static PyObject* gPyDisableMotionBlur(PyObject*, PyObject* args) Py_Return; } +int getGLSLSettingFlag(char *setting) +{ + if(strcmp(setting, "lights") == 0) + return G_FILE_GLSL_NO_LIGHTS; + else if(strcmp(setting, "shaders") == 0) + return G_FILE_GLSL_NO_SHADERS; + else if(strcmp(setting, "shadows") == 0) + return G_FILE_GLSL_NO_SHADOWS; + else if(strcmp(setting, "ramps") == 0) + return G_FILE_GLSL_NO_RAMPS; + else if(strcmp(setting, "nodes") == 0) + return G_FILE_GLSL_NO_NODES; + else if(strcmp(setting, "extra_textures") == 0) + return G_FILE_GLSL_NO_EXTRA_TEX; + else + return -1; +} + +static PyObject* gPySetGLSLMaterialSetting(PyObject*, + PyObject* args, + PyObject*) +{ + char *setting; + int enable, flag; + + if (PyArg_ParseTuple(args,"si",&setting,&enable)) + { + flag = getGLSLSettingFlag(setting); + + if(flag != -1) { + if (enable) + G.fileflags &= ~flag; + else + G.fileflags |= flag; + + /* display lists and GLSL materials need to be remade */ + if(gp_KetsjiEngine) { + KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes(); + KX_SceneList::iterator it; + + for(it=scenes->begin(); it!=scenes->end(); it++) + if((*it)->GetBucketManager()) + (*it)->GetBucketManager()->ReleaseDisplayLists(); + } + + GPU_materials_free(); + } + } + + Py_Return; +} + +static PyObject* gPyGetGLSLMaterialSetting(PyObject*, + PyObject* args, + PyObject*) +{ + char *setting; + int enabled = 0, flag; + + if (PyArg_ParseTuple(args,"s",&setting)) + { + flag = getGLSLSettingFlag(setting); + + if(flag != -1) + enabled = ((G.fileflags & flag) != 0); + } + + return PyInt_FromLong(enabled); +} + STR_String gPyGetWindowHeight__doc__="getWindowHeight doc"; STR_String gPyGetWindowWidth__doc__="getWindowWidth doc"; STR_String gPyEnableVisibility__doc__="enableVisibility doc"; @@ -703,11 +781,13 @@ static struct PyMethodDef rasterizer_methods[] = { {"getEyeSeparation", (PyCFunction) gPyGetEyeSeparation, METH_VARARGS, "get the eye separation for stereo mode"}, {"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the focal length for stereo mode"}, {"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the focal length for stereo mode"}, + {"setGLSLMaterialSetting",(PyCFunction) gPySetGLSLMaterialSetting, + METH_VARARGS, "set the state of a GLSL material setting"}, + {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting, + METH_VARARGS, "get the state of a GLSL material setting"}, { NULL, (PyCFunction) NULL, 0, NULL } }; - - // Initialization function for the module (*must* be called initGameLogic) static char GameLogic_module_documentation[] = @@ -720,11 +800,12 @@ static char Rasterizer_module_documentation[] = -PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook +PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack to get gravity hook { PyObject* m; PyObject* d; + gp_KetsjiEngine = engine; gp_KetsjiScene = scene; gUseVisibilityTemp=false; diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index f094a1ca575..388d073c6db 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -40,7 +40,7 @@ typedef enum { extern bool gUseVisibilityTemp; -PyObject* initGameLogic(class KX_Scene* ketsjiscene); +PyObject* initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene* ketsjiscene); PyObject* initGameKeys(); PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas); PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level); diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp index f085ff435dc..d651373869a 100644 --- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp +++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp @@ -78,7 +78,7 @@ UpdateChildCoordinates( if (parent) { - const BL_ArmatureObject *armature = (const BL_ArmatureObject*)(parent->GetSGClientObject()); + BL_ArmatureObject *armature = (BL_ArmatureObject*)(parent->GetSGClientObject()); if (armature) { MT_Matrix4x4 parent_matrix; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 1c37fcea77e..2ad0412f1bf 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -68,6 +68,7 @@ #include "SG_IObject.h" #include "SG_Tree.h" #include "DNA_group_types.h" +#include "DNA_scene_types.h" #include "BKE_anim.h" #include "KX_SG_NodeRelationships.h" @@ -116,7 +117,8 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, class SCA_IInputDevice* mousedevice, class NG_NetworkDeviceInterface *ndi, class SND_IAudioDevice* adi, - const STR_String& sceneName): + const STR_String& sceneName, + Scene *scene): PyObjectPlus(&KX_Scene::Type), m_keyboardmgr(NULL), m_mousemgr(NULL), @@ -126,7 +128,8 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_adi(adi), m_networkDeviceInterface(ndi), m_active_camera(NULL), - m_ueberExecutionPriority(0) + m_ueberExecutionPriority(0), + m_blenderScene(scene) { m_suspendedtime = 0.0; m_suspendeddelta = 0.0; @@ -453,7 +456,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal // this is the list of object that are send to the graphics pipeline m_objectlist->Add(newobj->AddRef()); - newobj->Bucketize(); + newobj->AddMeshUser(); // logic cannot be replicated, until the whole hierarchy is replicated. m_logicHierarchicalGameObjects.push_back(newobj); @@ -623,6 +626,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) if (blgroupobj == blenderobj) // this check is also in group_duplilist() continue; + gameobj = (KX_GameObject*)m_logicmgr->FindGameObjByBlendObj(blenderobj); if (gameobj == NULL) { @@ -630,6 +634,9 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) // Should not happen as dupli group are created automatically continue; } + + gameobj->SetBlenderGroupObject(blgroupobj); + if ((blenderobj->lay & group->layer)==0) { // object is not visible in the 3D view, will not be instantiated @@ -999,7 +1006,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) newobj->m_pDeformer = NULL; } - if (mesh->m_class == 1) + if (mesh->IsDeformed()) { // we must create a new deformer but which one? KX_GameObject* parentobj = newobj->GetParent(); @@ -1073,7 +1080,8 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) parentobj->Release(); } } - gameobj->Bucketize(); + + gameobj->AddMeshUser(); } @@ -1225,7 +1233,9 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi for (int m=0;mGetMesh(m))->SchedulePolygons(rasty->GetDrawingMode()); } - gameobj->MarkVisible(visible); + + gameobj->SetCulled(!visible); + gameobj->UpdateBuckets(); } } if (node->Left()) @@ -1242,7 +1252,8 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam // Shadow lamp layers if(layer && !(gameobj->GetLayer() & layer)) { - gameobj->MarkVisible(false); + gameobj->SetCulled(true); + gameobj->UpdateBuckets(); return; } @@ -1288,9 +1299,11 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam } // Visibility/ non-visibility are marked // elsewhere now. - gameobj->MarkVisible(); + gameobj->SetCulled(false); + gameobj->UpdateBuckets(); } else { - gameobj->MarkVisible(false); + gameobj->SetCulled(true); + gameobj->UpdateBuckets(); } } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index 1c56dd1ee55..5f7e1167e27 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -54,6 +54,7 @@ */ struct SM_MaterialProps; struct SM_ShapeProps; +struct Scene; class GEN_HashedPtr; class CListValue; @@ -277,12 +278,15 @@ protected: */ PyObject* m_attrlist; + struct Scene* m_blenderScene; + public: KX_Scene(class SCA_IInputDevice* keyboarddevice, class SCA_IInputDevice* mousedevice, class NG_NetworkDeviceInterface* ndi, class SND_IAudioDevice* adi, - const STR_String& scenename ); + const STR_String& scenename, + struct Scene* scene); virtual ~KX_Scene(); @@ -582,6 +586,10 @@ public: * was running and not suspended) and the "curtime" */ double getSuspendedDelta(); + /** + * Returns the Blender scene this was made from + */ + struct Scene *GetBlenderScene() { return m_blenderScene; } }; typedef std::vector KX_SceneList; diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 5cec65dff1c..25205714308 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -82,7 +82,7 @@ PyObject* KX_VertexProxy::_getattr(const STR_String& attr) { if (attr == "XYZ") - return PyObjectFrom(MT_Vector3(m_vertex->getLocalXYZ())); + return PyObjectFrom(MT_Vector3(m_vertex->getXYZ())); if (attr == "UV") return PyObjectFrom(MT_Point2(m_vertex->getUV1())); @@ -102,11 +102,11 @@ KX_VertexProxy::_getattr(const STR_String& attr) // pos if (attr == "x") - return PyFloat_FromDouble(m_vertex->getLocalXYZ()[0]); + return PyFloat_FromDouble(m_vertex->getXYZ()[0]); if (attr == "y") - return PyFloat_FromDouble(m_vertex->getLocalXYZ()[1]); + return PyFloat_FromDouble(m_vertex->getXYZ()[1]); if (attr == "z") - return PyFloat_FromDouble(m_vertex->getLocalXYZ()[2]); + return PyFloat_FromDouble(m_vertex->getXYZ()[2]); // Col if (attr == "r") @@ -184,7 +184,7 @@ int KX_VertexProxy::_setattr(const STR_String& attr, PyObject *pyvalue) { float val = PyFloat_AsDouble(pyvalue); // pos - MT_Point3 pos(m_vertex->getLocalXYZ()); + MT_Point3 pos(m_vertex->getXYZ()); if (attr == "x") { pos.x() = val; @@ -312,7 +312,7 @@ PyObject* KX_VertexProxy::PyGetXYZ(PyObject*, PyObject*, PyObject*) { - return PyObjectFrom(MT_Point3(m_vertex->getLocalXYZ())); + return PyObjectFrom(MT_Point3(m_vertex->getXYZ())); } PyObject* KX_VertexProxy::PySetXYZ(PyObject*, @@ -426,7 +426,7 @@ PyObject* KX_VertexProxy::PySetUV2(PyObject*, { if (PyVecTo(list, vec)) { - m_vertex->SetFlag((m_vertex->getFlag()|TV_2NDUV)); + m_vertex->SetFlag((m_vertex->getFlag()|RAS_TexVert::SECOND_UV)); m_vertex->SetUnit(unit); m_vertex->SetUV2(vec); m_mesh->SetMeshModified(true); diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index b4693a7a7db..5a0cadcbcfe 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -76,7 +76,7 @@ KX_VisibilityActuator::Update() KX_GameObject *obj = (KX_GameObject*) GetParent(); obj->SetVisible(m_visible); - obj->MarkVisible(); + obj->UpdateBuckets(); return true; } diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile index 995237adf2c..0b48ad8b8c3 100644 --- a/source/gameengine/Ketsji/Makefile +++ b/source/gameengine/Ketsji/Makefile @@ -64,13 +64,9 @@ CPPFLAGS += -I../../blender/blenlib CPPFLAGS += -I../../blender/include CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I../../blender/imbuf +CPPFLAGS += -I../../blender/gpu CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include -ifeq ($(WITH_BF_GLEXT),true) - CPPFLAGS += -DWITH_GLEXT -endif - - ########################### SOURCEDIR = source/gameengine/Ketsji diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index f6f744b199a..02e7aed82a5 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -32,16 +32,13 @@ incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common #sourc incs += ' #source/gameengine/Physics/BlOde #source/gameengine/Physics/Dummy' incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/include' incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork' -incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include' +incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include #source/blender/gpu' cflags = [] if env['OURPLATFORM'] == 'win32-vc': cflags.append('/GR') cflags.append('/Ox') -if env['WITH_BF_GLEXT'] == 1: - env['CPPFLAGS'].append('-DWITH_GLEXT') - incs += ' ' + env['BF_SOLID_INC'] incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_SDL_INC'] diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 2ec96c75a68..8fd89295b03 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -815,9 +815,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) { for (int i=0;iVertexCount();i++) { - const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[i], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + const float* vtx = poly->GetVertex(i)->getXYZ(); btPoint3 point(vtx[0],vtx[1],vtx[2]); m_vertexArray.push_back(point); numvalidpolys++; @@ -825,18 +823,15 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) } else { { - const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[2], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + const float* vtx = poly->GetVertex(2)->getXYZ(); btPoint3 vertex0(vtx[0],vtx[1],vtx[2]); - vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[1], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + + vtx = poly->GetVertex(1)->getXYZ(); btPoint3 vertex1(vtx[0],vtx[1],vtx[2]); - vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[0], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + + vtx = poly->GetVertex(0)->getXYZ(); btPoint3 vertex2(vtx[0],vtx[1],vtx[2]); + m_vertexArray.push_back(vertex0); m_vertexArray.push_back(vertex1); m_vertexArray.push_back(vertex2); @@ -845,18 +840,15 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) } if (poly->VertexCount() == 4) { - const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[3], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + const float* vtx = poly->GetVertex(3)->getXYZ(); btPoint3 vertex0(vtx[0],vtx[1],vtx[2]); - vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[2], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + + vtx = poly->GetVertex(2)->getXYZ(); btPoint3 vertex1(vtx[0],vtx[1],vtx[2]); - vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, - poly->GetVertexIndexBase().m_indexarray[0], - poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ(); + + vtx = poly->GetVertex(0)->getXYZ(); btPoint3 vertex2(vtx[0],vtx[1],vtx[2]); + m_vertexArray.push_back(vertex0); m_vertexArray.push_back(vertex1); m_vertexArray.push_back(vertex2); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 8a7f1062f53..a3fbb502c08 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -128,7 +128,8 @@ struct CcdConstructionInfo CcdConstructionInfo() - : m_gravity(0,0,0), + : m_localInertiaTensor(1.f, 1.f, 1.f), + m_gravity(0,0,0), m_scaling(1.f,1.f,1.f), m_mass(0.f), m_restitution(0.1f), diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index b65bc0f3ce8..af3d2810553 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -220,6 +220,13 @@ def setPhysicsTicRate(ticrate): @param ticrate: The new update frequency (in Hz). @type ticrate: float """ +def getAverageFrameRate(): + """ + Gets the estimated average framerate + + @return: The estimed average framerate in frames per second + @rtype: float + """ def expandPath(path): """ @@ -245,4 +252,4 @@ def getBlendFileList(path = "//"): @type path: string @return: A list of filenames, with no directory prefix @rtype: list - """ \ No newline at end of file + """ diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py index 3711ac63b3e..7afdcf07f2e 100644 --- a/source/gameengine/PyDoc/Rasterizer.py +++ b/source/gameengine/PyDoc/Rasterizer.py @@ -146,3 +146,20 @@ def getFocalLength(): @rtype: float """ + +def setGLSLMaterialSetting(setting, enable): + """ + Enables or disables a GLSL material setting. + + @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) + @type enable: boolean + """ + +def getGLSLMaterialSetting(setting, enable): + """ + Get the state of a GLSL material setting. + + @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) + @rtype: boolean + """ + diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile index e3b1f274ee5..917f70c7108 100644 --- a/source/gameengine/Rasterizer/Makefile +++ b/source/gameengine/Rasterizer/Makefile @@ -49,10 +49,6 @@ ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings endif -ifeq ($(WITH_BF_GLEXT),true) - CPPFLAGS += -DWITH_GLEXT -endif - ############### SOURCEDIR = source/gameengine/Rasterizer diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 82bdce44519..9fb21a3c17b 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -26,10 +26,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef WIN32 // don't show these anoying STL warnings #pragma warning (disable:4786) @@ -39,168 +35,243 @@ #include "RAS_MaterialBucket.h" #include "STR_HashedString.h" #include "RAS_MeshObject.h" -#define KX_NUM_MATERIALBUCKETS 100 #include "RAS_IRasterizer.h" #include "RAS_IRenderTools.h" #include "RAS_BucketManager.h" +#include #include -RAS_BucketManager::RAS_BucketManager() +/* sorting */ + +struct RAS_BucketManager::sortedmeshslot { +public: + MT_Scalar m_z; /* depth */ + RAS_MeshSlot *m_ms; /* mesh slot */ + RAS_MaterialBucket *m_bucket; /* buck mesh slot came from */ -} + sortedmeshslot() {} -RAS_BucketManager::~RAS_BucketManager() -{ - RAS_BucketManagerClearAll(); -} + void set(RAS_MeshSlot *ms, RAS_MaterialBucket *bucket, const MT_Vector3& pnorm) + { + // would be good to use the actual bounding box center instead + MT_Point3 pos(ms->m_OpenGLMatrix[12], ms->m_OpenGLMatrix[13], ms->m_OpenGLMatrix[14]); -/** - * struct alphamesh holds a mesh, (m_ms) it's depth, (m_z) and the bucket it came from (m_bucket.) - */ -struct RAS_BucketManager::alphamesh -{ -public: - MT_Scalar m_z; - RAS_MaterialBucket::T_MeshSlotList::iterator m_ms; - RAS_MaterialBucket *m_bucket; - alphamesh(MT_Scalar z, RAS_MaterialBucket::T_MeshSlotList::iterator &ms, RAS_MaterialBucket *bucket) : - m_z(z), - m_ms(ms), - m_bucket(bucket) - {} + m_z = MT_dot(pnorm, pos); + m_ms = ms; + m_bucket = bucket; + } }; struct RAS_BucketManager::backtofront { - bool operator()(const alphamesh &a, const alphamesh &b) + bool operator()(const sortedmeshslot &a, const sortedmeshslot &b) { - return a.m_z < b.m_z; + return (a.m_z < b.m_z) || (a.m_z == b.m_z && a.m_ms < b.m_ms); } }; + +struct RAS_BucketManager::fronttoback +{ + bool operator()(const sortedmeshslot &a, const sortedmeshslot &b) + { + return (a.m_z > b.m_z) || (a.m_z == b.m_z && a.m_ms > b.m_ms); + } +}; + +/* bucket manager */ + +RAS_BucketManager::RAS_BucketManager() +{ + +} + +RAS_BucketManager::~RAS_BucketManager() +{ + BucketList::iterator it; + + for (it = m_SolidBuckets.begin(); it != m_SolidBuckets.end(); it++) + delete (*it); + + for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++) + delete(*it); + m_SolidBuckets.clear(); + m_AlphaBuckets.clear(); +} + +void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector& slots, bool alpha) +{ + BucketList::iterator bit; + list::iterator mit; + size_t size = 0, i = 0; + + /* Camera's near plane equation: pnorm.dot(point) + pval, + * but we leave out pval since it's constant anyway */ + const MT_Vector3 pnorm(cameratrans.getBasis()[2]); + + for (bit = buckets.begin(); bit != buckets.end(); ++bit) + for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) + if (!mit->IsCulled()) + size++; + + slots.resize(size); + + for (bit = buckets.begin(); bit != buckets.end(); ++bit) + for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) + if (!mit->IsCulled()) + slots[i++].set(&*mit, *bit, pnorm); + + if(alpha) + sort(slots.begin(), slots.end(), backtofront()); + else + sort(slots.begin(), slots.end(), fronttoback()); +} + +//static int TOTASLOT = 0; +//static int TOTSLOT = 0; void RAS_BucketManager::RenderAlphaBuckets( const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools) { - BucketList::iterator bit; - std::multiset alphameshset; - RAS_MaterialBucket::T_MeshSlotList::iterator mit; + vector slots; + vector::iterator sit; + + // Having depth masks disabled/enabled gives different artifacts in + // case no sorting is done or is done inexact. For compatibility, we + // disable it. + rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED); + + OrderBuckets(cameratrans, m_AlphaBuckets, slots, true); - /* Camera's near plane equation: cam_norm.dot(point) + cam_origin */ - const MT_Vector3 cam_norm(cameratrans.getBasis()[2]); - const MT_Scalar cam_origin = cameratrans.getOrigin()[2]; - for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) - { - for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) - { - if ((*mit).m_bVisible) - { - MT_Point3 pos((*mit).m_OpenGLMatrix[12], (*mit).m_OpenGLMatrix[13], (*mit).m_OpenGLMatrix[14]); - alphameshset.insert(alphamesh(MT_dot(cam_norm, pos) + cam_origin, mit, *bit)); + for(sit=slots.begin(); sit!=slots.end(); ++sit) { + rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj); + + while(sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) { + sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms)); + //TOTASLOT++; + } + } + + rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED); +} + +void RAS_BucketManager::RenderSolidBuckets( + const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools) +{ + BucketList::iterator bit; + list::iterator mit; + + rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED); + + for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) { + for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) { + if (mit->IsCulled()) + continue; + + rendertools->SetClientObject(rasty, mit->m_clientObj); + + while ((*bit)->ActivateMaterial(cameratrans, rasty, rendertools)) { + (*bit)->RenderMeshSlot(cameratrans, rasty, rendertools, *mit); + //TOTSLOT++; } } } - // It shouldn't be strictly necessary to disable depth writes; but - // it is needed for compatibility. - rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED); +#if 0 + vector slots; + vector::iterator sit; - RAS_IRasterizer::DrawMode drawingmode; - std::multiset< alphamesh, backtofront>::iterator msit = alphameshset.begin(); - for (; msit != alphameshset.end(); ++msit) - { - rendertools->SetClientObject((*(*msit).m_ms).m_clientObj); - while ((*msit).m_bucket->ActivateMaterial(cameratrans, rasty, rendertools, drawingmode)) - (*msit).m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(*msit).m_ms, drawingmode); + OrderBuckets(cameratrans, m_SolidBuckets, slots, false); + + for(sit=slots.begin(); sit!=slots.end(); ++sit) { + rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj); + + while(sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) + sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms)); } - - rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED); +#endif } void RAS_BucketManager::Renderbuckets( const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools) { - BucketList::iterator bucket; - - rasty->EnableTextures(false); - rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED); - // beginning each frame, clear (texture/material) caching information rasty->ClearCachingInfo(); - RAS_MaterialBucket::StartFrame(); - - for (bucket = m_MaterialBuckets.begin(); bucket != m_MaterialBuckets.end(); ++bucket) - (*bucket)->Render(cameratrans,rasty,rendertools); + //TOTASLOT = 0; + //TOTSLOT = 0; + RenderSolidBuckets(cameratrans, rasty, rendertools); RenderAlphaBuckets(cameratrans, rasty, rendertools); - RAS_MaterialBucket::EndFrame(); + + //printf("total slots = %d = %d + %d\n", TOTSLOT + TOTASLOT, TOTSLOT, TOTASLOT); + + rendertools->SetClientObject(rasty, NULL); } RAS_MaterialBucket* RAS_BucketManager::FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated) { - bucketCreated = false; BucketList::iterator it; - for (it = m_MaterialBuckets.begin(); it != m_MaterialBuckets.end(); it++) - { + + bucketCreated = false; + + for (it = m_SolidBuckets.begin(); it != m_SolidBuckets.end(); it++) if (*(*it)->GetPolyMaterial() == *material) return *it; - } for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++) - { if (*(*it)->GetPolyMaterial() == *material) return *it; - } RAS_MaterialBucket *bucket = new RAS_MaterialBucket(material); bucketCreated = true; + if (bucket->IsAlpha()) m_AlphaBuckets.push_back(bucket); else - m_MaterialBuckets.push_back(bucket); + m_SolidBuckets.push_back(bucket); return bucket; } -void RAS_BucketManager::RAS_BucketManagerClearAll() +void RAS_BucketManager::OptimizeBuckets(MT_Scalar distance) { - BucketList::iterator it; - for (it = m_MaterialBuckets.begin(); it != m_MaterialBuckets.end(); it++) - { - delete (*it); - } - for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++) - { - delete(*it); - } + BucketList::iterator bit; - m_MaterialBuckets.clear(); - m_AlphaBuckets.clear(); + distance = 10.0; + + for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) + (*bit)->Optimize(distance); + for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) + (*bit)->Optimize(distance); } -void RAS_BucketManager::ReleaseDisplayLists() +void RAS_BucketManager::ReleaseDisplayLists(RAS_IPolyMaterial *mat) { BucketList::iterator bit; - RAS_MaterialBucket::T_MeshSlotList::iterator mit; + list::iterator mit; - for (bit = m_MaterialBuckets.begin(); bit != m_MaterialBuckets.end(); ++bit) { - for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) { - if(mit->m_DisplayList) { - mit->m_DisplayList->Release(); - mit->m_DisplayList = NULL; + for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) { + if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) { + for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) { + if(mit->m_DisplayList) { + mit->m_DisplayList->Release(); + mit->m_DisplayList = NULL; + } } } } for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) { - for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) { - if(mit->m_DisplayList) { - mit->m_DisplayList->Release(); - mit->m_DisplayList = NULL; + if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) { + for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) { + if(mit->m_DisplayList) { + mit->m_DisplayList->Release(); + mit->m_DisplayList = NULL; + } } } } diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index 08b67ed022f..74526f365a0 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -39,32 +39,33 @@ class RAS_BucketManager { - //GEN_Map m_MaterialBuckets; - typedef std::vector BucketList; - BucketList m_MaterialBuckets; + BucketList m_SolidBuckets; BucketList m_AlphaBuckets; - struct alphamesh; + struct sortedmeshslot; struct backtofront; + struct fronttoback; public: RAS_BucketManager(); virtual ~RAS_BucketManager(); - void RenderAlphaBuckets(const MT_Transform& cameratrans, - RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); void Renderbuckets(const MT_Transform & cameratrans, - RAS_IRasterizer* rasty, - class RAS_IRenderTools* rendertools); + RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated); + void OptimizeBuckets(MT_Scalar distance); - void ReleaseDisplayLists(); + void ReleaseDisplayLists(RAS_IPolyMaterial * material = NULL); private: - void RAS_BucketManagerClearAll(); + void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector& slots, bool alpha); + void RenderSolidBuckets(const MT_Transform& cameratrans, + RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); + void RenderAlphaBuckets(const MT_Transform& cameratrans, + RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools); }; #endif //__RAS_BUCKETMANAGER diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp index 4ee06d96603..fb3607f89f4 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp @@ -42,11 +42,8 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, int transp, bool alpha, bool zsort, - int lightlayer, - bool bIsTriangle, - void* clientobject=NULL) : - - m_texturename(texname), + int lightlayer) + : m_texturename(texname), m_materialname(matname), m_tile(tile), m_tilexrep(tilexrep), @@ -56,7 +53,6 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname, m_alpha(alpha), m_zsort(zsort), m_lightlayer(lightlayer), - m_bIsTriangle(bIsTriangle), m_polymatid(m_newpolymatid++), m_flag(0), m_multimode(0) @@ -72,15 +68,16 @@ bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const { if(m_flag &RAS_BLENDERMAT) { - return ( + bool test = ( this->m_multimode == lhs.m_multimode && this->m_flag == lhs.m_flag && this->m_drawingmode == lhs.m_drawingmode && this->m_transp == lhs.m_transp && - this->m_lightlayer == lhs.m_lightlayer && this->m_texturename.hash() == lhs.m_texturename.hash() && this->m_materialname.hash() == lhs.m_materialname.hash() ); + + return test; } else { @@ -92,8 +89,6 @@ bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const this->m_alpha == lhs.m_alpha && this->m_zsort == lhs.m_zsort && this->m_drawingmode == lhs.m_drawingmode && - this->m_bIsTriangle == lhs.m_bIsTriangle && - this->m_lightlayer == lhs.m_lightlayer && this->m_texturename.hash() == lhs.m_texturename.hash() && this->m_materialname.hash() == lhs.m_materialname.hash() ); @@ -123,11 +118,6 @@ bool RAS_IPolyMaterial::IsZSort() const return m_zsort; } -bool RAS_IPolyMaterial::UsesTriangles() const -{ - return m_bIsTriangle; -} - unsigned int RAS_IPolyMaterial::hash() const { return m_texturename.hash(); @@ -172,5 +162,10 @@ bool RAS_IPolyMaterial::UsesLighting(RAS_IRasterizer *rasty) const return dolights; } +bool RAS_IPolyMaterial::UsesObjectColor() const +{ + return !(m_flag & RAS_BLENDERGLSL); +} + unsigned int RAS_IPolyMaterial::m_newpolymatid = 0; diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h index 8fc53e6b038..218dd91cb30 100644 --- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h +++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h @@ -71,7 +71,6 @@ protected: bool m_alpha; bool m_zsort; int m_lightlayer; - bool m_bIsTriangle; unsigned int m_polymatid; static unsigned int m_newpolymatid; @@ -106,9 +105,7 @@ public: int transp, bool alpha, bool zsort, - int lightlayer, - bool bIsTriangle, - void* clientobject); + int lightlayer); virtual ~RAS_IPolyMaterial() {}; /** @@ -129,14 +126,13 @@ public: { return false; } - virtual void ActivateMeshSlot(const class KX_MeshSlot & ms, RAS_IRasterizer* rasty) const {} + virtual void ActivateMeshSlot(const class RAS_MeshSlot & ms, RAS_IRasterizer* rasty) const {} virtual bool Equals(const RAS_IPolyMaterial& lhs) const; bool Less(const RAS_IPolyMaterial& rhs) const; int GetLightLayer() const; bool IsAlpha() const; bool IsZSort() const; - bool UsesTriangles() const; unsigned int hash() const; int GetDrawingMode() const; const STR_String& GetMaterialName() const; @@ -145,6 +141,7 @@ public: const unsigned int GetFlag() const; virtual bool UsesLighting(RAS_IRasterizer *rasty) const; + virtual bool UsesObjectColor() const; /* * PreCalculate texture gen diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 9e03212283e..1d18d02a583 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -217,39 +217,18 @@ public: // Drawing Functions /** - * IndexPrimitives: Renders primitives. - * @param vertexarrays is an array of vertex arrays - * @param indexarrays is an array of index arrays - * @param mode determines the type of primitive stored in the vertex/index arrays - * @param useObjectColor will render the object using @param rgbacolor instead of - * vertex colors. - */ - virtual void IndexPrimitives( const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot)=0; - - virtual void IndexPrimitivesMulti( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot)=0; + * IndexPrimitives: Renders primitives from mesh slot. + */ + virtual void IndexPrimitives(class RAS_MeshSlot& ms)=0; + virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms)=0; /** * IndexPrimitives_3DText will render text into the polygons. * The text to be rendered is from @param rendertools client object's text property. */ - virtual void IndexPrimitives_3DText( const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, + virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms, class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor)=0; + class RAS_IRenderTools* rendertools)=0; virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0; /* This one should become our final version, methinks. */ @@ -269,9 +248,6 @@ public: /** */ virtual const MT_Point3& GetCameraPosition()=0; - /** - */ - virtual void LoadViewMatrix()=0; /** */ virtual void SetFog(float start, @@ -308,9 +284,6 @@ public: * @return the current drawing mode: KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED. */ virtual int GetDrawingMode()=0; - /** - */ - virtual void EnableTextures(bool enable)=0; /** * Sets face culling */ @@ -385,7 +358,9 @@ public: virtual void SetAttribNum(int num) = 0; virtual void SetTexCoord(TexCoGen coords, int unit) = 0; virtual void SetAttrib(TexCoGen coords, int unit) = 0; - virtual void GetViewMatrix(MT_Matrix4x4 &mat) const = 0; + + virtual const MT_Matrix4x4& GetViewMatrix() const = 0; + virtual const MT_Matrix4x4& GetViewInvMatrix() const = 0; virtual bool QueryLists(){return false;} virtual bool QueryArrays(){return false;} @@ -398,6 +373,7 @@ public: virtual void SetMotionBlurState(int newstate)=0; virtual void SetBlendingMode(int blendmode)=0; + virtual void SetFrontFace(bool ccw)=0; }; #endif //__RAS_IRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp b/source/gameengine/Rasterizer/RAS_IRenderTools.cpp index 2be9bb75ebf..555a3520bb4 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.cpp @@ -28,42 +28,22 @@ #include "RAS_IRenderTools.h" -#ifdef HAVE_CONFIG_H -#include -#endif - -void RAS_IRenderTools::SetViewMat(const MT_Transform& trans) -{ - trans.getValue(m_viewmat); -} - - - -void RAS_IRenderTools::SetClientObject(void* obj) +void RAS_IRenderTools::SetClientObject(RAS_IRasterizer* rasty, void *obj) { if (m_clientobject != obj) - { m_clientobject = obj; - m_modified = true; - } } - - void RAS_IRenderTools::SetAuxilaryClientInfo(void* inf) { m_auxilaryClientInfo = inf; } - - void RAS_IRenderTools::AddLight(struct RAS_LightObject* lightobject) { m_lights.push_back(lightobject); } - - void RAS_IRenderTools::RemoveLight(struct RAS_LightObject* lightobject) { std::vector::iterator lit = @@ -71,5 +51,5 @@ void RAS_IRenderTools::RemoveLight(struct RAS_LightObject* lightobject) if (!(lit==m_lights.end())) m_lights.erase(lit); - } + diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h index 54a663ba111..57f331e64cb 100644 --- a/source/gameengine/Rasterizer/RAS_IRenderTools.h +++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h @@ -44,12 +44,9 @@ class RAS_IRenderTools { protected: - float m_viewmat[16]; void* m_clientobject; void* m_auxilaryClientInfo; - bool m_modified; - std::vector m_lights; RAS_2DFilterManager m_filtermanager; @@ -68,8 +65,7 @@ public: RAS_IRenderTools( ) : - m_clientobject(NULL), - m_modified(true) + m_clientobject(NULL) { }; @@ -131,24 +127,21 @@ public: float v1[3], float v2[3], float v3[3], - float v4[3] + float v4[3], + int glattrib )=0; virtual - void - SetViewMat( - const MT_Transform& trans - ); - - virtual - int + void ProcessLighting( - int layer + int layer, + const MT_Transform& trans )=0; virtual void SetClientObject( + RAS_IRasterizer* rasty, void* obj ); @@ -190,24 +183,6 @@ public: virtual void Render2DFilters(RAS_ICanvas* canvas)=0; - - virtual - class RAS_IPolyMaterial* - CreateBlenderPolyMaterial( - const STR_String &texname, - bool ba, - const STR_String& matname, - int tile, - int tilexrep, - int tileyrep, - int mode, - bool transparant, - bool zsort, - int lightlayer, - bool bIsTriangle, - void* clientobject, - void* tface - )=0; }; #endif //__RAS_IRENDERTOOLS diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 0015b6a251f..e003cdc9368 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -28,10 +28,6 @@ #include "RAS_MaterialBucket.h" -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef WIN32 #pragma warning (disable:4786) #include @@ -44,79 +40,408 @@ #include "RAS_MeshObject.h" #include "RAS_Deformer.h" // __NLA +/* mesh slot */ + +RAS_MeshSlot::RAS_MeshSlot() +{ + m_clientObj = NULL; + m_pDeformer = NULL; + m_OpenGLMatrix = NULL; + m_mesh = NULL; + m_bucket = NULL; + m_bVisible = false; + m_bCulled = true; + m_bObjectColor = false; + m_RGBAcolor = MT_Vector4(0.0, 0.0, 0.0, 0.0); + m_DisplayList = NULL; + m_bDisplayList = true; + m_joinSlot = NULL; +} + +RAS_MeshSlot::~RAS_MeshSlot() +{ + vector::iterator it; + + Split(true); + + while(m_joinedSlots.size()) + m_joinedSlots.front()->Split(true); + for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + (*it)->m_users--; + if((*it)->m_users == 0) + delete *it; + } + + if (m_DisplayList) { + m_DisplayList->Release(); + m_DisplayList = NULL; + } +} -KX_VertexIndex::KX_VertexIndex(int size) +RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot) { - m_size = size; + vector::iterator it; + + m_clientObj = NULL; + m_pDeformer = NULL; + m_OpenGLMatrix = NULL; + m_mesh = slot.m_mesh; + m_bucket = slot.m_bucket; + m_bVisible = slot.m_bVisible; + m_bCulled = slot.m_bCulled; + m_bObjectColor = slot.m_bObjectColor; + m_RGBAcolor = slot.m_RGBAcolor; + m_DisplayList = NULL; + m_bDisplayList = slot.m_bDisplayList; + m_joinSlot = NULL; + m_currentArray = slot.m_currentArray; + m_displayArrays = slot.m_displayArrays; + m_joinedSlots = slot.m_joinedSlots; + + m_startarray = slot.m_startarray; + m_startvertex = slot.m_startvertex; + m_startindex = slot.m_startindex; + m_endarray = slot.m_endarray; + m_endvertex = slot.m_endvertex; + m_endindex = slot.m_endindex; + + for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + *it = new RAS_DisplayArray(**it); + (*it)->m_users = 1; + } } +void RAS_MeshSlot::init(RAS_MaterialBucket *bucket, int numverts) +{ + m_bucket = bucket; + + SetDisplayArray(numverts); + m_startarray = 0; + m_startvertex = 0; + m_startindex = 0; + m_endarray = 0; + m_endvertex = 0; + m_endindex = 0; +} -void KX_VertexIndex::SetIndex(short loc,unsigned int index) +void RAS_MeshSlot::begin(RAS_MeshSlot::iterator& it) { - m_indexarray[loc]=index; + int startvertex, endvertex; + int startindex, endindex; + + it.array = m_displayArrays[m_startarray]; + + startvertex = m_startvertex; + endvertex = (m_startarray == m_endarray)? m_endvertex: it.array->m_vertex.size(); + startindex = m_startindex; + endindex = (m_startarray == m_endarray)? m_endindex: it.array->m_index.size(); + + it.vertex = &it.array->m_vertex[0]; + it.index = &it.array->m_index[startindex]; + it.startvertex = startvertex; + it.endvertex = endvertex; + it.totindex = endindex-startindex; + it.arraynum = m_startarray; } -bool KX_MeshSlot::Less(const KX_MeshSlot& lhs) const +void RAS_MeshSlot::next(RAS_MeshSlot::iterator& it) { - bool result = ((m_mesh < lhs.m_mesh ) || - ((m_mesh == lhs.m_mesh)&&(m_OpenGLMatrix < lhs.m_OpenGLMatrix))); - - return result; + int startvertex, endvertex; + int startindex, endindex; + + if(it.arraynum == (size_t)m_endarray) { + it.array = NULL; + it.vertex = NULL; + it.index = NULL; + it.startvertex = 0; + it.endvertex = 0; + it.totindex = 0; + } + else { + it.arraynum++; + it.array = m_displayArrays[it.arraynum]; + + startindex = 0; + endindex = (it.arraynum == (size_t)m_endarray)? m_endindex: it.array->m_index.size(); + startvertex = 0; + endvertex = (it.arraynum == (size_t)m_endarray)? m_endvertex: it.array->m_vertex.size(); + + it.vertex = &it.array->m_vertex[0]; + it.index = &it.array->m_index[startindex]; + it.startvertex = startvertex; + it.endvertex = endvertex; + it.totindex = endindex-startindex; + } } -KX_MeshSlot::~KX_MeshSlot() +bool RAS_MeshSlot::end(RAS_MeshSlot::iterator& it) { - if (m_DisplayList) - m_DisplayList->Release(); + return (it.array == NULL); } +RAS_DisplayArray *RAS_MeshSlot::CurrentDisplayArray() +{ + return m_currentArray; +} -RAS_MaterialBucket::RAS_MaterialBucket(RAS_IPolyMaterial* mat) - :m_bModified(true) +void RAS_MeshSlot::SetDisplayArray(int numverts) { - m_material = mat; + vector::iterator it; + RAS_DisplayArray *darray = NULL; + + for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + darray = *it; + + if(darray->m_type == numverts) { + if(darray->m_index.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_INDEX) + darray = NULL; + else if(darray->m_vertex.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_VERTEX) + darray = NULL; + else + break; + } + else + darray = NULL; + } + + if(!darray) { + darray = new RAS_DisplayArray(); + darray->m_users = 1; + + if(numverts == 2) darray->m_type = RAS_DisplayArray::LINE; + else if(numverts == 3) darray->m_type = RAS_DisplayArray::TRIANGLE; + else darray->m_type = RAS_DisplayArray::QUAD; + + m_displayArrays.push_back(darray); + + if(numverts == 2) + darray->m_type = RAS_DisplayArray::LINE; + else if(numverts == 3) + darray->m_type = RAS_DisplayArray::TRIANGLE; + else if(numverts == 4) + darray->m_type = RAS_DisplayArray::QUAD; + + m_endarray = m_displayArrays.size()-1; + m_endvertex = 0; + m_endindex = 0; + } + + m_currentArray = darray; } +void RAS_MeshSlot::AddPolygon(int numverts) +{ + SetDisplayArray(numverts); +} +int RAS_MeshSlot::AddVertex(const RAS_TexVert& tv) +{ + RAS_DisplayArray *darray; + int offset; + + darray = m_currentArray; + darray->m_vertex.push_back(tv); + offset = darray->m_vertex.size()-1; -RAS_IPolyMaterial* RAS_MaterialBucket::GetPolyMaterial() const -{ - return m_material; + if(darray == m_displayArrays[m_endarray]) + m_endvertex++; + + return offset; } +void RAS_MeshSlot::AddPolygonVertex(int offset) +{ + RAS_DisplayArray *darray; + + darray = m_currentArray; + darray->m_index.push_back(offset); + + if(darray == m_displayArrays[m_endarray]) + m_endindex++; +} +bool RAS_MeshSlot::Equals(RAS_MeshSlot *target) +{ + if(!m_OpenGLMatrix || !target->m_OpenGLMatrix) + return false; + if(m_pDeformer || target->m_pDeformer) + return false; + if(m_bVisible != target->m_bVisible) + return false; + if(m_bObjectColor != target->m_bObjectColor) + return false; + if(m_bObjectColor && !(m_RGBAcolor == target->m_RGBAcolor)) + return false; -void RAS_MaterialBucket::SetMeshSlot(KX_MeshSlot& ms) + return true; +} + +bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance) { - m_meshSlots.insert(ms); + vector::iterator it; + iterator mit; + size_t i; + + // verify if we can join + if(m_joinSlot || m_joinedSlots.size() || target->m_joinSlot) + return false; + + if(!Equals(target)) + return false; + + MT_Vector3 co(&m_OpenGLMatrix[12]); + MT_Vector3 targetco(&target->m_OpenGLMatrix[12]); + + if((co - targetco).length() > distance) + return false; + + MT_Matrix4x4 mat(m_OpenGLMatrix); + MT_Matrix4x4 targetmat(target->m_OpenGLMatrix); + targetmat.invert(); + + MT_Matrix4x4 transform = targetmat*mat; + + // m_mesh, clientobj + m_joinSlot = target; + m_joinInvTransform = transform; + m_joinInvTransform.invert(); + target->m_joinedSlots.push_back(this); + + MT_Matrix4x4 ntransform = m_joinInvTransform.transposed(); + ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f; + + for(begin(mit); !end(mit); next(mit)) + for(i=mit.startvertex; im_displayArrays.push_back(*it); + target->m_endarray++; + target->m_endvertex = target->m_displayArrays.back()->m_vertex.size(); + target->m_endindex = target->m_displayArrays.back()->m_index.size(); + } + + if (m_DisplayList) { + m_DisplayList->Release(); + m_DisplayList = NULL; + } + if (target->m_DisplayList) { + target->m_DisplayList->Release(); + target->m_DisplayList = NULL; + } + + return true; +#if 0 + return false; +#endif } +bool RAS_MeshSlot::Split(bool force) +{ + list::iterator jit; + RAS_MeshSlot *target = m_joinSlot; + vector::iterator it, jt; + iterator mit; + size_t i, found0 = 0, found1 = 0; + + if(target && (force || !Equals(target))) { + m_joinSlot = NULL; + + for(jit=target->m_joinedSlots.begin(); jit!=target->m_joinedSlots.end(); jit++) { + if(*jit == this) { + target->m_joinedSlots.erase(jit); + found0 = 1; + break; + } + } + + if(!found0) + abort(); + + for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { + found1 = 0; + for(jt=target->m_displayArrays.begin(); jt!=target->m_displayArrays.end(); jt++) { + if(*jt == *it) { + target->m_displayArrays.erase(jt); + target->m_endarray--; + found1 = 1; + break; + } + } + + if(!found1) + abort(); + } + + if(target->m_displayArrays.size()) { + target->m_endvertex = target->m_displayArrays.back()->m_vertex.size(); + target->m_endindex = target->m_displayArrays.back()->m_index.size(); + } + else { + target->m_endvertex = 0; + target->m_endindex = 0; + } + + MT_Matrix4x4 ntransform = m_joinInvTransform.inverse().transposed(); + ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f; + for(begin(mit); !end(mit); next(mit)) + for(i=mit.startvertex; im_DisplayList) { + target->m_DisplayList->Release(); + target->m_DisplayList = NULL; + } + + return true; + } -void RAS_MaterialBucket::RemoveMeshSlot(KX_MeshSlot& ms) + return false; +} + +bool RAS_MeshSlot::IsCulled() { - T_MeshSlotList::iterator it = m_meshSlots.find(ms); + list::iterator it; - if (!(it == m_meshSlots.end())) - m_meshSlots.erase(it); - + if(m_joinSlot) + return true; + if(!m_bCulled) + return false; + + for(it=m_joinedSlots.begin(); it!=m_joinedSlots.end(); it++) + if(!(*it)->m_bCulled) + return false; + + return true; } +/* material bucket sorting */ + +struct RAS_MaterialBucket::less +{ + bool operator()(const RAS_MaterialBucket* x, const RAS_MaterialBucket* y) const + { + return *x->GetPolyMaterial() < *y->GetPolyMaterial(); + } +}; +/* material bucket */ -void RAS_MaterialBucket::MarkVisibleMeshSlot(KX_MeshSlot& ms, - bool visible, - bool color, - const MT_Vector4& rgbavec) +RAS_MaterialBucket::RAS_MaterialBucket(RAS_IPolyMaterial* mat) +{ + m_material = mat; +} + +RAS_MaterialBucket::~RAS_MaterialBucket() { - T_MeshSlotList::iterator it = m_meshSlots.find(ms); - - assert (!(it == m_meshSlots.end())); - (*it).m_bVisible = visible; - (*it).m_bObjectColor = color; - (*it).m_RGBAcolor= rgbavec; +} + +RAS_IPolyMaterial* RAS_MaterialBucket::GetPolyMaterial() const +{ + return m_material; } bool RAS_MaterialBucket::IsAlpha() const @@ -129,162 +454,129 @@ bool RAS_MaterialBucket::IsZSort() const return (m_material->IsZSort()); } - - -void RAS_MaterialBucket::StartFrame() +RAS_MeshSlot* RAS_MaterialBucket::AddMesh(int numverts) { -} + RAS_MeshSlot *ms; + m_meshSlots.push_back(RAS_MeshSlot()); + + ms = &m_meshSlots.back(); + ms->init(this, numverts); + return ms; +} -void RAS_MaterialBucket::EndFrame() +RAS_MeshSlot* RAS_MaterialBucket::CopyMesh(RAS_MeshSlot *ms) { + m_meshSlots.push_back(RAS_MeshSlot(*ms)); + + return &m_meshSlots.back(); } -unsigned int RAS_MaterialBucket::NumMeshSlots() +void RAS_MaterialBucket::RemoveMesh(RAS_MeshSlot* ms) { - return m_meshSlots.size(); + list::iterator it; + + for(it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) { + if(&*it == ms) { + m_meshSlots.erase(it); + return; + } + } } -RAS_MaterialBucket::T_MeshSlotList::iterator RAS_MaterialBucket::msBegin() +list::iterator RAS_MaterialBucket::msBegin() { return m_meshSlots.begin(); } -RAS_MaterialBucket::T_MeshSlotList::iterator RAS_MaterialBucket::msEnd() +list::iterator RAS_MaterialBucket::msEnd() { return m_meshSlots.end(); } bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools *rendertools, RAS_IRasterizer::DrawMode &drawmode) + RAS_IRenderTools *rendertools) { - rendertools->SetViewMat(cameratrans); - if (!rasty->SetMaterial(*m_material)) return false; if (m_material->UsesLighting(rasty)) - rendertools->ProcessLighting(RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER/*m_material->GetLightLayer()*/); - else - rendertools->ProcessLighting(-1); - - if(rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID) - drawmode = RAS_IRasterizer::KX_MODE_LINES; - else if(m_material->UsesTriangles()) - drawmode = RAS_IRasterizer::KX_MODE_TRIANGLES; + rendertools->ProcessLighting(RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER, cameratrans); else - drawmode = RAS_IRasterizer::KX_MODE_QUADS; + rendertools->ProcessLighting(-1, cameratrans); return true; } void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, RAS_IRasterizer::DrawMode drawmode) + RAS_IRenderTools* rendertools, RAS_MeshSlot &ms) { - if (!ms.m_bVisible) - return; - m_material->ActivateMeshSlot(ms, rasty); - /* __NLA Do the deformation */ if (ms.m_pDeformer) { ms.m_pDeformer->Apply(m_material); // KX_ReInstanceShapeFromMesh(ms.m_mesh); // Recompute the physics mesh. (Can't call KX_* from RAS_) } - /* End __NLA */ - if (rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) - ms.m_mesh->SortPolygons(cameratrans*MT_Transform(ms.m_OpenGLMatrix)); + if(IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) + ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix)); rendertools->PushMatrix(); rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode()); if(rasty->QueryLists()) - { if(ms.m_DisplayList) ms.m_DisplayList->SetModified(ms.m_mesh->MeshModified()); - } // verify if we can use display list, not for deformed object, and // also don't create a new display list when drawing shadow buffers, - // then it won't have texture coordinates for actual drawing - KX_ListSlot **displaylist; + // then it won't have texture coordinates for actual drawing. also + // for zsort we can't make a display list, since the polygon order + // changes all the time. if(ms.m_pDeformer) - displaylist = 0; + ms.m_bDisplayList = false; else if(!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW) - displaylist = 0; + ms.m_bDisplayList = false; + else if (IsZSort()) + ms.m_bDisplayList = false; + else if(m_material->UsesObjectColor() && ms.m_bObjectColor) + ms.m_bDisplayList = false; else - displaylist = &ms.m_DisplayList; + ms.m_bDisplayList = true; - // Use the text-specific IndexPrimitives for text faces + // for text drawing using faces if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) - { - rasty->IndexPrimitives_3DText( - ms.m_mesh->GetVertexCache(m_material), - ms.m_mesh->GetIndexCache(m_material), - drawmode, - m_material, - rendertools, // needed for textprinting on polys - ms.m_bObjectColor, - ms.m_RGBAcolor); - } - - // for using glMultiTexCoord + rasty->IndexPrimitives_3DText(ms, m_material, rendertools); + // for multitexturing else if((m_material->GetFlag() & RAS_MULTITEX)) - { - rasty->IndexPrimitivesMulti( - ms.m_mesh->GetVertexCache(m_material), - ms.m_mesh->GetIndexCache(m_material), - drawmode, - ms.m_bObjectColor, - ms.m_RGBAcolor, - displaylist); - } - - // Use the normal IndexPrimitives + rasty->IndexPrimitivesMulti(ms); + // use normal IndexPrimitives else - { - rasty->IndexPrimitives( - ms.m_mesh->GetVertexCache(m_material), - ms.m_mesh->GetIndexCache(m_material), - drawmode, - ms.m_bObjectColor, - ms.m_RGBAcolor, - displaylist); - } + rasty->IndexPrimitives(ms); - if(rasty->QueryLists()) { + if(rasty->QueryLists()) if(ms.m_DisplayList) ms.m_mesh->SetMeshModified(false); - } rendertools->PopMatrix(); } -void RAS_MaterialBucket::Render(const MT_Transform& cameratrans, - RAS_IRasterizer* rasty, - RAS_IRenderTools* rendertools) +void RAS_MaterialBucket::Optimize(MT_Scalar distance) { - if (m_meshSlots.begin()== m_meshSlots.end()) - return; - - //rendertools->SetViewMat(cameratrans); - - //rasty->SetMaterial(*m_material); + /* TODO: still have to check before this works correct: + * - lightlayer, frontface, text, billboard + * - make it work with physics */ - RAS_IRasterizer::DrawMode drawmode; - for (T_MeshSlotList::const_iterator it = m_meshSlots.begin(); - ! (it == m_meshSlots.end()); ++it) - { - rendertools->SetClientObject((*it).m_clientObj); - while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode)) { - RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode); - } - } - // to reset the eventual GL_CW mode - rendertools->SetClientObject(NULL); +#if 0 + list::iterator it; + list::iterator jt; + + // greed joining on all following buckets + for(it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) + for(jt=it, jt++; jt!=m_meshSlots.end(); jt++) + jt->Join(&*it, distance); +#endif } - diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h index 4eef889c533..475f01d549a 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h @@ -36,30 +36,15 @@ #include "MT_Transform.h" #include "RAS_IPolygonMaterial.h" #include "RAS_IRasterizer.h" -#include "RAS_Deformer.h" // __NLA +#include "RAS_Deformer.h" + #include -#include #include +#include using namespace std; -/** - * KX_VertexIndex - */ -struct KX_VertexIndex { -public: - KX_VertexIndex(int size); - void SetIndex(short loc,unsigned int index); - - // The vertex array - short m_vtxarray; - // An index into the vertex array for up to 4 verticies - unsigned short m_indexarray[4]; - short m_size; -}; +/* Display List Slot */ -/** - * KX_ListSlot. - */ class KX_ListSlot { protected: @@ -80,91 +65,149 @@ public: virtual void SetModified(bool mod)=0; }; -/** - * KX_MeshSlot. - */ -class KX_MeshSlot +class RAS_DisplayArray; +class RAS_MeshSlot; +class RAS_MeshMaterial; +class RAS_MaterialBucket; + +/* An array with data used for OpenGL drawing */ + +class RAS_DisplayArray { public: - void* m_clientObj; - RAS_Deformer* m_pDeformer; // __NLA - double* m_OpenGLMatrix; - class RAS_MeshObject* m_mesh; - mutable bool m_bVisible; // for visibility - mutable bool m_bObjectColor; - mutable MT_Vector4 m_RGBAcolor; - mutable KX_ListSlot* m_DisplayList; // for lists - KX_MeshSlot() : - m_pDeformer(NULL), - m_bVisible(true), - m_DisplayList(0) - { - } - ~KX_MeshSlot(); - bool Less(const KX_MeshSlot& lhs) const; + vector m_vertex; + vector m_index; + enum { LINE = 2, TRIANGLE = 3, QUAD = 4 } m_type; + //RAS_MeshSlot *m_origSlot; + int m_users; + + enum { BUCKET_MAX_INDEX = 65535 }; + enum { BUCKET_MAX_VERTEX = 65535 }; }; +/* Entry of a RAS_MeshObject into RAS_MaterialBucket */ -inline bool operator <( const KX_MeshSlot& rhs,const KX_MeshSlot& lhs) +class RAS_MeshSlot { - return ( rhs.Less(lhs)); -} +private: + // indices into display arrays + int m_startarray; + int m_endarray; + int m_startindex; + int m_endindex; + int m_startvertex; + int m_endvertex; + vector m_displayArrays; + + // for construction only + RAS_DisplayArray* m_currentArray; + +public: + // for rendering + RAS_MaterialBucket* m_bucket; + RAS_MeshObject* m_mesh; + void* m_clientObj; + RAS_Deformer* m_pDeformer; + double* m_OpenGLMatrix; + // visibility + bool m_bVisible; + bool m_bCulled; + // object color + bool m_bObjectColor; + MT_Vector4 m_RGBAcolor; + // display lists + KX_ListSlot* m_DisplayList; + bool m_bDisplayList; + // joined mesh slots + RAS_MeshSlot* m_joinSlot; + MT_Matrix4x4 m_joinInvTransform; + list m_joinedSlots; + + RAS_MeshSlot(); + RAS_MeshSlot(const RAS_MeshSlot& slot); + virtual ~RAS_MeshSlot(); + + void init(RAS_MaterialBucket *bucket, int numverts); + + struct iterator { + RAS_DisplayArray *array; + RAS_TexVert *vertex; + unsigned short *index; + size_t startvertex; + size_t endvertex; + size_t totindex; + size_t arraynum; + }; + + void begin(iterator& it); + void next(iterator& it); + bool end(iterator& it); + + /* used during construction */ + void SetDisplayArray(int numverts); + RAS_DisplayArray *CurrentDisplayArray(); + + void AddPolygon(int numverts); + int AddVertex(const RAS_TexVert& tv); + void AddPolygonVertex(int offset); + + /* optimization */ + bool Split(bool force=false); + bool Join(RAS_MeshSlot *target, MT_Scalar distance); + bool Equals(RAS_MeshSlot *target); + bool IsCulled(); +}; + +/* Used by RAS_MeshObject, to point to it's slots in a bucket */ + +class RAS_MeshMaterial +{ +public: + RAS_MeshSlot *m_baseslot; + class RAS_MaterialBucket *m_bucket; + + GEN_Map m_slots; +}; + +/* Contains a list of display arrays with the same material, + * and a mesh slot for each mesh that uses display arrays in + * this bucket */ -/** - * Contains a list of meshs with the same material properties. - */ class RAS_MaterialBucket { public: - typedef std::set T_MeshSlotList; - RAS_MaterialBucket(RAS_IPolyMaterial* mat); - virtual ~RAS_MaterialBucket() {} - - void Render(const MT_Transform& cameratrans, - class RAS_IRasterizer* rasty, - class RAS_IRenderTools* rendertools); + virtual ~RAS_MaterialBucket(); + /* Bucket Sorting */ + struct less; + typedef set Set; + + /* Material Properties */ RAS_IPolyMaterial* GetPolyMaterial() const; - bool IsAlpha() const; - bool IsZSort() const; + bool IsAlpha() const; + bool IsZSort() const; - static void StartFrame(); - static void EndFrame(); - - void SetMeshSlot(KX_MeshSlot& ms); - void RemoveMeshSlot(KX_MeshSlot& ms); - void MarkVisibleMeshSlot(KX_MeshSlot& ms, - bool visible, - bool color, - const MT_Vector4& rgbavec); - - void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, RAS_IRasterizer::DrawMode drawmode); + /* Rendering */ bool ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, - RAS_IRenderTools *rendertools, RAS_IRasterizer::DrawMode& drawmode); - - unsigned int NumMeshSlots(); - T_MeshSlotList::iterator msBegin(); - T_MeshSlotList::iterator msEnd(); - - struct less - { - bool operator()(const RAS_MaterialBucket* x, const RAS_MaterialBucket* y) const - { - return *x->GetPolyMaterial() < *y->GetPolyMaterial(); - } - }; + RAS_IRenderTools *rendertools); + void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty, + RAS_IRenderTools* rendertools, RAS_MeshSlot &ms); - typedef set Set; + /* Mesh Slot Access */ + list::iterator msBegin(); + list::iterator msEnd(); + + class RAS_MeshSlot* AddMesh(int numverts); + class RAS_MeshSlot* CopyMesh(class RAS_MeshSlot *ms); + void RemoveMesh(class RAS_MeshSlot* ms); + void Optimize(MT_Scalar distance); + private: - - T_MeshSlotList m_meshSlots; - bool m_bModified; + list m_meshSlots; RAS_IPolyMaterial* m_material; - double* m_pOGLMatrix; }; -#endif //__KX_BUCKET +#endif //__RAS_MATERIAL_BUCKET diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index a4f7f3f01dd..a907994bf57 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -26,10 +26,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" #include "MT_MinMax.h" @@ -37,62 +33,84 @@ #include +/* polygon sorting */ -STR_String RAS_MeshObject::s_emptyname = ""; +struct RAS_MeshObject::polygonSlot +{ + float m_z; + int m_index[4]; + + polygonSlot() {} + /* pnorm is the normal from the plane equation that the distance from is + * used to sort again. */ + void get(const RAS_TexVert *vertexarray, const unsigned short *indexarray, + int offset, int nvert, const MT_Vector3& pnorm) + { + MT_Vector3 center(0, 0, 0); + int i; + for(i=0; i::iterator itv = m_VertexArrayCache1.begin(); - !(itv == m_VertexArrayCache1.end());++itv) - { - delete (*itv); + /* note we don't divide center by the number of vertices, since all + * polygons have the same number of vertices, and that we leave out + * the 4-th component of the plane equation since it is constant. */ + m_z = MT_dot(pnorm, center); } - for (vector::iterator iti = m_IndexArrayCache1.begin(); - !(iti == m_IndexArrayCache1.end());++iti) + void set(unsigned short *indexarray, int offset, int nvert) { - delete (*iti); + int i; + + for(i=0; i b.m_z; + } +}; +/* mesh object */ +STR_String RAS_MeshObject::s_emptyname = ""; RAS_MeshObject::RAS_MeshObject(Mesh* mesh, int lightlayer) - : m_bModified(true), - m_lightlayer(lightlayer), - m_zsort(false), - m_MeshMod(true), + : m_lightlayer(lightlayer), + m_bModified(true), + m_bMeshModified(true), m_mesh(mesh), - m_class(0) + m_bDeformed(false) { } - -bool RAS_MeshObject::MeshModified() -{ - return m_MeshMod; -} - - RAS_MeshObject::~RAS_MeshObject() { - for (vector::iterator it=m_Polygons.begin();!(it==m_Polygons.end());it++) - { - delete (*it); - } + vector::iterator it; - ClearArrayData(); + for(it=m_Polygons.begin(); it!=m_Polygons.end(); it++) + delete (*it); } - +bool RAS_MeshObject::MeshModified() +{ + return m_bMeshModified; +} unsigned int RAS_MeshObject::GetLightLayer() { @@ -108,18 +126,21 @@ int RAS_MeshObject::NumMaterials() const STR_String& RAS_MeshObject::GetMaterialName(unsigned int matid) { - RAS_MaterialBucket* bucket = GetMaterialBucket(matid); + RAS_MeshMaterial* mmat = GetMeshMaterial(matid); + + if(mmat) + return mmat->m_bucket->GetPolyMaterial()->GetMaterialName(); - return bucket?bucket->GetPolyMaterial()->GetMaterialName():s_emptyname; + return s_emptyname; } -RAS_MaterialBucket* RAS_MeshObject::GetMaterialBucket(unsigned int matid) +RAS_MeshMaterial* RAS_MeshObject::GetMeshMaterial(unsigned int matid) { if (m_materials.size() > 0 && (matid < m_materials.size())) { - RAS_MaterialBucket::Set::const_iterator it = m_materials.begin(); + list::iterator it = m_materials.begin(); while (matid--) ++it; - return *it; + return &*it; } return NULL; @@ -141,14 +162,17 @@ RAS_Polygon* RAS_MeshObject::GetPolygon(int num) const -RAS_MaterialBucket::Set::iterator RAS_MeshObject::GetFirstMaterial() + + list::iterator GetFirstMaterial(); + list::iterator GetLastMaterial(); +list::iterator RAS_MeshObject::GetFirstMaterial() { return m_materials.begin(); } -RAS_MaterialBucket::Set::iterator RAS_MeshObject::GetLastMaterial() +list::iterator RAS_MeshObject::GetLastMaterial() { return m_materials.end(); } @@ -171,377 +195,238 @@ const STR_String& RAS_MeshObject::GetName() const STR_String& RAS_MeshObject::GetTextureName(unsigned int matid) { - RAS_MaterialBucket* bucket = GetMaterialBucket(matid); + RAS_MeshMaterial* mmat = GetMeshMaterial(matid); - return bucket?bucket->GetPolyMaterial()->GetTextureName():s_emptyname; + if(mmat) + return mmat->m_bucket->GetPolyMaterial()->GetTextureName(); + + return s_emptyname; } +RAS_MeshMaterial *RAS_MeshObject::GetMeshMaterial(RAS_IPolyMaterial *mat) +{ + list::iterator mit; + /* find a mesh material */ + for(mit = m_materials.begin(); mit != m_materials.end(); mit++) + if(mit->m_bucket->GetPolyMaterial() == mat) + return &*mit; -void RAS_MeshObject::AddPolygon(RAS_Polygon* poly) -{ - m_Polygons.push_back(poly); + return NULL; } +RAS_Polygon* RAS_MeshObject::AddPolygon(RAS_MaterialBucket *bucket, int numverts) +{ + RAS_MeshMaterial *mmat; + RAS_Polygon *poly; + RAS_MeshSlot *slot; + /* find a mesh material */ + mmat = GetMeshMaterial(bucket->GetPolyMaterial()); + + /* none found, create a new one */ + if(!mmat) { + RAS_MeshMaterial meshmat; + meshmat.m_bucket = bucket; + meshmat.m_baseslot = meshmat.m_bucket->AddMesh(numverts); + m_materials.push_back(meshmat); + mmat = &m_materials.back(); + } + + /* add it to the bucket, this also adds new display arrays */ + slot = mmat->m_baseslot; + slot->AddPolygon(numverts); + + /* create a new polygon */ + RAS_DisplayArray *darray = slot->CurrentDisplayArray(); + poly = new RAS_Polygon(bucket, darray, numverts); + m_Polygons.push_back(poly); + + return poly; +} void RAS_MeshObject::DebugColor(unsigned int abgr) { -/* - int numpolys = NumPolygons(); - for (int i=0;iVertexCount();v++) - { - RAS_TexVert* vtx = poly->GetVertex(v); - vtx->setDebugRGBA(abgr); - } + RAS_TexVert* vtx = poly->GetVertex(v)->setDebugRGBA(abgr); } */ - m_debugcolor = abgr; + /* m_debugcolor = abgr; */ } void RAS_MeshObject::SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba) { - const vecVertexArray & vertexvec = GetVertexCache(mat); - - for (vector::const_iterator it = vertexvec.begin(); it != vertexvec.end(); ++it) - { - KX_VertexArray::iterator vit; - for (vit=(*it)->begin(); vit != (*it)->end(); vit++) - { - vit->SetRGBA(rgba); - } - } -} - -void RAS_MeshObject::SchedulePoly(const KX_VertexIndex& idx, - int numverts, - RAS_IPolyMaterial* mat) -{ - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); - - ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[0]); - ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[1]); - ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[2]); - - if (!mat->UsesTriangles()) - ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[3]); -} + RAS_MeshMaterial *mmat = GetMeshMaterial(mat); + RAS_MeshSlot *slot = mmat->m_baseslot; + RAS_MeshSlot::iterator it; + size_t i; + + for(slot->begin(it); !slot->end(it); slot->next(it)) + for(i=it.startvertex; iGetMaterial()->GetPolyMaterial()); + slot = mmat->m_baseslot; + darray = slot->CurrentDisplayArray(); + if(!flat) { + /* find vertices shared between faces, with the restriction + * that they exist in the same display array, and have the + * same uv coordinate etc */ + vector& sharedmap = m_sharedvertex_map[origindex]; + vector::iterator it; -void RAS_MeshObject::ScheduleWireframePoly(const KX_VertexIndex& idx, - int numverts, - int edgecode, - RAS_IPolyMaterial* mat) -{ - //int indexpos = m_IndexArrayCount[idx.m_vtxarray]; - int edgetrace = 1<<(numverts-1); - bool drawedge = (edgecode & edgetrace)!=0; - edgetrace = 1; - int prevvert = idx.m_indexarray[numverts-1]; - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); - - for (int v = 0; v < numverts; v++) - { - unsigned int curvert = idx.m_indexarray[v]; - if (drawedge) + for(it = sharedmap.begin(); it != sharedmap.end(); it++) { - ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(prevvert); - ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(curvert); + if(it->m_darray != darray) + continue; + if(!it->m_darray->m_vertex[it->m_offset].closeTo(&texvert)) + continue; + + /* found one, add it and we're done */ + if(poly->IsVisible()) + slot->AddPolygonVertex(it->m_offset); + poly->SetVertexOffset(i, it->m_offset); + return; } - prevvert = curvert; - drawedge = (edgecode & edgetrace)!=0; - edgetrace*=2; } - //m_IndexArrayCount[idx.m_vtxarray] = indexpos; -} -int RAS_MeshObject::FindOrAddVertex(int vtxarray, - const MT_Point3& xyz, - const MT_Point2& uv, - const MT_Point2& uv2, - const MT_Vector4& tangent, - const unsigned int rgbacolor, - const MT_Vector3& normal, - bool flat, - RAS_IPolyMaterial* mat, - int origindex) -{ - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); - - int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray]; - RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, flat? TV_CALCFACENORMAL: 0,origindex); + /* no shared vertex found, add a new one */ + offset = slot->AddVertex(texvert); + if(poly->IsVisible()) + slot->AddPolygonVertex(offset); + poly->SetVertexOffset(i, offset); -#define KX_FIND_SHARED_VERTICES -#ifdef KX_FIND_SHARED_VERTICES if(!flat) { - for (std::vector::iterator it = m_xyz_index_to_vertex_index_mapping[origindex].begin(); - it != m_xyz_index_to_vertex_index_mapping[origindex].end(); - it++) - { - if ((*it).m_arrayindex1 == ao->m_index1 && - (*it).m_array == vtxarray && - *(*it).m_matid == *mat && - (*ao->m_VertexArrayCache1[vtxarray])[(*it).m_index].closeTo(&newvert) - ) - { - return (*it).m_index; - } - } + SharedVertex shared; + shared.m_darray = darray; + shared.m_offset = offset; + m_sharedvertex_map[origindex].push_back(shared); } -#endif // KX_FIND_SHARED_VERTICES - - // no vertex found, add one - ao->m_VertexArrayCache1[vtxarray]->push_back(newvert); - // printf("(%f,%f,%f) ",xyz[0],xyz[1],xyz[2]); - RAS_MatArrayIndex idx; - idx.m_arrayindex1 = ao->m_index1; - idx.m_array = vtxarray; - idx.m_index = numverts; - idx.m_matid = mat; - m_xyz_index_to_vertex_index_mapping[origindex].push_back(idx); - - return numverts; } -vecVertexArray& RAS_MeshObject::GetVertexCache (RAS_IPolyMaterial* mat) +int RAS_MeshObject::NumVertices(RAS_IPolyMaterial* mat) { - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); - - return ao->m_VertexArrayCache1; -} + RAS_MeshMaterial *mmat; + RAS_MeshSlot *slot; + RAS_MeshSlot::iterator it; + size_t len = 0; -int RAS_MeshObject::GetVertexArrayLength(RAS_IPolyMaterial* mat) -{ - int len = 0; - - const vecVertexArray & vertexvec = GetVertexCache(mat); - vector::const_iterator it = vertexvec.begin(); + mmat = GetMeshMaterial(mat); + slot = mmat->m_baseslot; + for(slot->begin(it); !slot->end(it); slot->next(it)) + len += it.endvertex - it.startvertex; - for (; it != vertexvec.end(); ++it) - { - len += (*it)->size(); - } - return len; } - RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid, unsigned int index) { - RAS_TexVert* vertex = NULL; - - RAS_MaterialBucket* bucket = GetMaterialBucket(matid); - if (bucket) - { - RAS_IPolyMaterial* mat = bucket->GetPolyMaterial(); - if (mat) - { - const vecVertexArray & vertexvec = GetVertexCache(mat); - vector::const_iterator it = vertexvec.begin(); - - for (unsigned int len = 0; it != vertexvec.end(); ++it) - { - if (index < len + (*it)->size()) - { - vertex = &(*(*it))[index-len]; - break; - } - else - { - len += (*it)->size(); - } - } - } - } - - return vertex; -} - - + RAS_MeshMaterial *mmat; + RAS_MeshSlot *slot; + RAS_MeshSlot::iterator it; + size_t len; -const vecIndexArrays& RAS_MeshObject::GetIndexCache (RAS_IPolyMaterial* mat) -{ - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); - - return ao->m_IndexArrayCache1; -} + mmat = GetMeshMaterial(matid); - - -KX_ArrayOptimizer* RAS_MeshObject::GetArrayOptimizer(RAS_IPolyMaterial* polymat) -{ - KX_ArrayOptimizer** aop = m_matVertexArrayS[polymat]; - - if(aop) - return *aop; + if(!mmat) + return NULL; - // didn't find array, but an array might already exist - // for a material equal to this one - for(int i=0;igetValue()); - if(*mat == *polymat) { - m_matVertexArrayS.insert(polymat, *m_matVertexArrayS.at(i)); - return *m_matVertexArrayS.at(i); - } + slot = mmat->m_baseslot; + len = 0; + for(slot->begin(it); !slot->end(it); slot->next(it)) { + if(index >= len + it.endvertex - it.startvertex) + len += it.endvertex - it.startvertex; + else + return &it.vertex[index - len]; } - - // create new array - int numelements = m_matVertexArrayS.size(); - m_sortedMaterials.push_back(polymat); - - KX_ArrayOptimizer* ao = new KX_ArrayOptimizer(numelements); - m_matVertexArrayS.insert(polymat, ao); - return ao; + return NULL; } - - -void RAS_MeshObject::Bucketize(double* oglmatrix, - void* clientobj, - bool useObjectColor, - const MT_Vector4& rgbavec) +void RAS_MeshObject::AddMeshUser(void *clientobj) { - KX_MeshSlot ms; - ms.m_clientObj = clientobj; - ms.m_mesh = this; - ms.m_OpenGLMatrix = oglmatrix; - ms.m_bObjectColor = useObjectColor; - ms.m_RGBAcolor = rgbavec; - - for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it) - { - RAS_MaterialBucket* bucket = *it; -// KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial()); - bucket->SetMeshSlot(ms); - } + list::iterator it; -} - - - -void RAS_MeshObject::MarkVisible(double* oglmatrix, - void* clientobj, - bool visible, - bool useObjectColor, - const MT_Vector4& rgbavec) -{ - KX_MeshSlot ms; - ms.m_clientObj = clientobj; - ms.m_mesh = this; - ms.m_OpenGLMatrix = oglmatrix; - ms.m_RGBAcolor = rgbavec; - ms.m_bObjectColor= useObjectColor; - - for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it) - { - RAS_MaterialBucket* bucket = *it; -// KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial()); - bucket->MarkVisibleMeshSlot(ms,visible,useObjectColor,rgbavec); + for(it = m_materials.begin();it!=m_materials.end();++it) { + /* always copy from the base slot, which is never removed + * since new objects can be created with the same mesh data */ + RAS_MeshSlot *ms = it->m_bucket->CopyMesh(it->m_baseslot); + ms->m_clientObj = clientobj; + it->m_slots.insert(clientobj, ms); } } - -void RAS_MeshObject::RemoveFromBuckets(double* oglmatrix, - void* clientobj) +void RAS_MeshObject::UpdateBuckets(void* clientobj, + double* oglmatrix, + bool useObjectColor, + const MT_Vector4& rgbavec, + bool visible, + bool culled) { - KX_MeshSlot ms; - ms.m_clientObj = clientobj; - ms.m_mesh = this; - ms.m_OpenGLMatrix = oglmatrix; - - for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it) - { - RAS_MaterialBucket* bucket = *it; -// RAS_IPolyMaterial* polymat = bucket->GetPolyMaterial(); - //KX_ArrayOptimizer* oa = GetArrayOptimizer(polymat); - bucket->RemoveMeshSlot(ms); - } - -} - - + list::iterator it; -/* - * RAS_MeshObject::GetVertex returns the vertex located somewhere in the vertexpool - * it is the clients responsibility to make sure the array and index are valid - */ -RAS_TexVert* RAS_MeshObject::GetVertex(short array, - unsigned int index, - RAS_IPolyMaterial* polymat) -{ - KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat); - return &((*(ao->m_VertexArrayCache1)[array])[index]); -} + for(it = m_materials.begin();it!=m_materials.end();++it) { + RAS_MeshSlot **msp = it->m_slots[clientobj]; + if(!msp) + continue; + RAS_MeshSlot *ms = *msp; -void RAS_MeshObject::ClearArrayData() -{ - for (int i=0;im_mesh = this; + ms->m_OpenGLMatrix = oglmatrix; + ms->m_bObjectColor = useObjectColor; + ms->m_RGBAcolor = rgbavec; + ms->m_bVisible = visible; + ms->m_bCulled = culled || !visible; - if (ao) - delete *ao; + /* split if necessary */ + ms->Split(); } } - - -/** - * RAS_MeshObject::CreateNewVertices creates vertices within sorted pools of vertices that share same material -*/ -int RAS_MeshObject::FindVertexArray(int numverts, - RAS_IPolyMaterial* polymat) +void RAS_MeshObject::RemoveFromBuckets(void *clientobj) { -// bool found=false; - int array=-1; + list::iterator it; - KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat); + for(it = m_materials.begin();it!=m_materials.end();++it) { + RAS_MeshSlot **msp = it->m_slots[clientobj]; - for (unsigned int i=0;im_VertexArrayCache1.size();i++) - { - if ( (ao->m_TriangleArrayCount[i] + (numverts-2)) < BUCKET_MAX_TRIANGLES) - { - if((ao->m_VertexArrayCache1[i]->size()+numverts < BUCKET_MAX_INDICES)) - { - array = i; - ao->m_TriangleArrayCount[array]+=numverts-2; - break; - } - } - } + if(!msp) + continue; - if (array == -1) - { - array = ao->m_VertexArrayCache1.size(); - vector* va = new vector; - ao->m_VertexArrayCache1.push_back(va); - KX_IndexArray *ia = new KX_IndexArray(); - ao->m_IndexArrayCache1.push_back(ia); - ao->m_TriangleArrayCount.push_back(numverts-2); - } + RAS_MeshSlot *ms = *msp; - return array; + it->m_bucket->RemoveMesh(ms); + it->m_slots.remove(clientobj); + } } - - - //void RAS_MeshObject::Transform(const MT_Transform& trans) //{ //m_trans.translate(MT_Vector3(0,0,1));//.operator *=(trans); @@ -563,71 +448,7 @@ void RAS_MeshObject::RelativeTransform(const MT_Vector3& vec) } */ - - -void RAS_MeshObject::UpdateMaterialList() -{ - m_materials.clear(); - unsigned int numpolys = m_Polygons.size(); - // for all polygons, find out which material they use, and add it to the set of materials - for (unsigned int i=0;iGetMaterial()); - } -} - -struct RAS_MeshObject::polygonSlot -{ - float m_z; - int m_index[4]; - - polygonSlot() {} - - /* pnorm is the normal from the plane equation that the distance from is - * used to sort again. */ - void get(const KX_VertexArray& vertexarray, const KX_IndexArray& indexarray, - int offset, int nvert, const MT_Vector3& pnorm) - { - MT_Vector3 center(0, 0, 0); - int i; - - for(i=0; i b.m_z; - } -}; - -void RAS_MeshObject::SortPolygons(const MT_Transform &transform) +void RAS_MeshObject::SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform) { // Limitations: sorting is quite simple, and handles many // cases wrong, partially due to polygons being sorted per @@ -645,43 +466,34 @@ void RAS_MeshObject::SortPolygons(const MT_Transform &transform) // to avoid excessive state changes while drawing. e) would // require splitting polygons. - if (!m_zsort) - return; + RAS_MeshSlot::iterator it; + size_t j; - // Extract camera Z plane... - const MT_Vector3 pnorm(transform.getBasis()[2]); - // unneeded: const MT_Scalar pval = transform.getOrigin()[2]; + for(ms.begin(it); !ms.end(it); ms.next(it)) { + unsigned int nvert = (int)it.array->m_type; + unsigned int totpoly = it.totindex/nvert; - for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it) - { - if(!(*it)->IsZSort()) + if(totpoly <= 1) + continue; + if(it.array->m_type == RAS_DisplayArray::LINE) continue; - RAS_IPolyMaterial *mat = (*it)->GetPolyMaterial(); - KX_ArrayOptimizer* ao = GetArrayOptimizer(mat); - - vecIndexArrays& indexarrays = ao->m_IndexArrayCache1; - vecVertexArray& vertexarrays = ao->m_VertexArrayCache1; - unsigned int i, j, nvert = (mat->UsesTriangles())? 3: 4; - - for(i=0; i slots(totpoly); + vector slots(totpoly); - /* get indices and z into temporary array */ - for(j=0; jIsZSort()) - m_zsort = true; - - if (drawingmode == RAS_IRasterizer::KX_WIREFRAME) - { - for (i=0;iIsVisible()) - ScheduleWireframePoly(poly->GetVertexIndexBase(),poly->VertexCount(),poly->GetEdgeCode(), - poly->GetMaterial()->GetPolyMaterial()); - - } - m_zsort = false; - } - else - { - for (i=0;iIsVisible()) - SchedulePoly(poly->GetVertexIndexBase(),poly->VertexCount(), - poly->GetMaterial()->GetPolyMaterial()); - } - } - m_bModified = false; - m_MeshMod = true; + m_bMeshModified = true; } } diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h index 9a46d89c393..0d35a2f402b 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.h +++ b/source/gameengine/Rasterizer/RAS_MeshObject.h @@ -36,6 +36,7 @@ #include #include +#include #include "RAS_Polygon.h" #include "RAS_MaterialBucket.h" @@ -44,194 +45,71 @@ #include "GEN_HashedPtr.h" struct Mesh; -/** - * This class holds an array of vertices and indicies. - */ -class KX_ArrayOptimizer -{ -public: - KX_ArrayOptimizer(int index) - : m_index1(index) - {}; - virtual ~KX_ArrayOptimizer(); - - vector m_VertexArrayCache1; - vector m_TriangleArrayCount; - vector m_IndexArrayCache1; - /** - order in which they are stored into the mesh - */ - int m_index1; -}; +/* RAS_MeshObject is a mesh used for rendering. It stores polygons, + * but the actual vertices and index arrays are stored in material + * buckets, referenced by the list of RAS_MeshMaterials. */ -/** - * This struct holds a triangle. - */ -struct RAS_TriangleIndex -{ -public: - int m_index[3]; - int m_array; - RAS_IPolyMaterial* m_matid; - bool m_collider; -}; - -/** - * This class looks horribly broken. Only m_matid is used, and - * m_matid is a (int) RAS_IPolyMaterial*. - * --> m_matid == lhs.m_matid should be *m_matid == *lhs.m_matid - */ -class RAS_MatArrayIndex -{ -public: - - int m_arrayindex1; - RAS_IPolyMaterial* m_matid; - int m_array; - int m_index; - -/* - inline bool Less(const RAS_MatArrayIndex& lhs) const { - bool result = - ( (m_matid < lhs.m_matid) || - ((m_matid == lhs.m_matid)&&(m_array < lhs.m_array)) || - ((m_matid == lhs.m_matid) && (m_array == lhs.m_array) && - (m_index < lhs.m_index)) - - ); - return result; - - } -*/ - -}; -/* -inline bool operator <( const RAS_MatArrayIndex& rhs,const RAS_MatArrayIndex& lhs) -{ - return ( rhs.Less(lhs)); -}*/ - -/** - * RAS_MeshObject stores mesh data for the renderer. - */ class RAS_MeshObject { - - // GEN_Map m_matVertexArrayS; - //vector m_vertexArrays; - virtual KX_ArrayOptimizer* GetArrayOptimizer(RAS_IPolyMaterial* polymat); - //vector m_polygons; - +private: unsigned int m_debugcolor; - bool m_bModified; int m_lightlayer; - - vector m_Polygons; + + bool m_bModified; + bool m_bMeshModified; + STR_String m_name; static STR_String s_emptyname; - bool m_zsort; - bool m_MeshMod; + vector m_Polygons; + + /* polygon sorting */ struct polygonSlot; struct backtofront; struct fronttoback; - void SchedulePoly( - const KX_VertexIndex& idx, - int numverts, - RAS_IPolyMaterial* mat - ); - - void ScheduleWireframePoly( - const KX_VertexIndex& idx, - int numverts, - int edgecode, - RAS_IPolyMaterial* mat - ); - protected: - enum { BUCKET_MAX_INDICES = 65535 };//2048};//8192}; - enum { BUCKET_MAX_TRIANGLES = 65535 }; - - GEN_Map m_matVertexArrayS; - - RAS_MaterialBucket::Set m_materials; + list m_materials; Mesh* m_mesh; + bool m_bDeformed; + public: // for now, meshes need to be in a certain layer (to avoid sorting on lights in realtime) RAS_MeshObject(Mesh* mesh, int lightlayer); virtual ~RAS_MeshObject(); - vector m_sortedMaterials; - vector > m_xyz_index_to_vertex_index_mapping; - vector m_triangle_indices; - - int m_class; - unsigned int GetLightLayer(); + bool IsDeformed() { return m_bDeformed; } + + /* materials */ int NumMaterials(); const STR_String& GetMaterialName(unsigned int matid); - RAS_MaterialBucket* GetMaterialBucket(unsigned int matid); const STR_String& GetTextureName(unsigned int matid); - virtual void AddPolygon(RAS_Polygon* poly); - void UpdateMaterialList(); - - int NumPolygons(); - RAS_Polygon* GetPolygon(int num) const; - - virtual void Bucketize( - double* oglmatrix, - void* clientobj, - bool useObjectColor, - const MT_Vector4& rgbavec - ); - void RemoveFromBuckets( - double* oglmatrix, - void* clientobj - ); + RAS_MeshMaterial* GetMeshMaterial(unsigned int matid); + RAS_MeshMaterial* GetMeshMaterial(RAS_IPolyMaterial *mat); - void MarkVisible( - double* oglmatrix, - void* clientobj, - bool visible, - bool useObjectColor, - const MT_Vector4& rgbavec - ); + list::iterator GetFirstMaterial(); + list::iterator GetLastMaterial(); - void DebugColor(unsigned int abgr); - void SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba); - - /** - * Sorts the polygons by their transformed z values. - */ - void SortPolygons(const MT_Transform &transform); + unsigned int GetLightLayer(); - void SchedulePolygons(int drawingmode); + /* name */ + void SetName(STR_String name); + const STR_String& GetName(); - void ClearArrayData(); - - RAS_MaterialBucket::Set::iterator GetFirstMaterial(); - RAS_MaterialBucket::Set::iterator GetLastMaterial(); - - virtual RAS_TexVert* GetVertex( - short array, - unsigned int index, - RAS_IPolyMaterial* polymat - ); - - virtual int FindVertexArray( - int numverts, - RAS_IPolyMaterial* polymat - ); + /* modification state */ + bool MeshModified(); + void SetMeshModified(bool v){m_bMeshModified = v;} + /* original blender mesh */ + Mesh* GetMesh() { return m_mesh; } + + /* mesh construction */ - // find (and share) or add vertices - // for some speedup, only the last 20 added vertices are searched for equality - - virtual int FindOrAddVertex( - int vtxarray, + virtual RAS_Polygon* AddPolygon(RAS_MaterialBucket *bucket, int numverts); + virtual void AddVertex(RAS_Polygon *poly, int i, const MT_Point3& xyz, const MT_Point2& uv, const MT_Point2& uv2, @@ -239,27 +117,43 @@ public: const unsigned int rgbacolor, const MT_Vector3& normal, bool flat, - RAS_IPolyMaterial* mat, - int origindex - ); - - vecVertexArray& GetVertexCache (RAS_IPolyMaterial* mat); + int origindex); + + void SchedulePolygons(int drawingmode); + + /* vertex and polygon acces */ + int NumVertices(RAS_IPolyMaterial* mat); + RAS_TexVert* GetVertex(unsigned int matid, unsigned int index); + + int NumPolygons(); + RAS_Polygon* GetPolygon(int num) const; - int GetVertexArrayLength(RAS_IPolyMaterial* mat); + /* buckets */ + virtual void AddMeshUser(void *clientobj); + virtual void UpdateBuckets( + void* clientobj, + double* oglmatrix, + bool useObjectColor, + const MT_Vector4& rgbavec, + bool visible, + bool culled); - RAS_TexVert* GetVertex( - unsigned int matid, - unsigned int index - ); + void RemoveFromBuckets(void *clientobj); - const vecIndexArrays& GetIndexCache (RAS_IPolyMaterial* mat); - void SetName(STR_String name); - const STR_String& GetName(); + /* colors */ + void DebugColor(unsigned int abgr); + void SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba); + + /* polygon sorting by Z for alpha */ + void SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform); - bool MeshModified(); - void SetMeshModified(bool v){m_MeshMod = v;} - Mesh* GetMesh() { return m_mesh; } + /* for construction to find shared vertices */ + struct SharedVertex { + RAS_DisplayArray *m_darray; + int m_offset; + }; + vector > m_sharedvertex_map; }; #endif //__RAS_MESHOBJECT diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt index 2a6d64ecc73..e4403ace69f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt @@ -32,6 +32,7 @@ SET(INC ../../../../intern/moto/include ../../../../source/gameengine/Rasterizer ../../../../extern/glew/include + ../../../../source/blender/gpu ) BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}") diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile index f01978b8eb1..aee485a22be 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile @@ -41,12 +41,11 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../../kernel/gen_system +CPPFLAGS += -I../../../blender/gpu CPPFLAGS += -I../../BlenderRoutines CPPFLAGS += -I.. + ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings endif -ifeq ($(WITH_BF_GLEXT),true) - CPPFLAGS += -DWITH_GLEXT -endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index c2687319717..2c4b55ff964 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -9,6 +9,7 @@ #include "GL/glew.h" +#include "RAS_MaterialBucket.h" #include "RAS_TexVert.h" #include "MT_assert.h" @@ -125,20 +126,20 @@ void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list) } } -RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot) +RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms) { /* Keep a copy of constant lists submitted for rendering, this guards against (replicated)new...delete every frame, and we can reuse lists! - :: sorted by vertex array + :: sorted by mesh slot */ - RAS_ListSlot* localSlot = (RAS_ListSlot*)*slot; + RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList; if(!localSlot) { - RAS_Lists::iterator it = mLists.find(vertexarrays); + RAS_Lists::iterator it = mLists.find(&ms); if(it == mLists.end()) { localSlot = new RAS_ListSlot(this); - mLists.insert(std::pair(vertexarrays, localSlot)); + mLists.insert(std::pair(&ms, localSlot)); } else { localSlot = static_cast(it->second->AddRef()); } @@ -157,69 +158,45 @@ void RAS_ListRasterizer::ReleaseAlloc() mLists.clear(); } - -void RAS_ListRasterizer::IndexPrimitives( - const vecVertexArray & vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot) +void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms) { RAS_ListSlot* localSlot =0; - // useObjectColor(are we updating every frame?) - if(!useObjectColor && slot) { - localSlot = FindOrAdd(vertexarrays, slot); + if(ms.m_bDisplayList) { + localSlot = FindOrAdd(ms); localSlot->DrawList(); if(localSlot->End()) { // save slot here too, needed for replicas and object using same mesh // => they have the same vertexarray but different mesh slot - *slot = localSlot; + ms.m_DisplayList = localSlot; return; } } - if (mUseVertexArrays) { - RAS_VAOpenGLRasterizer::IndexPrimitives( - vertexarrays, indexarrays, - mode, useObjectColor, - rgbacolor,slot - ); - } else { - RAS_OpenGLRasterizer::IndexPrimitives( - vertexarrays, indexarrays, - mode, useObjectColor, - rgbacolor,slot - ); - } + if (mUseVertexArrays) + RAS_VAOpenGLRasterizer::IndexPrimitives(ms); + else + RAS_OpenGLRasterizer::IndexPrimitives(ms); - if(!useObjectColor && slot) { + if(ms.m_bDisplayList) { localSlot->EndList(); - *slot = localSlot; + ms.m_DisplayList = localSlot; } } -void RAS_ListRasterizer::IndexPrimitivesMulti( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot) +void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms) { RAS_ListSlot* localSlot =0; - // useObjectColor(are we updating every frame?) - if(!useObjectColor && slot) { - localSlot = FindOrAdd(vertexarrays, slot); + if(ms.m_bDisplayList) { + localSlot = FindOrAdd(ms); localSlot->DrawList(); if(localSlot->End()) { // save slot here too, needed for replicas and object using same mesh // => they have the same vertexarray but different mesh slot - *slot = localSlot; + ms.m_DisplayList = localSlot; return; } } @@ -227,23 +204,14 @@ void RAS_ListRasterizer::IndexPrimitivesMulti( // workaround: note how we do not use vertex arrays for making display // lists, since glVertexAttribPointerARB doesn't seem to work correct // in display lists on ATI? either a bug in the driver or in Blender .. - if (mUseVertexArrays && !localSlot) { - RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( - vertexarrays, indexarrays, - mode, useObjectColor, - rgbacolor,slot - ); - } else { - RAS_OpenGLRasterizer::IndexPrimitivesMulti( - vertexarrays, indexarrays, - mode, useObjectColor, - rgbacolor,slot - ); - } + if (mUseVertexArrays && !localSlot) + RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(ms); + else + RAS_OpenGLRasterizer::IndexPrimitivesMulti(ms); - if(!useObjectColor && slot) { + if(ms.m_bDisplayList) { localSlot->EndList(); - *slot = localSlot; + ms.m_DisplayList = localSlot; } } diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h index b1b19144c12..96d6d2a995d 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h @@ -4,6 +4,7 @@ #include "RAS_MaterialBucket.h" #include "RAS_VAOpenGLRasterizer.h" #include +#include class RAS_ListRasterizer; class RAS_ListSlot : public KX_ListSlot @@ -34,14 +35,14 @@ enum RAS_ListSlotFlags { LIST_REGEN =64 }; -typedef std::map RAS_Lists; +typedef std::map RAS_Lists; class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer { bool mUseVertexArrays; RAS_Lists mLists; - RAS_ListSlot* FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot); + RAS_ListSlot* FindOrAdd(class RAS_MeshSlot& ms); void ReleaseAlloc(); public: @@ -49,23 +50,8 @@ public: RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays=false, bool lock=false); virtual ~RAS_ListRasterizer(); - virtual void IndexPrimitives( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot - ); - - virtual void IndexPrimitivesMulti( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot - ); + virtual void IndexPrimitives(class RAS_MeshSlot& ms); + virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms); virtual bool Init(); virtual void Exit(); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 1dcc6e70934..62ee2edb731 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -38,6 +38,9 @@ #include "MT_CmMatrix4x4.h" #include "RAS_IRenderTools.h" // rendering text +#include "GPU_draw.h" +#include "GPU_material.h" + /** * 32x32 bit masks for vinterlace stereo mode */ @@ -67,10 +70,12 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas) m_motionblurvalue(-1.0), m_texco_num(0), m_attrib_num(0), - m_last_blendmode(0), + m_last_blendmode(GPU_BLEND_SOLID), + m_last_frontface(true), m_materialCachingInfo(0) { - m_viewmatrix.Identity(); + m_viewmatrix.setIdentity(); + m_viewinvmatrix.setIdentity(); for (int i = 0; i < 32; i++) { @@ -87,81 +92,9 @@ RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer() { } - - -static void Myinit_gl_stuff(void) -{ - float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; - float mat_shininess[] = { 35.0 }; -/* float one= 1.0; */ - int a, x, y; - GLubyte pat[32*32]; - const GLubyte *patc= pat; - - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_specular); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); - glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); - - -#if defined(__FreeBSD) || defined(__linux__) - glDisable(GL_DITHER); /* op sgi/sun hardware && 12 bits */ -#endif - - /* no local viewer, looks ugly in ortho mode */ - /* glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, &one); */ - - glDepthFunc(GL_LEQUAL); - /* scaling matrices */ - glEnable(GL_NORMALIZE); - - glShadeModel(GL_FLAT); - - glDisable(GL_ALPHA_TEST); - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDisable(GL_FOG); - glDisable(GL_LIGHTING); - glDisable(GL_LOGIC_OP); - glDisable(GL_STENCIL_TEST); - glDisable(GL_TEXTURE_1D); - glDisable(GL_TEXTURE_2D); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - - glPixelTransferi(GL_MAP_COLOR, GL_FALSE); - glPixelTransferi(GL_RED_SCALE, 1); - glPixelTransferi(GL_RED_BIAS, 0); - glPixelTransferi(GL_GREEN_SCALE, 1); - glPixelTransferi(GL_GREEN_BIAS, 0); - glPixelTransferi(GL_BLUE_SCALE, 1); - glPixelTransferi(GL_BLUE_BIAS, 0); - glPixelTransferi(GL_ALPHA_SCALE, 1); - glPixelTransferi(GL_ALPHA_BIAS, 0); - - a = 0; - for(x=0; x<32; x++) - { - for(y=0; y<4; y++) - { - if( (x) & 1) pat[a++]= 0x88; - else pat[a++]= 0x22; - } - } - - glPolygonStipple(patc); - - glFrontFace(GL_CCW); - glCullFace(GL_BACK); - glEnable(GL_CULL_FACE); -} - - - bool RAS_OpenGLRasterizer::Init() { - - Myinit_gl_stuff(); + GPU_state_init(); m_redback = 0.4375; m_greenback = 0.4375; @@ -172,7 +105,8 @@ bool RAS_OpenGLRasterizer::Init() m_ambg = 0.0f; m_ambb = 0.0f; - SetBlendingMode(0); + SetBlendingMode(GPU_BLEND_SOLID); + SetFrontFace(true); glClearColor(m_redback,m_greenback,m_blueback,m_alphaback); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); @@ -344,7 +278,8 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time) glEnable (GL_CULL_FACE); } - SetBlendingMode(0); + SetBlendingMode(GPU_BLEND_SOLID); + SetFrontFace(true); glShadeModel(GL_SMOOTH); @@ -359,28 +294,16 @@ void RAS_OpenGLRasterizer::SetDrawingMode(int drawingmode) { m_drawingmode = drawingmode; - switch (m_drawingmode) - { - case KX_WIREFRAME: - { - glDisable (GL_CULL_FACE); - break; - } - default: - { - } - } + if(m_drawingmode == KX_WIREFRAME) + glDisable(GL_CULL_FACE); } - - int RAS_OpenGLRasterizer::GetDrawingMode() { return m_drawingmode; } - void RAS_OpenGLRasterizer::SetDepthMask(DepthMask depthmask) { glDepthMask(depthmask == KX_DEPTHMASK_DISABLED ? GL_FALSE : GL_TRUE); @@ -573,294 +496,84 @@ void RAS_OpenGLRasterizer::SwapBuffers() -void RAS_OpenGLRasterizer::GetViewMatrix(MT_Matrix4x4 &mat) const +const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewMatrix() const { - float viewmat[16]; - glGetFloatv(GL_MODELVIEW_MATRIX, viewmat); - mat.setValue(viewmat); + return m_viewmatrix; } - - -void RAS_OpenGLRasterizer::IndexPrimitives(const vecVertexArray & vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot - ) -{ - const RAS_TexVert* vertexarray; - unsigned int numindices, vt; - - for (vt=0;vtm_type; + + if(it.array->m_type == RAS_DisplayArray::LINE) { + // line drawing, no text + glBegin(GL_LINES); + + for(i=0; iRenderText(polymat->GetDrawingMode(),polymat,v1,v2,v3,v4); - ClearCachingInfo(); - } - break; + vertex = &it.vertex[it.index[i]]; + glVertex3fv(vertex->getXYZ()); + + vertex = &it.vertex[it.index[i+1]]; + glVertex3fv(vertex->getXYZ()); } - case KX_MODE_TRIANGLES: + + glEnd(); + } + else { + // triangle and quad text drawing + for(i=0; iRenderText(polymat->GetDrawingMode(),polymat,v1,v2,v3,NULL); - ClearCachingInfo(); + float v[4][3]; + int glattrib, unit; + + for(j=0; jgetXYZ()[0]; + v[j][1] = vertex->getXYZ()[1]; + v[j][2] = vertex->getXYZ()[2]; } - glEnd(); - break; - } - default: - { + + // find the right opengl attribute + glattrib = -1; + if(GLEW_ARB_vertex_program) + for(unit=0; unitRenderText(polymat->GetDrawingMode(), polymat, + v[0], v[1], v[2], (numvert == 4)? v[3]: NULL, glattrib); + + ClearCachingInfo(); } - } //switch - } //for each vertexarray + } + } + + glDisableClientState(GL_COLOR_ARRAY); } void RAS_OpenGLRasterizer::SetTexCoordNum(int num) @@ -897,14 +610,14 @@ void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv) if(GLEW_ARB_multitexture) { for(unit=0; unitm_type; - const RAS_TexVert* vertexarray; - unsigned int numindices,vt; - - for (vt=0;vtm_type == RAS_DisplayArray::LINE) { + // line drawing + glBegin(GL_LINES); - int vindex=0; - switch (mode) - { - case KX_MODE_LINES: + for(i=0; igetXYZ()); + + vertex = &it.vertex[it.index[i+1]]; + glVertex3fv(vertex->getXYZ()); } - break; - case KX_MODE_QUADS: - { + + glEnd(); + } + else { + // triangle and quad drawing + if(it.array->m_type == RAS_DisplayArray::TRIANGLE) + glBegin(GL_TRIANGLES); + else glBegin(GL_QUADS); - vindex=0; - if (useObjectColor) - { - for (unsigned int i=0;igetRGBA())); + + glNormal3fv(vertex->getNormal()); + + if(multi) + TexCoord(*vertex); + else + glTexCoord2fv(vertex->getUV1()); } + + glVertex3fv(vertex->getXYZ()); } - glEnd(); - break; - } - default: - { } - } // switch - } // for each vertexarray + + glEnd(); + } + } } void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat) @@ -1232,7 +814,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vector3& campos, const MT_Point3 &, const MT_Quaternion &camOrientQuat) { - MT_Matrix4x4 viewMat = mat; + m_viewmatrix = mat; // correction for stereo if(m_stereomode != RAS_STEREO_NOSTEREO) @@ -1259,7 +841,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vecto MT_Transform transform; transform.setIdentity(); transform.translate(-(eyeline * m_eyeseparation / 2.0)); - viewMat *= transform; + m_viewmatrix *= transform; } break; case RAS_STEREO_RIGHTEYE: @@ -1268,20 +850,21 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vecto MT_Transform transform; transform.setIdentity(); transform.translate(eyeline * m_eyeseparation / 2.0); - viewMat *= transform; + m_viewmatrix *= transform; } break; } } - // convert row major matrix 'viewMat' to column major for OpenGL - MT_Scalar cammat[16]; - viewMat.getValue(cammat); - MT_CmMatrix4x4 viewCmmat = cammat; + m_viewinvmatrix = m_viewmatrix; + m_viewinvmatrix.invert(); + + // note: getValue gives back column major as needed by OpenGL + MT_Scalar glviewmat[16]; + m_viewmatrix.getValue(glviewmat); glMatrixMode(GL_MODELVIEW); - m_viewmatrix = viewCmmat; - glLoadMatrixd(&m_viewmatrix(0,0)); + glLoadMatrixd(glviewmat); m_campos = campos; } @@ -1292,20 +875,6 @@ const MT_Point3& RAS_OpenGLRasterizer::GetCameraPosition() } - -void RAS_OpenGLRasterizer::LoadViewMatrix() -{ - glLoadMatrixd(&m_viewmatrix(0,0)); -} - - - -void RAS_OpenGLRasterizer::EnableTextures(bool enable) -{ -} - - - void RAS_OpenGLRasterizer::SetCullFace(bool enable) { if (enable) @@ -1388,23 +957,23 @@ void RAS_OpenGLRasterizer::SetBlendingMode(int blendmode) if(blendmode == m_last_blendmode) return; - if(blendmode == 0) { + if(blendmode == GPU_BLEND_SOLID) { glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } - else if(blendmode == 1) { + else if(blendmode == GPU_BLEND_ADD) { glBlendFunc(GL_ONE, GL_ONE); glEnable(GL_BLEND); glDisable(GL_ALPHA_TEST); } - else if(blendmode == 2) { + else if(blendmode == GPU_BLEND_ALPHA) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.0f); } - else if(blendmode == 4) { + else if(blendmode == GPU_BLEND_CLIP) { glDisable(GL_BLEND); glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER, 0.5f); @@ -1413,3 +982,16 @@ void RAS_OpenGLRasterizer::SetBlendingMode(int blendmode) m_last_blendmode = blendmode; } +void RAS_OpenGLRasterizer::SetFrontFace(bool ccw) +{ + if(m_last_frontface == ccw) + return; + + if(ccw) + glFrontFace(GL_CCW); + else + glFrontFace(GL_CW); + + m_last_frontface = ccw; +} + diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 02056cce446..368bd4312ac 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -41,7 +41,7 @@ using namespace std; #include "RAS_MaterialBucket.h" #include "RAS_ICanvas.h" -#define RAS_MAX_TEXCO 3 // match in BL_Material +#define RAS_MAX_TEXCO 8 // match in BL_Material #define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader struct OglDebugLine @@ -77,7 +77,8 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer float m_ambb; double m_time; - MT_CmMatrix4x4 m_viewmatrix; + MT_Matrix4x4 m_viewmatrix; + MT_Matrix4x4 m_viewinvmatrix; MT_Point3 m_campos; StereoMode m_stereomode; @@ -100,6 +101,7 @@ protected: int m_texco_num; int m_attrib_num; int m_last_blendmode; + bool m_last_frontface; /** Stores the caching information for the last material activated. */ RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo; @@ -144,33 +146,15 @@ public: virtual float GetFocalLength(); virtual void SwapBuffers(); - virtual void IndexPrimitives( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot - ); + virtual void IndexPrimitives(class RAS_MeshSlot& ms); + virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms); virtual void IndexPrimitives_3DText( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, + class RAS_MeshSlot& ms, class RAS_IPolyMaterial* polymat, - class RAS_IRenderTools* rendertools, - bool useObjectColor, - const MT_Vector4& rgbacolor - ); - - virtual void IndexPrimitivesMulti( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot); + class RAS_IRenderTools* rendertools); + void IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi); virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat); virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat); @@ -182,7 +166,6 @@ public: ); virtual const MT_Point3& GetCameraPosition(); - virtual void LoadViewMatrix(); virtual void SetFog( float start, @@ -214,7 +197,6 @@ public: virtual void SetDrawingMode(int drawingmode); virtual int GetDrawingMode(); - virtual void EnableTextures(bool enable); virtual void SetCullFace(bool enable); virtual void SetLines(bool enable); @@ -270,13 +252,10 @@ public: virtual void SetTexCoord(TexCoGen coords, int unit); virtual void SetAttrib(TexCoGen coords, int unit); - void TexCoord(const RAS_TexVert &tv); - virtual void GetViewMatrix(MT_Matrix4x4 &mat) const; + void TexCoord(const RAS_TexVert &tv); - void Tangent(const RAS_TexVert& v1, - const RAS_TexVert& v2, - const RAS_TexVert& v3, - const MT_Vector3 &no); + const MT_Matrix4x4& GetViewMatrix() const; + const MT_Matrix4x4& GetViewInvMatrix() const; virtual void EnableMotionBlur(float motionblurvalue); virtual void DisableMotionBlur(); @@ -293,6 +272,7 @@ public: }; virtual void SetBlendingMode(int blendmode); + virtual void SetFrontFace(bool ccw); }; #endif //__RAS_OPENGLRASTERIZER diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index c78a97ad7be..2cb3b52adfb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -33,6 +33,7 @@ #include #include "GL/glew.h" +#include "GPU_extensions.h" #include "STR_String.h" #include "RAS_TexVert.h" @@ -77,16 +78,16 @@ void RAS_VAOpenGLRasterizer::SetDrawingMode(int drawingmode) { case KX_BOUNDINGBOX: case KX_WIREFRAME: - glDisableClientState(GL_COLOR_ARRAY); - glDisable(GL_CULL_FACE); + //glDisableClientState(GL_COLOR_ARRAY); + //glDisable(GL_CULL_FACE); break; case KX_SOLID: - glDisableClientState(GL_COLOR_ARRAY); + //glDisableClientState(GL_COLOR_ARRAY); break; case KX_TEXTURED: case KX_SHADED: case KX_SHADOW: - glEnableClientState(GL_COLOR_ARRAY); + //glEnableClientState(GL_COLOR_ARRAY); default: break; } @@ -98,141 +99,121 @@ void RAS_VAOpenGLRasterizer::Exit() glEnableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - EnableTextures(false); RAS_OpenGLRasterizer::Exit(); } -void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot) +void RAS_VAOpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms) { - static const GLsizei vtxstride = sizeof(RAS_TexVert); + static const GLsizei stride = sizeof(RAS_TexVert); + bool wireframe = m_drawingmode <= KX_WIREFRAME; + RAS_MeshSlot::iterator it; GLenum drawmode; - if(mode == KX_MODE_TRIANGLES) - drawmode = GL_TRIANGLES; - else if(mode == KX_MODE_QUADS) - drawmode = GL_QUADS; - else - drawmode = GL_LINES; - const RAS_TexVert* vertexarray; - unsigned int numindices, vt; - - if (drawmode != GL_LINES) - { - if (useObjectColor) - { - glDisableClientState(GL_COLOR_ARRAY); - glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - } else - { - glColor4d(0,0,0,1.0); - glEnableClientState(GL_COLOR_ARRAY); - } - } - else - { - glColor3d(0,0,0); - } - - EnableTextures(false); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); + if(!wireframe) + glEnableClientState(GL_TEXTURE_COORD_ARRAY); // use glDrawElements to draw each vertexarray - for (vt=0;vtgetLocalXYZ()); - glNormalPointer(GL_FLOAT,vtxstride,vertexarray->getNormal()); - glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1()); - if(glIsEnabled(GL_COLOR_ARRAY)) - glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); - //if(m_Lock) - // local->Begin(vertexarrays[vt]->size()); + // drawing mode + if(it.array->m_type == RAS_DisplayArray::TRIANGLE) + drawmode = GL_TRIANGLES; + else if(it.array->m_type == RAS_DisplayArray::QUAD) + drawmode = GL_QUADS; + else + drawmode = GL_LINES; + + // colors + if (drawmode != GL_LINES && !wireframe) { + if (ms.m_bObjectColor) { + const MT_Vector4& rgba = ms.m_RGBAcolor; - // here the actual drawing takes places - glDrawElements(drawmode,numindices,GL_UNSIGNED_SHORT,&(indexarray[0])); + glDisableClientState(GL_COLOR_ARRAY); + glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); + } + else { + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + glEnableClientState(GL_COLOR_ARRAY); + } + } + else + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + + glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ()); + glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal()); + if(!wireframe) { + glTexCoordPointer(2, GL_FLOAT, stride, it.vertex->getUV1()); + if(glIsEnabled(GL_COLOR_ARRAY)) + glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA()); + } - //if(m_Lock) - // local->End(); + // here the actual drawing takes places + glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index); } - glDisableClientState(GL_TEXTURE_COORD_ARRAY); + if(!wireframe) { + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + } } -void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot) +void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms) { - static const GLsizei vtxstride = sizeof(RAS_TexVert); - + static const GLsizei stride = sizeof(RAS_TexVert); + bool wireframe = m_drawingmode <= KX_WIREFRAME; + RAS_MeshSlot::iterator it; GLenum drawmode; - if(mode == KX_MODE_TRIANGLES) - drawmode = GL_TRIANGLES; - else if(mode == KX_MODE_QUADS) - drawmode = GL_QUADS; - else - drawmode = GL_LINES; - const RAS_TexVert* vertexarray; - unsigned int numindices, vt; - - if (drawmode != GL_LINES) - { - if (useObjectColor) - { - glDisableClientState(GL_COLOR_ARRAY); - glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]); - } - else - { - glColor4d(0,0,0,1.0); - glEnableClientState(GL_COLOR_ARRAY); - } - } - else - { - glColor3d(0,0,0); - } + if(!wireframe) + EnableTextures(true); // use glDrawElements to draw each vertexarray - for (vt=0;vtgetLocalXYZ()); - glNormalPointer(GL_FLOAT,vtxstride,vertexarray->getNormal()); - TexCoordPtr(vertexarray); - if(glIsEnabled(GL_COLOR_ARRAY)) - glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA()); + // drawing mode + if(it.array->m_type == RAS_DisplayArray::TRIANGLE) + drawmode = GL_TRIANGLES; + else if(it.array->m_type == RAS_DisplayArray::QUAD) + drawmode = GL_QUADS; + else + drawmode = GL_LINES; + + // colors + if (drawmode != GL_LINES && !wireframe) { + if (ms.m_bObjectColor) { + const MT_Vector4& rgba = ms.m_RGBAcolor; - //if(m_Lock) - // local->Begin(vertexarrays[vt]->size()); + glDisableClientState(GL_COLOR_ARRAY); + glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]); + } + else { + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + glEnableClientState(GL_COLOR_ARRAY); + } + } + else + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + + glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ()); + glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal()); + if(!wireframe) { + TexCoordPtr(it.vertex); + if(glIsEnabled(GL_COLOR_ARRAY)) + glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA()); + } // here the actual drawing takes places - glDrawElements(drawmode,numindices,GL_UNSIGNED_SHORT,&(indexarray[0])); - - //if(m_Lock) - // local->End(); + glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index); + } + + if(!wireframe) { + glDisableClientState(GL_COLOR_ARRAY); + EnableTextures(false); } } @@ -248,7 +229,7 @@ void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv) for(unit=0; unitgetFlag() & TV_2NDUV && (int)tv->getUnit() == unit) { + if(tv->getFlag() & RAS_TexVert::SECOND_UV && (int)tv->getUnit() == unit) { glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2()); continue; @@ -257,7 +238,7 @@ void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv) { case RAS_TEXCO_ORCO: case RAS_TEXCO_GLOB: - glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getLocalXYZ()); + glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getXYZ()); break; case RAS_TEXCO_UV1: glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV1()); @@ -284,7 +265,7 @@ void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv) switch(m_attrib[unit]) { case RAS_TEXCO_ORCO: case RAS_TEXCO_GLOB: - glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getLocalXYZ()); + glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getXYZ()); break; case RAS_TEXCO_UV1: glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV1()); @@ -313,11 +294,6 @@ void RAS_VAOpenGLRasterizer::EnableTextures(bool enable) TexCoGen *texco, *attrib; int unit, texco_num, attrib_num; - /* disable previously enabled texture coordinates and attributes. ideally - * this shouldn't be necessary .. */ - if(enable) - EnableTextures(false); - /* we cache last texcoords and attribs to ensure we disable the ones that * were actually last set */ if(enable) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h index e4cc4ace0e8..766bbfbed0e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h @@ -50,22 +50,10 @@ public: virtual void SetDrawingMode(int drawingmode); - virtual void IndexPrimitives( const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot); - - virtual void IndexPrimitivesMulti( - const vecVertexArray& vertexarrays, - const vecIndexArrays & indexarrays, - DrawMode mode, - bool useObjectColor, - const MT_Vector4& rgbacolor, - class KX_ListSlot** slot); - + virtual void IndexPrimitives(class RAS_MeshSlot& ms); + virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms); +private: virtual void EnableTextures(bool enable); //virtual bool QueryArrays(){return true;} //virtual bool QueryLists(){return m_Lock;} diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript index 0cf9c326370..8d46528f7f0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript @@ -1,12 +1,9 @@ #!/usr/bin/python Import ('env') -if env['WITH_BF_GLEXT'] == 1: - env['CPPFLAGS'].append('-DWITH_GLEXT') - sources = env.Glob('*.cpp') incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines ' -incs += ' #extern/glew/include ' + env['BF_OPENGL_INC'] +incs += ' #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC'] env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), [], libtype=['game','player'], priority=[40, 120] ) diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp index b74cb9cfcac..50331d7a664 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.cpp +++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp @@ -26,99 +26,82 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifdef HAVE_CONFIG_H -#include -#endif - #ifdef WIN32 - #pragma warning (disable:4786) #endif #include "RAS_Polygon.h" -RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, - bool visible, - int numverts, - int vtxarrayindex) - :m_bucket(bucket), - m_vertexindexbase(numverts), - m_numverts(numverts), - m_edgecode(65535) +RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert) { - m_vertexindexbase.m_vtxarray = vtxarrayindex ;//m_bucket->FindVertexArray(numverts); - m_polyFlags.Visible = visible; -} - + m_bucket = bucket; + m_darray = darray; + m_offset[0]= m_offset[1]= m_offset[2]= m_offset[3]= 0; + m_numvert = numvert; + m_edgecode = 255; + m_polyflags = 0; +} int RAS_Polygon::VertexCount() { - return m_numverts; + return m_numvert; } - - -void RAS_Polygon::SetVertex(int i, - unsigned int vertexindex ) //const MT_Point3& xyz,const MT_Point2& uv,const unsigned int rgbacolor,const MT_Vector3& normal) +void RAS_Polygon::SetVertexOffset(int i, unsigned short offset) { - m_vertexindexbase.SetIndex(i,vertexindex); //m_bucket->FindOrAddVertex(m_vertexindexbase.m_vtxarray, - //xyz,uv,rgbacolor,normal)); + m_offset[i] = offset; } - - -const KX_VertexIndex& RAS_Polygon::GetIndexBase() +RAS_TexVert *RAS_Polygon::GetVertex(int i) { - return m_vertexindexbase; + return &m_darray->m_vertex[m_offset[i]]; } - - -void RAS_Polygon::SetVisibleWireframeEdges(int edgecode) +int RAS_Polygon::GetVertexOffset(int i) { - m_edgecode = edgecode; + return m_offset[i]; } - - -// each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc. int RAS_Polygon::GetEdgeCode() { return m_edgecode; } +void RAS_Polygon::SetEdgeCode(int edgecode) +{ + m_edgecode = edgecode; +} bool RAS_Polygon::IsVisible() { - return m_polyFlags.Visible; + return (m_polyflags & VISIBLE) != 0; } - +void RAS_Polygon::SetVisible(bool visible) +{ + if(visible) m_polyflags |= VISIBLE; + else m_polyflags &= ~VISIBLE; +} bool RAS_Polygon::IsCollider() { - return m_polyFlags.Collider; + return (m_polyflags & COLLIDER) != 0; } - - -void RAS_Polygon::SetCollider(bool col) +void RAS_Polygon::SetCollider(bool visible) { - m_polyFlags.Collider = col; + if(visible) m_polyflags |= COLLIDER; + else m_polyflags &= ~COLLIDER; } - - -KX_VertexIndex& RAS_Polygon::GetVertexIndexBase() +RAS_MaterialBucket* RAS_Polygon::GetMaterial() { - return m_vertexindexbase; + return m_bucket; } - - -RAS_MaterialBucket* RAS_Polygon::GetMaterial() +RAS_DisplayArray* RAS_Polygon::GetDisplayArray() { - return m_bucket; + return m_darray; } diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h index 7ce7926a816..18526ba45f7 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.h +++ b/source/gameengine/Rasterizer/RAS_Polygon.h @@ -35,55 +35,47 @@ #include using namespace std; - -// -// Bitfield that stores the flags for each CValue derived class -// -struct PolygonFlags { - PolygonFlags() : - Visible(true), - Collider(true) - { - } - unsigned char Visible : 1; - unsigned char Collider : 1; - //int Visible : 1; - //int Collider : 1; -}; +/* polygon flags */ class RAS_Polygon { + /* location */ RAS_MaterialBucket* m_bucket; - KX_VertexIndex m_vertexindexbase; - int m_numverts; - int m_edgecode; - PolygonFlags m_polyFlags; - + RAS_DisplayArray* m_darray; + unsigned short m_offset[4]; + unsigned short m_numvert; + + /* flags */ + unsigned char m_edgecode; + unsigned char m_polyflags; public: - RAS_Polygon(RAS_MaterialBucket* bucket, - bool visible, - int numverts, - int vtxarrayindex) ; + enum { + VISIBLE = 1, + COLLIDER = 2 + }; + + RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray* darray, int numvert); virtual ~RAS_Polygon() {}; -// RAS_TexVert* GetVertex(int index); int VertexCount(); - void SetVertex(int i, unsigned int vertexindex); //const MT_Point3& xyz,const MT_Point2& uv,const unsigned int rgbacolor,const MT_Vector3& normal) - - const KX_VertexIndex& GetIndexBase(); + RAS_TexVert* GetVertex(int i); - void SetVisibleWireframeEdges(int edgecode); + void SetVertexOffset(int i, unsigned short offset); + int GetVertexOffset(int i); + // each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc. int GetEdgeCode(); + void SetEdgeCode(int edgecode); bool IsVisible(); + void SetVisible(bool visible); + bool IsCollider(); - void SetCollider(bool col); + void SetCollider(bool collider); - KX_VertexIndex& GetVertexIndexBase(); RAS_MaterialBucket* GetMaterial(); - + RAS_DisplayArray* GetDisplayArray(); }; #endif diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp index 935633dc636..d6f1fe912be 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.cpp +++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp @@ -27,12 +27,7 @@ */ #include "RAS_TexVert.h" - -#ifdef HAVE_CONFIG_H -#include -#endif - -#define SHORT(x) short(x*32767.0) +#include "MT_Matrix4x4.h" RAS_TexVert::RAS_TexVert(const MT_Point3& xyz, const MT_Point2& uv, @@ -40,7 +35,7 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz, const MT_Vector4& tangent, const unsigned int rgba, const MT_Vector3& normal, - const short flag, + const bool flat, const unsigned int origindex) { xyz.getValue(m_localxyz); @@ -49,7 +44,7 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz, SetRGBA(rgba); SetNormal(normal); tangent.getValue(m_tangent); - m_flag = flag; + m_flag = (flat)? FLAT: 0; m_origindex = origindex; m_unit = 2; } @@ -101,7 +96,7 @@ void RAS_TexVert::SetFlag(const short flag) void RAS_TexVert::SetUnit(const unsigned int u) { - m_unit = u<=TV_MAX?u:TV_MAX; + m_unit = u<=MAX_UNIT?u:MAX_UNIT; } void RAS_TexVert::SetNormal(const MT_Vector3& normal) @@ -109,12 +104,18 @@ void RAS_TexVert::SetNormal(const MT_Vector3& normal) normal.getValue(m_normal); } +void RAS_TexVert::SetTangent(const MT_Vector3& tangent) +{ + tangent.getValue(m_tangent); +} + // compare two vertices, and return TRUE if both are almost identical (they can be shared) bool RAS_TexVert::closeTo(const RAS_TexVert* other) { return (m_flag == other->m_flag && m_rgba == other->m_rgba && MT_fuzzyEqual(MT_Vector3(m_normal), MT_Vector3(other->m_normal)) && + MT_fuzzyEqual(MT_Vector3(m_tangent), MT_Vector3(other->m_tangent)) && MT_fuzzyEqual(MT_Vector2(m_uv1), MT_Vector2(other->m_uv1)) && MT_fuzzyEqual(MT_Vector2(m_uv2), MT_Vector2(other->m_uv2)) && // p -- MT_fuzzyEqual(MT_Vector3(m_localxyz), MT_Vector3(other->m_localxyz))) ; @@ -131,11 +132,10 @@ unsigned int RAS_TexVert::getUnit() const return m_unit; } - -void RAS_TexVert::getOffsets(void* &xyz, void* &uv1, void* &rgba, void* &normal) const +void RAS_TexVert::Transform(const MT_Matrix4x4& mat, const MT_Matrix4x4& nmat) { - xyz = (void *) m_localxyz; - uv1 = (void *) m_uv1; - rgba = (void *) &m_rgba; - normal = (void *) m_normal; + SetXYZ((mat*MT_Vector4(m_localxyz[0], m_localxyz[1], m_localxyz[2], 1.0)).getValue()); + SetNormal((nmat*MT_Vector4(m_normal[0], m_normal[1], m_normal[2], 1.0)).getValue()); + SetTangent((nmat*MT_Vector4(m_tangent[0], m_tangent[1], m_tangent[2], 1.0)).getValue()); } + diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h index bf092b4b230..4ec4db19e53 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.h +++ b/source/gameengine/Rasterizer/RAS_TexVert.h @@ -37,11 +37,6 @@ static MT_Point3 g_pt3; static MT_Point2 g_pt2; -#define TV_CALCFACENORMAL 0x0001 -#define TV_2NDUV 0x0002 - -#define TV_MAX 3//match Def in BL_Material.h - class RAS_TexVert { @@ -59,6 +54,12 @@ class RAS_TexVert // 32 bytes total size, fits nice = 56 = not fit nice. // We'll go for 64 bytes total size - 24 bytes left. public: + enum { + FLAT = 1, + SECOND_UV = 2, + MAX_UNIT = 8 + }; + short getFlag() const; unsigned int getUnit() const; @@ -70,7 +71,7 @@ public: const MT_Vector4& tangent, const unsigned int rgba, const MT_Vector3& normal, - const short flag, + const bool flat, const unsigned int origindex); ~RAS_TexVert() {}; @@ -82,7 +83,7 @@ public: return m_uv2; }; - const float* getLocalXYZ() const { + const float* getXYZ() const { return m_localxyz; }; @@ -108,20 +109,19 @@ public: void SetRGBA(const unsigned int rgba); void SetNormal(const MT_Vector3& normal); + void SetTangent(const MT_Vector3& tangent); void SetFlag(const short flag); void SetUnit(const unsigned u); void SetRGBA(const MT_Vector4& rgba); const MT_Point3& xyz(); - // compare two vertices, and return TRUE if both are almost identical (they can be shared) - bool closeTo(const RAS_TexVert* other); + void Transform(const class MT_Matrix4x4& mat, + const class MT_Matrix4x4& nmat); - bool closeTo(const MT_Point3& otherxyz, - const MT_Point2& otheruv, - const unsigned int otherrgba, - short othernormal[3]) const; - void getOffsets(void*&xyz, void *&uv1, void *&rgba, void *&normal) const; + // compare two vertices, to test if they can be shared, used for + // splitting up based on uv's, colors, etc + bool closeTo(const RAS_TexVert* other); }; #endif //__RAS_TEXVERT diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript index e6bc657ed6d..a024f7e0ee6 100644 --- a/source/gameengine/Rasterizer/SConscript +++ b/source/gameengine/Rasterizer/SConscript @@ -3,11 +3,8 @@ Import ('env') sources = env.Glob('*.cpp') -if env['WITH_BF_GLEXT'] == 1: - env['CPPFLAGS'].append('-DWITH_GLEXT') - -incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions' +incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/blender/blenkernel #source/blender/makesdna' incs += ' ' + env['BF_PYTHON_INC'] if env['OURPLATFORM']=='win32-vc': -- cgit v1.2.3 From 2d50ead6b8ae689b34c8e1a6bd9f57f414f6cef8 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 4 Sep 2008 23:07:43 +0000 Subject: Partial repair of raycast system with Bullet 2.71. Still to be done: face and normal information --- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index f9242e6876f..228709999a5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -721,17 +721,20 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul { } - virtual bool NeedRayCast(btCollisionObject* object) + virtual bool needsCollision(btBroadphaseProxy* proxy0) const { + if (!(proxy0->m_collisionFilterGroup & m_collisionFilterMask)) + return false; + if (!(m_collisionFilterGroup & proxy0->m_collisionFilterMask)) + return false; + btCollisionObject* object = (btCollisionObject*)proxy0->m_clientObject; CcdPhysicsController* phyCtrl = static_cast(object->getUserPointer()); - if (phyCtrl != m_phyRayFilter.m_ignoreController) - { - return m_phyRayFilter.needBroadphaseRayCast(phyCtrl); - } - return false; + if (phyCtrl == m_phyRayFilter.m_ignoreController) + return false; + return m_phyRayFilter.needBroadphaseRayCast(phyCtrl); } - virtual float AddSingleResult( btCollisionWorld::LocalRayResult& rayResult) + virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace) { CcdPhysicsController* curHit = static_cast(rayResult.m_collisionObject->getUserPointer()); // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it @@ -744,8 +747,7 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul m_hitTriangleShape = NULL; m_hitTriangleIndex = 0; } - bool normalInWorldspace = true; - return ClosestRayResultCallback::addSingleResult(rayResult,normalInWorldspace); + return ClosestRayResultCallback::addSingleResult(rayResult,normalInWorldSpace); } }; -- cgit v1.2.3 From e3a1547eea2b76daa30ccd9405868f8e5f2a1bc4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Sep 2008 02:53:12 +0000 Subject: BGE Py API added exception messages for replaceMesh.setMesh() and allowed None as an argument. added exception messages for other BGE module functions. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 403 ++++++++++----------- .../Ketsji/KX_SCA_ReplaceMeshActuator.cpp | 39 +- .../gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h | 2 +- .../gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py | 5 +- 4 files changed, 224 insertions(+), 225 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 120311fb967..f2902d0ef01 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -123,15 +123,13 @@ static PyObject* gPyGetRandomFloat(PyObject*) static PyObject* gPySetGravity(PyObject*, PyObject* args) { MT_Vector3 vec = MT_Vector3(0., 0., 0.); - if (PyVecArgTo(args, vec)) - { - if (gp_KetsjiScene) - gp_KetsjiScene->SetGravity(vec); - - Py_Return; - } + if (!PyVecArgTo(args, vec)) + return NULL; + + if (gp_KetsjiScene) + gp_KetsjiScene->SetGravity(vec); - return NULL; + Py_RETURN_NONE; } static char gPyExpandPath_doc[] = @@ -149,13 +147,12 @@ static PyObject* gPyExpandPath(PyObject*, PyObject* args) char expanded[FILE_MAXDIR + FILE_MAXFILE]; char* filename; - if (PyArg_ParseTuple(args,"s",&filename)) - { - BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE); - BLI_convertstringcode(expanded, G.sce); - return PyString_FromString(expanded); - } - return NULL; + if (!PyArg_ParseTuple(args,"s",&filename)) + return NULL; + + BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE); + BLI_convertstringcode(expanded, G.sce); + return PyString_FromString(expanded); } @@ -183,6 +180,12 @@ static PyObject* gPyGetSpectrum(PyObject*) PyList_SetItem(resultlist, index, PyFloat_FromDouble(spectrum[index])); } } + else { + for (int index = 0; index < 512; index++) + { + PyList_SetItem(resultlist, index, PyFloat_FromDouble(0.0)); + } + } return resultlist; } @@ -193,16 +196,17 @@ static PyObject* gPyStartDSP(PyObject*, PyObject* args) { SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); - if (audiodevice) - { - if (!usedsp) - { - audiodevice->StartUsingDSP(); - usedsp = true; - Py_Return; - } + if (!audiodevice) { + PyErr_SetString(PyExc_RuntimeError, "no audio device available"); + return NULL; } - return NULL; + + if (!usedsp) { + audiodevice->StartUsingDSP(); + usedsp = true; + } + + Py_RETURN_NONE; } @@ -211,28 +215,27 @@ static PyObject* gPyStopDSP(PyObject*, PyObject* args) { SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); - if (audiodevice) - { - if (usedsp) - { - audiodevice->StopUsingDSP(); - usedsp = false; - Py_Return; - } + if (!audiodevice) { + PyErr_SetString(PyExc_RuntimeError, "no audio device available"); + return NULL; } - return NULL; + + if (usedsp) { + audiodevice->StopUsingDSP(); + usedsp = true; + } + + Py_RETURN_NONE; } static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args) { float ticrate; - if (PyArg_ParseTuple(args, "f", &ticrate)) - { - KX_KetsjiEngine::SetTicRate(ticrate); - Py_Return; - } + if (!PyArg_ParseTuple(args, "f", &ticrate)) + return NULL; - return NULL; + KX_KetsjiEngine::SetTicRate(ticrate); + Py_RETURN_NONE; } static PyObject* gPyGetLogicTicRate(PyObject*) @@ -243,26 +246,21 @@ static PyObject* gPyGetLogicTicRate(PyObject*) static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args) { float ticrate; - if (PyArg_ParseTuple(args, "f", &ticrate)) - { - - PHY_GetActiveEnvironment()->setFixedTimeStep(true,ticrate); - Py_Return; - } + if (!PyArg_ParseTuple(args, "f", &ticrate)) + return NULL; - return NULL; + PHY_GetActiveEnvironment()->setFixedTimeStep(true,ticrate); + Py_RETURN_NONE; } static PyObject* gPySetPhysicsDebug(PyObject*, PyObject* args) { int debugMode; - if (PyArg_ParseTuple(args, "i", &debugMode)) - { - PHY_GetActiveEnvironment()->setDebugMode(debugMode); - Py_Return; - } + if (!PyArg_ParseTuple(args, "i", &debugMode)) + return NULL; - return NULL; + PHY_GetActiveEnvironment()->setDebugMode(debugMode); + Py_RETURN_NONE; } @@ -425,22 +423,14 @@ static struct PyMethodDef game_methods[] = { static PyObject* gPyGetWindowHeight(PyObject*, PyObject* args) { - int height = (gp_Canvas ? gp_Canvas->GetHeight() : 0); - - PyObject* heightval = PyInt_FromLong(height); - return heightval; + return PyInt_FromLong((gp_Canvas ? gp_Canvas->GetHeight() : 0)); } static PyObject* gPyGetWindowWidth(PyObject*, PyObject* args) { - - - int width = (gp_Canvas ? gp_Canvas->GetWidth() : 0); - - PyObject* widthval = PyInt_FromLong(width); - return widthval; + return PyInt_FromLong((gp_Canvas ? gp_Canvas->GetWidth() : 0)); } @@ -451,15 +441,11 @@ bool gUseVisibilityTemp = false; static PyObject* gPyEnableVisibility(PyObject*, PyObject* args) { int visible; - if (PyArg_ParseTuple(args,"i",&visible)) - { - gUseVisibilityTemp = (visible != 0); - } - else - { + if (!PyArg_ParseTuple(args,"i",&visible)) return NULL; - } - Py_Return; + + gUseVisibilityTemp = (visible != 0); + Py_RETURN_NONE; } @@ -467,23 +453,20 @@ static PyObject* gPyEnableVisibility(PyObject*, PyObject* args) static PyObject* gPyShowMouse(PyObject*, PyObject* args) { int visible; - if (PyArg_ParseTuple(args,"i",&visible)) - { - if (visible) - { - if (gp_Canvas) - gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); - } else - { - if (gp_Canvas) - gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); - } - } - else { + if (!PyArg_ParseTuple(args,"i",&visible)) return NULL; + + if (visible) + { + if (gp_Canvas) + gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); + } else + { + if (gp_Canvas) + gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE); } - Py_Return; + Py_RETURN_NONE; } @@ -491,74 +474,81 @@ static PyObject* gPyShowMouse(PyObject*, PyObject* args) static PyObject* gPySetMousePosition(PyObject*, PyObject* args) { int x,y; - if (PyArg_ParseTuple(args,"ii",&x,&y)) - { - if (gp_Canvas) - gp_Canvas->SetMousePosition(x,y); - } - else { + if (!PyArg_ParseTuple(args,"ii",&x,&y)) return NULL; - } - Py_Return; + if (gp_Canvas) + gp_Canvas->SetMousePosition(x,y); + + Py_RETURN_NONE; } static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args) { float sep; - if (PyArg_ParseTuple(args, "f", &sep)) - { - if (gp_Rasterizer) - gp_Rasterizer->SetEyeSeparation(sep); - - Py_Return; + if (!PyArg_ParseTuple(args, "f", &sep)) + return NULL; + + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + return NULL; } - return NULL; + gp_Rasterizer->SetEyeSeparation(sep); + + Py_RETURN_NONE; } static PyObject* gPyGetEyeSeparation(PyObject*, PyObject*, PyObject*) { - if (gp_Rasterizer) - return PyFloat_FromDouble(gp_Rasterizer->GetEyeSeparation()); + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + return NULL; + } - return NULL; + return PyFloat_FromDouble(gp_Rasterizer->GetEyeSeparation()); } static PyObject* gPySetFocalLength(PyObject*, PyObject* args) { float focus; - if (PyArg_ParseTuple(args, "f", &focus)) - { - if (gp_Rasterizer) - gp_Rasterizer->SetFocalLength(focus); - Py_Return; + if (!PyArg_ParseTuple(args, "f", &focus)) + return NULL; + + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + return NULL; } + + gp_Rasterizer->SetFocalLength(focus); - return NULL; + Py_RETURN_NONE; } static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*) { - if (gp_Rasterizer) - return PyFloat_FromDouble(gp_Rasterizer->GetFocalLength()); - return NULL; + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + return NULL; + } + + return PyFloat_FromDouble(gp_Rasterizer->GetFocalLength()); + + Py_RETURN_NONE; } static PyObject* gPySetBackgroundColor(PyObject*, PyObject* args) { MT_Vector4 vec = MT_Vector4(0., 0., 0.3, 0.); - if (PyVecArgTo(args, vec)) + if (!PyVecArgTo(args, vec)) + return NULL; + + if (gp_Canvas) { - if (gp_Canvas) - { - gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]); - } - Py_Return; + gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]); } - - return NULL; + Py_RETURN_NONE; } @@ -567,16 +557,16 @@ static PyObject* gPySetMistColor(PyObject*, PyObject* args) { MT_Vector3 vec = MT_Vector3(0., 0., 0.); - if (PyVecArgTo(args, vec)) - { - if (gp_Rasterizer) - { - gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]); - } - Py_Return; - } + if (!PyVecArgTo(args, vec)) + return NULL; - return NULL; + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + return NULL; + } + gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]); + + Py_RETURN_NONE; } @@ -585,17 +575,17 @@ static PyObject* gPySetMistStart(PyObject*, PyObject* args) { float miststart; - if (PyArg_ParseTuple(args,"f",&miststart)) - { - if (gp_Rasterizer) - { - gp_Rasterizer->SetFogStart(miststart); - } - } - else { + if (!PyArg_ParseTuple(args,"f",&miststart)) + return NULL; + + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); return NULL; } - Py_Return; + + gp_Rasterizer->SetFogStart(miststart); + + Py_RETURN_NONE; } @@ -604,17 +594,17 @@ static PyObject* gPySetMistEnd(PyObject*, PyObject* args) { float mistend; - if (PyArg_ParseTuple(args,"f",&mistend)) - { - if (gp_Rasterizer) - { - gp_Rasterizer->SetFogEnd(mistend); - } - } - else { + if (!PyArg_ParseTuple(args,"f",&mistend)) + return NULL; + + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); return NULL; } - Py_Return; + + gp_Rasterizer->SetFogEnd(mistend); + + Py_RETURN_NONE; } @@ -622,16 +612,16 @@ static PyObject* gPySetAmbientColor(PyObject*, PyObject* args) { MT_Vector3 vec = MT_Vector3(0., 0., 0.); - if (PyVecArgTo(args, vec)) - { - if (gp_Rasterizer) - { - gp_Rasterizer->SetAmbientColor(vec[0], vec[1], vec[2]); - } - Py_Return; - } + if (!PyVecArgTo(args, vec)) + return NULL; - return NULL; + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + return NULL; + } + gp_Rasterizer->SetAmbientColor(vec[0], vec[1], vec[2]); + + Py_RETURN_NONE; } @@ -640,42 +630,43 @@ static PyObject* gPySetAmbientColor(PyObject*, PyObject* args) static PyObject* gPyMakeScreenshot(PyObject*, PyObject* args) { char* filename; - if (PyArg_ParseTuple(args,"s",&filename)) - { - if (gp_Canvas) - { - gp_Canvas->MakeScreenShot(filename); - } - } - else { + if (!PyArg_ParseTuple(args,"s",&filename)) return NULL; + + if (gp_Canvas) + { + gp_Canvas->MakeScreenShot(filename); } - Py_Return; + + Py_RETURN_NONE; } static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args) { float motionblurvalue; - if (PyArg_ParseTuple(args,"f",&motionblurvalue)) - { - if(gp_Rasterizer) - { - gp_Rasterizer->EnableMotionBlur(motionblurvalue); - } - } - else { + if (!PyArg_ParseTuple(args,"f",&motionblurvalue)) + return NULL; + + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); return NULL; } - Py_Return; + + gp_Rasterizer->EnableMotionBlur(motionblurvalue); + + Py_RETURN_NONE; } static PyObject* gPyDisableMotionBlur(PyObject*, PyObject* args) { - if(gp_Rasterizer) - { - gp_Rasterizer->DisableMotionBlur(); + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + return NULL; } - Py_Return; + + gp_Rasterizer->DisableMotionBlur(); + + Py_RETURN_NONE; } int getGLSLSettingFlag(char *setting) @@ -704,30 +695,33 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, int enable, flag; if (PyArg_ParseTuple(args,"si",&setting,&enable)) - { - flag = getGLSLSettingFlag(setting); - - if(flag != -1) { - if (enable) - G.fileflags &= ~flag; - else - G.fileflags |= flag; - - /* display lists and GLSL materials need to be remade */ - if(gp_KetsjiEngine) { - KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes(); - KX_SceneList::iterator it; + return NULL; + + flag = getGLSLSettingFlag(setting); + + if (flag==-1) { + PyErr_SetString(PyExc_ValueError, "glsl setting is not known"); + return NULL; + } + + if (enable) + G.fileflags &= ~flag; + else + G.fileflags |= flag; - for(it=scenes->begin(); it!=scenes->end(); it++) - if((*it)->GetBucketManager()) - (*it)->GetBucketManager()->ReleaseDisplayLists(); - } + /* display lists and GLSL materials need to be remade */ + if(gp_KetsjiEngine) { + KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes(); + KX_SceneList::iterator it; - GPU_materials_free(); - } + for(it=scenes->begin(); it!=scenes->end(); it++) + if((*it)->GetBucketManager()) + (*it)->GetBucketManager()->ReleaseDisplayLists(); } - Py_Return; + GPU_materials_free(); + + Py_RETURN_NONE; } static PyObject* gPyGetGLSLMaterialSetting(PyObject*, @@ -737,14 +731,17 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*, char *setting; int enabled = 0, flag; - if (PyArg_ParseTuple(args,"s",&setting)) - { - flag = getGLSLSettingFlag(setting); - - if(flag != -1) - enabled = ((G.fileflags & flag) != 0); + if (!PyArg_ParseTuple(args,"s",&setting)) + return NULL; + + flag = getGLSLSettingFlag(setting); + + if (flag==-1) { + PyErr_SetString(PyExc_ValueError, "glsl setting is not known"); + return NULL; } + enabled = ((G.fileflags & flag) != 0); return PyInt_FromLong(enabled); } diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 630df2d21d9..18a297d6c92 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -80,7 +80,7 @@ PyParentObject KX_SCA_ReplaceMeshActuator::Parents[] = { PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = { - {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_VARARGS, SetMesh_doc}, + {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, SetMesh_doc}, KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh), KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh), @@ -99,28 +99,29 @@ PyObject* KX_SCA_ReplaceMeshActuator::_getattr(const STR_String& attr) /* 1. setMesh */ char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] = "setMesh(name)\n" - "\t- name: string\n" + "\t- name: string or None\n" "\tSet the mesh that will be substituted for the current one.\n"; -PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* self, PyObject* value) { - char* meshname; - - if (!PyArg_ParseTuple(args, "s", &meshname)) - { - return NULL; - } - - void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname)); - - if (mesh) { + if (value == Py_None) { + m_mesh = NULL; + } else { + char* meshname = PyString_AsString(value); + if (!meshname) { + PyErr_SetString(PyExc_ValueError, "Expected the name of a mesh or None"); + return NULL; + } + void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname)); + + if (mesh==NULL) { + PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist"); + return NULL; + } m_mesh= (class RAS_MeshObject*)mesh; - Py_Return; } - return NULL; + Py_RETURN_NONE; } KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh, @@ -129,7 +130,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh, ) { if (!m_mesh) - Py_Return; + Py_RETURN_NONE; return PyString_FromString(const_cast(m_mesh->GetName().ReadPtr())); } @@ -139,7 +140,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh, "instantReplaceMesh() : immediately replace mesh without delay\n") { InstantReplaceMesh(); - Py_Return; + Py_RETURN_NONE; } /* ------------------------------------------------------------------------- */ diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h index 5ba0a099b14..1da154cc222 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h @@ -76,7 +76,7 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator void InstantReplaceMesh(); /* 1. setMesh */ - KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,SetMesh); + KX_PYMETHOD_DOC_O(KX_SCA_ReplaceMeshActuator,SetMesh); KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,getMesh); KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,instantReplaceMesh); diff --git a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py index eb00a91a4ce..498f6072e23 100644 --- a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py +++ b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py @@ -59,8 +59,9 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator): def setMesh(name): """ Sets the name of the mesh that will replace the current one. + When the name is None it will unset the mesh value so no action is taken. - @type name: string + @type name: string or None """ def getMesh(): """ @@ -68,6 +69,6 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator): Returns None if no mesh has been scheduled to be added. - @rtype: string + @rtype: string or None """ -- cgit v1.2.3 From 330aa94ecc0a674c7c2e8c34909c7b8ee9753c31 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 5 Sep 2008 14:33:36 +0000 Subject: * GLSL lamps now respect 3d viewport layers. * Fix undo crash related to sound. Sounds still stop working in the game engine after undo, but seems to be a different issue. --- source/gameengine/Ketsji/BL_BlenderShader.cpp | 4 ++-- source/gameengine/Ketsji/KX_Light.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 13b8235687b..8ec463be6ff 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -22,7 +22,7 @@ BL_BlenderShader::BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lig mMat(ma), mLightLayer(lightlayer) { - mBlenderScene = scene->GetBlenderScene(); //GetSceneForName(scene->GetName()); + mBlenderScene = scene->GetBlenderScene(); mBlendMode = GPU_BLEND_SOLID; if(mMat) @@ -52,7 +52,7 @@ void BL_BlenderShader::SetProg(bool enable, double time) { if(VerifyShader()) { if(enable) - GPU_material_bind(GPU_material_from_blender(mBlenderScene, mMat), mLightLayer, time); + GPU_material_bind(GPU_material_from_blender(mBlenderScene, mMat), mLightLayer, ~0, time); else GPU_material_unbind(GPU_material_from_blender(mBlenderScene, mMat)); } diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 6cfe5610863..979015532e3 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -105,7 +105,7 @@ void KX_LightObject::Update() for(int j=0; j<4; j++, dobmat++) obmat[i][j] = (float)*dobmat; - GPU_lamp_update(lamp, obmat); + GPU_lamp_update(lamp, m_lightobj.m_layer, obmat); } } -- cgit v1.2.3 From 5eab0da6335b57cc3508d85277592e0f789c7ebd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Sep 2008 16:22:14 +0000 Subject: BGE set visible actuator, option to set visibility recursively to make managing visibility for collections of objects a lot easier. BGE Python api's ob.setVisible() also takes an optional recursive arg thats off by default --- .../gameengine/Converter/KX_ConvertActuators.cpp | 5 +- source/gameengine/Ketsji/KX_GameObject.cpp | 67 +++++++++++++++++----- source/gameengine/Ketsji/KX_GameObject.h | 6 +- source/gameengine/Ketsji/KX_Scene.cpp | 8 +-- source/gameengine/Ketsji/KX_VisibilityActuator.cpp | 8 ++- source/gameengine/Ketsji/KX_VisibilityActuator.h | 2 + 6 files changed, 70 insertions(+), 26 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 321fc325bb8..3142f7652de 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -962,10 +962,9 @@ void BL_ConvertActuators(char* maggiename, bVisibilityActuator *vis_act = (bVisibilityActuator *) bact->data; KX_VisibilityActuator * tmp_vis_act = NULL; bool v = ((vis_act->flag & ACT_VISIBILITY_INVISIBLE) != 0); + bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0); - tmp_vis_act = - new KX_VisibilityActuator(gameobj, - !v); + tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, recursive); baseact = tmp_vis_act; } diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index bec5d188f06..204eed9fa92 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -364,15 +364,36 @@ void KX_GameObject::AddMeshUser() for (size_t i=0;iAddMeshUser(this); - UpdateBuckets(); + UpdateBuckets(false); } -void KX_GameObject::UpdateBuckets() +static void UpdateBuckets_recursive(SG_Node* node) +{ + NodeList& children = node->GetSGChildren(); + + for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit) + { + SG_Node* childnode = (*childit); + KX_GameObject *clientgameobj = static_cast( (*childit)->GetSGClientObject()); + if (clientgameobj != NULL) // This is a GameObject + clientgameobj->UpdateBuckets(0); + + // if the childobj is NULL then this may be an inverse parent link + // so a non recursive search should still look down this node. + UpdateBuckets_recursive(childnode); + } +} + +void KX_GameObject::UpdateBuckets( bool recursive ) { double* fl = GetOpenGLMatrix(); for (size_t i=0;iUpdateBuckets(this, fl, m_bUseObjectColor, m_objectColor, m_bVisible, m_bCulled); + + if (recursive) { + UpdateBuckets_recursive(m_pSGNode); + } } void KX_GameObject::RemoveMeshes() @@ -502,12 +523,33 @@ KX_GameObject::GetVisible( return m_bVisible; } +static void setVisible_recursive(SG_Node* node, bool v) +{ + NodeList& children = node->GetSGChildren(); + + for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit) + { + SG_Node* childnode = (*childit); + KX_GameObject *clientgameobj = static_cast( (*childit)->GetSGClientObject()); + if (clientgameobj != NULL) // This is a GameObject + clientgameobj->SetVisible(v, 0); + + // if the childobj is NULL then this may be an inverse parent link + // so a non recursive search should still look down this node. + setVisible_recursive(childnode, v); + } +} + + void KX_GameObject::SetVisible( - bool v + bool v, + bool recursive ) { m_bVisible = v; + if (recursive) + setVisible_recursive(m_pSGNode, v); } bool @@ -880,7 +922,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_NOARGS}, {"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_O}, {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_NOARGS}, - {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_O}, + {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS}, {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_NOARGS}, {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_O}, {"alignAxisToVect",(PyCFunction) KX_GameObject::sPyAlignAxisToVect, METH_VARARGS}, @@ -1036,8 +1078,8 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr int val = PyInt_AsLong(value); if (attr == "visible") { - SetVisible(val != 0); - UpdateBuckets(); + SetVisible(val != 0, false); + UpdateBuckets(false); return 0; } } @@ -1198,17 +1240,14 @@ PyObject* KX_GameObject::PySetAngularVelocity(PyObject* self, PyObject* args) return NULL; } -PyObject* KX_GameObject::PySetVisible(PyObject* self, PyObject* value) +PyObject* KX_GameObject::PySetVisible(PyObject* self, PyObject* args) { - int visible = PyInt_AsLong(value); - - if (visible==-1 && PyErr_Occurred()) { - PyErr_SetString(PyExc_TypeError, "expected 0 or 1"); + int visible, recursive = 0; + if (!PyArg_ParseTuple(args,"i|i",&visible, &recursive)) return NULL; - } - SetVisible(visible != 0); - UpdateBuckets(); + SetVisible(visible ? true:false, recursive ? true:false); + UpdateBuckets(recursive ? true:false); Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 9dcf6526448..98b3f3b4c3f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -566,6 +566,7 @@ public: */ void UpdateBuckets( + bool recursive ); /** @@ -640,7 +641,8 @@ public: */ void SetVisible( - bool b + bool b, + bool recursive ); /** @@ -762,7 +764,7 @@ public: KX_PYMETHOD_NOARGS(KX_GameObject,GetOrientation); KX_PYMETHOD_O(KX_GameObject,SetOrientation); KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible); - KX_PYMETHOD_O(KX_GameObject,SetVisible); + KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible); KX_PYMETHOD_NOARGS(KX_GameObject,GetState); KX_PYMETHOD_O(KX_GameObject,SetState); KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 2ad0412f1bf..72875bbc039 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1235,7 +1235,7 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi } gameobj->SetCulled(!visible); - gameobj->UpdateBuckets(); + gameobj->UpdateBuckets(false); } } if (node->Left()) @@ -1253,7 +1253,7 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam // Shadow lamp layers if(layer && !(gameobj->GetLayer() & layer)) { gameobj->SetCulled(true); - gameobj->UpdateBuckets(); + gameobj->UpdateBuckets(false); return; } @@ -1300,10 +1300,10 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam // Visibility/ non-visibility are marked // elsewhere now. gameobj->SetCulled(false); - gameobj->UpdateBuckets(); + gameobj->UpdateBuckets(false); } else { gameobj->SetCulled(true); - gameobj->UpdateBuckets(); + gameobj->UpdateBuckets(false); } } diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 5a0cadcbcfe..60ea6ace53b 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -38,10 +38,12 @@ KX_VisibilityActuator::KX_VisibilityActuator( SCA_IObject* gameobj, bool visible, + bool recursive, PyTypeObject* T ) : SCA_IActuator(gameobj,T), - m_visible(visible) + m_visible(visible), + m_recursive(recursive) { // intentionally empty } @@ -75,8 +77,8 @@ KX_VisibilityActuator::Update() KX_GameObject *obj = (KX_GameObject*) GetParent(); - obj->SetVisible(m_visible); - obj->UpdateBuckets(); + obj->SetVisible(m_visible, m_recursive); + obj->UpdateBuckets(m_recursive); return true; } diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h index 9b4753033fb..d1b85ab998c 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.h +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h @@ -39,12 +39,14 @@ class KX_VisibilityActuator : public SCA_IActuator /** Make visible? */ bool m_visible; + bool m_recursive; public: KX_VisibilityActuator( SCA_IObject* gameobj, bool visible, + bool recursive, PyTypeObject* T=&Type ); -- cgit v1.2.3 From e279aadb9721d881167bd978a44a3408c8578def Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 6 Sep 2008 01:18:53 +0000 Subject: Bugfix: game engine could crash with empty display arrays on windows (caused by invisible faces for example). --- .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 36 ++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index e003cdc9368..69a8271d3e8 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -131,19 +131,29 @@ void RAS_MeshSlot::begin(RAS_MeshSlot::iterator& it) int startvertex, endvertex; int startindex, endindex; - it.array = m_displayArrays[m_startarray]; - - startvertex = m_startvertex; - endvertex = (m_startarray == m_endarray)? m_endvertex: it.array->m_vertex.size(); - startindex = m_startindex; - endindex = (m_startarray == m_endarray)? m_endindex: it.array->m_index.size(); - - it.vertex = &it.array->m_vertex[0]; - it.index = &it.array->m_index[startindex]; - it.startvertex = startvertex; - it.endvertex = endvertex; - it.totindex = endindex-startindex; - it.arraynum = m_startarray; + it.array = (m_displayArrays.size() > 0)? m_displayArrays[m_startarray]: NULL; + + if(it.array == NULL || it.array->m_index.size() == 0 || it.array->m_vertex.size() == 0) { + it.array = NULL; + it.vertex = NULL; + it.index = NULL; + it.startvertex = 0; + it.endvertex = 0; + it.totindex = 0; + } + else { + startvertex = m_startvertex; + endvertex = (m_startarray == m_endarray)? m_endvertex: it.array->m_vertex.size(); + startindex = m_startindex; + endindex = (m_startarray == m_endarray)? m_endindex: it.array->m_index.size(); + + it.vertex = &it.array->m_vertex[0]; + it.index = &it.array->m_index[startindex]; + it.startvertex = startvertex; + it.endvertex = endvertex; + it.totindex = endindex-startindex; + it.arraynum = m_startarray; + } } void RAS_MeshSlot::next(RAS_MeshSlot::iterator& it) -- cgit v1.2.3 From 8675ff6d1dc4d5b9967aa825e5dc23620a0179bb Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Sat, 6 Sep 2008 02:46:11 +0000 Subject: Trying to keep things compiling on my imac (10.4.11) I'm getting this error now: GPG_Application.cpp: In member function 'void GPG_Application::stopEngine()': /System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3/marshal.h:12: error: too many arguments to function 'PyObject* PyMarshal_WriteObjectToString(PyObject*)' GPG_Application.cpp:720: error: at this point in file Are we offically not supporint older versions of python now? :) Kent --- source/gameengine/Converter/BL_ActionActuator.cpp | 1 + source/gameengine/Converter/BL_ShapeActionActuator.cpp | 2 ++ source/gameengine/Converter/Makefile | 1 + source/gameengine/Expressions/Makefile | 2 ++ source/gameengine/Expressions/PyObjectPlus.cpp | 1 + source/gameengine/GameLogic/Makefile | 2 ++ source/gameengine/GameLogic/SCA_ILogicBrick.cpp | 1 + source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 2 ++ source/gameengine/GameLogic/SCA_PythonController.cpp | 2 ++ source/gameengine/Ketsji/BL_Shader.cpp | 2 ++ source/gameengine/Ketsji/KX_CameraActuator.cpp | 2 ++ source/gameengine/Ketsji/KX_ConstraintWrapper.cpp | 1 + source/gameengine/Ketsji/KX_GameObject.cpp | 2 ++ source/gameengine/Ketsji/KX_MeshProxy.cpp | 2 ++ source/gameengine/Ketsji/KX_ParentActuator.cpp | 2 ++ source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp | 2 ++ source/gameengine/Ketsji/KX_PyConstraintBinding.cpp | 2 ++ source/gameengine/Ketsji/KX_PythonInit.cpp | 2 ++ source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 2 ++ source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp | 2 ++ source/gameengine/Ketsji/KX_TrackToActuator.cpp | 2 ++ source/gameengine/Ketsji/KX_VehicleWrapper.cpp | 2 ++ 22 files changed, 39 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index d8b2e063a9d..13c25188753 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -50,6 +50,7 @@ #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" #include "FloatValue.h" +#include "gen_utils.h" /* Python stuff */ #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 799b6b74b66..06a9db866d4 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -50,6 +50,8 @@ #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" +#include "gen_utils.h" /* python stuff */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile index 4dd63e428bd..9bd8ae4fc7b 100644 --- a/source/gameengine/Converter/Makefile +++ b/source/gameengine/Converter/Makefile @@ -39,6 +39,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) +CPPFLAGS += -I../../blender/python/api2_2x CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_SOLID)/include CPPFLAGS += -I$(NAN_BULLET2)/include diff --git a/source/gameengine/Expressions/Makefile b/source/gameengine/Expressions/Makefile index e9c02eedcf2..f333de68be0 100644 --- a/source/gameengine/Expressions/Makefile +++ b/source/gameengine/Expressions/Makefile @@ -36,6 +36,8 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) +CPPFLAGS += -I../../blender/python/api2_2x +CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 1eca527151a..3dfa1b0da3d 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -50,6 +50,7 @@ #include "stdlib.h" #include "PyObjectPlus.h" #include "STR_String.h" +#include "gen_utils.h" /*------------------------------ * PyObjectPlus Type -- Every class, even the abstract one should have a Type ------------------------------*/ diff --git a/source/gameengine/GameLogic/Makefile b/source/gameengine/GameLogic/Makefile index b3eae5d67dc..564e9b16b55 100644 --- a/source/gameengine/GameLogic/Makefile +++ b/source/gameengine/GameLogic/Makefile @@ -42,7 +42,9 @@ CPPFLAGS += -I../Expressions CPPFLAGS += -I../Rasterizer CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include +CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) +CPPFLAGS += -I../../blender/python/api2_2x CPPFLAGS += $(NAN_SDLCFLAGS) CPPFLAGS += -I../../kernel/gen_system diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index f5512664d8f..1c446bc87c4 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -27,6 +27,7 @@ */ #include "SCA_ILogicBrick.h" +#include "gen_utils.h" /* python stuff */ #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 645afc8964b..2d42d64abe3 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -32,6 +32,8 @@ #include +#include "gen_utils.h" /* python stuff */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index e6f7b1dd143..6ba4456bddd 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -37,6 +37,8 @@ #include "eval.h" #include +#include "gen_utils.h" /* python stuff */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index f28d3fa2912..f4a4194edfe 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -15,6 +15,8 @@ #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" +#include "gen_utils.h" /* python stuff */ + #define spit(x) std::cout << x << std::endl; #define SORT_UNIFORMS 1 diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 42b909927fd..8f037a93f6a 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -35,6 +35,8 @@ #include #include "KX_GameObject.h" +#include "gen_utils.h" /* Python stuff */ + STR_String KX_CameraActuator::X_AXIS_STRING = "x"; STR_String KX_CameraActuator::Y_AXIS_STRING = "y"; diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index b54da6eb753..9cb859be30d 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -27,6 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ #include +#include "gen_utils.h" #include "KX_ConstraintWrapper.h" #include "PHY_IPhysicsEnvironment.h" diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 204eed9fa92..0ca823e148f 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -65,6 +65,8 @@ typedef unsigned long uint_ptr; #include "SCA_IActuator.h" #include "SCA_ISensor.h" +#include "gen_utils.h" /* python stuff */ + // This file defines relationships between parents and children // in the game engine. diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 5bfe8c70cba..e420a208ffd 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -43,6 +43,8 @@ #include "KX_PyMath.h" #include "KX_ConvertPhysicsObject.h" +#include "gen_utils.h" /* Python stuff */ + PyTypeObject KX_MeshProxy::Type = { PyObject_HEAD_INIT(&PyType_Type) 0, diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 344e0fccc35..58000062dcf 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -36,6 +36,8 @@ #include "KX_GameObject.h" #include "KX_PythonInit.h" +#include "gen_utils.h" /* Python stuff */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index 9291199d859..cd76e00a2e3 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -27,6 +27,8 @@ * ***** END GPL LICENSE BLOCK ***** */ #include +#include "gen_utils.h" + #include "KX_PhysicsObjectWrapper.h" #include "PHY_IPhysicsEnvironment.h" #include "PHY_IPhysicsController.h" diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 26243c7dba1..83695a9f4c3 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -34,6 +34,8 @@ #include "PHY_IPhysicsController.h" #include "PHY_IVehicle.h" +#include "gen_utils.h" /* Python stuff */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index f2902d0ef01..c89e4cbd831 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -68,6 +68,8 @@ #include "KX_PyMath.h" +#include "gen_utils.h" /* Python stuff */ + extern "C" { #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. } diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index a7330b9a20a..579ad94206b 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -39,6 +39,8 @@ #include "KX_GameObject.h" #include "KX_IPhysicsController.h" +#include "gen_utils.h" /* Python stuff */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 18a297d6c92..383347684cb 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -37,6 +37,8 @@ #include "KX_SCA_ReplaceMeshActuator.h" +#include "gen_utils.h" /* Python stuff */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 67937d5c579..962ca93c018 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -42,6 +42,8 @@ #include #include "KX_GameObject.h" +#include "gen_utils.h" /* Python stuff */ + #ifdef HAVE_CONFIG_H #include #endif diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index f5a2b5e02fe..9131afda5dd 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -1,6 +1,8 @@ #include +#include "gen_utils.h" + #include "KX_VehicleWrapper.h" #include "PHY_IPhysicsEnvironment.h" #include "PHY_IVehicle.h" -- cgit v1.2.3 From 115cf18bed42d590545d83c73438dc826120313a Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Sat, 6 Sep 2008 14:13:31 +0000 Subject: converted my gen_utils.h fix to PyObjectPlus.h Also added a fix for PyMarshal_WriteObjectToString Now I just need to figure out linking of the gameengine on my imac. Kent --- source/gameengine/Converter/BL_ActionActuator.cpp | 2 +- .../Converter/BL_ShapeActionActuator.cpp | 3 +-- source/gameengine/Converter/Makefile | 1 - source/gameengine/Expressions/Makefile | 1 - source/gameengine/Expressions/PyObjectPlus.cpp | 1 - source/gameengine/Expressions/PyObjectPlus.h | 27 ++++++++++++++++++++++ source/gameengine/GameLogic/Makefile | 1 - source/gameengine/GameLogic/SCA_ILogicBrick.cpp | 2 +- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 3 ++- .../gameengine/GameLogic/SCA_PythonController.cpp | 2 +- .../GamePlayer/ghost/GPG_Application.cpp | 4 ++++ source/gameengine/Ketsji/BL_Shader.cpp | 2 -- source/gameengine/Ketsji/KX_CameraActuator.cpp | 2 +- source/gameengine/Ketsji/KX_ConstraintWrapper.cpp | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- source/gameengine/Ketsji/KX_MeshProxy.cpp | 2 +- source/gameengine/Ketsji/KX_ParentActuator.cpp | 2 +- .../gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp | 2 +- .../gameengine/Ketsji/KX_PyConstraintBinding.cpp | 2 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 2 +- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 2 +- .../Ketsji/KX_SCA_ReplaceMeshActuator.cpp | 2 +- source/gameengine/Ketsji/KX_TrackToActuator.cpp | 2 +- source/gameengine/Ketsji/KX_VehicleWrapper.cpp | 2 +- 24 files changed, 49 insertions(+), 24 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 13c25188753..119465c8726 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -50,7 +50,7 @@ #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" #include "FloatValue.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 06a9db866d4..679b0df7ec6 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -49,8 +49,7 @@ #include "BLI_arithb.h" #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" - -#include "gen_utils.h" /* python stuff */ +#include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile index 9bd8ae4fc7b..4dd63e428bd 100644 --- a/source/gameengine/Converter/Makefile +++ b/source/gameengine/Converter/Makefile @@ -39,7 +39,6 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -CPPFLAGS += -I../../blender/python/api2_2x CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include CPPFLAGS += -I$(NAN_SOLID)/include CPPFLAGS += -I$(NAN_BULLET2)/include diff --git a/source/gameengine/Expressions/Makefile b/source/gameengine/Expressions/Makefile index f333de68be0..6736149bbcd 100644 --- a/source/gameengine/Expressions/Makefile +++ b/source/gameengine/Expressions/Makefile @@ -36,7 +36,6 @@ include nan_compile.mk CCFLAGS += $(LEVEL_1_CPP_WARNINGS) CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -CPPFLAGS += -I../../blender/python/api2_2x CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I$(NAN_STRING)/include diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 3dfa1b0da3d..1eca527151a 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -50,7 +50,6 @@ #include "stdlib.h" #include "PyObjectPlus.h" #include "STR_String.h" -#include "gen_utils.h" /*------------------------------ * PyObjectPlus Type -- Every class, even the abstract one should have a Type ------------------------------*/ diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 65cd4e890f7..ccc9af2ed79 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -43,6 +43,33 @@ * Python defines ------------------------------*/ +/* + Py_RETURN_NONE + Python 2.4 macro. + defined here until we switch to 2.4 + also in api2_2x/gen_utils.h +*/ +#ifndef Py_RETURN_NONE +#define Py_RETURN_NONE return Py_BuildValue("O", Py_None) +#endif +#ifndef Py_RETURN_FALSE +#define Py_RETURN_FALSE return PyBool_FromLong(0) +#endif +#ifndef Py_RETURN_TRUE +#define Py_RETURN_TRUE return PyBool_FromLong(1) +#endif + +/* for pre Py 2.5 */ +#if PY_VERSION_HEX < 0x02050000 +typedef int Py_ssize_t; +#define PY_SSIZE_T_MAX INT_MAX +#define PY_SSIZE_T_MIN INT_MIN +#else +/* Py 2.5 and later */ +#define intargfunc ssizeargfunc +#define intintargfunc ssizessizeargfunc +#endif + // some basic python macros #define Py_Return { Py_INCREF(Py_None); return Py_None;} diff --git a/source/gameengine/GameLogic/Makefile b/source/gameengine/GameLogic/Makefile index 564e9b16b55..355ece6e8bd 100644 --- a/source/gameengine/GameLogic/Makefile +++ b/source/gameengine/GameLogic/Makefile @@ -44,7 +44,6 @@ CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../blender/makesdna CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -CPPFLAGS += -I../../blender/python/api2_2x CPPFLAGS += $(NAN_SDLCFLAGS) CPPFLAGS += -I../../kernel/gen_system diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index 1c446bc87c4..abd049e9d64 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -27,7 +27,7 @@ */ #include "SCA_ILogicBrick.h" -#include "gen_utils.h" /* python stuff */ +#include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 2d42d64abe3..403fbfe6f4c 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -30,9 +30,10 @@ #include "SCA_EventManager.h" #include "SCA_LogicManager.h" +#include "PyObjectPlus.h" + #include -#include "gen_utils.h" /* python stuff */ #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 6ba4456bddd..6e9a0a7c6b6 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -33,11 +33,11 @@ #include "SCA_LogicManager.h" #include "SCA_ISensor.h" #include "SCA_IActuator.h" +#include "PyObjectPlus.h" #include "compile.h" #include "eval.h" #include -#include "gen_utils.h" /* python stuff */ #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index a690beb9f38..806216e05bb 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -717,7 +717,11 @@ void GPG_Application::stopEngine() if (gameLogic) { PyObject* pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module if (pyGlobalDict) { +#ifdef Py_MARSHAL_VERSION PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5 +#else + PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict ); +#endif if (pyGlobalDictMarshal) { m_pyGlobalDictString_Length = PyString_Size(pyGlobalDictMarshal); PyObject_Print(pyGlobalDictMarshal, stderr, 0); diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index f4a4194edfe..f28d3fa2912 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -15,8 +15,6 @@ #include "RAS_MeshObject.h" #include "RAS_IRasterizer.h" -#include "gen_utils.h" /* python stuff */ - #define spit(x) std::cout << x << std::endl; #define SORT_UNIFORMS 1 diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 8f037a93f6a..4948c0ea174 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -35,7 +35,7 @@ #include #include "KX_GameObject.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" STR_String KX_CameraActuator::X_AXIS_STRING = "x"; STR_String KX_CameraActuator::Y_AXIS_STRING = "y"; diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index 9cb859be30d..c9095ff34f6 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -27,7 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ #include -#include "gen_utils.h" +#include "PyObjectPlus.h" #include "KX_ConstraintWrapper.h" #include "PHY_IPhysicsEnvironment.h" diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 0ca823e148f..27a955b3105 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -65,7 +65,7 @@ typedef unsigned long uint_ptr; #include "SCA_IActuator.h" #include "SCA_ISensor.h" -#include "gen_utils.h" /* python stuff */ +#include "PyObjectPlus.h" /* python stuff */ // This file defines relationships between parents and children // in the game engine. diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index e420a208ffd..5cc102248f2 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -43,7 +43,7 @@ #include "KX_PyMath.h" #include "KX_ConvertPhysicsObject.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" PyTypeObject KX_MeshProxy::Type = { PyObject_HEAD_INIT(&PyType_Type) diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 58000062dcf..3ca121f63f8 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -36,7 +36,7 @@ #include "KX_GameObject.h" #include "KX_PythonInit.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp index cd76e00a2e3..da4f05ced7c 100644 --- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp +++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp @@ -27,7 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ #include -#include "gen_utils.h" +#include "PyObjectPlus.h" #include "KX_PhysicsObjectWrapper.h" #include "PHY_IPhysicsEnvironment.h" diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index 83695a9f4c3..ac63e3fade5 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -34,7 +34,7 @@ #include "PHY_IPhysicsController.h" #include "PHY_IVehicle.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index c89e4cbd831..fe6294e7626 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -68,7 +68,7 @@ #include "KX_PyMath.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" extern "C" { #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index 579ad94206b..c4c190e9fa1 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -39,7 +39,7 @@ #include "KX_GameObject.h" #include "KX_IPhysicsController.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 383347684cb..e1f11732085 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -37,7 +37,7 @@ #include "KX_SCA_ReplaceMeshActuator.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 962ca93c018..8b09cd4e953 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -42,7 +42,7 @@ #include #include "KX_GameObject.h" -#include "gen_utils.h" /* Python stuff */ +#include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H #include diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index 9131afda5dd..342e71c5093 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -1,7 +1,7 @@ #include -#include "gen_utils.h" +#include "PyObjectPlus.h" #include "KX_VehicleWrapper.h" #include "PHY_IPhysicsEnvironment.h" -- cgit v1.2.3 From c7fe2199a736eff39fba5e5400a150511815525d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 6 Sep 2008 17:04:54 +0000 Subject: object_find, didnt get images from an objects material textures KX_PythonInit.cpp - own error in recent commit. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index fe6294e7626..eb0052d71ff 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -696,7 +696,7 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, char *setting; int enable, flag; - if (PyArg_ParseTuple(args,"si",&setting,&enable)) + if (!PyArg_ParseTuple(args,"si",&setting,&enable)) return NULL; flag = getGLSLSettingFlag(setting); -- cgit v1.2.3 From 667c8d83fb5ec719ac9d8944f37ed796f06ae2f0 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 6 Sep 2008 22:06:01 +0000 Subject: BGE patch: break parent relationship when child and parent are not active/inactive at the same time. This unusual situation is used in Apricot for test purposes. --- .../Converter/BL_BlenderDataConversion.cpp | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index def4938b053..15e65ac9fe5 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2144,7 +2144,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie, gameobj->NodeUpdateGS(0,true); gameobj->AddMeshUser(); - } else { @@ -2209,6 +2208,24 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { struct Object* blenderchild = pcit->m_blenderchild; + struct Object* blenderparent = blenderchild->parent; + KX_GameObject* parentobj = converter->FindGameObject(blenderparent); + KX_GameObject* childobj = converter->FindGameObject(blenderchild); + + assert(childobj); + + if (!parentobj || objectlist->SearchValue(childobj) != objectlist->SearchValue(parentobj)) + { + // special case: the parent and child object are not in the same layer. + // This weird situation is used in Apricot for test purposes. + // Resolve it by breaking the parent relationship + childobj->GetSGNode()->DisconnectFromParent(); + delete pcit->m_gamechildnode; + // This leave the child object is an incorrect position: its local position becomes + // the global position but we don't care: the child should be in an invisble layer + continue; + } + switch (blenderchild->partype) { case PARVERT1: @@ -2248,12 +2265,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, break; } - struct Object* blenderparent = blenderchild->parent; - KX_GameObject* parentobj = converter->FindGameObject(blenderparent); - if (parentobj) - { - parentobj-> GetSGNode()->AddChild(pcit->m_gamechildnode); - } + parentobj-> GetSGNode()->AddChild(pcit->m_gamechildnode); } vec_parent_child.clear(); -- cgit v1.2.3 From 0bf03ef2f16870aa7a86c33accb4ba69de50c256 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 7 Sep 2008 10:47:33 +0000 Subject: BGE patch: Simulate dupligroup operation when parent and child are not active/inactive at the same time: don't convert the child. This unusual situation is used in Apricot for testing. --- .../Converter/BL_BlenderDataConversion.cpp | 23 +++++++++++++++++++--- .../Converter/KX_BlenderSceneConverter.cpp | 12 ++++++++++- 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 15e65ac9fe5..05d4f45b634 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2218,11 +2218,28 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { // special case: the parent and child object are not in the same layer. // This weird situation is used in Apricot for test purposes. - // Resolve it by breaking the parent relationship + // Resolve it by not converting the child childobj->GetSGNode()->DisconnectFromParent(); delete pcit->m_gamechildnode; - // This leave the child object is an incorrect position: its local position becomes - // the global position but we don't care: the child should be in an invisble layer + // Now destroy the child object but also all its descendent that may already be linked + // Remove the child reference in the local list! + // Note: there may be descendents already if the children of the child were processed + // by this loop before the child. In that case, we must remove the children also + CListValue* childrenlist = (CListValue*)childobj->PyGetChildrenRecursive(childobj); + childrenlist->Add(childobj->AddRef()); + for ( i=0;iGetCount();i++) + { + KX_GameObject* obj = static_cast(childrenlist->GetValue(i)); + if (templist->RemoveValue(obj)) + obj->Release(); + if (sumolist->RemoveValue(obj)) + obj->Release(); + if (logicbrick_conversionlist->RemoveValue(obj)) + obj->Release(); + } + childrenlist->Release(); + // now destroy recursively + kxscene->RemoveObject(childobj); continue; } diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 1f5b578d441..4734b84de54 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -496,7 +496,17 @@ void KX_BlenderSceneConverter::RegisterGameObject( void KX_BlenderSceneConverter::UnregisterGameObject( KX_GameObject *gameobject) { - m_map_gameobject_to_blender.remove(CHashedPtr(gameobject)); + CHashedPtr gptr(gameobject); + struct Object **bobp= m_map_gameobject_to_blender[gptr]; + if (bobp) { + CHashedPtr bptr(*bobp); + KX_GameObject **gobp= m_map_blender_to_gameobject[bptr]; + if (gobp && *gobp == gameobject) + // also maintain m_map_blender_to_gameobject if the gameobject + // being removed is matching the blender object + m_map_blender_to_gameobject.remove(bptr); + m_map_gameobject_to_blender.remove(gptr); + } } -- cgit v1.2.3 From f3fc5a8b6103f7f8b256fdceee8412e0182a5a8f Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 7 Sep 2008 19:58:37 +0000 Subject: BGE bug #17574 fixed: GE Text input doesn't register in 2.47. Force registration of keyboard sensor with no link as this is typically the setting for key logging. --- source/gameengine/Converter/KX_ConvertSensors.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 74819431858..f16855955ff 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -781,6 +781,13 @@ void BL_ConvertSensors(struct Object* blenderobject, "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2); } } + // special case: Keyboard sensor with no link + // this combination is usually used for key logging. + if (sens->type == SENS_KEYBOARD && sens->totlinks == 0) { + // Force the registration so that the sensor runs + gamesensor->IncLink(); + } + // done with gamesensor gamesensor->Release(); -- cgit v1.2.3 From f305bb22b7e5f809063539cdb76a24727f41a11a Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 9 Sep 2008 21:15:30 +0000 Subject: Patch 17508: Blender Web Plugin - XEmbed. Enable XEmbed integration of blenderplayer, using -i as input parameter to pass embedder window id. create a minimal web plugin to embed blenderplayer on web pages (using gecko/mozilla as browser). Only for *nix. --- source/gameengine/GamePlayer/CMakeLists.txt | 4 ++++ .../GamePlayer/ghost/GPG_Application.cpp | 25 ++++++++++++++++++++-- .../gameengine/GamePlayer/ghost/GPG_Application.h | 3 +++ source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 21 +++++++++++++++++- 4 files changed, 50 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/CMakeLists.txt b/source/gameengine/GamePlayer/CMakeLists.txt index ff1040bfb40..fc5912155cf 100644 --- a/source/gameengine/GamePlayer/CMakeLists.txt +++ b/source/gameengine/GamePlayer/CMakeLists.txt @@ -25,3 +25,7 @@ # ***** END GPL LICENSE BLOCK ***** SUBDIRS(common ghost) + +IF(WITH_WEBPLUGIN) + SUBDIRS(xembed) +ENDIF(WITH_WEBPLUGIN) diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 806216e05bb..3d9ae66c9ea 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -129,7 +129,8 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) m_blendermat(0), m_blenderglslmat(0), m_pyGlobalDictString(0), - m_pyGlobalDictString_Length(0) + m_pyGlobalDictString_Length(0), + m_isEmbedded(false) { fSystem = system; } @@ -325,6 +326,26 @@ bool GPG_Application::startWindow(STR_String& title, return success; } +bool GPG_Application::startEmbeddedWindow(STR_String& title, + const GHOST_TEmbedderWindowID parentWindow, + const bool stereoVisual, + const int stereoMode) { + + m_mainWindow = fSystem->createWindow(title, 0, 0, 0, 0, GHOST_kWindowStateNormal, + GHOST_kDrawingContextTypeOpenGL, stereoVisual, parentWindow); + + if (!m_mainWindow) { + printf("error: could not create main window\n"); + exit(-1); + } + m_isEmbedded = true; + + bool success = initEngine(m_mainWindow, stereoMode); + if (success) { + success = startEngine(); + } + return success; +} bool GPG_Application::startFullScreen( @@ -887,7 +908,7 @@ bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown) GHOST_TEventKeyData* keyData = static_cast(eventData); //no need for this test //if (fSystem->getFullScreen()) { - if (keyData->key == GHOST_kKeyEsc && !m_keyboard->m_hookesc) { + if (keyData->key == GHOST_kKeyEsc && !m_keyboard->m_hookesc && !m_isEmbedded) { m_exitRequested = KX_EXIT_REQUEST_OUTSIDE; } //} diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 5242a419808..7fc369fc0fd 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -62,6 +62,7 @@ public: bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight, const bool stereoVisual, const int stereoMode); bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode); + bool startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parent_window, const bool stereoVisual, const int stereoMode); #ifdef WIN32 bool startScreenSaverFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode); bool startScreenSaverPreview(HWND parentWindow, const bool stereoVisual, const int stereoMode); @@ -143,6 +144,8 @@ protected: bool m_engineInitialized; /** Engine state. */ bool m_engineRunning; + /** Running on embedded window */ + bool m_isEmbedded; /** the gameengine itself */ KX_KetsjiEngine* m_ketsjiengine; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index cc781a38bbb..d44e983af89 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -178,6 +178,9 @@ void usage(char* program) printf(" anaglyph (Red-Blue glasses)\n"); printf(" vinterlace (Vertical interlace for autostereo display)\n"); printf(" depending on the type of stereo you want\n"); +#ifndef _WIN32 + printf(" -i: parent windows ID \n"); +#endif #ifdef _WIN32 printf(" -c: keep console window open\n"); #endif @@ -297,6 +300,9 @@ int main(int argc, char** argv) int fullScreenFrequency = 60; char* pyGlobalDictString = NULL; /* store python dict data between blend file loading */ int pyGlobalDictString_Length = 0; + GHOST_TEmbedderWindowID parentWindow = 0; + + #ifdef __linux__ #ifdef __alpha__ @@ -457,6 +463,16 @@ int main(int argc, char** argv) usage(argv[0]); return 0; break; +#ifndef _WIN32 + case 'i': + i++; + if ( (i + 1) < argc ) + parentWindow = atoi(argv[i++]); +#ifndef NDEBUG + printf("XWindows ID = %d\n", parentWindow); +#endif //NDEBUG + +#endif // _WIN32 case 'c': i++; closeConsole = false; @@ -729,7 +745,10 @@ int main(int argc, char** argv) else #endif { - app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight, + if (parentWindow != 0) + app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode); + else + app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight, stereoWindow, stereomode); } } -- cgit v1.2.3 From 74ab278d46bd3784da769d3e3460750ad279cf02 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 9 Sep 2008 22:40:10 +0000 Subject: BGE bug #17549: fix crash on removeParent() with static mesh. Fix scaling bug on setParent(). Add python setWorldPosition() to allow setting object position in world coordinate regardless if it is a root or a child object. --- source/gameengine/Ketsji/KX_GameObject.cpp | 23 ++++++++++++++++++---- source/gameengine/Ketsji/KX_GameObject.h | 1 + .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 5 +++-- source/gameengine/PyDoc/KX_GameObject.py | 11 ++++++++++- 4 files changed, 33 insertions(+), 7 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 27a955b3105..0e5956d4fdb 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -235,11 +235,12 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) m_pPhysicsController1->SuspendDynamics(true); } // Set us to our new scale, position, and orientation - scale1[0] = scale1[0]/scale2[0]; - scale1[1] = scale1[1]/scale2[1]; - scale1[2] = scale1[2]/scale2[2]; + scale2[0] = 1.0/scale2[0]; + scale2[1] = 1.0/scale2[1]; + scale2[2] = 1.0/scale2[2]; + scale1 = scale1 * scale2; MT_Matrix3x3 invori = obj->NodeGetWorldOrientation().inverse(); - MT_Vector3 newpos = invori*(NodeGetWorldPosition()-obj->NodeGetWorldPosition())*scale1; + MT_Vector3 newpos = invori*(NodeGetWorldPosition()-obj->NodeGetWorldPosition())*scale2; NodeSetLocalScale(scale1); NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2])); @@ -914,6 +915,7 @@ void KX_GameObject::Suspend() PyMethodDef KX_GameObject::Methods[] = { {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_NOARGS}, {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_O}, + {"setWorldPosition", (PyCFunction) KX_GameObject::sPySetWorldPosition, METH_O}, {"getLinearVelocity", (PyCFunction) KX_GameObject::sPyGetLinearVelocity, METH_VARARGS}, {"setLinearVelocity", (PyCFunction) KX_GameObject::sPySetLinearVelocity, METH_VARARGS}, {"getAngularVelocity", (PyCFunction) KX_GameObject::sPyGetAngularVelocity, METH_VARARGS}, @@ -1576,6 +1578,19 @@ PyObject* KX_GameObject::PySetPosition(PyObject* self, PyObject* value) return NULL; } +PyObject* KX_GameObject::PySetWorldPosition(PyObject* self, PyObject* value) +{ + MT_Point3 pos; + if (PyVecTo(value, pos)) + { + NodeSetWorldPosition(pos); + NodeUpdateGS(0.f,true); + Py_RETURN_NONE; + } + + return NULL; +} + PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self) { KX_IPhysicsController* ctrl = GetPhysicsController(); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 98b3f3b4c3f..2da0be4df25 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -754,6 +754,7 @@ public: KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition); KX_PYMETHOD_O(KX_GameObject,SetPosition); + KX_PYMETHOD_O(KX_GameObject,SetWorldPosition); KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity); KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity); KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index d14ddf8f65c..d3b83a74439 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -452,11 +452,12 @@ void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctr // this function is used when the collisionning group of a controller is changed // remove and add the collistioning object btRigidBody* body = ctrl->GetRigidBody(); - btVector3 inertia; + btVector3 inertia(0.0,0.0,0.0); m_dynamicsWorld->removeCollisionObject(body); body->setCollisionFlags(newCollisionFlags); - body->getCollisionShape()->calculateLocalInertia(newMass, inertia); + if (newMass) + body->getCollisionShape()->calculateLocalInertia(newMass, inertia); body->setMassProps(newMass, inertia); m_dynamicsWorld->addCollisionObject(body, newCollisionGroup, newCollisionMask); // to avoid nasty interaction, we must update the property of the controller as well diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 9729b14a43f..ff9b4ffc95b 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -58,7 +58,16 @@ class KX_GameObject: """ def setPosition(pos): """ - Sets the game object's position. + Sets the game object's position. + Global coordinates for root object, local for child objects. + + + @type pos: [x, y, z] + @param pos: the new position, in local coordinates. + """ + def setWorldPosition(pos): + """ + Sets the game object's position in world coordinates regardless if the object is root or child. @type pos: [x, y, z] @param pos: the new position, in world coordinates. -- cgit v1.2.3 From 75078d62df5ee8186369b5f1273b61b0736346ec Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 10 Sep 2008 09:51:06 +0000 Subject: Fix for bug #17589: removing a lamp in the game engine with glsl materials did not work correct. --- source/gameengine/Ketsji/KX_Light.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 979015532e3..e0f171e78e0 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -65,6 +65,13 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, KX_LightObject::~KX_LightObject() { + GPULamp *lamp; + + if((lamp = GetGPULamp())) { + float obmat[4][4] = {{0}}; + GPU_lamp_update(lamp, 0, obmat); + } + m_rendertools->RemoveLight(&m_lightobj); } -- cgit v1.2.3 From dca6bd87efd2037f070fa9694e6a8e738cb4bb2c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 10 Sep 2008 22:49:11 +0000 Subject: removed debug print --- source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 3d9ae66c9ea..f35e2894f65 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -745,7 +745,8 @@ void GPG_Application::stopEngine() #endif if (pyGlobalDictMarshal) { m_pyGlobalDictString_Length = PyString_Size(pyGlobalDictMarshal); - PyObject_Print(pyGlobalDictMarshal, stderr, 0); + // for testing only + // PyObject_Print(pyGlobalDictMarshal, stderr, 0); m_pyGlobalDictString = static_cast (malloc(m_pyGlobalDictString_Length)); memcpy(m_pyGlobalDictString, PyString_AsString(pyGlobalDictMarshal), m_pyGlobalDictString_Length); } else { -- cgit v1.2.3 From 729af67742c3296ee3214c1e4981e4b689d57477 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 11 Sep 2008 13:00:54 +0000 Subject: Bugfix: saved game engine runtimes failed to load library .blend files with relative paths. --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index d44e983af89..3a9e59c3c25 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -613,7 +613,7 @@ int main(int argc, char** argv) } else { - bfd = load_game_data(argv[0], filename); + bfd = load_game_data(bprogname, filename); } //::printf("game data loaded from %s\n", filename); -- cgit v1.2.3 From 97178fecd942ec6418156ef033a67c1d1ee67539 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 11 Sep 2008 14:58:13 +0000 Subject: BGE message python api could return a CList type or None which makes exception checks annoying. just return an empty CList rather then None. --- .../Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 68 ++++++++-------------- .../Ketsji/KXNetwork/KX_NetworkMessageSensor.h | 10 ++-- 2 files changed, 28 insertions(+), 50 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 0c66ac1fde3..a35ab8b15e8 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -196,19 +196,19 @@ PyParentObject KX_NetworkMessageSensor::Parents[] = { PyMethodDef KX_NetworkMessageSensor::Methods[] = { {"setSubjectFilterText", (PyCFunction) - KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_VARARGS, + KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_O, SetSubjectFilterText_doc}, {"getFrameMessageCount", (PyCFunction) - KX_NetworkMessageSensor::sPyGetFrameMessageCount, METH_VARARGS, + KX_NetworkMessageSensor::sPyGetFrameMessageCount, METH_NOARGS, GetFrameMessageCount_doc}, {"getBodies", (PyCFunction) - KX_NetworkMessageSensor::sPyGetBodies, METH_VARARGS, + KX_NetworkMessageSensor::sPyGetBodies, METH_NOARGS, GetBodies_doc}, {"getSubject", (PyCFunction) - KX_NetworkMessageSensor::sPyGetSubject, METH_VARARGS, + KX_NetworkMessageSensor::sPyGetSubject, METH_NOARGS, GetSubject_doc}, {"getSubjects", (PyCFunction) - KX_NetworkMessageSensor::sPyGetSubjects, METH_VARARGS, + KX_NetworkMessageSensor::sPyGetSubjects, METH_NOARGS, GetSubjects_doc}, {NULL,NULL} //Sentinel }; @@ -222,22 +222,16 @@ char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] = "\tsetSubjectFilterText(value)\n" "\tChange the message subject text that this sensor is listening to.\n"; -PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText( - PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText( PyObject* self, PyObject* value) { - char* Subject; - - if (PyArg_ParseTuple(args, "s", &Subject)) - { - m_subject = Subject; - } - else { + char* Subject = PyString_AsString(value); + if (Subject==NULL) { + PyErr_SetString(PyExc_TypeError, "expected a string message"); return NULL; } - - Py_Return; + + m_subject = Subject; + Py_RETURN_NONE; } // 2. Get the number of messages received since the last frame @@ -245,10 +239,7 @@ char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] = "\tgetFrameMessageCount()\n" "\tGet the number of messages received since the last frame.\n"; -PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount( - PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount( PyObject* ) { return PyInt_FromLong(long(m_frame_message_count)); } @@ -258,16 +249,13 @@ char KX_NetworkMessageSensor::GetBodies_doc[] = "\tgetBodies()\n" "\tGet the list of message bodies.\n"; -PyObject* KX_NetworkMessageSensor::PyGetBodies( - PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_NetworkMessageSensor::PyGetBodies( PyObject* ) { if (m_BodyList) { return ((PyObject*) m_BodyList->AddRef()); + } else { + return ((PyObject*) new CListValue()); } - - Py_Return; } // 4. Get the message subject: field of the message sensor @@ -275,16 +263,9 @@ char KX_NetworkMessageSensor::GetSubject_doc[] = "\tgetSubject()\n" "\tGet the subject: field of the message sensor.\n"; -PyObject* KX_NetworkMessageSensor::PyGetSubject( - PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_NetworkMessageSensor::PyGetSubject( PyObject* ) { - if (m_subject) { - return PyString_FromString(m_subject); - } - - Py_Return; + return PyString_FromString(m_subject ? m_subject : ""); } // 5. Get the message subjects @@ -292,14 +273,11 @@ char KX_NetworkMessageSensor::GetSubjects_doc[] = "\tgetSubjects()\n" "\tGet list of message subjects.\n"; -PyObject* KX_NetworkMessageSensor::PyGetSubjects( - PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_NetworkMessageSensor::PyGetSubjects( PyObject* ) { if (m_SubjectList) { - return ((PyObject*) m_SubjectList->AddRef()); - } - - Py_Return; + return ((PyObject*) m_SubjectList->AddRef()); + } else { + return ((PyObject*) new CListValue()); + } } diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h index 6fd92d17be3..8cdfd6cdb5a 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h @@ -74,11 +74,11 @@ public: virtual PyObject* _getattr(const STR_String& attr); - KX_PYMETHOD_DOC(KX_NetworkMessageSensor, SetSubjectFilterText); - KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetFrameMessageCount); - KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetBodies); - KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetSubject); - KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetSubjects); + KX_PYMETHOD_DOC_O(KX_NetworkMessageSensor, SetSubjectFilterText); + KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetFrameMessageCount); + KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetBodies); + KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetSubject); + KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetSubjects); }; -- cgit v1.2.3 From b16b0f91ec488b5e4718047503829e7eb8b757c6 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 11 Sep 2008 20:16:30 +0000 Subject: Repair rayCast part 2: return correct polygon information and true normal --- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 68 ++++++++++++++++++---- 1 file changed, 56 insertions(+), 12 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 0747761ea0a..6df3297ec7e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -741,8 +741,8 @@ struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResul // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it if (rayResult.m_localShapeInfo) { - m_hitTriangleShape = NULL;//rayResult.m_localShapeInfo->m_triangleShape; - m_hitTriangleIndex = 0;//rayResult.m_localShapeInfo->m_triangleIndex; + m_hitTriangleShape = rayResult.m_collisionObject->getCollisionShape(); + m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex; } else { m_hitTriangleShape = NULL; @@ -786,16 +786,6 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac result.m_hitPoint[1] = rayCallback.m_hitPointWorld.getY(); result.m_hitPoint[2] = rayCallback.m_hitPointWorld.getZ(); - if (rayCallback.m_hitNormalWorld.length2() > (SIMD_EPSILON*SIMD_EPSILON)) - { - rayCallback.m_hitNormalWorld.normalize(); - } else - { - rayCallback.m_hitNormalWorld.setValue(1,0,0); - } - result.m_hitNormal[0] = rayCallback.m_hitNormalWorld.getX(); - result.m_hitNormal[1] = rayCallback.m_hitNormalWorld.getY(); - result.m_hitNormal[2] = rayCallback.m_hitNormalWorld.getZ(); if (rayCallback.m_hitTriangleShape != NULL) { // identify the mesh polygon @@ -821,9 +811,63 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac { result.m_meshObject = shapeInfo->m_meshObject; result.m_polygon = shapeInfo->m_polygonIndexArray.at(rayCallback.m_hitTriangleIndex); + + // Bullet returns the normal from "outside". + // If the user requests the real normal, compute it now + if (filterCallback.m_faceNormal) + { + // this code is copied from Bullet + btVector3 triangle[3]; + const unsigned char *vertexbase; + int numverts; + PHY_ScalarType type; + int stride; + const unsigned char *indexbase; + int indexstride; + int numfaces; + PHY_ScalarType indicestype; + btTriangleMeshShape* triangleShape = (btTriangleMeshShape*)shape; + btStridingMeshInterface* meshInterface = triangleShape->getMeshInterface(); + + meshInterface->getLockedReadOnlyVertexIndexBase( + &vertexbase, + numverts, + type, + stride, + &indexbase, + indexstride, + numfaces, + indicestype, + 0); + + unsigned int* gfxbase = (unsigned int*)(indexbase+rayCallback.m_hitTriangleIndex*indexstride); + const btVector3& meshScaling = meshInterface->getScaling(); + for (int j=2;j>=0;j--) + { + int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; + + btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride); + + triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); + } + meshInterface->unLockReadOnlyVertexBase(0); + btVector3 triangleNormal; + triangleNormal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]); + rayCallback.m_hitNormalWorld = rayCallback.m_collisionObject->getWorldTransform().getBasis()*triangleNormal; + } } } } + if (rayCallback.m_hitNormalWorld.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + { + rayCallback.m_hitNormalWorld.normalize(); + } else + { + rayCallback.m_hitNormalWorld.setValue(1,0,0); + } + result.m_hitNormal[0] = rayCallback.m_hitNormalWorld.getX(); + result.m_hitNormal[1] = rayCallback.m_hitNormalWorld.getY(); + result.m_hitNormal[2] = rayCallback.m_hitNormalWorld.getZ(); filterCallback.reportHit(&result); } -- cgit v1.2.3 From 0dea748e01dab697d2f8ac245bbd5e925cd732ce Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 12 Sep 2008 02:15:16 +0000 Subject: save and load configuration actuator, (option in game actuator menu) saves a marshal'd GameLogic.globalDict to the blendfile path with the blend extension replaced with bgeconf Use this in YoFrankie to save keyboard layout and graphics quality settings. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 10 ++++ .../GamePlayer/ghost/GPG_Application.cpp | 47 +++------------ source/gameengine/Ketsji/KX_GameActuator.cpp | 66 ++++++++++++++++++++++ source/gameengine/Ketsji/KX_GameActuator.h | 2 + source/gameengine/Ketsji/KX_PythonInit.cpp | 65 +++++++++++++++++++++ source/gameengine/Ketsji/KX_PythonInit.h | 4 ++ 6 files changed, 154 insertions(+), 40 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 3142f7652de..799506aecaa 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -876,6 +876,16 @@ void BL_ConvertActuators(char* maggiename, mode = KX_GameActuator::KX_GAME_QUIT; break; } + case ACT_GAME_SAVECFG: + { + mode = KX_GameActuator::KX_GAME_SAVECFG; + break; + } + case ACT_GAME_LOADCFG: + { + mode = KX_GameActuator::KX_GAME_LOADCFG; + break; + } default: ; /* flag error */ } diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index f35e2894f65..0287178004d 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -98,7 +98,6 @@ extern "C" #include "GHOST_IEventConsumer.h" #include "GHOST_IWindow.h" #include "GHOST_Rect.h" -#include "marshal.h" static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time); @@ -685,15 +684,7 @@ bool GPG_Application::startEngine(void) initMathutils(); /* Restore the dict */ - if (m_pyGlobalDictString) { - PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(m_pyGlobalDictString, m_pyGlobalDictString_Length); - if (pyGlobalDict) { - PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. - } else { - PyErr_Clear(); - printf("Error could not marshall string\n"); - } - } + loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length); m_sceneconverter->ConvertScene( startscenename, @@ -731,36 +722,12 @@ bool GPG_Application::startEngine(void) void GPG_Application::stopEngine() { // get the python dict and convert to a string for future use - { - SetPyGlobalDictMarshal(NULL, 0); - - PyObject* gameLogic = PyImport_ImportModule("GameLogic"); - if (gameLogic) { - PyObject* pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module - if (pyGlobalDict) { -#ifdef Py_MARSHAL_VERSION - PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5 -#else - PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict ); -#endif - if (pyGlobalDictMarshal) { - m_pyGlobalDictString_Length = PyString_Size(pyGlobalDictMarshal); - // for testing only - // PyObject_Print(pyGlobalDictMarshal, stderr, 0); - m_pyGlobalDictString = static_cast (malloc(m_pyGlobalDictString_Length)); - memcpy(m_pyGlobalDictString, PyString_AsString(pyGlobalDictMarshal), m_pyGlobalDictString_Length); - } else { - printf("Error, GameLogic.globalDict could not be marshal'd\n"); - } - Py_DECREF(gameLogic); - } else { - printf("Error, GameLogic.globalDict was removed\n"); - } - } else { - printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); - } - } - + char *marshal_buffer; + m_pyGlobalDictString_Length = saveGamePythonConfig(&marshal_buffer); + if (m_pyGlobalDictString_Length) { + m_pyGlobalDictString = static_cast (malloc(m_pyGlobalDictString_Length)); + memcpy(m_pyGlobalDictString, marshal_buffer, m_pyGlobalDictString_Length); + } // when exiting the mainloop exitGamePythonScripting(); diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index fcd32d5f4fe..91ddbbbfbc9 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -34,6 +34,7 @@ //#include #include "KX_Scene.h" #include "KX_KetsjiEngine.h" +#include "KX_PythonInit.h" /* for config load/saving */ #ifdef HAVE_CONFIG_H #include @@ -125,6 +126,71 @@ bool KX_GameActuator::Update() } break; } + case KX_GAME_SAVECFG: + { + if (m_ketsjiengine) + { + char mashal_path[512]; + char *marshal_buffer = NULL; + int marshal_length; + FILE *fp = NULL; + + pathGamePythonConfig(mashal_path); + marshal_length = saveGamePythonConfig(&marshal_buffer); + + if (marshal_length && marshal_buffer) { + fp = fopen(mashal_path, "wb"); + if (fp) { + if (fwrite(marshal_buffer, 1, marshal_length, fp) != marshal_length) { + printf("Warning: could not write marshal data\n"); + } + fclose(fp); + } else { + printf("Warning: could not open marshal file\n"); + } + } else { + printf("Warning: could not create marshal buffer\n"); + } + } + break; + } + case KX_GAME_LOADCFG: + { + if (m_ketsjiengine) + { + char mashal_path[512]; + char *marshal_buffer; + int marshal_length; + FILE *fp = NULL; + int result; + + pathGamePythonConfig(mashal_path); + + fp = fopen(mashal_path, "rb"); + if (fp) { + // obtain file size: + fseek (fp , 0 , SEEK_END); + marshal_length = ftell(fp); + rewind(fp); + + marshal_buffer = (char*) malloc (sizeof(char)*marshal_length); + + result = fread (marshal_buffer, 1, marshal_length, fp); + + if (result == marshal_length) { + loadGamePythonConfig(marshal_buffer, marshal_length); + } else { + printf("warning: could not read all of '%s'\n", mashal_path); + } + + free(marshal_buffer); + fclose(fp); + } else { + printf("warning: could not open '%s'\n", mashal_path); + } + } + break; + } default: ; /* do nothing? this is an internal error !!! */ } diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h index 8565dc46caa..bb3448995dc 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.h +++ b/source/gameengine/Ketsji/KX_GameActuator.h @@ -54,6 +54,8 @@ protected: KX_GAME_START, KX_GAME_RESTART, KX_GAME_QUIT, + KX_GAME_SAVECFG, + KX_GAME_LOADCFG, KX_GAME_MAX }; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index eb0052d71ff..5742c530f6d 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -74,6 +74,8 @@ extern "C" { #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use. } +#include "marshal.h" /* python header for loading/saving dicts */ + #include "PHY_IPhysicsEnvironment.h" // FIXME: Enable for access to blender python modules. This is disabled because // python has dependencies on a lot of other modules and is a pain to link. @@ -1319,3 +1321,66 @@ class KX_Scene* PHY_GetActiveScene() { return gp_KetsjiScene; } + +// utility function for loading and saving the globalDict +int saveGamePythonConfig( char **marshal_buffer) +{ + int marshal_length = 0; + PyObject* gameLogic = PyImport_ImportModule("GameLogic"); + if (gameLogic) { + PyObject* pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module + if (pyGlobalDict) { +#ifdef Py_MARSHAL_VERSION + PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5 +#else + PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict ); +#endif + if (pyGlobalDictMarshal) { + marshal_length= PyString_Size(pyGlobalDictMarshal); + // for testing only + // PyObject_Print(pyGlobalDictMarshal, stderr, 0); + *marshal_buffer = PyString_AsString(pyGlobalDictMarshal); + } else { + printf("Error, GameLogic.globalDict could not be marshal'd\n"); + } + Py_DECREF(gameLogic); + } else { + printf("Error, GameLogic.globalDict was removed\n"); + } + } else { + printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); + } + return marshal_length; +} + +int loadGamePythonConfig(char *marshal_buffer, int marshal_length) +{ + PyObject* gameLogic = PyImport_ImportModule("GameLogic"); + /* Restore the dict */ + if (marshal_buffer) { + PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length); + if (pyGlobalDict) { + PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + return 1; + } else { + PyErr_Clear(); + printf("Error could not marshall string\n"); + } + } else { + printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); + } + return 0; +} + +void pathGamePythonConfig( char *path ) +{ + int len = strlen(G.sce); + + strncpy(path, G.sce, sizeof(G.sce)); + /* replace extension */ + if (BLI_testextensie(path, ".blend")) { + strcpy(path+(len-6), ".bgeconf"); + } else { + strcpy(path+len, ".bgeconf"); + } +} diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 388d073c6db..28d9d72a4c3 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -49,6 +49,10 @@ void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level); void exitGamePythonScripting(); +void pathGamePythonConfig( char *path ); +int saveGamePythonConfig( char **marshal_buffer); +int loadGamePythonConfig(char *marshal_buffer, int marshal_length); + void PHY_SetActiveScene(class KX_Scene* scene); class KX_Scene* PHY_GetActiveScene(); #include "MT_Vector3.h" -- cgit v1.2.3 From 6ebd6cfa73aa96af2b97384242b716e75897766f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 12 Sep 2008 15:26:00 +0000 Subject: Bugfixes in SDL joystick, apparently it gives NULLs in OSX. --- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 403fbfe6f4c..8ef33240592 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -108,6 +108,9 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) bool result = false; bool reset = m_reset && m_level; + if(js==NULL) + return false; + m_reset = false; switch(m_joymode) { @@ -397,7 +400,9 @@ char SCA_JoystickSensor::GetRealAxis_doc[] = "\tReturns a list of the values for each axis .\n"; PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21()); + if(joy) + return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21()); + return NULL; } @@ -478,7 +483,9 @@ char SCA_JoystickSensor::NumberOfAxes_doc[] = "\tReturns the number of axes .\n"; PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - return PyInt_FromLong( joy->GetNumberOfAxes() ); + if(joy) + return PyInt_FromLong( joy->GetNumberOfAxes() ); + return false; } @@ -487,7 +494,9 @@ char SCA_JoystickSensor::NumberOfButtons_doc[] = "\tReturns the number of buttons .\n"; PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - return PyInt_FromLong( joy->GetNumberOfButtons() ); + if(joy) + return PyInt_FromLong( joy->GetNumberOfButtons() ); + return false; } @@ -496,7 +505,9 @@ char SCA_JoystickSensor::NumberOfHats_doc[] = "\tReturns the number of hats .\n"; PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - return PyInt_FromLong( joy->GetNumberOfHats() ); + if(joy) + return PyInt_FromLong( joy->GetNumberOfHats() ); + return false; } char SCA_JoystickSensor::Connected_doc[] = @@ -504,5 +515,7 @@ char SCA_JoystickSensor::Connected_doc[] = "\tReturns True if a joystick is connected at this joysticks index.\n"; PyObject* SCA_JoystickSensor::PyConnected( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - return PyBool_FromLong( joy->Connected() ); + if(joy) + return PyBool_FromLong( joy->Connected() ); + return false; } -- cgit v1.2.3 From 21d74deda6a26433ba36e5751ca74f0a162f3279 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 12 Sep 2008 16:06:17 +0000 Subject: Fixes for game engine runtime on Mac OS X, there were issues working with relative paths. Still doesn't work optimal, since paths are relative to game.blend which is in the app bundle under Contents/Resources, so other files need to be moved there manually at the moment. --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 96 +++++++++++++++++------- 1 file changed, 69 insertions(+), 27 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 3a9e59c3c25..0b4fde61e1c 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -198,7 +198,53 @@ void usage(char* program) printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program); } -char *get_filename(int argc, char **argv) { +static void make_absolute_filename(char *blendfilename) +{ + int abs = 0; + int filelen; + char cwd[FILE_MAXDIR + FILE_MAXFILE]; + char filename[FILE_MAXDIR + FILE_MAXFILE]; + + cwd[0] = filename[0] = '\0'; + + BLI_strncpy(filename, blendfilename, sizeof(filename)); + filelen = strlen(filename); + + /* relative path checks, could do more tests here... */ +#ifdef WIN32 + /* Account for X:/ and X:\ - should be enough */ + if (filelen >= 3 && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/')) + abs = 1; +#else + if (filelen >= 2 && filename[0] == '/') + abs = 1 ; +#endif + if (!abs) { + BLI_getwdN(cwd); /* incase the full path to the blend isnt used */ + + if (cwd[0] == '\0') { + printf( + "Could not get the current working directory - $PWD for an unknown reason.\n\t" + "Relative linked files will not load if the entire blend path is not used.\n\t" + "The 'Play' button may also fail.\n" + ); + } else { + /* uses the blend path relative to cwd important for loading relative linked files. + * + * cwd should contain c:\ etc on win32 so the relbase can be NULL + * relbase being NULL also prevents // being misunderstood as relative to the current + * blend file which isnt a feature we want to use in this case since were dealing + * with a path from the command line, rather then from inside Blender */ + + BLI_make_file_string(NULL, filename, cwd, blendfilename); + } + } + + BLI_strncpy(blendfilename, filename, sizeof(filename)); +} + +static void get_filename(int argc, char **argv, char *filename) +{ #ifdef __APPLE__ /* On Mac we park the game file (called game.blend) in the application bundle. * The executable is located in the bundle as well. @@ -206,22 +252,18 @@ char *get_filename(int argc, char **argv) { */ int srclen = ::strlen(argv[0]); int len = 0; - char *filename = NULL; + char *gamefile = NULL; + filename[0] = '\0'; + if (argc > 1) { if (BLI_exists(argv[argc-1])) { - len = ::strlen(argv[argc-1]); - filename = new char [len + 1]; - ::strcpy(filename, argv[argc-1]); - return(filename); + BLI_strncpy(filename, argv[argc-1], FILE_MAXDIR + FILE_MAXFILE); } if (::strncmp(argv[argc-1], "-psn_", 5)==0) { static char firstfilebuf[512]; if (GHOST_HACK_getFirstFile(firstfilebuf)) { - len = ::strlen(firstfilebuf); - filename = new char [len + 1]; - ::strcpy(filename, firstfilebuf); - return(filename); + BLI_strncpy(filename, firstfilebuf, FILE_MAXDIR + FILE_MAXFILE); } } } @@ -229,23 +271,26 @@ char *get_filename(int argc, char **argv) { srclen -= ::strlen("MacOS/blenderplayer"); if (srclen > 0) { len = srclen + ::strlen("Resources/game.blend"); - filename = new char [len + 1]; - ::strcpy(filename, argv[0]); - ::strcpy(filename + srclen, "Resources/game.blend"); + gamefile = new char [len + 1]; + ::strcpy(gamefile, argv[0]); + ::strcpy(gamefile + srclen, "Resources/game.blend"); //::printf("looking for file: %s\n", filename); - if (BLI_exists(filename)) { - return (filename); - } + if (BLI_exists(gamefile)) + BLI_strncpy(filename, gamefile, FILE_MAXDIR + FILE_MAXFILE); + + delete gamefile; } - return(NULL); #else - return (argc>1)?argv[argc-1]:NULL; + filename[0] = '\0'; + + if(argc > 1) + BLI_strncpy(filename, argv[argc-1], FILE_MAXDIR + FILE_MAXFILE); #endif // !_APPLE } -static BlendFileData *load_game_data(char *progname, char *filename = NULL) { +static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL) { BlendReadError error; BlendFileData *bfd = NULL; @@ -579,9 +624,12 @@ int main(int argc, char** argv) STR_String exitstring = ""; GPG_Application app(system); bool firstTimeRunning = true; - char *filename = get_filename(argc, argv); + char filename[FILE_MAXDIR + FILE_MAXFILE]; char *titlename; char pathname[160]; + + get_filename(argc, argv, filename); + make_absolute_filename(filename); do { @@ -613,7 +661,7 @@ int main(int argc, char** argv) } else { - bfd = load_game_data(bprogname, filename); + bfd = load_game_data(bprogname, filename[0]? filename: NULL); } //::printf("game data loaded from %s\n", filename); @@ -782,12 +830,6 @@ int main(int argc, char** argv) pyGlobalDictString_Length = app.GetPyGlobalDictMarshalLength(); BLO_blendfiledata_free(bfd); - -#ifdef __APPLE__ - if (filename) { - delete [] filename; - } -#endif // __APPLE__ } } while (exitcode == KX_EXIT_REQUEST_RESTART_GAME || exitcode == KX_EXIT_REQUEST_START_OTHER_GAME); } -- cgit v1.2.3 From dfb5ebb12ea18bc8982777142c6e185cb389ad45 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 13 Sep 2008 11:43:01 +0000 Subject: return dummy python values when no joystick is present --- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 8ef33240592..3c08710c6ce 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -402,7 +402,8 @@ PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); if(joy) return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21()); - return NULL; + else + return Py_BuildValue("[iiii]", 0, 0, 0, 0); } @@ -483,9 +484,8 @@ char SCA_JoystickSensor::NumberOfAxes_doc[] = "\tReturns the number of axes .\n"; PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - if(joy) - return PyInt_FromLong( joy->GetNumberOfAxes() ); - return false; + // when the joystick is null their is 0 exis still. dumb but scripters should use isConnected() + return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 ); } @@ -494,9 +494,7 @@ char SCA_JoystickSensor::NumberOfButtons_doc[] = "\tReturns the number of buttons .\n"; PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - if(joy) - return PyInt_FromLong( joy->GetNumberOfButtons() ); - return false; + return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 ); } @@ -505,9 +503,7 @@ char SCA_JoystickSensor::NumberOfHats_doc[] = "\tReturns the number of hats .\n"; PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - if(joy) - return PyInt_FromLong( joy->GetNumberOfHats() ); - return false; + return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 ); } char SCA_JoystickSensor::Connected_doc[] = @@ -515,7 +511,5 @@ char SCA_JoystickSensor::Connected_doc[] = "\tReturns True if a joystick is connected at this joysticks index.\n"; PyObject* SCA_JoystickSensor::PyConnected( PyObject* self ) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); - if(joy) - return PyBool_FromLong( joy->Connected() ); - return false; + return PyBool_FromLong( joy ? joy->Connected() : 0 ); } -- cgit v1.2.3 From ba9d3aa4ab1be8c7faa28c9d49b4d0ed5f17b32a Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 13 Sep 2008 11:46:07 +0000 Subject: BGE patch: fix transform bug on compound shape: child shape didn't take into account parent inverse node. Fix scaling bug on instantiation of compound shape: child shape didn't have correct shape. Note: global scaling doesn't work on compound shape (limitation of Bullet); don't set any scale on the top dynamic object. --- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 26 ++++++++++++++++++---- .../Physics/Bullet/CcdPhysicsController.cpp | 1 + .../Physics/Bullet/CcdPhysicsController.h | 2 ++ 3 files changed, 25 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 9607489497d..6507bf501e4 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -801,11 +801,29 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, assert(colShape->isCompound()); btCompoundShape* compoundShape = (btCompoundShape*)colShape; - MT_Point3 childPos = gameobj->GetSGNode()->GetLocalPosition(); - MT_Matrix3x3 childRot = gameobj->GetSGNode()->GetLocalOrientation(); - MT_Vector3 childScale = gameobj->GetSGNode()->GetLocalScale(); + // compute the local transform from parent, this may include a parent inverse node + SG_Node* gameNode = gameobj->GetSGNode(); + SG_Node* parentInverseNode = gameNode->GetSGParent(); + if (parentInverseNode && parentInverseNode->GetSGClientObject() != NULL) + // this is not a parent inverse node, cancel it + parentInverseNode = NULL; + // now combine the parent inverse node and the game node + MT_Point3 childPos = gameNode->GetLocalPosition(); + MT_Matrix3x3 childRot = gameNode->GetLocalOrientation(); + MT_Vector3 childScale = gameNode->GetLocalScale(); + if (parentInverseNode) + { + const MT_Point3& parentInversePos = parentInverseNode->GetLocalPosition(); + const MT_Matrix3x3& parentInverseRot = parentInverseNode->GetLocalOrientation(); + const MT_Vector3& parentInverseScale = parentInverseNode->GetLocalScale(); + childRot = parentInverseRot * childRot; + childScale = parentInverseScale * childScale; + childPos = parentInversePos+parentInverseScale*(parentInverseRot*childPos); + } - bm->setLocalScaling(btVector3(childScale.x(),childScale.y(),childScale.z())); + shapeInfo->m_childScale.setValue(childScale.x(),childScale.y(),childScale.z()); + bm->setLocalScaling(shapeInfo->m_childScale); + shapeInfo->m_childTrans.setOrigin(btVector3(childPos.x(),childPos.y(),childPos.z())); float rotval[12]; childRot.getValue(rotval); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index b67cf0425c5..b9266bb9b0e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -924,6 +924,7 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() collisionShape = nextShapeInfo->CreateBulletShape(); if (collisionShape) { + collisionShape->setLocalScaling(nextShapeInfo->m_childScale); compoundShape->addChildShape(nextShapeInfo->m_childTrans, collisionShape); } } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index a3fbb502c08..d6f0867e01d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -47,6 +47,7 @@ public: m_radius(1.0), m_height(1.0), m_halfExtend(0.f,0.f,0.f), + m_childScale(1.0f,1.0f,1.0f), m_nextShape(NULL), m_refCount(1) { @@ -96,6 +97,7 @@ public: btScalar m_height; btVector3 m_halfExtend; btTransform m_childTrans; + btVector3 m_childScale; std::vector m_vertexArray; // Contains both vertex array for polytope shape and // triangle array for concave mesh shape. // In this case a triangle is made of 3 consecutive points -- cgit v1.2.3 From 8925ae60428ed213fd8cb1271671e6ca56fda70e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 13 Sep 2008 16:03:11 +0000 Subject: BGE patch: use new btScaledBvhTriangleMeshShape to allow shape sharing between replicas and avoid BVH rebuild in case of scaling. This will save memory and speed up greatly the instantiation of static mesh. --- .../Physics/Bullet/CcdPhysicsController.cpp | 32 ++++++--- .../Physics/Bullet/CcdPhysicsController.h | 7 ++ .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 76 ++++++++++++---------- 3 files changed, 70 insertions(+), 45 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index b9266bb9b0e..4da9143fc3d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -15,7 +15,7 @@ subject to the following restrictions: #include "CcdPhysicsController.h" #include "btBulletDynamicsCommon.h" - +#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h" #include "PHY_IMotionState.h" #include "CcdPhysicsEnvironment.h" #include "RAS_MeshObject.h" @@ -904,15 +904,26 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() break; case PHY_SHAPE_MESH: - collisionMeshData = new btTriangleMesh(); - // m_vertexArray is necessarily a multiple of 3 - for (std::vector::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) + // Let's use the latest btScaledBvhTriangleMeshShape: it allows true sharing of + // triangle mesh information between duplicates => drastic performance increase when + // duplicating complex mesh objects. + // BUT it causes a small performance decrease when sharing is not required: + // 9 multiplications/additions and one function call for each triangle that passes the mid phase filtering + // One possible optimization is to use directly the btBvhTriangleMeshShape when the scale is 1,1,1 + // and btScaledBvhTriangleMeshShape otherwise. + if (!m_unscaledShape) { - collisionMeshData->addTriangle(*it++,*it++,*it++); + collisionMeshData = new btTriangleMesh(); + // m_vertexArray is necessarily a multiple of 3 + for (std::vector::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) + { + collisionMeshData->addTriangle(*it++,*it++,*it++); + } + // this shape will be shared and not deleted until shapeInfo is deleted + m_unscaledShape = new btBvhTriangleMeshShape( collisionMeshData, true ); + m_unscaledShape->recalcLocalAabb(); } - concaveShape = new btBvhTriangleMeshShape( collisionMeshData, true ); - concaveShape->recalcLocalAabb(); - collisionShape = concaveShape; + collisionShape = new btScaledBvhTriangleMeshShape(m_unscaledShape, btVector3(1.0f,1.0f,1.0f)); break; case PHY_SHAPE_COMPOUND: @@ -953,7 +964,10 @@ CcdShapeConstructionInfo::~CcdShapeConstructionInfo() childShape->Release(); childShape = nextShape; } - + if (m_unscaledShape) + { + DeleteBulletShape(m_unscaledShape); + } m_vertexArray.clear(); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index d6f0867e01d..a685c466944 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -49,6 +49,7 @@ public: m_halfExtend(0.f,0.f,0.f), m_childScale(1.0f,1.0f,1.0f), m_nextShape(NULL), + m_unscaledShape(NULL), m_refCount(1) { m_childTrans.setIdentity(); @@ -72,6 +73,10 @@ public: void AddShape(CcdShapeConstructionInfo* shapeInfo); + btTriangleMeshShape* GetMeshShape(void) + { + return m_unscaledShape; + } CcdShapeConstructionInfo* GetNextShape() { return m_nextShape; @@ -108,6 +113,8 @@ public: protected: CcdShapeConstructionInfo* m_nextShape; // for compound shape + btBvhTriangleMeshShape* m_unscaledShape;// holds the shared unscale BVH mesh shape, + // the actual shape is of type btScaledBvhTriangleMeshShape int m_refCount; // this class is shared between replicas // keep track of users so that we can release it }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 6df3297ec7e..5042df2162a 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -816,44 +816,48 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac // If the user requests the real normal, compute it now if (filterCallback.m_faceNormal) { - // this code is copied from Bullet - btVector3 triangle[3]; - const unsigned char *vertexbase; - int numverts; - PHY_ScalarType type; - int stride; - const unsigned char *indexbase; - int indexstride; - int numfaces; - PHY_ScalarType indicestype; - btTriangleMeshShape* triangleShape = (btTriangleMeshShape*)shape; - btStridingMeshInterface* meshInterface = triangleShape->getMeshInterface(); - - meshInterface->getLockedReadOnlyVertexIndexBase( - &vertexbase, - numverts, - type, - stride, - &indexbase, - indexstride, - numfaces, - indicestype, - 0); - - unsigned int* gfxbase = (unsigned int*)(indexbase+rayCallback.m_hitTriangleIndex*indexstride); - const btVector3& meshScaling = meshInterface->getScaling(); - for (int j=2;j>=0;j--) + // mesh shapes are shared and stored in the shapeInfo + btTriangleMeshShape* triangleShape = shapeInfo->GetMeshShape(); + if (triangleShape) { - int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; - - btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride); - - triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); + // this code is copied from Bullet + btVector3 triangle[3]; + const unsigned char *vertexbase; + int numverts; + PHY_ScalarType type; + int stride; + const unsigned char *indexbase; + int indexstride; + int numfaces; + PHY_ScalarType indicestype; + btStridingMeshInterface* meshInterface = triangleShape->getMeshInterface(); + + meshInterface->getLockedReadOnlyVertexIndexBase( + &vertexbase, + numverts, + type, + stride, + &indexbase, + indexstride, + numfaces, + indicestype, + 0); + + unsigned int* gfxbase = (unsigned int*)(indexbase+rayCallback.m_hitTriangleIndex*indexstride); + const btVector3& meshScaling = shape->getLocalScaling(); + for (int j=2;j>=0;j--) + { + int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; + + btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride); + + triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); + } + meshInterface->unLockReadOnlyVertexBase(0); + btVector3 triangleNormal; + triangleNormal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]); + rayCallback.m_hitNormalWorld = rayCallback.m_collisionObject->getWorldTransform().getBasis()*triangleNormal; } - meshInterface->unLockReadOnlyVertexBase(0); - btVector3 triangleNormal; - triangleNormal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]); - rayCallback.m_hitNormalWorld = rayCallback.m_collisionObject->getWorldTransform().getBasis()*triangleNormal; } } } -- cgit v1.2.3 From fa825e70e3d5f05a1a803d2be563c3b919adf4ed Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 13 Sep 2008 19:19:51 +0000 Subject: Game engine: added Rasterizer.get/setMaterialMode to set texface, multitexture or glsl materials. This does not affect existing scenes, only newly created ones. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 12 ++-- .../GamePlayer/ghost/GPG_Application.cpp | 21 +++--- source/gameengine/Ketsji/KX_PythonInit.cpp | 77 +++++++++++++++++++--- source/gameengine/PyDoc/Rasterizer.py | 19 ++++++ 4 files changed, 102 insertions(+), 27 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 1f66335c749..fa771cb3ce8 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -138,10 +138,12 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, bool usemat = false, useglslmat = false; if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) - usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 0) != 0); + usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0); if(GPU_extensions_minimum_support()) - useglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 0) != 0); + useglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 1) != 0); + else if(G.fileflags & G_FILE_GAME_MAT_GLSL) + usemat = false; // create the canvas, rasterizer and rendertools RAS_ICanvas* canvas = new KX_BlenderCanvas(area); @@ -299,10 +301,10 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, sceneconverter->addInitFromFrame=false; if (always_use_expand_framing) sceneconverter->SetAlwaysUseExpandFraming(true); - - if(usemat) + + if(usemat && (G.fileflags & G_FILE_GAME_MAT)) sceneconverter->SetMaterials(true); - if(useglslmat) + if(useglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)) sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(keyboarddevice, diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 0287178004d..580c80ee0a5 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -524,17 +524,14 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DISPLAY_LISTS) != 0); - if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) { - int gameflag =(G.fileflags & G_FILE_GAME_MAT); - m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0); - } + if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) + m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0); - if(GPU_extensions_minimum_support()) { - int gameflag = (G.fileflags & G_FILE_GAME_MAT_GLSL); + if(GPU_extensions_minimum_support()) + m_blenderglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 1) != 0); + else if(G.fileflags & G_FILE_GAME_MAT_GLSL) + m_blendermat = false; - m_blenderglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", gameflag) != 0); - } - // create the canvas, rasterizer and rendertools m_canvas = new GPG_Canvas(window); if (!m_canvas) @@ -657,12 +654,12 @@ bool GPG_Application::startEngine(void) { STR_String startscenename = m_startSceneName.Ptr(); m_ketsjiengine->SetSceneConverter(m_sceneconverter); - + // if (always_use_expand_framing) // sceneconverter->SetAlwaysUseExpandFraming(true); - if(m_blendermat) + if(m_blendermat && (G.fileflags & G_FILE_GAME_MAT)) m_sceneconverter->SetMaterials(true); - if(m_blenderglslmat) + if(m_blenderglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)) m_sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(m_keyboard, diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 5742c530f6d..5308a0b9536 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -303,7 +303,7 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) if((dp = opendir(cpath)) == NULL) { /* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */ - fprintf(stderr, "Could not read directoty () failed, code %d (%s)\n", cpath, errno, strerror(errno)); + fprintf(stderr, "Could not read directoty (%s) failed, code %d (%s)\n", cpath, errno, strerror(errno)); return list; } @@ -696,7 +696,7 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, PyObject*) { char *setting; - int enable, flag; + int enable, flag, fileflags; if (!PyArg_ParseTuple(args,"si",&setting,&enable)) return NULL; @@ -707,6 +707,8 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, PyErr_SetString(PyExc_ValueError, "glsl setting is not known"); return NULL; } + + fileflags = G.fileflags; if (enable) G.fileflags &= ~flag; @@ -714,17 +716,19 @@ static PyObject* gPySetGLSLMaterialSetting(PyObject*, G.fileflags |= flag; /* display lists and GLSL materials need to be remade */ - if(gp_KetsjiEngine) { - KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes(); - KX_SceneList::iterator it; + if(G.fileflags != fileflags) { + if(gp_KetsjiEngine) { + KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes(); + KX_SceneList::iterator it; + + for(it=scenes->begin(); it!=scenes->end(); it++) + if((*it)->GetBucketManager()) + (*it)->GetBucketManager()->ReleaseDisplayLists(); + } - for(it=scenes->begin(); it!=scenes->end(); it++) - if((*it)->GetBucketManager()) - (*it)->GetBucketManager()->ReleaseDisplayLists(); + GPU_materials_free(); } - GPU_materials_free(); - Py_RETURN_NONE; } @@ -749,6 +753,50 @@ static PyObject* gPyGetGLSLMaterialSetting(PyObject*, return PyInt_FromLong(enabled); } +#define KX_TEXFACE_MATERIAL 0 +#define KX_BLENDER_MULTITEX_MATERIAL 1 +#define KX_BLENDER_GLSL_MATERIAL 2 + +static PyObject* gPySetMaterialType(PyObject*, + PyObject* args, + PyObject*) +{ + int flag, type; + + if (!PyArg_ParseTuple(args,"i",&type)) + return NULL; + + if(type == KX_BLENDER_GLSL_MATERIAL) + flag = G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL; + else if(type == KX_BLENDER_MULTITEX_MATERIAL) + flag = G_FILE_GAME_MAT; + else if(type == KX_TEXFACE_MATERIAL) + flag = 0; + else { + PyErr_SetString(PyExc_ValueError, "material type is not known"); + return NULL; + } + + G.fileflags &= ~(G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL); + G.fileflags |= flag; + + Py_RETURN_NONE; +} + +static PyObject* gPyGetMaterialType(PyObject*) +{ + int flag; + + if(G.fileflags & (G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL)) + flag = KX_BLENDER_GLSL_MATERIAL; + else if(G.fileflags & G_FILE_GAME_MAT) + flag = KX_BLENDER_MULTITEX_MATERIAL; + else + flag = KX_TEXFACE_MATERIAL; + + return PyInt_FromLong(flag); +} + STR_String gPyGetWindowHeight__doc__="getWindowHeight doc"; STR_String gPyGetWindowWidth__doc__="getWindowWidth doc"; STR_String gPyEnableVisibility__doc__="enableVisibility doc"; @@ -782,6 +830,10 @@ static struct PyMethodDef rasterizer_methods[] = { {"getEyeSeparation", (PyCFunction) gPyGetEyeSeparation, METH_VARARGS, "get the eye separation for stereo mode"}, {"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the focal length for stereo mode"}, {"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the focal length for stereo mode"}, + {"setMaterialMode",(PyCFunction) gPySetMaterialType, + METH_VARARGS, "set the material mode to use for OpenGL rendering"}, + {"getMaterialMode",(PyCFunction) gPyGetMaterialType, + METH_NOARGS, "get the material mode being used for OpenGL rendering"}, {"setGLSLMaterialSetting",(PyCFunction) gPySetGLSLMaterialSetting, METH_VARARGS, "set the state of a GLSL material setting"}, {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting, @@ -1111,6 +1163,11 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) ErrorObject = PyString_FromString("Rasterizer.error"); PyDict_SetItemString(d, "error", ErrorObject); + /* needed for get/setMaterialType */ + KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL); + KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL); + KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL); + // XXXX Add constants here // Check for errors diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py index 7afdcf07f2e..ebb5332d98d 100644 --- a/source/gameengine/PyDoc/Rasterizer.py +++ b/source/gameengine/PyDoc/Rasterizer.py @@ -37,6 +37,10 @@ Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement M # Centre the mouse Rasterizer.setMousePosition(Rasterizer.getWindowWidth()/2, Rasterizer.getWindowHeight()/2) +@group Material Types: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL +@var KX_TEXFACE_MATERIAL: Materials as defined by the texture face settings. +@var KX_BLENDER_MULTITEX_MATERIAL: Materials approximating blender materials with multitexturing. +@var KX_BLENDER_BLENDER_MATERIAL: Materials approximating blender materials with GLSL. """ @@ -147,6 +151,21 @@ def getFocalLength(): @rtype: float """ +def setMaterialMode(mode): + """ + Set the material mode to use for OpenGL rendering. + + @type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL + @note: Changes will only affect newly created scenes. + """ + +def getMaterialMode(mode): + """ + Get the material mode to use for OpenGL rendering. + + @rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL + """ + def setGLSLMaterialSetting(setting, enable): """ Enables or disables a GLSL material setting. -- cgit v1.2.3 From 704fef314a6a4ed17ad93cb32f1821c337ddb7d5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 14 Sep 2008 00:32:18 +0000 Subject: Various game engine fixes: * Fix issue with add transparency mode with blender materials. * Possible fix at frontface flip in the game engine. * Fix color buffering clearing for multiple viewports, it used to clear as if there was one. * Fix for zoom level in user defined viewports, it was based on the full window before, now it is based on the viewport itself. * For user defined viewports, always use Expose instead of Letterbox with bars, the latter doesn't make sense then. --- .../Converter/BL_BlenderDataConversion.cpp | 2 +- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 3 +- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 142 ++++++++++++++------- source/gameengine/Ketsji/KX_KetsjiEngine.h | 3 +- source/gameengine/Rasterizer/RAS_BucketManager.cpp | 21 +-- source/gameengine/Rasterizer/RAS_FramingManager.h | 15 +-- source/gameengine/Rasterizer/RAS_IRasterizer.h | 8 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 37 +++--- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 3 +- 9 files changed, 142 insertions(+), 92 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 05d4f45b634..7a04a42e90d 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -627,7 +627,7 @@ BL_Material* ConvertMaterial( material->transp = TF_ALPHA; // always zsort alpha + add - if((material->transp == TF_ALPHA || texalpha) && (material->transp != TF_CLIP)) { + if((material->transp == TF_ALPHA || material->transp == TF_ADD || texalpha) && (material->transp != TF_CLIP)) { material->ras_mode |= ALPHA; material->ras_mode |= (material->mode & TF_ALPHASORT)? ZSORT: 0; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 0b4fde61e1c..4d24ba195cc 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -629,7 +629,8 @@ int main(int argc, char** argv) char pathname[160]; get_filename(argc, argv, filename); - make_absolute_filename(filename); + if(filename[0]) + make_absolute_filename(filename); do { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index cf98bb72601..4d83853537e 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -276,30 +276,73 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo) } -bool KX_KetsjiEngine::BeginFrame() +void KX_KetsjiEngine::ClearFrame() { - bool result = false; + // clear unless we're drawing overlapping stereo + if(m_rasterizer->InterlacedStereo() && + m_rasterizer->GetEye() == RAS_IRasterizer::RAS_STEREO_RIGHTEYE) + return; - RAS_Rect vp; - KX_Scene* firstscene = *m_scenes.begin(); - const RAS_FrameSettings &framesettings = firstscene->GetFramingType(); + // clear the viewports with the background color of the first scene + bool doclear = false; + KX_SceneList::iterator sceneit; + RAS_Rect clearvp, area, viewport; - // set the area used for rendering - m_rasterizer->SetRenderArea(); + for (sceneit = m_scenes.begin(); sceneit != m_scenes.end(); sceneit++) + { + KX_Scene* scene = *sceneit; + //const RAS_FrameSettings &framesettings = scene->GetFramingType(); + list* cameras = scene->GetCameras(); + + list::iterator it; + for(it = cameras->begin(); it != cameras->end(); it++) + { + SetupViewport(scene, (*it), area, viewport); + + if(!doclear) { + clearvp = viewport; + doclear = true; + } + else { + if(viewport.GetLeft() < clearvp.GetLeft()) + clearvp.SetLeft(viewport.GetLeft()); + if(viewport.GetBottom() < clearvp.GetBottom()) + clearvp.SetBottom(viewport.GetBottom()); + if(viewport.GetRight() > clearvp.GetRight()) + clearvp.SetRight(viewport.GetRight()); + if(viewport.GetTop() > clearvp.GetTop()) + clearvp.SetTop(viewport.GetTop()); + + } + } + } + + if(doclear) { + KX_Scene* firstscene = *m_scenes.begin(); + SetBackGround(firstscene->GetWorldInfo()); + + m_canvas->SetViewPort(clearvp.GetLeft(), clearvp.GetBottom(), + clearvp.GetRight(), clearvp.GetTop()); + m_rasterizer->ClearColorBuffer(); + } +} - RAS_FramingManager::ComputeViewport(framesettings, m_canvas->GetDisplayArea(), vp); +bool KX_KetsjiEngine::BeginFrame() +{ + // set the area used for rendering (stereo can assign only a subset) + m_rasterizer->SetRenderArea(); if (m_canvas->BeginDraw()) { - result = true; + ClearFrame(); + + m_rasterizer->BeginFrame(m_drawingmode , m_kxsystem->GetTimeInSeconds()); + m_rendertools->BeginFrame(m_rasterizer); - m_canvas->SetViewPort(vp.GetLeft(), vp.GetBottom(), vp.GetRight(), vp.GetTop()); - SetBackGround( firstscene->GetWorldInfo() ); - m_rasterizer->BeginFrame( m_drawingmode , m_kxsystem->GetTimeInSeconds()); - m_rendertools->BeginFrame( m_rasterizer); + return true; } - return result; + return false; } @@ -606,7 +649,7 @@ void KX_KetsjiEngine::Render() ); } // clear the -whole- viewport - m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER); + m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); } m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_LEFTEYE); @@ -635,9 +678,6 @@ void KX_KetsjiEngine::Render() m_rendertools->SetAuxilaryClientInfo(scene); - //Initialize scene viewport. - SetupRenderFrame(scene, cam); - // do the rendering RenderFrame(scene, cam); } @@ -655,9 +695,6 @@ void KX_KetsjiEngine::Render() m_rendertools->SetAuxilaryClientInfo(scene); - //Initialize scene viewport. - SetupRenderFrame(scene, (*it)); - // do the rendering RenderFrame(scene, (*it)); } @@ -690,10 +727,6 @@ void KX_KetsjiEngine::Render() //pass the scene, for picking and raycasting (shadows) m_rendertools->SetAuxilaryClientInfo(scene); - //Initialize scene viewport. - //SetupRenderFrame(scene); - SetupRenderFrame(scene, cam); - // do the rendering //RenderFrame(scene); RenderFrame(scene, cam); @@ -854,7 +887,7 @@ void KX_KetsjiEngine::SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat) } -void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam) +void KX_KetsjiEngine::SetupViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport) { // In this function we make sure the rasterizer settings are upto // date. We compute the viewport so that logic @@ -862,17 +895,26 @@ void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam) // Note we postpone computation of the projection matrix // so that we are using the latest camera position. + if (cam->GetViewport()) { + RAS_Rect userviewport; - RAS_Rect viewport; + userviewport.SetLeft(cam->GetViewportLeft()); + userviewport.SetBottom(cam->GetViewportBottom()); + userviewport.SetRight(cam->GetViewportRight()); + userviewport.SetTop(cam->GetViewportTop()); - if (!cam) - return; + // Don't do bars on user specified viewport + RAS_FrameSettings settings = scene->GetFramingType(); + if(settings.FrameType() == RAS_FrameSettings::e_frame_bars) + settings.SetFrameType(RAS_FrameSettings::e_frame_extend); - if (cam->GetViewport()) { - viewport.SetLeft(cam->GetViewportLeft()); - viewport.SetBottom(cam->GetViewportBottom()); - viewport.SetRight(cam->GetViewportRight()); - viewport.SetTop(cam->GetViewportTop()); + RAS_FramingManager::ComputeViewport( + scene->GetFramingType(), + userviewport, + viewport + ); + + area = userviewport; } else if ( m_overrideCam || (scene->GetName() != m_overrideSceneName) || m_overrideCamUseOrtho ) { RAS_FramingManager::ComputeViewport( @@ -880,24 +922,16 @@ void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam) m_canvas->GetDisplayArea(), viewport ); + + area = m_canvas->GetDisplayArea(); } else { viewport.SetLeft(0); viewport.SetBottom(0); viewport.SetRight(int(m_canvas->GetWidth())); viewport.SetTop(int(m_canvas->GetHeight())); - } - // store the computed viewport in the scene - - scene->SetSceneViewport(viewport); - - // set the viewport for this frame and scene - m_canvas->SetViewPort( - viewport.GetLeft(), - viewport.GetBottom(), - viewport.GetRight(), - viewport.GetTop() - ); + area = m_canvas->GetDisplayArea(); + } } void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) @@ -951,12 +985,22 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) // update graphics void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) { + RAS_Rect viewport, area; float left, right, bottom, top, nearfrust, farfrust, focallength; const float ortho = 100.0; // KX_Camera* cam = scene->GetActiveCamera(); if (!cam) return; + + SetupViewport(scene, cam, area, viewport); + + // store the computed viewport in the scene + scene->SetSceneViewport(viewport); + + // set the viewport for this frame and scene + m_canvas->SetViewPort(viewport.GetLeft(), viewport.GetBottom(), + viewport.GetRight(), viewport.GetTop()); // see KX_BlenderMaterial::Activate //m_rasterizer->SetAmbient(); @@ -985,8 +1029,8 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) RAS_FramingManager::ComputeFrustum( scene->GetFramingType(), - m_canvas->GetDisplayArea(), - scene->GetSceneViewport(), + area, + viewport, lens, nearfrust, farfrust, @@ -1002,7 +1046,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix( left, right, bottom, top, nearfrust, farfrust, focallength); - + cam->SetProjectionMatrix(projmat); // Otherwise the projection matrix for each eye will be the same... diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 97458362f0f..89f6fe55045 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -177,7 +177,7 @@ private: /** Blue component of framing bar color. */ float m_overrideFrameColorB; - void SetupRenderFrame(KX_Scene *scene, KX_Camera* cam); + void SetupViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport); void RenderFrame(KX_Scene* scene, KX_Camera* cam); void PostRenderFrame(); void RenderDebugProperties(); @@ -355,6 +355,7 @@ protected: KX_Scene* CreateScene(const STR_String& scenename); bool BeginFrame(); + void ClearFrame(); void EndFrame(); }; diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 9fb21a3c17b..f7938bb62e6 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -130,9 +130,6 @@ void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList sort(slots.begin(), slots.end(), fronttoback()); } -//static int TOTASLOT = 0; -//static int TOTSLOT = 0; - void RAS_BucketManager::RenderAlphaBuckets( const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools) { @@ -149,10 +146,8 @@ void RAS_BucketManager::RenderAlphaBuckets( for(sit=slots.begin(); sit!=slots.end(); ++sit) { rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj); - while(sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) { + while(sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms)); - //TOTASLOT++; - } } rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED); @@ -173,13 +168,14 @@ void RAS_BucketManager::RenderSolidBuckets( rendertools->SetClientObject(rasty, mit->m_clientObj); - while ((*bit)->ActivateMaterial(cameratrans, rasty, rendertools)) { + while ((*bit)->ActivateMaterial(cameratrans, rasty, rendertools)) (*bit)->RenderMeshSlot(cameratrans, rasty, rendertools, *mit); - //TOTSLOT++; - } } } + /* this code draws meshes order front-to-back instead to reduce overdraw. + * it turned out slower due to much material state switching, a more clever + * algorithm might do better. */ #if 0 vector slots; vector::iterator sit; @@ -198,17 +194,12 @@ void RAS_BucketManager::RenderSolidBuckets( void RAS_BucketManager::Renderbuckets( const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools) { - // beginning each frame, clear (texture/material) caching information + /* beginning each frame, clear (texture/material) caching information */ rasty->ClearCachingInfo(); - //TOTASLOT = 0; - //TOTSLOT = 0; - RenderSolidBuckets(cameratrans, rasty, rendertools); RenderAlphaBuckets(cameratrans, rasty, rendertools); - //printf("total slots = %d = %d + %d\n", TOTSLOT + TOTASLOT, TOTSLOT, TOTASLOT); - rendertools->SetClientObject(rasty, NULL); } diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h index dcb48c1c2a0..9cb59f300f7 100644 --- a/source/gameengine/Rasterizer/RAS_FramingManager.h +++ b/source/gameengine/Rasterizer/RAS_FramingManager.h @@ -108,6 +108,13 @@ public : ) const { return m_frame_type; }; + + void + SetFrameType( + RAS_FrameType type + ) { + m_frame_type = type; + }; float BarRed( @@ -140,14 +147,6 @@ public : }; private : - - /** - * private to force use of public constructor - */ - - RAS_FrameSettings( - const RAS_FrameSettings & - ); RAS_FrameType m_frame_type; float m_bar_r; diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 1d18d02a583..411b28fa3b7 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -168,6 +168,10 @@ public: * BeginFrame is called at the start of each frame. */ virtual bool BeginFrame(int drawingmode, double time)=0; + /** + * ClearColorBuffer clears the color buffer. + */ + virtual void ClearColorBuffer()=0; /** * ClearDepthBuffer clears the depth buffer. */ @@ -181,7 +185,8 @@ public: */ virtual void EndFrame()=0; /** - * SetRenderArea sets the render area from the 2d canvas + * SetRenderArea sets the render area from the 2d canvas. + * Returns true if only of subset of the canvas is used. */ virtual void SetRenderArea()=0; @@ -195,6 +200,7 @@ public: * @return true if stereo mode is enabled. */ virtual bool Stereo()=0; + virtual bool InterlacedStereo()=0; /** * Sets which eye buffer subsequent primitives will be rendered to. */ diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 62ee2edb731..4f31ae7fcbc 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -105,8 +105,12 @@ bool RAS_OpenGLRasterizer::Init() m_ambg = 0.0f; m_ambb = 0.0f; - SetBlendingMode(GPU_BLEND_SOLID); - SetFrontFace(true); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + m_last_blendmode = GPU_BLEND_SOLID; + + glFrontFace(GL_CCW); + m_last_frontface = true; glClearColor(m_redback,m_greenback,m_blueback,m_alphaback); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); @@ -250,21 +254,10 @@ void RAS_OpenGLRasterizer::Exit() EndFrame(); } -bool RAS_OpenGLRasterizer::InterlacedStereo() const -{ - return m_stereomode == RAS_STEREO_VINTERLACE || m_stereomode == RAS_STEREO_INTERLACED; -} - bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time) { m_time = time; m_drawingmode = drawingmode; - - if (!InterlacedStereo() || m_curreye == RAS_STEREO_LEFTEYE) - { - m_2DCanvas->ClearColor(m_redback,m_greenback,m_blueback,m_alphaback); - m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER); - } // Blender camera routine destroys the settings if (m_drawingmode < KX_SOLID) @@ -278,8 +271,12 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time) glEnable (GL_CULL_FACE); } - SetBlendingMode(GPU_BLEND_SOLID); - SetFrontFace(true); + glDisable(GL_BLEND); + glDisable(GL_ALPHA_TEST); + m_last_blendmode = GPU_BLEND_SOLID; + + glFrontFace(GL_CCW); + m_last_frontface = true; glShadeModel(GL_SMOOTH); @@ -310,6 +307,12 @@ void RAS_OpenGLRasterizer::SetDepthMask(DepthMask depthmask) } +void RAS_OpenGLRasterizer::ClearColorBuffer() +{ + m_2DCanvas->ClearColor(m_redback,m_greenback,m_blueback,m_alphaback); + m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER); +} + void RAS_OpenGLRasterizer::ClearDepthBuffer() { @@ -420,6 +423,10 @@ bool RAS_OpenGLRasterizer::Stereo() return true; } +bool RAS_OpenGLRasterizer::InterlacedStereo() +{ + return m_stereomode == RAS_STEREO_VINTERLACE || m_stereomode == RAS_STEREO_INTERLACED; +} void RAS_OpenGLRasterizer::SetEye(const StereoEye eye) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 368bd4312ac..0717cce0ce8 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -88,7 +88,6 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer float m_focallength; bool m_setfocallength; int m_noOfScanlines; - bool InterlacedStereo() const; //motion blur int m_motionblur; @@ -131,6 +130,7 @@ public: virtual bool Init(); virtual void Exit(); virtual bool BeginFrame(int drawingmode, double time); + virtual void ClearColorBuffer(); virtual void ClearDepthBuffer(); virtual void ClearCachingInfo(void); virtual void EndFrame(); @@ -138,6 +138,7 @@ public: virtual void SetStereoMode(const StereoMode stereomode); virtual bool Stereo(); + virtual bool InterlacedStereo(); virtual void SetEye(const StereoEye eye); virtual StereoEye GetEye(); virtual void SetEyeSeparation(const float eyeseparation); -- cgit v1.2.3 From c4cde9a02724abdf1488634fc39d2d822907278e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 14 Sep 2008 01:10:45 +0000 Subject: Fix for bug #7097: blender multitexture materials in the game engine player did not enable mipmapping when falling back to texfaces. Also commented out code that disabled mipmapping in the player on Mac OS X. If that is a workaround for a bug it is a really poor one, and hopefully fixed now since this code is from 2002 or earlier. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 1 + source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 7a04a42e90d..4851b7f9b08 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -377,6 +377,7 @@ BL_Material* ConvertMaterial( material->texname[i] = material->img[i]->id.name; material->flag[i] |= ( tface->transp &TF_ALPHA )?USEALPHA:0; material->flag[i] |= ( tface->transp &TF_ADD )?CALCALPHA:0; + material->flag[i] |= MIPMAP; if(material->img[i]->flag & IMA_REFLECT) material->mapping[i].mapping |= USEREFL; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 4d24ba195cc..b0950fece5f 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -594,7 +594,7 @@ int main(int argc, char** argv) { #ifdef __APPLE__ //SYS_WriteCommandLineInt(syshandle, "show_framerate", 1); - SYS_WriteCommandLineInt(syshandle, "nomipmap", 1); + //SYS_WriteCommandLineInt(syshandle, "nomipmap", 1); //fullScreen = false; // Can't use full screen #endif -- cgit v1.2.3 From d111983064296dc9dd2c1b3f1735efd38f95c9d1 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 14 Sep 2008 03:51:51 +0000 Subject: Fix for bug #5758 and #17585: armatures with IK constraint did not work in the game player, now the IK lib is linked into the player. Makefiles/Scons/CMake buildsystems have been updated. Fix materials nodes to work in the game player. --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index b0950fece5f..a50577e2266 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -54,6 +54,7 @@ extern "C" #endif // __cplusplus #include "BKE_global.h" #include "BKE_icons.h" +#include "BKE_node.h" #include "BLI_blenlib.h" #include "DNA_scene_types.h" #include "BLO_readfile.h" @@ -376,6 +377,8 @@ int main(int argc, char** argv) ::DisposeNibReference(nibRef); */ #endif // __APPLE__ + + init_nodesystem(); GEN_init_messaging_system(); @@ -846,6 +849,8 @@ int main(int argc, char** argv) } } + free_nodesystem(); + if (pyGlobalDictString) { free(pyGlobalDictString); pyGlobalDictString = NULL; -- cgit v1.2.3 From b25d0cc5cc7bfa7ce9f668cdba77e9b3f3238d3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 14 Sep 2008 05:42:05 +0000 Subject: game engine didnt compile with recent keyframing changes --- source/gameengine/Converter/KX_BlenderSceneConverter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 2ce325326a8..b05893da4e1 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -662,11 +662,11 @@ extern "C" char *getIpoCurveName( IpoCurve * icu ); struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int); void testhandles_ipocurve(struct IpoCurve *icu); + void insert_vert_icu(struct IpoCurve *, float, float, short); void Mat3ToEul(float tmat[][3], float *eul); - } -IpoCurve* findIpoCurve(IpoCurve* first,char* searchName) +IpoCurve* findIpoCurve(IpoCurve* first, const char* searchName) { IpoCurve* icu1; for( icu1 = first; icu1; icu1 = icu1->next ) -- cgit v1.2.3 From 4245aaed86dad24395d8b863832be23fcb85ae4e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 14 Sep 2008 12:41:42 +0000 Subject: == Global 'Delete Key' Tool == The 'opposite' of the "Insert Key" tool. - Use the hotkey Ctrl-Alt-IKEY to activate. - Only available in 3d-view and buttons window I've added an extra var to verify_ipo and verify_ipocurve to save having to make another duplicate of that code. Hopefully the gameengine compiles ok with this. --- .../Converter/KX_BlenderSceneConverter.cpp | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index b05893da4e1..7eec93dc402 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -660,7 +660,7 @@ extern "C" { Ipo *add_ipo( char *name, int idcode ); char *getIpoCurveName( IpoCurve * icu ); - struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int); + struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int, short); void testhandles_ipocurve(struct IpoCurve *icu); void insert_vert_icu(struct IpoCurve *, float, float, short); void Mat3ToEul(float tmat[][3], float *eul); @@ -873,27 +873,27 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) IpoCurve *icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1); @@ -1029,27 +1029,27 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo() IpoCurve *icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1); icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ"); if (!icu1) - icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z); + icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1); -- cgit v1.2.3 From 2eb8eb4e7eedece1f3233aa0d9889993c8575d3e Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sun, 14 Sep 2008 16:22:03 +0000 Subject: Bugfix: avoid crash with too long pathname. --- source/gameengine/Converter/KX_ConvertActuators.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 799506aecaa..e8be8de95ed 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -74,6 +74,8 @@ #include "BKE_text.h" #include "BLI_blenlib.h" +#define FILE_MAX 240 // repeated here to avoid dependency from BKE_utildefines.h + #include "KX_NetworkMessageActuator.h" #ifdef WIN32 @@ -362,7 +364,7 @@ void BL_ConvertActuators(char* maggiename, if (soundact->sound) { /* Need to convert the samplename into absolute path * before checking if its loaded */ - char fullpath[sizeof(soundact->sound->name)]; + char fullpath[FILE_MAX]; /* dont modify soundact->sound->name, only change a copy */ BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath)); -- cgit v1.2.3 From 59b202fc320a06de79787ef7b95f3c4ce2bc92d0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 14 Sep 2008 17:59:22 +0000 Subject: Fix a game engine crash with mesh objects parented to an armature without vertex groups. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 4851b7f9b08..19fb9d01cbf 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -783,9 +783,9 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* MT_Point2 uv20(0.0,0.0),uv21(0.0,0.0),uv22(0.0,0.0),uv23(0.0,0.0); unsigned int rgb0,rgb1,rgb2,rgb3 = 0; - MT_Vector3 no0, no1, no2, no3; MT_Point3 pt0, pt1, pt2, pt3; - MT_Vector4 tan0, tan1, tan2, tan3; + MT_Vector3 no0(0,0,0), no1(0,0,0), no2(0,0,0), no3(0,0,0); + MT_Vector4 tan0(0,0,0,0), tan1(0,0,0,0), tan2(0,0,0,0), tan3(0,0,0,0); /* get coordinates, normals and tangents */ pt0 = MT_Point3(mvert[mface->v1].co); @@ -807,8 +807,6 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* NormalShortToFloat(n3, mvert[mface->v4].no); no3 = n3; } - else - no3 = MT_Vector3(0.0, 0.0, 0.0); } else { float fno[3]; @@ -2186,16 +2184,16 @@ void BL_ConvertBlenderObjects(struct Main* maggie, for(oit=allblobj.begin(); oit!=allblobj.end(); oit++) { Object* blenderobj = *oit; - if (blenderobj->type==OB_MESH){ + if (blenderobj->type==OB_MESH) { Mesh *me = (Mesh*)blenderobj->data; if (me->dvert){ - KX_GameObject *obj = converter->FindGameObject(blenderobj); + BL_DeformableGameObject *obj = (BL_DeformableGameObject*)converter->FindGameObject(blenderobj); if (obj && blenderobj->parent && blenderobj->parent->type==OB_ARMATURE && blenderobj->partype==PARSKEL){ KX_GameObject *par = converter->FindGameObject(blenderobj->parent); - if (par) - ((BL_SkinDeformer*)(((BL_DeformableGameObject*)obj)->m_pDeformer))->SetArmature((BL_ArmatureObject*) par); + if (par && obj->m_pDeformer) + ((BL_SkinDeformer*)obj->m_pDeformer)->SetArmature((BL_ArmatureObject*) par); } } } -- cgit v1.2.3 From 41a0b56b704758e1e024b2e0df6b97e17f700ecd Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 14 Sep 2008 19:34:06 +0000 Subject: BGE patch: new Physics button and margin parameter in Logic panel. Change subversion. The Physics button controls the creation of a physics representation of the object when starting the game. If the button is not selected, the object is a pure graphical object with no physics representation and all the other physics buttons are hidden. Selecting this button gives access to the usual physics buttons. The physics button is enabled by default to match previous Blender behavior. The margin parameter allows to control the collision margin from the UI. Previously, this parameter was only accessible through Python. By default, the collision margin is set to 0.0 on static objects and 0.06 on dynamic objects. To maintain compatibility with older games, the collision margin is set to 0.06 on all objects when loading older blend file. Note about the collision algorithms in Bullet 2.71 -------------------------------------------------- Bullet 2.71 handles the collision margin differently than Bullet 2.53 (the previous Bullet version in Blender). The collision margin is now kept "inside" the object for box, sphere and cylinder bound shapes. This means that two objects bound to any of these shape will come in close contact when colliding. The static mesh, convex hull and cone shapes still have their collision margin "outside" the object, which leaves a space of 1 or 2 times the collision margin between objects. The situation with Bullet 2.53 was more complicated, generally leading to more space between objects, except for box-box collisions. This means that running a old game under Bullet 2.71 may cause visual problems, especially if the objects are small. You can fix these problems by changing some visual aspect of the objects: center, shape, size, position of children, etc. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 5 +++++ source/gameengine/Ketsji/KX_ConvertPhysicsObject.h | 1 + source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 3 ++- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 2 ++ source/gameengine/Physics/Bullet/CcdPhysicsController.h | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 19fb9d01cbf..8bdec219354 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1279,6 +1279,10 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, //int userigidbody = SYS_GetCommandLineInt(syshandle,"norigidbody",0); //bool bRigidBody = (userigidbody == 0); + // object has physics representation? + if (!(blenderobject->gameflag & OB_PHYSICS)) + return; + // get Root Parent of blenderobject struct Object* parent= blenderobject->parent; while(parent && parent->parent) { @@ -1310,6 +1314,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_isCompoundChild = isCompoundChild; objprop.m_hasCompoundChildren = (blenderobject->gameflag & OB_CHILD) != 0; + objprop.m_margin = blenderobject->margin; if ((objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0)) { diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h index 6653026f28a..248d2f49b0b 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h @@ -86,6 +86,7 @@ struct KX_ObjectProperties bool m_disableSleeping; bool m_hasCompoundChildren; bool m_isCompoundChild; + double m_margin; KX_BoundBoxClass m_boundclass; union { KX_BoxBounds box; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 6507bf501e4..b3f24d97281 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -699,6 +699,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_gravity = btVector3(0,0,0); ci.m_localInertiaTensor =btVector3(0,0,0); ci.m_mass = objprop->m_dyna ? shapeprops->m_mass : 0.f; + ci.m_margin = objprop->m_margin; shapeInfo->m_radius = objprop->m_radius; isbulletdyna = objprop->m_dyna; @@ -786,7 +787,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, return; } - bm->setMargin(0.06); + bm->setMargin(ci.m_margin); if (objprop->m_isCompoundChild) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 4da9143fc3d..8ba138df437 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -277,7 +277,9 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta if (m_collisionShape) { // new shape has no scaling, apply initial scaling + m_collisionShape->setMargin(m_cci.m_margin); m_collisionShape->setLocalScaling(m_cci.m_scaling); + if (m_cci.m_mass) m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index a685c466944..7d55851ebf6 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -145,6 +145,7 @@ struct CcdConstructionInfo m_friction(0.5f), m_linearDamping(0.1f), m_angularDamping(0.1f), + m_margin(0.06f), m_collisionFlags(0), m_bRigid(false), m_collisionFilterGroup(DefaultFilter), @@ -165,6 +166,7 @@ struct CcdConstructionInfo btScalar m_friction; btScalar m_linearDamping; btScalar m_angularDamping; + btScalar m_margin; int m_collisionFlags; bool m_bRigid; -- cgit v1.2.3 From f554f14329cb6c69dfbaf97f055d4651726aa8a3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 14 Sep 2008 21:31:07 +0000 Subject: Fix for bug #17617: GLSL shaders change vertex color unexpectedly. --- source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 69a8271d3e8..788af29c4bb 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -560,7 +560,7 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT) rasty->IndexPrimitives_3DText(ms, m_material, rendertools); // for multitexturing - else if((m_material->GetFlag() & RAS_MULTITEX)) + else if((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL))) rasty->IndexPrimitivesMulti(ms); // use normal IndexPrimitives else -- cgit v1.2.3 From 3b153f887a507181ec37d11eb4ba98dd778f216c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 15 Sep 2008 00:11:30 +0000 Subject: Fix zoom level and clipping to be consistent with the viewport when pressing P without a camera active, now it should match the view exactly. Fix an issue when setting a camera with an actuator and being in orthographic mode in the viewport without an active camera, it used a strange mix of the set camera and the viewport then. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 11 ++++++++-- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 24 ++++++++++++++++++---- source/gameengine/Ketsji/KX_KetsjiEngine.h | 3 +++ 3 files changed, 32 insertions(+), 6 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index fa771cb3ce8..74fe6c68863 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -198,6 +198,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, // some blender stuff MT_CmMatrix4x4 projmat; MT_CmMatrix4x4 viewmat; + float camzoom; int i; for (i = 0; i < 16; i++) @@ -211,8 +212,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, projmat.setElem(i, projmat_linear[i]); } - float camzoom = (1.41421 + (v3d->camzoom / 50.0)); - camzoom *= camzoom; + if(v3d->persp==V3D_CAMOB) { + camzoom = (1.41421 + (v3d->camzoom / 50.0)); + camzoom *= camzoom; + } + else + camzoom = 2.0; + camzoom = 4.0 / camzoom; ketsjiengine->SetDrawType(v3d->drawtype); @@ -293,6 +299,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, ketsjiengine->SetCameraOverrideUseOrtho((v3d->persp == V3D_ORTHO)); ketsjiengine->SetCameraOverrideProjectionMatrix(projmat); ketsjiengine->SetCameraOverrideViewMatrix(viewmat); + ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far); } // create a scene converter, create and convert the startingscene diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 4d83853537e..888dcf3d01f 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -135,6 +135,8 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_overrideCam(false), m_overrideCamUseOrtho(false), + m_overrideCamNear(0.0), + m_overrideCamFar(0.0), m_stereo(false), m_curreye(0), @@ -886,7 +888,12 @@ void KX_KetsjiEngine::SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat) m_overrideCamViewMat = mat; } - +void KX_KetsjiEngine::SetCameraOverrideClipping(float near, float far) +{ + m_overrideCamNear = near; + m_overrideCamFar = far; +} + void KX_KetsjiEngine::SetupViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport) { // In this function we make sure the rasterizer settings are upto @@ -985,6 +992,7 @@ void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene) // update graphics void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) { + bool override_camera; RAS_Rect viewport, area; float left, right, bottom, top, nearfrust, farfrust, focallength; const float ortho = 100.0; @@ -1006,7 +1014,10 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) //m_rasterizer->SetAmbient(); m_rasterizer->DisplayFog(); - if (m_overrideCam && (scene->GetName() == m_overrideSceneName) && m_overrideCamUseOrtho) { + override_camera = m_overrideCam && (scene->GetName() == m_overrideSceneName); + override_camera = override_camera && (cam->GetName() == "__default__cam__"); + + if (override_camera && m_overrideCamUseOrtho) { MT_CmMatrix4x4 projmat = m_overrideCamProjMat; m_rasterizer->SetProjectionMatrix(projmat); } else if (cam->hasValidProjectionMatrix() && !cam->GetViewport() ) @@ -1016,12 +1027,17 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) { RAS_FrameFrustum frustum; float lens = cam->GetLens(); + bool orthographic = !cam->GetCameraData()->m_perspective; nearfrust = cam->GetCameraNear(); farfrust = cam->GetCameraFar(); focallength = cam->GetFocalLength(); - if (!cam->GetCameraData()->m_perspective) - { + if(override_camera) { + nearfrust = m_overrideCamNear; + farfrust = m_overrideCamFar; + } + + if (orthographic) { lens *= ortho; nearfrust = (nearfrust + 1.0)*ortho; farfrust *= ortho; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 89f6fe55045..8fe8731dc05 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -124,6 +124,8 @@ private: bool m_overrideCamUseOrtho; MT_CmMatrix4x4 m_overrideCamProjMat; MT_CmMatrix4x4 m_overrideCamViewMat; + float m_overrideCamNear; + float m_overrideCamFar; bool m_stereo; int m_curreye; @@ -236,6 +238,7 @@ public: void SetCameraOverrideUseOrtho(bool useOrtho); void SetCameraOverrideProjectionMatrix(const MT_CmMatrix4x4& mat); void SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat); + void SetCameraOverrideClipping(float near, float far); /** * Sets display of all frames. -- cgit v1.2.3 From a24960daa8c4555e13bd0218cd735df4063b0e57 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 15 Sep 2008 00:34:43 +0000 Subject: Fix for bug #4859: once a visibility actuator was set it was not possible to change the visibility again through python for example. This is because the actuator kept setting the visibility again each frame, as a workaround for there being no separate visible and viewport culling flag, but that was added some time ago. --- source/gameengine/Ketsji/KX_VisibilityActuator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 60ea6ace53b..e60a8d7c099 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -80,7 +80,7 @@ KX_VisibilityActuator::Update() obj->SetVisible(m_visible, m_recursive); obj->UpdateBuckets(m_recursive); - return true; + return false; } /* ------------------------------------------------------------------------- */ -- cgit v1.2.3 From 2c31cc4503ee4de8e8c4ff5665ed1e7dbabfb832 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 15 Sep 2008 00:57:11 +0000 Subject: Fix for bug #17620: the motion blur actuator did not work correct with an always sensor, it kept resettting the motion blur each frame. --- source/gameengine/GameLogic/SCA_2DFilterActuator.cpp | 8 +++----- .../Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 5 ++++- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index 96a770a553f..9ec4ea00337 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -23,8 +23,8 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( : SCA_IActuator(gameobj, T), m_type(type), m_flag(flag), - m_int_arg(int_arg), m_float_arg(float_arg), + m_int_arg(int_arg), m_rasterizer(rasterizer), m_rendertools(rendertools) { @@ -64,13 +64,11 @@ bool SCA_2DFilterActuator::Update() if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR ) { if(!m_flag) - { m_rasterizer->EnableMotionBlur(m_float_arg); - } else - { m_rasterizer->DisableMotionBlur(); - } + + return false; } else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS) { diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 4f31ae7fcbc..87a0a1d8b9e 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -949,7 +949,10 @@ void RAS_OpenGLRasterizer::SetPolygonOffset(float mult, float add) void RAS_OpenGLRasterizer::EnableMotionBlur(float motionblurvalue) { - m_motionblur = 1; + /* don't just set m_motionblur to 1, but check if it is 0 so + * we don't reset a motion blur that is already enabled */ + if(m_motionblur == 0) + m_motionblur = 1; m_motionblurvalue = motionblurvalue; } -- cgit v1.2.3 From 89721ec4de25172a7ae725eb0a7334ecd5a96535 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 15 Sep 2008 02:18:37 +0000 Subject: replaced static make_absolute_filename with BLI_convertstringcwd --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 47 +----------------------- 1 file changed, 1 insertion(+), 46 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index a50577e2266..c4e738c1896 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -199,51 +199,6 @@ void usage(char* program) printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program); } -static void make_absolute_filename(char *blendfilename) -{ - int abs = 0; - int filelen; - char cwd[FILE_MAXDIR + FILE_MAXFILE]; - char filename[FILE_MAXDIR + FILE_MAXFILE]; - - cwd[0] = filename[0] = '\0'; - - BLI_strncpy(filename, blendfilename, sizeof(filename)); - filelen = strlen(filename); - - /* relative path checks, could do more tests here... */ -#ifdef WIN32 - /* Account for X:/ and X:\ - should be enough */ - if (filelen >= 3 && filename[1] == ':' && (filename[2] == '\\' || filename[2] == '/')) - abs = 1; -#else - if (filelen >= 2 && filename[0] == '/') - abs = 1 ; -#endif - if (!abs) { - BLI_getwdN(cwd); /* incase the full path to the blend isnt used */ - - if (cwd[0] == '\0') { - printf( - "Could not get the current working directory - $PWD for an unknown reason.\n\t" - "Relative linked files will not load if the entire blend path is not used.\n\t" - "The 'Play' button may also fail.\n" - ); - } else { - /* uses the blend path relative to cwd important for loading relative linked files. - * - * cwd should contain c:\ etc on win32 so the relbase can be NULL - * relbase being NULL also prevents // being misunderstood as relative to the current - * blend file which isnt a feature we want to use in this case since were dealing - * with a path from the command line, rather then from inside Blender */ - - BLI_make_file_string(NULL, filename, cwd, blendfilename); - } - } - - BLI_strncpy(blendfilename, filename, sizeof(filename)); -} - static void get_filename(int argc, char **argv, char *filename) { #ifdef __APPLE__ @@ -633,7 +588,7 @@ int main(int argc, char** argv) get_filename(argc, argv, filename); if(filename[0]) - make_absolute_filename(filename); + BLI_convertstringcwd(filename); do { -- cgit v1.2.3 From dc2594c81b5d67cc290f88ca846c5285ba45a412 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 15 Sep 2008 12:40:17 +0000 Subject: Added -d debug option for blenderplayer, and remove some invalid/unnecessary opengl calls on shader errors. --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index c4e738c1896..8fd23318df1 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -52,6 +52,7 @@ extern "C" { #endif // __cplusplus +#include "MEM_guardedalloc.h" #include "BKE_global.h" #include "BKE_icons.h" #include "BKE_node.h" @@ -185,6 +186,7 @@ void usage(char* program) #ifdef _WIN32 printf(" -c: keep console window open\n"); #endif + printf(" -d: turn debugging on\n"); printf(" -g: game engine options:\n"); printf(" Name Default Description\n"); printf(" ----------------------------------------\n"); @@ -414,6 +416,12 @@ int main(int argc, char** argv) } } break; + + case 'd': + i++; + G.f |= G_DEBUG; /* std output printf's */ + MEM_set_memory_debug(); + break; case 'p': // Parse window position and size options -- cgit v1.2.3 From cffba77f50455b300efba1de834e2f8edca64519 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 15 Sep 2008 15:58:50 +0000 Subject: Small tweak to get things compiling again. Kent --- source/gameengine/GamePlayer/ghost/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index 0b187791734..52e219db8f2 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -41,6 +41,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_BMFONT)/include CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include CPPFLAGS += -I../../GamePlayer/common -- cgit v1.2.3 From c6d0be2a9943818b98db3831e5d56969bd95c5fa Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Sep 2008 19:25:35 +0000 Subject: Fix (harmless) error print about GameLogic.globalDict being lost. Also fixed some memory leaks in this code and simplified it. --- .../GamePlayer/ghost/GPG_Application.cpp | 29 +++++++++++------ .../gameengine/GamePlayer/ghost/GPG_Application.h | 23 ------------- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 18 +--------- source/gameengine/Ketsji/KX_PythonInit.cpp | 38 ++++++++++++++-------- 4 files changed, 44 insertions(+), 64 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 580c80ee0a5..752b776beff 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -115,6 +115,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) m_cursor(GHOST_kStandardCursorFirstCursor), m_engineInitialized(0), m_engineRunning(0), + m_isEmbedded(false), m_ketsjiengine(0), m_kxsystem(0), m_keyboard(0), @@ -128,8 +129,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) m_blendermat(0), m_blenderglslmat(0), m_pyGlobalDictString(0), - m_pyGlobalDictString_Length(0), - m_isEmbedded(false) + m_pyGlobalDictString_Length(0) { fSystem = system; } @@ -138,6 +138,12 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) GPG_Application::~GPG_Application(void) { + if(m_pyGlobalDictString) { + delete m_pyGlobalDictString; + m_pyGlobalDictString = 0; + m_pyGlobalDictString_Length = 0; + } + exitEngine(); fSystem->disposeWindow(m_mainWindow); } @@ -680,7 +686,8 @@ bool GPG_Application::startEngine(void) initPythonConstraintBinding(); initMathutils(); - /* Restore the dict */ + // Set the GameLogic.globalDict from marshal'd data, so we can + // load new blend files and keep data in GameLogic.globalDict loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length); m_sceneconverter->ConvertScene( @@ -718,13 +725,15 @@ bool GPG_Application::startEngine(void) void GPG_Application::stopEngine() { - // get the python dict and convert to a string for future use - char *marshal_buffer; - m_pyGlobalDictString_Length = saveGamePythonConfig(&marshal_buffer); - if (m_pyGlobalDictString_Length) { - m_pyGlobalDictString = static_cast (malloc(m_pyGlobalDictString_Length)); - memcpy(m_pyGlobalDictString, marshal_buffer, m_pyGlobalDictString_Length); - } + // GameLogic.globalDict gets converted into a buffer, and sorted in + // m_pyGlobalDictString so we can restore after python has stopped + // and started between .blend file loads. + if(m_pyGlobalDictString) { + delete m_pyGlobalDictString; + m_pyGlobalDictString = 0; + } + + m_pyGlobalDictString_Length = saveGamePythonConfig(&m_pyGlobalDictString); // when exiting the mainloop exitGamePythonScripting(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 7fc369fc0fd..38408f919b4 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -74,29 +74,6 @@ public: bool StartGameEngine(int stereoMode); void StopGameEngine(); - char* - GetPyGlobalDictMarshal() - { - return m_pyGlobalDictString; - }; - - void - SetPyGlobalDictMarshal( char* pyGlobalDictString, int length ) - { - if (m_pyGlobalDictString && m_pyGlobalDictString != pyGlobalDictString) - free(m_pyGlobalDictString); - - m_pyGlobalDictString = pyGlobalDictString; - m_pyGlobalDictString_Length = length; - }; - - int - GetPyGlobalDictMarshalLength() - { - return m_pyGlobalDictString_Length; - }; - - protected: bool handleWheel(GHOST_IEvent* event); bool handleButton(GHOST_IEvent* event, bool isDown); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 8fd23318df1..01774a68cc4 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -301,8 +301,6 @@ int main(int argc, char** argv) GHOST_TUns32 fullScreenHeight= 0; int fullScreenBpp = 32; int fullScreenFrequency = 60; - char* pyGlobalDictString = NULL; /* store python dict data between blend file loading */ - int pyGlobalDictString_Length = 0; GHOST_TEmbedderWindowID parentWindow = 0; @@ -658,10 +656,6 @@ int main(int argc, char** argv) titlename = maggie->name; - // Set the GameLogic.globalDict from marshal'd data, so we can load new blend files - // abd keep data in GameLogic.globalDict - app.SetPyGlobalDictMarshal(pyGlobalDictString, pyGlobalDictString_Length); - // Check whether the game should be displayed full-screen if ((!fullScreenParFound) && (!windowParFound)) { @@ -790,12 +784,7 @@ int main(int argc, char** argv) } } app.StopGameEngine(); - - // GameLogic.globalDict has been converted into a buffer - // store in pyGlobalDictString so we can restore after python has stopped and started. - pyGlobalDictString = app.GetPyGlobalDictMarshal(); - pyGlobalDictString_Length = app.GetPyGlobalDictMarshalLength(); - + BLO_blendfiledata_free(bfd); } } while (exitcode == KX_EXIT_REQUEST_RESTART_GAME || exitcode == KX_EXIT_REQUEST_START_OTHER_GAME); @@ -814,11 +803,6 @@ int main(int argc, char** argv) free_nodesystem(); - if (pyGlobalDictString) { - free(pyGlobalDictString); - pyGlobalDictString = NULL; - } - return error ? -1 : 0; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 5308a0b9536..09c49a15f76 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1393,17 +1393,21 @@ int saveGamePythonConfig( char **marshal_buffer) PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict ); #endif if (pyGlobalDictMarshal) { - marshal_length= PyString_Size(pyGlobalDictMarshal); // for testing only // PyObject_Print(pyGlobalDictMarshal, stderr, 0); - *marshal_buffer = PyString_AsString(pyGlobalDictMarshal); + + marshal_length= PyString_Size(pyGlobalDictMarshal); + *marshal_buffer = new char[marshal_length + 1]; + memcpy(*marshal_buffer, PyString_AsString(pyGlobalDictMarshal), marshal_length); + + Py_DECREF(pyGlobalDictMarshal); } else { printf("Error, GameLogic.globalDict could not be marshal'd\n"); } - Py_DECREF(gameLogic); } else { printf("Error, GameLogic.globalDict was removed\n"); } + Py_DECREF(gameLogic); } else { printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); } @@ -1412,20 +1416,26 @@ int saveGamePythonConfig( char **marshal_buffer) int loadGamePythonConfig(char *marshal_buffer, int marshal_length) { - PyObject* gameLogic = PyImport_ImportModule("GameLogic"); /* Restore the dict */ if (marshal_buffer) { - PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length); - if (pyGlobalDict) { - PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. - return 1; + PyObject* gameLogic = PyImport_ImportModule("GameLogic"); + + if (gameLogic) { + PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length); + + if (pyGlobalDict) { + PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + Py_DECREF(gameLogic); + return 1; + } else { + Py_DECREF(gameLogic); + PyErr_Clear(); + printf("Error could not marshall string\n"); + } } else { - PyErr_Clear(); - printf("Error could not marshall string\n"); - } - } else { - printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); - } + printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); + } + } return 0; } -- cgit v1.2.3 From 99cd0dd5d5373a2437a99b69d3731043d3b014bb Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Sep 2008 19:28:54 +0000 Subject: Fix bug that broke editing vertices through python in the game engine. --- source/gameengine/Rasterizer/RAS_MaterialBucket.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 788af29c4bb..2b129f51609 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -107,8 +107,13 @@ RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot) m_endindex = slot.m_endindex; for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) { - *it = new RAS_DisplayArray(**it); - (*it)->m_users = 1; + // don't copy display arrays for now because it breaks python + // access to vertices, but we'll need a solution if we want to + // join display arrays for reducing draw calls. + //*it = new RAS_DisplayArray(**it); + //(*it)->m_users = 1; + + (*it)->m_users++; } } -- cgit v1.2.3 From 73fd8000775e1558b5140ace86860477d61d8b98 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 16 Sep 2008 21:11:38 +0000 Subject: Fix for bug #5413: game engine armature actions and shapes keys didn't work correct with scene suspend/resume, now works the same as IPO's. --- source/gameengine/Converter/BL_ActionActuator.cpp | 2 ++ source/gameengine/Converter/BL_ShapeActionActuator.cpp | 2 ++ source/gameengine/Ketsji/KX_IpoActuator.cpp | 7 ++++--- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 119465c8726..b8514e33127 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -152,6 +152,8 @@ bool BL_ActionActuator::Update(double curtime, bool frame) bool apply=true; int priority; float newweight; + + curtime -= KX_KetsjiEngine::GetSuspendedDelta(); // result = true if animation has to be continued, false if animation stops // maybe there are events for us in the queue ! diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 679b0df7ec6..da5ca1e7c95 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -155,6 +155,8 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) bool apply=true; int priority; float newweight; + + curtime -= KX_KetsjiEngine::GetSuspendedDelta(); // result = true if animation has to be continued, false if animation stops // maybe there are events for us in the queue ! diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index a203ea6a6ff..75e4ade6574 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -130,7 +130,6 @@ void KX_IpoActuator::SetStartTime(float curtime) { float direction = m_startframe < m_endframe ? 1.0f : -1.0f; - curtime = curtime - KX_KetsjiEngine::GetSuspendedDelta(); if (m_direction > 0) m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate(); else @@ -139,7 +138,7 @@ void KX_IpoActuator::SetStartTime(float curtime) void KX_IpoActuator::SetLocalTime(float curtime) { - float delta_time = ((curtime - m_starttime) - KX_KetsjiEngine::GetSuspendedDelta())*KX_KetsjiEngine::GetAnimFrameRate(); + float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate(); // negative delta_time is caused by floating point inaccuracy // perhaps the inaccuracy could be reduced a bit @@ -165,6 +164,8 @@ bool KX_IpoActuator::Update(double curtime, bool frame) int numevents = 0; bool bIpoStart = false; + curtime -= KX_KetsjiEngine::GetSuspendedDelta(); + if (frame) { numevents = m_events.size(); @@ -180,7 +181,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame) if (m_starttime < -2.0f*start_smaller_then_end*(m_endframe - m_startframe)) { // start for all Ipo, initial start for LOOP_STOP - m_starttime = curtime - KX_KetsjiEngine::GetSuspendedDelta(); + m_starttime = curtime; m_bIpoPlaying = true; bIpoStart = true; } -- cgit v1.2.3 From 9b7d40dbae1be5aa18894ffbc8f97a4a8c4c6fdd Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 16 Sep 2008 22:52:42 +0000 Subject: BGE patch: bullet buttons UI change after discussion with Erwin: use a drop down instead of a series of buttons. Introduction of soft body option. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 8bdec219354..c3992d02eee 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1280,7 +1280,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, //bool bRigidBody = (userigidbody == 0); // object has physics representation? - if (!(blenderobject->gameflag & OB_PHYSICS)) + if (!(blenderobject->gameflag & OB_COLLISION)) return; // get Root Parent of blenderobject -- cgit v1.2.3 From 9064ed8d6aa934dedc4b344e328566a8549371f6 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 17 Sep 2008 01:29:54 +0000 Subject: Fix for bug #4192: game engine armatures that are dynamically added but don't have an action got the pose of already added armatures, even though they're not related. This also fixes an issue where the armature in Blender would end up in the pose from the game after ESC, removes unneeded copies made during armature evaluation, and also solves the constraint copying hack. --- source/gameengine/Converter/BL_ActionActuator.cpp | 6 +-- source/gameengine/Converter/BL_ArmatureObject.cpp | 47 ++++++++-------------- source/gameengine/Converter/BL_ArmatureObject.h | 3 +- source/gameengine/Converter/BL_ShapeDeformer.cpp | 4 ++ source/gameengine/Converter/BL_SkinDeformer.cpp | 2 + .../GamePlayer/ghost/GPG_Application.cpp | 4 +- 6 files changed, 30 insertions(+), 36 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index b8514e33127..c08427c6d27 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -59,11 +59,11 @@ BL_ActionActuator::~BL_ActionActuator() { if (m_pose) - free_pose(m_pose); + game_free_pose(m_pose); if (m_userpose) - free_pose(m_userpose); + game_free_pose(m_userpose); if (m_blendpose) - free_pose(m_blendpose); + game_free_pose(m_blendpose); } void BL_ActionActuator::ProcessReplica(){ diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index bf774bf7568..d2001212f7d 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -45,7 +45,6 @@ #include #endif - BL_ArmatureObject::BL_ArmatureObject( void* sgReplicationInfo, SG_Callbacks callbacks, @@ -65,7 +64,7 @@ BL_ArmatureObject::BL_ArmatureObject( * the original pose before calling into blender functions, to deal with * replica's or other objects using the same blender object */ m_pose = NULL; - copy_pose(&m_pose, m_objArma->pose, 1 /* copy_constraint_channels_hack */); + game_copy_pose(&m_pose, m_objArma->pose); } CValue* BL_ArmatureObject::GetReplica() @@ -84,32 +83,30 @@ void BL_ArmatureObject::ProcessReplica(BL_ArmatureObject *replica) KX_GameObject::ProcessReplica(replica); replica->m_pose = NULL; - copy_pose(&replica->m_pose, m_pose, 1 /* copy_constraint_channels_hack */); + game_copy_pose(&replica->m_pose, m_pose); } BL_ArmatureObject::~BL_ArmatureObject() { if (m_pose) - free_pose(m_pose); + game_free_pose(m_pose); } -bool BL_ArmatureObject::VerifyPose() +void BL_ArmatureObject::ApplyPose() { + m_armpose = m_objArma->pose; + m_objArma->pose = m_pose; + if(m_lastapplyframe != m_lastframe) { - extract_pose_from_pose(m_objArma->pose, m_pose); where_is_pose(m_objArma); m_lastapplyframe = m_lastframe; - extract_pose_from_pose(m_pose, m_objArma->pose); - return false; } - else - return true; } -void BL_ArmatureObject::ApplyPose() +void BL_ArmatureObject::RestorePose() { - if(VerifyPose()) - extract_pose_from_pose(m_objArma->pose, m_pose); + m_objArma->pose = m_armpose; + m_armpose = NULL; } void BL_ArmatureObject::SetPose(bPose *pose) @@ -164,8 +161,7 @@ void BL_ArmatureObject::GetPose(bPose **pose) a crash and memory leakage when &BL_ActionActuator::m_pose is freed */ - int copy_constraint_channels_hack = 1; - copy_pose(pose, m_pose, copy_constraint_channels_hack); + game_copy_pose(pose, m_pose); } else { if (*pose == m_pose) @@ -181,17 +177,10 @@ void BL_ArmatureObject::GetMRDPose(bPose **pose) /* If the caller supplies a null pose, create a new one. */ /* Otherwise, copy the armature's pose channels into the caller-supplied pose */ - if (!*pose) { - // must duplicate the constraints too otherwise we have corruption in free_pose_channels() - // because it will free the blender constraints. - // Ideally, blender should rememeber that the constraints were not copied so that - // free_pose_channels() would not free them. - copy_pose(pose, m_pose, 1); - } - else { + if (!*pose) + game_copy_pose(pose, m_pose); + else extract_pose_from_pose(*pose, m_pose); - } - } short BL_ArmatureObject::GetActivePriority() @@ -210,13 +199,11 @@ bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) ApplyPose(); pchan = get_pose_channel(m_objArma->pose, bone->name); - - if(pchan) { + if(pchan) matrix.setValue(&pchan->pose_mat[0][0]); - return true; - } + RestorePose(); - return false; + return (pchan != NULL); } float BL_ArmatureObject::GetBoneLength(Bone* bone) const diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index 6f2c0d2f4c9..d68e37d9e37 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -61,7 +61,7 @@ public: void SetPose (struct bPose *pose); void ApplyPose(); - bool VerifyPose(); + void RestorePose(); bool SetActiveAction(class BL_ActionActuator *act, short priority, double curtime); @@ -82,6 +82,7 @@ protected: Object *m_objArma; struct bArmature *m_armature; struct bPose *m_pose; + struct bPose *m_armpose; struct bPose *m_framePose; double m_lastframe; class BL_ActionActuator *m_activeAct; diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 236cd1a6667..dfd33e45fef 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -109,6 +109,7 @@ bool BL_ShapeDeformer::ExecuteShapeDrivers(void) vector::iterator it; void *poin; int type; + // the shape drivers use the bone matrix as input. Must // update the matrix now m_armobj->ApplyPose(); @@ -121,7 +122,10 @@ bool BL_ShapeDeformer::ExecuteShapeDrivers(void) if (poin) write_ipo_poin(poin, type, icu->curval); } + ForceUpdate(); + m_armobj->RestorePose(); + return true; } return false; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index d8e7a9cdadf..b7b39ad7fbf 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -197,6 +197,8 @@ bool BL_SkinDeformer::Update(void) /* Update the current frame */ m_lastArmaUpdate=m_armobj->GetLastFrame(); + m_armobj->RestorePose(); + /* indicate that the m_transverts and normals are up to date */ return true; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 752b776beff..4cd5184fee1 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -139,7 +139,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) GPG_Application::~GPG_Application(void) { if(m_pyGlobalDictString) { - delete m_pyGlobalDictString; + delete [] m_pyGlobalDictString; m_pyGlobalDictString = 0; m_pyGlobalDictString_Length = 0; } @@ -729,7 +729,7 @@ void GPG_Application::stopEngine() // m_pyGlobalDictString so we can restore after python has stopped // and started between .blend file loads. if(m_pyGlobalDictString) { - delete m_pyGlobalDictString; + delete [] m_pyGlobalDictString; m_pyGlobalDictString = 0; } -- cgit v1.2.3 From ae418491dcbfa5c7e7415523695bdaea78a0b03e Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 17 Sep 2008 01:49:47 +0000 Subject: Preparation for real-time soft bodies for the game engine, step 1 out of 3. This should be harmless/non-intrusive. Please make sure each build system include extern/bullet2/src/BulletSoftBody/* and extern/bullet2/src/LinearMath/btConvexHull.* --- .../Physics/Bullet/CcdPhysicsController.cpp | 377 ++++++++++++++------- .../Physics/Bullet/CcdPhysicsController.h | 16 +- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 156 ++++++--- .../Physics/Bullet/CcdPhysicsEnvironment.h | 4 +- 4 files changed, 377 insertions(+), 176 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 8ba138df437..b1b97b5370f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -19,6 +19,7 @@ subject to the following restrictions: #include "PHY_IMotionState.h" #include "CcdPhysicsEnvironment.h" #include "RAS_MeshObject.h" +#include "BulletSoftBody/btSoftBody.h" class BP_Proxy; @@ -63,11 +64,11 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) CreateRigidbody(); - - #ifdef WIN32 - if (m_body->getInvMass()) - m_body->setLinearVelocity(startVel); - #endif +///??? +#ifdef WIN32 + if (GetRigidBody() && !GetRigidBody()->isStaticObject()) + GetRigidBody()->setLinearVelocity(startVel); +#endif } @@ -119,20 +120,59 @@ public: }; +btRigidBody* CcdPhysicsController::GetRigidBody() +{ + return btRigidBody::upcast(m_object); +} +btCollisionObject* CcdPhysicsController::GetCollisionObject() +{ + return m_object; +} +btSoftBody* CcdPhysicsController::GetSoftBody() +{ + return btSoftBody::upcast(m_object); +} + + void CcdPhysicsController::CreateRigidbody() { btTransform trans = GetTransformFromMotionState(m_MotionState); - m_bulletMotionState = new BlenderBulletMotionState(m_MotionState); - btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); - rbci.m_linearDamping = m_cci.m_linearDamping; - rbci.m_angularDamping = m_cci.m_angularDamping; - rbci.m_friction = m_cci.m_friction; - rbci.m_restitution = m_cci.m_restitution; - - m_body = new btRigidBody(rbci); + ///either create a btCollisionObject, btRigidBody or btSoftBody + + //create a collision object + if (0)//m_cci.m_mass==0.f) + { + btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); + rbci.m_linearDamping = m_cci.m_linearDamping; + rbci.m_angularDamping = m_cci.m_angularDamping; + rbci.m_friction = m_cci.m_friction; + rbci.m_restitution = m_cci.m_restitution; + m_object = new btCollisionObject(); + m_object->setCollisionShape(rbci.m_collisionShape); + btTransform startTrans; + + if (rbci.m_motionState) + { + rbci.m_motionState->getWorldTransform(startTrans); + } else + { + startTrans = rbci.m_startWorldTransform; + } + m_object->setWorldTransform(startTrans); + m_object->setInterpolationWorldTransform(startTrans); + + } else + { + btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); + rbci.m_linearDamping = m_cci.m_linearDamping; + rbci.m_angularDamping = m_cci.m_angularDamping; + rbci.m_friction = m_cci.m_friction; + rbci.m_restitution = m_cci.m_restitution; + m_object = new btRigidBody(rbci); + } // // init the rigidbody properly @@ -145,15 +185,20 @@ void CcdPhysicsController::CreateRigidbody() if ((m_cci.m_collisionFilterGroup & CcdConstructionInfo::SensorFilter) != 0) { // reset the flags that have been set so far - m_body->setCollisionFlags(0); + GetCollisionObject()->setCollisionFlags(0); } - m_body->setCollisionFlags(m_body->getCollisionFlags() | m_cci.m_collisionFlags); - m_body->setGravity( m_cci.m_gravity); - m_body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping); + GetCollisionObject()->setCollisionFlags(m_object->getCollisionFlags() | m_cci.m_collisionFlags); + btRigidBody* body = GetRigidBody(); - if (!m_cci.m_bRigid) + if (body) { - m_body->setAngularFactor(0.f); + body->setGravity( m_cci.m_gravity); + body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping); + + if (!m_cci.m_bRigid) + { + body->setAngularFactor(0.f); + } } } @@ -180,7 +225,7 @@ CcdPhysicsController::~CcdPhysicsController() delete m_MotionState; if (m_bulletMotionState) delete m_bulletMotionState; - delete m_body; + delete m_object; if (m_collisionShape) { @@ -212,12 +257,14 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) { //sync non-static to motionstate, and static from motionstate (todo: add kinematic etc.) - if (!m_body->isStaticObject()) + btRigidBody* body = GetRigidBody(); + + if (body && !body->isStaticObject()) { - const btVector3& worldPos = m_body->getCenterOfMassPosition(); + const btVector3& worldPos = body->getCenterOfMassPosition(); m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); - const btQuaternion& worldquat = m_body->getOrientation(); + const btQuaternion& worldquat = body->getOrientation(); m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]); m_MotionState->calculateWorldTransformations(); @@ -236,7 +283,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) btTransform oldTrans = m_body->getCenterOfMassTransform(); btTransform newTrans(worldquat,worldPos); - m_body->setCenterOfMassTransform(newTrans); + SetCenterOfMassTransform(newTrans); //need to keep track of previous position for friction effects... m_MotionState->calculateWorldTransformations(); @@ -285,15 +332,17 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta } } - m_body = 0; + m_object = 0; CreateRigidbody(); - if (m_body) + btRigidBody* body = GetRigidBody(); + + if (body) { if (m_cci.m_mass) { - m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); - } + body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); + } } m_cci.m_physicsEnv->addCcdPhysicsController(this); @@ -328,42 +377,77 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta +} + + +void CcdPhysicsController::SetCenterOfMassTransform(btTransform& xform) +{ + btRigidBody* body = GetRigidBody(); + if (body) + { + body->setCenterOfMassTransform(xform); + } else + { + //either collision object or soft body? + if (GetSoftBody()) + { + //not yet + } else + { + + if (m_object->isStaticOrKinematicObject()) + { + m_object->setInterpolationWorldTransform(m_object->getWorldTransform()); + } else + { + m_object->setInterpolationWorldTransform(xform); + } + if (body) + { + body->setInterpolationLinearVelocity(body->getLinearVelocity()); + body->setInterpolationAngularVelocity(body->getAngularVelocity()); + body->updateInertiaTensor(); + } + m_object->setWorldTransform(xform); + } + } } // kinematic methods void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local) { - if (m_body) + if (m_object) { - m_body->activate(true); - if (m_body->isStaticObject()) + m_object->activate(true); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } + btRigidBody* body = GetRigidBody(); btVector3 dloc(dlocX,dlocY,dlocZ); - btTransform xform = m_body->getCenterOfMassTransform(); - + btTransform xform = m_object->getWorldTransform(); + if (local) { dloc = xform.getBasis()*dloc; } xform.setOrigin(xform.getOrigin() + dloc); - m_body->setCenterOfMassTransform(xform); + SetCenterOfMassTransform(xform); } } void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) { - if (m_body) + if (m_object) { - m_body->activate(true); - if (m_body->isStaticObject()) + m_object->activate(true); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } btMatrix3x3 drotmat( rotval[0],rotval[4],rotval[8], @@ -374,16 +458,16 @@ void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local) btMatrix3x3 currentOrn; GetWorldOrientation(currentOrn); - btTransform xform = m_body->getCenterOfMassTransform(); - + btTransform xform = m_object->getWorldTransform(); + xform.setBasis(xform.getBasis()*(local ? drotmat : (currentOrn.inverse() * drotmat * currentOrn))); - m_body->setCenterOfMassTransform(xform); + SetCenterOfMassTransform(xform); } - } + void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat) { float orn[4]; @@ -394,7 +478,7 @@ void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat) void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal) { - btQuaternion q = m_body->getCenterOfMassTransform().getRotation(); + btQuaternion q = m_object->getWorldTransform().getRotation(); quatImag0 = q[0]; quatImag1 = q[1]; quatImag2 = q[2]; @@ -402,18 +486,18 @@ void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,flo } void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal) { - if (m_body) + if (m_object) { - m_body->activate(true); - if (m_body->isStaticObject()) + m_object->activate(true); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } // not required //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); - btTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = m_object->getWorldTransform(); xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal)); - m_body->setCenterOfMassTransform(xform); + SetCenterOfMassTransform(xform); // not required //m_bulletMotionState->setWorldTransform(xform); } @@ -422,18 +506,18 @@ void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn) { - if (m_body) + if (m_object) { - m_body->activate(true); - if (m_body->isStaticObject()) + m_object->activate(true); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } // not required //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal); - btTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = m_object->getWorldTransform(); xform.setBasis(orn); - m_body->setCenterOfMassTransform(xform); + SetCenterOfMassTransform(xform); // not required //m_bulletMotionState->setWorldTransform(xform); } @@ -442,18 +526,18 @@ void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn) void CcdPhysicsController::setPosition(float posX,float posY,float posZ) { - if (m_body) + if (m_object) { - m_body->activate(true); - if (m_body->isStaticObject()) + m_object->activate(true); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } // not required, this function is only used to update the physic controller //m_MotionState->setWorldPosition(posX,posY,posZ); - btTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = m_object->getWorldTransform(); xform.setOrigin(btVector3(posX,posY,posZ)); - m_body->setCenterOfMassTransform(xform); + SetCenterOfMassTransform(xform); // not required //m_bulletMotionState->setWorldTransform(xform); } @@ -466,7 +550,7 @@ void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvel void CcdPhysicsController::getPosition(PHY__Vector3& pos) const { - const btTransform& xform = m_body->getCenterOfMassTransform(); + const btTransform& xform = m_object->getWorldTransform(); pos[0] = xform.getOrigin().x(); pos[1] = xform.getOrigin().y(); pos[2] = xform.getOrigin().z(); @@ -480,15 +564,16 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ) { m_cci.m_scaling = btVector3(scaleX,scaleY,scaleZ); - if (m_body && m_body->getCollisionShape()) + if (m_object && m_object->getCollisionShape()) { - m_body->getCollisionShape()->setLocalScaling(m_cci.m_scaling); + m_object->getCollisionShape()->setLocalScaling(m_cci.m_scaling); //printf("no inertia recalc for fixed objects with mass=0\n"); - if (m_cci.m_mass) + btRigidBody* body = GetRigidBody(); + if (body && m_cci.m_mass) { - m_body->getCollisionShape()->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); - m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); + body->getCollisionShape()->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); + body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); } } @@ -499,19 +584,23 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ) void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local) { btVector3 torque(torqueX,torqueY,torqueZ); - btTransform xform = m_body->getCenterOfMassTransform(); - if (m_body && torque.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + btTransform xform = m_object->getWorldTransform(); + + + if (m_object && torque.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { - m_body->activate(); - if (m_body->isStaticObject()) + btRigidBody* body = GetRigidBody(); + m_object->activate(); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } if (local) { torque = xform.getBasis()*torque; } - m_body->applyTorque(torque); + if (body) + body->applyTorque(torque); } } @@ -519,41 +608,47 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo { btVector3 force(forceX,forceY,forceZ); - if (m_body && force.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + + if (m_object && force.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { - m_body->activate(); - if (m_body->isStaticObject()) + m_object->activate(); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } + + btRigidBody* body = GetRigidBody(); + if (body) { - btTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = body->getCenterOfMassTransform(); if (local) { force = xform.getBasis()*force; } + body->applyCentralForce(force); } - m_body->applyCentralForce(force); } } void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local) { btVector3 angvel(ang_velX,ang_velY,ang_velZ); - if (m_body && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_object && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { - m_body->activate(true); - if (m_body->isStaticObject()) + m_object->activate(true); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } + btRigidBody* body = GetRigidBody(); + if (body) { - btTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = body->getCenterOfMassTransform(); if (local) { angvel = xform.getBasis()*angvel; } + body->setAngularVelocity(angvel); } - m_body->setAngularVelocity(angvel); } } @@ -561,39 +656,41 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa { btVector3 linVel(lin_velX,lin_velY,lin_velZ); - if (m_body && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_object && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { - m_body->activate(true); - if (m_body->isStaticObject()) + m_object->activate(true); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } - + btRigidBody* body = GetRigidBody(); + if (body) { - btTransform xform = m_body->getCenterOfMassTransform(); + btTransform xform = m_object->getWorldTransform(); if (local) { linVel = xform.getBasis()*linVel; } + body->setLinearVelocity(linVel); } - m_body->setLinearVelocity(linVel); } } void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ) { btVector3 impulse(impulseX,impulseY,impulseZ); - if (m_body && impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_object && impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON)) { - m_body->activate(); - if (m_body->isStaticObject()) + m_object->activate(); + if (m_object->isStaticObject()) { - m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } btVector3 pos(attachX,attachY,attachZ); - - m_body->applyImpulse(impulse,pos); + btRigidBody* body = GetRigidBody(); + if (body) + body->applyImpulse(impulse,pos); } } @@ -603,29 +700,56 @@ void CcdPhysicsController::SetActive(bool active) // reading out information from physics void CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ) { - const btVector3& linvel = this->m_body->getLinearVelocity(); - linvX = linvel.x(); - linvY = linvel.y(); - linvZ = linvel.z(); + btRigidBody* body = GetRigidBody(); + if (body) + { + const btVector3& linvel = body->getLinearVelocity(); + linvX = linvel.x(); + linvY = linvel.y(); + linvZ = linvel.z(); + } else + { + linvX = 0.f; + linvY = 0.f; + linvZ = 0.f; + } } void CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ) { - const btVector3& angvel= m_body->getAngularVelocity(); - angVelX = angvel.x(); - angVelY = angvel.y(); - angVelZ = angvel.z(); + btRigidBody* body = GetRigidBody(); + if (body) + { + const btVector3& angvel= body->getAngularVelocity(); + angVelX = angvel.x(); + angVelY = angvel.y(); + angVelZ = angvel.z(); + } else + { + angVelX = 0.f; + angVelY = 0.f; + angVelZ = 0.f; + } } void CcdPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ) { btVector3 pos(posX,posY,posZ); - btVector3 rel_pos = pos-m_body->getCenterOfMassPosition(); - btVector3 linvel = m_body->getVelocityInLocalPoint(rel_pos); - linvX = linvel.x(); - linvY = linvel.y(); - linvZ = linvel.z(); + btRigidBody* body = GetRigidBody(); + if (body) + { + btVector3 rel_pos = pos-body->getCenterOfMassPosition(); + btVector3 linvel = body->getVelocityInLocalPoint(rel_pos); + linvX = linvel.x(); + linvY = linvel.y(); + linvZ = linvel.z(); + } else + { + linvX = 0.f; + linvY = 0.f; + linvZ = 0.f; + } } void CcdPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ) { @@ -636,11 +760,15 @@ void CcdPhysicsController::setRigidBody(bool rigid) { if (!rigid) { - //fake it for now - btVector3 inertia = m_body->getInvInertiaDiagLocal(); - inertia[1] = 0.f; - m_body->setInvInertiaDiagLocal(inertia); - m_body->updateInertiaTensor(); + btRigidBody* body = GetRigidBody(); + if (body) + { + //fake it for now + btVector3 inertia = body->getInvInertiaDiagLocal(); + inertia[1] = 0.f; + body->setInvInertiaDiagLocal(inertia); + body->updateInertiaTensor(); + } } } @@ -657,13 +785,22 @@ void CcdPhysicsController::setNewClientInfo(void* clientinfo) void CcdPhysicsController::UpdateDeactivation(float timeStep) { - m_body->updateDeactivation( timeStep); + btRigidBody* body = GetRigidBody(); + if (body) + { + body->updateDeactivation( timeStep); + } } bool CcdPhysicsController::wantsSleeping() { - - return m_body->wantsSleeping(); + btRigidBody* body = GetRigidBody(); + if (body) + { + return body->wantsSleeping(); + } + //check it out + return true; } PHY_IPhysicsController* CcdPhysicsController::GetReplica() diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 7d55851ebf6..355c1d608b1 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -190,12 +190,15 @@ struct CcdConstructionInfo class btRigidBody; - +class btCollisionObject; +class btSoftBody; ///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution. class CcdPhysicsController : public PHY_IPhysicsController { - btRigidBody* m_body; + + btCollisionObject* m_object; + class PHY_IMotionState* m_MotionState; btMotionState* m_bulletMotionState; class btCollisionShape* m_collisionShape; @@ -231,11 +234,14 @@ class CcdPhysicsController : public PHY_IPhysicsController virtual ~CcdPhysicsController(); - btRigidBody* GetRigidBody() { return m_body;} + btRigidBody* GetRigidBody(); + btCollisionObject* GetCollisionObject(); + btSoftBody* GetSoftBody(); + CcdShapeConstructionInfo* GetShapeInfo() { return m_shapeInfo; } btCollisionShape* GetCollisionShape() { - return m_body->getCollisionShape(); + return m_object->getCollisionShape(); } //////////////////////////////////// // PHY_IPhysicsController interface @@ -310,6 +316,8 @@ class CcdPhysicsController : public PHY_IPhysicsController void UpdateDeactivation(float timeStep); + void SetCenterOfMassTransform(btTransform& xform); + static btTransform GetTransformFromMotionState(PHY_IMotionState* motionState); void setAabb(const btVector3& aabbMin,const btVector3& aabbMax); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 5042df2162a..96caf885e7c 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -23,6 +23,7 @@ subject to the following restrictions: #include "btBulletDynamicsCommon.h" #include "LinearMath/btIDebugDraw.h" #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" +#include "BulletSoftBody/btSoftRigidDynamicsWorld.h" //profiling/timings #include "LinearMath/btQuickprof.h" @@ -344,7 +345,9 @@ m_filterCallback(NULL) m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback); setSolverType(1);//issues with quickstep and memory allocations - m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); +// m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); + m_dynamicsWorld = new btSoftRigidDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration); + m_debugDrawer = 0; m_gravity = btVector3(0.f,-10.f,0.f); m_dynamicsWorld->setGravity(m_gravity); @@ -355,24 +358,43 @@ m_filterCallback(NULL) void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) { btRigidBody* body = ctrl->GetRigidBody(); + btCollisionObject* obj = ctrl->GetCollisionObject(); //this m_userPointer is just used for triggers, see CallbackTriggers - body->setUserPointer(ctrl); + obj->setUserPointer(ctrl); + if (body) + body->setGravity( m_gravity ); - body->setGravity( m_gravity ); m_controllers.insert(ctrl); - //use explicit group/filter for finer control over collision in bullet => near/radar sensor - m_dynamicsWorld->addRigidBody(body, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask()); - if (body->isStaticOrKinematicObject()) + if (body) + { + //use explicit group/filter for finer control over collision in bullet => near/radar sensor + m_dynamicsWorld->addRigidBody(body, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask()); + } else + { + if (ctrl->GetSoftBody()) + { + //not yet + btAssert(0); + //m_dynamicsWorld->addSo + } else + { + if (obj->getCollisionShape()) + { + m_dynamicsWorld->addCollisionObject(obj,ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask()); + } + } + } + if (obj->isStaticOrKinematicObject()) { - body->setActivationState(ISLAND_SLEEPING); + obj->setActivationState(ISLAND_SLEEPING); } //CollisionObject(body,ctrl->GetCollisionFilterGroup(),ctrl->GetCollisionFilterMask()); - assert(body->getBroadphaseHandle()); + assert(obj->getBroadphaseHandle()); btBroadphaseInterface* scene = getBroadphase(); @@ -381,7 +403,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) assert(shapeinterface); - const btTransform& t = ctrl->GetRigidBody()->getCenterOfMassTransform(); + const btTransform& t = ctrl->GetCollisionObject()->getWorldTransform(); btPoint3 minAabb,maxAabb; @@ -393,32 +415,34 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) //extent it with the motion - btVector3 linMotion = body->getLinearVelocity()*timeStep; - - float maxAabbx = maxAabb.getX(); - float maxAabby = maxAabb.getY(); - float maxAabbz = maxAabb.getZ(); - float minAabbx = minAabb.getX(); - float minAabby = minAabb.getY(); - float minAabbz = minAabb.getZ(); - - if (linMotion.x() > 0.f) - maxAabbx += linMotion.x(); - else - minAabbx += linMotion.x(); - if (linMotion.y() > 0.f) - maxAabby += linMotion.y(); - else - minAabby += linMotion.y(); - if (linMotion.z() > 0.f) - maxAabbz += linMotion.z(); - else - minAabbz += linMotion.z(); - - - minAabb = btVector3(minAabbx,minAabby,minAabbz); - maxAabb = btVector3(maxAabbx,maxAabby,maxAabbz); - + if (body) + { + btVector3 linMotion = body->getLinearVelocity()*timeStep; + + float maxAabbx = maxAabb.getX(); + float maxAabby = maxAabb.getY(); + float maxAabbz = maxAabb.getZ(); + float minAabbx = minAabb.getX(); + float minAabby = minAabb.getY(); + float minAabbz = minAabb.getZ(); + + if (linMotion.x() > 0.f) + maxAabbx += linMotion.x(); + else + minAabbx += linMotion.x(); + if (linMotion.y() > 0.f) + maxAabby += linMotion.y(); + else + minAabby += linMotion.y(); + if (linMotion.z() > 0.f) + maxAabbz += linMotion.z(); + else + minAabbz += linMotion.z(); + + + minAabb = btVector3(minAabbx,minAabby,minAabbz); + maxAabb = btVector3(maxAabbx,maxAabby,maxAabbz); + } @@ -427,8 +451,22 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctrl) { //also remove constraint - - m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody()); + btRigidBody* body = ctrl->GetRigidBody(); + if (body) + { + m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody()); + } else + { + //if a softbody + if (ctrl->GetSoftBody()) + { + //not yet + btAssert(0); + } else + { + m_dynamicsWorld->removeCollisionObject(ctrl->GetCollisionObject()); + } + } m_controllers.erase(ctrl); if (ctrl->m_registerCount != 0) @@ -443,14 +481,20 @@ void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctr // this function is used when the collisionning group of a controller is changed // remove and add the collistioning object btRigidBody* body = ctrl->GetRigidBody(); - btVector3 inertia(0.0,0.0,0.0); - - m_dynamicsWorld->removeCollisionObject(body); - body->setCollisionFlags(newCollisionFlags); - if (newMass) - body->getCollisionShape()->calculateLocalInertia(newMass, inertia); - body->setMassProps(newMass, inertia); - m_dynamicsWorld->addCollisionObject(body, newCollisionGroup, newCollisionMask); + btCollisionObject* obj = ctrl->GetCollisionObject(); + if (obj) + { + btVector3 inertia(0.0,0.0,0.0); + m_dynamicsWorld->removeCollisionObject(obj); + obj->setCollisionFlags(newCollisionFlags); + if (body) + { + if (newMass) + body->getCollisionShape()->calculateLocalInertia(newMass, inertia); + body->setMassProps(newMass, inertia); + } + m_dynamicsWorld->addCollisionObject(obj, newCollisionGroup, newCollisionMask); + } // to avoid nasty interaction, we must update the property of the controller as well ctrl->m_cci.m_mass = newMass; ctrl->m_cci.m_collisionFilterGroup = newCollisionGroup; @@ -462,9 +506,9 @@ void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctr { if (m_controllers.insert(ctrl).second) { - btRigidBody* body = ctrl->GetRigidBody(); - body->setUserPointer(ctrl); - m_dynamicsWorld->addCollisionObject(body, + btCollisionObject* obj = ctrl->GetCollisionObject(); + obj->setUserPointer(ctrl); + m_dynamicsWorld->addCollisionObject(obj, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask()); } } @@ -473,7 +517,19 @@ void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ct { if (m_controllers.erase(ctrl)) { - m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody()); + btRigidBody* body = ctrl->GetRigidBody(); + if (body) + { + m_dynamicsWorld->removeRigidBody(body); + } else + { + if (ctrl->GetSoftBody()) + { + } else + { + m_dynamicsWorld->removeCollisionObject(body); + } + } } } @@ -792,7 +848,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac CcdShapeConstructionInfo* shapeInfo = controller->m_shapeInfo; if (shapeInfo) { - btCollisionShape* shape = controller->GetRigidBody()->getCollisionShape(); + btCollisionShape* shape = controller->GetCollisionObject()->getCollisionShape(); if (shape->isCompound()) { btCompoundShape* compoundShape = (btCompoundShape*)shape; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 3cf5a943e3f..3569cf25b68 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -233,13 +233,13 @@ protected: std::vector m_wrapperVehicles; - //use explicit btDiscreteDynamicsWorld* so that we have access to + //use explicit btSoftRigidDynamicsWorld/btDiscreteDynamicsWorld* so that we have access to //btDiscreteDynamicsWorld::addRigidBody(body,filter,group) //so that we can set the body collision filter/group at the time of creation //and not afterwards (breaks the collision system for radar/near sensor) //Ideally we would like to have access to this function from the btDynamicsWorld interface //class btDynamicsWorld* m_dynamicsWorld; - class btDiscreteDynamicsWorld* m_dynamicsWorld; + class btSoftRigidDynamicsWorld* m_dynamicsWorld; class btConstraintSolver* m_solver; -- cgit v1.2.3 From 067a890d823bb0181b1d028931004eba86fb9220 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 17 Sep 2008 21:47:05 +0000 Subject: BGE bug #17578: repair linV actuator in Add+Local mode. --- source/gameengine/Ketsji/KX_GameObject.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 0e5956d4fdb..252741754ec 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -590,8 +590,11 @@ KX_GameObject::GetLayer( void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local) { - if (m_pPhysicsController1) - m_pPhysicsController1->SetLinearVelocity(lin_vel + m_pPhysicsController1->GetLinearVelocity(),local); + if (m_pPhysicsController1) + { + MT_Vector3 lv = local ? NodeGetWorldOrientation() * lin_vel : lin_vel; + m_pPhysicsController1->SetLinearVelocity(lv + m_pPhysicsController1->GetLinearVelocity(), 0); + } } -- cgit v1.2.3 From 0a7767d597dc92727a64fae676cbf03c9ef17915 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 18 Sep 2008 01:46:28 +0000 Subject: Fix for bug #3858: the game engine mouse focus sensor did not work correct if there was more than one camera. It shoots rays from the active camera, but used the viewport from whichever camera was drawn last, now it uses the correct vieport. --- .../gameengine/Converter/BL_BlenderDataConversion.cpp | 2 +- source/gameengine/Converter/KX_ConvertSensors.cpp | 2 ++ source/gameengine/Converter/KX_ConvertSensors.h | 1 + source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 6 +++--- source/gameengine/Ketsji/KX_KetsjiEngine.h | 3 ++- source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 17 +++++++++++------ source/gameengine/Ketsji/KX_MouseFocusSensor.h | 10 ++++------ 7 files changed, 24 insertions(+), 17 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index c3992d02eee..425e07a257c 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2471,7 +2471,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, struct Object* blenderobj = converter->FindBlenderObject(gameobj); int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0; bool isInActiveLayer = (blenderobj->lay & layerMask)!=0; - BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,keydev,executePriority,layerMask,isInActiveLayer,canvas,converter); + BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,keydev,executePriority,layerMask,isInActiveLayer,canvas,converter); // set the init state to all objects gameobj->SetInitState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state); } diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index f16855955ff..be0bb8103c0 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -92,6 +92,7 @@ void BL_ConvertSensors(struct Object* blenderobject, class KX_GameObject* gameobj, SCA_LogicManager* logicmgr, KX_Scene* kxscene, + KX_KetsjiEngine* kxengine, SCA_IInputDevice* keydev, int & executePriority, int activeLayerBitInfo, @@ -508,6 +509,7 @@ void BL_ConvertSensors(struct Object* blenderobject, trackfocus, canvas, kxscene, + kxengine, gameobj); } } else { diff --git a/source/gameengine/Converter/KX_ConvertSensors.h b/source/gameengine/Converter/KX_ConvertSensors.h index 73da51f47f0..b18ffc10a2a 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.h +++ b/source/gameengine/Converter/KX_ConvertSensors.h @@ -33,6 +33,7 @@ void BL_ConvertSensors(struct Object* blenderobject, class KX_GameObject* gameobj, class SCA_LogicManager* logicmgr, class KX_Scene* kxscene, + class KX_KetsjiEngine* kxengine, class SCA_IInputDevice* keydev, int & executePriority , int activeLayerBitInfo, diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 888dcf3d01f..c7b0d7b3ea3 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -299,7 +299,7 @@ void KX_KetsjiEngine::ClearFrame() list::iterator it; for(it = cameras->begin(); it != cameras->end(); it++) { - SetupViewport(scene, (*it), area, viewport); + GetSceneViewport(scene, (*it), area, viewport); if(!doclear) { clearvp = viewport; @@ -894,7 +894,7 @@ void KX_KetsjiEngine::SetCameraOverrideClipping(float near, float far) m_overrideCamFar = far; } -void KX_KetsjiEngine::SetupViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport) +void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport) { // In this function we make sure the rasterizer settings are upto // date. We compute the viewport so that logic @@ -1001,7 +1001,7 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) if (!cam) return; - SetupViewport(scene, cam, area, viewport); + GetSceneViewport(scene, cam, area, viewport); // store the computed viewport in the scene scene->SetSceneViewport(viewport); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 8fe8731dc05..1aa067a9962 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -179,7 +179,6 @@ private: /** Blue component of framing bar color. */ float m_overrideFrameColorB; - void SetupViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport); void RenderFrame(KX_Scene* scene, KX_Camera* cam); void PostRenderFrame(); void RenderDebugProperties(); @@ -230,6 +229,8 @@ public: void SuspendScene(const STR_String& scenename); void ResumeScene(const STR_String& scenename); + void GetSceneViewport(KX_Scene* scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport); + void SetDrawType(int drawingtype); void SetCameraZoom(float camzoom); diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 3156f543ed5..6f76448707c 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -62,12 +62,14 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, int focusmode, RAS_ICanvas* canvas, KX_Scene* kxscene, + KX_KetsjiEngine *kxengine, SCA_IObject* gameobj, PyTypeObject* T) : SCA_MouseSensor(eventmgr, startx, starty, mousemode, gameobj, T), m_focusmode(focusmode), m_gp_canvas(canvas), - m_kxscene(kxscene) + m_kxscene(kxscene), + m_kxengine(kxengine) { Init(); } @@ -193,11 +195,14 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void) * calculations don't bomb. Maybe we should explicitly guard for * division by 0.0...*/ - /** - * Get the scenes current viewport. - */ + KX_Camera* cam = m_kxscene->GetActiveCamera(); + + /* get the scenes current viewport. we recompute it because there + * may be multiple cameras and m_kxscene->GetSceneViewport() only + * has the one that was last drawn */ - const RAS_Rect & viewport = m_kxscene->GetSceneViewport(); + RAS_Rect area, viewport; + m_kxengine->GetSceneViewport(m_kxscene, cam, area, viewport); float height = float(viewport.m_y2 - viewport.m_y1 + 1); float width = float(viewport.m_x2 - viewport.m_x1 + 1); @@ -205,9 +210,9 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void) float x_lb = float(viewport.m_x1); float y_lb = float(viewport.m_y1); - KX_Camera* cam = m_kxscene->GetActiveCamera(); /* There's some strangeness I don't fully get here... These values * _should_ be wrong! */ + /* old: */ float nearclip = 0.0; diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index a6cc39d66eb..6731444699b 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -56,6 +56,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor int focusmode, RAS_ICanvas* canvas, KX_Scene* kxscene, + KX_KetsjiEngine* kxengine, SCA_IObject* gameobj, PyTypeObject* T=&Type ); @@ -142,12 +143,6 @@ class KX_MouseFocusSensor : public SCA_MouseSensor MT_Vector3 m_hitNormal; - /** - * Ref to the engine, for retrieving a reference to the current - * scene. */ - class KX_KetsjiEngine* m_engine; - - /** * The active canvas. The size of this canvas determines a part of * the start position of the picking ray. */ @@ -158,6 +153,9 @@ class KX_MouseFocusSensor : public SCA_MouseSensor * determines a part of the start location of the picking ray. */ KX_Scene* m_kxscene; + /** + * The KX engine is needed for computing the viewport */ + KX_KetsjiEngine* m_kxengine; }; #endif //__KX_MOUSESENSOR -- cgit v1.2.3 From 6b7b81220808203c9a778df3b4585a77a8096f10 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 18 Sep 2008 16:43:31 +0000 Subject: This file did not compile, but is also not part of the build target... Fixed neverheless, patch #6258 from Early Ehlinger --- source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp index 6d9b41e08d2..2e8ee31058f 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp +++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp @@ -198,7 +198,7 @@ int ODEPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl } -void ODEPhysicsEnvironment::removeConstraint(int constraintid) +void ODEPhysicsEnvironment::removeConstraint(void *constraintid) { if (constraintid) { -- cgit v1.2.3 From 02a91ac784d2d4f612dcd3a7772d0f1b26b56166 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 18 Sep 2008 19:28:28 +0000 Subject: BGE patch: change constraint location actuator to work in local coordinates. It won't change anything for root objects but will be of some use for child objects. --- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 4b57b0e8c54..e0c9af5ae60 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -359,7 +359,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) case KX_ACT_CONSTRAINT_LOCX: case KX_ACT_CONSTRAINT_LOCY: case KX_ACT_CONSTRAINT_LOCZ: - newposition = position; + newposition = position = obj->GetSGNode()->GetLocalPosition(); switch (m_locrot) { case KX_ACT_CONSTRAINT_LOCX: Clamp(newposition[0], m_minimumBound, m_maximumBound); @@ -375,7 +375,8 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) if (m_posDampTime) { newposition = filter*position + (1.0-filter)*newposition; } - break; + obj->NodeSetLocalPosition(newposition); + goto CHECK_TIME; } if (result) { // set the new position but take into account parent if any -- cgit v1.2.3 From a44177a4019536871da8c976fd4bbf38a30fd766 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 19 Sep 2008 20:41:38 +0000 Subject: BGE patch: new 'Advanced Settings' button to keep special Bullet options away from main UI. Three features that were on the main UI interface are now moved to the Advanced Settings panel: Margin, Actor (that becomes Sensor Actor) and No sleeping. Sensor Actor is now a feature: it can be turned on and off for all types of objects, and not just static objects. Select the Sensor Actor button to make the object visible to Near and Radar sensor. The button is selected by default for dynamic objects and unselected by default for static objects, to match previous behavior. --- .../gameengine/Converter/BL_BlenderDataConversion.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 425e07a257c..593833742e7 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1315,19 +1315,12 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_isCompoundChild = isCompoundChild; objprop.m_hasCompoundChildren = (blenderobject->gameflag & OB_CHILD) != 0; objprop.m_margin = blenderobject->margin; - - if ((objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0)) - { - objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0; - objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; - objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; - objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag - } else { - objprop.m_dyna = false; - objprop.m_angular_rigidbody = false; - objprop.m_ghost = false; - objprop.m_disableSleeping = false; - } + // ACTOR is now a separate feature + objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0; + objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0; + objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; + objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; + objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag //mmm, for now, taks this for the size of the dynamicobject // Blender uses inertia for radius of dynamic object objprop.m_radius = blenderobject->inertia; -- cgit v1.2.3 From f510057fefea61a15fbbbd6556bf00a6350bb519 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 20 Sep 2008 11:08:35 +0000 Subject: [#17600] char* -> const char* Thanks to Sean Bartell (wtachi), was causing many many warnings which distracted from the real problems. --- source/gameengine/Converter/BL_ActionActuator.cpp | 40 ++++++++++---------- .../Converter/BL_BlenderDataConversion.cpp | 2 +- .../Converter/BL_ShapeActionActuator.cpp | 34 ++++++++--------- source/gameengine/Expressions/PyObjectPlus.h | 14 +++---- source/gameengine/GameLogic/SCA_ActuatorSensor.cpp | 4 +- source/gameengine/GameLogic/SCA_DelaySensor.cpp | 12 +++--- source/gameengine/GameLogic/SCA_ISensor.cpp | 26 ++++++------- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 30 +++++++-------- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 16 ++++---- source/gameengine/GameLogic/SCA_MouseSensor.cpp | 4 +- .../gameengine/GameLogic/SCA_PropertyActuator.cpp | 8 ++-- source/gameengine/GameLogic/SCA_PropertySensor.cpp | 12 +++--- .../gameengine/GameLogic/SCA_PythonController.cpp | 16 ++++---- source/gameengine/GameLogic/SCA_PythonController.h | 4 +- source/gameengine/GameLogic/SCA_RandomActuator.cpp | 34 ++++++++--------- source/gameengine/GameLogic/SCA_RandomSensor.cpp | 6 +-- .../gameengine/GamePlayer/common/GPC_RawImage.cpp | 2 +- source/gameengine/GamePlayer/common/GPC_RawImage.h | 2 +- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 4 +- source/gameengine/Ketsji/BL_Shader.cpp | 28 +++++++------- source/gameengine/Ketsji/BL_Shader.h | 4 +- .../Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 10 ++--- source/gameengine/Ketsji/KX_CameraActuator.cpp | 20 +++++----- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 44 +++++++++++----------- source/gameengine/Ketsji/KX_ConstraintActuator.h | 8 ++-- source/gameengine/Ketsji/KX_GameActuator.cpp | 4 +- source/gameengine/Ketsji/KX_IpoActuator.cpp | 28 +++++++------- source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 12 +++--- source/gameengine/Ketsji/KX_ParentActuator.cpp | 4 +- source/gameengine/Ketsji/KX_RadarSensor.cpp | 6 +-- source/gameengine/Ketsji/KX_RaySensor.cpp | 8 ++-- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 18 ++++----- .../Ketsji/KX_SCA_ReplaceMeshActuator.cpp | 2 +- source/gameengine/Ketsji/KX_SceneActuator.cpp | 12 +++--- source/gameengine/Ketsji/KX_StateActuator.cpp | 4 +- source/gameengine/Ketsji/KX_TouchSensor.cpp | 12 +++--- source/gameengine/Ketsji/KX_TrackToActuator.cpp | 12 +++--- source/gameengine/Ketsji/KX_VisibilityActuator.cpp | 2 +- .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 2 +- source/gameengine/Rasterizer/RAS_2DFilterManager.h | 2 +- .../RAS_OpenGLFilters/RAS_Blur2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_Dilation2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_Erosion2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_GrayScale2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_Invert2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_Laplacian2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_Prewitt2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_Sepia2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_Sharpen2DFilter.h | 2 +- .../RAS_OpenGLFilters/RAS_Sobel2DFilter.h | 2 +- 50 files changed, 266 insertions(+), 266 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index c08427c6d27..16bdbe6269b 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -480,7 +480,7 @@ PyObject* BL_ActionActuator::_getattr(const STR_String& attr) { } /* setStart */ -char BL_ActionActuator::GetAction_doc[] = +const char BL_ActionActuator::GetAction_doc[] = "getAction()\n" "\tReturns a string containing the name of the current action.\n"; @@ -494,7 +494,7 @@ PyObject* BL_ActionActuator::PyGetAction(PyObject* self, } /* getProperty */ -char BL_ActionActuator::GetProperty_doc[] = +const char BL_ActionActuator::GetProperty_doc[] = "getProperty()\n" "\tReturns the name of the property to be used in FromProp mode.\n"; @@ -509,7 +509,7 @@ PyObject* BL_ActionActuator::PyGetProperty(PyObject* self, } /* getProperty */ -char BL_ActionActuator::GetFrameProperty_doc[] = +const char BL_ActionActuator::GetFrameProperty_doc[] = "getFrameProperty()\n" "\tReturns the name of the property, that is set to the current frame number.\n"; @@ -524,7 +524,7 @@ PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* self, } /* getFrame */ -char BL_ActionActuator::GetFrame_doc[] = +const char BL_ActionActuator::GetFrame_doc[] = "getFrame()\n" "\tReturns the current frame number.\n"; @@ -539,7 +539,7 @@ PyObject* BL_ActionActuator::PyGetFrame(PyObject* self, } /* getEnd */ -char BL_ActionActuator::GetEnd_doc[] = +const char BL_ActionActuator::GetEnd_doc[] = "getEnd()\n" "\tReturns the last frame of the action.\n"; @@ -554,7 +554,7 @@ PyObject* BL_ActionActuator::PyGetEnd(PyObject* self, } /* getStart */ -char BL_ActionActuator::GetStart_doc[] = +const char BL_ActionActuator::GetStart_doc[] = "getStart()\n" "\tReturns the starting frame of the action.\n"; @@ -569,7 +569,7 @@ PyObject* BL_ActionActuator::PyGetStart(PyObject* self, } /* getBlendin */ -char BL_ActionActuator::GetBlendin_doc[] = +const char BL_ActionActuator::GetBlendin_doc[] = "getBlendin()\n" "\tReturns the number of interpolation animation frames to be\n" "\tgenerated when this actuator is triggered.\n"; @@ -585,7 +585,7 @@ PyObject* BL_ActionActuator::PyGetBlendin(PyObject* self, } /* getPriority */ -char BL_ActionActuator::GetPriority_doc[] = +const char BL_ActionActuator::GetPriority_doc[] = "getPriority()\n" "\tReturns the priority for this actuator. Actuators with lower\n" "\tPriority numbers will override actuators with higher numbers.\n"; @@ -601,7 +601,7 @@ PyObject* BL_ActionActuator::PyGetPriority(PyObject* self, } /* setAction */ -char BL_ActionActuator::SetAction_doc[] = +const char BL_ActionActuator::SetAction_doc[] = "setAction(action, (reset))\n" "\t - action : The name of the action to set as the current action.\n" "\t - reset : Optional parameter indicating whether to reset the\n" @@ -640,7 +640,7 @@ PyObject* BL_ActionActuator::PySetAction(PyObject* self, } /* setStart */ -char BL_ActionActuator::SetStart_doc[] = +const char BL_ActionActuator::SetStart_doc[] = "setStart(start)\n" "\t - start : Specifies the starting frame of the animation.\n"; @@ -661,7 +661,7 @@ PyObject* BL_ActionActuator::PySetStart(PyObject* self, } /* setEnd */ -char BL_ActionActuator::SetEnd_doc[] = +const char BL_ActionActuator::SetEnd_doc[] = "setEnd(end)\n" "\t - end : Specifies the ending frame of the animation.\n"; @@ -682,7 +682,7 @@ PyObject* BL_ActionActuator::PySetEnd(PyObject* self, } /* setBlendin */ -char BL_ActionActuator::SetBlendin_doc[] = +const char BL_ActionActuator::SetBlendin_doc[] = "setBlendin(blendin)\n" "\t - blendin : Specifies the number of frames of animation to generate\n" "\t when making transitions between actions.\n"; @@ -704,7 +704,7 @@ PyObject* BL_ActionActuator::PySetBlendin(PyObject* self, } /* setBlendtime */ -char BL_ActionActuator::SetBlendtime_doc[] = +const char BL_ActionActuator::SetBlendtime_doc[] = "setBlendtime(blendtime)\n" "\t - blendtime : Allows the script to directly modify the internal timer\n" "\t used when generating transitions between actions. This\n" @@ -731,7 +731,7 @@ PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self, } /* setPriority */ -char BL_ActionActuator::SetPriority_doc[] = +const char BL_ActionActuator::SetPriority_doc[] = "setPriority(priority)\n" "\t - priority : Specifies the new priority. Actuators will lower\n" "\t priority numbers will override actuators with higher\n" @@ -754,7 +754,7 @@ PyObject* BL_ActionActuator::PySetPriority(PyObject* self, } /* setFrame */ -char BL_ActionActuator::SetFrame_doc[] = +const char BL_ActionActuator::SetFrame_doc[] = "setFrame(frame)\n" "\t - frame : Specifies the new current frame for the animation\n"; @@ -779,7 +779,7 @@ PyObject* BL_ActionActuator::PySetFrame(PyObject* self, } /* setProperty */ -char BL_ActionActuator::SetProperty_doc[] = +const char BL_ActionActuator::SetProperty_doc[] = "setProperty(prop)\n" "\t - prop : A string specifying the property name to be used in\n" "\t FromProp playback mode.\n"; @@ -801,7 +801,7 @@ PyObject* BL_ActionActuator::PySetProperty(PyObject* self, } /* setFrameProperty */ -char BL_ActionActuator::SetFrameProperty_doc[] = +const char BL_ActionActuator::SetFrameProperty_doc[] = "setFrameProperty(prop)\n" "\t - prop : A string specifying the property of the frame set up update.\n"; @@ -840,7 +840,7 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self, */ /* setChannel */ -char BL_ActionActuator::SetChannel_doc[] = +const char BL_ActionActuator::SetChannel_doc[] = "setChannel(channel, matrix)\n" "\t - channel : A string specifying the name of the bone channel.\n" "\t - matrix : A 4x4 matrix specifying the overriding transformation\n" @@ -924,7 +924,7 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self, } /* getType */ -char BL_ActionActuator::GetType_doc[] = +const char BL_ActionActuator::GetType_doc[] = "getType()\n" "\tReturns the operation mode of the actuator.\n"; PyObject* BL_ActionActuator::PyGetType(PyObject* self, @@ -934,7 +934,7 @@ PyObject* BL_ActionActuator::PyGetType(PyObject* self, } /* setType */ -char BL_ActionActuator::SetType_doc[] = +const char BL_ActionActuator::SetType_doc[] = "setType(mode)\n" "\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n" "\tSet the operation mode of the actuator.\n"; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 593833742e7..ae9b8602500 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -308,7 +308,7 @@ static void GetRGB(short type, typedef struct MTF_localLayer { MTFace *face; - char *name; + const char *name; }MTF_localLayer; // ------------------------------------ diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index da5ca1e7c95..721c24dfb94 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -461,7 +461,7 @@ PyObject* BL_ShapeActionActuator::_getattr(const STR_String& attr) { } /* setStart */ -char BL_ShapeActionActuator::GetAction_doc[] = +const char BL_ShapeActionActuator::GetAction_doc[] = "getAction()\n" "\tReturns a string containing the name of the current action.\n"; @@ -473,7 +473,7 @@ PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) { } /* getProperty */ -char BL_ShapeActionActuator::GetProperty_doc[] = +const char BL_ShapeActionActuator::GetProperty_doc[] = "getProperty()\n" "\tReturns the name of the property to be used in FromProp mode.\n"; @@ -486,7 +486,7 @@ PyObject* BL_ShapeActionActuator::PyGetProperty(PyObject* self) { } /* getFrame */ -char BL_ShapeActionActuator::GetFrame_doc[] = +const char BL_ShapeActionActuator::GetFrame_doc[] = "getFrame()\n" "\tReturns the current frame number.\n"; @@ -499,7 +499,7 @@ PyObject* BL_ShapeActionActuator::PyGetFrame(PyObject* self) { } /* getEnd */ -char BL_ShapeActionActuator::GetEnd_doc[] = +const char BL_ShapeActionActuator::GetEnd_doc[] = "getEnd()\n" "\tReturns the last frame of the action.\n"; @@ -512,7 +512,7 @@ PyObject* BL_ShapeActionActuator::PyGetEnd(PyObject* self) { } /* getStart */ -char BL_ShapeActionActuator::GetStart_doc[] = +const char BL_ShapeActionActuator::GetStart_doc[] = "getStart()\n" "\tReturns the starting frame of the action.\n"; @@ -525,7 +525,7 @@ PyObject* BL_ShapeActionActuator::PyGetStart(PyObject* self) { } /* getBlendin */ -char BL_ShapeActionActuator::GetBlendin_doc[] = +const char BL_ShapeActionActuator::GetBlendin_doc[] = "getBlendin()\n" "\tReturns the number of interpolation animation frames to be\n" "\tgenerated when this actuator is triggered.\n"; @@ -539,7 +539,7 @@ PyObject* BL_ShapeActionActuator::PyGetBlendin(PyObject* self) { } /* getPriority */ -char BL_ShapeActionActuator::GetPriority_doc[] = +const char BL_ShapeActionActuator::GetPriority_doc[] = "getPriority()\n" "\tReturns the priority for this actuator. Actuators with lower\n" "\tPriority numbers will override actuators with higher numbers.\n"; @@ -553,7 +553,7 @@ PyObject* BL_ShapeActionActuator::PyGetPriority(PyObject* self) { } /* setAction */ -char BL_ShapeActionActuator::SetAction_doc[] = +const char BL_ShapeActionActuator::SetAction_doc[] = "setAction(action, (reset))\n" "\t - action : The name of the action to set as the current action.\n" "\t Should be an action with Shape channels.\n" @@ -593,7 +593,7 @@ PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self, } /* setStart */ -char BL_ShapeActionActuator::SetStart_doc[] = +const char BL_ShapeActionActuator::SetStart_doc[] = "setStart(start)\n" "\t - start : Specifies the starting frame of the animation.\n"; @@ -614,7 +614,7 @@ PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self, } /* setEnd */ -char BL_ShapeActionActuator::SetEnd_doc[] = +const char BL_ShapeActionActuator::SetEnd_doc[] = "setEnd(end)\n" "\t - end : Specifies the ending frame of the animation.\n"; @@ -635,7 +635,7 @@ PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self, } /* setBlendin */ -char BL_ShapeActionActuator::SetBlendin_doc[] = +const char BL_ShapeActionActuator::SetBlendin_doc[] = "setBlendin(blendin)\n" "\t - blendin : Specifies the number of frames of animation to generate\n" "\t when making transitions between actions.\n"; @@ -657,7 +657,7 @@ PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self, } /* setBlendtime */ -char BL_ShapeActionActuator::SetBlendtime_doc[] = +const char BL_ShapeActionActuator::SetBlendtime_doc[] = "setBlendtime(blendtime)\n" "\t - blendtime : Allows the script to directly modify the internal timer\n" "\t used when generating transitions between actions. This\n" @@ -684,7 +684,7 @@ PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self, } /* setPriority */ -char BL_ShapeActionActuator::SetPriority_doc[] = +const char BL_ShapeActionActuator::SetPriority_doc[] = "setPriority(priority)\n" "\t - priority : Specifies the new priority. Actuators will lower\n" "\t priority numbers will override actuators with higher\n" @@ -707,7 +707,7 @@ PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, } /* setFrame */ -char BL_ShapeActionActuator::SetFrame_doc[] = +const char BL_ShapeActionActuator::SetFrame_doc[] = "setFrame(frame)\n" "\t - frame : Specifies the new current frame for the animation\n"; @@ -732,7 +732,7 @@ PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self, } /* setProperty */ -char BL_ShapeActionActuator::SetProperty_doc[] = +const char BL_ShapeActionActuator::SetProperty_doc[] = "setProperty(prop)\n" "\t - prop : A string specifying the property name to be used in\n" "\t FromProp playback mode.\n"; @@ -754,7 +754,7 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, } /* getType */ -char BL_ShapeActionActuator::GetType_doc[] = +const char BL_ShapeActionActuator::GetType_doc[] = "getType()\n" "\tReturns the operation mode of the actuator.\n"; PyObject* BL_ShapeActionActuator::PyGetType(PyObject* self) { @@ -762,7 +762,7 @@ PyObject* BL_ShapeActionActuator::PyGetType(PyObject* self) { } /* setType */ -char BL_ShapeActionActuator::SetType_doc[] = +const char BL_ShapeActionActuator::SetType_doc[] = "setType(mode)\n" "\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n" "\tSet the operation mode of the actuator.\n"; diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index ccc9af2ed79..9d5e31aa757 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -73,7 +73,7 @@ typedef int Py_ssize_t; // some basic python macros #define Py_Return { Py_INCREF(Py_None); return Py_None;} -static inline void Py_Fatal(char *M) { +static inline void Py_Fatal(const char *M) { //cout << M << endl; exit(-1); }; @@ -152,28 +152,28 @@ static inline void Py_Fatal(char *M) { static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \ return ((class_name*) self)->Py##method_name(self, args, kwds); \ }; \ - static char method_name##_doc[]; \ + static const char method_name##_doc[]; \ #define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \ PyObject* Py##method_name(PyObject* self, PyObject* args); \ static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \ return ((class_name*) self)->Py##method_name(self, args); \ }; \ - static char method_name##_doc[]; \ + static const char method_name##_doc[]; \ #define KX_PYMETHOD_DOC_O(class_name, method_name) \ PyObject* Py##method_name(PyObject* self, PyObject* value); \ static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \ return ((class_name*) self)->Py##method_name(self, value); \ }; \ - static char method_name##_doc[]; \ + static const char method_name##_doc[]; \ #define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \ PyObject* Py##method_name(PyObject* self); \ static PyObject* sPy##method_name( PyObject* self) { \ return ((class_name*) self)->Py##method_name(self); \ }; \ - static char method_name##_doc[]; \ + static const char method_name##_doc[]; \ /* The line above should remain empty */ @@ -190,11 +190,11 @@ static inline void Py_Fatal(char *M) { * Function implementation macro */ #define KX_PYMETHODDEF_DOC(class_name, method_name, doc_string) \ -char class_name::method_name##_doc[] = doc_string; \ +const char class_name::method_name##_doc[] = doc_string; \ PyObject* class_name::Py##method_name(PyObject*, PyObject* args, PyObject*) #define KX_PYMETHODDEF_DOC_NOARG(class_name, method_name, doc_string) \ -char class_name::method_name##_doc[] = doc_string; \ +const char class_name::method_name##_doc[] = doc_string; \ PyObject* class_name::Py##method_name(PyObject*) /*------------------------------ diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index 44a488fa719..95fb7e20ad0 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -159,7 +159,7 @@ PyObject* SCA_ActuatorSensor::_getattr(const STR_String& attr) { } /* 3. getActuator */ -char SCA_ActuatorSensor::GetActuator_doc[] = +const char SCA_ActuatorSensor::GetActuator_doc[] = "getActuator()\n" "\tReturn the Actuator with which the sensor operates.\n"; PyObject* SCA_ActuatorSensor::PyGetActuator(PyObject* self) @@ -168,7 +168,7 @@ PyObject* SCA_ActuatorSensor::PyGetActuator(PyObject* self) } /* 4. setActuator */ -char SCA_ActuatorSensor::SetActuator_doc[] = +const char SCA_ActuatorSensor::SetActuator_doc[] = "setActuator(name)\n" "\t- name: string\n" "\tSets the Actuator with which to operate. If there is no Actuator\n" diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index 4d05250e91c..577c523f51f 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -173,7 +173,7 @@ PyObject* SCA_DelaySensor::_getattr(const STR_String& attr) { _getattr_up(SCA_ISensor); } -char SCA_DelaySensor::SetDelay_doc[] = +const char SCA_DelaySensor::SetDelay_doc[] = "setDelay(delay)\n" "\t- delay: length of the initial OFF period as number of frame\n" "\t 0 for immediate trigger\n" @@ -193,7 +193,7 @@ PyObject* SCA_DelaySensor::PySetDelay(PyObject* self, PyObject* args, PyObject* Py_Return; } -char SCA_DelaySensor::SetDuration_doc[] = +const char SCA_DelaySensor::SetDuration_doc[] = "setDuration(duration)\n" "\t- duration: length of the ON period in number of frame after the initial off period\n" "\t 0 for no ON period\n" @@ -214,7 +214,7 @@ PyObject* SCA_DelaySensor::PySetDuration(PyObject* self, PyObject* args, PyObjec Py_Return; } -char SCA_DelaySensor::SetRepeat_doc[] = +const char SCA_DelaySensor::SetRepeat_doc[] = "setRepeat(repeat)\n" "\t- repeat: 1 if the initial OFF-ON cycle should be repeated indefinately\n" "\t 0 if the initial OFF-ON cycle should run only once\n" @@ -230,7 +230,7 @@ PyObject* SCA_DelaySensor::PySetRepeat(PyObject* self, PyObject* args, PyObject* Py_Return; } -char SCA_DelaySensor::GetDelay_doc[] = +const char SCA_DelaySensor::GetDelay_doc[] = "getDelay()\n" "\tReturn the delay parameter value\n"; PyObject* SCA_DelaySensor::PyGetDelay(PyObject* self) @@ -238,7 +238,7 @@ PyObject* SCA_DelaySensor::PyGetDelay(PyObject* self) return PyInt_FromLong(m_delay); } -char SCA_DelaySensor::GetDuration_doc[] = +const char SCA_DelaySensor::GetDuration_doc[] = "getDuration()\n" "\tReturn the duration parameter value\n"; PyObject* SCA_DelaySensor::PyGetDuration(PyObject* self) @@ -246,7 +246,7 @@ PyObject* SCA_DelaySensor::PyGetDuration(PyObject* self) return PyInt_FromLong(m_duration); } -char SCA_DelaySensor::GetRepeat_doc[] = +const char SCA_DelaySensor::GetRepeat_doc[] = "getRepeat()\n" "\tReturn the repeat parameter value\n"; PyObject* SCA_DelaySensor::PyGetRepeat(PyObject* self) diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 084b1395159..260805e0aa8 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -277,7 +277,7 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event) } /* Python functions: */ -char SCA_ISensor::IsPositive_doc[] = +const char SCA_ISensor::IsPositive_doc[] = "isPositive()\n" "\tReturns whether the sensor is in an active state.\n"; PyObject* SCA_ISensor::PyIsPositive(PyObject* self) @@ -286,7 +286,7 @@ PyObject* SCA_ISensor::PyIsPositive(PyObject* self) return PyInt_FromLong(retval); } -char SCA_ISensor::IsTriggered_doc[] = +const char SCA_ISensor::IsTriggered_doc[] = "isTriggered()\n" "\tReturns whether the sensor has triggered the current controller.\n"; PyObject* SCA_ISensor::PyIsTriggered(PyObject* self) @@ -301,7 +301,7 @@ PyObject* SCA_ISensor::PyIsTriggered(PyObject* self) /** * getUsePulseMode: getter for the pulse mode (KX_TRUE = on) */ -char SCA_ISensor::GetUsePosPulseMode_doc[] = +const char SCA_ISensor::GetUsePosPulseMode_doc[] = "getUsePosPulseMode()\n" "\tReturns whether positive pulse mode is active.\n"; PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self) @@ -312,7 +312,7 @@ PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self) /** * setUsePulseMode: setter for the pulse mode (KX_TRUE = on) */ -char SCA_ISensor::SetUsePosPulseMode_doc[] = +const char SCA_ISensor::SetUsePosPulseMode_doc[] = "setUsePosPulseMode(pulse?)\n" "\t - pulse? : Pulse when a positive event occurs?\n" "\t (KX_TRUE, KX_FALSE)\n" @@ -328,7 +328,7 @@ PyObject* SCA_ISensor::PySetUsePosPulseMode(PyObject* self, PyObject* args, PyOb /** * getFrequency: getter for the pulse mode interval */ -char SCA_ISensor::GetFrequency_doc[] = +const char SCA_ISensor::GetFrequency_doc[] = "getFrequency()\n" "\tReturns the frequency of the updates in pulse mode.\n" ; PyObject* SCA_ISensor::PyGetFrequency(PyObject* self) @@ -339,7 +339,7 @@ PyObject* SCA_ISensor::PyGetFrequency(PyObject* self) /** * setFrequency: setter for the pulse mode (KX_TRUE = on) */ -char SCA_ISensor::SetFrequency_doc[] = +const char SCA_ISensor::SetFrequency_doc[] = "setFrequency(pulse_frequency)\n" "\t- pulse_frequency: The frequency of the updates in pulse mode (integer)" "\tSet the frequency of the updates in pulse mode.\n" @@ -363,7 +363,7 @@ PyObject* SCA_ISensor::PySetFrequency(PyObject* self, PyObject* args, PyObject* } -char SCA_ISensor::GetInvert_doc[] = +const char SCA_ISensor::GetInvert_doc[] = "getInvert()\n" "\tReturns whether or not pulses from this sensor are inverted.\n" ; PyObject* SCA_ISensor::PyGetInvert(PyObject* self) @@ -371,7 +371,7 @@ PyObject* SCA_ISensor::PyGetInvert(PyObject* self) return BoolToPyArg(m_invert); } -char SCA_ISensor::SetInvert_doc[] = +const char SCA_ISensor::SetInvert_doc[] = "setInvert(invert?)\n" "\t- invert?: Invert the event-values? (KX_TRUE, KX_FALSE)\n" "\tSet whether to invert pulses.\n"; @@ -383,7 +383,7 @@ PyObject* SCA_ISensor::PySetInvert(PyObject* self, PyObject* args, PyObject* kwd Py_Return; } -char SCA_ISensor::GetLevel_doc[] = +const char SCA_ISensor::GetLevel_doc[] = "getLevel()\n" "\tReturns whether this sensor is a level detector or a edge detector.\n" "\tIt makes a difference only in case of logic state transition (state actuator).\n" @@ -395,7 +395,7 @@ PyObject* SCA_ISensor::PyGetLevel(PyObject* self) return BoolToPyArg(m_level); } -char SCA_ISensor::SetLevel_doc[] = +const char SCA_ISensor::SetLevel_doc[] = "setLevel(level?)\n" "\t- level?: Detect level instead of edge? (KX_TRUE, KX_FALSE)\n" "\tSet whether to detect level or edge transition when entering a state.\n"; @@ -407,7 +407,7 @@ PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds Py_Return; } -char SCA_ISensor::GetUseNegPulseMode_doc[] = +const char SCA_ISensor::GetUseNegPulseMode_doc[] = "getUseNegPulseMode()\n" "\tReturns whether negative pulse mode is active.\n"; PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self) @@ -415,7 +415,7 @@ PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self) return BoolToPyArg(m_neg_pulsemode); } -char SCA_ISensor::SetUseNegPulseMode_doc[] = +const char SCA_ISensor::SetUseNegPulseMode_doc[] = "setUseNegPulseMode(pulse?)\n" "\t - pulse? : Pulse when a negative event occurs?\n" "\t (KX_TRUE, KX_FALSE)\n" @@ -428,7 +428,7 @@ PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyOb Py_Return; } -char SCA_ISensor::Reset_doc[] = +const char SCA_ISensor::Reset_doc[] = "reset()\n" "\tReset sensor internal state, effect depends on the type of sensor and settings.\n" "\tThe sensor is put in its initial state as if it was just activated.\n"; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 3c08710c6ce..f486e7985b3 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -346,7 +346,7 @@ PyObject* SCA_JoystickSensor::_getattr(const STR_String& attr) { /* get index ---------------------------------------------------------- */ -char SCA_JoystickSensor::GetIndex_doc[] = +const char SCA_JoystickSensor::GetIndex_doc[] = "getIndex\n" "\tReturns the joystick index to use.\n"; PyObject* SCA_JoystickSensor::PyGetIndex( PyObject* self ) { @@ -355,7 +355,7 @@ PyObject* SCA_JoystickSensor::PyGetIndex( PyObject* self ) { /* set index ---------------------------------------------------------- */ -char SCA_JoystickSensor::SetIndex_doc[] = +const char SCA_JoystickSensor::SetIndex_doc[] = "setIndex\n" "\tSets the joystick index to use.\n"; PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) { @@ -370,7 +370,7 @@ PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) { } /* get axis ---------------------------------------------------------- */ -char SCA_JoystickSensor::GetAxis_doc[] = +const char SCA_JoystickSensor::GetAxis_doc[] = "getAxis\n" "\tReturns the current state of the axis.\n"; PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) { @@ -379,7 +379,7 @@ PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) { /* set axis ---------------------------------------------------------- */ -char SCA_JoystickSensor::SetAxis_doc[] = +const char SCA_JoystickSensor::SetAxis_doc[] = "setAxis\n" "\tSets the current state of the axis.\n"; PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) { @@ -395,7 +395,7 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) { /* get axis value ----------------------------------------------------- */ -char SCA_JoystickSensor::GetRealAxis_doc[] = +const char SCA_JoystickSensor::GetRealAxis_doc[] = "getAxisValue\n" "\tReturns a list of the values for each axis .\n"; PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) { @@ -408,7 +408,7 @@ PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) { /* get threshold ----------------------------------------------------- */ -char SCA_JoystickSensor::GetThreshold_doc[] = +const char SCA_JoystickSensor::GetThreshold_doc[] = "getThreshold\n" "\tReturns the threshold of the axis.\n"; PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self) { @@ -417,7 +417,7 @@ PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self) { /* set threshold ----------------------------------------------------- */ -char SCA_JoystickSensor::SetThreshold_doc[] = +const char SCA_JoystickSensor::SetThreshold_doc[] = "setThreshold\n" "\tSets the threshold of the axis.\n"; PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, PyObject* args ) { @@ -431,7 +431,7 @@ PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, PyObject* args ) { /* get button -------------------------------------------------------- */ -char SCA_JoystickSensor::GetButton_doc[] = +const char SCA_JoystickSensor::GetButton_doc[] = "getButton\n" "\tReturns the currently pressed button.\n"; PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self) { @@ -440,7 +440,7 @@ PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self) { /* set button -------------------------------------------------------- */ -char SCA_JoystickSensor::SetButton_doc[] = +const char SCA_JoystickSensor::SetButton_doc[] = "setButton\n" "\tSets the button the sensor reacts to.\n"; PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* args ) { @@ -455,7 +455,7 @@ PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* args ) { /* get hat ----------------------------------------------------------- */ -char SCA_JoystickSensor::GetHat_doc[] = +const char SCA_JoystickSensor::GetHat_doc[] = "getHat\n" "\tReturns the current direction of the hat.\n"; PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self ) { @@ -464,7 +464,7 @@ PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self ) { /* set hat ----------------------------------------------------------- */ -char SCA_JoystickSensor::SetHat_doc[] = +const char SCA_JoystickSensor::SetHat_doc[] = "setHat\n" "\tSets the hat the sensor reacts to.\n"; PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, PyObject* args ) { @@ -479,7 +479,7 @@ PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, PyObject* args ) { /* get # of ----------------------------------------------------- */ -char SCA_JoystickSensor::NumberOfAxes_doc[] = +const char SCA_JoystickSensor::NumberOfAxes_doc[] = "getNumAxes\n" "\tReturns the number of axes .\n"; PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) { @@ -489,7 +489,7 @@ PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) { } -char SCA_JoystickSensor::NumberOfButtons_doc[] = +const char SCA_JoystickSensor::NumberOfButtons_doc[] = "getNumButtons\n" "\tReturns the number of buttons .\n"; PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) { @@ -498,7 +498,7 @@ PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) { } -char SCA_JoystickSensor::NumberOfHats_doc[] = +const char SCA_JoystickSensor::NumberOfHats_doc[] = "getNumHats\n" "\tReturns the number of hats .\n"; PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) { @@ -506,7 +506,7 @@ PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) { return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 ); } -char SCA_JoystickSensor::Connected_doc[] = +const char SCA_JoystickSensor::Connected_doc[] = "getConnected\n" "\tReturns True if a joystick is connected at this joysticks index.\n"; PyObject* SCA_JoystickSensor::PyConnected( PyObject* self ) { diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index fba1162993d..ac773139794 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -510,7 +510,7 @@ PyObject* SCA_KeyboardSensor::sPySetAllMode(PyObject* self, /** 1. GetKey : check which key this sensor looks at */ -char SCA_KeyboardSensor::GetKey_doc[] = +const char SCA_KeyboardSensor::GetKey_doc[] = "getKey()\n" "\tReturn the code of the key this sensor is listening to.\n" ; PyObject* SCA_KeyboardSensor::PyGetKey(PyObject* self, PyObject* args, PyObject* kwds) @@ -519,7 +519,7 @@ PyObject* SCA_KeyboardSensor::PyGetKey(PyObject* self, PyObject* args, PyObject* } /** 2. SetKey: change the key to look at */ -char SCA_KeyboardSensor::SetKey_doc[] = +const char SCA_KeyboardSensor::SetKey_doc[] = "setKey(keycode)\n" "\t- keycode: any code from GameKeys\n" "\tSet the key this sensor should listen to.\n" ; @@ -539,7 +539,7 @@ PyObject* SCA_KeyboardSensor::PySetKey(PyObject* self, PyObject* args, PyObject* } /** 3. GetHold1 : set the first bucky bit */ -char SCA_KeyboardSensor::GetHold1_doc[] = +const char SCA_KeyboardSensor::GetHold1_doc[] = "getHold1()\n" "\tReturn the code of the first key modifier to the key this \n" "\tsensor is listening to.\n" ; @@ -549,7 +549,7 @@ PyObject* SCA_KeyboardSensor::PyGetHold1(PyObject* self, PyObject* args, PyObjec } /** 4. SetHold1: change the first bucky bit */ -char SCA_KeyboardSensor::SetHold1_doc[] = +const char SCA_KeyboardSensor::SetHold1_doc[] = "setHold1(keycode)\n" "\t- keycode: any code from GameKeys\n" "\tSet the first modifier to the key this sensor should listen to.\n" ; @@ -569,7 +569,7 @@ PyObject* SCA_KeyboardSensor::PySetHold1(PyObject* self, PyObject* args, PyObjec } /** 5. GetHold2 : get the second bucky bit */ -char SCA_KeyboardSensor::GetHold2_doc[] = +const char SCA_KeyboardSensor::GetHold2_doc[] = "getHold2()\n" "\tReturn the code of the second key modifier to the key this \n" "\tsensor is listening to.\n" ; @@ -579,7 +579,7 @@ PyObject* SCA_KeyboardSensor::PyGetHold2(PyObject* self, PyObject* args, PyObjec } /** 6. SetHold2: change the second bucky bit */ -char SCA_KeyboardSensor::SetHold2_doc[] = +const char SCA_KeyboardSensor::SetHold2_doc[] = "setHold2(keycode)\n" "\t- keycode: any code from GameKeys\n" "\tSet the first modifier to the key this sensor should listen to.\n" ; @@ -599,7 +599,7 @@ PyObject* SCA_KeyboardSensor::PySetHold2(PyObject* self, PyObject* args, PyObjec } -char SCA_KeyboardSensor::GetPressedKeys_doc[] = +const char SCA_KeyboardSensor::GetPressedKeys_doc[] = "getPressedKeys()\n" "\tGet a list of pressed keys that have either been pressed, or just released this frame.\n" ; @@ -639,7 +639,7 @@ PyObject* SCA_KeyboardSensor::PyGetPressedKeys(PyObject* self, PyObject* args, P -char SCA_KeyboardSensor::GetCurrentlyPressedKeys_doc[] = +const char SCA_KeyboardSensor::GetCurrentlyPressedKeys_doc[] = "getCurrentlyPressedKeys()\n" "\tGet a list of keys that are currently pressed.\n" ; diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 2298ddb0743..8f56d153f02 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -293,7 +293,7 @@ PyObject* SCA_MouseSensor::_getattr(const STR_String& attr) { } /* get x position ---------------------------------------------------------- */ -char SCA_MouseSensor::GetXPosition_doc[] = +const char SCA_MouseSensor::GetXPosition_doc[] = "getXPosition\n" "\tReturns the x-coordinate of the mouse sensor, in frame coordinates.\n" "\tThe lower-left corner is the origin. The coordinate is given in\n" @@ -305,7 +305,7 @@ PyObject* SCA_MouseSensor::PyGetXPosition(PyObject* self, } /* get y position ---------------------------------------------------------- */ -char SCA_MouseSensor::GetYPosition_doc[] = +const char SCA_MouseSensor::GetYPosition_doc[] = "getYPosition\n" "\tReturns the y-coordinate of the mouse sensor, in frame coordinates.\n" "\tThe lower-left corner is the origin. The coordinate is given in\n" diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index 7062f2cef6a..e5ddd8d121c 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -257,7 +257,7 @@ PyObject* SCA_PropertyActuator::_getattr(const STR_String& attr) { } /* 1. setProperty */ -char SCA_PropertyActuator::SetProperty_doc[] = +const char SCA_PropertyActuator::SetProperty_doc[] = "setProperty(name)\n" "\t- name: string\n" "\tSet the property on which to operate. If there is no property\n" @@ -283,7 +283,7 @@ PyObject* SCA_PropertyActuator::PySetProperty(PyObject* self, PyObject* args, Py } /* 2. getProperty */ -char SCA_PropertyActuator::GetProperty_doc[] = +const char SCA_PropertyActuator::GetProperty_doc[] = "getProperty(name)\n" "\tReturn the property on which the actuator operates.\n"; PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds) @@ -292,7 +292,7 @@ PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* self, PyObject* args, Py } /* 3. setValue */ -char SCA_PropertyActuator::SetValue_doc[] = +const char SCA_PropertyActuator::SetValue_doc[] = "setValue(value)\n" "\t- value: string\n" "\tSet the value with which the actuator operates. If the value\n" @@ -311,7 +311,7 @@ PyObject* SCA_PropertyActuator::PySetValue(PyObject* self, PyObject* args, PyObj } /* 4. getValue */ -char SCA_PropertyActuator::GetValue_doc[] = +const char SCA_PropertyActuator::GetValue_doc[] = "getValue()\n" "\tReturns the value with which the actuator operates.\n"; PyObject* SCA_PropertyActuator::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds) diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index c50c011cc63..b1a4b776860 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -347,7 +347,7 @@ PyObject* SCA_PropertySensor::_getattr(const STR_String& attr) { } /* 1. getType */ -char SCA_PropertySensor::GetType_doc[] = +const char SCA_PropertySensor::GetType_doc[] = "getType()\n" "\tReturns the type of check this sensor performs.\n"; PyObject* SCA_PropertySensor::PyGetType(PyObject* self, PyObject* args, PyObject* kwds) @@ -356,7 +356,7 @@ PyObject* SCA_PropertySensor::PyGetType(PyObject* self, PyObject* args, PyObject } /* 2. setType */ -char SCA_PropertySensor::SetType_doc[] = +const char SCA_PropertySensor::SetType_doc[] = "setType(type)\n" "\t- type: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,\n" "\t KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,\n" @@ -379,7 +379,7 @@ PyObject* SCA_PropertySensor::PySetType(PyObject* self, PyObject* args, PyObject } /* 3. getProperty */ -char SCA_PropertySensor::GetProperty_doc[] = +const char SCA_PropertySensor::GetProperty_doc[] = "getProperty()\n" "\tReturn the property with which the sensor operates.\n"; PyObject* SCA_PropertySensor::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds) @@ -388,7 +388,7 @@ PyObject* SCA_PropertySensor::PyGetProperty(PyObject* self, PyObject* args, PyOb } /* 4. setProperty */ -char SCA_PropertySensor::SetProperty_doc[] = +const char SCA_PropertySensor::SetProperty_doc[] = "setProperty(name)\n" "\t- name: string\n" "\tSets the property with which to operate. If there is no property\n" @@ -414,7 +414,7 @@ PyObject* SCA_PropertySensor::PySetProperty(PyObject* self, PyObject* args, PyOb } /* 5. getValue */ -char SCA_PropertySensor::GetValue_doc[] = +const char SCA_PropertySensor::GetValue_doc[] = "getValue()\n" "\tReturns the value with which the sensor operates.\n"; PyObject* SCA_PropertySensor::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds) @@ -423,7 +423,7 @@ PyObject* SCA_PropertySensor::PyGetValue(PyObject* self, PyObject* args, PyObjec } /* 6. setValue */ -char SCA_PropertySensor::SetValue_doc[] = +const char SCA_PropertySensor::SetValue_doc[] = "setValue(value)\n" "\t- value: string\n" "\tSet the value with which the sensor operates. If the value\n" diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 6e9a0a7c6b6..7e2fb081083 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -151,7 +151,7 @@ int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor) } #if 0 -static char* sPyGetCurrentController__doc__; +static const char* sPyGetCurrentController__doc__; #endif @@ -162,7 +162,7 @@ PyObject* SCA_PythonController::sPyGetCurrentController(PyObject* self) } #if 0 -static char* sPyAddActiveActuator__doc__; +static const char* sPyAddActiveActuator__doc__; #endif PyObject* SCA_PythonController::sPyAddActiveActuator( @@ -199,9 +199,9 @@ PyObject* SCA_PythonController::sPyAddActiveActuator( } -char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentController()"; -char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuator(actuator,bool)"; -char SCA_PythonController::GetActuators_doc[] = "getActuator"; +const char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentController()"; +const char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuator(actuator,bool)"; +const char SCA_PythonController::GetActuators_doc[] = "getActuator"; PyTypeObject SCA_PythonController::Type = { PyObject_HEAD_INIT(&PyType_Type) @@ -329,7 +329,7 @@ PyObject* SCA_PythonController::PyGetActuators(PyObject* self) return resultlist; } -char SCA_PythonController::GetSensor_doc[] = +const char SCA_PythonController::GetSensor_doc[] = "GetSensor (char sensorname) return linked sensor that is named [sensorname]\n"; PyObject* SCA_PythonController::PyGetSensor(PyObject* self, PyObject* value) @@ -359,7 +359,7 @@ SCA_PythonController::PyGetSensor(PyObject* self, PyObject* value) -char SCA_PythonController::GetActuator_doc[] = +const char SCA_PythonController::GetActuator_doc[] = "GetActuator (char sensorname) return linked actuator that is named [actuatorname]\n"; PyObject* SCA_PythonController::PyGetActuator(PyObject* self, PyObject* value) @@ -388,7 +388,7 @@ SCA_PythonController::PyGetActuator(PyObject* self, PyObject* value) } -char SCA_PythonController::GetSensors_doc[] = "getSensors returns a list of all attached sensors"; +const char SCA_PythonController::GetSensors_doc[] = "getSensors returns a list of all attached sensors"; PyObject* SCA_PythonController::PyGetSensors(PyObject* self) { diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 1b62e7ecb53..d9b2e242bea 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -71,9 +71,9 @@ class SCA_PythonController : public SCA_IController { m_triggeredSensors.push_back(sensor); } int IsTriggered(class SCA_ISensor* sensor); - static char* sPyGetCurrentController__doc__; + static const char* sPyGetCurrentController__doc__; static PyObject* sPyGetCurrentController(PyObject* self); - static char* sPyAddActiveActuator__doc__; + static const char* sPyAddActiveActuator__doc__; static PyObject* sPyAddActiveActuator(PyObject* self, PyObject* args); virtual PyObject* _getattr(const STR_String& attr); diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index 0a1ac2d0668..e87b3dba458 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -364,7 +364,7 @@ PyObject* SCA_RandomActuator::_getattr(const STR_String& attr) { } /* 1. setSeed */ -char SCA_RandomActuator::SetSeed_doc[] = +const char SCA_RandomActuator::SetSeed_doc[] = "setSeed(seed)\n" "\t- seed: integer\n" "\tSet the initial seed of the generator. Equal seeds produce\n" @@ -381,7 +381,7 @@ PyObject* SCA_RandomActuator::PySetSeed(PyObject* self, PyObject* args, PyObject Py_Return; } /* 2. getSeed */ -char SCA_RandomActuator::GetSeed_doc[] = +const char SCA_RandomActuator::GetSeed_doc[] = "getSeed()\n" "\tReturns the initial seed of the generator. Equal seeds produce\n" "\tequal series.\n"; @@ -390,7 +390,7 @@ PyObject* SCA_RandomActuator::PyGetSeed(PyObject* self, PyObject* args, PyObject } /* 4. getPara1 */ -char SCA_RandomActuator::GetPara1_doc[] = +const char SCA_RandomActuator::GetPara1_doc[] = "getPara1()\n" "\tReturns the first parameter of the active distribution. Refer\n" "\tto the documentation of the generator types for the meaning\n" @@ -400,7 +400,7 @@ PyObject* SCA_RandomActuator::PyGetPara1(PyObject* self, PyObject* args, PyObjec } /* 6. getPara2 */ -char SCA_RandomActuator::GetPara2_doc[] = +const char SCA_RandomActuator::GetPara2_doc[] = "getPara2()\n" "\tReturns the first parameter of the active distribution. Refer\n" "\tto the documentation of the generator types for the meaning\n" @@ -410,7 +410,7 @@ PyObject* SCA_RandomActuator::PyGetPara2(PyObject* self, PyObject* args, PyObjec } /* 8. getDistribution */ -char SCA_RandomActuator::GetDistribution_doc[] = +const char SCA_RandomActuator::GetDistribution_doc[] = "getDistribution()\n" "\tReturns the type of the active distribution.\n"; PyObject* SCA_RandomActuator::PyGetDistribution(PyObject* self, PyObject* args, PyObject* kwds) { @@ -418,7 +418,7 @@ PyObject* SCA_RandomActuator::PyGetDistribution(PyObject* self, PyObject* args, } /* 9. setProperty */ -char SCA_RandomActuator::SetProperty_doc[] = +const char SCA_RandomActuator::SetProperty_doc[] = "setProperty(name)\n" "\t- name: string\n" "\tSet the property to which the random value is assigned. If the \n" @@ -441,7 +441,7 @@ PyObject* SCA_RandomActuator::PySetProperty(PyObject* self, PyObject* args, PyOb Py_Return; } /* 10. getProperty */ -char SCA_RandomActuator::GetProperty_doc[] = +const char SCA_RandomActuator::GetProperty_doc[] = "getProperty(name)\n" "\tReturn the property to which the random value is assigned. If the \n" "\tgenerator and property types do not match, the assignment is ignored.\n"; @@ -450,7 +450,7 @@ PyObject* SCA_RandomActuator::PyGetProperty(PyObject* self, PyObject* args, PyOb } /* 11. setBoolConst */ -char SCA_RandomActuator::SetBoolConst_doc[] = +const char SCA_RandomActuator::SetBoolConst_doc[] = "setBoolConst(value)\n" "\t- value: 0 or 1\n" "\tSet this generator to produce a constant boolean value.\n"; @@ -470,7 +470,7 @@ PyObject* SCA_RandomActuator::PySetBoolConst(PyObject* self, Py_Return; } /* 12. setBoolUniform, */ -char SCA_RandomActuator::SetBoolUniform_doc[] = +const char SCA_RandomActuator::SetBoolUniform_doc[] = "setBoolUniform()\n" "\tSet this generator to produce true and false, each with 50%% chance of occuring\n"; PyObject* SCA_RandomActuator::PySetBoolUniform(PyObject* self, @@ -482,7 +482,7 @@ PyObject* SCA_RandomActuator::PySetBoolUniform(PyObject* self, Py_Return; } /* 13. setBoolBernouilli, */ -char SCA_RandomActuator::SetBoolBernouilli_doc[] = +const char SCA_RandomActuator::SetBoolBernouilli_doc[] = "setBoolBernouilli(value)\n" "\t- value: a float between 0 and 1\n" "\tReturn false value * 100%% of the time.\n"; @@ -500,7 +500,7 @@ PyObject* SCA_RandomActuator::PySetBoolBernouilli(PyObject* self, Py_Return; } /* 14. setIntConst,*/ -char SCA_RandomActuator::SetIntConst_doc[] = +const char SCA_RandomActuator::SetIntConst_doc[] = "setIntConst(value)\n" "\t- value: integer\n" "\tAlways return value\n"; @@ -518,7 +518,7 @@ PyObject* SCA_RandomActuator::PySetIntConst(PyObject* self, Py_Return; } /* 15. setIntUniform,*/ -char SCA_RandomActuator::SetIntUniform_doc[] = +const char SCA_RandomActuator::SetIntUniform_doc[] = "setIntUniform(lower_bound, upper_bound)\n" "\t- lower_bound: integer\n" "\t- upper_bound: integer\n" @@ -539,7 +539,7 @@ PyObject* SCA_RandomActuator::PySetIntUniform(PyObject* self, Py_Return; } /* 16. setIntPoisson, */ -char SCA_RandomActuator::SetIntPoisson_doc[] = +const char SCA_RandomActuator::SetIntPoisson_doc[] = "setIntPoisson(value)\n" "\t- value: float\n" "\tReturn a Poisson-distributed number. This performs a series\n" @@ -559,7 +559,7 @@ PyObject* SCA_RandomActuator::PySetIntPoisson(PyObject* self, Py_Return; } /* 17. setFloatConst,*/ -char SCA_RandomActuator::SetFloatConst_doc[] = +const char SCA_RandomActuator::SetFloatConst_doc[] = "setFloatConst(value)\n" "\t- value: float\n" "\tAlways return value\n"; @@ -577,7 +577,7 @@ PyObject* SCA_RandomActuator::PySetFloatConst(PyObject* self, Py_Return; } /* 18. setFloatUniform, */ -char SCA_RandomActuator::SetFloatUniform_doc[] = +const char SCA_RandomActuator::SetFloatUniform_doc[] = "setFloatUniform(lower_bound, upper_bound)\n" "\t- lower_bound: float\n" "\t- upper_bound: float\n" @@ -598,7 +598,7 @@ PyObject* SCA_RandomActuator::PySetFloatUniform(PyObject* self, Py_Return; } /* 19. setFloatNormal, */ -char SCA_RandomActuator::SetFloatNormal_doc[] = +const char SCA_RandomActuator::SetFloatNormal_doc[] = "setFloatNormal(mean, standard_deviation)\n" "\t- mean: float\n" "\t- standard_deviation: float\n" @@ -619,7 +619,7 @@ PyObject* SCA_RandomActuator::PySetFloatNormal(PyObject* self, Py_Return; } /* 20. setFloatNegativeExponential, */ -char SCA_RandomActuator::SetFloatNegativeExponential_doc[] = +const char SCA_RandomActuator::SetFloatNegativeExponential_doc[] = "setFloatNegativeExponential(half_life)\n" "\t- half_life: float\n" "\tReturn negative-exponentially distributed numbers. The half-life 'time'\n" diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 3626522e49a..2caca1a27ec 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -165,7 +165,7 @@ PyObject* SCA_RandomSensor::_getattr(const STR_String& attr) { } /* 1. setSeed */ -char SCA_RandomSensor::SetSeed_doc[] = +const char SCA_RandomSensor::SetSeed_doc[] = "setSeed(seed)\n" "\t- seed: integer\n" "\tSet the initial seed of the generator. Equal seeds produce\n" @@ -183,7 +183,7 @@ PyObject* SCA_RandomSensor::PySetSeed(PyObject* self, PyObject* args, PyObject* } /* 2. getSeed */ -char SCA_RandomSensor::GetSeed_doc[] = +const char SCA_RandomSensor::GetSeed_doc[] = "getSeed()\n" "\tReturns the initial seed of the generator. Equal seeds produce\n" "\tequal series.\n"; @@ -192,7 +192,7 @@ PyObject* SCA_RandomSensor::PyGetSeed(PyObject* self, PyObject* args, PyObject* } /* 3. getLastDraw */ -char SCA_RandomSensor::GetLastDraw_doc[] = +const char SCA_RandomSensor::GetLastDraw_doc[] = "getLastDraw()\n" "\tReturn the last value that was drawn.\n"; PyObject* SCA_RandomSensor::PyGetLastDraw(PyObject* self, PyObject* args, PyObject* kwds) { diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp index a9cfb0a9366..e6e97cbdfd3 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp @@ -45,7 +45,7 @@ GPC_RawImage::GPC_RawImage() bool GPC_RawImage::Load( - char *srcName, + const char *srcName, int destWidth, int destHeight, TImageAlignment alignment, int offsetX, int offsetY) { diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.h b/source/gameengine/GamePlayer/common/GPC_RawImage.h index 17c00d2fcc3..49a3043bffc 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawImage.h +++ b/source/gameengine/GamePlayer/common/GPC_RawImage.h @@ -61,7 +61,7 @@ public: * @param offsetX Amount of horzontal offset applied to the resource image. * @param offsetY Amount of vertical offset applied to the resource image. */ - virtual bool Load(char *srcName, + virtual bool Load(const char *srcName, int destWidth, int destHeight, TImageAlignment alignment = alignTopLeft, int offsetX = 0, int offsetY = 0); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 01774a68cc4..4dfbbab7cd3 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -150,9 +150,9 @@ static BOOL scr_saver_init(int argc, char **argv) #endif /* WIN32 */ -void usage(char* program) +void usage(const char* program) { - char * consoleoption; + const char * consoleoption; #ifdef _WIN32 consoleoption = "-c "; #else diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index f28d3fa2912..80892764089 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -881,7 +881,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" ) Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; int index=-1; if(PyArg_ParseTuple(args, "si", &uniform, &index)) { @@ -922,7 +922,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" ) Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; float value=0; if(PyArg_ParseTuple(args, "sf", &uniform, &value )) { @@ -946,7 +946,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)") if(mError) { Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; float array[2]={ 0,0 }; if(PyArg_ParseTuple(args, "sff", &uniform, &array[0],&array[1] )) { @@ -970,7 +970,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ") if(mError) { Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; float array[3]={0,0,0}; if(PyArg_ParseTuple(args, "sfff", &uniform, &array[0],&array[1],&array[2])) { @@ -995,7 +995,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) " if(mError) { Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; float array[4]={0,0,0,0}; if(PyArg_ParseTuple(args, "sffff", &uniform, &array[0],&array[1],&array[2], &array[3])) { @@ -1019,7 +1019,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" ) if(mError) { Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; int value=0; if(PyArg_ParseTuple(args, "si", &uniform, &value )) { @@ -1043,7 +1043,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)") if(mError) { Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; int array[2]={ 0,0 }; if(PyArg_ParseTuple(args, "sii", &uniform, &array[0],&array[1] )) { @@ -1068,7 +1068,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ") Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; int array[3]={0,0,0}; if(PyArg_ParseTuple(args, "siii", &uniform, &array[0],&array[1],&array[2])) { @@ -1091,7 +1091,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) " if(mError) { Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; int array[4]={0,0,0, 0}; if(PyArg_ParseTuple(args, "siiii", &uniform, &array[0],&array[1],&array[2], &array[3] )) { @@ -1114,7 +1114,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or lis if(mError) { Py_RETURN_NONE; } - char*uniform = ""; + const char *uniform = ""; PyObject *listPtr =0; float array_data[4] = {0.f,0.f,0.f,0.f}; @@ -1183,7 +1183,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( int (list2 or list3 if(mError) { Py_RETURN_NONE; } - char*uniform = ""; + const char *uniform = ""; PyObject *listPtr =0; int array_data[4] = {0,0,0,0}; @@ -1263,7 +1263,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4, 0,0,0,1 }; - char *uniform=""; + const char *uniform=""; PyObject *matrix=0; int transp=1; // MT_ is row major so transpose by default.... if(PyArg_ParseTuple(args, "sO|i",&uniform, &matrix,&transp)) @@ -1304,7 +1304,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3, 0,0,1, }; - char *uniform=""; + const char *uniform=""; PyObject *matrix=0; int transp=1; // MT_ is row major so transpose by default.... if(PyArg_ParseTuple(args, "sO|i",&uniform, &matrix,&transp)) @@ -1358,7 +1358,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" ) Py_RETURN_NONE; } - char *uniform=""; + const char *uniform=""; int nloc=0; if(PyArg_ParseTuple(args, "si",&uniform, &nloc)) { diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h index c7fae31ba03..18ca8f8b4f8 100644 --- a/source/gameengine/Ketsji/BL_Shader.h +++ b/source/gameengine/Ketsji/BL_Shader.h @@ -102,8 +102,8 @@ private: bool mUse; // ... //BL_Sampler mSampler[MAXTEX]; // Number of samplers int mAttr; // Tangent attribute - char* vertProg; // Vertex program string - char* fragProg; // Fragment program string + const char* vertProg; // Vertex program string + const char* fragProg; // Fragment program string bool mError; // ... bool mDirty; // diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index a35ab8b15e8..16dbe65d508 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -218,7 +218,7 @@ PyObject* KX_NetworkMessageSensor::_getattr(const STR_String& attr) { } // 1. Set the message subject that this sensor listens for -char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] = +const char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] = "\tsetSubjectFilterText(value)\n" "\tChange the message subject text that this sensor is listening to.\n"; @@ -235,7 +235,7 @@ PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText( PyObject* self, PyObj } // 2. Get the number of messages received since the last frame -char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] = +const char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] = "\tgetFrameMessageCount()\n" "\tGet the number of messages received since the last frame.\n"; @@ -245,7 +245,7 @@ PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount( PyObject* ) } // 3. Get the message bodies -char KX_NetworkMessageSensor::GetBodies_doc[] = +const char KX_NetworkMessageSensor::GetBodies_doc[] = "\tgetBodies()\n" "\tGet the list of message bodies.\n"; @@ -259,7 +259,7 @@ PyObject* KX_NetworkMessageSensor::PyGetBodies( PyObject* ) } // 4. Get the message subject: field of the message sensor -char KX_NetworkMessageSensor::GetSubject_doc[] = +const char KX_NetworkMessageSensor::GetSubject_doc[] = "\tgetSubject()\n" "\tGet the subject: field of the message sensor.\n"; @@ -269,7 +269,7 @@ PyObject* KX_NetworkMessageSensor::PyGetSubject( PyObject* ) } // 5. Get the message subjects -char KX_NetworkMessageSensor::GetSubjects_doc[] = +const char KX_NetworkMessageSensor::GetSubjects_doc[] = "\tgetSubjects()\n" "\tGet list of message subjects.\n"; diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 4948c0ea174..099b0d90870 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -414,7 +414,7 @@ PyObject* KX_CameraActuator::_getattr(const STR_String& attr) { _getattr_up(SCA_IActuator); } /* get obj ---------------------------------------------------------- */ -char KX_CameraActuator::GetObject_doc[] = +const char KX_CameraActuator::GetObject_doc[] = "getObject(name_only = 1)\n" "name_only - optional arg, when true will return the KX_GameObject rather then its name\n" "\tReturns the object this sensor reacts to.\n"; @@ -433,7 +433,7 @@ PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* args) return m_ob->AddRef(); } /* set obj ---------------------------------------------------------- */ -char KX_CameraActuator::SetObject_doc[] = +const char KX_CameraActuator::SetObject_doc[] = "setObject(object)\n" "\t- object: KX_GameObject, string or None\n" "\tSets the object this sensor reacts to.\n"; @@ -455,7 +455,7 @@ PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* value) } /* get min ---------------------------------------------------------- */ -char KX_CameraActuator::GetMin_doc[] = +const char KX_CameraActuator::GetMin_doc[] = "getMin\n" "\tReturns the minimum value set in the Min: field.\n"; PyObject* KX_CameraActuator::PyGetMin(PyObject* self, @@ -465,7 +465,7 @@ PyObject* KX_CameraActuator::PyGetMin(PyObject* self, return PyFloat_FromDouble(m_minHeight); } /* set min ---------------------------------------------------------- */ -char KX_CameraActuator::SetMin_doc[] = +const char KX_CameraActuator::SetMin_doc[] = "setMin\n" "\tSets the minimum value.\n"; PyObject* KX_CameraActuator::PySetMin(PyObject* self, @@ -481,7 +481,7 @@ PyObject* KX_CameraActuator::PySetMin(PyObject* self, return NULL; } /* get min ---------------------------------------------------------- */ -char KX_CameraActuator::GetMax_doc[] = +const char KX_CameraActuator::GetMax_doc[] = "getMax\n" "\tReturns the maximum value set in the Max: field.\n"; PyObject* KX_CameraActuator::PyGetMax(PyObject* self, @@ -491,7 +491,7 @@ PyObject* KX_CameraActuator::PyGetMax(PyObject* self, return PyFloat_FromDouble(m_maxHeight); } /* set min ---------------------------------------------------------- */ -char KX_CameraActuator::SetMax_doc[] = +const char KX_CameraActuator::SetMax_doc[] = "setMax\n" "\tSets the maximum value.\n"; PyObject* KX_CameraActuator::PySetMax(PyObject* self, @@ -507,7 +507,7 @@ PyObject* KX_CameraActuator::PySetMax(PyObject* self, return NULL; } /* get height ---------------------------------------------------------- */ -char KX_CameraActuator::GetHeight_doc[] = +const char KX_CameraActuator::GetHeight_doc[] = "getHeight\n" "\tReturns the height value set in the height: field.\n"; PyObject* KX_CameraActuator::PyGetHeight(PyObject* self, @@ -517,7 +517,7 @@ PyObject* KX_CameraActuator::PyGetHeight(PyObject* self, return PyFloat_FromDouble(m_height); } /* set height ---------------------------------------------------------- */ -char KX_CameraActuator::SetHeight_doc[] = +const char KX_CameraActuator::SetHeight_doc[] = "setHeight\n" "\tSets the height value.\n"; PyObject* KX_CameraActuator::PySetHeight(PyObject* self, @@ -533,7 +533,7 @@ PyObject* KX_CameraActuator::PySetHeight(PyObject* self, return NULL; } /* set XY ---------------------------------------------------------- */ -char KX_CameraActuator::SetXY_doc[] = +const char KX_CameraActuator::SetXY_doc[] = "setXY\n" "\tSets axis the camera tries to get behind.\n" "\t1=x, 0=y\n"; @@ -551,7 +551,7 @@ PyObject* KX_CameraActuator::PySetXY(PyObject* self, } /* get XY -------------------------------------------------------------*/ -char KX_CameraActuator::GetXY_doc[] = +const char KX_CameraActuator::GetXY_doc[] = "getXY\n" "\tGets the axis the camera tries to get behind.\n" "\tTrue = X, False = Y\n"; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index e0c9af5ae60..11af4b9324b 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -479,7 +479,7 @@ PyObject* KX_ConstraintActuator::_getattr(const STR_String& attr) { } /* 2. setDamp */ -char KX_ConstraintActuator::SetDamp_doc[] = +const char KX_ConstraintActuator::SetDamp_doc[] = "setDamp(duration)\n" "\t- duration: integer\n" "\tSets the time constant of the orientation and distance constraint.\n" @@ -498,7 +498,7 @@ PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self, Py_Return; } /* 3. getDamp */ -char KX_ConstraintActuator::GetDamp_doc[] = +const char KX_ConstraintActuator::GetDamp_doc[] = "getDamp()\n" "\tReturns the damping parameter.\n"; PyObject* KX_ConstraintActuator::PyGetDamp(PyObject* self){ @@ -506,7 +506,7 @@ PyObject* KX_ConstraintActuator::PyGetDamp(PyObject* self){ } /* 2. setRotDamp */ -char KX_ConstraintActuator::SetRotDamp_doc[] = +const char KX_ConstraintActuator::SetRotDamp_doc[] = "setRotDamp(duration)\n" "\t- duration: integer\n" "\tSets the time constant of the orientation constraint.\n" @@ -525,7 +525,7 @@ PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* self, Py_Return; } /* 3. getRotDamp */ -char KX_ConstraintActuator::GetRotDamp_doc[] = +const char KX_ConstraintActuator::GetRotDamp_doc[] = "getRotDamp()\n" "\tReturns the damping time for application of the constraint.\n"; PyObject* KX_ConstraintActuator::PyGetRotDamp(PyObject* self){ @@ -533,7 +533,7 @@ PyObject* KX_ConstraintActuator::PyGetRotDamp(PyObject* self){ } /* 2. setDirection */ -char KX_ConstraintActuator::SetDirection_doc[] = +const char KX_ConstraintActuator::SetDirection_doc[] = "setDirection(vector)\n" "\t- vector: 3-tuple\n" "\tSets the reference direction in world coordinate for the orientation constraint.\n"; @@ -560,7 +560,7 @@ PyObject* KX_ConstraintActuator::PySetDirection(PyObject* self, Py_Return; } /* 3. getDirection */ -char KX_ConstraintActuator::GetDirection_doc[] = +const char KX_ConstraintActuator::GetDirection_doc[] = "getDirection()\n" "\tReturns the reference direction of the orientation constraint as a 3-tuple.\n"; PyObject* KX_ConstraintActuator::PyGetDirection(PyObject* self){ @@ -573,7 +573,7 @@ PyObject* KX_ConstraintActuator::PyGetDirection(PyObject* self){ } /* 2. setOption */ -char KX_ConstraintActuator::SetOption_doc[] = +const char KX_ConstraintActuator::SetOption_doc[] = "setOption(option)\n" "\t- option: integer\n" "\tSets several options of the distance constraint.\n" @@ -595,7 +595,7 @@ PyObject* KX_ConstraintActuator::PySetOption(PyObject* self, Py_Return; } /* 3. getOption */ -char KX_ConstraintActuator::GetOption_doc[] = +const char KX_ConstraintActuator::GetOption_doc[] = "getOption()\n" "\tReturns the option parameter.\n"; PyObject* KX_ConstraintActuator::PyGetOption(PyObject* self){ @@ -603,7 +603,7 @@ PyObject* KX_ConstraintActuator::PyGetOption(PyObject* self){ } /* 2. setTime */ -char KX_ConstraintActuator::SetTime_doc[] = +const char KX_ConstraintActuator::SetTime_doc[] = "setTime(duration)\n" "\t- duration: integer\n" "\tSets the activation time of the actuator.\n" @@ -624,7 +624,7 @@ PyObject* KX_ConstraintActuator::PySetTime(PyObject* self, Py_Return; } /* 3. getTime */ -char KX_ConstraintActuator::GetTime_doc[] = +const char KX_ConstraintActuator::GetTime_doc[] = "getTime()\n" "\tReturns the time parameter.\n"; PyObject* KX_ConstraintActuator::PyGetTime(PyObject* self){ @@ -632,7 +632,7 @@ PyObject* KX_ConstraintActuator::PyGetTime(PyObject* self){ } /* 2. setProperty */ -char KX_ConstraintActuator::SetProperty_doc[] = +const char KX_ConstraintActuator::SetProperty_doc[] = "setProperty(property)\n" "\t- property: string\n" "\tSets the name of the property or material for the ray detection of the distance constraint.\n" @@ -654,7 +654,7 @@ PyObject* KX_ConstraintActuator::PySetProperty(PyObject* self, Py_Return; } /* 3. getProperty */ -char KX_ConstraintActuator::GetProperty_doc[] = +const char KX_ConstraintActuator::GetProperty_doc[] = "getProperty()\n" "\tReturns the property parameter.\n"; PyObject* KX_ConstraintActuator::PyGetProperty(PyObject* self){ @@ -662,12 +662,12 @@ PyObject* KX_ConstraintActuator::PyGetProperty(PyObject* self){ } /* 4. setDistance */ -char KX_ConstraintActuator::SetDistance_doc[] = +const char KX_ConstraintActuator::SetDistance_doc[] = "setDistance(distance)\n" "\t- distance: float\n" "\tSets the target distance in distance constraint\n"; /* 4. setMin */ -char KX_ConstraintActuator::SetMin_doc[] = +const char KX_ConstraintActuator::SetMin_doc[] = "setMin(lower_bound)\n" "\t- lower_bound: float\n" "\tSets the lower value of the interval to which the value\n" @@ -694,11 +694,11 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self, Py_Return; } /* 5. getDistance */ -char KX_ConstraintActuator::GetDistance_doc[] = +const char KX_ConstraintActuator::GetDistance_doc[] = "getDistance()\n" "\tReturns the distance parameter \n"; /* 5. getMin */ -char KX_ConstraintActuator::GetMin_doc[] = +const char KX_ConstraintActuator::GetMin_doc[] = "getMin()\n" "\tReturns the lower value of the interval to which the value\n" "\tis clipped.\n"; @@ -707,12 +707,12 @@ PyObject* KX_ConstraintActuator::PyGetMin(PyObject* self) { } /* 6. setRayLength */ -char KX_ConstraintActuator::SetRayLength_doc[] = +const char KX_ConstraintActuator::SetRayLength_doc[] = "setRayLength(length)\n" "\t- length: float\n" "\tSets the maximum ray length of the distance constraint\n"; /* 6. setMax */ -char KX_ConstraintActuator::SetMax_doc[] = +const char KX_ConstraintActuator::SetMax_doc[] = "setMax(upper_bound)\n" "\t- upper_bound: float\n" "\tSets the upper value of the interval to which the value\n" @@ -739,11 +739,11 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self, Py_Return; } /* 7. getRayLength */ -char KX_ConstraintActuator::GetRayLength_doc[] = +const char KX_ConstraintActuator::GetRayLength_doc[] = "getRayLength()\n" "\tReturns the length of the ray\n"; /* 7. getMax */ -char KX_ConstraintActuator::GetMax_doc[] = +const char KX_ConstraintActuator::GetMax_doc[] = "getMax()\n" "\tReturns the upper value of the interval to which the value\n" "\tis clipped.\n"; @@ -754,7 +754,7 @@ PyObject* KX_ConstraintActuator::PyGetMax(PyObject* self) { /* This setter/getter probably for the constraint type */ /* 8. setLimit */ -char KX_ConstraintActuator::SetLimit_doc[] = +const char KX_ConstraintActuator::SetLimit_doc[] = "setLimit(type)\n" "\t- type: integer\n" "\t 1 : LocX\n" @@ -783,7 +783,7 @@ PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self, Py_Return; } /* 9. getLimit */ -char KX_ConstraintActuator::GetLimit_doc[] = +const char KX_ConstraintActuator::GetLimit_doc[] = "getLimit()\n" "\tReturns the type of constraint.\n"; PyObject* KX_ConstraintActuator::PyGetLimit(PyObject* self) { diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index 6ec4de9aad9..99c09c1e5cc 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -147,12 +147,12 @@ protected: KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetProperty); KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMin); KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMin); - static char SetDistance_doc[]; - static char GetDistance_doc[]; + static const char SetDistance_doc[]; + static const char GetDistance_doc[]; KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMax); KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMax); - static char SetRayLength_doc[]; - static char GetRayLength_doc[]; + static const char SetRayLength_doc[]; + static const char GetRayLength_doc[]; KX_PYMETHOD_DOC(KX_ConstraintActuator,SetLimit); KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetLimit); }; diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index 91ddbbbfbc9..db9333eafa7 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -247,7 +247,7 @@ PyMethodDef KX_GameActuator::Methods[] = }; /* getFile */ -char KX_GameActuator::GetFile_doc[] = +const char KX_GameActuator::GetFile_doc[] = "getFile()\n" "get the name of the file to start.\n"; PyObject* KX_GameActuator::PyGetFile(PyObject* self, PyObject* args, PyObject* kwds) @@ -256,7 +256,7 @@ PyObject* KX_GameActuator::PyGetFile(PyObject* self, PyObject* args, PyObject* k } /* setFile */ -char KX_GameActuator::SetFile_doc[] = +const char KX_GameActuator::SetFile_doc[] = "setFile(name)\n" "set the name of the file to start.\n"; PyObject* KX_GameActuator::PySetFile(PyObject* self, PyObject* args, PyObject* kwds) diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 75e4ade6574..d9945a4b131 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -462,7 +462,7 @@ PyObject* KX_IpoActuator::_getattr(const STR_String& attr) { /* set --------------------------------------------------------------------- */ -char KX_IpoActuator::Set_doc[] = +const char KX_IpoActuator::Set_doc[] = "set(type, startframe, endframe, mode?)\n" "\t - type: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n" "\t - startframe: first frame to use (int)\n" @@ -505,7 +505,7 @@ PyObject* KX_IpoActuator::PySet(PyObject* self, } /* set property ----------------------------------------------------------- */ -char KX_IpoActuator::SetProperty_doc[] = +const char KX_IpoActuator::SetProperty_doc[] = "setProperty(propname)\n" "\t - propname: name of the property (string)\n" "\tSet the property to be used in FromProp mode.\n"; @@ -525,7 +525,7 @@ PyObject* KX_IpoActuator::PySetProperty(PyObject* self, } /* 4. setStart: */ -char KX_IpoActuator::SetStart_doc[] = +const char KX_IpoActuator::SetStart_doc[] = "setStart(frame)\n" "\t - frame: first frame to use (int)\n" "\tSet the frame from which the ipo starts playing.\n"; @@ -542,7 +542,7 @@ PyObject* KX_IpoActuator::PySetStart(PyObject* self, Py_Return; } /* 5. getStart: */ -char KX_IpoActuator::GetStart_doc[] = +const char KX_IpoActuator::GetStart_doc[] = "getStart()\n" "\tReturns the frame from which the ipo starts playing.\n"; PyObject* KX_IpoActuator::PyGetStart(PyObject* self) { @@ -550,7 +550,7 @@ PyObject* KX_IpoActuator::PyGetStart(PyObject* self) { } /* 6. setEnd: */ -char KX_IpoActuator::SetEnd_doc[] = +const char KX_IpoActuator::SetEnd_doc[] = "setEnd(frame)\n" "\t - frame: last frame to use (int)\n" "\tSet the frame at which the ipo stops playing.\n"; @@ -567,7 +567,7 @@ PyObject* KX_IpoActuator::PySetEnd(PyObject* self, Py_Return; } /* 7. getEnd: */ -char KX_IpoActuator::GetEnd_doc[] = +const char KX_IpoActuator::GetEnd_doc[] = "getEnd()\n" "\tReturns the frame at which the ipo stops playing.\n"; PyObject* KX_IpoActuator::PyGetEnd(PyObject* self) { @@ -575,7 +575,7 @@ PyObject* KX_IpoActuator::PyGetEnd(PyObject* self) { } /* 6. setIpoAsForce: */ -char KX_IpoActuator::SetIpoAsForce_doc[] = +const char KX_IpoActuator::SetIpoAsForce_doc[] = "setIpoAsForce(force?)\n" "\t - force? : interpret this ipo as a force? (KX_TRUE, KX_FALSE)\n" "\tSet whether to interpret the ipo as a force rather than a displacement.\n"; @@ -595,7 +595,7 @@ PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self, Py_Return; } /* 7. getIpoAsForce: */ -char KX_IpoActuator::GetIpoAsForce_doc[] = +const char KX_IpoActuator::GetIpoAsForce_doc[] = "getIpoAsForce()\n" "\tReturns whether to interpret the ipo as a force rather than a displacement.\n"; PyObject* KX_IpoActuator::PyGetIpoAsForce(PyObject* self) { @@ -603,7 +603,7 @@ PyObject* KX_IpoActuator::PyGetIpoAsForce(PyObject* self) { } /* 6. setIpoAsForce: */ -char KX_IpoActuator::SetIpoAdd_doc[] = +const char KX_IpoActuator::SetIpoAdd_doc[] = "setIpoAdd(add?)\n" "\t - add? : add flag (KX_TRUE, KX_FALSE)\n" "\tSet whether to interpret the ipo as additive rather than absolute.\n"; @@ -623,7 +623,7 @@ PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self, Py_Return; } /* 7. getIpoAsForce: */ -char KX_IpoActuator::GetIpoAdd_doc[] = +const char KX_IpoActuator::GetIpoAdd_doc[] = "getIpoAsAdd()\n" "\tReturns whether to interpret the ipo as additive rather than absolute.\n"; PyObject* KX_IpoActuator::PyGetIpoAdd(PyObject* self) { @@ -631,7 +631,7 @@ PyObject* KX_IpoActuator::PyGetIpoAdd(PyObject* self) { } /* 8. setType: */ -char KX_IpoActuator::SetType_doc[] = +const char KX_IpoActuator::SetType_doc[] = "setType(mode)\n" "\t - mode: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n" "\tSet the operation mode of the actuator.\n"; @@ -652,7 +652,7 @@ PyObject* KX_IpoActuator::PySetType(PyObject* self, Py_Return; } /* 9. getType: */ -char KX_IpoActuator::GetType_doc[] = +const char KX_IpoActuator::GetType_doc[] = "getType()\n" "\tReturns the operation mode of the actuator.\n"; PyObject* KX_IpoActuator::PyGetType(PyObject* self) { @@ -660,7 +660,7 @@ PyObject* KX_IpoActuator::PyGetType(PyObject* self) { } /* 10. setForceIpoActsLocal: */ -char KX_IpoActuator::SetForceIpoActsLocal_doc[] = +const char KX_IpoActuator::SetForceIpoActsLocal_doc[] = "setForceIpoActsLocal(local?)\n" "\t - local? : Apply the ipo-as-force in the object's local\n" "\t coordinates? (KX_TRUE, KX_FALSE)\n" @@ -680,7 +680,7 @@ PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* self, Py_Return; } /* 11. getForceIpoActsLocal: */ -char KX_IpoActuator::GetForceIpoActsLocal_doc[] = +const char KX_IpoActuator::GetForceIpoActsLocal_doc[] = "getForceIpoActsLocal()\n" "\tReturn whether to apply the force in the object's local\n" "\tcoordinates rather than the world global coordinates.\n"; diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 6f76448707c..c2e4430d1bc 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -338,7 +338,7 @@ PyObject* KX_MouseFocusSensor::_getattr(const STR_String& attr) { } -char KX_MouseFocusSensor::GetHitObject_doc[] = +const char KX_MouseFocusSensor::GetHitObject_doc[] = "getHitObject()\n" "\tReturns the name of the object that was hit by this ray.\n"; PyObject* KX_MouseFocusSensor::PyGetHitObject(PyObject* self, @@ -353,7 +353,7 @@ PyObject* KX_MouseFocusSensor::PyGetHitObject(PyObject* self, } -char KX_MouseFocusSensor::GetHitPosition_doc[] = +const char KX_MouseFocusSensor::GetHitPosition_doc[] = "getHitPosition()\n" "\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n"; PyObject* KX_MouseFocusSensor::PyGetHitPosition(PyObject* self, @@ -373,7 +373,7 @@ PyObject* KX_MouseFocusSensor::PyGetHitPosition(PyObject* self, } -char KX_MouseFocusSensor::GetRayDirection_doc[] = +const char KX_MouseFocusSensor::GetRayDirection_doc[] = "getRayDirection()\n" "\tReturns the direction from the ray (in worldcoordinates) .\n"; PyObject* KX_MouseFocusSensor::PyGetRayDirection(PyObject* self, @@ -394,7 +394,7 @@ PyObject* KX_MouseFocusSensor::PyGetRayDirection(PyObject* self, } -char KX_MouseFocusSensor::GetHitNormal_doc[] = +const char KX_MouseFocusSensor::GetHitNormal_doc[] = "getHitNormal()\n" "\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n"; PyObject* KX_MouseFocusSensor::PyGetHitNormal(PyObject* self, @@ -415,7 +415,7 @@ PyObject* KX_MouseFocusSensor::PyGetHitNormal(PyObject* self, /* getRayTarget */ -char KX_MouseFocusSensor::GetRayTarget_doc[] = +const char KX_MouseFocusSensor::GetRayTarget_doc[] = "getRayTarget()\n" "\tReturns the target of the ray that seeks the focus object,\n" "\tin worldcoordinates."; @@ -432,7 +432,7 @@ PyObject* KX_MouseFocusSensor::PyGetRayTarget(PyObject* self, } /* getRayTarget */ -char KX_MouseFocusSensor::GetRaySource_doc[] = +const char KX_MouseFocusSensor::GetRaySource_doc[] = "getRaySource()\n" "\tReturns the source of the ray that seeks the focus object,\n" "\tin worldcoordinates."; diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 3ca121f63f8..2dc2702ac27 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -176,7 +176,7 @@ PyObject* KX_ParentActuator::_getattr(const STR_String& attr) { } /* 1. setObject */ -char KX_ParentActuator::SetObject_doc[] = +const char KX_ParentActuator::SetObject_doc[] = "setObject(object)\n" "\t- object: KX_GameObject, string or None\n" "\tSet the object to set as parent.\n"; @@ -199,7 +199,7 @@ PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* value) { /* 2. getObject */ /* get obj ---------------------------------------------------------- */ -char KX_ParentActuator::GetObject_doc[] = +const char KX_ParentActuator::GetObject_doc[] = "getObject(name_only = 1)\n" "name_only - optional arg, when true will return the KX_GameObject rather then its name\n" "\tReturns the object that is set to.\n"; diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index d371626b597..9a75e58c8ca 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -234,7 +234,7 @@ PyObject* KX_RadarSensor::_getattr(const STR_String& attr) { } /* getConeOrigin */ -char KX_RadarSensor::GetConeOrigin_doc[] = +const char KX_RadarSensor::GetConeOrigin_doc[] = "getConeOrigin()\n" "\tReturns the origin of the cone with which to test. The origin\n" "\tis in the middle of the cone."; @@ -251,7 +251,7 @@ PyObject* KX_RadarSensor::PyGetConeOrigin(PyObject* self, } /* getConeOrigin */ -char KX_RadarSensor::GetConeTarget_doc[] = +const char KX_RadarSensor::GetConeTarget_doc[] = "getConeTarget()\n" "\tReturns the center of the bottom face of the cone with which to test.\n"; PyObject* KX_RadarSensor::PyGetConeTarget(PyObject* self, @@ -267,7 +267,7 @@ PyObject* KX_RadarSensor::PyGetConeTarget(PyObject* self, } /* getConeOrigin */ -char KX_RadarSensor::GetConeHeight_doc[] = +const char KX_RadarSensor::GetConeHeight_doc[] = "getConeHeight()\n" "\tReturns the height of the cone with which to test.\n"; PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self, diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 8dc22fe13c1..64897bd62ba 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -342,7 +342,7 @@ PyMethodDef KX_RaySensor::Methods[] = { {NULL,NULL} //Sentinel }; -char KX_RaySensor::GetHitObject_doc[] = +const char KX_RaySensor::GetHitObject_doc[] = "getHitObject()\n" "\tReturns the name of the object that was hit by this ray.\n"; PyObject* KX_RaySensor::PyGetHitObject(PyObject* self, @@ -357,7 +357,7 @@ PyObject* KX_RaySensor::PyGetHitObject(PyObject* self, } -char KX_RaySensor::GetHitPosition_doc[] = +const char KX_RaySensor::GetHitPosition_doc[] = "getHitPosition()\n" "\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n"; PyObject* KX_RaySensor::PyGetHitPosition(PyObject* self, @@ -377,7 +377,7 @@ PyObject* KX_RaySensor::PyGetHitPosition(PyObject* self, } -char KX_RaySensor::GetRayDirection_doc[] = +const char KX_RaySensor::GetRayDirection_doc[] = "getRayDirection()\n" "\tReturns the direction from the ray (in worldcoordinates) .\n"; PyObject* KX_RaySensor::PyGetRayDirection(PyObject* self, @@ -397,7 +397,7 @@ PyObject* KX_RaySensor::PyGetRayDirection(PyObject* self, } -char KX_RaySensor::GetHitNormal_doc[] = +const char KX_RaySensor::GetHitNormal_doc[] = "getHitNormal()\n" "\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n"; PyObject* KX_RaySensor::PyGetHitNormal(PyObject* self, diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index c4c190e9fa1..ba4a23eb427 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -209,7 +209,7 @@ PyObject* KX_SCA_AddObjectActuator::_getattr(const STR_String& attr) } /* 1. setObject */ -char KX_SCA_AddObjectActuator::SetObject_doc[] = +const char KX_SCA_AddObjectActuator::SetObject_doc[] = "setObject(object)\n" "\t- object: KX_GameObject, string or None\n" "\tSets the object that will be added. There has to be an object\n" @@ -234,7 +234,7 @@ PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self, PyObject* value) /* 2. setTime */ -char KX_SCA_AddObjectActuator::SetTime_doc[] = +const char KX_SCA_AddObjectActuator::SetTime_doc[] = "setTime(duration)\n" "\t- duration: integer\n" "\tSets the lifetime of the object that will be added, in frames. \n" @@ -258,7 +258,7 @@ PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self, PyObject* value) /* 3. getTime */ -char KX_SCA_AddObjectActuator::GetTime_doc[] = +const char KX_SCA_AddObjectActuator::GetTime_doc[] = "GetTime()\n" "\tReturns the lifetime of the object that will be added.\n"; @@ -270,7 +270,7 @@ PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self) /* 4. getObject */ -char KX_SCA_AddObjectActuator::GetObject_doc[] = +const char KX_SCA_AddObjectActuator::GetObject_doc[] = "getObject(name_only = 1)\n" "name_only - optional arg, when true will return the KX_GameObject rather then its name\n" "\tReturns the name of the object that will be added.\n"; @@ -292,7 +292,7 @@ PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* self, PyObject* args) /* 5. getLinearVelocity */ -char KX_SCA_AddObjectActuator::GetLinearVelocity_doc[] = +const char KX_SCA_AddObjectActuator::GetLinearVelocity_doc[] = "GetLinearVelocity()\n" "\tReturns the linear velocity that will be assigned to \n" "\tthe created object.\n"; @@ -311,7 +311,7 @@ PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self) /* 6. setLinearVelocity */ -char KX_SCA_AddObjectActuator::SetLinearVelocity_doc[] = +const char KX_SCA_AddObjectActuator::SetLinearVelocity_doc[] = "setLinearVelocity(vx, vy, vz)\n" "\t- vx: float\n" "\t- vy: float\n" @@ -331,7 +331,7 @@ PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, PyObject } /* 7. getAngularVelocity */ -char KX_SCA_AddObjectActuator::GetAngularVelocity_doc[] = +const char KX_SCA_AddObjectActuator::GetAngularVelocity_doc[] = "GetAngularVelocity()\n" "\tReturns the angular velocity that will be assigned to \n" "\tthe created object.\n"; @@ -350,7 +350,7 @@ PyObject* KX_SCA_AddObjectActuator::PyGetAngularVelocity(PyObject* self) /* 8. setAngularVelocity */ -char KX_SCA_AddObjectActuator::SetAngularVelocity_doc[] = +const char KX_SCA_AddObjectActuator::SetAngularVelocity_doc[] = "setAngularVelocity(vx, vy, vz)\n" "\t- vx: float\n" "\t- vy: float\n" @@ -406,7 +406,7 @@ PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self) /* 7. GetLastCreatedObject */ -char KX_SCA_AddObjectActuator::GetLastCreatedObject_doc[] = +const char KX_SCA_AddObjectActuator::GetLastCreatedObject_doc[] = "getLastCreatedObject()\n" "\tReturn the last created object. \n"; diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index e1f11732085..a5cd3f85f85 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -99,7 +99,7 @@ PyObject* KX_SCA_ReplaceMeshActuator::_getattr(const STR_String& attr) /* 1. setMesh */ -char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] = +const char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] = "setMesh(name)\n" "\t- name: string or None\n" "\tSet the mesh that will be substituted for the current one.\n"; diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index d6164dc812a..7d0181b162f 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -278,7 +278,7 @@ PyObject* KX_SceneActuator::_getattr(const STR_String& attr) /* 2. setUseRestart--------------------------------------------------------- */ -char KX_SceneActuator::SetUseRestart_doc[] = +const char KX_SceneActuator::SetUseRestart_doc[] = "setUseRestart(flag)\n" "\t- flag: 0 or 1.\n" "\tSet flag to 1 to restart the scene.\n" ; @@ -301,7 +301,7 @@ PyObject* KX_SceneActuator::PySetUseRestart(PyObject* self, /* 3. getUseRestart: */ -char KX_SceneActuator::GetUseRestart_doc[] = +const char KX_SceneActuator::GetUseRestart_doc[] = "getUseRestart()\n" "\tReturn whether the scene will be restarted.\n" ; PyObject* KX_SceneActuator::PyGetUseRestart(PyObject* self, @@ -314,7 +314,7 @@ PyObject* KX_SceneActuator::PyGetUseRestart(PyObject* self, /* 4. set scene------------------------------------------------------------- */ -char KX_SceneActuator::SetScene_doc[] = +const char KX_SceneActuator::SetScene_doc[] = "setScene(scene)\n" "\t- scene: string\n" "\tSet the name of scene the actuator will switch to.\n" ; @@ -339,7 +339,7 @@ PyObject* KX_SceneActuator::PySetScene(PyObject* self, /* 5. getScene: */ -char KX_SceneActuator::GetScene_doc[] = +const char KX_SceneActuator::GetScene_doc[] = "getScene()\n" "\tReturn the name of the scene the actuator wants to switch to.\n" ; PyObject* KX_SceneActuator::PyGetScene(PyObject* self, @@ -352,7 +352,7 @@ PyObject* KX_SceneActuator::PyGetScene(PyObject* self, /* 6. set camera------------------------------------------------------------ */ -char KX_SceneActuator::SetCamera_doc[] = +const char KX_SceneActuator::SetCamera_doc[] = "setCamera(camera)\n" "\t- camera: string\n" "\tSet the camera to switch to.\n" ; @@ -394,7 +394,7 @@ PyObject* KX_SceneActuator::PySetCamera(PyObject* self, /* 7. getCamera: */ -char KX_SceneActuator::GetCamera_doc[] = +const char KX_SceneActuator::GetCamera_doc[] = "getCamera()\n" "\tReturn the name of the camera to switch to.\n" ; PyObject* KX_SceneActuator::PyGetCamera(PyObject* self, diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index 95a79f0c480..be874c97b3c 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -157,7 +157,7 @@ KX_StateActuator::_getattr( /* set operation ---------------------------------------------------------- */ -char +const char KX_StateActuator::SetOperation_doc[] = "setOperation(op)\n" "\t - op : bit operation (0=Copy, 1=Set, 2=Clear, 3=Negate)" @@ -180,7 +180,7 @@ KX_StateActuator::PySetOperation(PyObject* self, } /* set mask ---------------------------------------------------------- */ -char +const char KX_StateActuator::SetMask_doc[] = "setMask(mask)\n" "\t - mask : bits that will be modified" diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 60e1d87d318..ad0b7428a24 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -257,7 +257,7 @@ PyObject* KX_TouchSensor::_getattr(const STR_String& attr) { /* Python API */ /* 1. setProperty */ -char KX_TouchSensor::SetProperty_doc[] = +const char KX_TouchSensor::SetProperty_doc[] = "setProperty(name)\n" "\t- name: string\n" "\tSet the property or material to collide with. Use\n" @@ -283,7 +283,7 @@ PyObject* KX_TouchSensor::PySetProperty(PyObject* self, Py_Return; } /* 2. getProperty */ -char KX_TouchSensor::GetProperty_doc[] = +const char KX_TouchSensor::GetProperty_doc[] = "getProperty(name)\n" "\tReturns the property or material to collide with. Use\n" "\tgetTouchMaterial() to find out whether this sensor\n" @@ -294,7 +294,7 @@ PyObject* KX_TouchSensor::PyGetProperty(PyObject* self, return PyString_FromString(m_touchedpropname); } -char KX_TouchSensor::GetHitObject_doc[] = +const char KX_TouchSensor::GetHitObject_doc[] = "getHitObject()\n" ; PyObject* KX_TouchSensor::PyGetHitObject(PyObject* self, @@ -310,7 +310,7 @@ PyObject* KX_TouchSensor::PyGetHitObject(PyObject* self, Py_Return; } -char KX_TouchSensor::GetHitObjectList_doc[] = +const char KX_TouchSensor::GetHitObjectList_doc[] = "getHitObjectList()\n" "\tReturn a list of the objects this object collided with,\n" "\tbut only those matching the property/material condition.\n"; @@ -364,7 +364,7 @@ PyObject* KX_TouchSensor::PyGetHitObjectList(PyObject* self, } /* 5. getTouchMaterial */ -char KX_TouchSensor::GetTouchMaterial_doc[] = +const char KX_TouchSensor::GetTouchMaterial_doc[] = "getTouchMaterial()\n" "\tReturns KX_TRUE if this sensor looks for a specific material,\n" "\tKX_FALSE if it looks for a specific property.\n" ; @@ -376,7 +376,7 @@ PyObject* KX_TouchSensor::PyGetTouchMaterial(PyObject* self, } /* 6. setTouchMaterial */ -char KX_TouchSensor::SetTouchMaterial_doc[] = +const char KX_TouchSensor::SetTouchMaterial_doc[] = "setTouchMaterial(flag)\n" "\t- flag: KX_TRUE or KX_FALSE.\n" "\tSet flag to KX_TRUE to switch on positive pulse mode,\n" diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 8b09cd4e953..42f11adf004 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -475,7 +475,7 @@ PyObject* KX_TrackToActuator::_getattr(const STR_String& attr) /* 1. setObject */ -char KX_TrackToActuator::SetObject_doc[] = +const char KX_TrackToActuator::SetObject_doc[] = "setObject(object)\n" "\t- object: KX_GameObject, string or None\n" "\tSet the object to track with the parent of this actuator.\n"; @@ -499,7 +499,7 @@ PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* value) /* 2. getObject */ -char KX_TrackToActuator::GetObject_doc[] = +const char KX_TrackToActuator::GetObject_doc[] = "getObject(name_only = 1)\n" "name_only - optional arg, when true will return the KX_GameObject rather then its name\n" "\tReturns the object to track with the parent of this actuator\n"; @@ -521,7 +521,7 @@ PyObject* KX_TrackToActuator::PyGetObject(PyObject* self, PyObject* args) /* 3. setTime */ -char KX_TrackToActuator::SetTime_doc[] = +const char KX_TrackToActuator::SetTime_doc[] = "setTime(time)\n" "\t- time: integer\n" "\tSet the time in frames with which to delay the tracking motion.\n"; @@ -542,7 +542,7 @@ PyObject* KX_TrackToActuator::PySetTime(PyObject* self, PyObject* args, PyObject /* 4.getTime */ -char KX_TrackToActuator::GetTime_doc[] = +const char KX_TrackToActuator::GetTime_doc[] = "getTime()\n" "\t- time: integer\n" "\tReturn the time in frames with which the tracking motion is delayed.\n"; @@ -554,7 +554,7 @@ PyObject* KX_TrackToActuator::PyGetTime(PyObject* self, PyObject* args, PyObject /* 5. getUse3D */ -char KX_TrackToActuator::GetUse3D_doc[] = +const char KX_TrackToActuator::GetUse3D_doc[] = "getUse3D()\n" "\tReturns 1 if the motion is allowed to extend in the z-direction.\n"; PyObject* KX_TrackToActuator::PyGetUse3D(PyObject* self, PyObject* args, PyObject* kwds) @@ -565,7 +565,7 @@ PyObject* KX_TrackToActuator::PyGetUse3D(PyObject* self, PyObject* args, PyObjec /* 6. setUse3D */ -char KX_TrackToActuator::SetUse3D_doc[] = +const char KX_TrackToActuator::SetUse3D_doc[] = "setUse3D(value)\n" "\t- value: 0 or 1\n" "\tSet to 1 to allow the tracking motion to extend in the z-direction,\n" diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index e60a8d7c099..7fe9d81e2e1 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -137,7 +137,7 @@ KX_VisibilityActuator::_getattr( /* set visibility ---------------------------------------------------------- */ -char +const char KX_VisibilityActuator::SetVisible_doc[] = "setVisible(visible?)\n" "\t - visible? : Make the object visible? (KX_TRUE, KX_FALSE)" diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index ef206332057..6e5553d4781 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -85,7 +85,7 @@ RAS_2DFilterManager::~RAS_2DFilterManager() FreeTextures(); } -unsigned int RAS_2DFilterManager::CreateShaderProgram(char* shadersource) +unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource) { GLuint program = 0; GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index f5998e1f093..c16bd41dd0e 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -33,7 +33,7 @@ class RAS_2DFilterManager { private: - unsigned int CreateShaderProgram(char* shadersource); + unsigned int CreateShaderProgram(const char* shadersource); unsigned int CreateShaderProgram(int filtermode); void AnalyseShader(int passindex, vector& propNames); void StartShaderProgram(int passindex); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h index 33c4b3faab0..81821639489 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_BLUR2DFILTER #define __RAS_BLUR2DFILTER -char * BlurFragmentShader=STRINGIFY( +const char * BlurFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h index c41e5ac06af..2ee75396f42 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_DILATION2DFILTER #define __RAS_DILATION2DFILTER -char * DilationFragmentShader=STRINGIFY( +const char * DilationFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h index 2bb357c958a..d3ce829bab0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_EROSION2DFILTER #define __RAS_EROSION2DFILTER -char * ErosionFragmentShader=STRINGIFY( +const char * ErosionFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h index 7324edd4e92..ae51308e9a4 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_GRAYSCALE2DFILTER #define __RAS_GRAYSCALE2DFILTER -char * GrayScaleFragmentShader=STRINGIFY( +const char * GrayScaleFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; void main(void) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h index 5d90fe3475b..f723f619f68 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_INVERT2DFILTER #define __RAS_INVERT2DFILTER -char * InvertFragmentShader=STRINGIFY( +const char * InvertFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; void main(void) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h index cbe926976df..bfbb40b2fc9 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_LAPLACION2DFILTER #define __RAS_LAPLACION2DFILTER -char * LaplacionFragmentShader=STRINGIFY( +const char * LaplacionFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h index 7cd1082e5e3..0cbf8a7a802 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_PREWITT2DFILTER #define __RAS_PREWITT2DFILTER -char * PrewittFragmentShader=STRINGIFY( +const char * PrewittFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h index d1c16f39823..ca431af4cd7 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_SEPIA2DFILTER #define __RAS_SEPIA2DFILTER -char * SepiaFragmentShader=STRINGIFY( +const char * SepiaFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; void main(void) diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h index 14e0be6df9d..5a9661e2617 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_SHARPEN2DFILTER #define __RAS_SHARPEN2DFILTER -char * SharpenFragmentShader=STRINGIFY( +const char * SharpenFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h index 40c17c285ce..142e4f0e3d4 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h @@ -28,7 +28,7 @@ #ifndef __RAS_SOBEL2DFILTER #define __RAS_SOBEL2DFILTER -char * SobelFragmentShader=STRINGIFY( +const char * SobelFragmentShader=STRINGIFY( uniform sampler2D bgl_RenderedTexture; uniform vec2 bgl_TextureCoordinateOffset[9]; -- cgit v1.2.3 From 22a50402efc1fd9b725d7760c90b343e63191ee4 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 20 Sep 2008 21:33:54 +0000 Subject: BGE patch: allow Bullet mesh shape sharing for objects copied with ALT-D. --- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 12 ++++- .../Physics/Bullet/CcdPhysicsController.cpp | 58 ++++++++++++++++------ .../Physics/Bullet/CcdPhysicsController.h | 37 +++++++------- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 2 +- 4 files changed, 73 insertions(+), 36 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index b3f24d97281..6f5f9e22506 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -767,7 +767,17 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, { if (!ci.m_mass) { - shapeInfo->SetMesh(meshobj, false); + // mesh shapes can be shared, check first if we already have a shape on that mesh + class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, false); + if (sharedShapeInfo != NULL) + { + delete shapeInfo; + shapeInfo = sharedShapeInfo; + shapeInfo->AddRef(); + } else + { + shapeInfo->SetMesh(meshobj, false); + } bm = shapeInfo->CreateBulletShape(); //no moving concave meshes, so don't bother calculating inertia //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index b1b97b5370f..1ec555f653d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -902,9 +902,25 @@ void DefaultMotionState::calculateWorldTransformations() } // Shape constructor +std::map CcdShapeConstructionInfo::m_meshShapeMap; + +CcdShapeConstructionInfo* CcdShapeConstructionInfo::FindMesh(RAS_MeshObject* mesh, bool polytope) +{ + if (polytope) + // not yet supported + return NULL; + + std::map::const_iterator mit = m_meshShapeMap.find(mesh); + if (mit != m_meshShapeMap.end()) + return mit->second; + return NULL; +} + bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) { // assume no shape information + // no support for dynamic change of shape yet + assert(m_meshObject == NULL); m_shapeType = PHY_SHAPE_NONE; m_vertexArray.clear(); m_polygonIndexArray.clear(); @@ -1006,6 +1022,11 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) return false; } m_meshObject = meshobj; + if (!polytope) + { + // triangle shape can be shared, store the mesh object in the map + m_meshShapeMap.insert(std::pair(meshobj,this)); + } return true; } @@ -1066,16 +1087,18 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() break; case PHY_SHAPE_COMPOUND: - if (m_nextShape) + if (m_shapeArray.size() > 0) { compoundShape = new btCompoundShape(); - for (nextShapeInfo=m_nextShape; nextShapeInfo; nextShapeInfo = nextShapeInfo->m_nextShape) + for (std::vector::iterator sit = m_shapeArray.begin(); + sit != m_shapeArray.end(); + sit++) { - collisionShape = nextShapeInfo->CreateBulletShape(); + collisionShape = (*sit)->CreateBulletShape(); if (collisionShape) { - collisionShape->setLocalScaling(nextShapeInfo->m_childScale); - compoundShape->addChildShape(nextShapeInfo->m_childTrans, collisionShape); + collisionShape->setLocalScaling((*sit)->m_childScale); + compoundShape->addChildShape((*sit)->m_childTrans, collisionShape); } } collisionShape = compoundShape; @@ -1086,28 +1109,31 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() void CcdShapeConstructionInfo::AddShape(CcdShapeConstructionInfo* shapeInfo) { - CcdShapeConstructionInfo* nextShape = this; - while (nextShape->m_nextShape != NULL) - nextShape = nextShape->m_nextShape; - nextShape->m_nextShape = shapeInfo; + m_shapeArray.push_back(shapeInfo); } CcdShapeConstructionInfo::~CcdShapeConstructionInfo() { - CcdShapeConstructionInfo* childShape = m_nextShape; - - while (childShape) + for (std::vector::iterator sit = m_shapeArray.begin(); + sit != m_shapeArray.end(); + sit++) { - CcdShapeConstructionInfo* nextShape = childShape->m_nextShape; - childShape->m_nextShape = NULL; - childShape->Release(); - childShape = nextShape; + (*sit)->Release(); } + m_shapeArray.clear(); if (m_unscaledShape) { DeleteBulletShape(m_unscaledShape); } m_vertexArray.clear(); + if (m_shapeType == PHY_SHAPE_MESH && m_meshObject != NULL) + { + std::map::iterator mit = m_meshShapeMap.find(m_meshObject); + if (mit != m_meshShapeMap.end() && mit->second == this) + { + m_meshShapeMap.erase(mit); + } + } } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 355c1d608b1..af146413c91 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -18,6 +18,7 @@ subject to the following restrictions: #define BULLET2_PHYSICSCONTROLLER_H #include +#include #include "PHY_IPhysicsController.h" @@ -42,15 +43,17 @@ class btCollisionShape; class CcdShapeConstructionInfo { public: + static CcdShapeConstructionInfo* FindMesh(RAS_MeshObject* mesh, bool polytope); + CcdShapeConstructionInfo() : m_shapeType(PHY_SHAPE_NONE), m_radius(1.0), m_height(1.0), m_halfExtend(0.f,0.f,0.f), m_childScale(1.0f,1.0f,1.0f), - m_nextShape(NULL), - m_unscaledShape(NULL), - m_refCount(1) + m_refCount(1), + m_meshObject(NULL), + m_unscaledShape(NULL) { m_childTrans.setIdentity(); } @@ -77,22 +80,19 @@ public: { return m_unscaledShape; } - CcdShapeConstructionInfo* GetNextShape() - { - return m_nextShape; - } CcdShapeConstructionInfo* GetChildShape(int i) { - CcdShapeConstructionInfo* shape = m_nextShape; - while (i > 0 && shape != NULL) - { - shape = shape->m_nextShape; - i--; - } - return shape; + if (i < 0 || i >= m_shapeArray.size()) + return NULL; + + return m_shapeArray.at(i); } bool SetMesh(RAS_MeshObject* mesh, bool polytope); + RAS_MeshObject* GetMesh(void) + { + return m_meshObject; + } btCollisionShape* CreateBulletShape(); @@ -109,14 +109,15 @@ public: std::vector m_polygonIndexArray; // Contains the array of polygon index in the // original mesh that correspond to shape triangles. // only set for concave mesh shape. - const RAS_MeshObject* m_meshObject; // Keep a pointer to the original mesh protected: - CcdShapeConstructionInfo* m_nextShape; // for compound shape - btBvhTriangleMeshShape* m_unscaledShape;// holds the shared unscale BVH mesh shape, - // the actual shape is of type btScaledBvhTriangleMeshShape + static std::map m_meshShapeMap; int m_refCount; // this class is shared between replicas // keep track of users so that we can release it + RAS_MeshObject* m_meshObject; // Keep a pointer to the original mesh + btBvhTriangleMeshShape* m_unscaledShape;// holds the shared unscale BVH mesh shape, + // the actual shape is of type btScaledBvhTriangleMeshShape + std::vector m_shapeArray; // for compound shapes }; struct CcdConstructionInfo diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 96caf885e7c..68b3df1695c 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -865,7 +865,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac if (shape == rayCallback.m_hitTriangleShape && rayCallback.m_hitTriangleIndex < shapeInfo->m_polygonIndexArray.size()) { - result.m_meshObject = shapeInfo->m_meshObject; + result.m_meshObject = shapeInfo->GetMesh(); result.m_polygon = shapeInfo->m_polygonIndexArray.at(rayCallback.m_hitTriangleIndex); // Bullet returns the normal from "outside". -- cgit v1.2.3 From a72b65011e826342eaf9620413714fbbf1a1d872 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 20 Sep 2008 22:19:59 +0000 Subject: BGE bug fix: dupligroup scale not correctly applied to bullet shape. --- source/gameengine/Ketsji/KX_GameObject.cpp | 10 ++++++++++ source/gameengine/Ketsji/KX_Scene.cpp | 23 ----------------------- 2 files changed, 10 insertions(+), 23 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 252741754ec..15055a9cf93 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -823,7 +823,17 @@ void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale) void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale) { if (GetSGNode()) + { GetSGNode()->RelativeScale(scale); + if (m_pPhysicsController1 && (!GetSGNode()->GetSGParent())) + { + // see note above + // we can use the local scale: it's the same thing for a root object + // and the world scale is not yet updated + MT_Vector3 newscale = GetSGNode()->GetLocalScale(); + m_pPhysicsController1->setScaling(newscale); + } + } } void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 72875bbc039..04db96c298c 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -694,17 +694,6 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) newscale*(groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldPosition()); replica->NodeSetLocalPosition(newpos); - if (replica->GetPhysicsController()) - { - // not required, already done in NodeSetLocalOrientation.. - //replica->GetPhysicsController()->setPosition(newpos); - //replica->GetPhysicsController()->setOrientation(newori.getRotation()); - // Scaling has been set relatively hereabove, this does not - // set the scaling of the controller. I don't know why it's just the - // relative scale and not the full scale that has to be put here... - replica->GetPhysicsController()->setScaling(newscale); - } - replica->GetSGNode()->UpdateWorldData(0); replica->GetSGNode()->SetBBox(gameobj->GetSGNode()->BBox()); replica->GetSGNode()->SetRadius(gameobj->GetSGNode()->Radius()); @@ -829,18 +818,6 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject, // set the replica's relative scale with the rootnode's scale replica->NodeSetRelativeScale(newscale); - if (replica->GetPhysicsController()) - { - // not needed, already done in NodeSetLocalPosition() - //replica->GetPhysicsController()->setPosition(newpos); - //replica->GetPhysicsController()->setOrientation(newori.getRotation()); - replica->GetPhysicsController()->setScaling(newscale); - } - - // here we want to set the relative scale: the rootnode's scale will override all other - // scalings, so lets better prepare for it - - replica->GetSGNode()->UpdateWorldData(0); replica->GetSGNode()->SetBBox(originalobj->GetSGNode()->BBox()); replica->GetSGNode()->SetRadius(originalobj->GetSGNode()->Radius()); -- cgit v1.2.3 From 2064f5542ae8edf0c52bcc104f10696f5b6e3659 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Sep 2008 04:39:40 +0000 Subject: set the visibility state based on the objects render option in the outliner. - saves adding UV's to faces just to set the invisibility option or having an logic bricks to set the visibility state. --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index ae9b8602500..daa67b147c3 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1601,6 +1601,8 @@ static KX_GameObject *gameobject_from_blenderobject( gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment()); gameobj->SetLayer(ob->lay); gameobj->SetBlenderObject(ob); + /* set the visibility state based on the objects render option in the outliner */ + if(ob->restrictflag & OB_RESTRICT_RENDER) gameobj->SetVisible(0, 0); } return gameobj; } -- cgit v1.2.3 From e11cd5a962803747ce3c0bddaef73a47d8938b63 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 21 Sep 2008 05:38:28 +0000 Subject: game engine now compiles with SDL disabled. CDROM and Joystick wont function in this case --- .../gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 54 ++++++++++++++++++---- .../gameengine/GameLogic/Joystick/SCA_Joystick.h | 10 ++-- .../GameLogic/Joystick/SCA_JoystickEvents.cpp | 3 +- .../GameLogic/Joystick/SCA_JoystickPrivate.h | 3 ++ .../gameengine/GameLogic/SCA_JoystickManager.cpp | 4 +- source/gameengine/GameLogic/SConscript | 7 ++- 6 files changed, 65 insertions(+), 16 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 06002060bf1..092956e6489 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -42,14 +42,18 @@ SCA_Joystick::SCA_Joystick(short int index) m_isinit(0), m_istrig(0) { +#ifndef DISABLE_SDL m_private = new PrivateData(); +#endif } SCA_Joystick::~SCA_Joystick() { +#ifndef DISABLE_SDL delete m_private; +#endif } SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX]; @@ -57,6 +61,9 @@ int SCA_Joystick::m_refCount = 0; SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) { +#ifdef DISABLE_SDL + return NULL; +#else if (joyindex < 0 || joyindex >= JOYINDEX_MAX) { echo("Error-invalid joystick index: " << joyindex); return NULL; @@ -81,12 +88,14 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) m_refCount++; } return m_instance[joyindex]; +#endif } void SCA_Joystick::ReleaseInstance() { if (--m_refCount == 0) { +#ifndef DISABLE_SDL int i; for (i=0; im_joystick, button)? result = true:result = false; m_istrig = result; return result; +#endif } bool SCA_Joystick::aButtonReleaseIsPositive(int button) { +#ifdef DISABLE_SDL + return false; +#else bool result; SDL_JoystickGetButton(m_private->m_joystick, button)? result = false : result = true; m_istrig = result; return result; +#endif } @@ -199,6 +218,9 @@ int SCA_Joystick::pGetHat(int direction) int SCA_Joystick::GetNumberOfAxes() { +#ifdef DISABLE_SDL + return -1; +#else int number; if(m_isinit){ if(m_private->m_joystick){ @@ -207,11 +229,15 @@ int SCA_Joystick::GetNumberOfAxes() } } return -1; +#endif } int SCA_Joystick::GetNumberOfButtons() { +#ifdef DISABLE_SDL + return -1; +#else int number; if(m_isinit){ if(m_private->m_joystick){ @@ -220,11 +246,15 @@ int SCA_Joystick::GetNumberOfButtons() } } return -1; +#endif } int SCA_Joystick::GetNumberOfHats() { +#ifdef DISABLE_SDL + return -1; +#else int number; if(m_isinit){ if(m_private->m_joystick){ @@ -233,10 +263,14 @@ int SCA_Joystick::GetNumberOfHats() } } return -1; +#endif } bool SCA_Joystick::CreateJoystickDevice(void) { +#ifdef DISABLE_SDL + return false; +#else if(m_isinit == false){ if (m_joyindex>=SDL_NumJoysticks()) { // don't print a message, because this is done anyway @@ -251,11 +285,13 @@ bool SCA_Joystick::CreateJoystickDevice(void) m_isinit = true; } return true; +#endif } void SCA_Joystick::DestroyJoystickDevice(void) { +#ifndef DISABLE_SDL if (m_isinit){ if(SDL_JoystickOpened(m_joyindex)){ echo("Closing-joystick " << m_joyindex); @@ -263,21 +299,21 @@ void SCA_Joystick::DestroyJoystickDevice(void) } m_isinit = false; } +#endif } int SCA_Joystick::Connected(void) { - if (m_isinit){ - if(SDL_JoystickOpened(m_joyindex)){ - return 1; - } - } - +#ifndef DISABLE_SDL + if (m_isinit && SDL_JoystickOpened(m_joyindex)) + return 1; +#endif return 0; } void SCA_Joystick::pFillAxes() { +#ifndef DISABLE_SDL if(GetNumberOfAxes() == 1){ m_axis10 = SDL_JoystickGetAxis(m_private->m_joystick, 0); m_axis11 = SDL_JoystickGetAxis(m_private->m_joystick, 1); @@ -287,18 +323,20 @@ void SCA_Joystick::pFillAxes() m_axis20 = SDL_JoystickGetAxis(m_private->m_joystick, 2); m_axis21 = SDL_JoystickGetAxis(m_private->m_joystick, 3); }else{ - m_axis10 = 0;m_axis11 = 0; - m_axis20 = 0;m_axis21 = 0; + m_axis10 = m_axis11 = m_axis20 = m_axis21 = 0; } +#endif } int SCA_Joystick::pGetAxis(int axisnum, int udlr) { +#ifndef DISABLE_SDL if(axisnum == 1 && udlr == 1)return m_axis10; //u/d if(axisnum == 1 && udlr == 0)return m_axis11; //l/r if(axisnum == 2 && udlr == 0)return m_axis20; //... if(axisnum == 2 && udlr == 1)return m_axis21; +#endif return 0; } diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index bcbb43241c2..ea7ecf7cefe 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -45,9 +45,9 @@ class SCA_Joystick static int m_refCount; class PrivateData; - +#ifndef DISABLE_SDL PrivateData *m_private; - +#endif int m_joyindex; /* @@ -104,6 +104,7 @@ class SCA_Joystick /* is triggered */ bool m_istrig; +#ifndef DISABLE_SDL /* * event callbacks */ @@ -113,7 +114,7 @@ class SCA_Joystick void OnButtonDown(SDL_Event *sdl_event); void OnNothing(SDL_Event *sdl_event); void OnBallMotion(SDL_Event *sdl_event){} - +#endif /* * Open the joystick */ @@ -226,8 +227,9 @@ public: */ int Connected(void); }; - +#ifndef DISABLE_SDL void Joystick_HandleEvents( void ); +#endif #endif diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp index 1e064f55397..0e2078265c9 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp @@ -29,7 +29,7 @@ #include "SCA_JoystickPrivate.h" - +#ifndef DISABLE_SDL void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event) { pFillAxes(); @@ -102,3 +102,4 @@ void SCA_Joystick::HandleEvents(void) } } } +#endif diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h index bb6bfe2d4cc..acbbcae9cd7 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h @@ -29,6 +29,7 @@ #define __SCA_JOYSTICKPRIVATE_H__ #include "SCA_Joystick.h" +#ifndef DISABLE_SDL class SCA_Joystick::PrivateData { public: @@ -43,3 +44,5 @@ public: } }; #endif + +#endif diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp index a86770a6e0a..d874b5b013a 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp @@ -63,9 +63,9 @@ void SCA_JoystickManager::NextFrame(double curtime,double deltatime) } else { set::iterator it; - +#ifndef DISABLE_SDL SCA_Joystick::HandleEvents(); /* Handle all SDL Joystick events */ - +#endif for (it = m_sensors.begin(); it != m_sensors.end(); it++) { SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it); diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index 1ca884f6dec..fa5a3123215 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -10,4 +10,9 @@ incs += ' #/source/gameengine/Rasterizer' incs += ' ' + env['BF_PYTHON_INC'] incs += ' ' + env['BF_SDL_INC'] -env.BlenderLib ( 'bf_logic', sources, Split(incs), [], libtype=['game','player'], priority=[30, 110] ) +defs = '' + +if not env['WITH_BF_SDL']: + defs += ' DISABLE_SDL' + +env.BlenderLib ( 'bf_logic', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[30, 110] ) -- cgit v1.2.3 From 1c29d02305685a942742846c757775800202a52a Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 21 Sep 2008 15:17:50 +0000 Subject: BGE real-time soft bodies, step 2 / 3: create a btSoftBody. Next step is hooking up / deform graphics mesh and choose collision shape. Note: feature is still disabled. --- .../Converter/BL_BlenderDataConversion.cpp | 1 + source/gameengine/Ketsji/KX_ConvertPhysicsObject.h | 1 + .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 9 ++-- .../Physics/Bullet/CcdPhysicsController.cpp | 61 +++++++++++++++++++++- .../Physics/Bullet/CcdPhysicsController.h | 2 + .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 33 +++++++++--- .../Physics/Bullet/CcdPhysicsEnvironment.h | 5 +- 7 files changed, 97 insertions(+), 15 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index daa67b147c3..9b9d5c95de9 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1318,6 +1318,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, // ACTOR is now a separate feature objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0; objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0; + objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0; objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h index 248d2f49b0b..2b6c2535878 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h @@ -75,6 +75,7 @@ struct KX_CBounds struct KX_ObjectProperties { bool m_dyna; + bool m_softbody; double m_radius; bool m_angular_rigidbody; bool m_in_active_layer; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 6f5f9e22506..46b53d07efc 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -917,6 +917,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter); ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody; + ci.m_bSoft = objprop->m_softbody; MT_Vector3 scaling = gameobj->NodeGetWorldScaling(); ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]); KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); @@ -933,10 +934,12 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, gameobj->SetPhysicsController(physicscontroller,isbulletdyna); physicscontroller->setNewClientInfo(gameobj->getClientInfo()); - btRigidBody* rbody = physicscontroller->GetRigidBody(); + { + btRigidBody* rbody = physicscontroller->GetRigidBody(); - if (objprop->m_disableSleeping) - rbody->setActivationState(DISABLE_DEACTIVATION); + if (rbody && objprop->m_disableSleeping) + rbody->setActivationState(DISABLE_DEACTIVATION); + } //Now done directly in ci.m_collisionFlags so that it propagates to replica //if (objprop->m_ghost) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 1ec555f653d..41ae5e38309 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -133,6 +133,13 @@ btSoftBody* CcdPhysicsController::GetSoftBody() return btSoftBody::upcast(m_object); } +#include "BulletSoftBody/btSoftBodyHelpers.h" + +btVector3 pts[3] = {btVector3(0,0,0), +btVector3(0,1,0), +btVector3(1,1,0)}; +int triangles[3] = {0,1,2}; +btSoftBodyWorldInfo sbi; void CcdPhysicsController::CreateRigidbody() { @@ -143,14 +150,64 @@ void CcdPhysicsController::CreateRigidbody() ///either create a btCollisionObject, btRigidBody or btSoftBody //create a collision object - if (0)//m_cci.m_mass==0.f) + + //disable soft body until first sneak preview is ready + if (0)//m_cci.m_bSoft) { btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); rbci.m_linearDamping = m_cci.m_linearDamping; rbci.m_angularDamping = m_cci.m_angularDamping; rbci.m_friction = m_cci.m_friction; rbci.m_restitution = m_cci.m_restitution; - m_object = new btCollisionObject(); + + + sbi.m_broadphase = this->m_cci.m_physicsEnv->getBroadphase(); + sbi.m_dispatcher = (btCollisionDispatcher*) m_cci.m_physicsEnv->getDispatcher(); + + int nodecount = 0; + + + int numtriangles = 1; + + btVector3 p = trans.getOrigin(); + btScalar h = 1.f; + + PHY__Vector3 grav; + m_cci.m_physicsEnv->getGravity(grav); + sbi.m_gravity.setValue(grav[0],grav[1],grav[2]); + + const btVector3 c[]={ p+h*btVector3(-1,-1,-1), + p+h*btVector3(+1,-1,-1), + p+h*btVector3(-1,+1,-1), + p+h*btVector3(+1,+1,-1), + p+h*btVector3(-1,-1,+1), + p+h*btVector3(+1,-1,+1), + p+h*btVector3(-1,+1,+1), + p+h*btVector3(+1,+1,+1)}; + + int i=0; + const int n=15; + //btSoftBody* psb=btSoftBodyHelpers::CreateRope(sbi, btVector3(-10,0,i*0.25),btVector3(10,0,i*0.25), 16,1+2); + btSoftBody* psb = btSoftBodyHelpers::CreateFromConvexHull(sbi,c,8); + + m_object = psb;//btSoftBodyHelpers::CreateFromTriMesh(sbi,&pts[0].getX(),triangles,numtriangles); + + psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS;//btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS; + + sbi.m_sparsesdf.Reset(); + sbi.m_sparsesdf.Initialize(); + + psb->generateBendingConstraints(2); + + psb->m_cfg.kDF=1; + psb->activate(); + psb->setActivationState(1); + psb->setDeactivationTime(1.f); + psb->m_cfg.piterations = 4; + //psb->m_materials[0]->m_kLST = 0.1+(i/(btScalar)(n-1))*0.9; + psb->setTotalMass(20); + psb->setCollisionFlags(0); + m_object->setCollisionShape(rbci.m_collisionShape); btTransform startTrans; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index af146413c91..c45f4590749 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -149,6 +149,7 @@ struct CcdConstructionInfo m_margin(0.06f), m_collisionFlags(0), m_bRigid(false), + m_bSoft(false), m_collisionFilterGroup(DefaultFilter), m_collisionFilterMask(AllFilter), m_collisionShape(0), @@ -170,6 +171,7 @@ struct CcdConstructionInfo btScalar m_margin; int m_collisionFlags; bool m_bRigid; + bool m_bSoft; ///optional use of collision group/mask: ///only collision with object goups that match the collision mask. diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 68b3df1695c..96aa9ad164e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -24,6 +24,7 @@ subject to the following restrictions: #include "LinearMath/btIDebugDraw.h" #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" #include "BulletSoftBody/btSoftRigidDynamicsWorld.h" +#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" //profiling/timings #include "LinearMath/btQuickprof.h" @@ -331,7 +332,9 @@ m_filterCallback(NULL) { m_triggerCallbacks[i] = 0; } - m_collisionConfiguration = new btDefaultCollisionConfiguration(); + +// m_collisionConfiguration = new btDefaultCollisionConfiguration(); + m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration(); if (!dispatcher) { @@ -339,6 +342,8 @@ m_filterCallback(NULL) m_ownDispatcher = dispatcher; } + //m_broadphase = new btAxisSweep3(btVector3(-1000,-1000,-1000),btVector3(1000,1000,1000)); + //m_broadphase = new btSimpleBroadphase(); m_broadphase = new btDbvtBroadphase(); m_filterCallback = new CcdOverlapFilterCallBack(this); @@ -375,9 +380,8 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) { if (ctrl->GetSoftBody()) { - //not yet - btAssert(0); - //m_dynamicsWorld->addSo + btSoftBody* softBody = ctrl->GetSoftBody(); + m_dynamicsWorld->addSoftBody(softBody); } else { if (obj->getCollisionShape()) @@ -460,8 +464,7 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr //if a softbody if (ctrl->GetSoftBody()) { - //not yet - btAssert(0); + m_dynamicsWorld->removeSoftBody(ctrl->GetSoftBody()); } else { m_dynamicsWorld->removeCollisionObject(ctrl->GetCollisionObject()); @@ -553,7 +556,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) float subStep = timeStep / float(m_numTimeSubSteps); for (i=0;istepSimulation(subStep,0);//perform always a full simulation step +// m_dynamicsWorld->stepSimulation(subStep,20,1./240.);//perform always a full simulation step + m_dynamicsWorld->stepSimulation(subStep,0);//perform always a full simulation step } for (it=m_controllers.begin(); it!=m_controllers.end(); it++) @@ -670,7 +674,13 @@ void CcdPhysicsEnvironment::setSolverType(int solverType) - +void CcdPhysicsEnvironment::getGravity(PHY__Vector3& grav) +{ + const btVector3& gravity = m_dynamicsWorld->getGravity(); + grav[0] = gravity.getX(); + grav[1] = gravity.getY(); + grav[2] = gravity.getZ(); +} void CcdPhysicsEnvironment::setGravity(float x,float y,float z) @@ -955,6 +965,13 @@ btBroadphaseInterface* CcdPhysicsEnvironment::getBroadphase() return m_dynamicsWorld->getBroadphase(); } +btDispatcher* CcdPhysicsEnvironment::getDispatcher() +{ + return m_dynamicsWorld->getDispatcher(); +} + + + diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 3569cf25b68..9b6a76d49ee 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -119,6 +119,8 @@ protected: virtual void setDebugMode(int debugMode); virtual void setGravity(float x,float y,float z); + virtual void getGravity(PHY__Vector3& grav); + virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ, @@ -195,8 +197,7 @@ protected: btBroadphaseInterface* getBroadphase(); - - + btDispatcher* getDispatcher(); bool IsSatCollisionDetectionEnabled() const -- cgit v1.2.3 From 8fcac6820af048a5c03f41e8f5f40cecf6a67684 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Sep 2008 04:18:17 +0000 Subject: KX_PythonInit.cpp - workaround for current sandbox and possible fix. no real change for now but others may want to look into it. blendef.h - removed some unused defines. editipo_mods.c - deselect all was selecting instead. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 09c49a15f76..6b2f3c68d55 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1047,6 +1047,21 @@ PyObject *KXpy_import(PyObject *self, PyObject *args) } +/* override python file type functions */ +#if 0 +static int +file_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + KXpy_file(NULL, NULL); + return -1; +} + +static PyObject * +file_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + return KXpy_file(NULL, NULL); +} +#endif static PyMethodDef meth_open[] = {{ "open", KXpy_open, METH_VARARGS, "(disabled)"}}; static PyMethodDef meth_reload[] = {{ "reload", KXpy_reload, METH_VARARGS, "(disabled)"}}; @@ -1060,7 +1075,6 @@ static PyMethodDef meth_import[] = {{ "import", KXpy_import, METH_VARARGS, "our //static PyObject *g_oldimport = 0; //static int g_security = 0; - void setSandbox(TPythonSecurityLevel level) { PyObject *m = PyImport_AddModule("__builtin__"); @@ -1081,6 +1095,19 @@ void setSandbox(TPythonSecurityLevel level) // our own import PyDict_SetItemString(d, "__import__", PyCFunction_New(meth_import, NULL)); //g_security = level; + + // Overiding file dosnt stop it being accessed if your sneaky + // f = [ t for t in (1).__class__.__mro__[-1].__subclasses__() if t.__name__ == 'file'][0]('/some_file.txt', 'w') + // f.write('...') + // so overwrite the file types functions. be very careful here still, since python uses python. + // ps - python devs frown deeply upon this. + + /* this could mess up pythons internals, if we are serious about sandboxing + * issues like the one above need to be solved, possibly modify __subclasses__ is safer? */ +#if 0 + PyFile_Type.tp_init = file_init; + PyFile_Type.tp_new = file_new; +#endif //} break; /* -- cgit v1.2.3 From 9b4956ae2213570e07475ecc544a630c44d2892c Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 22 Sep 2008 19:54:30 +0000 Subject: BGE patch: KX_STATEx constant to allow simple state manipulation in setState() The constants KX_STATE1 to KX_STATE30 can be used with setState() to change the object state in a python controller. The constants are defined in the GameLogic module so that the full name is GameLogic.KX_STATE1 to GameLogic.KX_STATE30 but you can simplify this with the import statement: from GameLogic import * cont = getCurrentController() ob = cont.getOwner() ob.setState(KX_STATE2) #go to state 2 KX_STATEx constants are defined as (1<<(x-1)) Binary operators |, &, ^ and ~ can be used to combine states: You can activate more than one state at a time with the | operator: ob.setState(KX_STATE1|KX_STATE2) #activate state 1 and 2, stop all others You can add a state to the current state mask with: state = ob.getState() ob.setState(state|KX_STATE3) #activate state 3, keep others You can substract a state to the current state mask with the & and operator: state = ob.getState() ob.setState(state&~KX_STATE2) #stop state 2, keep others You can invert a state with the ^ operator: state = ob.getState() ob.setState(state^KX_STATE2) #invert state 2, keep others --- source/gameengine/Ketsji/KX_PythonInit.cpp | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 6b2f3c68d55..95693efe30e 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -975,6 +975,38 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack KX_MACRO_addTypesToDict(d, CAM_POS, BL_Shader::CAM_POS); KX_MACRO_addTypesToDict(d, CONSTANT_TIMER, BL_Shader::CONSTANT_TIMER); + /* 10 state actuator */ + KX_MACRO_addTypesToDict(d, KX_STATE1, (1<<0)); + KX_MACRO_addTypesToDict(d, KX_STATE2, (1<<1)); + KX_MACRO_addTypesToDict(d, KX_STATE3, (1<<2)); + KX_MACRO_addTypesToDict(d, KX_STATE4, (1<<3)); + KX_MACRO_addTypesToDict(d, KX_STATE5, (1<<4)); + KX_MACRO_addTypesToDict(d, KX_STATE6, (1<<5)); + KX_MACRO_addTypesToDict(d, KX_STATE7, (1<<6)); + KX_MACRO_addTypesToDict(d, KX_STATE8, (1<<7)); + KX_MACRO_addTypesToDict(d, KX_STATE9, (1<<8)); + KX_MACRO_addTypesToDict(d, KX_STATE10, (1<<9)); + KX_MACRO_addTypesToDict(d, KX_STATE11, (1<<10)); + KX_MACRO_addTypesToDict(d, KX_STATE12, (1<<11)); + KX_MACRO_addTypesToDict(d, KX_STATE13, (1<<12)); + KX_MACRO_addTypesToDict(d, KX_STATE14, (1<<13)); + KX_MACRO_addTypesToDict(d, KX_STATE15, (1<<14)); + KX_MACRO_addTypesToDict(d, KX_STATE16, (1<<15)); + KX_MACRO_addTypesToDict(d, KX_STATE17, (1<<16)); + KX_MACRO_addTypesToDict(d, KX_STATE18, (1<<17)); + KX_MACRO_addTypesToDict(d, KX_STATE19, (1<<18)); + KX_MACRO_addTypesToDict(d, KX_STATE20, (1<<19)); + KX_MACRO_addTypesToDict(d, KX_STATE21, (1<<20)); + KX_MACRO_addTypesToDict(d, KX_STATE22, (1<<21)); + KX_MACRO_addTypesToDict(d, KX_STATE23, (1<<22)); + KX_MACRO_addTypesToDict(d, KX_STATE24, (1<<23)); + KX_MACRO_addTypesToDict(d, KX_STATE25, (1<<24)); + KX_MACRO_addTypesToDict(d, KX_STATE26, (1<<25)); + KX_MACRO_addTypesToDict(d, KX_STATE27, (1<<26)); + KX_MACRO_addTypesToDict(d, KX_STATE28, (1<<27)); + KX_MACRO_addTypesToDict(d, KX_STATE29, (1<<28)); + KX_MACRO_addTypesToDict(d, KX_STATE30, (1<<29)); + // Check for errors if (PyErr_Occurred()) { -- cgit v1.2.3 From 18c954e95ba8181a67a6e67246d5f507246db007 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 22 Sep 2008 21:49:48 +0000 Subject: BGE patch #17569 approved: Make FrameProp: work in Shape Action. PyDoc updated. --- .../Converter/BL_ShapeActionActuator.cpp | 50 ++++++++++++++++++++++ .../gameengine/Converter/BL_ShapeActionActuator.h | 5 +++ .../gameengine/Converter/KX_ConvertActuators.cpp | 2 + source/gameengine/PyDoc/BL_ActionActuator.py | 13 +++++- source/gameengine/PyDoc/BL_ShapeActionActuator.py | 13 +++++- 5 files changed, 79 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 721c24dfb94..7a73420fc7c 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -49,6 +49,7 @@ #include "BLI_arithb.h" #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" +#include "FloatValue.h" #include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H @@ -342,6 +343,18 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) break; } + /* Set the property if its defined */ + if (m_framepropname[0] != '\0') { + CValue* propowner = GetParent(); + CValue* oldprop = propowner->GetProperty(m_framepropname); + CValue* newval = new CFloatValue(m_localtime); + if (oldprop) { + oldprop->SetValue(newval); + } else { + propowner->SetProperty(m_framepropname, newval); + } + newval->Release(); + } if (bNegativeEvent) m_blendframe=0.0f; @@ -442,6 +455,7 @@ PyMethodDef BL_ShapeActionActuator::Methods[] = { {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, SetPriority_doc}, {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, SetFrame_doc}, {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, SetFrameProperty_doc}, {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc}, {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, GetAction_doc}, @@ -451,6 +465,7 @@ PyMethodDef BL_ShapeActionActuator::Methods[] = { {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, GetPriority_doc}, {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, GetFrame_doc}, {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, GetFrameProperty_doc}, {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, GetType_doc}, {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, SetType_doc}, {NULL,NULL} //Sentinel @@ -706,6 +721,20 @@ PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, Py_RETURN_NONE; } +/* getProperty */ +const char BL_ShapeActionActuator::GetFrameProperty_doc[] = +"getFrameProperty()\n" +"\tReturns the name of the property, that is set to the current frame number.\n"; + +PyObject* BL_ShapeActionActuator::PyGetFrameProperty(PyObject* self) { + PyObject *result; + + result = Py_BuildValue("s", (const char *)m_framepropname); + + return result; +} + + /* setFrame */ const char BL_ShapeActionActuator::SetFrame_doc[] = "setFrame(frame)\n" @@ -753,6 +782,27 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, Py_RETURN_NONE; } +/* setFrameProperty */ +const char BL_ShapeActionActuator::SetFrameProperty_doc[] = +"setFrameProperty(prop)\n" +"\t - prop : A string specifying the property of the frame set up update.\n"; + +PyObject* BL_ShapeActionActuator::PySetFrameProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + char *string; + + if (PyArg_ParseTuple(args,"s",&string)) + { + m_framepropname = string; + } + else { + return NULL; + } + + Py_RETURN_NONE; +} + /* getType */ const char BL_ShapeActionActuator::GetType_doc[] = "getType()\n" diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index a9b9ad8fa86..30b2d41fc67 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -42,6 +42,7 @@ public: Py_Header; BL_ShapeActionActuator(SCA_IObject* gameobj, const STR_String& propname, + const STR_String& framepropname, float starttime, float endtime, struct bAction *action, @@ -66,6 +67,7 @@ public: m_playtype(playtype), m_priority(priority), m_action(action), + m_framepropname(framepropname), m_propname(propname) { }; @@ -84,6 +86,7 @@ public: KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetEnd); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrame); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetProperty); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrameProperty); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendtime); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetChannel); @@ -94,6 +97,7 @@ public: KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetEnd); KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrame); KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetProperty); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrameProperty); // KX_PYMETHOD(BL_ActionActuator,GetChannel); KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType); @@ -126,6 +130,7 @@ protected: short m_priority; struct bAction *m_action; STR_String m_propname; + STR_String m_framepropname; vector m_blendshape; }; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index e8be8de95ed..78791c53d7c 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -210,10 +210,12 @@ void BL_ConvertActuators(char* maggiename, if (blenderobject->type==OB_MESH){ bActionActuator* actact = (bActionActuator*) bact->data; STR_String propname = (actact->name ? actact->name : ""); + STR_String propframe = (actact->frameProp ? actact->frameProp : ""); BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator( gameobj, propname, + propframe, actact->sta, actact->end, actact->act, diff --git a/source/gameengine/PyDoc/BL_ActionActuator.py b/source/gameengine/PyDoc/BL_ActionActuator.py index d56888cde80..b68d3014115 100644 --- a/source/gameengine/PyDoc/BL_ActionActuator.py +++ b/source/gameengine/PyDoc/BL_ActionActuator.py @@ -164,5 +164,14 @@ class BL_ActionActuator(SCA_IActuator): @param mode: True for armature/world space, False for bone space @type mode: boolean """ - - + def setFrameProperty(prop): + """ + @param prop: A string specifying the property of the object that will be updated with the action frame number. + @type prop: string + """ + def getFrameProperty(): + """ + Returns the name of the property that is set to the current frame number. + + @rtype: string + """ diff --git a/source/gameengine/PyDoc/BL_ShapeActionActuator.py b/source/gameengine/PyDoc/BL_ShapeActionActuator.py index 63cce253fa4..a26b276a2da 100644 --- a/source/gameengine/PyDoc/BL_ShapeActionActuator.py +++ b/source/gameengine/PyDoc/BL_ShapeActionActuator.py @@ -154,5 +154,14 @@ class BL_ShapeActionActuator(SCA_IActuator): @rtype: string """ - - + def setFrameProperty(prop): + """ + @param prop: A string specifying the property of the object that will be updated with the action frame number. + @type prop: string + """ + def getFrameProperty(): + """ + Returns the name of the property that is set to the current frame number. + + @rtype: string + """ -- cgit v1.2.3 From 7a28ca4398465be1d6d57079e4b27c3a03418745 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Sep 2008 00:37:19 +0000 Subject: Make GameLogic work for python autocomplete (after running the BGE once at least) only clear newly added items from the gameLogic dictionary rather then the whole dictionary. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 74fe6c68863..6a296a3e244 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -326,8 +326,10 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, ketsjiengine->SetPythonDictionary(dictionaryobject); initRasterizer(rasterizer, canvas); PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); - PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module. PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + PyObject *gameLogic_keys = PyDict_Keys(PyModule_GetDict(gameLogic)); + PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module. + initGameKeys(); initPythonConstraintBinding(); initMathutils(); @@ -401,8 +403,20 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, // inside the GameLogic dictionary when the python interpreter is finalized. // which allows the scene to safely delete them :) // see: (space.c)->start_game - PyDict_Clear(PyModule_GetDict(gameLogic)); - PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); + + //PyDict_Clear(PyModule_GetDict(gameLogic)); + + // Keep original items, means python plugins will autocomplete members + int listIndex; + PyObject *gameLogic_keys_new = PyDict_Keys(PyModule_GetDict(gameLogic)); + for (listIndex=0; listIndex < PyList_Size(gameLogic_keys_new); listIndex++) { + PyObject* item = PyList_GET_ITEM(gameLogic_keys_new, listIndex); + if (!PySequence_Contains(gameLogic_keys, item)) { + PyDict_DelItem( PyModule_GetDict(gameLogic), item); + } + } + Py_DECREF(gameLogic_keys_new); + gameLogic_keys_new = NULL; ketsjiengine->StopEngine(); exitGamePythonScripting(); @@ -413,6 +427,9 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, delete sceneconverter; sceneconverter = NULL; } + + Py_DECREF(gameLogic_keys); + gameLogic_keys = NULL; } // set the cursor back to normal canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); -- cgit v1.2.3 From 005c5e63711e92677547ec2477238fd1f016fb30 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 23 Sep 2008 20:07:15 +0000 Subject: BGE bug #17657 fixed: dRotY doesn't work properly after 90 degrees rotation. This problem is caused by discontinuities in the conversion orientation matrix -> euler angles: the angle sign can switch and thus the direction of the rotation produced by the dRot Ipo. To avoid this bug, the matrix->euler conversion must be avoided during the game. I took the following approach that is compatible with Blender (identical effect in the game and in the 3D view): - no change in Add mode: Rot and dRot are treated as additional rotation to the orientation at the start of the Ipo. There is no matrix->euler conversion and thus no discontinuities. - Rot Ipo are treated as absolute rotation. All 3 axis should be specified but if they are not, the startup object orientation will be used to set the unspecified axis. By doing a matrix-> euler conversion once at the start, the discontinuities are avoided. If there are also dRot curves, they are treated as delta of the corresponding Rot curve or startup angle. - dRot Ipo are treated as Add mode in Local axis. Note about Add mode: Rot and dRot curves are treated identically during the game. However, only dRot curves make sense because they don't interfere with the object orientation in the 3D view. --- source/gameengine/Ketsji/KX_IPO_SGController.cpp | 115 ++++++++++++++++------- source/gameengine/Ketsji/KX_IPO_SGController.h | 6 ++ 2 files changed, 85 insertions(+), 36 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp index 6223643f75a..67d54cf0b0b 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp +++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp @@ -59,7 +59,9 @@ KX_IpoSGController::KX_IpoSGController() m_ipo_local(false), m_modified(true), m_ipo_start_initialized(false), - m_ipotime(1.0) + m_ipotime(1.0), + m_ipo_start_euler(0.0,0.0,0.0), + m_ipo_euler_initialized(false) { m_game_object = NULL; for (int i=0; i < KX_MAX_IPO_CHANNELS; i++) @@ -136,6 +138,11 @@ bool KX_IpoSGController::Update(double currentTime) m_ipo_start_orient = ob->GetLocalOrientation(); m_ipo_start_scale = ob->GetLocalScale(); m_ipo_start_initialized = true; + if (!m_ipo_euler_initialized) { + // do it only once to avoid angle discontinuities + m_ipo_start_orient.getEuler(m_ipo_start_euler[0], m_ipo_start_euler[1], m_ipo_start_euler[2]); + m_ipo_euler_initialized = true; + } } //modifies position? @@ -199,51 +206,87 @@ bool KX_IpoSGController::Update(double currentTime) ob->GetWorldOrientation() * m_ipo_xform.GetEulerAngles() : m_ipo_xform.GetEulerAngles(), false); } - } else { - double yaw=0, pitch=0, roll=0; //final Euler angles - double tempYaw=0, tempPitch=0, tempRoll=0; //temp holders - if (!m_ipo_add) - ob->GetLocalOrientation().getEuler(yaw, pitch, roll); + } else if (m_ipo_add) { + if (m_ipo_start_initialized) { + double yaw=0, pitch=0, roll=0; //delta Euler angles - //RotX and dRotX - if (m_ipo_channels_active[OB_ROT_X]) { - yaw = (m_ipo_channels_active[OB_DROT_X] ? (m_ipo_xform.GetEulerAngles()[0] + m_ipo_xform.GetDeltaEulerAngles()[0]) : m_ipo_xform.GetEulerAngles()[0] ); - } - else if (m_ipo_channels_active[OB_DROT_X] && m_ipo_start_initialized) { - if (!m_ipo_add) - m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); - yaw = tempYaw + m_ipo_xform.GetDeltaEulerAngles()[0]; - } + //RotX and dRotX + if (m_ipo_channels_active[OB_ROT_X]) + yaw += m_ipo_xform.GetEulerAngles()[0]; + if (m_ipo_channels_active[OB_DROT_X]) + yaw += m_ipo_xform.GetDeltaEulerAngles()[0]; + + //RotY dRotY + if (m_ipo_channels_active[OB_ROT_Y]) + pitch += m_ipo_xform.GetEulerAngles()[1]; + if (m_ipo_channels_active[OB_DROT_Y]) + pitch += m_ipo_xform.GetDeltaEulerAngles()[1]; + + //RotZ and dRotZ + if (m_ipo_channels_active[OB_ROT_Z]) + roll += m_ipo_xform.GetEulerAngles()[2]; + if (m_ipo_channels_active[OB_DROT_Z]) + roll += m_ipo_xform.GetDeltaEulerAngles()[2]; - //RotY dRotY - if (m_ipo_channels_active[OB_ROT_Y]) { - pitch = (m_ipo_channels_active[OB_DROT_Y] ? (m_ipo_xform.GetEulerAngles()[1] + m_ipo_xform.GetDeltaEulerAngles()[1]) : m_ipo_xform.GetEulerAngles()[1] ); - } - else if (m_ipo_channels_active[OB_DROT_Y] && m_ipo_start_initialized) { - if (!m_ipo_add) - m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); - pitch = tempPitch + m_ipo_xform.GetDeltaEulerAngles()[1]; - } - - //RotZ and dRotZ - if (m_ipo_channels_active[OB_ROT_Z]) { - roll = (m_ipo_channels_active[OB_DROT_Z] ? (m_ipo_xform.GetEulerAngles()[2] + m_ipo_xform.GetDeltaEulerAngles()[2]) : m_ipo_xform.GetEulerAngles()[2] ); - } - else if (m_ipo_channels_active[OB_DROT_Z] && m_ipo_start_initialized) { - if (!m_ipo_add) - m_ipo_start_orient.getEuler(tempYaw, tempPitch, tempRoll); - roll = tempRoll + m_ipo_xform.GetDeltaEulerAngles()[2]; - } - if (m_ipo_add) { MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll)); if (m_ipo_local) rotation = m_ipo_start_orient * rotation; else rotation = rotation * m_ipo_start_orient; ob->SetLocalOrientation(rotation); - } else { + } + } else if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z]) { + if (m_ipo_euler_initialized) { + // assume all channel absolute + // All 3 channels should be specified but if they are not, we will take + // the value at the start of the game to avoid angle sign reversal + double yaw=m_ipo_start_euler[0], pitch=m_ipo_start_euler[1], roll=m_ipo_start_euler[2]; + + //RotX and dRotX + if (m_ipo_channels_active[OB_ROT_X]) { + yaw = (m_ipo_channels_active[OB_DROT_X] ? (m_ipo_xform.GetEulerAngles()[0] + m_ipo_xform.GetDeltaEulerAngles()[0]) : m_ipo_xform.GetEulerAngles()[0] ); + } + else if (m_ipo_channels_active[OB_DROT_X]) { + yaw += m_ipo_xform.GetDeltaEulerAngles()[0]; + } + + //RotY dRotY + if (m_ipo_channels_active[OB_ROT_Y]) { + pitch = (m_ipo_channels_active[OB_DROT_Y] ? (m_ipo_xform.GetEulerAngles()[1] + m_ipo_xform.GetDeltaEulerAngles()[1]) : m_ipo_xform.GetEulerAngles()[1] ); + } + else if (m_ipo_channels_active[OB_DROT_Y]) { + pitch += m_ipo_xform.GetDeltaEulerAngles()[1]; + } + + //RotZ and dRotZ + if (m_ipo_channels_active[OB_ROT_Z]) { + roll = (m_ipo_channels_active[OB_DROT_Z] ? (m_ipo_xform.GetEulerAngles()[2] + m_ipo_xform.GetDeltaEulerAngles()[2]) : m_ipo_xform.GetEulerAngles()[2] ); + } + else if (m_ipo_channels_active[OB_DROT_Z]) { + roll += m_ipo_xform.GetDeltaEulerAngles()[2]; + } ob->SetLocalOrientation(MT_Vector3(yaw, pitch, roll)); } + } else if (m_ipo_start_initialized) { + // only DROT, treat as Add + double yaw=0, pitch=0, roll=0; //delta Euler angles + + //dRotX + if (m_ipo_channels_active[OB_DROT_X]) + yaw = m_ipo_xform.GetDeltaEulerAngles()[0]; + + //dRotY + if (m_ipo_channels_active[OB_DROT_Y]) + pitch = m_ipo_xform.GetDeltaEulerAngles()[1]; + + //dRotZ + if (m_ipo_channels_active[OB_DROT_Z]) + roll = m_ipo_xform.GetDeltaEulerAngles()[2]; + + // dRot are always local + MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll)); + rotation = m_ipo_start_orient * rotation; + ob->SetLocalOrientation(rotation); } } //modifies scale? diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h index 0bd8980f11c..031b74294ce 100644 --- a/source/gameengine/Ketsji/KX_IPO_SGController.h +++ b/source/gameengine/Ketsji/KX_IPO_SGController.h @@ -72,6 +72,12 @@ class KX_IpoSGController : public SG_Controller /** if IPO initial position has been set for local normal IPO */ bool m_ipo_start_initialized; + /** Euler angles at the start of the game, needed for incomplete ROT Ipo curves */ + class MT_Vector3 m_ipo_start_euler; + + /** true is m_ipo_start_euler has been initialized */ + bool m_ipo_euler_initialized; + /** A reference to the original game object. */ class KX_GameObject* m_game_object; -- cgit v1.2.3 From 3b09c0b0d5a5bea78f0832532f8c206280ae6456 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 24 Sep 2008 03:12:10 +0000 Subject: Created a KX_SoftBodyDeformer for real-time soft bodies. Added SetDeformer/GetDeformer() to KX_GameObject. Store mapping between graphics/soft body vertices (work-in-progress) Real-time soft body integration is still very premature, but for a quick preview, see this testfile: http://bulletphysics.com/ftp/pub/test/index.php?dir=blender/&file=soft_test.blend --- .../Converter/BL_BlenderDataConversion.cpp | 13 +- .../gameengine/Converter/BL_DeformableGameObject.h | 14 +- source/gameengine/Converter/BL_SkinMeshObject.cpp | 2 +- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 110 +++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 8 + source/gameengine/Ketsji/KX_Scene.cpp | 12 +- .../Physics/Bullet/CcdPhysicsController.cpp | 195 ++++++++++++++++----- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 2 + .../Physics/Bullet/CcdPhysicsEnvironment.h | 5 +- 9 files changed, 306 insertions(+), 55 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 9b9d5c95de9..6a5048a9f15 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -743,7 +743,8 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* } // Determine if we need to make a skinned mesh - if (mesh->dvert || mesh->key) { + if (mesh->dvert || mesh->key || ((blenderobj->gameflag & OB_SOFT_BODY) != 0)) + { meshobj = new BL_SkinMeshObject(mesh, lightlayer); skinMesh = true; } @@ -1554,20 +1555,20 @@ static KX_GameObject *gameobject_from_blenderobject( // not that we can have shape keys without dvert! BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj, ob, (BL_SkinMeshObject*)meshobj); - ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; + ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont); if (bHasArmature) dcont->LoadShapeDrivers(ob->parent); } else if (bHasArmature) { BL_SkinDeformer *dcont = new BL_SkinDeformer((BL_DeformableGameObject*)gameobj, ob, (BL_SkinMeshObject*)meshobj); - ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; + ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont); } else if (bHasDvert) { // this case correspond to a mesh that can potentially deform but not with the // object to which it is attached for the moment. A skin mesh was created in // BL_ConvertMesh() so must create a deformer too! BL_MeshDeformer *dcont = new BL_MeshDeformer((BL_DeformableGameObject*)gameobj, ob, (BL_SkinMeshObject*)meshobj); - ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont; + ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont); } MT_Point3 min = MT_Point3(center) - MT_Vector3(extents); @@ -2193,8 +2194,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, if (obj && blenderobj->parent && blenderobj->parent->type==OB_ARMATURE && blenderobj->partype==PARSKEL){ KX_GameObject *par = converter->FindGameObject(blenderobj->parent); - if (par && obj->m_pDeformer) - ((BL_SkinDeformer*)obj->m_pDeformer)->SetArmature((BL_ArmatureObject*) par); + if (par && obj->GetDeformer()) + ((BL_SkinDeformer*)obj->GetDeformer())->SetArmature((BL_ArmatureObject*) par); } } } diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h index 315ad18c42c..126a1fcb1e7 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.h +++ b/source/gameengine/Converter/BL_DeformableGameObject.h @@ -83,9 +83,21 @@ public: return (m_pDeformer) ? ((BL_MeshDeformer*)m_pDeformer)->GetMesh()->key : NULL; } + virtual void SetDeformer(class RAS_Deformer* deformer) + { + m_pDeformer = deformer; + } + virtual class RAS_Deformer* GetDeformer() + { + return m_pDeformer; + } + public: - RAS_Deformer *m_pDeformer; + protected: + + RAS_Deformer *m_pDeformer; + class BL_ShapeActionActuator *m_activeAct; double m_lastframe; Object* m_blendobj; diff --git a/source/gameengine/Converter/BL_SkinMeshObject.cpp b/source/gameengine/Converter/BL_SkinMeshObject.cpp index 4f9f1a434b5..eb3f9d0588d 100644 --- a/source/gameengine/Converter/BL_SkinMeshObject.cpp +++ b/source/gameengine/Converter/BL_SkinMeshObject.cpp @@ -87,7 +87,7 @@ void BL_SkinMeshObject::UpdateBuckets(void* clientobj,double* oglmatrix,bool use continue; RAS_MeshSlot *slot = *it->m_slots[clientobj]; - slot->m_pDeformer = ((BL_DeformableGameObject*)clientobj)->m_pDeformer; + slot->m_pDeformer = ((BL_DeformableGameObject*)clientobj)->GetDeformer(); } RAS_MeshObject::UpdateBuckets(clientobj, oglmatrix, useObjectColor, rgbavec, visible, culled); diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 46b53d07efc..c4411a58856 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -38,6 +38,8 @@ #include "RAS_MeshObject.h" #include "KX_Scene.h" #include "SYS_System.h" +#include "BL_SkinMeshObject.h" +#include "BulletSoftBody/btSoftBody.h" #include "PHY_Pro.h" //todo cleanup #include "KX_ClientObjectInfo.h" @@ -765,7 +767,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, } case KX_BOUNDMESH: { - if (!ci.m_mass) + if (!ci.m_mass ||objprop->m_softbody) { // mesh shapes can be shared, check first if we already have a shape on that mesh class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, false); @@ -988,6 +990,112 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, physicscontroller->SetObject(gameobj->GetSGNode()); + class KX_SoftBodyDeformer : public RAS_Deformer + { + btSoftBody* m_softBody; + class BL_SkinMeshObject* m_pMeshObject; + class BL_DeformableGameObject* m_gameobj; + + + public: + KX_SoftBodyDeformer(btSoftBody* softBody,BL_SkinMeshObject* pMeshObject,BL_DeformableGameObject* gameobj) + : m_softBody(softBody), + m_pMeshObject(pMeshObject), + m_gameobj(gameobj) + { + //printf("KX_SoftBodyDeformer\n"); + }; + + virtual ~KX_SoftBodyDeformer() + { + //printf("~KX_SoftBodyDeformer\n"); + }; + virtual void Relink(GEN_Map*map) + { + //printf("relink\n"); + } + virtual bool Apply(class RAS_IPolyMaterial *polymat) + { + //printf("apply\n"); + RAS_MeshSlot::iterator it; + RAS_MeshMaterial *mmat; + RAS_MeshSlot *slot; + size_t i; + + // update the vertex in m_transverts + Update(); + + // The vertex cache can only be updated for this deformer: + // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) + // share the same mesh (=the same cache). As the rendering is done per polymaterial + // cycling through the objects, the entire mesh cache cannot be updated in one shot. + mmat = m_pMeshObject->GetMeshMaterial(polymat); + if(!mmat->m_slots[(void*)m_gameobj]) + return true; + + slot = *mmat->m_slots[(void*)m_gameobj]; + + // for each array + for(slot->begin(it); !slot->end(it); slot->next(it)) + { + // for each vertex + // copy the untransformed data from the original mvert + int count = 0; + { + + for(i=it.startvertex; im_nodes); + + if (count == m_softBody->m_userIndexMapping.size()) + { + int index = 0; + for(i=it.startvertex; im_userIndexMapping[index]].m_x.getX(), + nodes[m_softBody->m_userIndexMapping[index]].m_x.getY(), + nodes[m_softBody->m_userIndexMapping[index]].m_x.getZ()); + v.SetXYZ(pt); + + //(m_transverts[v.getOrigIndex()]); + } + } + + } + + return true; + } + virtual bool Update(void) + { + //printf("update\n"); + return true;//?? + } + virtual RAS_Deformer *GetReplica() + { + //printf("getReplica\n"); + return 0; + } + protected: + //class RAS_MeshObject *m_pMesh; + }; + + ///test for soft bodies + if (objprop->m_softbody && physicscontroller) + { + btSoftBody* softBody = physicscontroller->GetSoftBody(); + if (softBody && gameobj->GetMesh(0)) + { + //should be a mesh then, so add a soft body deformer + KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer(softBody, (BL_SkinMeshObject*)gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj); + gameobj->SetDeformer(softbodyDeformer); + + } + } + } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 2da0be4df25..12e29cf3294 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -332,6 +332,14 @@ public: m_pPhysicsController1 = physicscontroller; } + virtual class RAS_Deformer* GetDeformer() + { + return 0; + } + virtual void SetDeformer(class RAS_Deformer* deformer) + { + + } /** * @section Coordinate system manipulation functions diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 04db96c298c..6eeb732c1e3 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -977,10 +977,10 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) { BL_DeformableGameObject* newobj = static_cast( gameobj ); - if (newobj->m_pDeformer) + if (newobj->GetDeformer()) { - delete newobj->m_pDeformer; - newobj->m_pDeformer = NULL; + delete newobj->GetDeformer(); + newobj->SetDeformer(NULL); } if (mesh->IsDeformed()) @@ -1030,7 +1030,7 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) NULL ); } - newobj->m_pDeformer = shapeDeformer; + newobj->SetDeformer( shapeDeformer); } else if (bHasArmature) { @@ -1042,14 +1042,14 @@ void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj) static_cast( parentobj ) ); releaseParent= false; - newobj->m_pDeformer = skinDeformer; + newobj->SetDeformer(skinDeformer); } else if (bHasDvert) { BL_MeshDeformer* meshdeformer = new BL_MeshDeformer( newobj, oldblendobj, static_cast(mesh) ); - newobj->m_pDeformer = meshdeformer; + newobj->SetDeformer(meshdeformer); } // release parent reference if its not being used diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 41ae5e38309..ad79db16dc4 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -20,7 +20,11 @@ subject to the following restrictions: #include "CcdPhysicsEnvironment.h" #include "RAS_MeshObject.h" #include "BulletSoftBody/btSoftBody.h" +#include "BulletSoftBody//btSoftBodyInternals.h" +#include "BulletSoftBody/btSoftBodyHelpers.h" +#include "LinearMath/btConvexHull.h" +#include "BulletSoftBody/btSoftRigidDynamicsWorld.h" class BP_Proxy; @@ -135,11 +139,7 @@ btSoftBody* CcdPhysicsController::GetSoftBody() #include "BulletSoftBody/btSoftBodyHelpers.h" -btVector3 pts[3] = {btVector3(0,0,0), -btVector3(0,1,0), -btVector3(1,1,0)}; -int triangles[3] = {0,1,2}; -btSoftBodyWorldInfo sbi; + void CcdPhysicsController::CreateRigidbody() { @@ -151,8 +151,13 @@ void CcdPhysicsController::CreateRigidbody() //create a collision object + int shapeType = m_cci.m_collisionShape ? m_cci.m_collisionShape->getShapeType() : 0; + //disable soft body until first sneak preview is ready - if (0)//m_cci.m_bSoft) + if (m_cci.m_bSoft && m_cci.m_collisionShape && + (shapeType == CONVEX_HULL_SHAPE_PROXYTYPE)) + //(shapeType == TRIANGLE_MESH_SHAPE_PROXYTYPE) | + //(shapeType == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE))) { btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); rbci.m_linearDamping = m_cci.m_linearDamping; @@ -161,54 +166,161 @@ void CcdPhysicsController::CreateRigidbody() rbci.m_restitution = m_cci.m_restitution; - sbi.m_broadphase = this->m_cci.m_physicsEnv->getBroadphase(); - sbi.m_dispatcher = (btCollisionDispatcher*) m_cci.m_physicsEnv->getDispatcher(); - int nodecount = 0; - int numtriangles = 1; - btVector3 p = trans.getOrigin(); + btVector3 p(0,0,0);// = getOrigin(); btScalar h = 1.f; + btSoftRigidDynamicsWorld* softDynaWorld = (btSoftRigidDynamicsWorld*)m_cci.m_physicsEnv->getDynamicsWorld(); + PHY__Vector3 grav; - m_cci.m_physicsEnv->getGravity(grav); - sbi.m_gravity.setValue(grav[0],grav[1],grav[2]); - - const btVector3 c[]={ p+h*btVector3(-1,-1,-1), - p+h*btVector3(+1,-1,-1), - p+h*btVector3(-1,+1,-1), - p+h*btVector3(+1,+1,-1), - p+h*btVector3(-1,-1,+1), - p+h*btVector3(+1,-1,+1), - p+h*btVector3(-1,+1,+1), - p+h*btVector3(+1,+1,+1)}; - - int i=0; - const int n=15; + grav[0] = softDynaWorld->getGravity().getX(); + grav[1] = softDynaWorld->getGravity().getY(); + grav[2] = softDynaWorld->getGravity().getZ(); + softDynaWorld->getWorldInfo().m_gravity.setValue(grav[0],grav[1],grav[2]); //?? + + //btSoftBody* psb=btSoftBodyHelpers::CreateRope(sbi, btVector3(-10,0,i*0.25),btVector3(10,0,i*0.25), 16,1+2); - btSoftBody* psb = btSoftBodyHelpers::CreateFromConvexHull(sbi,c,8); - m_object = psb;//btSoftBodyHelpers::CreateFromTriMesh(sbi,&pts[0].getX(),triangles,numtriangles); + btSoftBody* psb = 0; + + if (m_cci.m_collisionShape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE) + { + btConvexHullShape* convexHull = (btConvexHullShape* )m_cci.m_collisionShape; + btAlignedObjectArray transformedVertices; + transformedVertices.resize(convexHull->getNumPoints()); + for (int i=0;igetNumPoints();i++) + { + transformedVertices[i] = trans(convexHull->getPoints()[i]); + } + + //psb = btSoftBodyHelpers::CreateFromConvexHull(sbi,&transformedVertices[0],convexHull->getNumPoints()); + + { + int nvertices = convexHull->getNumPoints(); + const btVector3* vertices = &transformedVertices[0]; + btSoftBodyWorldInfo& worldInfo = softDynaWorld->getWorldInfo(); + + HullDesc hdsc(QF_TRIANGLES,nvertices,vertices); + HullResult hres; + HullLibrary hlib;/*??*/ + hdsc.mMaxVertices=nvertices; + hlib.CreateConvexHull(hdsc,hres); + + psb=new btSoftBody(&worldInfo,(int)hres.mNumOutputVertices, + &hres.m_OutputVertices[0],0); + for(int i=0;i<(int)hres.mNumFaces;++i) + { + const int idx[]={ hres.m_Indices[i*3+0], + hres.m_Indices[i*3+1], + hres.m_Indices[i*3+2]}; + if(idx[0]appendLink( idx[0],idx[1]); + if(idx[1]appendLink( idx[1],idx[2]); + if(idx[2]appendLink( idx[2],idx[0]); + psb->appendFace(idx[0],idx[1],idx[2]); + } + + { + for (int i=0;im_userIndexMapping.push_back(hlib.m_vertexIndexMapping[i]); + //psb->m_userIndexMapping.push_back(hres.m_Indices[i]); + } + + hlib.ReleaseResult(hres); + psb->randomizeConstraints(); + + } + + - psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS;//btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS; - sbi.m_sparsesdf.Reset(); - sbi.m_sparsesdf.Initialize(); - psb->generateBendingConstraints(2); - psb->m_cfg.kDF=1; - psb->activate(); - psb->setActivationState(1); - psb->setDeactivationTime(1.f); - psb->m_cfg.piterations = 4; + } else + { + /* + if (m_cci.m_collisionShape->getShapeType() ==SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE) + { + btScaledBvhTriangleMeshShape* scaledtrimeshshape = (btScaledBvhTriangleMeshShape*) m_cci.m_collisionShape; + btBvhTriangleMeshShape* trimeshshape = scaledtrimeshshape->getChildShape(); + + ///only deal with meshes that have 1 sub part/component, for now + if (trimeshshape->getMeshInterface()->getNumSubParts()==1) + { + unsigned char* vertexBase; + PHY_ScalarType vertexType; + int numverts; + int vertexstride; + unsigned char* indexbase; + int indexstride; + int numtris; + PHY_ScalarType indexType; + trimeshshape->getMeshInterface()->getLockedVertexIndexBase(&vertexBase,numverts,vertexType,vertexstride,&indexbase,indexstride,numtris,indexType); + + psb = btSoftBodyHelpers::CreateFromTriMesh(sbi,(const btScalar*)vertexBase,(const int*)indexbase,numtris); + } + } else + { + btBvhTriangleMeshShape* trimeshshape = (btBvhTriangleMeshShape*) m_cci.m_collisionShape; + ///only deal with meshes that have 1 sub part/component, for now + if (trimeshshape->getMeshInterface()->getNumSubParts()==1) + { + unsigned char* vertexBase; + PHY_ScalarType vertexType; + int numverts; + int vertexstride; + unsigned char* indexbase; + int indexstride; + int numtris; + PHY_ScalarType indexType; + trimeshshape->getMeshInterface()->getLockedVertexIndexBase(&vertexBase,numverts,vertexType,vertexstride,&indexbase,indexstride,numtris,indexType); + + psb = btSoftBodyHelpers::CreateFromTriMesh(sbi,(const btScalar*)vertexBase,(const int*)indexbase,numtris); + } + + + //psb = btSoftBodyHelpers::CreateFromTriMesh(sbi,&pts[0].getX(),triangles,numtriangles); + } + */ + + } + + + m_object = psb; + + //psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS;//btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS; + psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::CL_SS; + + //btSoftBody::Material* pm=psb->appendMaterial(); + btSoftBody::Material* pm=psb->m_materials[0]; + pm->m_kLST = 0.1f; + //pm->m_kAST = 0.01f; + //pm->m_kVST = 0.001f; + psb->generateBendingConstraints(2,pm); +/* + psb->m_cfg.kDF = 0.1f;//1.f; + psb->m_cfg.kDP = 0.0001; + //psb->m_cfg.kDP = 0.005; + psb->m_cfg.kCHR = 0.1; + //psb->m_cfg.kVCF = 0.1f; + psb->m_cfg.kVCF = 0.0001f; + //psb->m_cfg.kAHR = 0.1f; + psb->m_cfg.kAHR = 0.0001f; + psb->m_cfg.kMT = 0.1f; + //psb->m_cfg.kDF=1; + */ + +// psb->activate(); +// psb->setActivationState(1); +// psb->setDeactivationTime(1.f); + //psb->m_cfg.piterations = 4; //psb->m_materials[0]->m_kLST = 0.1+(i/(btScalar)(n-1))*0.9; - psb->setTotalMass(20); + psb->setTotalMass(m_cci.m_mass); + psb->generateClusters(64); psb->setCollisionFlags(0); - - m_object->setCollisionShape(rbci.m_collisionShape); +// m_object->setCollisionShape(rbci.m_collisionShape); btTransform startTrans; if (rbci.m_motionState) @@ -218,8 +330,13 @@ void CcdPhysicsController::CreateRigidbody() { startTrans = rbci.m_startWorldTransform; } + startTrans.setIdentity(); + m_object->setWorldTransform(startTrans); m_object->setInterpolationWorldTransform(startTrans); + m_MotionState->setWorldPosition(0,0,0); + m_MotionState->setWorldOrientation(0,0,0,1); + } else { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 96aa9ad164e..8c5aae3f8c9 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -452,6 +452,8 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) } + + void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctrl) { //also remove constraint diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 9b6a76d49ee..56a639509c5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -216,7 +216,10 @@ protected: void SyncMotionStates(float timeStep); - + class btSoftRigidDynamicsWorld* getDynamicsWorld() + { + return m_dynamicsWorld; + } class btConstraintSolver* GetConstraintSolver(); -- cgit v1.2.3 From 38a80ff9a5c6d7bebef42bc3b8320d781b4e4f1c Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 24 Sep 2008 22:58:49 +0000 Subject: BGE patch: add advanced parameters for SoftBody. Add Rasterizer.drawLine() Python function. --- source/gameengine/Ketsji/KX_PythonInit.cpp | 32 ++++++++++++++++++++++++++++++ source/gameengine/PyDoc/Rasterizer.py | 11 ++++++++++ 2 files changed, 43 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 95693efe30e..3e271be7984 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -797,6 +797,36 @@ static PyObject* gPyGetMaterialType(PyObject*) return PyInt_FromLong(flag); } +static PyObject* gPyDrawLine(PyObject*, PyObject* args) +{ + PyObject* ob_from; + PyObject* ob_to; + PyObject* ob_color; + + if (!gp_Rasterizer) { + PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available"); + return NULL; + } + + if (!PyArg_ParseTuple(args,"OOO",&ob_from,&ob_to,&ob_color)) + return NULL; + + MT_Vector3 from(0., 0., 0.); + MT_Vector3 to(0., 0., 0.); + MT_Vector3 color(0., 0., 0.); + if (!PyVecTo(ob_from, from)) + return NULL; + if (!PyVecTo(ob_to, to)) + return NULL; + if (!PyVecTo(ob_color, color)) + return NULL; + + gp_Rasterizer->DrawDebugLine(from,to,color); + + Py_RETURN_NONE; +} + + STR_String gPyGetWindowHeight__doc__="getWindowHeight doc"; STR_String gPyGetWindowWidth__doc__="getWindowWidth doc"; STR_String gPyEnableVisibility__doc__="enableVisibility doc"; @@ -838,6 +868,8 @@ static struct PyMethodDef rasterizer_methods[] = { METH_VARARGS, "set the state of a GLSL material setting"}, {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting, METH_VARARGS, "get the state of a GLSL material setting"}, + {"drawLine", (PyCFunction) gPyDrawLine, + METH_VARARGS, "draw a line on the screen"}, { NULL, (PyCFunction) NULL, 0, NULL } }; diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py index ebb5332d98d..cdda87fcb49 100644 --- a/source/gameengine/PyDoc/Rasterizer.py +++ b/source/gameengine/PyDoc/Rasterizer.py @@ -181,4 +181,15 @@ def getGLSLMaterialSetting(setting, enable): @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) @rtype: boolean """ +def drawLine(from,to,color): + """ + Draw a line in the 3D scene. + + @param from: the origin of the line + @type from: list [x, y, z] + @param to: the end of the line + @type to: list [x, y, z] + @param color: the color of the line + @type color: list [r, g, b] + """ -- cgit v1.2.3 From 718e2bf74f0ba2dcabe5bee7d88c1975ecfe9f06 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 25 Sep 2008 03:02:30 +0000 Subject: improved game soft bodies, works for objects that are using 'set smooth' use shape matching by default for game soft bodies store soft body index for game vertices --- .../Converter/BL_BlenderDataConversion.cpp | 7 + source/gameengine/Ketsji/KX_ConvertPhysicsObject.h | 6 + .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 180 ++++++++++----------- .../Physics/Bullet/CcdPhysicsController.cpp | 100 +++++++++++- .../Physics/Bullet/CcdPhysicsController.h | 10 ++ source/gameengine/Rasterizer/RAS_TexVert.h | 21 ++- 6 files changed, 217 insertions(+), 107 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 6a5048a9f15..b3df2d7bc85 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1321,6 +1321,13 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0; objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0; objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; + + ///for game soft bodies + objprop.m_linearStiffness = blenderobject->linearStiffness; + objprop.m_angularStiffness = blenderobject->angularStiffness; + objprop.m_volumePreservation = blenderobject->volumePreservation; + objprop.m_gamesoftFlag = blenderobject->gamesoftFlag; + objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag //mmm, for now, taks this for the size of the dynamicobject diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h index 2b6c2535878..6325c9365fd 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h @@ -87,6 +87,12 @@ struct KX_ObjectProperties bool m_disableSleeping; bool m_hasCompoundChildren; bool m_isCompoundChild; + + float m_linearStiffness; + float m_angularStiffness; + float m_volumePreservation; + int m_gamesoftFlag; + double m_margin; KX_BoundBoxClass m_boundclass; union { diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index c4411a58856..5744a860e92 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -667,6 +667,85 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, #endif //WIN32 + + class KX_SoftBodyDeformer : public RAS_Deformer + { + btSoftBody* m_softBody; + class RAS_MeshObject* m_pMeshObject; + class BL_DeformableGameObject* m_gameobj; + + + public: + KX_SoftBodyDeformer(btSoftBody* softBody,RAS_MeshObject* pMeshObject,BL_DeformableGameObject* gameobj) + : m_softBody(softBody), + m_pMeshObject(pMeshObject), + m_gameobj(gameobj) + { + //printf("KX_SoftBodyDeformer\n"); + }; + + virtual ~KX_SoftBodyDeformer() + { + //printf("~KX_SoftBodyDeformer\n"); + }; + virtual void Relink(GEN_Map*map) + { + //printf("relink\n"); + } + virtual bool Apply(class RAS_IPolyMaterial *polymat) + { + //printf("apply\n"); + RAS_MeshSlot::iterator it; + RAS_MeshMaterial *mmat; + RAS_MeshSlot *slot; + size_t i; + + // update the vertex in m_transverts + Update(); + + // The vertex cache can only be updated for this deformer: + // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) + // share the same mesh (=the same cache). As the rendering is done per polymaterial + // cycling through the objects, the entire mesh cache cannot be updated in one shot. + mmat = m_pMeshObject->GetMeshMaterial(polymat); + if(!mmat->m_slots[(void*)m_gameobj]) + return true; + + slot = *mmat->m_slots[(void*)m_gameobj]; + + // for each array + for(slot->begin(it); !slot->end(it); slot->next(it)) + { + btSoftBody::tNodeArray& nodes(m_softBody->m_nodes); + + int index = 0; + for(i=it.startvertex; im_ang_drag; //need a bit of damping, else system doesn't behave well ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour + ci.m_linearStiffness = objprop->m_linearStiffness; + ci.m_angularStiffness= objprop->m_angularStiffness; + ci.m_volumePreservation= objprop->m_volumePreservation; + ci.m_gamesoftFlag = objprop->m_gamesoftFlag; + ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter); ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody; @@ -990,107 +1074,15 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, physicscontroller->SetObject(gameobj->GetSGNode()); - class KX_SoftBodyDeformer : public RAS_Deformer - { - btSoftBody* m_softBody; - class BL_SkinMeshObject* m_pMeshObject; - class BL_DeformableGameObject* m_gameobj; - - - public: - KX_SoftBodyDeformer(btSoftBody* softBody,BL_SkinMeshObject* pMeshObject,BL_DeformableGameObject* gameobj) - : m_softBody(softBody), - m_pMeshObject(pMeshObject), - m_gameobj(gameobj) - { - //printf("KX_SoftBodyDeformer\n"); - }; - - virtual ~KX_SoftBodyDeformer() - { - //printf("~KX_SoftBodyDeformer\n"); - }; - virtual void Relink(GEN_Map*map) - { - //printf("relink\n"); - } - virtual bool Apply(class RAS_IPolyMaterial *polymat) - { - //printf("apply\n"); - RAS_MeshSlot::iterator it; - RAS_MeshMaterial *mmat; - RAS_MeshSlot *slot; - size_t i; - - // update the vertex in m_transverts - Update(); - - // The vertex cache can only be updated for this deformer: - // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) - // share the same mesh (=the same cache). As the rendering is done per polymaterial - // cycling through the objects, the entire mesh cache cannot be updated in one shot. - mmat = m_pMeshObject->GetMeshMaterial(polymat); - if(!mmat->m_slots[(void*)m_gameobj]) - return true; - - slot = *mmat->m_slots[(void*)m_gameobj]; - - // for each array - for(slot->begin(it); !slot->end(it); slot->next(it)) - { - // for each vertex - // copy the untransformed data from the original mvert - int count = 0; - { - - for(i=it.startvertex; im_nodes); - - if (count == m_softBody->m_userIndexMapping.size()) - { - int index = 0; - for(i=it.startvertex; im_userIndexMapping[index]].m_x.getX(), - nodes[m_softBody->m_userIndexMapping[index]].m_x.getY(), - nodes[m_softBody->m_userIndexMapping[index]].m_x.getZ()); - v.SetXYZ(pt); - - //(m_transverts[v.getOrigIndex()]); - } - } - - } - - return true; - } - virtual bool Update(void) - { - //printf("update\n"); - return true;//?? - } - virtual RAS_Deformer *GetReplica() - { - //printf("getReplica\n"); - return 0; - } - protected: - //class RAS_MeshObject *m_pMesh; - }; ///test for soft bodies if (objprop->m_softbody && physicscontroller) { btSoftBody* softBody = physicscontroller->GetSoftBody(); - if (softBody && gameobj->GetMesh(0)) + if (softBody && gameobj->GetMesh(0))//only the first mesh, if any { //should be a mesh then, so add a soft body deformer - KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer(softBody, (BL_SkinMeshObject*)gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj); + KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer(softBody, gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj); gameobj->SetDeformer(softbodyDeformer); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index ad79db16dc4..333ecd6ea11 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -222,14 +222,57 @@ void CcdPhysicsController::CreateRigidbody() psb->appendFace(idx[0],idx[1],idx[2]); } + ///create a mapping between graphics mesh vertices and soft body vertices { - for (int i=0;im_userIndexMapping.push_back(hlib.m_vertexIndexMapping[i]); - //psb->m_userIndexMapping.push_back(hres.m_Indices[i]); + RAS_MeshObject* rasMesh= GetShapeInfo()->GetMesh(); + + if (rasMesh) + { + + //printf("apply\n"); + RAS_MeshSlot::iterator it; + RAS_MeshMaterial *mmat; + RAS_MeshSlot *slot; + size_t i; + + //for each material + for (int m=0;mNumMaterials();m++) + { + // The vertex cache can only be updated for this deformer: + // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) + // share the same mesh (=the same cache). As the rendering is done per polymaterial + // cycling through the objects, the entire mesh cache cannot be updated in one shot. + mmat = rasMesh->GetMeshMaterial(m); + + slot = mmat->m_baseslot; + for(slot->begin(it); !slot->end(it); slot->next(it)) + { + int index = 0; + for(i=it.startvertex; isetSoftBodyIndex(0); + btScalar maxDistSqr = 1e30; + btSoftBody::tNodeArray& nodes(psb->m_nodes); + btVector3 xyz = trans(btVector3(vertex->getXYZ()[0],vertex->getXYZ()[1],vertex->getXYZ()[2])); + for (int n=0;nsetSoftBodyIndex(n); + } + } + } + } + } + } } hlib.ReleaseResult(hres); - psb->randomizeConstraints(); + } @@ -292,13 +335,42 @@ void CcdPhysicsController::CreateRigidbody() //psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS;//btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS; psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::CL_SS; + //psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS + btSoftBody::fCollision::CL_RS; //btSoftBody::Material* pm=psb->appendMaterial(); btSoftBody::Material* pm=psb->m_materials[0]; - pm->m_kLST = 0.1f; + + pm->m_kLST = m_cci.m_linearStiffness; + pm->m_kAST = m_cci.m_angularStiffness; + pm->m_kVST = m_cci.m_volumePreservation; + + + + //pm->m_kAST = 0.01f; //pm->m_kVST = 0.001f; psb->generateBendingConstraints(2,pm); + //psb->m_cfg.piterations = 4; + //psb->m_cfg.viterations = 4; + //psb->m_cfg.diterations = 4; + //psb->m_cfg.citerations = 4; + if (m_cci.m_gamesoftFlag & 1)///OB_SOFT_SHAPE_MATCHING) + { + psb->setPose(false,true);// + } else + { + psb->setPose(true,false); + } + + psb->m_cfg.kDF = 0.5; + psb->m_cfg.kMT = 0.05; + psb->m_cfg.piterations = 5; + + psb->m_cfg.piterations = 5; + //psb->m_cfg.kVC = 20; + + psb->randomizeConstraints(); + /* psb->m_cfg.kDF = 0.1f;//1.f; psb->m_cfg.kDP = 0.0001; @@ -315,10 +387,10 @@ void CcdPhysicsController::CreateRigidbody() // psb->activate(); // psb->setActivationState(1); // psb->setDeactivationTime(1.f); - //psb->m_cfg.piterations = 4; + //psb->m_materials[0]->m_kLST = 0.1+(i/(btScalar)(n-1))*0.9; psb->setTotalMass(m_cci.m_mass); - psb->generateClusters(64); + //psb->generateClusters(8);//(64); psb->setCollisionFlags(0); // m_object->setCollisionShape(rbci.m_collisionShape); btTransform startTrans; @@ -1147,7 +1219,19 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) { const float* vtx = poly->GetVertex(i)->getXYZ(); btPoint3 point(vtx[0],vtx[1],vtx[2]); - m_vertexArray.push_back(point); + //avoid duplicates (could better directly use vertex offsets, rather than a vertex compare) + bool found = false; + for (int j=0;j Date: Thu, 25 Sep 2008 16:19:07 +0000 Subject: BGE patch: add Debug button next to object state. The object state mask will be printed at runtime with the debug info as a comma separated list of state numbers (1..30) for each active state bit. The reserved property name __state__ is used for that purpose (users should not create a property with that name). --- .../gameengine/Converter/KX_ConvertProperties.cpp | 8 +++- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 48 ++++++++++++++++++---- 2 files changed, 45 insertions(+), 11 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index aae8752671f..dfbc6f0c48d 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -132,6 +132,10 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan prop = prop->next; } - - + // check if state needs to be debugged + if (object->scaflag & OB_DEBUGSTATE) + { + // reserve name for object state + scene->AddDebugProperty(gameobj,STR_String("__state__")); + } } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index c7b0d7b3ea3..b1ab8e3e7de 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1243,19 +1243,49 @@ void KX_KetsjiEngine::RenderDebugProperties() CValue* propobj = (*it)->m_obj; STR_String objname = propobj->GetName(); STR_String propname = (*it)->m_name; - CValue* propval = propobj->GetProperty(propname); - if (propval) + if (propname == "__state__") { - STR_String text = propval->GetText(); - debugtxt = objname + "." + propname + " = " + text; + // reserve name for object state + KX_GameObject* gameobj = static_cast(propobj); + unsigned int state = gameobj->GetState(); + debugtxt = objname + "." + propname + " = "; + bool first = true; + for (int statenum=1;state;state >>= 1, statenum++) + { + if (state & 1) + { + if (!first) + { + debugtxt += ","; + } + debugtxt += STR_String(statenum); + first = false; + } + } m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, - debugtxt.Ptr(), - xcoord, - ycoord, - m_canvas->GetWidth(), - m_canvas->GetHeight()); + debugtxt.Ptr(), + xcoord, + ycoord, + m_canvas->GetWidth(), + m_canvas->GetHeight()); ycoord += 14; } + else + { + CValue* propval = propobj->GetProperty(propname); + if (propval) + { + STR_String text = propval->GetText(); + debugtxt = objname + "." + propname + " = " + text; + m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED, + debugtxt.Ptr(), + xcoord, + ycoord, + m_canvas->GetWidth(), + m_canvas->GetHeight()); + ycoord += 14; + } + } } } } -- cgit v1.2.3 From bc28feb997b05d61d2d1e971137be489c780dcbc Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 25 Sep 2008 16:48:25 +0000 Subject: re-use some Blender soft body settings for Bullet game soft bodies --- .../gameengine/Converter/BL_BlenderDataConversion.cpp | 19 +++++++++++++++---- .../Physics/Bullet/CcdPhysicsController.cpp | 5 ++--- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index b3df2d7bc85..5b72a10cd0d 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -129,6 +129,7 @@ #include "DNA_sound_types.h" #include "DNA_key_types.h" #include "DNA_armature_types.h" +#include "DNA_object_force.h" #include "MEM_guardedalloc.h" #include "BKE_utildefines.h" @@ -1323,10 +1324,20 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; ///for game soft bodies - objprop.m_linearStiffness = blenderobject->linearStiffness; - objprop.m_angularStiffness = blenderobject->angularStiffness; - objprop.m_volumePreservation = blenderobject->volumePreservation; - objprop.m_gamesoftFlag = blenderobject->gamesoftFlag; + if (blenderobject->soft) + { + objprop.m_linearStiffness = blenderobject->soft->inspring; + objprop.m_angularStiffness = 1.f;//blenderobject->angularStiffness; + objprop.m_volumePreservation = 1.f;//blenderobject->volumePreservation; + objprop.m_gamesoftFlag = blenderobject->softflag;//blenderobject->gamesoftFlag; + + } else + { + objprop.m_linearStiffness = 0.5;//blenderobject->linearStiffness; + objprop.m_angularStiffness = 1.f;//blenderobject->angularStiffness; + objprop.m_volumePreservation = 1.f;//blenderobject->volumePreservation; + objprop.m_gamesoftFlag = 1;//blenderobject->gamesoftFlag; + } objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 333ecd6ea11..b24ff42a495 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -346,7 +346,6 @@ void CcdPhysicsController::CreateRigidbody() - //pm->m_kAST = 0.01f; //pm->m_kVST = 0.001f; psb->generateBendingConstraints(2,pm); @@ -354,7 +353,7 @@ void CcdPhysicsController::CreateRigidbody() //psb->m_cfg.viterations = 4; //psb->m_cfg.diterations = 4; //psb->m_cfg.citerations = 4; - if (m_cci.m_gamesoftFlag & 1)///OB_SOFT_SHAPE_MATCHING) + if (m_cci.m_gamesoftFlag & 2)//OB_SB_GOAL) { psb->setPose(false,true);// } else @@ -390,7 +389,7 @@ void CcdPhysicsController::CreateRigidbody() //psb->m_materials[0]->m_kLST = 0.1+(i/(btScalar)(n-1))*0.9; psb->setTotalMass(m_cci.m_mass); - //psb->generateClusters(8);//(64); + psb->generateClusters(8);//(64); psb->setCollisionFlags(0); // m_object->setCollisionShape(rbci.m_collisionShape); btTransform startTrans; -- cgit v1.2.3 From 27098d3aa019a010f83f94ce935a6de63680ca2c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 25 Sep 2008 17:43:06 +0000 Subject: [#17679] BGE print statement when start and when finish from Dalai Felinto (dfelinto) would useually not encourage prints in these cases, except its often useful to know if an error happened since you last pressed Pkey and without this you end up needing to manually clear the terminal. --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 6a296a3e244..cc141249561 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -359,6 +359,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, ketsjiengine->SetAnimFrameRate( (((double) blscene->r.frs_sec) / blscene->r.frs_sec_base) ); // the mainloop + printf("\nBlender Game Engine Started\n\n"); while (!exitrequested) { // first check if we want to exit @@ -394,6 +395,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, mousedevice->ConvertBlenderEvent(event,val); } } + printf("\nBlender Game Engine Finished\n\n"); exitstring = ketsjiengine->GetExitString(); // when exiting the mainloop -- cgit v1.2.3 From 9c08e86b062fe2faa69894faccdc0e2ce2d8190d Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 25 Sep 2008 17:53:15 +0000 Subject: avoid crash and apply force for soft bodies. copy normals for soft body vertices, to get proper lighting --- .../Ketsji/KX_BulletPhysicsController.cpp | 25 +++++++++++------ .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 7 +++++ .../Physics/Bullet/CcdPhysicsController.cpp | 31 ++++++++++++++-------- 3 files changed, 44 insertions(+), 19 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index 539eaec4a7b..d7bd1e9c7cd 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -14,6 +14,7 @@ #include "PHY_IPhysicsEnvironment.h" #include "CcdPhysicsEnvironment.h" +#include "BulletSoftBody/btSoftBody.h" KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna) @@ -148,8 +149,12 @@ void KX_BulletPhysicsController::setScaling(const MT_Vector3& scaling) } MT_Scalar KX_BulletPhysicsController::GetMass() { - - MT_Scalar invmass = GetRigidBody()->getInvMass(); + if (GetSoftBody()) + return GetSoftBody()->getTotalMass(); + + MT_Scalar invmass = 0.f; + if (GetRigidBody()) + invmass = GetRigidBody()->getInvMass(); if (invmass) return 1.f/invmass; return 0.f; @@ -167,7 +172,7 @@ void KX_BulletPhysicsController::setRigidBody(bool rigid) void KX_BulletPhysicsController::SuspendDynamics(bool ghost) { btRigidBody *body = GetRigidBody(); - if (body->getActivationState() != DISABLE_SIMULATION) + if (body && body->getActivationState() != DISABLE_SIMULATION) { btBroadphaseProxy* handle = body->getBroadphaseHandle(); m_savedCollisionFlags = body->getCollisionFlags(); @@ -186,7 +191,7 @@ void KX_BulletPhysicsController::SuspendDynamics(bool ghost) void KX_BulletPhysicsController::RestoreDynamics() { btRigidBody *body = GetRigidBody(); - if (body->getActivationState() == DISABLE_SIMULATION) + if (body && body->getActivationState() == DISABLE_SIMULATION) { GetPhysicsEnvironment()->updateCcdPhysicsController(this, m_savedMass, @@ -241,18 +246,22 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode) void KX_BulletPhysicsController::SetSumoTransform(bool nondynaonly) { - GetRigidBody()->activate(true); + if (GetRigidBody()) + GetRigidBody()->activate(true); if (!m_bDyna) { - GetRigidBody()->setCollisionFlags(GetRigidBody()->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + GetCollisionObject()->setCollisionFlags(GetRigidBody()->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } else { if (!nondynaonly) { btTransform worldTrans; - GetRigidBody()->getMotionState()->getWorldTransform(worldTrans); - GetRigidBody()->setCenterOfMassTransform(worldTrans); + if (GetRigidBody()) + { + GetRigidBody()->getMotionState()->getWorldTransform(worldTrans); + GetRigidBody()->setCenterOfMassTransform(worldTrans); + } /* scaling? diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 5744a860e92..f90df047ca0 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -727,6 +727,13 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, nodes[v.getSoftBodyIndex()].m_x.getY(), nodes[v.getSoftBodyIndex()].m_x.getZ()); v.SetXYZ(pt); + + MT_Vector3 normal ( + nodes[v.getSoftBodyIndex()].m_n.getX(), + nodes[v.getSoftBodyIndex()].m_n.getY(), + nodes[v.getSoftBodyIndex()].m_n.getZ()); + v.SetNormal(normal); + } } return true; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index b24ff42a495..f8dc81e0f3d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -862,15 +862,20 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } - btRigidBody* body = GetRigidBody(); - if (body) { - btTransform xform = body->getCenterOfMassTransform(); + btTransform xform = m_object->getWorldTransform(); + if (local) { force = xform.getBasis()*force; } - body->applyCentralForce(force); + btRigidBody* body = GetRigidBody(); + if (body) + body->applyCentralForce(force); + btSoftBody* soft = GetSoftBody(); + if (soft) + soft->addForce(force); + } } } @@ -884,15 +889,16 @@ void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo { m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } - btRigidBody* body = GetRigidBody(); - if (body) { - btTransform xform = body->getCenterOfMassTransform(); + btTransform xform = m_object->getWorldTransform(); if (local) { angvel = xform.getBasis()*angvel; } - body->setAngularVelocity(angvel); + btRigidBody* body = GetRigidBody(); + if (body) + body->setAngularVelocity(angvel); + } } @@ -908,15 +914,17 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa { m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } - btRigidBody* body = GetRigidBody(); - if (body) + { btTransform xform = m_object->getWorldTransform(); if (local) { linVel = xform.getBasis()*linVel; } - body->setLinearVelocity(linVel); + btRigidBody* body = GetRigidBody(); + if (body) + body->setLinearVelocity(linVel); + } } } @@ -936,6 +944,7 @@ void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attac btRigidBody* body = GetRigidBody(); if (body) body->applyImpulse(impulse,pos); + } } -- cgit v1.2.3 From 6732718ef1b7f212e2368cf237c08d72f13d06ab Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 25 Sep 2008 21:04:41 +0000 Subject: don't apply vertex transformation for deformable game soft bodies. set a fake world transform for game soft bodies, based on center of the AABB, so visiblity and some game logic works. note: this world transform is not smooth. --- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 14 ++++++++++--- .../Physics/Bullet/CcdPhysicsController.cpp | 24 ++++++++++++++++++---- source/gameengine/Rasterizer/RAS_Deformer.h | 4 ++++ .../gameengine/Rasterizer/RAS_MaterialBucket.cpp | 5 ++++- 4 files changed, 39 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index f90df047ca0..7e684e5d5b7 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -672,11 +672,11 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, { btSoftBody* m_softBody; class RAS_MeshObject* m_pMeshObject; - class BL_DeformableGameObject* m_gameobj; + class KX_GameObject* m_gameobj; public: - KX_SoftBodyDeformer(btSoftBody* softBody,RAS_MeshObject* pMeshObject,BL_DeformableGameObject* gameobj) + KX_SoftBodyDeformer(btSoftBody* softBody,RAS_MeshObject* pMeshObject,KX_GameObject* gameobj) : m_softBody(softBody), m_pMeshObject(pMeshObject), m_gameobj(gameobj) @@ -703,6 +703,8 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, // update the vertex in m_transverts Update(); + + // The vertex cache can only be updated for this deformer: // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) // share the same mesh (=the same cache). As the rendering is done per polymaterial @@ -748,6 +750,12 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, //printf("getReplica\n"); return 0; } + + virtual bool SkipVertexTransform() + { + return true; + } + protected: //class RAS_MeshObject *m_pMesh; }; @@ -1089,7 +1097,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, if (softBody && gameobj->GetMesh(0))//only the first mesh, if any { //should be a mesh then, so add a soft body deformer - KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer(softBody, gameobj->GetMesh(0),(BL_DeformableGameObject*)gameobj); + KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer(softBody, gameobj->GetMesh(0),gameobj); gameobj->SetDeformer(softbodyDeformer); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index f8dc81e0f3d..29ee0310c58 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -401,13 +401,17 @@ void CcdPhysicsController::CreateRigidbody() { startTrans = rbci.m_startWorldTransform; } - startTrans.setIdentity(); + //startTrans.setIdentity(); - m_object->setWorldTransform(startTrans); - m_object->setInterpolationWorldTransform(startTrans); - m_MotionState->setWorldPosition(0,0,0); + //m_object->setWorldTransform(startTrans); + //m_object->setInterpolationWorldTransform(startTrans); + m_MotionState->setWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ()); m_MotionState->setWorldOrientation(0,0,0,1); +// btVector3 wp = m_softBody->getWorldTransform().getOrigin(); +// MT_Point3 center(wp.getX(),wp.getY(),wp.getZ()); +// m_gameobj->NodeSetWorldPosition(center); + } else { @@ -502,10 +506,22 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time) { //sync non-static to motionstate, and static from motionstate (todo: add kinematic etc.) + btSoftBody* sb = GetSoftBody(); + if (sb) + { + btVector3 aabbMin,aabbMax; + sb->getAabb(aabbMin,aabbMax); + btVector3 worldPos = (aabbMax+aabbMin)*0.5f; + m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); + m_MotionState->calculateWorldTransformations(); + return true; + } + btRigidBody* body = GetRigidBody(); if (body && !body->isStaticObject()) { + const btVector3& worldPos = body->getCenterOfMassPosition(); m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]); diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 4e8484ab880..6665e1926cf 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -45,6 +45,10 @@ public: virtual bool Apply(class RAS_IPolyMaterial *polymat)=0; virtual bool Update(void)=0; virtual RAS_Deformer *GetReplica()=0; + virtual bool SkipVertexTransform() + { + return false; + } protected: class RAS_MeshObject *m_pMesh; }; diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 2b129f51609..ad8d7ebd5b0 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -539,7 +539,10 @@ void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRa ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix)); rendertools->PushMatrix(); - rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode()); + if (!ms.m_pDeformer || !ms.m_pDeformer->SkipVertexTransform()) + { + rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode()); + } if(rasty->QueryLists()) if(ms.m_DisplayList) -- cgit v1.2.3 From a1bef84ea859cf85487d4cac8664402dd86f4465 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Fri, 26 Sep 2008 02:27:59 +0000 Subject: Allow Bullet soft bodies to be created using a AddObject actuator. Added a fake world coordinate system to game soft bodies, although the vertices are already in world space. Added Bullet/Gimpact concave collision detection to Blender. If your build system isn't updated yet, please add extern/bullet2/src/BulletCollision/Gimpact/* This allows moving/dynamic concave triangle meshes (decomposing meshes into compound convex shapes, and using 'compound' shapes is still preferred) --- .../Converter/BL_DeformableGameObject.cpp | 2 +- source/gameengine/Converter/BL_MeshDeformer.h | 2 +- source/gameengine/Converter/BL_ShapeDeformer.cpp | 2 +- source/gameengine/Converter/BL_ShapeDeformer.h | 2 +- source/gameengine/Converter/BL_SkinDeformer.cpp | 2 +- source/gameengine/Converter/BL_SkinDeformer.h | 2 +- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 35 +++++--- .../Physics/Bullet/CcdPhysicsController.cpp | 97 +++++++++++++++++----- .../Physics/Bullet/CcdPhysicsController.h | 13 ++- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 5 +- source/gameengine/Rasterizer/RAS_Deformer.h | 2 +- source/gameengine/Rasterizer/RAS_TexVert.cpp | 1 + 12 files changed, 120 insertions(+), 45 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp index 1d62a41cce9..e2610d2b405 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.cpp +++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp @@ -47,7 +47,7 @@ void BL_DeformableGameObject::ProcessReplica(KX_GameObject* replica) KX_GameObject::ProcessReplica(replica); if (m_pDeformer) { - deformer = (BL_MeshDeformer*)m_pDeformer->GetReplica(); + deformer = (BL_MeshDeformer*)m_pDeformer->GetReplica(replica); ((BL_DeformableGameObject*)replica)->m_pDeformer = deformer; } diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 9d3d2e78123..8de59c1cdf3 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -64,7 +64,7 @@ public: virtual void SetSimulatedTime(double time){}; virtual bool Apply(class RAS_IPolyMaterial *mat); virtual bool Update(void){ return false; }; - virtual RAS_Deformer* GetReplica(){return NULL;}; + virtual RAS_Deformer* GetReplica(class KX_GameObject* replica){return NULL;}; struct Mesh* GetMesh() { return m_bmesh; }; // virtual void InitDeform(double time){}; diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index dfd33e45fef..fc6498579ad 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -68,7 +68,7 @@ BL_ShapeDeformer::~BL_ShapeDeformer() { }; -RAS_Deformer *BL_ShapeDeformer::GetReplica() +RAS_Deformer *BL_ShapeDeformer::GetReplica(class KX_GameObject* replica) { BL_ShapeDeformer *result; diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 1465bb01e22..90b9f5caea1 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -66,7 +66,7 @@ public: }; virtual void ProcessReplica(); - virtual RAS_Deformer *GetReplica(); + virtual RAS_Deformer *GetReplica(class KX_GameObject* replica); virtual ~BL_ShapeDeformer(); bool Update (void); diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index b7b39ad7fbf..d8563763954 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -146,7 +146,7 @@ bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat) return true; } -RAS_Deformer *BL_SkinDeformer::GetReplica() +RAS_Deformer *BL_SkinDeformer::GetReplica(class KX_GameObject* replica) { BL_SkinDeformer *result; diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h index e08de8c478a..f87860021c6 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.h +++ b/source/gameengine/Converter/BL_SkinDeformer.h @@ -67,7 +67,7 @@ public: BL_ArmatureObject* arma = NULL); virtual void ProcessReplica(); - virtual RAS_Deformer *GetReplica(); + virtual RAS_Deformer *GetReplica(class KX_GameObject* replica); virtual ~BL_SkinDeformer(); bool Update (void); bool Apply (class RAS_IPolyMaterial *polymat); diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 7e684e5d5b7..ddf1f402431 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -670,15 +670,12 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, class KX_SoftBodyDeformer : public RAS_Deformer { - btSoftBody* m_softBody; class RAS_MeshObject* m_pMeshObject; class KX_GameObject* m_gameobj; - public: - KX_SoftBodyDeformer(btSoftBody* softBody,RAS_MeshObject* pMeshObject,KX_GameObject* gameobj) - : m_softBody(softBody), - m_pMeshObject(pMeshObject), + KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,KX_GameObject* gameobj) + :m_pMeshObject(pMeshObject), m_gameobj(gameobj) { //printf("KX_SoftBodyDeformer\n"); @@ -694,6 +691,14 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, } virtual bool Apply(class RAS_IPolyMaterial *polymat) { + KX_BulletPhysicsController* ctrl = (KX_BulletPhysicsController*) m_gameobj->GetPhysicsController(); + if (!ctrl) + return false; + + btSoftBody* softBody= ctrl->GetSoftBody(); + if (!softBody) + return false; + //printf("apply\n"); RAS_MeshSlot::iterator it; RAS_MeshMaterial *mmat; @@ -718,11 +723,12 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, // for each array for(slot->begin(it); !slot->end(it); slot->next(it)) { - btSoftBody::tNodeArray& nodes(m_softBody->m_nodes); + btSoftBody::tNodeArray& nodes(softBody->m_nodes); int index = 0; for(i=it.startvertex; i= 0); MT_Point3 pt ( nodes[v.getSoftBodyIndex()].m_x.getX(), @@ -745,10 +751,10 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj, //printf("update\n"); return true;//?? } - virtual RAS_Deformer *GetReplica() + virtual RAS_Deformer *GetReplica(class KX_GameObject* replica) { - //printf("getReplica\n"); - return 0; + KX_SoftBodyDeformer* deformer = new KX_SoftBodyDeformer(replica->GetMesh(0),replica); + return deformer; } virtual bool SkipVertexTransform() @@ -855,12 +861,13 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, } case KX_BOUNDPOLYTOPE: { - shapeInfo->SetMesh(meshobj, true); + shapeInfo->SetMesh(meshobj, true,false); bm = shapeInfo->CreateBulletShape(); break; } case KX_BOUNDMESH: { + if (!ci.m_mass ||objprop->m_softbody) { // mesh shapes can be shared, check first if we already have a shape on that mesh @@ -872,11 +879,15 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, shapeInfo->AddRef(); } else { - shapeInfo->SetMesh(meshobj, false); + shapeInfo->SetMesh(meshobj, false,false); } bm = shapeInfo->CreateBulletShape(); //no moving concave meshes, so don't bother calculating inertia //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); + } else + { + shapeInfo->SetMesh(meshobj, false,true); + bm = shapeInfo->CreateBulletShape(); } break; @@ -1097,7 +1108,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, if (softBody && gameobj->GetMesh(0))//only the first mesh, if any { //should be a mesh then, so add a soft body deformer - KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer(softBody, gameobj->GetMesh(0),gameobj); + KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),gameobj); gameobj->SetDeformer(softbodyDeformer); } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 29ee0310c58..d552cb3dc9e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -23,6 +23,8 @@ subject to the following restrictions: #include "BulletSoftBody//btSoftBodyInternals.h" #include "BulletSoftBody/btSoftBodyHelpers.h" #include "LinearMath/btConvexHull.h" +#include "BulletCollision/Gimpact/btGImpactShape.h" + #include "BulletSoftBody/btSoftRigidDynamicsWorld.h" @@ -46,10 +48,13 @@ btVector3 startVel(0,0,0);//-10000); CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) :m_cci(ci) { + m_prototypeTransformInitialized = false; + m_softbodyMappingDone = false; m_collisionDelay = 0; m_newClientInfo = 0; m_registerCount = 0; - + m_softBodyTransformInitialized = false; + // copy pointers locally to allow smart release m_MotionState = ci.m_MotionState; m_collisionShape = ci.m_collisionShape; @@ -144,7 +149,7 @@ btSoftBody* CcdPhysicsController::GetSoftBody() void CcdPhysicsController::CreateRigidbody() { - btTransform trans = GetTransformFromMotionState(m_MotionState); + //btTransform trans = GetTransformFromMotionState(m_MotionState); m_bulletMotionState = new BlenderBulletMotionState(m_MotionState); ///either create a btCollisionObject, btRigidBody or btSoftBody @@ -189,18 +194,12 @@ void CcdPhysicsController::CreateRigidbody() if (m_cci.m_collisionShape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE) { btConvexHullShape* convexHull = (btConvexHullShape* )m_cci.m_collisionShape; - btAlignedObjectArray transformedVertices; - transformedVertices.resize(convexHull->getNumPoints()); - for (int i=0;igetNumPoints();i++) - { - transformedVertices[i] = trans(convexHull->getPoints()[i]); - } //psb = btSoftBodyHelpers::CreateFromConvexHull(sbi,&transformedVertices[0],convexHull->getNumPoints()); { int nvertices = convexHull->getNumPoints(); - const btVector3* vertices = &transformedVertices[0]; + const btVector3* vertices = convexHull->getPoints(); btSoftBodyWorldInfo& worldInfo = softDynaWorld->getWorldInfo(); HullDesc hdsc(QF_TRIANGLES,nvertices,vertices); @@ -226,7 +225,7 @@ void CcdPhysicsController::CreateRigidbody() { RAS_MeshObject* rasMesh= GetShapeInfo()->GetMesh(); - if (rasMesh) + if (rasMesh && !m_softbodyMappingDone) { //printf("apply\n"); @@ -251,17 +250,20 @@ void CcdPhysicsController::CreateRigidbody() for(i=it.startvertex; isetSoftBodyIndex(0); btScalar maxDistSqr = 1e30; btSoftBody::tNodeArray& nodes(psb->m_nodes); - btVector3 xyz = trans(btVector3(vertex->getXYZ()[0],vertex->getXYZ()[1],vertex->getXYZ()[2])); + btVector3 xyz = btVector3(vertex->getXYZ()[0],vertex->getXYZ()[1],vertex->getXYZ()[2]); for (int n=0;nsetSoftBodyIndex(n); } } @@ -330,6 +332,7 @@ void CcdPhysicsController::CreateRigidbody() } + m_softbodyMappingDone = true; m_object = psb; @@ -408,6 +411,13 @@ void CcdPhysicsController::CreateRigidbody() m_MotionState->setWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ()); m_MotionState->setWorldOrientation(0,0,0,1); + if (!m_prototypeTransformInitialized) + { + m_prototypeTransformInitialized = true; + m_softBodyTransformInitialized = true; + GetSoftBody()->transform(startTrans); + } + // btVector3 wp = m_softBody->getWorldTransform().getOrigin(); // MT_Point3 center(wp.getX(),wp.getY(),wp.getZ()); // m_gameobj->NodeSetWorldPosition(center); @@ -572,6 +582,7 @@ void CcdPhysicsController::WriteDynamicsToMotionState() // controller replication void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl) { + m_softBodyTransformInitialized=false; m_MotionState = motionstate; m_registerCount = 0; m_collisionShape = NULL; @@ -652,7 +663,7 @@ void CcdPhysicsController::SetCenterOfMassTransform(btTransform& xform) //either collision object or soft body? if (GetSoftBody()) { - //not yet + } else { @@ -761,6 +772,9 @@ void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float SetCenterOfMassTransform(xform); // not required //m_bulletMotionState->setWorldTransform(xform); + + + } } @@ -781,6 +795,15 @@ void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn) SetCenterOfMassTransform(xform); // not required //m_bulletMotionState->setWorldTransform(xform); + //only once! + if (!m_softBodyTransformInitialized && GetSoftBody()) + { + m_softbodyStartTrans.setBasis(orn); + xform.setOrigin(m_softbodyStartTrans.getOrigin()); + GetSoftBody()->transform(xform); + m_softBodyTransformInitialized = true; + } + } } @@ -799,6 +822,8 @@ void CcdPhysicsController::setPosition(float posX,float posY,float posZ) btTransform xform = m_object->getWorldTransform(); xform.setOrigin(btVector3(posX,posY,posZ)); SetCenterOfMassTransform(xform); + if (!m_softBodyTransformInitialized) + m_softbodyStartTrans.setOrigin(xform.getOrigin()); // not required //m_bulletMotionState->setWorldTransform(xform); } @@ -931,6 +956,15 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); } + btSoftBody* soft = GetSoftBody(); + if (soft) + { + if (local) + { + linVel = m_softbodyStartTrans.getBasis()*linVel; + } + soft->setVelocity(linVel); + } else { btTransform xform = m_object->getWorldTransform(); if (local) @@ -940,7 +974,6 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa btRigidBody* body = GetRigidBody(); if (body) body->setLinearVelocity(linVel); - } } } @@ -1186,8 +1219,10 @@ CcdShapeConstructionInfo* CcdShapeConstructionInfo::FindMesh(RAS_MeshObject* mes return NULL; } -bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope) +bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bool useGimpact) { + m_useGimpact = useGimpact; + // assume no shape information // no support for dynamic change of shape yet assert(m_meshObject == NULL); @@ -1353,19 +1388,35 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() // 9 multiplications/additions and one function call for each triangle that passes the mid phase filtering // One possible optimization is to use directly the btBvhTriangleMeshShape when the scale is 1,1,1 // and btScaledBvhTriangleMeshShape otherwise. - if (!m_unscaledShape) + if (m_useGimpact) { - collisionMeshData = new btTriangleMesh(); - // m_vertexArray is necessarily a multiple of 3 - for (std::vector::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) + collisionMeshData = new btTriangleMesh(); + // m_vertexArray is necessarily a multiple of 3 + for (std::vector::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) + { + collisionMeshData->addTriangle(*it++,*it++,*it++); + } + btGImpactMeshShape* gimpactShape = new btGImpactMeshShape(collisionMeshData); + + collisionShape = gimpactShape; + gimpactShape->updateBound(); + + } else + { + if (!m_unscaledShape) { - collisionMeshData->addTriangle(*it++,*it++,*it++); + collisionMeshData = new btTriangleMesh(); + // m_vertexArray is necessarily a multiple of 3 + for (std::vector::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) + { + collisionMeshData->addTriangle(*it++,*it++,*it++); + } + // this shape will be shared and not deleted until shapeInfo is deleted + m_unscaledShape = new btBvhTriangleMeshShape( collisionMeshData, true ); + m_unscaledShape->recalcLocalAabb(); } - // this shape will be shared and not deleted until shapeInfo is deleted - m_unscaledShape = new btBvhTriangleMeshShape( collisionMeshData, true ); - m_unscaledShape->recalcLocalAabb(); + collisionShape = new btScaledBvhTriangleMeshShape(m_unscaledShape, btVector3(1.0f,1.0f,1.0f)); } - collisionShape = new btScaledBvhTriangleMeshShape(m_unscaledShape, btVector3(1.0f,1.0f,1.0f)); break; case PHY_SHAPE_COMPOUND: diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 65c23eb2543..5d35482dd46 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -53,7 +53,8 @@ public: m_childScale(1.0f,1.0f,1.0f), m_refCount(1), m_meshObject(NULL), - m_unscaledShape(NULL) + m_unscaledShape(NULL), + m_useGimpact(false) { m_childTrans.setIdentity(); } @@ -88,7 +89,7 @@ public: return m_shapeArray.at(i); } - bool SetMesh(RAS_MeshObject* mesh, bool polytope); + bool SetMesh(RAS_MeshObject* mesh, bool polytope,bool useGimpact); RAS_MeshObject* GetMesh(void) { return m_meshObject; @@ -118,6 +119,7 @@ protected: btBvhTriangleMeshShape* m_unscaledShape;// holds the shared unscale BVH mesh shape, // the actual shape is of type btScaledBvhTriangleMeshShape std::vector m_shapeArray; // for compound shapes + bool m_useGimpact; }; struct CcdConstructionInfo @@ -211,6 +213,7 @@ class CcdPhysicsController : public PHY_IPhysicsController { btCollisionObject* m_object; + class PHY_IMotionState* m_MotionState; btMotionState* m_bulletMotionState; @@ -219,6 +222,12 @@ class CcdPhysicsController : public PHY_IPhysicsController friend class CcdPhysicsEnvironment; // needed when updating the controller + //some book keeping for replication + bool m_softbodyMappingDone; + bool m_softBodyTransformInitialized; + bool m_prototypeTransformInitialized; + btTransform m_softbodyStartTrans; + void* m_newClientInfo; int m_registerCount; // needed when multiple sensors use the same controller diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 8c5aae3f8c9..3593aecf3d5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -25,6 +25,7 @@ subject to the following restrictions: #include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h" #include "BulletSoftBody/btSoftRigidDynamicsWorld.h" #include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h" +#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h" //profiling/timings #include "LinearMath/btQuickprof.h" @@ -338,7 +339,9 @@ m_filterCallback(NULL) if (!dispatcher) { - dispatcher = new btCollisionDispatcher(m_collisionConfiguration); + btCollisionDispatcher* disp = new btCollisionDispatcher(m_collisionConfiguration); + dispatcher = disp; + btGImpactCollisionAlgorithm::registerAlgorithm(disp); m_ownDispatcher = dispatcher; } diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h index 6665e1926cf..3332ac4c0a7 100644 --- a/source/gameengine/Rasterizer/RAS_Deformer.h +++ b/source/gameengine/Rasterizer/RAS_Deformer.h @@ -44,7 +44,7 @@ public: virtual void Relink(GEN_Map*map)=0; virtual bool Apply(class RAS_IPolyMaterial *polymat)=0; virtual bool Update(void)=0; - virtual RAS_Deformer *GetReplica()=0; + virtual RAS_Deformer *GetReplica(class KX_GameObject* replica)=0; virtual bool SkipVertexTransform() { return false; diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp index d6f1fe912be..b92965ed1cc 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.cpp +++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp @@ -47,6 +47,7 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz, m_flag = (flat)? FLAT: 0; m_origindex = origindex; m_unit = 2; + m_softBodyIndex = -1; } const MT_Point3& RAS_TexVert::xyz() -- cgit v1.2.3 From 9d3c77ec6277b28993f76804cd975b3684a304e9 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Fri, 26 Sep 2008 06:25:35 +0000 Subject: support concave soft bodies, preliminary. could be used for cloth too. need vertex pinning/constraint attach to other objects. --- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 3 + .../Physics/Bullet/CcdPhysicsController.cpp | 151 ++++++++++++--------- .../Physics/Bullet/CcdPhysicsController.h | 17 ++- 3 files changed, 103 insertions(+), 68 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index ddf1f402431..c5dbabe24fc 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -881,6 +881,9 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, { shapeInfo->SetMesh(meshobj, false,false); } + if (objprop->m_softbody) + shapeInfo->setVertexWeldingThreshold(0.01f); //todo: expose this to the UI + bm = shapeInfo->CreateBulletShape(); //no moving concave meshes, so don't bother calculating inertia //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index d552cb3dc9e..f1e30b4a1e3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -160,9 +160,9 @@ void CcdPhysicsController::CreateRigidbody() //disable soft body until first sneak preview is ready if (m_cci.m_bSoft && m_cci.m_collisionShape && - (shapeType == CONVEX_HULL_SHAPE_PROXYTYPE)) - //(shapeType == TRIANGLE_MESH_SHAPE_PROXYTYPE) | - //(shapeType == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE))) + (shapeType == CONVEX_HULL_SHAPE_PROXYTYPE)| + (shapeType == TRIANGLE_MESH_SHAPE_PROXYTYPE) | + (shapeType == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)) { btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); rbci.m_linearDamping = m_cci.m_linearDamping; @@ -221,57 +221,7 @@ void CcdPhysicsController::CreateRigidbody() psb->appendFace(idx[0],idx[1],idx[2]); } - ///create a mapping between graphics mesh vertices and soft body vertices - { - RAS_MeshObject* rasMesh= GetShapeInfo()->GetMesh(); - - if (rasMesh && !m_softbodyMappingDone) - { - - //printf("apply\n"); - RAS_MeshSlot::iterator it; - RAS_MeshMaterial *mmat; - RAS_MeshSlot *slot; - size_t i; - - //for each material - for (int m=0;mNumMaterials();m++) - { - // The vertex cache can only be updated for this deformer: - // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) - // share the same mesh (=the same cache). As the rendering is done per polymaterial - // cycling through the objects, the entire mesh cache cannot be updated in one shot. - mmat = rasMesh->GetMeshMaterial(m); - - slot = mmat->m_baseslot; - for(slot->begin(it); !slot->end(it); slot->next(it)) - { - int index = 0; - for(i=it.startvertex; isetSoftBodyIndex(0); - btScalar maxDistSqr = 1e30; - btSoftBody::tNodeArray& nodes(psb->m_nodes); - btVector3 xyz = btVector3(vertex->getXYZ()[0],vertex->getXYZ()[1],vertex->getXYZ()[2]); - for (int n=0;nsetSoftBodyIndex(n); - } - } - } - } - } - } - } + hlib.ReleaseResult(hres); @@ -285,7 +235,9 @@ void CcdPhysicsController::CreateRigidbody() } else { - /* + + btSoftBodyWorldInfo& sbi= softDynaWorld->getWorldInfo(); + if (m_cci.m_collisionShape->getShapeType() ==SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE) { btScaledBvhTriangleMeshShape* scaledtrimeshshape = (btScaledBvhTriangleMeshShape*) m_cci.m_collisionShape; @@ -328,16 +280,15 @@ void CcdPhysicsController::CreateRigidbody() //psb = btSoftBodyHelpers::CreateFromTriMesh(sbi,&pts[0].getX(),triangles,numtriangles); } - */ } - - m_softbodyMappingDone = true; + + m_object = psb; //psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS;//btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS; - psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::CL_SS; + psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::VF_SS;//CL_SS; //psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS + btSoftBody::fCollision::CL_RS; //btSoftBody::Material* pm=psb->appendMaterial(); @@ -352,10 +303,10 @@ void CcdPhysicsController::CreateRigidbody() //pm->m_kAST = 0.01f; //pm->m_kVST = 0.001f; psb->generateBendingConstraints(2,pm); - //psb->m_cfg.piterations = 4; - //psb->m_cfg.viterations = 4; - //psb->m_cfg.diterations = 4; - //psb->m_cfg.citerations = 4; + psb->m_cfg.piterations = 4; + psb->m_cfg.viterations = 4; + psb->m_cfg.diterations = 4; + psb->m_cfg.citerations = 4; if (m_cci.m_gamesoftFlag & 2)//OB_SB_GOAL) { psb->setPose(false,true);// @@ -365,7 +316,7 @@ void CcdPhysicsController::CreateRigidbody() } psb->m_cfg.kDF = 0.5; - psb->m_cfg.kMT = 0.05; + //psb->m_cfg.kMT = 0.05; psb->m_cfg.piterations = 5; psb->m_cfg.piterations = 5; @@ -392,8 +343,72 @@ void CcdPhysicsController::CreateRigidbody() //psb->m_materials[0]->m_kLST = 0.1+(i/(btScalar)(n-1))*0.9; psb->setTotalMass(m_cci.m_mass); - psb->generateClusters(8);//(64); + psb->generateClusters(64); psb->setCollisionFlags(0); + + + + + + ///create a mapping between graphics mesh vertices and soft body vertices + { + RAS_MeshObject* rasMesh= GetShapeInfo()->GetMesh(); + + if (rasMesh && !m_softbodyMappingDone) + { + + //printf("apply\n"); + RAS_MeshSlot::iterator it; + RAS_MeshMaterial *mmat; + RAS_MeshSlot *slot; + size_t i; + + //for each material + for (int m=0;mNumMaterials();m++) + { + // The vertex cache can only be updated for this deformer: + // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object) + // share the same mesh (=the same cache). As the rendering is done per polymaterial + // cycling through the objects, the entire mesh cache cannot be updated in one shot. + mmat = rasMesh->GetMeshMaterial(m); + + slot = mmat->m_baseslot; + for(slot->begin(it); !slot->end(it); slot->next(it)) + { + int index = 0; + for(i=it.startvertex; isetSoftBodyIndex(0); + btScalar maxDistSqr = 1e30; + btSoftBody::tNodeArray& nodes(psb->m_nodes); + btVector3 xyz = btVector3(vertex->getXYZ()[0],vertex->getXYZ()[1],vertex->getXYZ()[2]); + for (int n=0;nsetSoftBodyIndex(n); + } + } + } + } + } + } + } + + m_softbodyMappingDone = true; + + + + + + // m_object->setCollisionShape(rbci.m_collisionShape); btTransform startTrans; @@ -1391,6 +1406,8 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() if (m_useGimpact) { collisionMeshData = new btTriangleMesh(); + + // m_vertexArray is necessarily a multiple of 3 for (std::vector::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) { @@ -1405,7 +1422,9 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape() { if (!m_unscaledShape) { - collisionMeshData = new btTriangleMesh(); + collisionMeshData = new btTriangleMesh(true,false); + collisionMeshData->m_weldingThreshold = m_weldingThreshold; + // m_vertexArray is necessarily a multiple of 3 for (std::vector::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); ) { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 5d35482dd46..60c734838f3 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -43,6 +43,8 @@ class btCollisionShape; class CcdShapeConstructionInfo { public: + + static CcdShapeConstructionInfo* FindMesh(RAS_MeshObject* mesh, bool polytope); CcdShapeConstructionInfo() : @@ -54,7 +56,8 @@ public: m_refCount(1), m_meshObject(NULL), m_unscaledShape(NULL), - m_useGimpact(false) + m_useGimpact(false), + m_weldingThreshold(0.f) { m_childTrans.setIdentity(); } @@ -111,6 +114,14 @@ public: // original mesh that correspond to shape triangles. // only set for concave mesh shape. + void setVertexWeldingThreshold(float threshold) + { + m_weldingThreshold = threshold; + } + float getVertexWeldingThreshold() const + { + return m_weldingThreshold; + } protected: static std::map m_meshShapeMap; int m_refCount; // this class is shared between replicas @@ -119,7 +130,9 @@ protected: btBvhTriangleMeshShape* m_unscaledShape;// holds the shared unscale BVH mesh shape, // the actual shape is of type btScaledBvhTriangleMeshShape std::vector m_shapeArray; // for compound shapes - bool m_useGimpact; + bool m_useGimpact; //use gimpact for concave dynamic/moving collision detection + float m_weldingThreshold; //welding closeby vertices together can improve softbody stability etc. + }; struct CcdConstructionInfo -- cgit v1.2.3 From f13bd6ef3ca908e1bec36e015c309225f18751e3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 26 Sep 2008 14:54:21 +0000 Subject: Bugfix: the game player did not initialize tiff and quicktime, so loading those file formats did not work. Also made sure G.order is initialized as otherwise some reading tiff goes wrong. --- source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 9 +++++++-- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 10 ++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 4cd5184fee1..a9196a1a5e3 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -57,6 +57,7 @@ extern "C" #include "BLO_readfile.h" #include "BKE_global.h" #include "BKE_main.h" +#include "IMB_imbuf.h" #include "DNA_scene_types.h" #ifdef __cplusplus } @@ -754,8 +755,6 @@ void GPG_Application::stopEngine() void GPG_Application::exitEngine() { - GPU_extensions_exit(); - if (m_ketsjiengine) { stopEngine(); @@ -803,6 +802,12 @@ void GPG_Application::exitEngine() m_canvas = 0; } + libtiff_exit(); +#ifdef WITH_QUICKTIME + quicktime_exit(); +#endif + GPU_extensions_exit(); + m_exitRequested = 0; m_engineInitialized = false; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 4dfbbab7cd3..9700e6387f2 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -53,6 +53,7 @@ extern "C" { #endif // __cplusplus #include "MEM_guardedalloc.h" +#include "BKE_blender.h" #include "BKE_global.h" #include "BKE_icons.h" #include "BKE_node.h" @@ -60,6 +61,7 @@ extern "C" #include "DNA_scene_types.h" #include "BLO_readfile.h" #include "BLO_readblenfile.h" +#include "IMB_imbuf.h" int GHOST_HACK_getFirstFile(char buf[]); @@ -335,7 +337,15 @@ int main(int argc, char** argv) init_nodesystem(); + initglobals(); + GEN_init_messaging_system(); + +#ifdef WITH_QUICKTIME + quicktime_init(); +#endif + + libtiff_init(); // Parse command line options #ifndef NDEBUG -- cgit v1.2.3 From 8e1cf42dbd23d99db8e06617f37abec9ab5a146b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 26 Sep 2008 18:03:14 +0000 Subject: BGE patch: local/global flag to distance contraint actuator. Previously the distance constraint actuator was always working in local axis. The local flag allows to cast the ray along a world axis (when the flag is not selected). The N flag works differently in this case: only the object orientation is changed to be parallel to the normal at the hit point. The linear velocity is now changed so that the speed along the ray axis is null. This eliminates the need to compensate the gravity when casting along the Z axis. --- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 116 +++++++++++++-------- source/gameengine/Ketsji/KX_ConstraintActuator.h | 3 +- .../Physics/Bullet/CcdPhysicsController.cpp | 2 +- 3 files changed, 78 insertions(+), 43 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 11af4b9324b..49534ccbd4a 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -172,13 +172,15 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) KX_GameObject *obj = (KX_GameObject*) GetParent(); MT_Point3 position = obj->NodeGetWorldPosition(); MT_Point3 newposition; - MT_Vector3 direction, refDirection; + MT_Vector3 normal, direction, refDirection; MT_Matrix3x3 rotation = obj->NodeGetWorldOrientation(); MT_Scalar filter, newdistance, cosangle; int axis, sign; if (m_posDampTime) { filter = m_posDampTime/(1.0+m_posDampTime); + } else { + filter = 0.0; } switch (m_locrot) { case KX_ACT_CONSTRAINT_ORIX: @@ -238,12 +240,8 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } else { refDirection = m_refDirection; } - if (m_posDampTime) { - // apply damping on the direction - direction = filter*direction + (1.0-filter)*refDirection; - } else { - direction = refDirection; - } + // apply damping on the direction + direction = filter*direction + (1.0-filter)*refDirection; obj->AlignAxisToVect(direction, axis); result = true; goto CHECK_TIME; @@ -255,49 +253,74 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) case KX_ACT_CONSTRAINT_DIRNZ: switch (m_locrot) { case KX_ACT_CONSTRAINT_DIRPX: - direction[0] = rotation[0][0]; - direction[1] = rotation[1][0]; - direction[2] = rotation[2][0]; + normal[0] = rotation[0][0]; + normal[1] = rotation[1][0]; + normal[2] = rotation[2][0]; axis = 0; // axis according to KX_GameObject::AlignAxisToVect() - sign = 1; // X axis will be anti parrallel to normal + sign = 0; // X axis will be parrallel to direction of ray break; case KX_ACT_CONSTRAINT_DIRPY: - direction[0] = rotation[0][1]; - direction[1] = rotation[1][1]; - direction[2] = rotation[2][1]; + normal[0] = rotation[0][1]; + normal[1] = rotation[1][1]; + normal[2] = rotation[2][1]; axis = 1; - sign = 1; + sign = 0; break; case KX_ACT_CONSTRAINT_DIRPZ: - direction[0] = rotation[0][2]; - direction[1] = rotation[1][2]; - direction[2] = rotation[2][2]; + normal[0] = rotation[0][2]; + normal[1] = rotation[1][2]; + normal[2] = rotation[2][2]; axis = 2; - sign = 1; + sign = 0; break; case KX_ACT_CONSTRAINT_DIRNX: - direction[0] = -rotation[0][0]; - direction[1] = -rotation[1][0]; - direction[2] = -rotation[2][0]; + normal[0] = -rotation[0][0]; + normal[1] = -rotation[1][0]; + normal[2] = -rotation[2][0]; axis = 0; - sign = 0; + sign = 1; break; case KX_ACT_CONSTRAINT_DIRNY: - direction[0] = -rotation[0][1]; - direction[1] = -rotation[1][1]; - direction[2] = -rotation[2][1]; + normal[0] = -rotation[0][1]; + normal[1] = -rotation[1][1]; + normal[2] = -rotation[2][1]; axis = 1; - sign = 0; + sign = 1; break; case KX_ACT_CONSTRAINT_DIRNZ: - direction[0] = -rotation[0][2]; - direction[1] = -rotation[1][2]; - direction[2] = -rotation[2][2]; + normal[0] = -rotation[0][2]; + normal[1] = -rotation[1][2]; + normal[2] = -rotation[2][2]; axis = 2; - sign = 0; + sign = 1; break; } - direction.normalize(); + normal.normalize(); + if (m_option & KX_ACT_CONSTRAINT_LOCAL) { + // direction of the ray is along the local axis + direction = normal; + } else { + switch (m_locrot) { + case KX_ACT_CONSTRAINT_DIRPX: + direction = MT_Vector3(1.0,0.0,0.0); + break; + case KX_ACT_CONSTRAINT_DIRPY: + direction = MT_Vector3(0.0,1.0,0.0); + break; + case KX_ACT_CONSTRAINT_DIRPZ: + direction = MT_Vector3(0.0,0.0,1.0); + break; + case KX_ACT_CONSTRAINT_DIRNX: + direction = MT_Vector3(-1.0,0.0,0.0); + break; + case KX_ACT_CONSTRAINT_DIRNY: + direction = MT_Vector3(0.0,-1.0,0.0); + break; + case KX_ACT_CONSTRAINT_DIRNZ: + direction = MT_Vector3(0.0,0.0,-1.0); + break; + } + } { MT_Point3 topoint = position + (m_maximumBound) * direction; PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment(); @@ -326,18 +349,19 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) goto CHECK_TIME; } if (m_option & KX_ACT_CONSTRAINT_NORMAL) { - // the new orientation must be so that the axis is parallel to normal - if (sign) - newnormal = -newnormal; + MT_Scalar rotFilter; // apply damping on the direction if (m_rotDampTime) { - MT_Scalar rotFilter = 1.0/(1.0+m_rotDampTime); - newnormal = (-m_rotDampTime*rotFilter)*direction + rotFilter*newnormal; - } else if (m_posDampTime) { - newnormal = -filter*direction + (1.0-filter)*newnormal; + rotFilter = m_rotDampTime/(1.0+m_rotDampTime); + } else { + rotFilter = filter; + } + newnormal = rotFilter*normal - (1.0-rotFilter)*newnormal; + obj->AlignAxisToVect((sign)?-newnormal:newnormal, axis); + if (m_option & KX_ACT_CONSTRAINT_LOCAL) { + direction = newnormal; + direction.normalize(); } - obj->AlignAxisToVect(newnormal, axis); - direction = -newnormal; } if (m_option & KX_ACT_CONSTRAINT_DISTANCE) { if (m_posDampTime) { @@ -345,6 +369,16 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } else { newdistance = m_minimumBound; } + // logically we should cancel the speed along the ray direction as we set the + // position along that axis + spc = obj->GetPhysicsController(); + if (spc) { + MT_Vector3 linV = spc->GetLinearVelocity(); + // cancel the projection along the ray direction + MT_Scalar fallspeed = linV.dot(direction); + if (!MT_fuzzyZero(fallspeed)) + spc->SetLinearVelocity(linV-fallspeed*direction,false); + } } else { newdistance = (position-callback.m_hitPoint).length(); } diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index 99c09c1e5cc..b2ef0dae553 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -99,7 +99,8 @@ protected: KX_ACT_CONSTRAINT_NORMAL = 64, KX_ACT_CONSTRAINT_MATERIAL = 128, KX_ACT_CONSTRAINT_PERMANENT = 256, - KX_ACT_CONSTRAINT_DISTANCE = 512 + KX_ACT_CONSTRAINT_DISTANCE = 512, + KX_ACT_CONSTRAINT_LOCAL = 1024 }; bool IsValidMode(KX_CONSTRAINTTYPE m); bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index f1e30b4a1e3..f17cfb79e92 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -963,7 +963,7 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa { btVector3 linVel(lin_velX,lin_velY,lin_velZ); - if (m_object && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)) + if (m_object/* && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)*/) { m_object->activate(true); if (m_object->isStaticObject()) -- cgit v1.2.3 From c723b91446a04a953ed4ec761310c2f5c675268f Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 27 Sep 2008 21:52:20 +0000 Subject: BGE patch: create new BulletSoftBody data block to store bullet soft body specific parameters. Previously we tried to share the parameters with the blender render soft body but there were too many differences. MSVC project files updated. --- .../gameengine/Converter/BL_BlenderDataConversion.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 5b72a10cd0d..784a103f3e3 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1324,19 +1324,19 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; ///for game soft bodies - if (blenderobject->soft) + if (blenderobject->bsoft) { - objprop.m_linearStiffness = blenderobject->soft->inspring; - objprop.m_angularStiffness = 1.f;//blenderobject->angularStiffness; - objprop.m_volumePreservation = 1.f;//blenderobject->volumePreservation; - objprop.m_gamesoftFlag = blenderobject->softflag;//blenderobject->gamesoftFlag; + objprop.m_linearStiffness = blenderobject->bsoft->linStiff; + objprop.m_angularStiffness = blenderobject->bsoft->angStiff; + objprop.m_volumePreservation = blenderobject->bsoft->volume; + objprop.m_gamesoftFlag = blenderobject->bsoft->flag; } else { - objprop.m_linearStiffness = 0.5;//blenderobject->linearStiffness; - objprop.m_angularStiffness = 1.f;//blenderobject->angularStiffness; - objprop.m_volumePreservation = 1.f;//blenderobject->volumePreservation; - objprop.m_gamesoftFlag = 1;//blenderobject->gamesoftFlag; + objprop.m_linearStiffness = 0.5;//blenderobject->bsoft->linStiff; + objprop.m_angularStiffness = 1.f;//blenderobject->bsoft->angStiff; + objprop.m_volumePreservation = 1.f;//blenderobject->bsoft->volume; + objprop.m_gamesoftFlag = 1;//blenderobject->bsoft->flag; } objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; -- cgit v1.2.3 From f8fb61f9fa0439cbdb6b43d79d82687692daea2f Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 28 Sep 2008 03:07:13 +0000 Subject: enable -noaudio option, so it actually works (and doesn't get overwritten by a game flag). audio initialization delays startup of game engine 2 seconds add -nojoystick commandline option: it takes 5 seconds everytime to start the game engine, while there IS no joystick. In other words: blender -noaudio -nojoystick improves workflow turnaround times for P - ESC from 7 seconds to 1 second! Improved Bullet soft body advanced options, still work-in-progress. Make sure to create game Bullet soft bodies from scratch, it is not compatible with last weeks builds. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 7 ++ .../Converter/BL_BlenderDataConversion.cpp | 90 ++++++++++++++--- source/gameengine/Ketsji/KX_ConvertPhysicsObject.h | 40 +++++++- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 41 +++++++- source/gameengine/Ketsji/KX_Scene.cpp | 12 ++- .../Physics/Bullet/CcdPhysicsController.cpp | 106 +++++++++++++-------- .../Physics/Bullet/CcdPhysicsController.h | 59 ++++++++++-- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 3 +- 8 files changed, 290 insertions(+), 68 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index cc141249561..0d58810e156 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -170,6 +170,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, NG_NetworkDeviceInterface* networkdevice = new NG_LoopBackNetworkDeviceInterface(); + // + SYS_SystemHandle hSystem = SYS_GetSystem(); + bool noaudio = SYS_GetCommandLineInt(hSystem,"noaudio",0); + + if (noaudio)/*(noaudio) intrr: disable game engine audio (openal) */ + SND_DeviceManager::SetDeviceType(snd_e_dummydevice); + // get an audiodevice SND_DeviceManager::Subscribe(); SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance(); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 784a103f3e3..66eed4201ee 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1323,20 +1323,86 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0; objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0; - ///for game soft bodies - if (blenderobject->bsoft) + if (objprop.m_softbody) { - objprop.m_linearStiffness = blenderobject->bsoft->linStiff; - objprop.m_angularStiffness = blenderobject->bsoft->angStiff; - objprop.m_volumePreservation = blenderobject->bsoft->volume; - objprop.m_gamesoftFlag = blenderobject->bsoft->flag; + ///for game soft bodies + if (blenderobject->bsoft) + { + objprop.m_gamesoftFlag = blenderobject->bsoft->flag; + /////////////////// + objprop.m_soft_linStiff = blenderobject->bsoft->linStiff; + objprop.m_soft_angStiff = blenderobject->bsoft->angStiff; /* angular stiffness 0..1 */ + objprop.m_soft_volume= blenderobject->bsoft->volume; /* volume preservation 0..1 */ + + objprop.m_soft_viterations= blenderobject->bsoft->viterations; /* Velocities solver iterations */ + objprop.m_soft_piterations= blenderobject->bsoft->piterations; /* Positions solver iterations */ + objprop.m_soft_diterations= blenderobject->bsoft->diterations; /* Drift solver iterations */ + objprop.m_soft_citerations= blenderobject->bsoft->citerations; /* Cluster solver iterations */ + + objprop.m_soft_kSRHR_CL= blenderobject->bsoft->kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */ + objprop.m_soft_kSKHR_CL= blenderobject->bsoft->kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */ + objprop.m_soft_kSSHR_CL= blenderobject->bsoft->kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */ + objprop.m_soft_kSR_SPLT_CL= blenderobject->bsoft->kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + + objprop.m_soft_kSK_SPLT_CL= blenderobject->bsoft->kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + objprop.m_soft_kSS_SPLT_CL= blenderobject->bsoft->kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + objprop.m_soft_kVCF= blenderobject->bsoft->kVCF; /* Velocities correction factor (Baumgarte) */ + objprop.m_soft_kDP= blenderobject->bsoft->kDP; /* Damping coefficient [0,1] */ + + objprop.m_soft_kDG= blenderobject->bsoft->kDG; /* Drag coefficient [0,+inf] */ + objprop.m_soft_kLF= blenderobject->bsoft->kLF; /* Lift coefficient [0,+inf] */ + objprop.m_soft_kPR= blenderobject->bsoft->kPR; /* Pressure coefficient [-inf,+inf] */ + objprop.m_soft_kVC= blenderobject->bsoft->kVC; /* Volume conversation coefficient [0,+inf] */ + + objprop.m_soft_kDF= blenderobject->bsoft->kDF; /* Dynamic friction coefficient [0,1] */ + objprop.m_soft_kMT= blenderobject->bsoft->kMT; /* Pose matching coefficient [0,1] */ + objprop.m_soft_kCHR= blenderobject->bsoft->kCHR; /* Rigid contacts hardness [0,1] */ + objprop.m_soft_kKHR= blenderobject->bsoft->kKHR; /* Kinetic contacts hardness [0,1] */ + + objprop.m_soft_kSHR= blenderobject->bsoft->kSHR; /* Soft contacts hardness [0,1] */ + objprop.m_soft_kAHR= blenderobject->bsoft->kAHR; /* Anchors hardness [0,1] */ + objprop.m_soft_collisionflags= blenderobject->bsoft->collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */ + objprop.m_soft_numclusteriterations= blenderobject->bsoft->numclusteriterations; /* number of iterations to refine collision clusters*/ - } else - { - objprop.m_linearStiffness = 0.5;//blenderobject->bsoft->linStiff; - objprop.m_angularStiffness = 1.f;//blenderobject->bsoft->angStiff; - objprop.m_volumePreservation = 1.f;//blenderobject->bsoft->volume; - objprop.m_gamesoftFlag = 1;//blenderobject->bsoft->flag; + } else + { + objprop.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT; + + objprop.m_soft_linStiff = 0.5;; + objprop.m_soft_angStiff = 1.f; /* angular stiffness 0..1 */ + objprop.m_soft_volume= 1.f; /* volume preservation 0..1 */ + + + objprop.m_soft_viterations= 0; + objprop.m_soft_piterations= 1; + objprop.m_soft_diterations= 0; + objprop.m_soft_citerations= 4; + + objprop.m_soft_kSRHR_CL= 0.1f; + objprop.m_soft_kSKHR_CL= 1.f; + objprop.m_soft_kSSHR_CL= 0.5; + objprop.m_soft_kSR_SPLT_CL= 0.5f; + + objprop.m_soft_kSK_SPLT_CL= 0.5f; + objprop.m_soft_kSS_SPLT_CL= 0.5f; + objprop.m_soft_kVCF= 1; + objprop.m_soft_kDP= 0; + + objprop.m_soft_kDG= 0; + objprop.m_soft_kLF= 0; + objprop.m_soft_kPR= 0; + objprop.m_soft_kVC= 0; + + objprop.m_soft_kDF= 0.2f; + objprop.m_soft_kMT= 0.f; + objprop.m_soft_kCHR= 1.0f; + objprop.m_soft_kKHR= 0.1f; + + objprop.m_soft_kSHR= 1.f; + objprop.m_soft_kAHR= 0.7f; + objprop.m_soft_collisionflags= OB_BSB_COL_SDF_RS + OB_BSB_COL_VF_SS; + objprop.m_soft_numclusteriterations= 16; + } } objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h index 6325c9365fd..53486cecf73 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h @@ -88,10 +88,44 @@ struct KX_ObjectProperties bool m_hasCompoundChildren; bool m_isCompoundChild; - float m_linearStiffness; - float m_angularStiffness; - float m_volumePreservation; + ///////////////////////// + int m_gamesoftFlag; + float m_soft_linStiff; /* linear stiffness 0..1 */ + float m_soft_angStiff; /* angular stiffness 0..1 */ + float m_soft_volume; /* volume preservation 0..1 */ + + int m_soft_viterations; /* Velocities solver iterations */ + int m_soft_piterations; /* Positions solver iterations */ + int m_soft_diterations; /* Drift solver iterations */ + int m_soft_citerations; /* Cluster solver iterations */ + + float m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */ + float m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */ + float m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */ + float m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + + float m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + float m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + float m_soft_kVCF; /* Velocities correction factor (Baumgarte) */ + float m_soft_kDP; /* Damping coefficient [0,1] */ + + float m_soft_kDG; /* Drag coefficient [0,+inf] */ + float m_soft_kLF; /* Lift coefficient [0,+inf] */ + float m_soft_kPR; /* Pressure coefficient [-inf,+inf] */ + float m_soft_kVC; /* Volume conversation coefficient [0,+inf] */ + + float m_soft_kDF; /* Dynamic friction coefficient [0,1] */ + float m_soft_kMT; /* Pose matching coefficient [0,1] */ + float m_soft_kCHR; /* Rigid contacts hardness [0,1] */ + float m_soft_kKHR; /* Kinetic contacts hardness [0,1] */ + + float m_soft_kSHR; /* Soft contacts hardness [0,1] */ + float m_soft_kAHR; /* Anchors hardness [0,1] */ + int m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */ + int m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/ + + ///////////////////////// double m_margin; KX_BoundBoxClass m_boundclass; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index c5dbabe24fc..e4c7e7f9317 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1024,10 +1024,45 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_angularDamping = 1.f - shapeprops->m_ang_drag; //need a bit of damping, else system doesn't behave well ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour - ci.m_linearStiffness = objprop->m_linearStiffness; - ci.m_angularStiffness= objprop->m_angularStiffness; - ci.m_volumePreservation= objprop->m_volumePreservation; + + + /////////////////// ci.m_gamesoftFlag = objprop->m_gamesoftFlag; + ci.m_soft_linStiff = objprop->m_soft_linStiff; + ci.m_soft_angStiff = objprop->m_soft_angStiff; /* angular stiffness 0..1 */ + ci.m_soft_volume= objprop->m_soft_volume; /* volume preservation 0..1 */ + + ci.m_soft_viterations= objprop->m_soft_viterations; /* Velocities solver iterations */ + ci.m_soft_piterations= objprop->m_soft_piterations; /* Positions solver iterations */ + ci.m_soft_diterations= objprop->m_soft_diterations; /* Drift solver iterations */ + ci.m_soft_citerations= objprop->m_soft_citerations; /* Cluster solver iterations */ + + ci.m_soft_kSRHR_CL= objprop->m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */ + ci.m_soft_kSKHR_CL= objprop->m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */ + ci.m_soft_kSSHR_CL= objprop->m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */ + ci.m_soft_kSR_SPLT_CL= objprop->m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + + ci.m_soft_kSK_SPLT_CL= objprop->m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + ci.m_soft_kSS_SPLT_CL= objprop->m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + ci.m_soft_kVCF= objprop->m_soft_kVCF; /* Velocities correction factor (Baumgarte) */ + ci.m_soft_kDP= objprop->m_soft_kDP; /* Damping coefficient [0,1] */ + + ci.m_soft_kDG= objprop->m_soft_kDG; /* Drag coefficient [0,+inf] */ + ci.m_soft_kLF= objprop->m_soft_kLF; /* Lift coefficient [0,+inf] */ + ci.m_soft_kPR= objprop->m_soft_kPR; /* Pressure coefficient [-inf,+inf] */ + ci.m_soft_kVC= objprop->m_soft_kVC; /* Volume conversation coefficient [0,+inf] */ + + ci.m_soft_kDF= objprop->m_soft_kDF; /* Dynamic friction coefficient [0,1] */ + ci.m_soft_kMT= objprop->m_soft_kMT; /* Pose matching coefficient [0,1] */ + ci.m_soft_kCHR= objprop->m_soft_kCHR; /* Rigid contacts hardness [0,1] */ + ci.m_soft_kKHR= objprop->m_soft_kKHR; /* Kinetic contacts hardness [0,1] */ + + ci.m_soft_kSHR= objprop->m_soft_kSHR; /* Soft contacts hardness [0,1] */ + ci.m_soft_kAHR= objprop->m_soft_kAHR; /* Anchors hardness [0,1] */ + ci.m_soft_collisionflags= objprop->m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */ + ci.m_soft_numclusteriterations= objprop->m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/ + + //////////////////// ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter); ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 6eeb732c1e3..f5d6d7e8e0a 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -159,7 +159,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, KX_NetworkEventManager* netmgr = new KX_NetworkEventManager(m_logicmgr, ndi); - SCA_JoystickManager *joymgr = new SCA_JoystickManager(m_logicmgr); + m_logicmgr->RegisterEventManager(alwaysmgr); m_logicmgr->RegisterEventManager(propmgr); @@ -170,7 +170,15 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_logicmgr->RegisterEventManager(rndmgr); m_logicmgr->RegisterEventManager(raymgr); m_logicmgr->RegisterEventManager(netmgr); - m_logicmgr->RegisterEventManager(joymgr); + + + SYS_SystemHandle hSystem = SYS_GetSystem(); + bool nojoystick= SYS_GetCommandLineInt(hSystem,"nojoystick",0); + if (!nojoystick) + { + SCA_JoystickManager *joymgr = new SCA_JoystickManager(m_logicmgr); + m_logicmgr->RegisterEventManager(joymgr); + } m_soundScene = new SND_Scene(adi); MT_assert (m_networkDeviceInterface != NULL); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index f17cfb79e92..166731459e7 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -288,26 +288,69 @@ void CcdPhysicsController::CreateRigidbody() m_object = psb; //psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS;//btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS; - psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::VF_SS;//CL_SS; - //psb->m_cfg.collisions = btSoftBody::fCollision::CL_SS + btSoftBody::fCollision::CL_RS; - //btSoftBody::Material* pm=psb->appendMaterial(); - btSoftBody::Material* pm=psb->m_materials[0]; + //psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::VF_SS;//CL_SS; - pm->m_kLST = m_cci.m_linearStiffness; - pm->m_kAST = m_cci.m_angularStiffness; - pm->m_kVST = m_cci.m_volumePreservation; + //btSoftBody::Material* pm=psb->appendMaterial(); + btSoftBody::Material* pm=psb->m_materials[0]; + pm->m_kLST = m_cci.m_soft_linStiff; + pm->m_kAST = m_cci.m_soft_angStiff; + pm->m_kVST = m_cci.m_soft_volume; + psb->m_cfg.collisions = 0; - - //pm->m_kAST = 0.01f; - //pm->m_kVST = 0.001f; - psb->generateBendingConstraints(2,pm); - psb->m_cfg.piterations = 4; - psb->m_cfg.viterations = 4; - psb->m_cfg.diterations = 4; - psb->m_cfg.citerations = 4; - if (m_cci.m_gamesoftFlag & 2)//OB_SB_GOAL) + if (m_cci.m_soft_collisionflags & CCD_BSB_COL_CL_RS) + { + psb->m_cfg.collisions += btSoftBody::fCollision::CL_RS; + } else + { + psb->m_cfg.collisions += btSoftBody::fCollision::SDF_RS; + } + if (m_cci.m_soft_collisionflags & CCD_BSB_COL_CL_SS) + { + psb->m_cfg.collisions += btSoftBody::fCollision::CL_SS; + } else + { + psb->m_cfg.collisions += btSoftBody::fCollision::VF_SS; + } + + + psb->m_cfg.kSRHR_CL = m_cci.m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */ + psb->m_cfg.kSKHR_CL = m_cci.m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */ + psb->m_cfg.kSSHR_CL = m_cci.m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */ + psb->m_cfg.kSR_SPLT_CL = m_cci.m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + + psb->m_cfg.kSK_SPLT_CL = m_cci.m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + psb->m_cfg.kSS_SPLT_CL = m_cci.m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + psb->m_cfg.kVCF = m_cci.m_soft_kVCF; /* Velocities correction factor (Baumgarte) */ + psb->m_cfg.kDP = m_cci.m_soft_kDP; /* Damping coefficient [0,1] */ + + psb->m_cfg.kDG = m_cci.m_soft_kDG; /* Drag coefficient [0,+inf] */ + psb->m_cfg.kLF = m_cci.m_soft_kLF; /* Lift coefficient [0,+inf] */ + psb->m_cfg.kPR = m_cci.m_soft_kPR; /* Pressure coefficient [-inf,+inf] */ + psb->m_cfg.kVC = m_cci.m_soft_kVC; /* Volume conversation coefficient [0,+inf] */ + + psb->m_cfg.kDF = m_cci.m_soft_kDF; /* Dynamic friction coefficient [0,1] */ + psb->m_cfg.kMT = m_cci.m_soft_kMT; /* Pose matching coefficient [0,1] */ + psb->m_cfg.kCHR = m_cci.m_soft_kCHR; /* Rigid contacts hardness [0,1] */ + psb->m_cfg.kKHR = m_cci.m_soft_kKHR; /* Kinetic contacts hardness [0,1] */ + + psb->m_cfg.kSHR = m_cci.m_soft_kSHR; /* Soft contacts hardness [0,1] */ + psb->m_cfg.kAHR = m_cci.m_soft_kAHR; /* Anchors hardness [0,1] */ + + + + if (m_cci.m_gamesoftFlag & CCD_BSB_BENDING_CONSTRAINTS)//OB_SB_GOAL) + { + psb->generateBendingConstraints(2,pm); + } + + psb->m_cfg.piterations = m_cci.m_soft_piterations; + psb->m_cfg.viterations = m_cci.m_soft_viterations; + psb->m_cfg.diterations = m_cci.m_soft_diterations; + psb->m_cfg.citerations = m_cci.m_soft_citerations; + + if (m_cci.m_gamesoftFlag & CCD_BSB_SHAPE_MATCHING)//OB_SB_GOAL) { psb->setPose(false,true);// } else @@ -315,27 +358,14 @@ void CcdPhysicsController::CreateRigidbody() psb->setPose(true,false); } - psb->m_cfg.kDF = 0.5; - //psb->m_cfg.kMT = 0.05; - psb->m_cfg.piterations = 5; - - psb->m_cfg.piterations = 5; - //psb->m_cfg.kVC = 20; + psb->randomizeConstraints(); -/* - psb->m_cfg.kDF = 0.1f;//1.f; - psb->m_cfg.kDP = 0.0001; - //psb->m_cfg.kDP = 0.005; - psb->m_cfg.kCHR = 0.1; - //psb->m_cfg.kVCF = 0.1f; - psb->m_cfg.kVCF = 0.0001f; - //psb->m_cfg.kAHR = 0.1f; - psb->m_cfg.kAHR = 0.0001f; - psb->m_cfg.kMT = 0.1f; - //psb->m_cfg.kDF=1; - */ + if (m_cci.m_soft_collisionflags & (CCD_BSB_COL_CL_RS+CCD_BSB_COL_CL_SS)) + { + psb->generateClusters(m_cci.m_soft_numclusteriterations); + } // psb->activate(); // psb->setActivationState(1); @@ -343,14 +373,10 @@ void CcdPhysicsController::CreateRigidbody() //psb->m_materials[0]->m_kLST = 0.1+(i/(btScalar)(n-1))*0.9; psb->setTotalMass(m_cci.m_mass); - psb->generateClusters(64); + psb->setCollisionFlags(0); - - - - - ///create a mapping between graphics mesh vertices and soft body vertices + ///create a mapping between graphics mesh vertices and soft body vertices { RAS_MeshObject* rasMesh= GetShapeInfo()->GetMesh(); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 60c734838f3..1366764eb63 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -38,6 +38,20 @@ class btMotionState; class RAS_MeshObject; class btCollisionShape; + +#define CCD_BSB_SHAPE_MATCHING 2 +#define CCD_BSB_BENDING_CONSTRAINTS 8 +#define CCD_BSB_AERO_VPOINT 16 /* aero model, Vertex normals are oriented toward velocity*/ +#define CCD_BSB_AERO_VTWOSIDE 32 /* aero model, Vertex normals are flipped to match velocity */ + +/* BulletSoftBody.collisionflags */ +#define CCD_BSB_COL_SDF_RS 2 /* SDF based rigid vs soft */ +#define CCD_BSB_COL_CL_RS 4 /* Cluster based rigid vs soft */ +#define CCD_BSB_COL_CL_SS 8 /* Cluster based soft vs soft */ +#define CCD_BSB_COL_VF_SS 16 /* Vertex/Face based soft vs soft */ + + + // Shape contructor // It contains all the information needed to create a simple bullet shape at runtime class CcdShapeConstructionInfo @@ -162,9 +176,6 @@ struct CcdConstructionInfo m_linearDamping(0.1f), m_angularDamping(0.1f), m_margin(0.06f), - m_linearStiffness(1.f), - m_angularStiffness(1.f), - m_volumePreservation(1.f), m_gamesoftFlag(0), m_collisionFlags(0), m_bRigid(false), @@ -189,10 +200,44 @@ struct CcdConstructionInfo btScalar m_angularDamping; btScalar m_margin; - btScalar m_linearStiffness; - btScalar m_angularStiffness; - btScalar m_volumePreservation; - int m_gamesoftFlag; + //////////////////// + int m_gamesoftFlag; + float m_soft_linStiff; /* linear stiffness 0..1 */ + float m_soft_angStiff; /* angular stiffness 0..1 */ + float m_soft_volume; /* volume preservation 0..1 */ + + int m_soft_viterations; /* Velocities solver iterations */ + int m_soft_piterations; /* Positions solver iterations */ + int m_soft_diterations; /* Drift solver iterations */ + int m_soft_citerations; /* Cluster solver iterations */ + + float m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */ + float m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */ + float m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */ + float m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + + float m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + float m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ + float m_soft_kVCF; /* Velocities correction factor (Baumgarte) */ + float m_soft_kDP; /* Damping coefficient [0,1] */ + + float m_soft_kDG; /* Drag coefficient [0,+inf] */ + float m_soft_kLF; /* Lift coefficient [0,+inf] */ + float m_soft_kPR; /* Pressure coefficient [-inf,+inf] */ + float m_soft_kVC; /* Volume conversation coefficient [0,+inf] */ + + float m_soft_kDF; /* Dynamic friction coefficient [0,1] */ + float m_soft_kMT; /* Pose matching coefficient [0,1] */ + float m_soft_kCHR; /* Rigid contacts hardness [0,1] */ + float m_soft_kKHR; /* Kinetic contacts hardness [0,1] */ + + float m_soft_kSHR; /* Soft contacts hardness [0,1] */ + float m_soft_kAHR; /* Anchors hardness [0,1] */ + int m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */ + int m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/ +/////////////////// + + int m_collisionFlags; bool m_bRigid; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 3593aecf3d5..763fc148a04 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -576,7 +576,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) veh->SyncWheels(); } - m_dynamicsWorld->debugDrawWorld(); + if (m_dynamicsWorld->getDebugDrawer() && m_dynamicsWorld->getDebugDrawer()->getDebugMode() >0) + m_dynamicsWorld->debugDrawWorld(); CallbackTriggers(); -- cgit v1.2.3 From 28684b1c094a7df9569788956398513609b6948a Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 28 Sep 2008 03:17:45 +0000 Subject: make gui backwards compatible with this weeks softbody blend files --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 66eed4201ee..09b0f063e2a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1394,7 +1394,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_soft_kVC= 0; objprop.m_soft_kDF= 0.2f; - objprop.m_soft_kMT= 0.f; + objprop.m_soft_kMT= 0.05f; objprop.m_soft_kCHR= 1.0f; objprop.m_soft_kKHR= 0.1f; -- cgit v1.2.3 From 0b622fc07f1a19c4fbc72782f6000814b66b2088 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 29 Sep 2008 03:09:03 +0000 Subject: added anisotropic friction support for Bullet. Both for static and dynamic objects --- source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 8 ++++++++ source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 5 +++++ source/gameengine/Physics/Bullet/CcdPhysicsController.h | 7 ++++++- 3 files changed, 19 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index e4c7e7f9317..68e0997aec0 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1025,6 +1025,14 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, //need a bit of damping, else system doesn't behave well ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour + ci.m_do_anisotropic = shapeprops->m_do_anisotropic; + ci.m_anisotropicFriction.setValue(shapeprops->m_friction_scaling[0],shapeprops->m_friction_scaling[1],shapeprops->m_friction_scaling[2]); + + //smprop->m_do_fh = kxshapeprops->m_do_fh; + //smprop->m_do_rot_fh = kxshapeprops->m_do_rot_fh ; + + + /////////////////// ci.m_gamesoftFlag = objprop->m_gamesoftFlag; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 166731459e7..8ec040e89ee 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -500,6 +500,11 @@ void CcdPhysicsController::CreateRigidbody() body->setAngularFactor(0.f); } } + if (m_object && m_cci.m_do_anisotropic) + { + m_object->setAnisotropicFriction(m_cci.m_anisotropicFriction); + } + } static void DeleteBulletShape(btCollisionShape* shape) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 1366764eb63..f001d6043cb 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -186,7 +186,9 @@ struct CcdConstructionInfo m_MotionState(0), m_shapeInfo(0), m_physicsEnv(0), - m_inertiaFactor(1.f) + m_inertiaFactor(1.f), + m_do_anisotropic(false), + m_anisotropicFriction(1.f,1.f,1.f) { } @@ -259,6 +261,9 @@ struct CcdConstructionInfo CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication float m_inertiaFactor;//tweak the inertia (hooked up to Blender 'formfactor' + bool m_do_anisotropic; + btVector3 m_anisotropicFriction; + }; -- cgit v1.2.3 From 425264d7ccd30fb72db6a9d2d9c326aa3571f8fe Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 29 Sep 2008 04:14:47 +0000 Subject: Update the Bullet/game buttons_bullet, to better reflect usage. 1) Anisotropic friction works for static and dynamic objects 2) For soft bodies, assume triangle mesh if no bounds a chosen 3) Form factor == inertia scaling factor, it was actually hooked up in Bullet 4) Only show 'radius' if sphere is chosen, or no bounds+dynamics (== sphere bounds) --- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 09b0f063e2a..97ed6f4002a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1414,6 +1414,12 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, objprop.m_dynamic_parent=NULL; objprop.m_isdeformable = ((blenderobject->gameflag2 & 2)) != 0; objprop.m_boundclass = objprop.m_dyna?KX_BOUNDSPHERE:KX_BOUNDMESH; + + if ((blenderobject->gameflag & OB_SOFT_BODY) && !(blenderobject->gameflag & OB_BOUNDS)) + { + objprop.m_boundclass = KX_BOUNDMESH; + } + KX_BoxBounds bb; my_get_local_bounds(blenderobject,objprop.m_boundobject.box.m_center,bb.m_extends); if (blenderobject->gameflag & OB_BOUNDS) -- cgit v1.2.3 From cef5c4b76508d826959fb46f3f77ba0af029046f Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 29 Sep 2008 06:58:49 +0000 Subject: Add Fh/Rot Fh to Bullet. --- .../Ketsji/KX_BulletPhysicsController.cpp | 8 +- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 16 +- .../Physics/Bullet/CcdPhysicsController.cpp | 3 +- .../Physics/Bullet/CcdPhysicsController.h | 37 +++++ .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 171 +++++++++++++++++++++ .../Physics/Bullet/CcdPhysicsEnvironment.h | 1 + 6 files changed, 231 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index d7bd1e9c7cd..3d20ce8a3a5 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -211,6 +211,9 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode) //parentcontroller is here be able to avoid collisions between parent/child PHY_IPhysicsController* parentctrl = NULL; + KX_BulletPhysicsController* parentKxCtrl = NULL; + CcdPhysicsController* ccdParent = NULL; + if (destnode != destnode->GetRootSGParent()) { @@ -230,12 +233,15 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode) KX_GameObject *clientgameobj = static_cast( (*childit)->GetSGClientObject()); if (clientgameobj) { - parentctrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController(); + parentKxCtrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController(); + parentctrl = parentKxCtrl; + ccdParent = parentKxCtrl; } } } } + physicsreplica->setParentCtrl(ccdParent); physicsreplica->PostProcessReplica(motionstate,parentctrl); physicsreplica->m_userdata = (PHY_IPhysicsController*)physicsreplica; return physicsreplica; diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 68e0997aec0..0e7a6d92ec1 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -1028,10 +1028,16 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_do_anisotropic = shapeprops->m_do_anisotropic; ci.m_anisotropicFriction.setValue(shapeprops->m_friction_scaling[0],shapeprops->m_friction_scaling[1],shapeprops->m_friction_scaling[2]); - //smprop->m_do_fh = kxshapeprops->m_do_fh; - //smprop->m_do_rot_fh = kxshapeprops->m_do_rot_fh ; - +////////// + //do Fh, do Rot Fh + ci.m_do_fh = shapeprops->m_do_fh; + ci.m_do_rot_fh = shapeprops->m_do_rot_fh ; + ci.m_fh_damping = smmaterial->m_fh_damping; + ci.m_fh_distance = smmaterial->m_fh_distance; + ci.m_fh_normal = smmaterial->m_fh_normal; + ci.m_fh_spring = smmaterial->m_fh_spring; + ci.m_radius = objprop->m_radius; /////////////////// @@ -1098,6 +1104,10 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, if (rbody && objprop->m_disableSleeping) rbody->setActivationState(DISABLE_DEACTIVATION); } + + CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0; + physicscontroller->setParentCtrl(parentCtrl); + //Now done directly in ci.m_collisionFlags so that it propagates to replica //if (objprop->m_ghost) diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 8ec040e89ee..7196a1ae095 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -54,7 +54,7 @@ CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci) m_newClientInfo = 0; m_registerCount = 0; m_softBodyTransformInitialized = false; - + m_parentCtrl = 0; // copy pointers locally to allow smart release m_MotionState = ci.m_MotionState; m_collisionShape = ci.m_collisionShape; @@ -628,6 +628,7 @@ void CcdPhysicsController::WriteDynamicsToMotionState() // controller replication void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl) { + m_softBodyTransformInitialized=false; m_MotionState = motionstate; m_registerCount = 0; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index f001d6043cb..a1245f6a3e9 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -264,6 +264,14 @@ struct CcdConstructionInfo bool m_do_anisotropic; btVector3 m_anisotropicFriction; + bool m_do_fh; ///< Should the object have a linear Fh spring? + bool m_do_rot_fh; ///< Should the object have an angular Fh spring? + btScalar m_fh_spring; ///< Spring constant (both linear and angular) + btScalar m_fh_damping; ///< Damping factor (linear and angular) in range [0, 1] + btScalar m_fh_distance; ///< The range above the surface where Fh is active. + bool m_fh_normal; ///< Should the object slide off slopes? + float m_radius;//for fh backwards compatibility + }; @@ -295,6 +303,9 @@ class CcdPhysicsController : public PHY_IPhysicsController void* m_newClientInfo; int m_registerCount; // needed when multiple sensors use the same controller CcdConstructionInfo m_cci;//needed for replication + + CcdPhysicsController* m_parentCtrl; + void GetWorldOrientation(btMatrix3x3& mat); void CreateRigidbody(); @@ -318,6 +329,15 @@ class CcdPhysicsController : public PHY_IPhysicsController virtual ~CcdPhysicsController(); + CcdConstructionInfo& getConstructionInfo() + { + return m_cci; + } + const CcdConstructionInfo& getConstructionInfo() const + { + return m_cci; + } + btRigidBody* GetRigidBody(); btCollisionObject* GetCollisionObject(); @@ -422,6 +442,23 @@ class CcdPhysicsController : public PHY_IPhysicsController { return m_cci.m_physicsEnv; } + + void setParentCtrl(CcdPhysicsController* parentCtrl) + { + m_parentCtrl = parentCtrl; + } + + CcdPhysicsController* getParentCtrl() + { + return m_parentCtrl; + } + + const CcdPhysicsController* getParentCtrl() const + { + return m_parentCtrl; + } + + }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 763fc148a04..483f829c2bd 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -558,6 +558,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep) (*it)->SynchronizeMotionStates(timeStep); } + processFhSprings(curTime,timeStep); + float subStep = timeStep / float(m_numTimeSubSteps); for (i=0;iSynchronizeMotionStates(timeStep); } + for (it=m_controllers.begin(); it!=m_controllers.end(); it++) + { + (*it)->SynchronizeMotionStates(timeStep); + } + for (i=0;im_clientObject == m_owner) + return false; + + if (proxy0->m_clientObject == m_parent) + return false; + + return btCollisionWorld::ClosestRayResultCallback::needsCollision(proxy0); + } + +}; + +void CcdPhysicsEnvironment::processFhSprings(double curTime,float timeStep) +{ + std::set::iterator it; + + for (it=m_controllers.begin(); it!=m_controllers.end(); it++) + { + CcdPhysicsController* ctrl = (*it); + if (ctrl->GetRigidBody() && ctrl->getConstructionInfo().m_do_fh || ctrl->getConstructionInfo().m_do_rot_fh) + { + //printf("has Fh or RotFh\n"); + //re-implement SM_FhObject.cpp using btCollisionWorld::rayTest and info from ctrl->getConstructionInfo() + //send a ray from {0.0, 0.0, 0.0} towards {0.0, 0.0, -10.0}, in local coordinates + + btRigidBody* body = ctrl->GetRigidBody(); + CcdPhysicsController* parentCtrl = ctrl->getParentCtrl(); + btRigidBody* parentBody = parentCtrl?parentCtrl->GetRigidBody() : 0; + btRigidBody* cl_object = parentBody ? parentBody : body; + + if (body->isStaticOrKinematicObject()) + continue; + + btVector3 rayDirLocal(0,0,-10); + + //m_dynamicsWorld + //ctrl->GetRigidBody(); + btVector3 rayFromWorld = body->getCenterOfMassPosition(); + //btVector3 rayToWorld = rayFromWorld + body->getCenterOfMassTransform().getBasis() * rayDirLocal; + //ray always points down the z axis in world space... + btVector3 rayToWorld = rayFromWorld + rayDirLocal; + + ClosestRayResultCallbackNotMe resultCallback(rayFromWorld,rayToWorld,body,parentBody); + + m_dynamicsWorld->rayTest(rayFromWorld,rayToWorld,resultCallback); + if (resultCallback.hasHit()) + { + //we hit this one: resultCallback.m_collisionObject; + CcdPhysicsController* controller = static_cast(resultCallback.m_collisionObject->getUserPointer()); + + if (controller) + { + if (controller->getConstructionInfo().m_fh_distance < SIMD_EPSILON) + continue; + + btRigidBody* hit_object = controller->GetRigidBody(); + if (!hit_object) + continue; + + CcdConstructionInfo& hitObjShapeProps = controller->getConstructionInfo(); + + float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->getConstructionInfo().m_radius; + if (distance >= hitObjShapeProps.m_fh_distance) + continue; + + + + //btVector3 ray_dir = cl_object->getCenterOfMassTransform().getBasis()* rayDirLocal.normalized(); + btVector3 ray_dir = rayDirLocal.normalized(); + btVector3 normal = resultCallback.m_hitNormalWorld; + normal.normalize(); + + + if (ctrl->getConstructionInfo().m_do_fh) + { + btVector3 lspot = cl_object->getCenterOfMassPosition() + + rayDirLocal * resultCallback.m_closestHitFraction; + + + + + lspot -= hit_object->getCenterOfMassPosition(); + btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot); + btScalar rel_vel_ray = ray_dir.dot(rel_vel); + btScalar spring_extent = 1.0 - distance / hitObjShapeProps.m_fh_distance; + + btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring; + btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping; + + cl_object->setLinearVelocity(cl_object->getLinearVelocity() + (-(i_spring + i_damp) * ray_dir)); + if (hitObjShapeProps.m_fh_normal) + { + cl_object->setLinearVelocity(cl_object->getLinearVelocity()+(i_spring + i_damp) *(normal - normal.dot(ray_dir) * ray_dir)); + } + + btVector3 lateral = rel_vel - rel_vel_ray * ray_dir; + + + if (ctrl->getConstructionInfo().m_do_anisotropic) { + //Bullet basis contains no scaling/shear etc. + const btMatrix3x3& lcs = cl_object->getCenterOfMassTransform().getBasis(); + btVector3 loc_lateral = lateral * lcs; + const btVector3& friction_scaling = cl_object->getAnisotropicFriction(); + loc_lateral *= friction_scaling; + lateral = lcs * loc_lateral; + } + + btScalar rel_vel_lateral = lateral.length(); + + if (rel_vel_lateral > SIMD_EPSILON) { + btScalar friction_factor = hit_object->getFriction();//cl_object->getFriction(); + + btScalar max_friction = friction_factor * btMax(btScalar(0.0), i_spring); + + btScalar rel_mom_lateral = rel_vel_lateral / cl_object->getInvMass(); + + btVector3 friction = (rel_mom_lateral > max_friction) ? + -lateral * (max_friction / rel_vel_lateral) : + -lateral; + + cl_object->applyCentralImpulse(friction); + } + } + + + if (ctrl->getConstructionInfo().m_do_rot_fh) { + btVector3 up2 = cl_object->getWorldTransform().getBasis().getColumn(2); + + btVector3 t_spring = up2.cross(normal) * hitObjShapeProps.m_fh_spring; + btVector3 ang_vel = cl_object->getAngularVelocity(); + + // only rotations that tilt relative to the normal are damped + ang_vel -= ang_vel.dot(normal) * normal; + + btVector3 t_damp = ang_vel * hitObjShapeProps.m_fh_damping; + + cl_object->setAngularVelocity(cl_object->getAngularVelocity() + (t_spring - t_damp)); + } + + } + + + } + + + } + } + +} void CcdPhysicsEnvironment::setDebugMode(int debugMode) { diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 56a639509c5..3d9d5442b8f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -74,6 +74,7 @@ protected: btContactSolverInfo m_solverInfo; + void processFhSprings(double curTime,float timeStep); public: CcdPhysicsEnvironment(btDispatcher* dispatcher=0, btOverlappingPairCache* pairCache=0); -- cgit v1.2.3 From 638c51ba7d54b7a815c745d5f383bcbed6d4d1d1 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 29 Sep 2008 08:00:38 +0000 Subject: don't crash when trying to make a soft body 'fh' object --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 483f829c2bd..fc19789196d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -626,13 +626,15 @@ void CcdPhysicsEnvironment::processFhSprings(double curTime,float timeStep) for (it=m_controllers.begin(); it!=m_controllers.end(); it++) { CcdPhysicsController* ctrl = (*it); - if (ctrl->GetRigidBody() && ctrl->getConstructionInfo().m_do_fh || ctrl->getConstructionInfo().m_do_rot_fh) + btRigidBody* body = ctrl->GetRigidBody(); + + if (body && (ctrl->getConstructionInfo().m_do_fh || ctrl->getConstructionInfo().m_do_rot_fh)) { //printf("has Fh or RotFh\n"); //re-implement SM_FhObject.cpp using btCollisionWorld::rayTest and info from ctrl->getConstructionInfo() //send a ray from {0.0, 0.0, 0.0} towards {0.0, 0.0, -10.0}, in local coordinates - btRigidBody* body = ctrl->GetRigidBody(); + CcdPhysicsController* parentCtrl = ctrl->getParentCtrl(); btRigidBody* parentBody = parentCtrl?parentCtrl->GetRigidBody() : 0; btRigidBody* cl_object = parentBody ? parentBody : body; -- cgit v1.2.3 From a1513a8c0f6953932d004b3bd85831d096ee095b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 29 Sep 2008 17:46:25 +0000 Subject: BGE patch: fix force application on soft body. Force is applied on each node, it must be reduced by the same extend. --- source/gameengine/Physics/Bullet/CcdPhysicsController.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 7196a1ae095..47329235517 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -962,8 +962,12 @@ void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bo body->applyCentralForce(force); btSoftBody* soft = GetSoftBody(); if (soft) + { + // the force is applied on each node, must reduce it in the same extend + if (soft->m_nodes.size() > 0) + force /= soft->m_nodes.size(); soft->addForce(force); - + } } } } -- cgit v1.2.3 From 808d6197cfa372c15067aa14a91791ba9b167915 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Tue, 30 Sep 2008 23:34:25 +0000 Subject: add support for Bullet soft body constraints against a Bullet rigid body, as well as 'fixing' it. Just use the existing rigid body joint to use it. For now, it searches the closest node/vertex to the pivot. So you can use multiple constraints/joint to attach a cloth, soft body etc. --- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 86 +++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index fc19789196d..72caadadac5 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1464,6 +1464,26 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi return sphereController; } +int findClosestNode(btSoftBody* sb,const btVector3& worldPoint); +int findClosestNode(btSoftBody* sb,const btVector3& worldPoint) +{ + int node = -1; + + btSoftBody::tNodeArray& nodes(sb->m_nodes); + float maxDistSqr = 1e30f; + + for (int n=0;nGetRigidBody() : 0; btRigidBody* rb1 = c1 ? c1->GetRigidBody() : 0; + + + bool rb0static = rb0 ? rb0->isStaticOrKinematicObject() : true; bool rb1static = rb1 ? rb1->isStaticOrKinematicObject() : true; + + btCollisionObject* colObj0 = c0->GetCollisionObject(); + if (!colObj0) + { + return 0; + } + + btVector3 pivotInA(pivotX,pivotY,pivotZ); + + //it might be a soft body, let's try + btSoftBody* sb0 = c0 ? c0->GetSoftBody() : 0; + btSoftBody* sb1 = c1 ? c1->GetSoftBody() : 0; + if (sb0 && sb1) + { + //not between two soft bodies? + return 0; + } + + if (sb0) + { + //either cluster or node attach, let's find closest node first + //the soft body doesn't have a 'real' world transform, so get its initial world transform for now + btVector3 pivotPointSoftWorld = sb0->m_initialWorldTransform(pivotInA); + int node=findClosestNode(sb0,pivotPointSoftWorld); + if (node >=0) + { + if (rb1) + { + sb0->appendAnchor(node,rb1); + } else + { + sb0->setMass(node,0.f); + } + } + return 0;//can't remove soft body anchors yet + } + + if (sb1) + { + btVector3 pivotPointAWorld = colObj0->getWorldTransform()(pivotInA); + int node=findClosestNode(sb1,pivotPointAWorld); + if (node >=0) + { + if (rb0) + { + sb1->appendAnchor(node,rb0); + } else + { + sb1->setMass(node,0.f); + } + } + return 0;//can't remove soft body anchors yet + } + if (rb0static && rb1static) + { + return 0; + } + - btVector3 pivotInA(pivotX,pivotY,pivotZ); + if (!rb0) + return 0; + + btVector3 pivotInB = rb1 ? rb1->getCenterOfMassTransform().inverse()(rb0->getCenterOfMassTransform()(pivotInA)) : rb0->getCenterOfMassTransform() * pivotInA; btVector3 axisInA(axisX,axisY,axisZ); -- cgit v1.2.3 From aa5c4f8801f64f99be83eb419e9664f732650ede Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Wed, 1 Oct 2008 06:36:17 +0000 Subject: + hook up a few more parameters, that can be useful for Bullet soft bodies + work-in-progress to hook up cluster constraints (they are better than node/vertex pinning, because they maintain a proper world coordinate system) --- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 104 +++++++++++++++++++-- 1 file changed, 96 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 72caadadac5..91655e96101 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1532,13 +1532,56 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl int node=findClosestNode(sb0,pivotPointSoftWorld); if (node >=0) { - if (rb1) + bool clusterconstaint = false; +/* + switch (type) { - sb0->appendAnchor(node,rb1); - } else + case PHY_LINEHINGE_CONSTRAINT: + { + if (sb0->clusterCount() && rb1) + { + btSoftBody::LJoint::Specs ls; + ls.erp=0.5f; + ls.position=sb0->clusterCom(0); + sb0->appendLinearJoint(ls,rb1); + clusterconstaint = true; + break; + } + } + case PHY_GENERIC_6DOF_CONSTRAINT: + { + if (sb0->clusterCount() && rb1) + { + btSoftBody::AJoint::Specs as; + as.erp = 1; + as.cfm = 1; + as.axis.setValue(axisX,axisY,axisZ); + sb0->appendAngularJoint(as,rb1); + clusterconstaint = true; + break; + } + + break; + } + default: + { + + } + }; + */ + + if (!clusterconstaint) { - sb0->setMass(node,0.f); + if (rb1) + { + sb0->appendAnchor(node,rb1); + } else + { + sb0->setMass(node,0.f); + } } + + } return 0;//can't remove soft body anchors yet } @@ -1549,13 +1592,58 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl int node=findClosestNode(sb1,pivotPointAWorld); if (node >=0) { - if (rb0) + bool clusterconstaint = false; + + /* + switch (type) { - sb1->appendAnchor(node,rb0); - } else + case PHY_LINEHINGE_CONSTRAINT: + { + if (sb1->clusterCount() && rb0) + { + btSoftBody::LJoint::Specs ls; + ls.erp=0.5f; + ls.position=sb1->clusterCom(0); + sb1->appendLinearJoint(ls,rb0); + clusterconstaint = true; + break; + } + } + case PHY_GENERIC_6DOF_CONSTRAINT: + { + if (sb1->clusterCount() && rb0) + { + btSoftBody::AJoint::Specs as; + as.erp = 1; + as.cfm = 1; + as.axis.setValue(axisX,axisY,axisZ); + sb1->appendAngularJoint(as,rb0); + clusterconstaint = true; + break; + } + + break; + } + default: + { + + + } + };*/ + + + if (!clusterconstaint) { - sb1->setMass(node,0.f); + if (rb0) + { + sb1->appendAnchor(node,rb0); + } else + { + sb1->setMass(node,0.f); + } } + + } return 0;//can't remove soft body anchors yet } -- cgit v1.2.3 From 949b6ca80f68d5cb99a0d17dd66238ef15444ac2 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 1 Oct 2008 07:55:02 +0000 Subject: BGE bug #17688 fixed: Near Sensor Reset not working (for Gamekit) Implementation of the PHY_IPhysicsController::SetMargin(), GetMargin(), SetRadius() and GetRadius() for Bullet and Sumo to allow resetting the Near sensor radius. For bullet use the new setUnscaledRadius() function to change sphere radius. In pPreparation of a Fh constraint actuator: - Add KX_IPhysicsController::GetRadius() - Fix implementation of KX_BulletPhysicsController::GetVelocity() (velocity at a point in geometric coordinate) - Don't try to set velocity on static object (Bullet will assert) - Add KX_GameObject::GetVelocity() for C access to local velocity --- .../Ketsji/KX_BulletPhysicsController.cpp | 8 ++++++- .../gameengine/Ketsji/KX_BulletPhysicsController.h | 4 +--- source/gameengine/Ketsji/KX_GameObject.cpp | 9 +++++++- source/gameengine/Ketsji/KX_GameObject.h | 9 ++++++++ source/gameengine/Ketsji/KX_IPhysicsController.h | 4 ++++ source/gameengine/Ketsji/KX_NearSensor.cpp | 4 ++-- .../gameengine/Ketsji/KX_OdePhysicsController.cpp | 5 +++++ source/gameengine/Ketsji/KX_OdePhysicsController.h | 2 +- .../gameengine/Ketsji/KX_SumoPhysicsController.cpp | 5 +++++ .../gameengine/Ketsji/KX_SumoPhysicsController.h | 1 + .../Physics/BlOde/OdePhysicsController.h | 2 ++ .../Physics/Bullet/CcdPhysicsController.cpp | 6 +++--- .../Physics/Bullet/CcdPhysicsController.h | 25 ++++++++++++++++++++-- .../Physics/Sumo/SumoPhysicsController.h | 1 + .../Physics/common/PHY_IPhysicsController.h | 3 ++- 15 files changed, 74 insertions(+), 14 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index 3d20ce8a3a5..bf838e60210 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -115,7 +115,7 @@ MT_Vector3 KX_BulletPhysicsController::GetAngularVelocity() MT_Vector3 KX_BulletPhysicsController::GetVelocity(const MT_Point3& pos) { float linVel[3]; - CcdPhysicsController::GetLinearVelocity(linVel[0],linVel[1],linVel[2]); + CcdPhysicsController::GetVelocity(pos[0], pos[1], pos[2], linVel[0],linVel[1],linVel[2]); return MT_Vector3(linVel[0],linVel[1],linVel[2]); } @@ -160,6 +160,12 @@ MT_Scalar KX_BulletPhysicsController::GetMass() return 0.f; } + +MT_Scalar KX_BulletPhysicsController::GetRadius() +{ + return MT_Scalar(CcdPhysicsController::GetRadius()); +} + MT_Vector3 KX_BulletPhysicsController::getReactionForce() { assert(0); diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h index 2efe0474b30..cdcb82c87ca 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h @@ -49,9 +49,7 @@ public: virtual SG_Controller* GetReplica(class SG_Node* destnode); - void SetDyna(bool isDynamic) { - m_bDyna = isDynamic; - } + virtual MT_Scalar GetRadius(); virtual void SetSumoTransform(bool nondynaonly); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 15055a9cf93..1b57b9acc1d 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -772,7 +772,14 @@ MT_Vector3 KX_GameObject::GetAngularVelocity(bool local) return velocity; } - +MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point) +{ + if (m_pPhysicsController1) + { + return m_pPhysicsController1->GetVelocity(point); + } + return MT_Vector3(0.0,0.0,0.0); +} // scenegraph node stuff diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 12e29cf3294..472d31362dd 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -264,6 +264,15 @@ public: bool local=false ); + /** + * Return the linear velocity of a given point in world coordinate + * but relative to center of object ([0,0,0]=center of object) + */ + MT_Vector3 + GetVelocity( + const MT_Point3& position + ); + /** * Return the mass of the object */ diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h index ecfdb8c4275..4ea283e9f98 100644 --- a/source/gameengine/Ketsji/KX_IPhysicsController.h +++ b/source/gameengine/Ketsji/KX_IPhysicsController.h @@ -88,7 +88,11 @@ public: m_bDyna = isDynamic; } + bool IsDyna(void) { + return m_bDyna; + } + virtual MT_Scalar GetRadius()=0; virtual void SetSumoTransform(bool nondynaonly)=0; // todo: remove next line ! virtual void SetSimulatedTime(double time)=0; diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 140dd37f5c6..b00cd616a5b 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -190,13 +190,13 @@ bool KX_NearSensor::Evaluate(CValue* event) { if (m_physCtrl) { - m_physCtrl->SetMargin(m_ResetMargin); + m_physCtrl->SetRadius(m_ResetMargin); } } else { if (m_physCtrl) { - m_physCtrl->SetMargin(m_Margin); + m_physCtrl->SetRadius(m_Margin); } } diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp index 05feb11a2bc..6a701a5f25b 100644 --- a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp @@ -169,6 +169,11 @@ MT_Scalar KX_OdePhysicsController::GetMass() return ODEPhysicsController::getMass(); } +MT_Scalar KX_OdePhysicsController::GetRadius() +{ + return MT_Scalar(0.f); +} + MT_Vector3 KX_OdePhysicsController::getReactionForce() { return MT_Vector3(0,0,0); diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h index 18f9edc6835..53050f6ce3e 100644 --- a/source/gameengine/Ketsji/KX_OdePhysicsController.h +++ b/source/gameengine/Ketsji/KX_OdePhysicsController.h @@ -76,7 +76,7 @@ public: virtual void SuspendDynamics(bool); virtual void RestoreDynamics(); - + virtual MT_Scalar GetRadius(); virtual SG_Controller* GetReplica(class SG_Node* destnode); diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp index 4032a795ce3..c842ca1ee14 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp @@ -205,6 +205,11 @@ MT_Scalar KX_SumoPhysicsController::GetMass() return SumoPhysicsController::getMass(); } +MT_Scalar KX_SumoPhysicsController::GetRadius() +{ + return SumoPhysicsController::GetRadius(); +} + MT_Vector3 KX_SumoPhysicsController::getReactionForce() { float force[3]; diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h index 1dd930bf3d9..abe48d99043 100644 --- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h +++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h @@ -84,6 +84,7 @@ public: virtual void setPosition(const MT_Point3& pos); virtual void setScaling(const MT_Vector3& scaling); virtual MT_Scalar GetMass(); + virtual MT_Scalar GetRadius(); virtual MT_Vector3 getReactionForce(); virtual void setRigidBody(bool rigid); diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.h b/source/gameengine/Physics/BlOde/OdePhysicsController.h index d3eb443ed3a..925f5b6686a 100644 --- a/source/gameengine/Physics/BlOde/OdePhysicsController.h +++ b/source/gameengine/Physics/BlOde/OdePhysicsController.h @@ -111,6 +111,8 @@ public: virtual void calcXform(){} virtual void SetMargin(float margin) {} virtual float GetMargin() const {return 0.f;} + virtual float GetRadius() const {return 0.f;} + virtual void SetRadius(float margin) {} // clientinfo for raycasts for example virtual void* getNewClientInfo() { return m_clientInfo;} diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 47329235517..c9c30c1b450 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -980,7 +980,7 @@ void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,flo if (m_object->isStaticObject()) { m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); - } + } else { btTransform xform = m_object->getWorldTransform(); if (local) @@ -1005,6 +1005,7 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa if (m_object->isStaticObject()) { m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT); + return; } btSoftBody* soft = GetSoftBody(); @@ -1093,8 +1094,7 @@ void CcdPhysicsController::GetVelocity(const float posX,const float posY,const btRigidBody* body = GetRigidBody(); if (body) { - btVector3 rel_pos = pos-body->getCenterOfMassPosition(); - btVector3 linvel = body->getVelocityInLocalPoint(rel_pos); + btVector3 linvel = body->getVelocityInLocalPoint(pos); linvX = linvel.x(); linvY = linvel.y(); linvZ = linvel.z(); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index a1245f6a3e9..054ec91122a 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -413,8 +413,29 @@ class CcdPhysicsController : public PHY_IPhysicsController } virtual void calcXform() {} ; - virtual void SetMargin(float margin) {}; - virtual float GetMargin() const {return 0.f;}; + virtual void SetMargin(float margin) + { + if (m_collisionShape) + m_collisionShape->setMargin(btScalar(margin)); + } + virtual float GetMargin() const + { + return (m_collisionShape) ? m_collisionShape->getMargin() : 0.f; + } + virtual float GetRadius() const + { + // this is not the actual shape radius, it's only used for Fh support + return m_cci.m_radius; + } + virtual void SetRadius(float margin) + { + if (m_collisionShape && m_collisionShape->getShapeType() == SPHERE_SHAPE_PROXYTYPE) + { + btSphereShape* sphereShape = static_cast(m_collisionShape); + sphereShape->setUnscaledRadius(margin); + } + m_cci.m_radius = margin; + } bool wantsSleeping(); diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.h b/source/gameengine/Physics/Sumo/SumoPhysicsController.h index 95f01b45f2b..d8ee54935d7 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsController.h +++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.h @@ -120,6 +120,7 @@ public: virtual void SetMargin(float margin) ; virtual float GetMargin() const; virtual float GetRadius() const ; + virtual void SetRadius(float margin) { SetMargin(margin); } // clientinfo for raycasts for example diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h index ca8edea114a..884e14cfb5a 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsController.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h @@ -90,7 +90,8 @@ class PHY_IPhysicsController virtual void calcXform() =0; virtual void SetMargin(float margin) =0; virtual float GetMargin() const=0; - virtual float GetRadius() const { return 0.f;} + virtual float GetRadius() const=0; + virtual void SetRadius(float margin) = 0; PHY__Vector3 GetWorldPosition(PHY__Vector3& localpos); }; -- cgit v1.2.3 From 8550c2b594fb1a2544b77b7f3abec84b29b1745d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 1 Oct 2008 19:16:13 +0000 Subject: BGE patch: new force field constraint actuator A new type of constraint actuator is available: Force field. It provides a very similar service to the Fh material feature but with some specificities: - It is defined at the object level: each object can have different settings and you don't need to use material. - It can be applied in all 6 directions and not just -Z. - It can be enabled/disabled easily (it's an actuator). - You can have multiple force fields active at the same time on the same object in different direction (think of a space ship in a tunnel with a repulsive force field on each wall). - You can have a different damping for the rotation. Besides that it provides the same dynamic behavior and the parameters are self explanatory. It works by adapting the linear and angular velocity: the dynamic is independent of the mass. It is compatible with all other motion actuators. Note: linear and anysotropic friction is not yet implemented, the only friction will come from the object damping parameters. Support for friction will be added in a future revision. --- .../gameengine/Converter/KX_ConvertActuators.cpp | 34 +++++++ source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 110 ++++++++++++++++++++- source/gameengine/Ketsji/KX_ConstraintActuator.h | 12 ++- 3 files changed, 152 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 78791c53d7c..b739e3b2094 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -719,6 +719,40 @@ void BL_ConvertActuators(char* maggiename, break; } prop = conact->matprop; + } else if (conact->type == ACT_CONST_TYPE_FH) { + switch (conact->mode) { + case ACT_CONST_DIRPX: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPX; + min = conact->minloc[0]; + max = conact->maxloc[0]; + break; + case ACT_CONST_DIRPY: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPY; + min = conact->minloc[1]; + max = conact->maxloc[1]; + break; + case ACT_CONST_DIRPZ: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPZ; + min = conact->minloc[2]; + max = conact->maxloc[2]; + break; + case ACT_CONST_DIRNX: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNX; + min = conact->minloc[0]; + max = conact->maxloc[0]; + break; + case ACT_CONST_DIRNY: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNY; + min = conact->minloc[1]; + max = conact->maxloc[1]; + break; + case ACT_CONST_DIRNZ: + locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNZ; + min = conact->minloc[2]; + max = conact->maxloc[2]; + break; + } + prop = conact->matprop; } else { switch (conact->flag) { case ACT_CONST_LOCX: diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 49534ccbd4a..0210f78425e 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -112,7 +112,7 @@ KX_ConstraintActuator::~KX_ConstraintActuator() bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data) { - KX_GameObject* hitKXObj = client->m_gameobject; + m_hitObject = client->m_gameobject; bool bFound = false; @@ -131,7 +131,7 @@ bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo* client, KX_RayCast* resu } else { - bFound = hitKXObj->GetProperty(m_property) != NULL; + bFound = m_hitObject->GetProperty(m_property) != NULL; } } // update the hit status @@ -372,7 +372,7 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) // logically we should cancel the speed along the ray direction as we set the // position along that axis spc = obj->GetPhysicsController(); - if (spc) { + if (spc && spc->IsDyna()) { MT_Vector3 linV = spc->GetLinearVelocity(); // cancel the projection along the ray direction MT_Scalar fallspeed = linV.dot(direction); @@ -390,6 +390,110 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame) } } break; + case KX_ACT_CONSTRAINT_FHPX: + case KX_ACT_CONSTRAINT_FHPY: + case KX_ACT_CONSTRAINT_FHPZ: + case KX_ACT_CONSTRAINT_FHNX: + case KX_ACT_CONSTRAINT_FHNY: + case KX_ACT_CONSTRAINT_FHNZ: + switch (m_locrot) { + case KX_ACT_CONSTRAINT_FHPX: + normal[0] = -rotation[0][0]; + normal[1] = -rotation[1][0]; + normal[2] = -rotation[2][0]; + direction = MT_Vector3(1.0,0.0,0.0); + break; + case KX_ACT_CONSTRAINT_FHPY: + normal[0] = -rotation[0][1]; + normal[1] = -rotation[1][1]; + normal[2] = -rotation[2][1]; + direction = MT_Vector3(0.0,1.0,0.0); + break; + case KX_ACT_CONSTRAINT_FHPZ: + normal[0] = -rotation[0][2]; + normal[1] = -rotation[1][2]; + normal[2] = -rotation[2][2]; + direction = MT_Vector3(0.0,0.0,1.0); + break; + case KX_ACT_CONSTRAINT_FHNX: + normal[0] = rotation[0][0]; + normal[1] = rotation[1][0]; + normal[2] = rotation[2][0]; + direction = MT_Vector3(-1.0,0.0,0.0); + break; + case KX_ACT_CONSTRAINT_FHNY: + normal[0] = rotation[0][1]; + normal[1] = rotation[1][1]; + normal[2] = rotation[2][1]; + direction = MT_Vector3(0.0,-1.0,0.0); + break; + case KX_ACT_CONSTRAINT_FHNZ: + normal[0] = rotation[0][2]; + normal[1] = rotation[1][2]; + normal[2] = rotation[2][2]; + direction = MT_Vector3(0.0,0.0,-1.0); + break; + } + normal.normalize(); + { + PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment(); + KX_IPhysicsController *spc = obj->GetPhysicsController(); + + if (!pe) { + std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl; + goto CHECK_TIME; + } + if (!spc || !spc->IsDyna()) { + // the object is not dynamic, it won't support setting speed + goto CHECK_TIME; + } + m_hitObject = NULL; + // distance of Fh area is stored in m_minimum + MT_Point3 topoint = position + (m_minimumBound+spc->GetRadius()) * direction; + KX_RayCast::Callback callback(this,spc); + result = KX_RayCast::RayTest(pe, position, topoint, callback); + // we expect a hit object + if (!m_hitObject) + result = false; + if (result) + { + MT_Vector3 newnormal = callback.m_hitNormal; + // compute new position & orientation + MT_Scalar distance = (callback.m_hitPoint-position).length()-spc->GetRadius(); + // estimate the velocity of the hit point + MT_Point3 relativeHitPoint; + relativeHitPoint = (callback.m_hitPoint-m_hitObject->NodeGetWorldPosition()); + MT_Vector3 velocityHitPoint = m_hitObject->GetVelocity(relativeHitPoint); + MT_Vector3 relativeVelocity = spc->GetLinearVelocity() - velocityHitPoint; + MT_Scalar relativeVelocityRay = direction.dot(relativeVelocity); + MT_Scalar springExtent = 1.0 - distance/m_minimumBound; + // Fh force is stored in m_maximum + MT_Scalar springForce = springExtent * m_maximumBound; + // damping is stored in m_refDirection [0] = damping, [1] = rot damping + MT_Scalar springDamp = relativeVelocityRay * m_refDirection[0]; + MT_Vector3 newVelocity = spc->GetLinearVelocity()-(springForce+springDamp)*direction; + if (m_option & KX_ACT_CONSTRAINT_NORMAL) + { + newVelocity+=(springForce+springDamp)*(newnormal-newnormal.dot(direction)*direction); + } + spc->SetLinearVelocity(newVelocity, false); + if (m_option & KX_ACT_CONSTRAINT_DOROTFH) + { + MT_Vector3 angSpring = (normal.cross(newnormal))*m_maximumBound; + MT_Vector3 angVelocity = spc->GetAngularVelocity(); + // remove component that is parallel to normal + angVelocity -= angVelocity.dot(newnormal)*newnormal; + MT_Vector3 angDamp = angVelocity * ((m_refDirection[1]>MT_EPSILON)?m_refDirection[1]:m_refDirection[0]); + spc->SetAngularVelocity(spc->GetAngularVelocity()+(angSpring-angDamp), false); + } + } else if (m_option & KX_ACT_CONSTRAINT_PERMANENT) { + // no contact but still keep running + result = true; + } + // don't set the position with this constraint + goto CHECK_TIME; + } + break; case KX_ACT_CONSTRAINT_LOCX: case KX_ACT_CONSTRAINT_LOCY: case KX_ACT_CONSTRAINT_LOCZ: diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h index b2ef0dae553..28b9b1e6a0b 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.h +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h @@ -38,6 +38,7 @@ #include "KX_ClientObjectInfo.h" class KX_RayCast; +class KX_GameObject; class KX_ConstraintActuator : public SCA_IActuator { @@ -65,6 +66,8 @@ protected: int m_option; // property to check char m_property[32]; + // hit object + KX_GameObject* m_hitObject; /** * Clamp to , . Borders are included (in as far as @@ -92,6 +95,12 @@ protected: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ, + KX_ACT_CONSTRAINT_FHPX, + KX_ACT_CONSTRAINT_FHPY, + KX_ACT_CONSTRAINT_FHPZ, + KX_ACT_CONSTRAINT_FHNX, + KX_ACT_CONSTRAINT_FHNY, + KX_ACT_CONSTRAINT_FHNZ, KX_ACT_CONSTRAINT_MAX }; // match ACT_CONST_... values from BIF_interface.h @@ -100,7 +109,8 @@ protected: KX_ACT_CONSTRAINT_MATERIAL = 128, KX_ACT_CONSTRAINT_PERMANENT = 256, KX_ACT_CONSTRAINT_DISTANCE = 512, - KX_ACT_CONSTRAINT_LOCAL = 1024 + KX_ACT_CONSTRAINT_LOCAL = 1024, + KX_ACT_CONSTRAINT_DOROTFH = 2048 }; bool IsValidMode(KX_CONSTRAINTTYPE m); bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data); -- cgit v1.2.3 From c2b8702a83c93cca28262606ed610e31fef22947 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 1 Oct 2008 21:17:00 +0000 Subject: BGE patch: add frameProp to Ipo actuator (Carsten's request). --- source/gameengine/Converter/KX_ConvertActuators.cpp | 4 +++- source/gameengine/Ketsji/KX_IpoActuator.cpp | 18 +++++++++++++++++- source/gameengine/Ketsji/KX_IpoActuator.h | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index b739e3b2094..d5f304c38e7 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -235,7 +235,8 @@ void BL_ConvertActuators(char* maggiename, { bIpoActuator* ipoact = (bIpoActuator*) bact->data; bool ipochild = (ipoact->flag & ACT_IPOCHILD) !=0; - STR_String propname = ( ipoact->name ? ipoact->name : ""); + STR_String propname = ipoact->name; + STR_String frameProp = ipoact->frameProp; // first bit? bool ipo_as_force = (ipoact->flag & ACT_IPOFORCE); bool local = (ipoact->flag & ACT_IPOLOCAL); @@ -244,6 +245,7 @@ void BL_ConvertActuators(char* maggiename, KX_IpoActuator* tmpbaseact = new KX_IpoActuator( gameobj, propname , + frameProp, ipoact->sta, ipoact->end, ipochild, diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index d9945a4b131..a6a3d03d60e 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -37,6 +37,7 @@ #include "KX_IpoActuator.h" #include "KX_GameObject.h" +#include "FloatValue.h" #ifdef HAVE_CONFIG_H #include @@ -62,6 +63,7 @@ STR_String KX_IpoActuator::S_KX_ACT_IPO_FROM_PROP_STRING = "FromProp"; KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj, const STR_String& propname, + const STR_String& framePropname, float starttime, float endtime, bool recurse, @@ -78,6 +80,7 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj, m_localtime(starttime), m_direction(1), m_propname(propname), + m_framepropname(framePropname), m_ipo_as_force(ipo_as_force), m_ipo_add(ipo_add), m_ipo_local(ipo_local), @@ -356,7 +359,20 @@ bool KX_IpoActuator::Update(double curtime, bool frame) default: result = false; } - + + /* Set the property if its defined */ + if (m_framepropname[0] != '\0') { + CValue* propowner = GetParent(); + CValue* oldprop = propowner->GetProperty(m_framepropname); + CValue* newval = new CFloatValue(m_localtime); + if (oldprop) { + oldprop->SetValue(newval); + } else { + propowner->SetProperty(m_framepropname, newval); + } + newval->Release(); + } + if (!result) { if (m_type != KX_ACT_IPO_LOOPSTOP) diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h index d6f52f8d59d..8e5baed0530 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.h +++ b/source/gameengine/Ketsji/KX_IpoActuator.h @@ -72,6 +72,9 @@ protected: /** Name of the property (only used in from_prop mode). */ STR_String m_propname; + /** Name of the property where we write the current frame number */ + STR_String m_framepropname; + /** Interpret the ipo as a force? */ bool m_ipo_as_force; @@ -111,6 +114,7 @@ public: KX_IpoActuator(SCA_IObject* gameobj, const STR_String& propname, + const STR_String& framePropname, float starttime, float endtime, bool recurse, -- cgit v1.2.3 From 3ec4f674d05a9ba664f6365ef8da7a8a8ece7837 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Oct 2008 00:22:28 +0000 Subject: Python 2.4 should build with the game engine now, no thanks to python for switching from char to const char --- source/gameengine/Converter/BL_ActionActuator.cpp | 42 ++++++++--------- .../Converter/BL_ShapeActionActuator.cpp | 40 ++++++++--------- source/gameengine/Expressions/PyObjectPlus.h | 6 ++- source/gameengine/GameLogic/SCA_ActuatorSensor.cpp | 4 +- source/gameengine/GameLogic/SCA_DelaySensor.cpp | 12 ++--- source/gameengine/GameLogic/SCA_ISensor.cpp | 26 +++++------ source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 30 ++++++------- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 22 ++++----- source/gameengine/GameLogic/SCA_MouseSensor.cpp | 4 +- .../gameengine/GameLogic/SCA_PropertyActuator.cpp | 8 ++-- source/gameengine/GameLogic/SCA_PropertySensor.cpp | 12 ++--- .../gameengine/GameLogic/SCA_PythonController.cpp | 8 ++-- source/gameengine/GameLogic/SCA_RandomActuator.cpp | 34 +++++++------- source/gameengine/GameLogic/SCA_RandomSensor.cpp | 6 +-- .../Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 10 ++--- source/gameengine/Ketsji/KX_CameraActuator.cpp | 20 ++++----- source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 44 +++++++++--------- source/gameengine/Ketsji/KX_GameActuator.cpp | 4 +- source/gameengine/Ketsji/KX_IpoActuator.cpp | 42 ++++++----------- source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 14 +++--- source/gameengine/Ketsji/KX_NearSensor.cpp | 12 ++--- source/gameengine/Ketsji/KX_ParentActuator.cpp | 4 +- .../gameengine/Ketsji/KX_PyConstraintBinding.cpp | 38 ++++++++-------- source/gameengine/Ketsji/KX_PythonInit.cpp | 52 +++++++++------------- source/gameengine/Ketsji/KX_RadarSensor.cpp | 6 +-- source/gameengine/Ketsji/KX_RaySensor.cpp | 8 ++-- .../gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 16 +++---- .../Ketsji/KX_SCA_ReplaceMeshActuator.cpp | 2 +- source/gameengine/Ketsji/KX_SceneActuator.cpp | 12 ++--- source/gameengine/Ketsji/KX_StateActuator.cpp | 4 +- source/gameengine/Ketsji/KX_TouchSensor.cpp | 8 ++-- source/gameengine/Ketsji/KX_TrackToActuator.cpp | 12 ++--- source/gameengine/Ketsji/KX_VisibilityActuator.cpp | 2 +- 33 files changed, 269 insertions(+), 295 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 16bdbe6269b..4d748948c27 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -448,28 +448,28 @@ PyParentObject BL_ActionActuator::Parents[] = { }; PyMethodDef BL_ActionActuator::Methods[] = { - {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, SetAction_doc}, - {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, SetStart_doc}, - {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, SetEnd_doc}, - {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, SetBlendin_doc}, - {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, SetPriority_doc}, - {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, SetFrame_doc}, - {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, - {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, SetFrameProperty_doc}, - {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc}, - - {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, GetAction_doc}, - {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, GetStart_doc}, - {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, GetEnd_doc}, - {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, GetBlendin_doc}, - {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, GetPriority_doc}, - {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, GetFrame_doc}, - {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, - {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, GetFrameProperty_doc}, - {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, SetChannel_doc}, + {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc}, + {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, + {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, + {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc}, + {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc}, + {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc}, + {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc}, + {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc}, + + {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc}, + {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc}, + {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc}, + {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, (PY_METHODCHAR)SetChannel_doc}, // {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS}, - {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc}, - {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, SetType_doc}, + {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc}, + {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0}, {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0}, {NULL,NULL} //Sentinel diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 7a73420fc7c..46f3141be29 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -448,26 +448,26 @@ PyParentObject BL_ShapeActionActuator::Parents[] = { }; PyMethodDef BL_ShapeActionActuator::Methods[] = { - {"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, SetAction_doc}, - {"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, SetStart_doc}, - {"setEnd", (PyCFunction) BL_ShapeActionActuator::sPySetEnd, METH_VARARGS, SetEnd_doc}, - {"setBlendin", (PyCFunction) BL_ShapeActionActuator::sPySetBlendin, METH_VARARGS, SetBlendin_doc}, - {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, SetPriority_doc}, - {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, SetFrame_doc}, - {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, - {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, SetFrameProperty_doc}, - {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc}, - - {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, GetAction_doc}, - {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_NOARGS, GetStart_doc}, - {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_NOARGS, GetEnd_doc}, - {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_NOARGS, GetBlendin_doc}, - {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, GetPriority_doc}, - {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, GetFrame_doc}, - {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, GetProperty_doc}, - {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, GetFrameProperty_doc}, - {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, GetType_doc}, - {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, SetType_doc}, + {"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc}, + {"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, + {"setEnd", (PyCFunction) BL_ShapeActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, + {"setBlendin", (PyCFunction) BL_ShapeActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc}, + {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc}, + {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc}, + {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc}, + {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc}, + + {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, (PY_METHODCHAR)GetAction_doc}, + {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc}, + {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_NOARGS, (PY_METHODCHAR)GetEnd_doc}, + {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_NOARGS, (PY_METHODCHAR)GetBlendin_doc}, + {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, (PY_METHODCHAR)GetPriority_doc}, + {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, (PY_METHODCHAR)GetFrame_doc}, + {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, (PY_METHODCHAR)GetFrameProperty_doc}, + {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc}, + {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, (PY_METHODCHAR)SetType_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h index 9d5e31aa757..3a054454a0b 100644 --- a/source/gameengine/Expressions/PyObjectPlus.h +++ b/source/gameengine/Expressions/PyObjectPlus.h @@ -64,10 +64,12 @@ typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN +#define PY_METHODCHAR char * #else /* Py 2.5 and later */ #define intargfunc ssizeargfunc #define intintargfunc ssizessizeargfunc +#define PY_METHODCHAR const char * #endif // some basic python macros @@ -181,10 +183,10 @@ static inline void Py_Fatal(const char *M) { * Method table macro (with doc) */ #define KX_PYMETHODTABLE(class_name, method_name) \ - {#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, class_name::method_name##_doc} + {#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (PY_METHODCHAR)class_name::method_name##_doc} #define KX_PYMETHODTABLE_NOARG(class_name, method_name) \ - {#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, class_name::method_name##_doc} + {#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (PY_METHODCHAR)class_name::method_name##_doc} /** * Function implementation macro diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp index 95fb7e20ad0..7c37b237d60 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp +++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp @@ -149,8 +149,8 @@ PyParentObject SCA_ActuatorSensor::Parents[] = { }; PyMethodDef SCA_ActuatorSensor::Methods[] = { - {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, GetActuator_doc}, - {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, SetActuator_doc}, + {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, (PY_METHODCHAR)GetActuator_doc}, + {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, (PY_METHODCHAR)SetActuator_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp index 577c523f51f..f15d4c7249f 100644 --- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp +++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp @@ -159,13 +159,13 @@ PyParentObject SCA_DelaySensor::Parents[] = { PyMethodDef SCA_DelaySensor::Methods[] = { /* setProperty */ - {"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, SetDelay_doc}, - {"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, SetDuration_doc}, - {"setRepeat", (PyCFunction) SCA_DelaySensor::sPySetRepeat, METH_VARARGS, SetRepeat_doc}, + {"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, (PY_METHODCHAR)SetDelay_doc}, + {"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, (PY_METHODCHAR)SetDuration_doc}, + {"setRepeat", (PyCFunction) SCA_DelaySensor::sPySetRepeat, METH_VARARGS, (PY_METHODCHAR)SetRepeat_doc}, /* getProperty */ - {"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, GetDelay_doc}, - {"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, GetDuration_doc}, - {"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, GetRepeat_doc}, + {"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, (PY_METHODCHAR)GetDelay_doc}, + {"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, (PY_METHODCHAR)GetDuration_doc}, + {"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, (PY_METHODCHAR)GetRepeat_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 260805e0aa8..b10ac676464 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -168,31 +168,31 @@ PyParentObject SCA_ISensor::Parents[] = { }; PyMethodDef SCA_ISensor::Methods[] = { {"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive, - METH_NOARGS, IsPositive_doc}, + METH_NOARGS, (PY_METHODCHAR)IsPositive_doc}, {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered, - METH_VARARGS, IsTriggered_doc}, + METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc}, {"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode, - METH_NOARGS, GetUsePosPulseMode_doc}, + METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc}, {"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode, - METH_VARARGS, SetUsePosPulseMode_doc}, + METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc}, {"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency, - METH_NOARGS, GetFrequency_doc}, + METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc}, {"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency, - METH_VARARGS, SetFrequency_doc}, + METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc}, {"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode, - METH_NOARGS, GetUseNegPulseMode_doc}, + METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc}, {"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode, - METH_VARARGS, SetUseNegPulseMode_doc}, + METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc}, {"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert, - METH_NOARGS, GetInvert_doc}, + METH_NOARGS, (PY_METHODCHAR)GetInvert_doc}, {"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert, - METH_VARARGS, SetInvert_doc}, + METH_VARARGS, (PY_METHODCHAR)SetInvert_doc}, {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel, - METH_NOARGS, GetLevel_doc}, + METH_NOARGS, (PY_METHODCHAR)GetLevel_doc}, {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel, - METH_VARARGS, SetLevel_doc}, + METH_VARARGS, (PY_METHODCHAR)SetLevel_doc}, {"reset", (PyCFunction) SCA_ISensor::sPyReset, - METH_NOARGS, Reset_doc}, + METH_NOARGS, (PY_METHODCHAR)Reset_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index f486e7985b3..58818240009 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -321,21 +321,21 @@ PyParentObject SCA_JoystickSensor::Parents[] = { PyMethodDef SCA_JoystickSensor::Methods[] = { - {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, GetIndex_doc}, - {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, SetIndex_doc}, - {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, GetAxis_doc}, - {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, SetAxis_doc}, - {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetRealAxis, METH_NOARGS, GetRealAxis_doc}, - {"getThreshold", (PyCFunction) SCA_JoystickSensor::sPyGetThreshold, METH_NOARGS, GetThreshold_doc}, - {"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, SetThreshold_doc}, - {"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, GetButton_doc}, - {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_VARARGS, SetButton_doc}, - {"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, GetHat_doc}, - {"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, SetHat_doc}, - {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, NumberOfAxes_doc}, - {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, NumberOfButtons_doc}, - {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, NumberOfHats_doc}, - {"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, Connected_doc}, + {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, (PY_METHODCHAR)GetIndex_doc}, + {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, (PY_METHODCHAR)SetIndex_doc}, + {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, (PY_METHODCHAR)GetAxis_doc}, + {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, (PY_METHODCHAR)SetAxis_doc}, + {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetRealAxis, METH_NOARGS, (PY_METHODCHAR)GetRealAxis_doc}, + {"getThreshold", (PyCFunction) SCA_JoystickSensor::sPyGetThreshold, METH_NOARGS, (PY_METHODCHAR)GetThreshold_doc}, + {"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, (PY_METHODCHAR)SetThreshold_doc}, + {"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, (PY_METHODCHAR)GetButton_doc}, + {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_VARARGS, (PY_METHODCHAR)SetButton_doc}, + {"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, (PY_METHODCHAR)GetHat_doc}, + {"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, (PY_METHODCHAR)SetHat_doc}, + {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, (PY_METHODCHAR)NumberOfAxes_doc}, + {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, (PY_METHODCHAR)NumberOfButtons_doc}, + {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, (PY_METHODCHAR)NumberOfHats_doc}, + {"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, (PY_METHODCHAR)Connected_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index ac773139794..d09a5394965 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -710,17 +710,17 @@ PyParentObject SCA_KeyboardSensor::Parents[] = { }; PyMethodDef SCA_KeyboardSensor::Methods[] = { - {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_VARARGS, GetKey_doc}, - {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, SetKey_doc}, - {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_VARARGS, GetHold1_doc}, - {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, SetHold1_doc}, - {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_VARARGS, GetHold2_doc}, - {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, SetHold2_doc}, -// {"getUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetUseAllKeys, METH_VARARGS, GetUseAllKeys_doc}, -// {"setUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPySetUseAllKeys, METH_VARARGS, SetUseAllKeys_doc}, - {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_VARARGS, GetPressedKeys_doc}, - {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_VARARGS, GetCurrentlyPressedKeys_doc}, -// {"getKeyEvents", (PyCFunction) SCA_KeyboardSensor::sPyGetKeyEvents, METH_VARARGS, GetKeyEvents_doc}, + {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_VARARGS, (PY_METHODCHAR)GetKey_doc}, + {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (PY_METHODCHAR)SetKey_doc}, + {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_VARARGS, (PY_METHODCHAR)GetHold1_doc}, + {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (PY_METHODCHAR)SetHold1_doc}, + {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_VARARGS, (PY_METHODCHAR)GetHold2_doc}, + {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (PY_METHODCHAR)SetHold2_doc}, +// {"getUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetUseAllKeys, METH_VARARGS, (PY_METHODCHAR)GetUseAllKeys_doc}, +// {"setUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPySetUseAllKeys, METH_VARARGS, (PY_METHODCHAR)SetUseAllKeys_doc}, + {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetPressedKeys_doc}, + {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetCurrentlyPressedKeys_doc}, +// {"getKeyEvents", (PyCFunction) SCA_KeyboardSensor::sPyGetKeyEvents, METH_VARARGS, (PY_METHODCHAR)GetKeyEvents_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index 8f56d153f02..d4952ce4777 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -283,8 +283,8 @@ PyParentObject SCA_MouseSensor::Parents[] = { }; PyMethodDef SCA_MouseSensor::Methods[] = { - {"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, GetXPosition_doc}, - {"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, GetYPosition_doc}, + {"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, (PY_METHODCHAR)GetXPosition_doc}, + {"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, (PY_METHODCHAR)GetYPosition_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp index e5ddd8d121c..3b541e87f02 100644 --- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp +++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp @@ -245,10 +245,10 @@ PyParentObject SCA_PropertyActuator::Parents[] = { }; PyMethodDef SCA_PropertyActuator::Methods[] = { - {"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, - {"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, - {"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, SetValue_doc}, - {"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, GetValue_doc}, + {"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, + {"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc}, + {"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index b1a4b776860..64e3d49c6cb 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -333,12 +333,12 @@ PyParentObject SCA_PropertySensor::Parents[] = { }; PyMethodDef SCA_PropertySensor::Methods[] = { - {"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_VARARGS, GetType_doc}, - {"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, SetType_doc}, - {"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_VARARGS, GetProperty_doc}, - {"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, SetProperty_doc}, - {"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_VARARGS, GetValue_doc}, - {"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, SetValue_doc}, + {"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc}, + {"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, + {"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, + {"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc}, + {"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 7e2fb081083..4cb9bc8fe53 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -229,10 +229,10 @@ PyParentObject SCA_PythonController::Parents[] = { NULL }; PyMethodDef SCA_PythonController::Methods[] = { - {"getActuators", (PyCFunction) SCA_PythonController::sPyGetActuators, METH_NOARGS, SCA_PythonController::GetActuators_doc}, - {"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, METH_O, SCA_PythonController::GetActuator_doc}, - {"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, METH_NOARGS, SCA_PythonController::GetSensors_doc}, - {"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, METH_O, SCA_PythonController::GetSensor_doc}, + {"getActuators", (PyCFunction) SCA_PythonController::sPyGetActuators, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetActuators_doc}, + {"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, METH_O, (PY_METHODCHAR)SCA_PythonController::GetActuator_doc}, + {"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetSensors_doc}, + {"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, METH_O, (PY_METHODCHAR)SCA_PythonController::GetSensor_doc}, {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS}, {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O}, {"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_NOARGS}, diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index e87b3dba458..7b50a483cd8 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -339,23 +339,23 @@ PyParentObject SCA_RandomActuator::Parents[] = { }; PyMethodDef SCA_RandomActuator::Methods[] = { - {"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, SetSeed_doc}, - {"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_VARARGS, GetSeed_doc}, - {"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_VARARGS, GetPara1_doc}, - {"getPara2", (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_VARARGS, GetPara2_doc}, - {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_VARARGS, GetDistribution_doc}, - {"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, - {"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc}, - {"setBoolConst", (PyCFunction) SCA_RandomActuator::sPySetBoolConst, METH_VARARGS, SetBoolConst_doc}, - {"setBoolUniform", (PyCFunction) SCA_RandomActuator::sPySetBoolUniform, METH_VARARGS, SetBoolUniform_doc}, - {"setBoolBernouilli",(PyCFunction) SCA_RandomActuator::sPySetBoolBernouilli, METH_VARARGS, SetBoolBernouilli_doc}, - {"setIntConst", (PyCFunction) SCA_RandomActuator::sPySetIntConst, METH_VARARGS, SetIntConst_doc}, - {"setIntUniform", (PyCFunction) SCA_RandomActuator::sPySetIntUniform, METH_VARARGS, SetIntUniform_doc}, - {"setIntPoisson", (PyCFunction) SCA_RandomActuator::sPySetIntPoisson, METH_VARARGS, SetIntPoisson_doc}, - {"setFloatConst", (PyCFunction) SCA_RandomActuator::sPySetFloatConst, METH_VARARGS, SetFloatConst_doc}, - {"setFloatUniform", (PyCFunction) SCA_RandomActuator::sPySetFloatUniform, METH_VARARGS, SetFloatUniform_doc}, - {"setFloatNormal", (PyCFunction) SCA_RandomActuator::sPySetFloatNormal, METH_VARARGS, SetFloatNormal_doc}, - {"setFloatNegativeExponential", (PyCFunction) SCA_RandomActuator::sPySetFloatNegativeExponential, METH_VARARGS, SetFloatNegativeExponential_doc}, + {"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc}, + {"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_VARARGS, (PY_METHODCHAR)GetSeed_doc}, + {"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_VARARGS, (PY_METHODCHAR)GetPara1_doc}, + {"getPara2", (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_VARARGS, (PY_METHODCHAR)GetPara2_doc}, + {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_VARARGS, (PY_METHODCHAR)GetDistribution_doc}, + {"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, + {"setBoolConst", (PyCFunction) SCA_RandomActuator::sPySetBoolConst, METH_VARARGS, (PY_METHODCHAR)SetBoolConst_doc}, + {"setBoolUniform", (PyCFunction) SCA_RandomActuator::sPySetBoolUniform, METH_VARARGS, (PY_METHODCHAR)SetBoolUniform_doc}, + {"setBoolBernouilli",(PyCFunction) SCA_RandomActuator::sPySetBoolBernouilli, METH_VARARGS, (PY_METHODCHAR)SetBoolBernouilli_doc}, + {"setIntConst", (PyCFunction) SCA_RandomActuator::sPySetIntConst, METH_VARARGS, (PY_METHODCHAR)SetIntConst_doc}, + {"setIntUniform", (PyCFunction) SCA_RandomActuator::sPySetIntUniform, METH_VARARGS, (PY_METHODCHAR)SetIntUniform_doc}, + {"setIntPoisson", (PyCFunction) SCA_RandomActuator::sPySetIntPoisson, METH_VARARGS, (PY_METHODCHAR)SetIntPoisson_doc}, + {"setFloatConst", (PyCFunction) SCA_RandomActuator::sPySetFloatConst, METH_VARARGS, (PY_METHODCHAR)SetFloatConst_doc}, + {"setFloatUniform", (PyCFunction) SCA_RandomActuator::sPySetFloatUniform, METH_VARARGS, (PY_METHODCHAR)SetFloatUniform_doc}, + {"setFloatNormal", (PyCFunction) SCA_RandomActuator::sPySetFloatNormal, METH_VARARGS, (PY_METHODCHAR)SetFloatNormal_doc}, + {"setFloatNegativeExponential", (PyCFunction) SCA_RandomActuator::sPySetFloatNegativeExponential, METH_VARARGS, (PY_METHODCHAR)SetFloatNegativeExponential_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 2caca1a27ec..202fd6382e6 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -154,9 +154,9 @@ PyParentObject SCA_RandomSensor::Parents[] = { }; PyMethodDef SCA_RandomSensor::Methods[] = { - {"setSeed", (PyCFunction) SCA_RandomSensor::sPySetSeed, METH_VARARGS, SetSeed_doc}, - {"getSeed", (PyCFunction) SCA_RandomSensor::sPyGetSeed, METH_VARARGS, GetSeed_doc}, - {"getLastDraw", (PyCFunction) SCA_RandomSensor::sPyGetLastDraw, METH_VARARGS, GetLastDraw_doc}, + {"setSeed", (PyCFunction) SCA_RandomSensor::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc}, + {"getSeed", (PyCFunction) SCA_RandomSensor::sPyGetSeed, METH_VARARGS, (PY_METHODCHAR)GetSeed_doc}, + {"getLastDraw", (PyCFunction) SCA_RandomSensor::sPyGetLastDraw, METH_VARARGS, (PY_METHODCHAR)GetLastDraw_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 16dbe65d508..8956df9c96b 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -197,19 +197,19 @@ PyParentObject KX_NetworkMessageSensor::Parents[] = { PyMethodDef KX_NetworkMessageSensor::Methods[] = { {"setSubjectFilterText", (PyCFunction) KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_O, - SetSubjectFilterText_doc}, + (PY_METHODCHAR)SetSubjectFilterText_doc}, {"getFrameMessageCount", (PyCFunction) KX_NetworkMessageSensor::sPyGetFrameMessageCount, METH_NOARGS, - GetFrameMessageCount_doc}, + (PY_METHODCHAR)GetFrameMessageCount_doc}, {"getBodies", (PyCFunction) KX_NetworkMessageSensor::sPyGetBodies, METH_NOARGS, - GetBodies_doc}, + (PY_METHODCHAR)GetBodies_doc}, {"getSubject", (PyCFunction) KX_NetworkMessageSensor::sPyGetSubject, METH_NOARGS, - GetSubject_doc}, + (PY_METHODCHAR)GetSubject_doc}, {"getSubjects", (PyCFunction) KX_NetworkMessageSensor::sPyGetSubjects, METH_NOARGS, - GetSubjects_doc}, + (PY_METHODCHAR)GetSubjects_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 099b0d90870..4d24e83843e 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -397,16 +397,16 @@ PyParentObject KX_CameraActuator::Parents[] = { }; PyMethodDef KX_CameraActuator::Methods[] = { - {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, SetObject_doc}, - {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, - {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, SetMin_doc}, - {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, GetMin_doc}, - {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, SetMax_doc}, - {"getMax" ,(PyCFunction) KX_CameraActuator::sPyGetMax, METH_NOARGS, GetMax_doc}, - {"setHeight",(PyCFunction) KX_CameraActuator::sPySetHeight, METH_VARARGS, SetHeight_doc}, - {"getHeight",(PyCFunction) KX_CameraActuator::sPyGetHeight, METH_NOARGS, GetHeight_doc}, - {"setXY" ,(PyCFunction) KX_CameraActuator::sPySetXY, METH_VARARGS, SetXY_doc}, - {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_VARARGS, GetXY_doc}, + {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc}, + {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc}, + {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetMin_doc}, + {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetMin_doc}, + {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetMax_doc}, + {"getMax" ,(PyCFunction) KX_CameraActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetMax_doc}, + {"setHeight",(PyCFunction) KX_CameraActuator::sPySetHeight, METH_VARARGS, (PY_METHODCHAR)SetHeight_doc}, + {"getHeight",(PyCFunction) KX_CameraActuator::sPyGetHeight, METH_NOARGS, (PY_METHODCHAR)GetHeight_doc}, + {"setXY" ,(PyCFunction) KX_CameraActuator::sPySetXY, METH_VARARGS, (PY_METHODCHAR)SetXY_doc}, + {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_VARARGS, (PY_METHODCHAR)GetXY_doc}, {NULL,NULL,NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 0210f78425e..76357e9c58f 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -587,28 +587,28 @@ PyParentObject KX_ConstraintActuator::Parents[] = { }; PyMethodDef KX_ConstraintActuator::Methods[] = { - {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, SetDamp_doc}, - {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_NOARGS, GetDamp_doc}, - {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, SetRotDamp_doc}, - {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_NOARGS, GetRotDamp_doc}, - {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, SetDirection_doc}, - {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_NOARGS, GetDirection_doc}, - {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, SetOption_doc}, - {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_NOARGS, GetOption_doc}, - {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, SetTime_doc}, - {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_NOARGS, GetTime_doc}, - {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, - {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_NOARGS, GetProperty_doc}, - {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, SetMin_doc}, - {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, GetMin_doc}, - {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, SetDistance_doc}, - {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, GetDistance_doc}, - {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, SetMax_doc}, - {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, GetMax_doc}, - {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, SetRayLength_doc}, - {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, GetRayLength_doc}, - {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, SetLimit_doc}, - {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_NOARGS, GetLimit_doc}, + {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, (PY_METHODCHAR)SetDamp_doc}, + {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_NOARGS, (PY_METHODCHAR)GetDamp_doc}, + {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, (PY_METHODCHAR)SetRotDamp_doc}, + {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_NOARGS, (PY_METHODCHAR)GetRotDamp_doc}, + {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, (PY_METHODCHAR)SetDirection_doc}, + {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_NOARGS, (PY_METHODCHAR)GetDirection_doc}, + {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, (PY_METHODCHAR)SetOption_doc}, + {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_NOARGS, (PY_METHODCHAR)GetOption_doc}, + {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, (PY_METHODCHAR)SetTime_doc}, + {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc}, + {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc}, + {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetMin_doc}, + {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetMin_doc}, + {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetDistance_doc}, + {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetDistance_doc}, + {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetMax_doc}, + {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetMax_doc}, + {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetRayLength_doc}, + {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetRayLength_doc}, + {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, (PY_METHODCHAR)SetLimit_doc}, + {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_NOARGS, (PY_METHODCHAR)GetLimit_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp index db9333eafa7..76459e46731 100644 --- a/source/gameengine/Ketsji/KX_GameActuator.cpp +++ b/source/gameengine/Ketsji/KX_GameActuator.cpp @@ -241,8 +241,8 @@ PyParentObject KX_GameActuator::Parents[] = PyMethodDef KX_GameActuator::Methods[] = { - {"getFile", (PyCFunction) KX_GameActuator::sPyGetFile, METH_VARARGS, GetFile_doc}, - {"setFile", (PyCFunction) KX_GameActuator::sPySetFile, METH_VARARGS, SetFile_doc}, + {"getFile", (PyCFunction) KX_GameActuator::sPyGetFile, METH_VARARGS, (PY_METHODCHAR)GetFile_doc}, + {"setFile", (PyCFunction) KX_GameActuator::sPySetFile, METH_VARARGS, (PY_METHODCHAR)SetFile_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index a6a3d03d60e..f5e17118ffb 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -440,34 +440,20 @@ PyParentObject KX_IpoActuator::Parents[] = { }; PyMethodDef KX_IpoActuator::Methods[] = { - {"set", (PyCFunction) KX_IpoActuator::sPySet, - METH_VARARGS, Set_doc}, - {"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty, - METH_VARARGS, SetProperty_doc}, - {"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, - METH_VARARGS, SetStart_doc}, - {"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, - METH_NOARGS, GetStart_doc}, - {"setEnd", (PyCFunction) KX_IpoActuator::sPySetEnd, - METH_VARARGS, SetEnd_doc}, - {"getEnd", (PyCFunction) KX_IpoActuator::sPyGetEnd, - METH_NOARGS, GetEnd_doc}, - {"setIpoAsForce", (PyCFunction) KX_IpoActuator::sPySetIpoAsForce, - METH_VARARGS, SetIpoAsForce_doc}, - {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, - METH_NOARGS, GetIpoAsForce_doc}, - {"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, - METH_VARARGS, SetIpoAdd_doc}, - {"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, - METH_NOARGS, GetIpoAdd_doc}, - {"setType", (PyCFunction) KX_IpoActuator::sPySetType, - METH_VARARGS, SetType_doc}, - {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, - METH_NOARGS, GetType_doc}, - {"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal, - METH_VARARGS, SetForceIpoActsLocal_doc}, - {"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal, - METH_NOARGS, GetForceIpoActsLocal_doc}, + {"set", (PyCFunction) KX_IpoActuator::sPySet, METH_VARARGS, (PY_METHODCHAR)Set_doc}, + {"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc}, + {"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc}, + {"setEnd", (PyCFunction) KX_IpoActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc}, + {"getEnd", (PyCFunction) KX_IpoActuator::sPyGetEnd, METH_NOARGS, (PY_METHODCHAR)GetEnd_doc}, + {"setIpoAsForce", (PyCFunction) KX_IpoActuator::sPySetIpoAsForce, METH_VARARGS, (PY_METHODCHAR)SetIpoAsForce_doc}, + {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, METH_NOARGS, (PY_METHODCHAR)GetIpoAsForce_doc}, + {"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, METH_VARARGS, (PY_METHODCHAR)SetIpoAdd_doc}, + {"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, METH_NOARGS, (PY_METHODCHAR)GetIpoAdd_doc}, + {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc}, + {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc}, + {"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal, METH_VARARGS, (PY_METHODCHAR)SetForceIpoActsLocal_doc}, + {"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal, METH_NOARGS, (PY_METHODCHAR)GetForceIpoActsLocal_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index c2e4430d1bc..28279b9a6b8 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -320,14 +320,12 @@ PyParentObject KX_MouseFocusSensor::Parents[] = { }; PyMethodDef KX_MouseFocusSensor::Methods[] = { - {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget, - METH_VARARGS, GetRayTarget_doc}, - {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource, - METH_VARARGS, GetRaySource_doc}, - {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_VARARGS, GetHitObject_doc}, - {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_VARARGS, GetHitPosition_doc}, - {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_VARARGS, GetHitNormal_doc}, - {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_VARARGS, GetRayDirection_doc}, + {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget, METH_VARARGS, (PY_METHODCHAR)GetRayTarget_doc}, + {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource, METH_VARARGS, (PY_METHODCHAR)GetRaySource_doc}, + {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc}, + {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_VARARGS, (PY_METHODCHAR)GetHitPosition_doc}, + {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_VARARGS, (PY_METHODCHAR)GetHitNormal_doc}, + {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_VARARGS, (PY_METHODCHAR)GetRayDirection_doc}, {NULL,NULL} //Sentinel diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index b00cd616a5b..397aedb3fa3 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -309,14 +309,10 @@ PyParentObject KX_NearSensor::Parents[] = { PyMethodDef KX_NearSensor::Methods[] = { - {"setProperty", - (PyCFunction) KX_NearSensor::sPySetProperty, METH_VARARGS, SetProperty_doc}, - {"getProperty", - (PyCFunction) KX_NearSensor::sPyGetProperty, METH_VARARGS, GetProperty_doc}, - {"getHitObject", - (PyCFunction) KX_NearSensor::sPyGetHitObject, METH_VARARGS, GetHitObject_doc}, - {"getHitObjectList", - (PyCFunction) KX_NearSensor::sPyGetHitObjectList, METH_VARARGS, GetHitObjectList_doc}, + {"setProperty", (PyCFunction) KX_NearSensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, + {"getProperty", (PyCFunction) KX_NearSensor::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, + {"getHitObject",(PyCFunction) KX_NearSensor::sPyGetHitObject, METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc}, + {"getHitObjectList", (PyCFunction) KX_NearSensor::sPyGetHitObjectList, METH_VARARGS, (PY_METHODCHAR)GetHitObjectList_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index 2dc2702ac27..eb56e8de679 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -166,8 +166,8 @@ PyParentObject KX_ParentActuator::Parents[] = { }; PyMethodDef KX_ParentActuator::Methods[] = { - {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_O, SetObject_doc}, - {"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, + {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc}, + {"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index ac63e3fade5..dea6225edc2 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -510,54 +510,54 @@ static PyObject* gPyRemoveConstraint(PyObject* self, static struct PyMethodDef physicsconstraints_methods[] = { {"setGravity",(PyCFunction) gPySetGravity, - METH_VARARGS, gPySetGravity__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetGravity__doc__}, {"setDebugMode",(PyCFunction) gPySetDebugMode, - METH_VARARGS, gPySetDebugMode__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetDebugMode__doc__}, /// settings that influence quality of the rigidbody dynamics {"setNumIterations",(PyCFunction) gPySetNumIterations, - METH_VARARGS, gPySetNumIterations__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetNumIterations__doc__}, {"setNumTimeSubSteps",(PyCFunction) gPySetNumTimeSubSteps, - METH_VARARGS, gPySetNumTimeSubSteps__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetNumTimeSubSteps__doc__}, {"setDeactivationTime",(PyCFunction) gPySetDeactivationTime, - METH_VARARGS, gPySetDeactivationTime__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationTime__doc__}, {"setDeactivationLinearTreshold",(PyCFunction) gPySetDeactivationLinearTreshold, - METH_VARARGS, gPySetDeactivationLinearTreshold__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationLinearTreshold__doc__}, {"setDeactivationAngularTreshold",(PyCFunction) gPySetDeactivationAngularTreshold, - METH_VARARGS, gPySetDeactivationAngularTreshold__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationAngularTreshold__doc__}, {"setContactBreakingTreshold",(PyCFunction) gPySetContactBreakingTreshold, - METH_VARARGS, gPySetContactBreakingTreshold__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetContactBreakingTreshold__doc__}, {"setCcdMode",(PyCFunction) gPySetCcdMode, - METH_VARARGS, gPySetCcdMode__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetCcdMode__doc__}, {"setSorConstant",(PyCFunction) gPySetSorConstant, - METH_VARARGS, gPySetSorConstant__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetSorConstant__doc__}, {"setSolverTau",(PyCFunction) gPySetSolverTau, - METH_VARARGS, gPySetSolverTau__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetSolverTau__doc__}, {"setSolverDamping",(PyCFunction) gPySetSolverDamping, - METH_VARARGS, gPySetSolverDamping__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetSolverDamping__doc__}, {"setLinearAirDamping",(PyCFunction) gPySetLinearAirDamping, - METH_VARARGS, gPySetLinearAirDamping__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetLinearAirDamping__doc__}, {"setUseEpa",(PyCFunction) gPySetUseEpa, - METH_VARARGS, gPySetUseEpa__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetUseEpa__doc__}, {"setSolverType",(PyCFunction) gPySetSolverType, - METH_VARARGS, gPySetSolverType__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPySetSolverType__doc__}, {"createConstraint",(PyCFunction) gPyCreateConstraint, - METH_VARARGS, gPyCreateConstraint__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPyCreateConstraint__doc__}, {"getVehicleConstraint",(PyCFunction) gPyGetVehicleConstraint, - METH_VARARGS, gPyGetVehicleConstraint__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPyGetVehicleConstraint__doc__}, {"removeConstraint",(PyCFunction) gPyRemoveConstraint, - METH_VARARGS, gPyRemoveConstraint__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPyRemoveConstraint__doc__}, {"getAppliedImpulse",(PyCFunction) gPyGetAppliedImpulse, - METH_VARARGS, gPyGetAppliedImpulse__doc__}, + METH_VARARGS, (PY_METHODCHAR)gPyGetAppliedImpulse__doc__}, //sentinel diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 3e271be7984..fc836234e2b 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -401,26 +401,26 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *) static struct PyMethodDef game_methods[] = { - {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, gPyExpandPath_doc}, + {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (PY_METHODCHAR)gPyExpandPath_doc}, {"getCurrentController", (PyCFunction) SCA_PythonController::sPyGetCurrentController, - METH_NOARGS, SCA_PythonController::sPyGetCurrentController__doc__}, + METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::sPyGetCurrentController__doc__}, {"getCurrentScene", (PyCFunction) gPyGetCurrentScene, - METH_NOARGS, gPyGetCurrentScene_doc.Ptr()}, + METH_NOARGS, (PY_METHODCHAR)gPyGetCurrentScene_doc.Ptr()}, {"addActiveActuator",(PyCFunction) SCA_PythonController::sPyAddActiveActuator, - METH_VARARGS, SCA_PythonController::sPyAddActiveActuator__doc__}, + METH_VARARGS, (PY_METHODCHAR)SCA_PythonController::sPyAddActiveActuator__doc__}, {"getRandomFloat",(PyCFunction) gPyGetRandomFloat, - METH_NOARGS,gPyGetRandomFloat_doc.Ptr()}, - {"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS,"set Gravitation"}, - {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS,"get audio spectrum"}, - {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS,"stop using the audio dsp (for performance reasons)"}, - {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, "Gets the logic tic rate"}, - {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"}, - {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, "Gets the physics tic rate"}, - {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"}, - {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, "Gets the estimated average frame rate"}, - {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, "Gets a list of blend files in the same directory as the current blend file"}, - {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, "Prints GL Extension Info"}, + METH_NOARGS, (PY_METHODCHAR)gPyGetRandomFloat_doc.Ptr()}, + {"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS, (PY_METHODCHAR)"set Gravitation"}, + {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS, (PY_METHODCHAR)"get audio spectrum"}, + {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS, (PY_METHODCHAR)"stop using the audio dsp (for performance reasons)"}, + {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the logic tic rate"}, + {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, (PY_METHODCHAR)"Sets the logic tic rate"}, + {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the physics tic rate"}, + {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, (PY_METHODCHAR)"Sets the physics tic rate"}, + {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (PY_METHODCHAR)"Gets the estimated average frame rate"}, + {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (PY_METHODCHAR)"Gets a list of blend files in the same directory as the current blend file"}, + {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (PY_METHODCHAR)"Prints GL Extension Info"}, {NULL, (PyCFunction) NULL, 0, NULL } }; @@ -826,27 +826,19 @@ static PyObject* gPyDrawLine(PyObject*, PyObject* args) Py_RETURN_NONE; } - -STR_String gPyGetWindowHeight__doc__="getWindowHeight doc"; -STR_String gPyGetWindowWidth__doc__="getWindowWidth doc"; -STR_String gPyEnableVisibility__doc__="enableVisibility doc"; -STR_String gPyMakeScreenshot__doc__="make Screenshot doc"; -STR_String gPyShowMouse__doc__="showMouse(bool visible)"; -STR_String gPySetMousePosition__doc__="setMousePosition(int x,int y)"; - static struct PyMethodDef rasterizer_methods[] = { {"getWindowWidth",(PyCFunction) gPyGetWindowWidth, - METH_VARARGS, gPyGetWindowWidth__doc__.Ptr()}, + METH_VARARGS, "getWindowWidth doc"}, {"getWindowHeight",(PyCFunction) gPyGetWindowHeight, - METH_VARARGS, gPyGetWindowHeight__doc__.Ptr()}, + METH_VARARGS, "getWindowHeight doc"}, {"makeScreenshot",(PyCFunction)gPyMakeScreenshot, - METH_VARARGS, gPyMakeScreenshot__doc__.Ptr()}, + METH_VARARGS, "make Screenshot doc"}, {"enableVisibility",(PyCFunction) gPyEnableVisibility, - METH_VARARGS, gPyEnableVisibility__doc__.Ptr()}, + METH_VARARGS, "enableVisibility doc"}, {"showMouse",(PyCFunction) gPyShowMouse, - METH_VARARGS, gPyShowMouse__doc__.Ptr()}, + METH_VARARGS, "showMouse(bool visible)"}, {"setMousePosition",(PyCFunction) gPySetMousePosition, - METH_VARARGS, gPySetMousePosition__doc__.Ptr()}, + METH_VARARGS, "setMousePosition(int x,int y)"}, {"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_VARARGS,"set Background Color (rgb)"}, {"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_VARARGS,"set Ambient Color (rgb)"}, {"setMistColor",(PyCFunction)gPySetMistColor,METH_VARARGS,"set Mist Color (rgb)"}, @@ -1311,7 +1303,7 @@ static PyObject* gPyEventToString(PyObject*, PyObject* value) } static struct PyMethodDef gamekeys_methods[] = { - {"EventToString", (PyCFunction)gPyEventToString, METH_O, gPyEventToString_doc}, + {"EventToString", (PyCFunction)gPyEventToString, METH_O, (PY_METHODCHAR)gPyEventToString_doc}, { NULL, (PyCFunction) NULL, 0, NULL } }; diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 9a75e58c8ca..244e9b75d8e 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -221,11 +221,11 @@ PyParentObject KX_RadarSensor::Parents[] = { PyMethodDef KX_RadarSensor::Methods[] = { {"getConeOrigin", (PyCFunction) KX_RadarSensor::sPyGetConeOrigin, - METH_VARARGS, GetConeOrigin_doc}, + METH_VARARGS, (PY_METHODCHAR)GetConeOrigin_doc}, {"getConeTarget", (PyCFunction) KX_RadarSensor::sPyGetConeTarget, - METH_VARARGS, GetConeTarget_doc}, + METH_VARARGS, (PY_METHODCHAR)GetConeTarget_doc}, {"getConeHeight", (PyCFunction) KX_RadarSensor::sPyGetConeHeight, - METH_VARARGS, GetConeHeight_doc}, + METH_VARARGS, (PY_METHODCHAR)GetConeHeight_doc}, {NULL,NULL,NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index 64897bd62ba..e24fb773eac 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -335,10 +335,10 @@ PyParentObject KX_RaySensor::Parents[] = { }; PyMethodDef KX_RaySensor::Methods[] = { - {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_VARARGS, GetHitObject_doc}, - {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_VARARGS, GetHitPosition_doc}, - {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_VARARGS, GetHitNormal_doc}, - {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_VARARGS, GetRayDirection_doc}, + {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc}, + {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_VARARGS, (PY_METHODCHAR)GetHitPosition_doc}, + {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_VARARGS, (PY_METHODCHAR)GetHitNormal_doc}, + {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_VARARGS, (PY_METHODCHAR)GetRayDirection_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index ba4a23eb427..5777f54b799 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -188,14 +188,14 @@ PyParentObject KX_SCA_AddObjectActuator::Parents[] = { NULL }; PyMethodDef KX_SCA_AddObjectActuator::Methods[] = { - {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, SetObject_doc}, - {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, SetTime_doc}, - {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, - {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, GetTime_doc}, - {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, GetLinearVelocity_doc}, - {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, SetLinearVelocity_doc}, - {"getAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetAngularVelocity, METH_NOARGS, GetAngularVelocity_doc}, - {"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, SetAngularVelocity_doc}, + {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc}, + {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, (PY_METHODCHAR)SetTime_doc}, + {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc}, + {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc}, + {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, (PY_METHODCHAR)GetLinearVelocity_doc}, + {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, (PY_METHODCHAR)SetLinearVelocity_doc}, + {"getAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetAngularVelocity, METH_NOARGS, (PY_METHODCHAR)GetAngularVelocity_doc}, + {"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, (PY_METHODCHAR)SetAngularVelocity_doc}, {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_NOARGS,"getLastCreatedObject() : get the object handle to the last created object\n"}, {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS,"instantAddObject() : immediately add object without delay\n"}, diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index a5cd3f85f85..261d9ec8f0c 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -82,7 +82,7 @@ PyParentObject KX_SCA_ReplaceMeshActuator::Parents[] = { PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = { - {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, SetMesh_doc}, + {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, (PY_METHODCHAR)SetMesh_doc}, KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh), KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh), diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp index 7d0181b162f..35484699b17 100644 --- a/source/gameengine/Ketsji/KX_SceneActuator.cpp +++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp @@ -259,12 +259,12 @@ PyParentObject KX_SceneActuator::Parents[] = PyMethodDef KX_SceneActuator::Methods[] = { - {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, SetUseRestart_doc}, - {"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, SetScene_doc}, - {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_VARARGS, SetCamera_doc}, - {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_VARARGS, GetUseRestart_doc}, - {"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_VARARGS, GetScene_doc}, - {"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_VARARGS, GetCamera_doc}, + {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (PY_METHODCHAR)SetUseRestart_doc}, + {"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (PY_METHODCHAR)SetScene_doc}, + {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_VARARGS, (PY_METHODCHAR)SetCamera_doc}, + {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_VARARGS, (PY_METHODCHAR)GetUseRestart_doc}, + {"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_VARARGS, (PY_METHODCHAR)GetScene_doc}, + {"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_VARARGS, (PY_METHODCHAR)GetCamera_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp index be874c97b3c..e360c4bac1f 100644 --- a/source/gameengine/Ketsji/KX_StateActuator.cpp +++ b/source/gameengine/Ketsji/KX_StateActuator.cpp @@ -140,9 +140,9 @@ KX_StateActuator::Parents[] = { PyMethodDef KX_StateActuator::Methods[] = { {"setOperation", (PyCFunction) KX_StateActuator::sPySetOperation, - METH_VARARGS, SetOperation_doc}, + METH_VARARGS, (PY_METHODCHAR)SetOperation_doc}, {"setMask", (PyCFunction) KX_StateActuator::sPySetMask, - METH_VARARGS, SetMask_doc}, + METH_VARARGS, (PY_METHODCHAR)SetMask_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index ad0b7428a24..41757a23f7a 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -240,13 +240,13 @@ PyParentObject KX_TouchSensor::Parents[] = { PyMethodDef KX_TouchSensor::Methods[] = { {"setProperty", - (PyCFunction) KX_TouchSensor::sPySetProperty, METH_VARARGS, SetProperty_doc}, + (PyCFunction) KX_TouchSensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc}, {"getProperty", - (PyCFunction) KX_TouchSensor::sPyGetProperty, METH_VARARGS, GetProperty_doc}, + (PyCFunction) KX_TouchSensor::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc}, {"getHitObject", - (PyCFunction) KX_TouchSensor::sPyGetHitObject, METH_VARARGS, GetHitObject_doc}, + (PyCFunction) KX_TouchSensor::sPyGetHitObject, METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc}, {"getHitObjectList", - (PyCFunction) KX_TouchSensor::sPyGetHitObjectList, METH_VARARGS, GetHitObjectList_doc}, + (PyCFunction) KX_TouchSensor::sPyGetHitObjectList, METH_VARARGS, (PY_METHODCHAR)GetHitObjectList_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 42f11adf004..acc4a6ab5d7 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -456,12 +456,12 @@ PyParentObject KX_TrackToActuator::Parents[] = { PyMethodDef KX_TrackToActuator::Methods[] = { - {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, SetObject_doc}, - {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, GetObject_doc}, - {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, SetTime_doc}, - {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_VARARGS, GetTime_doc}, - {"setUse3D", (PyCFunction) KX_TrackToActuator::sPySetUse3D, METH_VARARGS, SetUse3D_doc}, - {"getUse3D", (PyCFunction) KX_TrackToActuator::sPyGetUse3D, METH_VARARGS, GetUse3D_doc}, + {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc}, + {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc}, + {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, (PY_METHODCHAR)SetTime_doc}, + {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_VARARGS, (PY_METHODCHAR)GetTime_doc}, + {"setUse3D", (PyCFunction) KX_TrackToActuator::sPySetUse3D, METH_VARARGS, (PY_METHODCHAR)SetUse3D_doc}, + {"getUse3D", (PyCFunction) KX_TrackToActuator::sPyGetUse3D, METH_VARARGS, (PY_METHODCHAR)GetUse3D_doc}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp index 7fe9d81e2e1..4b0db5a7953 100644 --- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp +++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp @@ -122,7 +122,7 @@ KX_VisibilityActuator::Parents[] = { PyMethodDef KX_VisibilityActuator::Methods[] = { {"set", (PyCFunction) KX_VisibilityActuator::sPySetVisible, - METH_VARARGS, SetVisible_doc}, + METH_VARARGS, (PY_METHODCHAR)SetVisible_doc}, {NULL,NULL} //Sentinel }; -- cgit v1.2.3 From 365282e5c8c382a26f5111a8ae9921a989235e66 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Oct 2008 04:41:02 +0000 Subject: error with GameLogic.globalDict loading. It would replace the dictionary rather then updating it. This meant the BGE would load in an old dictonary replacing the loaded dict, loosing settings. was also missing a decref for marshal data --- source/gameengine/Ketsji/KX_PythonInit.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index fc836234e2b..53b141a9bfe 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1505,10 +1505,17 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) if (gameLogic) { PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length); - if (pyGlobalDict) { - PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + PyObject* pyGlobalDict_orig = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module. + if (pyGlobalDict_orig) { + PyDict_Clear(pyGlobalDict_orig); + PyDict_Update(pyGlobalDict_orig, pyGlobalDict); + } else { + /* this should not happen, but cant find the original globalDict, just assign it then */ + PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. + } Py_DECREF(gameLogic); + Py_DECREF(pyGlobalDict); return 1; } else { Py_DECREF(gameLogic); -- cgit v1.2.3 From a618708f48088d0975cb2b3e0a92b547579aea76 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Oct 2008 06:27:41 +0000 Subject: Blender works with python 2.6, our own import functions that replace pythons internal function needed updating for an extra in argument in 2.6. if importing is not working blender should not crash (was crashing on exit) --- source/gameengine/Ketsji/KX_PythonInit.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 53b141a9bfe..cdf7ebd0943 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1077,9 +1077,17 @@ PyObject *KXpy_import(PyObject *self, PyObject *args) PyObject *fromlist = NULL; PyObject *l, *m, *n; +#if (PY_VERSION_HEX >= 0x02060000) + int dummy_val; /* what does this do?*/ + + if (!PyArg_ParseTuple(args, "s|OOOi:m_import", + &name, &globals, &locals, &fromlist, &dummy_val)) + return NULL; +#else if (!PyArg_ParseTuple(args, "s|OOO:m_import", &name, &globals, &locals, &fromlist)) return NULL; +#endif /* check for builtin modules */ m = PyImport_AddModule("sys"); @@ -1492,6 +1500,7 @@ int saveGamePythonConfig( char **marshal_buffer) } Py_DECREF(gameLogic); } else { + PyErr_Clear(); printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); } return marshal_length; @@ -1523,6 +1532,7 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) printf("Error could not marshall string\n"); } } else { + PyErr_Clear(); printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n"); } } -- cgit v1.2.3 From df00a4b87853b276d6073b252ec66ff69d743971 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Oct 2008 09:51:43 +0000 Subject: interpreted request from Carsten - make message sensor work. object message actuators needed the prefix OB when sending a message to a specific object.--This line, and those below, will be ignored-- M source/gameengine/Converter/KX_ConvertActuators.cpp M source/blender/blenkernel/BKE_blender.h M source/blender/src/buttons_logic.c M source/blender/blenloader/intern/readfile.c --- source/gameengine/Converter/KX_ConvertActuators.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index d5f304c38e7..4f152acc918 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -291,15 +291,19 @@ void BL_ConvertActuators(char* maggiename, STR_String toPropName = (msgAct->toPropName ? (char*) msgAct->toPropName : ""); - /** - * Get the Message Subject to send. + /* BGE Wants "OB" prefix */ + if (toPropName != "") + toPropName = "OB" + toPropName; + + /** + * Get the Message Subject to send. */ STR_String subject = (msgAct->subject ? (char*) msgAct->subject : ""); - /** - * Get the bodyType + /** + * Get the bodyType */ int bodyType = msgAct->bodyType; -- cgit v1.2.3 From d7589d8bc88bac0f7af3b674d7a3737391532b0d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 4 Oct 2008 16:42:36 +0000 Subject: Game player: preserve material, debug settings, between .blend files. --- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 9700e6387f2..fbb8d6530ba 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -659,7 +659,9 @@ int main(int argc, char** argv) Main *maggie = bfd->main; Scene *scene = bfd->curscene; G.main = maggie; - G.fileflags = bfd->fileflags; + + if (firstTimeRunning) + G.fileflags = bfd->fileflags; //Seg Fault; icon.c gIcons == 0 BKE_icons_init(1); -- cgit v1.2.3 From 32d7a061310177921d6055ef389a9734c78f79d3 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 4 Oct 2008 17:04:23 +0000 Subject: Bugfix: modified game material settings in blender didn't get taken into account when loading a new .blend. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 0d58810e156..1110c4e0b48 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -135,15 +135,6 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); bool game2ipo = (SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0); bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0); - bool usemat = false, useglslmat = false; - - if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) - usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0); - - if(GPU_extensions_minimum_support()) - useglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 1) != 0); - else if(G.fileflags & G_FILE_GAME_MAT_GLSL) - usemat = false; // create the canvas, rasterizer and rendertools RAS_ICanvas* canvas = new KX_BlenderCanvas(area); @@ -316,10 +307,18 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, if (always_use_expand_framing) sceneconverter->SetAlwaysUseExpandFraming(true); - if(usemat && (G.fileflags & G_FILE_GAME_MAT)) - sceneconverter->SetMaterials(true); - if(useglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)) - sceneconverter->SetGLSLMaterials(true); + bool usemat = false, useglslmat = false; + + if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) + usemat = true; + + if(GPU_extensions_minimum_support()) + useglslmat = true; + else if(G.fileflags & G_FILE_GAME_MAT_GLSL) + usemat = false; + + sceneconverter->SetMaterials(usemat && (G.fileflags & G_FILE_GAME_MAT)); + sceneconverter->SetGLSLMaterials(useglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)); KX_Scene* startscene = new KX_Scene(keyboarddevice, mousedevice, -- cgit v1.2.3 From 77484d28d5098de2fd3924df28d846023d7751ec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Oct 2008 05:09:24 +0000 Subject: joystick update * use SDL events to trigger the sensor, trigger was being forced every tick. removed workaround for this problem. * added "All Events" option, similar to all keys in the keyboard sensor. This means every event from the joystick will trigger the sensor, however only events from the selected type (axis/button/hat) is used to set the positive state of the sensor. * Added python function sens_joy.GetButtonValues(), returns a list of pressed button indicies. * Removed pressed/released option for joystick buttons, it was the same as the invert option. --- source/gameengine/Converter/KX_ConvertSensors.cpp | 7 +- .../gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 110 +++++++----------- .../gameengine/GameLogic/Joystick/SCA_Joystick.h | 24 ++-- .../GameLogic/Joystick/SCA_JoystickEvents.cpp | 25 +++- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 129 +++++++++++---------- source/gameengine/GameLogic/SCA_JoystickSensor.h | 16 ++- 6 files changed, 161 insertions(+), 150 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index be0bb8103c0..e538afb69a2 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -685,7 +685,6 @@ void BL_ConvertSensors(struct Object* blenderobject, int axis =0; int axisf =0; int button =0; - int buttonf =0; int hat =0; int hatf =0; int prec =0; @@ -700,7 +699,6 @@ void BL_ConvertSensors(struct Object* blenderobject, break; case SENS_JOY_BUTTON: button = bjoy->button; - buttonf = bjoy->buttonf; joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_BUTTON; break; case SENS_JOY_HAT: @@ -719,8 +717,9 @@ void BL_ConvertSensors(struct Object* blenderobject, joysticktype, axis,axisf, prec, - button,buttonf, - hat,hatf); + button, + hat,hatf, + (bjoy->flag & SENS_JOY_ANY_EVENT)); } else { diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 092956e6489..b50cfe812a9 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -24,7 +24,9 @@ * * ***** END GPL LICENSE BLOCK ***** */ +#ifndef DISABLE_SDL #include +#endif #include "SCA_Joystick.h" #include "SCA_JoystickPrivate.h" @@ -40,7 +42,10 @@ SCA_Joystick::SCA_Joystick(short int index) m_buttonnum(-2), m_hatdir(-2), m_isinit(0), - m_istrig(0) + m_istrig(0), + m_axismax(-1), + m_buttonmax(-1), + m_hatmax(-1) { #ifndef DISABLE_SDL m_private = new PrivateData(); @@ -116,12 +121,19 @@ void SCA_Joystick::cSetPrecision(int val) } +bool SCA_Joystick::aAnyAxisIsPositive(int axis) +{ + bool result; + int res = pAxisTest(axis); + res > m_prec? result = true: result = false; + return result; +} + bool SCA_Joystick::aRightAxisIsPositive(int axis) { bool result; int res = pGetAxis(axis,1); res > m_prec? result = true: result = false; - m_istrig = result; return result; } @@ -131,7 +143,6 @@ bool SCA_Joystick::aUpAxisIsPositive(int axis) bool result; int res = pGetAxis(axis,0); res < -m_prec? result = true : result = false; - m_istrig = result; return result; } @@ -141,7 +152,6 @@ bool SCA_Joystick::aLeftAxisIsPositive(int axis) bool result; int res = pGetAxis(axis,1); res < -m_prec ? result = true : result = false; - m_istrig = result; return result; } @@ -151,10 +161,18 @@ bool SCA_Joystick::aDownAxisIsPositive(int axis) bool result; int res = pGetAxis(axis,0); res > m_prec ? result = true:result = false; - m_istrig = result; return result; } +bool SCA_Joystick::aAnyButtonPressIsPositive(void) +{ + return (m_buttonnum==-2) ? false : true; +} + +bool SCA_Joystick::aAnyButtonReleaseIsPositive(void) +{ + return (m_buttonnum==-2) ? true : false; +} bool SCA_Joystick::aButtonPressIsPositive(int button) { @@ -163,7 +181,6 @@ bool SCA_Joystick::aButtonPressIsPositive(int button) #else bool result; SDL_JoystickGetButton(m_private->m_joystick, button)? result = true:result = false; - m_istrig = result; return result; #endif } @@ -176,7 +193,6 @@ bool SCA_Joystick::aButtonReleaseIsPositive(int button) #else bool result; SDL_JoystickGetButton(m_private->m_joystick, button)? result = false : result = true; - m_istrig = result; return result; #endif } @@ -187,27 +203,9 @@ bool SCA_Joystick::aHatIsPositive(int dir) bool result; int res = pGetHat(dir); res == dir? result = true : result = false; - m_istrig = result; return result; } - -int SCA_Joystick::pGetButtonPress(int button) -{ - if(button == m_buttonnum) - return m_buttonnum; - return -2; -} - - -int SCA_Joystick::pGetButtonRelease(int button) -{ - if(button == m_buttonnum) - return m_buttonnum; - return -2; -} - - int SCA_Joystick::pGetHat(int direction) { if(direction == m_hatdir){ @@ -218,52 +216,19 @@ int SCA_Joystick::pGetHat(int direction) int SCA_Joystick::GetNumberOfAxes() { -#ifdef DISABLE_SDL - return -1; -#else - int number; - if(m_isinit){ - if(m_private->m_joystick){ - number = SDL_JoystickNumAxes(m_private->m_joystick); - return number; - } - } - return -1; -#endif + return m_axismax; } int SCA_Joystick::GetNumberOfButtons() { -#ifdef DISABLE_SDL - return -1; -#else - int number; - if(m_isinit){ - if(m_private->m_joystick){ - number = SDL_JoystickNumButtons(m_private->m_joystick); - return number; - } - } - return -1; -#endif + return m_buttonmax; } int SCA_Joystick::GetNumberOfHats() { -#ifdef DISABLE_SDL - return -1; -#else - int number; - if(m_isinit){ - if(m_private->m_joystick){ - number = SDL_JoystickNumHats(m_private->m_joystick); - return number; - } - } - return -1; -#endif + return m_hatmax; } bool SCA_Joystick::CreateJoystickDevice(void) @@ -280,9 +245,14 @@ bool SCA_Joystick::CreateJoystickDevice(void) m_private->m_joystick = SDL_JoystickOpen(m_joyindex); SDL_JoystickEventState(SDL_ENABLE); - - echo("Joystick " << m_joyindex << " initialized"); m_isinit = true; + + echo("Joystick " << m_joyindex << " initialized"); + + /* must run after being initialized */ + m_axismax = SDL_JoystickNumAxes(m_private->m_joystick); + m_buttonmax = SDL_JoystickNumButtons(m_private->m_joystick); + m_hatmax = SDL_JoystickNumHats(m_private->m_joystick); } return true; #endif @@ -314,10 +284,10 @@ int SCA_Joystick::Connected(void) void SCA_Joystick::pFillAxes() { #ifndef DISABLE_SDL - if(GetNumberOfAxes() == 1){ + if(m_axismax == 1){ m_axis10 = SDL_JoystickGetAxis(m_private->m_joystick, 0); m_axis11 = SDL_JoystickGetAxis(m_private->m_joystick, 1); - }else if(GetNumberOfAxes() > 1){ + }else if(m_axismax > 1){ m_axis10 = SDL_JoystickGetAxis(m_private->m_joystick, 0); m_axis11 = SDL_JoystickGetAxis(m_private->m_joystick, 1); m_axis20 = SDL_JoystickGetAxis(m_private->m_joystick, 2); @@ -340,3 +310,13 @@ int SCA_Joystick::pGetAxis(int axisnum, int udlr) return 0; } +#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) +int SCA_Joystick::pAxisTest(int axisnum) +{ +#ifndef DISABLE_SDL + if(axisnum == 1)return MAX2(abs(m_axis10), abs(m_axis11)); + if(axisnum == 2)return MAX2(abs(m_axis20), abs(m_axis21)); +#endif + return 0; +} + diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h index ea7ecf7cefe..33cfbd74d05 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h @@ -29,7 +29,9 @@ #define _SCA_JOYSTICK_H_ #include "SCA_JoystickDefines.h" +#ifndef DISABLE_SDL #include "SDL.h" +#endif /* * Basic Joystick class @@ -83,8 +85,11 @@ class SCA_Joystick /* * max # of buttons avail */ - + + int m_axismax; int m_buttonmax; + int m_hatmax; + /* * hat values stored here */ @@ -134,18 +139,12 @@ class SCA_Joystick /* * returns m_axis10,m_axis11... */ - int pGetAxis(int axisnum, int udlr); - - /* - * gets the current button - */ - - int pGetButtonPress(int button); + int pAxisTest(int axisnum); /* - * returns if no button is pressed + * returns m_axis10,m_axis11... */ - int pGetButtonRelease(int button); + int pGetAxis(int axisnum, int udlr); /* * gets the current hat direction @@ -165,11 +164,14 @@ public: /* */ - + bool aAnyAxisIsPositive(int axis); bool aUpAxisIsPositive(int axis); bool aDownAxisIsPositive(int axis); bool aLeftAxisIsPositive(int axis); bool aRightAxisIsPositive(int axis); + + bool aAnyButtonPressIsPositive(void); + bool aAnyButtonReleaseIsPositive(void); bool aButtonPressIsPositive(int button); bool aButtonReleaseIsPositive(int button); bool aHatIsPositive(int dir); diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp index 0e2078265c9..7a2ec5b3dea 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp @@ -24,7 +24,10 @@ * * ***** END GPL LICENSE BLOCK ***** */ +#ifndef DISABLE_SDL #include +#endif + #include "SCA_Joystick.h" #include "SCA_JoystickPrivate.h" @@ -46,17 +49,26 @@ void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event) m_istrig = 1; } - void SCA_Joystick::OnButtonUp(SDL_Event* sdl_event) { + m_istrig = 1; + + /* this is needed for the "all events" option + * so we know if there are no buttons pressed */ + int i; + for (i=0; im_joystick, i)) { + m_buttonnum = i; + return; + } + } m_buttonnum = -2; } void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event) { - m_buttonmax = GetNumberOfButtons(); - if(sdl_event->jbutton.button >= 1 || sdl_event->jbutton.button <= m_buttonmax) + if(sdl_event->jbutton.button >= 0 || sdl_event->jbutton.button <= m_buttonmax) { m_istrig = 1; m_buttonnum = sdl_event->jbutton.button; @@ -74,7 +86,12 @@ void SCA_Joystick::OnNothing(SDL_Event* sdl_event) void SCA_Joystick::HandleEvents(void) { SDL_Event sdl_event; - + + int i; + for (i=0; iOnNothing(&sdl_event); + } + if(SDL_PollEvent(&sdl_event)) { /* Note! m_instance[sdl_event.jaxis.which] diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 58818240009..2e9db5fb20a 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -45,27 +45,26 @@ SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr, short int joyindex, short int joymode, int axis, int axisf,int prec, - int button, int buttonf, - int hat, int hatf, + int button, + int hat, int hatf, bool allevents, PyTypeObject* T ) :SCA_ISensor(gameobj,eventmgr,T), m_pJoystickMgr(eventmgr), m_axis(axis), m_axisf(axisf), m_button(button), - m_buttonf(buttonf), m_hat(hat), m_hatf(hatf), m_precision(prec), m_joymode(joymode), - m_joyindex(joyindex) + m_joyindex(joyindex), + m_bAllEvents(allevents) { /* std::cout << " axis " << m_axis << std::endl; std::cout << " axis flag " << m_axisf << std::endl; std::cout << " precision " << m_precision << std::endl; std::cout << " button " << m_button << std::endl; -std::cout << " button flag "<< m_buttonf << std::endl; std::cout << " hat " << m_hat << std::endl; std::cout << " hat flag " << m_hatf << std::endl; */ @@ -108,9 +107,12 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) bool result = false; bool reset = m_reset && m_level; - if(js==NULL) + if(js==NULL) /* no joystick - dont do anything */ return false; + if (!js->IsTrig()) /* No events from SDL? - dont bother */ + return reset ? true : false; + m_reset = false; switch(m_joymode) { @@ -124,7 +126,18 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) numberof== m_axis -- max 2 */ js->cSetPrecision(m_precision); - if(m_axisf == 1){ + if (m_bAllEvents) { + if(js->aAnyAxisIsPositive(m_axis)){ + m_istrig = 1; + result = true; + }else{ + if(m_istrig){ + m_istrig = 0; + result = true; + } + } + } + else if(m_axisf == 1){ if(js->aUpAxisIsPositive(m_axis)){ m_istrig = 1; result = true; @@ -135,7 +148,7 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) } } } - if(m_axisf == 3){ + else if(m_axisf == 3){ if(js->aDownAxisIsPositive(m_axis)){ m_istrig = 1; result = true; @@ -146,7 +159,7 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) } } } - if(m_axisf == 2){ + else if(m_axisf == 2){ if(js->aLeftAxisIsPositive(m_axis)){ m_istrig = 1; result = true; @@ -157,7 +170,7 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) } } } - if(m_axisf == 0){ + else if(m_axisf == 0){ if(js->aRightAxisIsPositive(m_axis)){ m_istrig = 1; result = true; @@ -173,32 +186,17 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) case KX_JOYSENSORMODE_BUTTON: { /* what is what! - pressed = m_buttonf == 0 - released = m_buttonf == 1 m_button = the actual button in question */ - if(m_buttonf == 0){ - if(js->aButtonPressIsPositive(m_button)){ - m_istrig = 1; + if(( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) { + m_istrig = 1; + result = true; + }else { + if(m_istrig){ + m_istrig = 0; result = true; - }else { - if(m_istrig){ - m_istrig = 0; - result = true; - } } } - if(m_buttonf == 1){ - if(js->aButtonReleaseIsPositive(m_button)){ - m_istrig = 1; - result = true; - }else { - if(m_istrig){ - m_istrig = 0; - result = true; - } - } - } break; } case KX_JOYSENSORMODE_HAT: @@ -250,25 +248,14 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) break; } - if (js->IsTrig()) { - /* The if below detects changes with the joystick trigger state. - * js->IsTrig() will stay true as long as the key is held. - * even though the event from SDL will only be sent once. - * (js->IsTrig() && m_istrig_lastjs) - when true it means this sensor - * had the same joystick trigger state last time, - * Setting the result false this time means it wont run the sensors - * controller every time (like a pulse sensor) - * - * This is not done with the joystick its self incase other sensors use - * it or become active. - */ - if (m_istrig_lastjs) { + /* if not all events are enabled, only send a positive pulse when + * the button state changes */ + if (!m_bAllEvents) { + if (m_istrig_prev == m_istrig) { result = false; + } else { + m_istrig_prev = m_istrig; } - m_istrig_lastjs = true; - } else { - m_istrig = 0; - m_istrig_lastjs = false; } if (reset) @@ -325,11 +312,12 @@ PyMethodDef SCA_JoystickSensor::Methods[] = { {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, (PY_METHODCHAR)SetIndex_doc}, {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, (PY_METHODCHAR)GetAxis_doc}, {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, (PY_METHODCHAR)SetAxis_doc}, - {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetRealAxis, METH_NOARGS, (PY_METHODCHAR)GetRealAxis_doc}, + {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetAxisValue, METH_NOARGS, (PY_METHODCHAR)GetAxisValue_doc}, {"getThreshold", (PyCFunction) SCA_JoystickSensor::sPyGetThreshold, METH_NOARGS, (PY_METHODCHAR)GetThreshold_doc}, {"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, (PY_METHODCHAR)SetThreshold_doc}, {"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, (PY_METHODCHAR)GetButton_doc}, - {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_VARARGS, (PY_METHODCHAR)SetButton_doc}, + {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_O, (PY_METHODCHAR)SetButton_doc}, + {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(PY_METHODCHAR)GetButtonValue_doc}, {"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, (PY_METHODCHAR)GetHat_doc}, {"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, (PY_METHODCHAR)SetHat_doc}, {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, (PY_METHODCHAR)NumberOfAxes_doc}, @@ -374,7 +362,7 @@ const char SCA_JoystickSensor::GetAxis_doc[] = "getAxis\n" "\tReturns the current state of the axis.\n"; PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) { - return PyInt_FromLong(m_joyindex); + return Py_BuildValue("[ii]",m_axis, m_axisf); } @@ -395,10 +383,10 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) { /* get axis value ----------------------------------------------------- */ -const char SCA_JoystickSensor::GetRealAxis_doc[] = +const char SCA_JoystickSensor::GetAxisValue_doc[] = "getAxisValue\n" "\tReturns a list of the values for each axis .\n"; -PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self) { +PyObject* SCA_JoystickSensor::PyGetAxisValue( PyObject* self) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); if(joy) return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21()); @@ -429,30 +417,49 @@ PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, PyObject* args ) { Py_RETURN_NONE; } - /* get button -------------------------------------------------------- */ const char SCA_JoystickSensor::GetButton_doc[] = "getButton\n" -"\tReturns the currently pressed button.\n"; +"\tReturns the current button this sensor is checking.\n"; PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self) { - return Py_BuildValue("[ii]",m_button, m_buttonf); + return PyInt_FromLong(m_button); } - /* set button -------------------------------------------------------- */ const char SCA_JoystickSensor::SetButton_doc[] = "setButton\n" "\tSets the button the sensor reacts to.\n"; -PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* args ) { - int button,buttonflag; - if(!PyArg_ParseTuple(args, "ii", &button, &buttonflag)){ +PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* value ) { + int button = PyInt_AsLong(value); + if(button==-1 && PyErr_Occurred()) { + PyErr_SetString(PyExc_ValueError, "expected an int"); return NULL; } m_button = button; - m_buttonf = buttonflag; Py_RETURN_NONE; } +/* get button value -------------------------------------------------- */ +const char SCA_JoystickSensor::GetButtonValue_doc[] = +"getButtonValue\n" +"\tReturns a list containing the indicies of the currently pressed buttons.\n"; +PyObject* SCA_JoystickSensor::PyGetButtonValue( PyObject* self) { + SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); + PyObject *ls = PyList_New(0); + PyObject *value; + int i; + + if(joy) { + for (i=0; i < joy->GetNumberOfButtons(); i++) { + if (joy->aButtonPressIsPositive(i)) { + value = PyInt_FromLong(i); + PyList_Append(ls, value); + Py_DECREF(value); + } + } + } + return ls; +} /* get hat ----------------------------------------------------------- */ const char SCA_JoystickSensor::GetHat_doc[] = diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h index 8b74f6e0296..d316ad1119c 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.h +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h @@ -73,7 +73,7 @@ class SCA_JoystickSensor :public SCA_ISensor * Otherwise it will trigger all the time * this is used to see if the trigger state changes. */ - bool m_istrig_lastjs; + bool m_istrig_prev; /** * The mode to determine axis,button or hat */ @@ -83,6 +83,11 @@ class SCA_JoystickSensor :public SCA_ISensor */ short int m_joyindex; + /** + * Detect all events for the currently selected type + */ + bool m_bAllEvents; + enum KX_JOYSENSORMODE { KX_JOYSENSORMODE_NODEF = 0, KX_JOYSENSORMODE_AXIS, @@ -98,8 +103,8 @@ public: short int joyindex, short int joymode, int axis, int axisf,int prec, - int button, int buttonf, - int hat, int hatf, + int button, + int hat, int hatf, bool allevents, PyTypeObject* T=&Type ); virtual ~SCA_JoystickSensor(); virtual CValue* GetReplica(); @@ -124,12 +129,13 @@ public: /* Axes*/ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetAxis); KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetAxis); - KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetRealAxis); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetAxisValue); KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetThreshold); KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetThreshold); /* Buttons */ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButton); - KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetButton); + KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetButton); + KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonValue); /* Hats */ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetHat); KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetHat); -- cgit v1.2.3 From ce4162c9a13f8d147e898c625ffe1e10bca3b48d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 8 Oct 2008 03:16:19 +0000 Subject: * Joystick sensor is now only triggered from events of the selected type. * Keyboard sensor - added (back?) support for qualifiers (Hold buttons in the UI) --- source/gameengine/Converter/KX_ConvertSensors.cpp | 4 +- .../gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 24 ++++++-- .../gameengine/GameLogic/Joystick/SCA_Joystick.h | 20 +++++-- .../GameLogic/Joystick/SCA_JoystickEvents.cpp | 10 ++-- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 27 ++++----- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 68 +++++++++++++++++++++- 6 files changed, 119 insertions(+), 34 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index e538afb69a2..13b7f43195d 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -433,8 +433,8 @@ void BL_ConvertSensors(struct Object* blenderobject, { gamesensor = new SCA_KeyboardSensor(eventmgr, gReverseKeyTranslateTable[blenderkeybdsensor->key], - blenderkeybdsensor->qual, - blenderkeybdsensor->qual2, + gReverseKeyTranslateTable[blenderkeybdsensor->qual], + gReverseKeyTranslateTable[blenderkeybdsensor->qual2], (blenderkeybdsensor->type == SENS_ALL_KEYS), blenderkeybdsensor->targetName, blenderkeybdsensor->toggleName, diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index b50cfe812a9..f271baeed16 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -42,7 +42,9 @@ SCA_Joystick::SCA_Joystick(short int index) m_buttonnum(-2), m_hatdir(-2), m_isinit(0), - m_istrig(0), + m_istrig_axis(0), + m_istrig_button(0), + m_istrig_hat(0), m_axismax(-1), m_buttonmax(-1), m_hatmax(-1) @@ -310,13 +312,25 @@ int SCA_Joystick::pGetAxis(int axisnum, int udlr) return 0; } -#define MAX2(x,y) ( (x)>(y) ? (x) : (y) ) int SCA_Joystick::pAxisTest(int axisnum) { #ifndef DISABLE_SDL - if(axisnum == 1)return MAX2(abs(m_axis10), abs(m_axis11)); - if(axisnum == 2)return MAX2(abs(m_axis20), abs(m_axis21)); -#endif + short i1,i2; + if(axisnum == 1) { + i1 = m_axis10; i2 = m_axis11; + } + else if(axisnum == 2) { + i1 = m_axis20; i2 = m_axis21; + } + /* long winded way to do + * return MAX2(abs(i1), abs(i2)) + * avoid abs from math.h */ + if (i1 < 0) i1 = -i1; + if (i2 < 0) i2 = -i2; + if (i1 jaxis.axis; m_axisvalue = sdl_event->jaxis.value; - m_istrig = 1; + m_istrig_axis = 1; } @@ -46,12 +46,12 @@ void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event) { m_hatdir = sdl_event->jhat.value; m_hatnum = sdl_event->jhat.hat; - m_istrig = 1; + m_istrig_hat = 1; } void SCA_Joystick::OnButtonUp(SDL_Event* sdl_event) { - m_istrig = 1; + m_istrig_button = 1; /* this is needed for the "all events" option * so we know if there are no buttons pressed */ @@ -70,7 +70,7 @@ void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event) { if(sdl_event->jbutton.button >= 0 || sdl_event->jbutton.button <= m_buttonmax) { - m_istrig = 1; + m_istrig_button = 1; m_buttonnum = sdl_event->jbutton.button; } } @@ -78,7 +78,7 @@ void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event) void SCA_Joystick::OnNothing(SDL_Event* sdl_event) { - m_istrig = 0; + m_istrig_axis = m_istrig_button = m_istrig_hat = 0; } /* only handle events for 1 joystick */ diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 2e9db5fb20a..bcd3aa842b7 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -110,9 +110,6 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) if(js==NULL) /* no joystick - dont do anything */ return false; - if (!js->IsTrig()) /* No events from SDL? - dont bother */ - return reset ? true : false; - m_reset = false; switch(m_joymode) { @@ -125,6 +122,10 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) m_axisf == 3 == down numberof== m_axis -- max 2 */ + + if (!js->IsTrigAxis()) /* No events from SDL? - dont bother */ + return reset ? true : false; + js->cSetPrecision(m_precision); if (m_bAllEvents) { if(js->aAnyAxisIsPositive(m_axis)){ @@ -188,6 +189,9 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) /* what is what! m_button = the actual button in question */ + if (!js->IsTrigButton()) /* No events from SDL? - dont bother */ + return reset ? true : false; + if(( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) { m_istrig = 1; result = true; @@ -205,6 +209,10 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) numberof = m_hat -- max 2 direction= m_hatf -- max 12 */ + + if (!js->IsTrigHat()) /* No events from SDL? - dont bother */ + return reset ? true : false; + if(m_hat == 1){ if(js->aHatIsPositive(m_hatf)){ m_istrig = 1; @@ -227,19 +235,6 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) } } } - /* - if(m_hat == 3){ - if(js->aHatIsPositive(m_hatf)){ - m_istrig = 1; - result = true; - }else{ - if(m_istrig){ - m_istrig = 0; - result = true; - } - } - } - */ break; } /* test for ball anyone ?*/ diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index d09a5394965..fa39a13679f 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -122,6 +122,10 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) { bool result = false; bool reset = m_reset && m_level; + bool qual = true; + bool qual_change = false; + short int m_val_orig = m_val; + SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice(); // cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n"; @@ -202,7 +206,43 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) (SCA_IInputDevice::KX_EnumInputs) m_hotkey); // cerr << "======= SCA_KeyboardSensor::Evaluate:: status: " << inevent.m_status << endl; - + + + /* Check qualifier keys + * - see if the qualifiers we request are pressed - 'qual' true/false + * - see if the qualifiers we request changed their state - 'qual_change' true/false + */ + if (m_qual > 0) { + const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual); + switch(qualevent.m_status) { + case SCA_InputEvent::KX_NO_INPUTSTATUS: + qual = false; + break; + case SCA_InputEvent::KX_JUSTRELEASED: + qual_change = true; + qual = false; + break; + case SCA_InputEvent::KX_JUSTACTIVATED: + qual_change = true; + } + } + if (m_qual2 > 0 && qual==true) { + const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual2); + /* copy of above */ + switch(qualevent.m_status) { + case SCA_InputEvent::KX_NO_INPUTSTATUS: + qual = false; + break; + case SCA_InputEvent::KX_JUSTRELEASED: + qual_change = true; + qual = false; + break; + case SCA_InputEvent::KX_JUSTACTIVATED: + qual_change = true; + } + } + /* done reading qualifiers */ + if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS) { if (m_val == 1) @@ -240,7 +280,33 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval) } } } + + /* Modify the key state based on qual(s) + * Tested carefuly. dont touch unless your really sure. + * note, this will only change the results if key modifiers are set. + * + * When all modifiers and keys are positive + * - pulse true + * + * When ANY of the modifiers or main key become inactive, + * - pulse false + */ + if (qual==false) { /* one of the qualifiers are not pressed */ + if (m_val_orig && qual_change) { /* we were originally enabled, but a qualifier changed */ + result = true; + } else { + result = false; + } + m_val = 0; /* since one of the qualifiers is not on, set the state to false */ + } else { /* we done have any qualifiers or they are all pressed */ + if (m_val && qual_change) { /* the main key state is true and our qualifier just changed */ + result = true; + } + } + /* done with key quals */ + } + if (reset) // force an event result = true; -- cgit v1.2.3 From 75f458022e87379def66743bb4fa43fdd478d298 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 8 Oct 2008 11:40:39 +0000 Subject: my changes broke the "level" option for joystick keys being held between states --- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index bcd3aa842b7..3f95037d6e0 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -123,8 +123,8 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) numberof== m_axis -- max 2 */ - if (!js->IsTrigAxis()) /* No events from SDL? - dont bother */ - return reset ? true : false; + if (!js->IsTrigAxis() && !reset) /* No events from SDL? - dont bother */ + return false; js->cSetPrecision(m_precision); if (m_bAllEvents) { @@ -189,8 +189,8 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) /* what is what! m_button = the actual button in question */ - if (!js->IsTrigButton()) /* No events from SDL? - dont bother */ - return reset ? true : false; + if (!js->IsTrigButton() && !reset) /* No events from SDL? - dont bother */ + return false; if(( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) { m_istrig = 1; @@ -210,8 +210,8 @@ bool SCA_JoystickSensor::Evaluate(CValue* event) direction= m_hatf -- max 12 */ - if (!js->IsTrigHat()) /* No events from SDL? - dont bother */ - return reset ? true : false; + if (!js->IsTrigHat() && !reset) /* No events from SDL? - dont bother */ + return false; if(m_hat == 1){ if(js->aHatIsPositive(m_hatf)){ -- cgit v1.2.3 From 9ca5b78d1ad13a54f2649a7ed4287435c6727de6 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 9 Oct 2008 06:06:11 +0000 Subject: BGE bug fix: fix several bugs and inconsistencies in sound actuator: - support stopping of loop sound - support stopping by python - keep state of actuator in sync with audio device. The lack of state sync was causing several other problems: - actuator stop playing the sound - sound chopped before the end - not possible to pause sound --- source/gameengine/Ketsji/KX_SoundActuator.cpp | 58 ++++++++++++++++++--------- 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index f75a1ee5c62..afa5af3bc04 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -110,6 +110,9 @@ bool KX_SoundActuator::Update(double curtime, bool frame) if (!m_soundObject) return false; + // actual audio device playing state + bool isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED) ? true : false; + if (m_pino) { bNegativeEvent = true; @@ -119,30 +122,40 @@ bool KX_SoundActuator::Update(double curtime, bool frame) if (bNegativeEvent) { // here must be a check if it is still playing - m_isplaying = false; - - switch (m_type) + if (m_isplaying && isplaying) { - case KX_SOUNDACT_PLAYSTOP: - case KX_SOUNDACT_LOOPSTOP: - case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: - { - m_soundScene->RemoveActiveObject(m_soundObject); - break; - } - case KX_SOUNDACT_PLAYEND: + switch (m_type) { - m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED); + case KX_SOUNDACT_PLAYSTOP: + case KX_SOUNDACT_LOOPSTOP: + case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: + { + m_soundScene->RemoveActiveObject(m_soundObject); + break; + } + case KX_SOUNDACT_PLAYEND: + { + m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED); + break; + } + case KX_SOUNDACT_LOOPEND: + case KX_SOUNDACT_LOOPBIDIRECTIONAL: + { + m_soundObject->SetLoopMode(SND_LOOP_OFF); + m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED); + break; + } + default: + // implement me !! break; } - default: - // implement me !! - break; } + // remember that we tried to stop the actuator + m_isplaying = false; } else { - if (m_soundObject && !m_isplaying) + if (!m_isplaying) { switch (m_type) { @@ -179,8 +192,10 @@ bool KX_SoundActuator::Update(double curtime, bool frame) } } } + // verify that the sound is still playing + isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED) ? true : false; - if (m_isplaying) + if (isplaying) { m_soundObject->SetPosition(((KX_GameObject*)this->GetParent())->NodeGetWorldPosition()); m_soundObject->SetVelocity(((KX_GameObject*)this->GetParent())->GetLinearVelocity()); @@ -189,14 +204,15 @@ bool KX_SoundActuator::Update(double curtime, bool frame) } else { + m_isplaying = false; result = false; } - + /* if (result && (m_soundObject->IsLifeSpanOver(curtime)) && ((m_type == KX_SOUNDACT_PLAYEND) || (m_type == KX_SOUNDACT_PLAYSTOP))) { m_pino = true; } - + */ return result; } @@ -312,6 +328,9 @@ PyObject* KX_SoundActuator::PyGetFilename(PyObject* self, PyObject* args, PyObje PyObject* KX_SoundActuator::PyStartSound(PyObject* self, PyObject* args, PyObject* kwds) { if (m_soundObject) + // This has no effect if the actuator is not active. + // To start the sound you must activate the actuator. + // This function is to restart the sound. m_soundObject->StartSound(); Py_Return; } @@ -321,6 +340,7 @@ PyObject* KX_SoundActuator::PyStartSound(PyObject* self, PyObject* args, PyObjec PyObject* KX_SoundActuator::PyPauseSound(PyObject* self, PyObject* args, PyObject* kwds) { if (m_soundObject) + // unfortunately, openal does not implement pause correctly, it is equivalent to a stop m_soundObject->PauseSound(); Py_Return; } -- cgit v1.2.3 From 0749bf7be70e32b8fd4dd09839bce0267dbe9b29 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Fri, 10 Oct 2008 05:12:57 +0000 Subject: Fix bug in rigid body constraint buttons drawing, and while we are at it, add 'Collision' button to disable collisions between bodies, linked between constraint. --- .../Converter/BL_BlenderDataConversion.cpp | 2 +- source/gameengine/Ketsji/KX_PyConstraintBinding.cpp | 2 +- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 21 ++++++++++++++------- .../Physics/Bullet/CcdPhysicsEnvironment.h | 4 ++-- .../Physics/Dummy/DummyPhysicsEnvironment.cpp | 3 +-- .../Physics/Dummy/DummyPhysicsEnvironment.h | 2 +- .../Physics/Sumo/SumoPhysicsEnvironment.cpp | 4 ++-- .../Physics/Sumo/SumoPhysicsEnvironment.h | 2 +- .../Physics/common/PHY_IPhysicsEnvironment.h | 2 +- 9 files changed, 24 insertions(+), 18 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 97ed6f4002a..9c699b67b28 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2478,7 +2478,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, (float)dat->pivY,(float)dat->pivZ, (float)axis0.x(),(float)axis0.y(),(float)axis0.z(), (float)axis1.x(),(float)axis1.y(),(float)axis1.z(), - (float)axis2.x(),(float)axis2.y(),(float)axis2.z()); + (float)axis2.x(),(float)axis2.y(),(float)axis2.z(),dat->flag); if (constraintId) { //if it is a generic 6DOF constraint, set all the limits accordingly diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp index dea6225edc2..fb37eded450 100644 --- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp +++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp @@ -435,7 +435,7 @@ static PyObject* gPyCreateConstraint(PyObject* self, PHY_IPhysicsController* physctrl2 = (PHY_IPhysicsController*) physicsid2; if (physctrl) //TODO:check for existance of this pointer! { - int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ); + int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0); KX_ConstraintWrapper* wrap = new KX_ConstraintWrapper((enum PHY_ConstraintType)constrainttype,constraintid,PHY_GetActiveEnvironment()); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 91655e96101..82fa084a615 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -33,6 +33,7 @@ subject to the following restrictions: #include "PHY_IMotionState.h" +#define CCD_CONSTRAINT_DISABLE_LINKED_COLLISION 0x80 bool useIslands = true; @@ -882,13 +883,16 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( const btVector3& linearMinLimits, const btVector3& linearMaxLimits, const btVector3& angularMinLimits, - const btVector3& angularMaxLimits + const btVector3& angularMaxLimits,int flags ) { + bool disableCollisionBetweenLinkedBodies = (0==(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION)); + //we could either add some logic to recognize ball-socket and hinge, or let that up to the user //perhaps some warning or hint that hinge/ball-socket is more efficient? + btGeneric6DofConstraint* genericConstraint = 0; CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef; CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther; @@ -918,7 +922,7 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( if (genericConstraint) { // m_constraints.push_back(genericConstraint); - m_dynamicsWorld->addConstraint(genericConstraint); + m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies); genericConstraint->setUserConstraintId(gConstraintUid++); genericConstraint->setUserConstraintType(PHY_GENERIC_6DOF_CONSTRAINT); @@ -1488,10 +1492,13 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ, float axis1X,float axis1Y,float axis1Z, - float axis2X,float axis2Y,float axis2Z + float axis2X,float axis2Y,float axis2Z,int flags ) { + bool disableCollisionBetweenLinkedBodies = (0==(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION)); + + CcdPhysicsController* c0 = (CcdPhysicsController*)ctrl0; CcdPhysicsController* c1 = (CcdPhysicsController*)ctrl1; @@ -1683,7 +1690,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl pivotInA); } - m_dynamicsWorld->addConstraint(p2p); + m_dynamicsWorld->addConstraint(p2p,disableCollisionBetweenLinkedBodies); // m_constraints.push_back(p2p); p2p->setUserConstraintId(gConstraintUid++); @@ -1753,7 +1760,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl if (genericConstraint) { //m_constraints.push_back(genericConstraint); - m_dynamicsWorld->addConstraint(genericConstraint); + m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies); genericConstraint->setUserConstraintId(gConstraintUid++); genericConstraint->setUserConstraintType(type); //64 bit systems can't cast pointer to int. could use size_t instead. @@ -1819,7 +1826,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl if (coneTwistContraint) { //m_constraints.push_back(genericConstraint); - m_dynamicsWorld->addConstraint(coneTwistContraint); + m_dynamicsWorld->addConstraint(coneTwistContraint,disableCollisionBetweenLinkedBodies); coneTwistContraint->setUserConstraintId(gConstraintUid++); coneTwistContraint->setUserConstraintType(type); //64 bit systems can't cast pointer to int. could use size_t instead. @@ -1858,7 +1865,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl hinge->setAngularOnly(angularOnly); //m_constraints.push_back(hinge); - m_dynamicsWorld->addConstraint(hinge); + m_dynamicsWorld->addConstraint(hinge,disableCollisionBetweenLinkedBodies); hinge->setUserConstraintId(gConstraintUid++); hinge->setUserConstraintType(type); //64 bit systems can't cast pointer to int. could use size_t instead. diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 3d9d5442b8f..74384dd8cf2 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -127,7 +127,7 @@ protected: float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ, float axis1X=0,float axis1Y=0,float axis1Z=0, - float axis2X=0,float axis2Y=0,float axis2Z=0 + float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0 ); @@ -139,7 +139,7 @@ protected: const btVector3& linearMinLimits, const btVector3& linearMaxLimits, const btVector3& angularMinLimits, - const btVector3& angularMaxLimits + const btVector3& angularMaxLimits,int flags ); virtual void setConstraintParam(int constraintId,int param,float value,float value1); diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp index d78958b746c..ba196b5cf55 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp @@ -92,8 +92,7 @@ void DummyPhysicsEnvironment::setGravity(float x,float y,float z) int DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ, float axis1X,float axis1Y,float axis1Z, - float axis2X,float axis2Y,float axis2Z - + float axis2X,float axis2Y,float axis2Z,int flag ) { diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 975be84f2a7..a92b1e7f4a6 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -58,7 +58,7 @@ public: float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ, float axis1X=0,float axis1Y=0,float axis1Z=0, - float axis2X=0,float axis2Y=0,float axis2Z=0 + float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0 ); virtual void removeConstraint(int constraintid); diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp index 80e4dc4044e..3be5e027345 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp @@ -111,8 +111,8 @@ int SumoPhysicsEnvironment::createConstraint( float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ, float axis1X,float axis1Y,float axis1Z, - float axis2X,float axis2Y,float axis2Z - + float axis2X,float axis2Y,float axis2Z, + int flag ) { int constraintid = 0; diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h index 100adf969d5..65b07a7a0be 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h @@ -63,7 +63,7 @@ public: float pivotX,float pivotY,float pivotZ, float axisX,float axisY,float axisZ, float axis1X=0,float axis1Y=0,float axis1Z=0, - float axis2X=0,float axis2Y=0,float axis2Z=0 + float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0 ); diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index 98496fb7f9e..0e9c571924c 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -129,7 +129,7 @@ class PHY_IPhysicsEnvironment float pivotX,float pivotY,float pivotZ, float axis0X,float axis0Y,float axis0Z, float axis1X=0,float axis1Y=0,float axis1Z=0, - float axis2X=0,float axis2Y=0,float axis2Z=0 + float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0 )=0; virtual void removeConstraint(int constraintid)=0; virtual float getAppliedImpulse(int constraintid){ return 0.f;} -- cgit v1.2.3 From 7995395fd2a6ad503c70cf3bd463b579b2fd9386 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Fri, 10 Oct 2008 05:32:04 +0000 Subject: fix: leave default behaviour the same to be backward compatible with previous rigid body constraints: No Collision between linked objects if button is pressed. --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 82fa084a615..505db944097 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -887,7 +887,7 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint( ) { - bool disableCollisionBetweenLinkedBodies = (0==(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION)); + bool disableCollisionBetweenLinkedBodies = (0!=(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION)); //we could either add some logic to recognize ball-socket and hinge, or let that up to the user //perhaps some warning or hint that hinge/ball-socket is more efficient? @@ -1496,7 +1496,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl ) { - bool disableCollisionBetweenLinkedBodies = (0==(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION)); + bool disableCollisionBetweenLinkedBodies = (0!=(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION)); -- cgit v1.2.3 From 3fd204312f64a405e068cb68338dd929682d6297 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 10 Oct 2008 07:20:42 +0000 Subject: BGE bug #17789 fixed: Lock Active Camera and Layer to Scene doesn't work in BGE. This bug fix applies only to games started from the 3D view. Now the BGE will use the layer and camera selected in the 3d viewport under the mouse when the user presses P. Note that there is still a problem with the restart game actuator but that's another bug. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 1110c4e0b48..ffc32a3ad97 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -191,7 +191,16 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); - + + //lock frame and camera enabled - storing global values + int tmp_lay= G.scene->lay; + Object *tmp_camera = G.scene->camera; + + if (G.vd->scenelock==0){ + G.scene->lay= v3d->lay; + G.scene->camera= v3d->camera; + } + // some blender stuff MT_CmMatrix4x4 projmat; @@ -403,7 +412,8 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, } printf("\nBlender Game Engine Finished\n\n"); exitstring = ketsjiengine->GetExitString(); - + + // when exiting the mainloop // Clears the dictionary by hand: @@ -439,6 +449,12 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, Py_DECREF(gameLogic_keys); gameLogic_keys = NULL; } + //lock frame and camera enabled - restoring global values + if (G.vd->scenelock==0){ + G.scene->lay= tmp_lay; + G.scene->camera= tmp_camera; + } + // set the cursor back to normal canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL); -- cgit v1.2.3 From d99fd92ffa04b4f6fc7a830b62cb764d9de3f05d Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 10 Oct 2008 14:22:54 +0000 Subject: Missing include, apparently only scons+mingw suffers this, strange. --- source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index f271baeed16..e8e29fb2769 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -28,6 +28,8 @@ #include #endif +#include + #include "SCA_Joystick.h" #include "SCA_JoystickPrivate.h" -- cgit v1.2.3 From 9b948cad08067a6bedd49ccfb059874aba7555b9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 11 Oct 2008 00:56:49 +0000 Subject: Fix for a relative paths issue in the game engine. G.sce was being kept as the original file, but that can't work correct for solving relative paths once a .blend in another directory is loaded. The reason it went OK with the apricot tech demo is that the images there were lib linked into the level file, which still worked. Now it sets G.sce to the current loaded .blend file. Note that the python config file path still uses the first loaded .blend file so it looks in the same location each time. Also added some NULL pointer checks in the joystick code because it was crashing there on Mac, there's similar checks in related functions so I'm assuming this was just a missed case. --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 44 ++++++++++++++-------- .../GameLogic/Joystick/SCA_JoystickEvents.cpp | 3 +- .../gameengine/GameLogic/SCA_JoystickManager.cpp | 3 +- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 15 ++++---- source/gameengine/Ketsji/KX_PythonInit.cpp | 20 +++++++--- source/gameengine/Ketsji/KX_PythonInit.h | 1 + 6 files changed, 54 insertions(+), 32 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index ffc32a3ad97..1442458269b 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -70,6 +70,7 @@ #include "DNA_view3d_types.h" #include "DNA_screen_types.h" #include "BKE_global.h" +#include "BKE_utildefines.h" #include "BIF_screen.h" #include "BIF_scrarea.h" @@ -110,11 +111,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, Main* blenderdata = maggie1; char* startscenename = scenename; - char pathname[160]; - strcpy (pathname, blenderdata->name); + char pathname[FILE_MAXDIR+FILE_MAXFILE], oldsce[FILE_MAXDIR+FILE_MAXFILE]; STR_String exitstring = ""; BlendFileData *bfd= NULL; + BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); + BLI_strncpy(oldsce, G.sce, sizeof(oldsce)); + setGamePythonPath(G.sce); + // Acquire Python's GIL (global interpreter lock) // so we can safely run Python code and API calls PyGILState_STATE gilstate = PyGILState_Ensure(); @@ -240,9 +244,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, char basedpath[240]; // base the actuator filename with respect // to the original file working directory + if (exitstring != "") strcpy(basedpath, exitstring.Ptr()); + // load relative to the last loaded file, this used to be relative + // to the first file but that makes no sense, relative paths in + // blend files should be relative to that file, not some other file + // that happened to be loaded first BLI_convertstringcode(basedpath, pathname); bfd = load_game_data(basedpath); @@ -263,6 +272,11 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, { blenderdata = bfd->main; startscenename = bfd->curscene->id.name + 2; + + if(blenderdata) { + BLI_strncpy(G.sce, blenderdata->name, sizeof(G.sce)); + BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); + } } // else forget it, we can't find it else @@ -507,6 +521,8 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, if (bfd) BLO_blendfiledata_free(bfd); + BLI_strncpy(G.sce, oldsce, sizeof(G.sce)); + // Release Python's GIL PyGILState_Release(gilstate); } @@ -522,10 +538,10 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, Main* blenderdata = maggie; char* startscenename = scenename; - char pathname[160]; - strcpy (pathname, maggie->name); + char pathname[FILE_MAXDIR+FILE_MAXFILE]; STR_String exitstring = ""; - BlendFileData *bfd= NULL; + + BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); // Acquire Python's GIL (global interpreter lock) // so we can safely run Python code and API calls @@ -583,20 +599,17 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, KX_KetsjiEngine* ketsjiengine = new KX_KetsjiEngine(kxsystem); Scene *blscene = NULL; - if (!bfd) + + blscene = (Scene*) maggie->scene.first; + for (Scene *sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next) { - blscene = (Scene*) maggie->scene.first; - for (Scene *sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next) + if (startscenename == (sce->id.name+2)) { - if (startscenename == (sce->id.name+2)) - { - blscene = sce; - break; - } + blscene = sce; + break; } - } else { - blscene = bfd->curscene; } + int cframe = 1, startFrame; if (blscene) { @@ -717,7 +730,6 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, SND_DeviceManager::Unsubscribe(); } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); - if (bfd) BLO_blendfiledata_free(bfd); // Release Python's GIL PyGILState_Release(gilstate); diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp index 89e2420f822..73ca288861d 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp @@ -89,7 +89,8 @@ void SCA_Joystick::HandleEvents(void) int i; for (i=0; iOnNothing(&sdl_event); + if(SCA_Joystick::m_instance[i]) + SCA_Joystick::m_instance[i]->OnNothing(&sdl_event); } if(SDL_PollEvent(&sdl_event)) diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp index d874b5b013a..f3ce549a637 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp @@ -51,7 +51,8 @@ SCA_JoystickManager::~SCA_JoystickManager() { int i; for (i=0; iReleaseInstance(); + if(m_joystick[i]) + m_joystick[i]->ReleaseInstance(); } } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index fbb8d6530ba..0bf0317d8f2 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -44,6 +44,7 @@ #endif // __APPLE__ #include "GEN_messaging.h" #include "KX_KetsjiEngine.h" +#include "KX_PythonInit.h" /********************************** * Begin Blender include block @@ -599,8 +600,8 @@ int main(int argc, char** argv) GPG_Application app(system); bool firstTimeRunning = true; char filename[FILE_MAXDIR + FILE_MAXFILE]; + char pathname[FILE_MAXDIR + FILE_MAXFILE]; char *titlename; - char pathname[160]; get_filename(argc, argv, filename); if(filename[0]) @@ -616,8 +617,7 @@ int main(int argc, char** argv) { char basedpath[240]; - // base the actuator filename with respect - // to the original file working directory + // base the actuator filename relative to the last file strcpy(basedpath, exitstring.Ptr()); BLI_convertstringcode(basedpath, pathname); @@ -700,15 +700,14 @@ int main(int argc, char** argv) // GPG_Application app (system, maggie, startscenename); app.SetGameEngineData(maggie, scene); + BLI_strncpy(pathname, maggie->name, sizeof(pathname)); + BLI_strncpy(G.sce, maggie->name, sizeof(G.sce)); + if (firstTimeRunning) { + setGamePythonPath(G.sce); firstTimeRunning = false; - // set the filename only the first time as in KetsjiEmbedded - strcpy (pathname, maggie->name); - // also copy here (used by GameLogic.getBaseDirectory) - strcpy (G.sce, maggie->name); - if (fullScreen) { #ifdef WIN32 diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index cdf7ebd0943..a30d9f4022d 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -97,6 +97,7 @@ static RAS_ICanvas* gp_Canvas = NULL; static KX_Scene* gp_KetsjiScene = NULL; static KX_KetsjiEngine* gp_KetsjiEngine = NULL; static RAS_IRasterizer* gp_Rasterizer = NULL; +static char gp_GamePythonPath[FILE_MAXDIR + FILE_MAXFILE] = ""; void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color) { @@ -155,7 +156,7 @@ static PyObject* gPyExpandPath(PyObject*, PyObject* args) return NULL; BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE); - BLI_convertstringcode(expanded, G.sce); + BLI_convertstringcode(expanded, gp_GamePythonPath); return PyString_FromString(expanded); } @@ -281,7 +282,7 @@ static PyObject* gPyGetAverageFrameRate(PyObject*) static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) { - char cpath[sizeof(G.sce)]; + char cpath[sizeof(gp_GamePythonPath)]; char *searchpath = NULL; PyObject* list, *value; @@ -295,10 +296,10 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) if (searchpath) { BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE); - BLI_convertstringcode(cpath, G.sce); + BLI_convertstringcode(cpath, gp_GamePythonPath); } else { /* Get the dir only */ - BLI_split_dirfile_basic(G.sce, cpath, NULL); + BLI_split_dirfile_basic(gp_GamePythonPath, cpath, NULL); } if((dp = opendir(cpath)) == NULL) { @@ -1541,9 +1542,10 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) void pathGamePythonConfig( char *path ) { - int len = strlen(G.sce); + int len = strlen(gp_GamePythonPath); - strncpy(path, G.sce, sizeof(G.sce)); + BLI_strncpy(path, gp_GamePythonPath, sizeof(gp_GamePythonPath)); + /* replace extension */ if (BLI_testextensie(path, ".blend")) { strcpy(path+(len-6), ".bgeconf"); @@ -1551,3 +1553,9 @@ void pathGamePythonConfig( char *path ) strcpy(path+len, ".bgeconf"); } } + +void setGamePythonPath(char *path) +{ + BLI_strncpy(gp_GamePythonPath, path, sizeof(gp_GamePythonPath)); +} + diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 28d9d72a4c3..36e3db6ec35 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -49,6 +49,7 @@ void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level); void exitGamePythonScripting(); +void setGamePythonPath(char *path); void pathGamePythonConfig( char *path ); int saveGamePythonConfig( char **marshal_buffer); int loadGamePythonConfig(char *marshal_buffer, int marshal_length); -- cgit v1.2.3 From 3cac11a3a2e61555c48c559f9caa61b1787e9ddb Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sat, 11 Oct 2008 20:19:04 +0000 Subject: Last (hopefully) soft body fixes: Enable soft body collision clusters by default. Add option to 'disable collision' button between soft body and rigid body connected by constraint (option was already available between two rigid bodies) --- source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 505db944097..4fe35630784 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1581,7 +1581,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl { if (rb1) { - sb0->appendAnchor(node,rb1); + sb0->appendAnchor(node,rb1,disableCollisionBetweenLinkedBodies); } else { sb0->setMass(node,0.f); @@ -1643,7 +1643,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl { if (rb0) { - sb1->appendAnchor(node,rb0); + sb1->appendAnchor(node,rb0,disableCollisionBetweenLinkedBodies); } else { sb1->setMass(node,0.f); -- cgit v1.2.3 From d3c661e6823538e956c21f7d64d972efe8e785c7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 11 Oct 2008 22:29:50 +0000 Subject: Fix crash in game engine IPO code, got out of sync after IPO cleanup, removed the duplicated function declarations. --- .../gameengine/Converter/KX_BlenderScalarInterpolator.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp index f58d60b026a..4d79febb7b4 100644 --- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp +++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp @@ -28,13 +28,10 @@ #include "KX_BlenderScalarInterpolator.h" -#ifdef HAVE_CONFIG_H -#include -#endif - -extern "C" int IPO_GetChannels(struct Ipo *ipo, short *channels); -extern "C" float IPO_GetFloatValue(struct Ipo *ipo, /*IPO_Channel*/ short channel, float ctime); - +extern "C" { +#include "DNA_ipo_types.h" +#include "BKE_ipo.h" +} static const int BL_MAX_CHANNELS = 32; @@ -42,7 +39,7 @@ float BL_ScalarInterpolator::GetValue(float currentTime) const { return IPO_GetFloatValue(m_blender_ipo, m_channel, currentTime); } -typedef short IPO_Channel; + BL_InterpolatorList::BL_InterpolatorList(struct Ipo *ipo) { IPO_Channel channels[BL_MAX_CHANNELS]; -- cgit v1.2.3 From 513b544bbc432f3e1d306182758b83cdf52b131a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 11 Oct 2008 23:48:37 +0000 Subject: Fix for two more game engine issues: * Debug text drawing didn't disable textures correct leaving texture state invalid, quite old issue. * Multitexture materials didn't get enabled correct, recent bug. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both pointed out by José Ignacio Romero, thanks! --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 6 +++-- source/gameengine/BlenderRoutines/KX_BlenderGL.cpp | 26 ++++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 1442458269b..9fbdc3fa1c9 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -340,8 +340,10 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, else if(G.fileflags & G_FILE_GAME_MAT_GLSL) usemat = false; - sceneconverter->SetMaterials(usemat && (G.fileflags & G_FILE_GAME_MAT)); - sceneconverter->SetGLSLMaterials(useglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)); + if(usemat && (G.fileflags & G_FILE_GAME_MAT)) + sceneconverter->SetMaterials(true); + if(useglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL)) + sceneconverter->SetGLSLMaterials(true); KX_Scene* startscene = new KX_Scene(keyboarddevice, mousedevice, diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp index 669e7bd1b3f..54d1eb7e011 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp @@ -102,16 +102,28 @@ void DisableForText() glDisable(GL_COLOR_MATERIAL); } - if(GLEW_ARB_multitexture) - for(int i=0; i Date: Tue, 14 Oct 2008 22:31:10 +0000 Subject: cleanup epydoc errors --- source/gameengine/PyDoc/KX_ActuatorSensor.py | 1 + source/gameengine/PyDoc/KX_ConstraintActuator.py | 22 +++++++++++----------- source/gameengine/PyDoc/KX_IpoActuator.py | 6 +++--- source/gameengine/PyDoc/Rasterizer.py | 15 ++++++++------- source/gameengine/PyDoc/epy_docgen.sh | 2 +- 5 files changed, 24 insertions(+), 22 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/KX_ActuatorSensor.py b/source/gameengine/PyDoc/KX_ActuatorSensor.py index f9aef86f7f0..cdfbf27576e 100644 --- a/source/gameengine/PyDoc/KX_ActuatorSensor.py +++ b/source/gameengine/PyDoc/KX_ActuatorSensor.py @@ -1,6 +1,7 @@ # $Id$ # Documentation for KX_ActuatorSensor from SCA_IActuator import * +from SCA_ISensor import * class KX_ActuatorSensor(SCA_ISensor): """ diff --git a/source/gameengine/PyDoc/KX_ConstraintActuator.py b/source/gameengine/PyDoc/KX_ConstraintActuator.py index b1c6f3c0f4e..7c7ad5aa0fa 100644 --- a/source/gameengine/PyDoc/KX_ConstraintActuator.py +++ b/source/gameengine/PyDoc/KX_ConstraintActuator.py @@ -58,11 +58,11 @@ class KX_ConstraintActuator(SCA_IActuator): See module L{GameLogic} for valid constraint types. - @param limit: Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ, - Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ - Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, - KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ, - Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ + @param limit: + Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ + Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ + Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ + Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ """ def getLimit(): """ @@ -70,11 +70,11 @@ class KX_ConstraintActuator(SCA_IActuator): See module L{GameLogic} for valid constraints. - @return: Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ, - Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ, - Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, - KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ, - Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ + @return: + Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ, + Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ, + Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ, + Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ """ def setRotDamp(duration): """ @@ -107,7 +107,7 @@ class KX_ConstraintActuator(SCA_IActuator): @type option: integer @param option: Binary combination of the following values: - 64 : Activate alignment to surface + 64 : Activate alignment to surface 128 : Detect material rather than property 256 : No deactivation if ray does not hit target 512 : Activate distance control diff --git a/source/gameengine/PyDoc/KX_IpoActuator.py b/source/gameengine/PyDoc/KX_IpoActuator.py index 1cdab829385..e2fe3b289e3 100644 --- a/source/gameengine/PyDoc/KX_IpoActuator.py +++ b/source/gameengine/PyDoc/KX_IpoActuator.py @@ -6,7 +6,7 @@ class KX_IpoActuator(SCA_IActuator): """ IPO actuator activates an animation. """ - def set(mode, startframe, endframe, mode): + def set(mode, startframe, endframe, force): """ Sets the properties of the actuator. @@ -16,8 +16,8 @@ class KX_IpoActuator(SCA_IActuator): @type startframe: integer @param endframe: last frame to use @type endframe: integer - @param mode: special mode - @type mode: integer (0=normal, 1=interpret location as force, 2=additive) + @param force: special mode + @type force: integer (0=normal, 1=interpret location as force, 2=additive) """ def setProperty(property): """ diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py index cdda87fcb49..6a67cdcc71b 100644 --- a/source/gameengine/PyDoc/Rasterizer.py +++ b/source/gameengine/PyDoc/Rasterizer.py @@ -40,8 +40,8 @@ Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement M @group Material Types: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL @var KX_TEXFACE_MATERIAL: Materials as defined by the texture face settings. @var KX_BLENDER_MULTITEX_MATERIAL: Materials approximating blender materials with multitexturing. -@var KX_BLENDER_BLENDER_MATERIAL: Materials approximating blender materials with GLSL. - +@var KX_BLENDER_GLSL_MATERIAL: Materials approximating blender materials with GLSL. + """ def getWindowWidth(): @@ -181,14 +181,15 @@ def getGLSLMaterialSetting(setting, enable): @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures) @rtype: boolean """ -def drawLine(from,to,color): + +def drawLine(fromVec,toVec,color): """ Draw a line in the 3D scene. - @param from: the origin of the line - @type from: list [x, y, z] - @param to: the end of the line - @type to: list [x, y, z] + @param fromVec: the origin of the line + @type fromVec: list [x, y, z] + @param toVec: the end of the line + @type toVec: list [x, y, z] @param color: the color of the line @type color: list [r, g, b] """ diff --git a/source/gameengine/PyDoc/epy_docgen.sh b/source/gameengine/PyDoc/epy_docgen.sh index 7fb5e49c996..b243101ddcb 100644 --- a/source/gameengine/PyDoc/epy_docgen.sh +++ b/source/gameengine/PyDoc/epy_docgen.sh @@ -7,5 +7,5 @@ # set posix locale so regex works properly for [A-Z]*.py LC_ALL=POSIX -epydoc -v -o BPY_GE --url "http://www.blender.org" --top GameLogic \ +epydoc --debug -v -o BPY_GE --url "http://www.blender.org" --top GameLogic \ --name "Blender GameEngine" --no-private --no-frames *.py -- cgit v1.2.3 From c119fb6e51b07faec288c5b20739b773f24cc748 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 16 Oct 2008 23:33:40 +0000 Subject: BGE showstopper bug fix: - Reset hit object pointer at end of frame of touch sensor to avoid returning invalid pointer to getHitObject(). - Clear all references in KX_TouchSensor::m_colliders when the sensor is disabled to avoid loose references. - Test GetSGNode() systematically for all KX_GameObject functions that can be called from python in case a python controller keeps a reference in GameLogic (bad practice anyway). --- source/gameengine/Ketsji/KX_GameObject.cpp | 57 ++++++++++++++++++++------ source/gameengine/Ketsji/KX_Scene.cpp | 5 ++- source/gameengine/Ketsji/KX_TouchSensor.cpp | 8 ++++ source/gameengine/Ketsji/KX_TouchSensor.h | 1 + source/gameengine/Ketsji/KX_VehicleWrapper.cpp | 43 ++++++++++--------- 5 files changed, 80 insertions(+), 34 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 1b57b9acc1d..8b2feca53a3 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -214,7 +214,8 @@ KX_GameObject* KX_GameObject::GetParent() void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) { - if (obj && GetSGNode()->GetSGParent() != obj->GetSGNode()) + // check on valid node in case a python controller holds a reference to a deleted object + if (obj && GetSGNode() && obj->GetSGNode() && GetSGNode()->GetSGParent() != obj->GetSGNode()) { // Make sure the objects have some scale MT_Vector3 scale1 = NodeGetWorldScaling(); @@ -256,7 +257,8 @@ void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj) void KX_GameObject::RemoveParent(KX_Scene *scene) { - if (GetSGNode()->GetSGParent()) + // check on valid node in case a python controller holds a reference to a deleted object + if (GetSGNode() && GetSGNode()->GetSGParent()) { // Set us to the right spot GetSGNode()->SetLocalScale(GetSGNode()->GetWorldScaling()); @@ -642,6 +644,10 @@ void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac) MT_Vector3 vect,ori,z,x,y; MT_Scalar len; + // check on valid node in case a python controller holds a reference to a deleted object + if (!GetSGNode()) + return; + vect = dir; len = vect.length(); if (MT_fuzzyZero(len)) @@ -785,7 +791,11 @@ MT_Vector3 KX_GameObject::GetVelocity(const MT_Point3& point) void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans) { - if (m_pPhysicsController1 && (!GetSGNode() || !GetSGNode()->GetSGParent())) + // check on valid node in case a python controller holds a reference to a deleted object + if (!GetSGNode()) + return; + + if (m_pPhysicsController1 && !GetSGNode()->GetSGParent()) { // don't update physic controller if the object is a child: // 1) the transformation will not be right @@ -794,35 +804,39 @@ void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans) m_pPhysicsController1->setPosition(trans); } - if (GetSGNode()) - GetSGNode()->SetLocalPosition(trans); + GetSGNode()->SetLocalPosition(trans); } void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot) { - if (m_pPhysicsController1 && (!GetSGNode() || !GetSGNode()->GetSGParent())) + // check on valid node in case a python controller holds a reference to a deleted object + if (!GetSGNode()) + return; + + if (m_pPhysicsController1 && !GetSGNode()->GetSGParent()) { // see note above m_pPhysicsController1->setOrientation(rot); } - if (GetSGNode()) - GetSGNode()->SetLocalOrientation(rot); + GetSGNode()->SetLocalOrientation(rot); } void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale) { - if (m_pPhysicsController1 && (!GetSGNode() || !GetSGNode()->GetSGParent())) + // check on valid node in case a python controller holds a reference to a deleted object + if (!GetSGNode()) + return; + + if (m_pPhysicsController1 && !GetSGNode()->GetSGParent()) { // see note above m_pPhysicsController1->setScaling(scale); } - - if (GetSGNode()) - GetSGNode()->SetLocalScale(scale); + GetSGNode()->SetLocalScale(scale); } @@ -880,6 +894,13 @@ void KX_GameObject::NodeUpdateGS(double time,bool bInitiator) const MT_Matrix3x3& KX_GameObject::NodeGetWorldOrientation() const { + static MT_Matrix3x3 defaultOrientation = MT_Matrix3x3( 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0); + + // check on valid node in case a python controller holds a reference to a deleted object + if (!GetSGNode()) + return defaultOrientation; return GetSGNode()->GetWorldOrientation(); } @@ -887,6 +908,12 @@ const MT_Matrix3x3& KX_GameObject::NodeGetWorldOrientation() const const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const { + static MT_Vector3 defaultScaling = MT_Vector3(1.0, 1.0, 1.0); + + // check on valid node in case a python controller holds a reference to a deleted object + if (!GetSGNode()) + return defaultScaling; + return GetSGNode()->GetWorldScaling(); } @@ -894,6 +921,12 @@ const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const const MT_Point3& KX_GameObject::NodeGetWorldPosition() const { + static MT_Point3 defaultPosition = MT_Point3(0.0, 0.0, 0.0); + + // check on valid node in case a python controller holds a reference to a deleted object + if (!GetSGNode()) + return defaultPosition; + return GetSGNode()->GetWorldPosition(); } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index f5d6d7e8e0a..caa71441b1d 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -614,7 +614,8 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) GroupObject *go; vector duplilist; - if (!groupobj->IsDupliGroup() || + if (!groupobj->GetSGNode() || + !groupobj->IsDupliGroup() || level>MAX_DUPLI_RECUR) return; @@ -1232,7 +1233,7 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Camera* cam,int layer) { // User (Python/Actuator) has forced object invisible... - if (!gameobj->GetVisible()) + if (!gameobj->GetSGNode() || !gameobj->GetVisible()) return; // Shadow lamp layers diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 41757a23f7a..2802da2723d 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -55,9 +55,17 @@ void KX_TouchSensor::SynchronizeTransform() void KX_TouchSensor::EndFrame() { m_colliders->ReleaseAndRemoveAll(); + m_hitObject = NULL; m_bTriggered = false; } +void KX_TouchSensor::UnregisterToManager() +{ + // before unregistering the sensor, make sure we release all references + EndFrame(); + m_eventmgr->RemoveSensor(this); +} + bool KX_TouchSensor::Evaluate(CValue* event) { bool result = false; diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index b611d296939..8fbb1c676ba 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -77,6 +77,7 @@ public: virtual void RegisterSumo(KX_TouchEventManager* touchman); virtual void UnregisterSumo(KX_TouchEventManager* touchman); + virtual void UnregisterToManager(); // virtual DT_Bool HandleCollision(void* obj1,void* obj2, // const DT_CollData * coll_data); diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp index 342e71c5093..028f96f6c5b 100644 --- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp +++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp @@ -49,26 +49,29 @@ PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* self, if (PyArg_ParseTuple(args,"OOOOffi",&wheelGameObject,&pylistPos,&pylistDir,&pylistAxleDir,&suspensionRestLength,&wheelRadius,&hasSteering)) { KX_GameObject* gameOb = (KX_GameObject*) wheelGameObject; - - PHY_IMotionState* motionState = new KX_MotionState(gameOb->GetSGNode()); - - MT_Vector3 attachPos,attachDir,attachAxle; - PyVecTo(pylistPos,attachPos); - PyVecTo(pylistDir,attachDir); - PyVecTo(pylistAxleDir,attachAxle); - PHY__Vector3 aPos,aDir,aAxle; - aPos[0] = attachPos[0]; - aPos[1] = attachPos[1]; - aPos[2] = attachPos[2]; - aDir[0] = attachDir[0]; - aDir[1] = attachDir[1]; - aDir[2] = attachDir[2]; - aAxle[0] = -attachAxle[0];//someone reverse some conventions inside Bullet (axle winding) - aAxle[1] = -attachAxle[1]; - aAxle[2] = -attachAxle[2]; - - printf("attempt for addWheel: suspensionRestLength%f wheelRadius %f, hasSteering:%d\n",suspensionRestLength,wheelRadius,hasSteering); - m_vehicle->AddWheel(motionState,aPos,aDir,aAxle,suspensionRestLength,wheelRadius,hasSteering); + + if (gameOb->GetSGNode()) + { + PHY_IMotionState* motionState = new KX_MotionState(gameOb->GetSGNode()); + + MT_Vector3 attachPos,attachDir,attachAxle; + PyVecTo(pylistPos,attachPos); + PyVecTo(pylistDir,attachDir); + PyVecTo(pylistAxleDir,attachAxle); + PHY__Vector3 aPos,aDir,aAxle; + aPos[0] = attachPos[0]; + aPos[1] = attachPos[1]; + aPos[2] = attachPos[2]; + aDir[0] = attachDir[0]; + aDir[1] = attachDir[1]; + aDir[2] = attachDir[2]; + aAxle[0] = -attachAxle[0];//someone reverse some conventions inside Bullet (axle winding) + aAxle[1] = -attachAxle[1]; + aAxle[2] = -attachAxle[2]; + + printf("attempt for addWheel: suspensionRestLength%f wheelRadius %f, hasSteering:%d\n",suspensionRestLength,wheelRadius,hasSteering); + m_vehicle->AddWheel(motionState,aPos,aDir,aAxle,suspensionRestLength,wheelRadius,hasSteering); + } } else { return NULL; -- cgit v1.2.3 From bf0440add886761706476b69b5355ec7d94650c2 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 17 Oct 2008 09:24:35 +0000 Subject: BGE bug fix (continuation of previous bug fix): - Forgot to make SCA_ISensor::UnregisterToManager() virtual to intercept active-inactive transition on collision sensor to clear colliders reference. - Don't record collision on inactive sensor. This situation occurs when an object with an inactive collision sensor collides with an object with an active collision sensor: the collision handler triggers both sensors. The result of this bug was pending references that eventually cause temporary memory leak (until the sensor is reactivated). --- source/gameengine/GameLogic/SCA_ISensor.h | 4 ++-- source/gameengine/Ketsji/KX_NearSensor.cpp | 6 ++++-- source/gameengine/Ketsji/KX_TouchSensor.cpp | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 0d65270dc7b..d1872009291 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -116,8 +116,8 @@ public: /** set the level detection on or off */ void SetLevel(bool lvl); - void RegisterToManager(); - void UnregisterToManager(); + virtual void RegisterToManager(); + virtual void UnregisterToManager(); virtual float GetNumber(); diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 397aedb3fa3..bae87c28123 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -252,8 +252,10 @@ bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData client_info->m_gameobject : NULL); - // these checks are done already in BroadPhaseFilterCollision() - if (gameobj /*&& (gameobj != parent)*/) + // Add the same check as in SCA_ISensor::Activate(), + // we don't want to record collision when the sensor is not active. + if (m_links && !m_suspended && + gameobj /* done in BroadPhaseFilterCollision() && (gameobj != parent)*/) { if (!m_colliders->SearchValue(gameobj)) m_colliders->Add(gameobj->AddRef()); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 2802da2723d..1935a0bde39 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -184,7 +184,10 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll client_info->m_gameobject : NULL); - if (gameobj && (gameobj != parent) && client_info->isActor()) + // add the same check as in SCA_ISensor::Activate(), + // we don't want to record collision when the sensor is not active. + if (m_links && !m_suspended && + gameobj && (gameobj != parent) && client_info->isActor()) { if (!m_colliders->SearchValue(gameobj)) m_colliders->Add(gameobj->AddRef()); -- cgit v1.2.3 From 03d5780b76f74f9468d3ec990f1135b6a6db3478 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Oct 2008 13:23:30 +0000 Subject: Added joystick epydocs, only changed incorrect docstrings in SCA_JoystickSensor.cpp patch [#17857] HotKeys Update by dfelinto - SmoothStroke and Anchored. Made own edits, removed videoscape and added curve and armature specials. --- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 8 +- source/gameengine/PyDoc/GameLogic.py | 61 ++++++------ source/gameengine/PyDoc/SCA_JoystickSensor.py | 106 +++++++++++++++++++++ 3 files changed, 141 insertions(+), 34 deletions(-) create mode 100644 source/gameengine/PyDoc/SCA_JoystickSensor.py (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 3f95037d6e0..d0dc875da0b 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -355,7 +355,7 @@ PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) { /* get axis ---------------------------------------------------------- */ const char SCA_JoystickSensor::GetAxis_doc[] = "getAxis\n" -"\tReturns the current state of the axis.\n"; +"\tReturns the current axis this sensor reacts to.\n"; PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) { return Py_BuildValue("[ii]",m_axis, m_axisf); } @@ -364,7 +364,7 @@ PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) { /* set axis ---------------------------------------------------------- */ const char SCA_JoystickSensor::SetAxis_doc[] = "setAxis\n" -"\tSets the current state of the axis.\n"; +"\tSets the current axis this sensor reacts to.\n"; PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) { int axis,axisflag; @@ -380,7 +380,7 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) { /* get axis value ----------------------------------------------------- */ const char SCA_JoystickSensor::GetAxisValue_doc[] = "getAxisValue\n" -"\tReturns a list of the values for each axis .\n"; +"\tReturns a list of the values for the current state of each axis.\n"; PyObject* SCA_JoystickSensor::PyGetAxisValue( PyObject* self) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); if(joy) @@ -437,7 +437,7 @@ PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* value ) { /* get button value -------------------------------------------------- */ const char SCA_JoystickSensor::GetButtonValue_doc[] = "getButtonValue\n" -"\tReturns a list containing the indicies of the currently pressed buttons.\n"; +"\tReturns a list containing the indicies of the current pressed state of each button.\n"; PyObject* SCA_JoystickSensor::PyGetButtonValue( PyObject* self) { SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex); PyObject *ls = PyList_New(0); diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py index af3d2810553..9dab7db6081 100644 --- a/source/gameengine/PyDoc/GameLogic.py +++ b/source/gameengine/PyDoc/GameLogic.py @@ -13,10 +13,10 @@ Documentation for the GameLogic Module. See L{WhatsNew} for updates, changes and new functionality in the Game Engine Python API. Examples:: - # To get a controller: + # To get the controller thats running this python script: co = GameLogic.getCurrentController() # GameLogic is automatically imported - # To get the game object associated with this controller: + # To get the game object this controller is on: obj = co.getOwner() L{KX_GameObject} and L{KX_Camera} or L{KX_Light} methods are available depending on the type of object:: @@ -31,17 +31,18 @@ Documentation for the GameLogic Module. sensors = co.getSensors() See the sensor's reference for available methods: - - L{KX_NetworkMessageSensor} - - L{KX_RaySensor} - - L{KX_MouseFocusSensor} - - L{KX_NearSensor} - - L{KX_RadarSensor} - - L{KX_TouchSensor} - - L{SCA_KeyboardSensor} - - L{SCA_MouseSensor} - - L{SCA_PropertySensor} - - L{SCA_RandomSensor} - - L{SCA_DelaySensor} + - L{DelaySensor} + - L{JoystickSensor} + - L{KeyboardSensor} + - L{MouseFocusSensor} + - L{MouseSensor} + - L{NearSensor} + - L{NetworkMessageSensor} + - L{PropertySensor} + - L{RadarSensor} + - L{RandomSensor} + - L{RaySensor} + - L{TouchSensor} You can also access actuators linked to the controller:: # To get an actuator attached to the controller: @@ -54,23 +55,23 @@ Documentation for the GameLogic Module. GameLogic.addActiveActuator(actuator, True) See the actuator's reference for available methods: - - L{BL_ActionActuator} - - L{KX_CameraActuator} - - L{KX_CDActuator} - - L{KX_ConstraintActuator} - - L{KX_GameActuator} - - L{KX_IpoActuator} - - L{KX_NetworkMessageActuator} - - L{KX_ObjectActuator} - - L{KX_SCA_AddObjectActuator} - - L{KX_SCA_EndObjectActuator} - - L{KX_SCA_ReplaceMeshActuator} - - L{KX_SceneActuator} - - L{KX_SoundActuator} - - L{KX_TrackToActuator} - - L{KX_VisibilityActuator} - - L{SCA_PropertyActuator} - - L{SCA_RandomActuator} + - L{ActionActuator} + - L{AddObjectActuator} + - L{CameraActuator} + - L{CDActuator} + - L{ConstraintActuator} + - L{EndObjectActuator} + - L{GameActuator} + - L{IpoActuator} + - L{NetworkMessageActuator} + - L{ObjectActuator} + - L{PropertyActuator} + - L{RandomActuator} + - L{ReplaceMeshActuator} + - L{SceneActuator} + - L{SoundActuator} + - L{TrackToActuator} + - L{VisibilityActuator} Most logic brick's methods are accessors for the properties available in the logic buttons. Consult the logic bricks documentation for more information on how each logic brick works. diff --git a/source/gameengine/PyDoc/SCA_JoystickSensor.py b/source/gameengine/PyDoc/SCA_JoystickSensor.py new file mode 100644 index 00000000000..d1dab9afcaf --- /dev/null +++ b/source/gameengine/PyDoc/SCA_JoystickSensor.py @@ -0,0 +1,106 @@ +# $Id: SCA_RandomSensor.py 15444 2008-07-05 17:05:05Z lukep $ +# Documentation for SCA_RandomSensor +from SCA_ISensor import * + +class SCA_JoystickSensor(SCA_ISensor): + """ + This sensor detects player joystick events. + """ + + def getIndex(): + """ + Returns the joystick index to use (from 1 to 8). + @rtype: integer + """ + def setIndex(index): + """ + Sets the joystick index to use. + @param index: The index of this joystick sensor, Clamped between 1 and 8. + @type index: integer + @note: This is only useful when you have more then 1 joystick connected to your computer - multiplayer games. + """ + def getAxis(): + """ + Returns the current axis this sensor reacts to. See L{getAxisValue()} for the current axis state. + @rtype: list + @return: 2 values returned are [axisIndex, axisDirection] - see L{setAxis()} for their purpose. + @note: When the "All Events" toggle is set, this option has no effect. + """ + def setAxis(axisIndex, axisDirection): + """ + @param axisIndex: Set the axis index to use when detecting axis movement. + @type axisIndex: integer from 1 to 2 + @param axisDirection: Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down. + @type axisDirection: integer from 0 to 3 + @note: When the "All Events" toggle is set, this option has no effect. + """ + def getAxisValue(): + """ + Returns the state of the joysticks axis. See differs to L{getAxis()} returning the current state of the joystick. + @rtype: list + @return: 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing. + + The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls. + + left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...] + @note: Some gamepads only set the axis on and off like a button. + """ + def getThreshold(): + """ + Get the axis threshold. See L{setThreshold()} for details. + @rtype: integer + """ + def setThreshold(threshold): + """ + Set the axis threshold. + @param threshold: Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive. + @type threshold: integer + """ + def getButton(): + """ + Returns the button index the sensor reacts to. See L{getButtonValue()} for a list of pressed buttons. + @rtype: integer + @note: When the "All Events" toggle is set, this option has no effect. + """ + def setButton(index): + """ + Sets the button index the sensor reacts to when the "All Events" option is not set. + @note: When the "All Events" toggle is set, this option has no effect. + """ + def getButtonValue(): + """ + Returns a list containing the indicies of the currently pressed buttons. + @rtype: list + """ + def getHat(): + """ + Returns the current hat direction this sensor is set to. + [hatNumber, hatDirection]. + @rtype: list + @note: When the "All Events" toggle is set, this option has no effect. + """ + def setHat(index): + """ + Sets the hat index the sensor reacts to when the "All Events" option is not set. + @type index: integer + """ + def getNumAxes(): + """ + Returns the number of axes for the joystick at this index. + @rtype: integer + """ + def getNumButtons(): + """ + Returns the number of buttons for the joystick at this index. + @rtype: integer + """ + def getNumHats(): + """ + Returns the number of hats for the joystick at this index. + @rtype: integer + """ + def isConnected(): + """ + Returns True if a joystick is detected at this joysticks index. + @rtype: bool + """ -- cgit v1.2.3 From 42e287af1cc3ed2f37630f6f62c82c2d8ccc66b3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Oct 2008 04:02:37 +0000 Subject: source/blender/blenloader/intern/readfile.c - use memmove rather then strncpy for overlapping strings. source/blender/blenlib/intern/fileops.c - zero length strings would check for a slash before the strings first char. source/gameengine/GameLogic/SCA_JoystickSensor.cpp - m_istrig_prev was not initialized source/blender/src/editmesh.c - active face pointer was not set to NULL in free_editMesh() --- source/gameengine/GameLogic/SCA_JoystickSensor.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index d0dc875da0b..8b96840b149 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -74,6 +74,7 @@ std::cout << " hat flag " << m_hatf << std::endl; void SCA_JoystickSensor::Init() { m_istrig=(m_invert)?1:0; + m_istrig_prev=0; m_reset = true; } -- cgit v1.2.3 From bc55102eac2ac0dfba8f32530ac674213aedc477 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Oct 2008 23:21:01 +0000 Subject: renamed WITH_BF_BPYDOC to WITH_BF_DOCS, added SConscript for building BGE docs too. --- source/gameengine/PyDoc/SConscript | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 source/gameengine/PyDoc/SConscript (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/SConscript b/source/gameengine/PyDoc/SConscript new file mode 100644 index 00000000000..3d1aa66bc69 --- /dev/null +++ b/source/gameengine/PyDoc/SConscript @@ -0,0 +1,28 @@ +#!/usr/bin/python +Import ('env') + + +from optparse import OptionParser +try: + import epydoc +except ImportError: + print "No epydoc install detected, Python API Docs will not be generated " +if epydoc: + from epydoc.docbuilder import build_doc_index + from epydoc import cli + names = env.Glob("source/gameengine/PyDoc/*.py") + docindex = build_doc_index(names) + optvalues = cli.OPTION_DEFAULTS + optvalues["verbose"] = 1 + optvalues["target"] = env["BF_DOCDIR"]+"/BGE_API/" + optvalues["url"] = "http://www.blender.org" + optvalues["top"] = "Game Engine API" + optvalues["name"] = "Blender" + optvalues["noprivate"] = 1 + optvalues["noframes"] = 1 + optvalues["names"] = names + optparser = OptionParser() + optparser.set_defaults(**optvalues) + (options, args) = optparser.parse_args() + cli.write_html(docindex, options) + -- cgit v1.2.3 From 59a30d822fe5ecfafbb5676b2058b7ff8d3760ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Oct 2008 03:10:00 +0000 Subject: fix for [#17878] Scripts operating on blender objects don't clear memory after a crash This is an interesting bug since it is likely the cause of many other suspicious python crashes in blender. sys.last_traceback would store references to PyObjects at the point of the crash. it would only free these when sys.last_traceback was set again or on exit. This caused many crashes in the BGE while testing since python would end up freeing invalid game objects - When running scripts with errors, Blender would crash every 2-5 runs - in my test just now it crashed after 4 trys. It could also segfault blender, when (for eg) you run a script that has objects referenced. then load a new file and run another script that raises an error. In this case all the invalid Blender-Object's user counts would be decremented, even though none of the pointers were still valid. --- source/gameengine/GameLogic/SCA_PythonController.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 4cb9bc8fe53..1bbb93e0acc 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -262,6 +262,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) printf("Python compile error from controller \"%s\": \n", GetName().Ptr()); //PyRun_SimpleString(m_scriptText.Ptr()); PyErr_Print(); + + /* Added in 2.48a, the last_traceback can reference Objects for example, increasing + * their user count. Not to mention holding references to wrapped data. + * This is especially bad when the PyObject for the wrapped data is free'd, after blender + * has alredy dealocated the pointer */ + PySys_SetObject( "last_traceback", Py_None); + return; } m_bModified=false; @@ -298,6 +305,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) // something is wrong, tell the user what went wrong printf("Python script error from controller \"%s\": \n", GetName().Ptr()); PyErr_Print(); + + /* Added in 2.48a, the last_traceback can reference Objects for example, increasing + * their user count. Not to mention holding references to wrapped data. + * This is especially bad when the PyObject for the wrapped data is free'd, after blender + * has alredy dealocated the pointer */ + PySys_SetObject( "last_traceback", Py_None); + //PyRun_SimpleString(m_scriptText.Ptr()); } -- cgit v1.2.3 From 69c6bd604c36e06d704948bce1eb32134ac8971f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Oct 2008 07:09:15 +0000 Subject: make sure BPY_Err_Handle clears python errors, even if the exception cant be printed. Added PyErr_Clear() incase there are other references to exception data (sys.exc_info() from python) --- source/gameengine/GameLogic/SCA_PythonController.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 1bbb93e0acc..c354ab39747 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -268,6 +268,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) * This is especially bad when the PyObject for the wrapped data is free'd, after blender * has alredy dealocated the pointer */ PySys_SetObject( "last_traceback", Py_None); + PyErr_Clear(); /* just to be sure */ return; } @@ -311,6 +312,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) * This is especially bad when the PyObject for the wrapped data is free'd, after blender * has alredy dealocated the pointer */ PySys_SetObject( "last_traceback", Py_None); + PyErr_Clear(); /* just to be sure */ //PyRun_SimpleString(m_scriptText.Ptr()); } -- cgit v1.2.3 From 2e96728843d01fa0e8c79133b0e7f943930405de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 Oct 2008 15:47:58 +0000 Subject: face transp option CLIP wasnt added to the py api. added gameObject.replaceMesh(meshname) - needed this for an automatically generated scene where 100's of objects would have needed logic bricks automatically added. Quicker to run replace mesh on all of them from 1 script. --- source/gameengine/Ketsji/KX_GameObject.cpp | 23 +++++++++++++++++++++++ source/gameengine/Ketsji/KX_GameObject.h | 1 + source/gameengine/PyDoc/KX_GameObject.py | 5 +++++ 3 files changed, 29 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 8b2feca53a3..739c122a5ef 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -998,6 +998,7 @@ PyMethodDef KX_GameObject::Methods[] = { {"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS}, {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS}, {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS}, + {"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_O}, {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS}, KX_PYMETHODTABLE(KX_GameObject, rayCastTo), KX_PYMETHODTABLE(KX_GameObject, rayCast), @@ -1024,6 +1025,28 @@ bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args, } */ +PyObject* KX_GameObject::PyReplaceMesh(PyObject* self, PyObject* value) +{ + KX_Scene *scene = PHY_GetActiveScene(); + char* meshname; + void* mesh_pt; + + meshname = PyString_AsString(value); + if (meshname==NULL) { + PyErr_SetString(PyExc_ValueError, "Expected a mesh name"); + return NULL; + } + mesh_pt = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname)); + + if (mesh_pt==NULL) { + PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist"); + return NULL; + } + scene->ReplaceMesh(this, (class RAS_MeshObject*)mesh_pt); + + Py_RETURN_NONE; +} + PyObject* KX_GameObject::PyEndObject(PyObject* self) { diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 472d31362dd..20b15787d27 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -801,6 +801,7 @@ public: KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh); KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId); KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames); + KX_PYMETHOD_O(KX_GameObject,ReplaceMesh); KX_PYMETHOD_NOARGS(KX_GameObject,EndObject); KX_PYMETHOD_DOC(KX_GameObject,rayCastTo); KX_PYMETHOD_DOC(KX_GameObject,rayCast); diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index ff9b4ffc95b..505ce253dd1 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -30,6 +30,11 @@ class KX_GameObject: Delete this object, can be used inpace of the EndObject Actuator. The actual removal of the object from the scene is delayed. """ + def replaceMesh(mesh_name): + """ + Replace the mesh of this object with a new mesh. This works the same was as the actuator. + @type mesh_name: string + """ def getVisible(): """ Gets the game object's visible flag. -- cgit v1.2.3 From dca18fc332f6b4e18e8cf826fd15db3fe321aafc Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 30 Oct 2008 18:56:20 +0000 Subject: * Build aborts when giving options on command-line when WITH_BF_DOCS=True - make sure epydoc generation doesn't get a fit over options given on scons command-line -> don't use arguments from command-line. --- source/gameengine/PyDoc/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/PyDoc/SConscript b/source/gameengine/PyDoc/SConscript index 3d1aa66bc69..ac0b163d7bd 100644 --- a/source/gameengine/PyDoc/SConscript +++ b/source/gameengine/PyDoc/SConscript @@ -23,6 +23,6 @@ if epydoc: optvalues["names"] = names optparser = OptionParser() optparser.set_defaults(**optvalues) - (options, args) = optparser.parse_args() + (options, args) = optparser.parse_args([]) cli.write_html(docindex, options) -- cgit v1.2.3 From 0bd7934be731aba65680c7fe59f2d89a06391899 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 30 Oct 2008 23:55:07 +0000 Subject: * Minimum SCons version is now 1.0.0 - Code has been changed to reflect this (ie. deprecated functions are not anymore used) * clean up the C and C++ compiler flags mess. - in the environment construction of BlenderLib all the compile flag governing options have been split in the *C*, *CC* and *CXX* containing equivalents. C is for C compiler only flags. CC is for C and C++ compiler flags and CXX is for C++ compiler only flags. All the platform default config files need to be double checked and fixed wherever it looks necessary. Either DIY, or send me a note with needed changes. - a start for the BlenderLib parameter list has been made - all the SConscripts need to be checked and modified to hand in flags properly. * A theeth request: make -jN settable in the config file. - I give you BF_NUMJOBS, which is set to 1 by default. In your user-config.py, set BF_NUMJOBS=4 to have 4 parallel jobs handled. Yay. --- source/gameengine/Physics/Sumo/SConscript | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Physics/Sumo/SConscript b/source/gameengine/Physics/Sumo/SConscript index be7922efd44..86e8db5919f 100644 --- a/source/gameengine/Physics/Sumo/SConscript +++ b/source/gameengine/Physics/Sumo/SConscript @@ -1,7 +1,6 @@ #!/usr/bin/python Import ('env') -sumoenv = env.Copy() sources = ['SumoPHYCallbackBridge.cpp', 'SumoPhysicsController.cpp', 'SumoPhysicsEnvironment.cpp', @@ -16,7 +15,7 @@ incs =['.', 'Fuzzics/include', '#/intern/moto/include' ] -incs += [sumoenv['BF_SOLID_INC']] +incs += [env['BF_SOLID_INC']] cflags = [] if env['OURPLATFORM']=='win32-vc': -- cgit v1.2.3 From 77b4c66cc3de461fdd0074e46a3a77de1fd83447 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 31 Oct 2008 21:06:48 +0000 Subject: Preparation to VideoTexture: everything but the VideoTexture module itself. Rename PHY_GetActiveScene() to KX_GetActiveScene(): more logical name Add KX_GetActiveEngine() new KX_KetsjiEngine::GetClockTime(void) to return current render frame time: if the CPU does not keep up with the frame rate, up to 5 consecutive logic frames are processed between each render frame, so that the logic system stays accurate even if the graphic system is slow. For the video texture module, it is important to stay in sync with the render frame: no need to update the texture for logic frame. BL_Texture::swapTexture(): texture id manipulation BL_Texture::getTex() : return material texture Enable video support in ffmpeg for Linux. --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 1 + source/gameengine/Ketsji/BL_Texture.h | 8 ++++++++ source/gameengine/Ketsji/KX_BlenderMaterial.h | 3 +++ source/gameengine/Ketsji/KX_Camera.cpp | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 8 ++++---- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 9 +++++++-- source/gameengine/Ketsji/KX_KetsjiEngine.h | 5 +++++ source/gameengine/Ketsji/KX_ParentActuator.cpp | 2 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 9 +++++++-- source/gameengine/Ketsji/KX_PythonInit.h | 9 +++++++-- 10 files changed, 44 insertions(+), 12 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 9fbdc3fa1c9..2b3ef1b31e3 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -364,6 +364,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, initGameKeys(); initPythonConstraintBinding(); initMathutils(); + //initVideoTexture(); if (sceneconverter) { diff --git a/source/gameengine/Ketsji/BL_Texture.h b/source/gameengine/Ketsji/BL_Texture.h index 0d0c7a277f2..830ffceb0f7 100644 --- a/source/gameengine/Ketsji/BL_Texture.h +++ b/source/gameengine/Ketsji/BL_Texture.h @@ -59,6 +59,14 @@ public: void SetMapping(int mode); void DisableUnit(); void setTexEnv(BL_Material *mat, bool modulate=false); + unsigned int swapTexture (unsigned int newTex) { + // swap texture codes + unsigned int tmp = mTexture; + mTexture = newTex; + // return original texture code + return tmp; + } + }; #endif//__BL_TEXTURE_H__ diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index 4ddf5a924df..b858fa3754c 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -67,6 +67,9 @@ public: MTFace* GetMTFace(void) const; unsigned int* GetMCol(void) const; + BL_Texture * getTex (unsigned int idx) { + return (idx < MAXTEX) ? mTextures + idx : NULL; + } // for ipos void UpdateIPO( diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 3830d422138..53b3e348a36 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -793,7 +793,7 @@ KX_PYMETHODDEF_DOC(KX_Camera, setOnTop, { class KX_Scene* scene; - scene = PHY_GetActiveScene(); + scene = KX_GetActiveScene(); MT_assert(scene); scene->SetCameraOnTop(this); Py_Return; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 739c122a5ef..a168beb9a70 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1027,7 +1027,7 @@ bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args, PyObject* KX_GameObject::PyReplaceMesh(PyObject* self, PyObject* value) { - KX_Scene *scene = PHY_GetActiveScene(); + KX_Scene *scene = KX_GetActiveScene(); char* meshname; void* mesh_pt; @@ -1050,7 +1050,7 @@ PyObject* KX_GameObject::PyReplaceMesh(PyObject* self, PyObject* value) PyObject* KX_GameObject::PyEndObject(PyObject* self) { - KX_Scene *scene = PHY_GetActiveScene(); + KX_Scene *scene = KX_GetActiveScene(); scene->DelayedRemoveObject(this); Py_RETURN_NONE; @@ -1447,7 +1447,7 @@ PyObject* KX_GameObject::PySetParent(PyObject* self, PyObject* value) // The object we want to set as parent CValue *m_ob = (CValue*)value; KX_GameObject *obj = ((KX_GameObject*)m_ob); - KX_Scene *scene = PHY_GetActiveScene(); + KX_Scene *scene = KX_GetActiveScene(); this->SetParent(scene, obj); @@ -1456,7 +1456,7 @@ PyObject* KX_GameObject::PySetParent(PyObject* self, PyObject* value) PyObject* KX_GameObject::PyRemoveParent(PyObject* self) { - KX_Scene *scene = PHY_GetActiveScene(); + KX_Scene *scene = KX_GetActiveScene(); this->RemoveParent(scene); Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index b1ab8e3e7de..8bcda4479e1 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -470,7 +470,7 @@ else m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); // set Python hooks for each scene PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment()); - PHY_SetActiveScene(scene); + KX_SetActiveScene(scene); scene->GetPhysicsEnvironment()->endFrame(); @@ -568,7 +568,7 @@ else // set Python hooks for each scene PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment()); - PHY_SetActiveScene(scene); + KX_SetActiveScene(scene); m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); scene->UpdateParents(m_clockTime); @@ -1540,6 +1540,11 @@ double KX_KetsjiEngine::GetAnimFrameRate() return m_anim_framerate; } +double KX_KetsjiEngine::GetClockTime(void) const +{ + return m_clockTime; +} + void KX_KetsjiEngine::SetAnimFrameRate(double framerate) { m_anim_framerate = framerate; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 1aa067a9962..4184202c518 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -253,6 +253,11 @@ public: */ bool GetUseFixedTime(void) const; + /** + * Returns current render frame clock time + */ + double GetClockTime(void) const; + /** * Returns the difference between the local time of the scene (when it * was running and not suspended) and the "curtime" diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp index eb56e8de679..89549ca6b57 100644 --- a/source/gameengine/Ketsji/KX_ParentActuator.cpp +++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp @@ -119,7 +119,7 @@ bool KX_ParentActuator::Update() return false; // do nothing on negative events KX_GameObject *obj = (KX_GameObject*) GetParent(); - KX_Scene *scene = PHY_GetActiveScene(); + KX_Scene *scene = KX_GetActiveScene(); switch (m_mode) { case KX_PARENT_SET: if (m_ob) diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index a30d9f4022d..0032d83c2ff 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1461,16 +1461,21 @@ PyObject* initMathutils() return Mathutils_Init("Mathutils"); // Use as a top level module in BGE } -void PHY_SetActiveScene(class KX_Scene* scene) +void KX_SetActiveScene(class KX_Scene* scene) { gp_KetsjiScene = scene; } -class KX_Scene* PHY_GetActiveScene() +class KX_Scene* KX_GetActiveScene() { return gp_KetsjiScene; } +class KX_KetsjiEngine* KX_GetActiveEngine() +{ + return gp_KetsjiEngine; +} + // utility function for loading and saving the globalDict int saveGamePythonConfig( char **marshal_buffer) { diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h index 36e3db6ec35..57ee0be9400 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.h +++ b/source/gameengine/Ketsji/KX_PythonInit.h @@ -45,6 +45,7 @@ PyObject* initGameKeys(); PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas); PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level); PyObject* initMathutils(); +PyObject* initVideoTexture(void); void exitGamePlayerPythonScripting(); PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level); void exitGamePythonScripting(); @@ -54,8 +55,12 @@ void pathGamePythonConfig( char *path ); int saveGamePythonConfig( char **marshal_buffer); int loadGamePythonConfig(char *marshal_buffer, int marshal_length); -void PHY_SetActiveScene(class KX_Scene* scene); -class KX_Scene* PHY_GetActiveScene(); +class KX_KetsjiEngine; +class KX_Scene; + +void KX_SetActiveScene(class KX_Scene* scene); +class KX_Scene* KX_GetActiveScene(); +class KX_KetsjiEngine* KX_GetActiveEngine(); #include "MT_Vector3.h" void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color); -- cgit v1.2.3 From a8c4eef3265358d3d70c6c448fe4d1c4273defee Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 31 Oct 2008 22:35:52 +0000 Subject: VideoTexture module. The only compilation system that works for sure is the MSVC project files. I've tried my best to update the other compilation system but I count on the community to check and fix them. This is Zdeno Miklas video texture plugin ported to trunk. The original plugin API is maintained (can be found here http://home.scarlet.be/~tsi46445/blender/blendVideoTex.html) EXCEPT for the following: The module name is changed to VideoTexture (instead of blendVideoTex). A new (and only) video source is now available: VideoFFmpeg() You must pass 1 to 4 arguments when you create it (you can use named arguments): VideoFFmpeg(file) : play a video file VideoFFmpeg(file, capture, rate, width, height) : start a live video capture file: In the first form, file is a video file name, relative to startup directory. It can also be a URL, FFmpeg will happily stream a video from a network source. In the second form, file is empty or is a hint for the format of the video capture. In Windows, file is ignored and should be empty or not specified. In Linux, ffmpeg supports two types of device: VideoForLinux and DV1394. The user specifies the type of device with the file parameter: [][:] : 'v4l' for VideoForLinux, 'dv1394' for DV1394; default to 'v4l' : 'pal', 'secam' or 'ntsc', default to 'ntsc' The driver name is constructed automatically from the device types: v4l : /dev/video dv1394: /dev/dv1394/ If you have different driver name, you can specify the driver name explicitely instead of device type. Examples of valid file parameter: /dev/v4l/video0:pal /dev/ieee1394/1:ntsc dv1394:ntsc v4l:pal :secam capture: Defines the index number of the capture source, starting from 0. The first capture device is always 0. The VideoTexutre modules knows that you want to start a live video capture when you set this parameter to a number >= 0. Setting this parameter < 0 indicates a video file playback. Default value is -1. rate: the capture frame rate, by default 25 frames/sec width: height: Width and height of the video capture in pixel, default value 0. In Windows you must specify these values and they must fit with the capture device capability. For example, if you have a webcam that can capture at 160x120, 320x240 or 640x480, you must specify one of these couple of values or the opening of the video source will fail. In Linux, default values are provided by the VideoForLinux driver if you don't specify width and height. Simple example ************** 1. Texture definition script: import VideoTexture contr = GameLogic.getCurrentController() obj = contr.getOwner() if not hasattr(GameLogic, 'video'): matID = VideoTexture.materialID(obj, 'MAVideoMat') GameLogic.video = VideoTexture.Texture(obj, matID) GameLogic.vidSrc = VideoTexture.VideoFFmpeg('trailer_400p.ogg') # Streaming is also possible: #GameLogic.vidSrc = VideoTexture.VideoFFmpeg('http://10.32.1.10/trailer_400p.ogg') GameLogic.vidSrc.repeat = -1 # If the video dimensions are not a power of 2, scaling must be done before # sending the texture to the GPU. This is done by default with gluScaleImage() # but you can also use a faster, but less precise, scaling by setting scale # to True. Best approach is to convert the video offline and set the dimensions right. GameLogic.vidSrc.scale = True # FFmpeg always delivers the video image upside down, so flipping is enabled automatically #GameLogic.vidSrc.flip = True if contr.getSensors()[0].isPositive(): GameLogic.video.source = GameLogic.vidSrc GameLogic.vidSrc.play() 2. Texture refresh script: obj = GameLogic.getCurrentController().getOwner() if hasattr(GameLogic, 'video') != 0: GameLogic.video.refresh(True) You can download this demo here: http://home.scarlet.be/~tsi46445/blender/VideoTextureDemo.blend http://home.scarlet.be/~tsi46445/blender/trailer_400p.ogg --- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 2 +- source/gameengine/CMakeLists.txt | 1 + source/gameengine/SConscript | 3 +- source/gameengine/VideoTexture/BlendType.h | 75 +++ source/gameengine/VideoTexture/CMakeLists.txt | 60 ++ source/gameengine/VideoTexture/Common.h | 55 ++ source/gameengine/VideoTexture/Exception.cpp | 198 ++++++ source/gameengine/VideoTexture/Exception.h | 195 ++++++ source/gameengine/VideoTexture/FilterBase.cpp | 150 +++++ source/gameengine/VideoTexture/FilterBase.h | 132 ++++ .../gameengine/VideoTexture/FilterBlueScreen.cpp | 178 +++++ source/gameengine/VideoTexture/FilterBlueScreen.h | 98 +++ source/gameengine/VideoTexture/FilterColor.cpp | 350 ++++++++++ source/gameengine/VideoTexture/FilterColor.h | 164 +++++ source/gameengine/VideoTexture/FilterNormal.cpp | 162 +++++ source/gameengine/VideoTexture/FilterNormal.h | 98 +++ source/gameengine/VideoTexture/FilterSource.cpp | 125 ++++ source/gameengine/VideoTexture/FilterSource.h | 233 +++++++ source/gameengine/VideoTexture/ImageBase.cpp | 529 +++++++++++++++ source/gameengine/VideoTexture/ImageBase.h | 349 ++++++++++ source/gameengine/VideoTexture/ImageBuff.cpp | 166 +++++ source/gameengine/VideoTexture/ImageBuff.h | 51 ++ source/gameengine/VideoTexture/ImageMix.cpp | 205 ++++++ source/gameengine/VideoTexture/ImageMix.h | 123 ++++ source/gameengine/VideoTexture/ImageRender.cpp | 261 +++++++ source/gameengine/VideoTexture/ImageRender.h | 90 +++ source/gameengine/VideoTexture/ImageViewport.cpp | 298 ++++++++ source/gameengine/VideoTexture/ImageViewport.h | 84 +++ source/gameengine/VideoTexture/Makefile | 65 ++ source/gameengine/VideoTexture/PyTypeList.cpp | 83 +++ source/gameengine/VideoTexture/PyTypeList.h | 85 +++ source/gameengine/VideoTexture/SConscript | 32 + source/gameengine/VideoTexture/Texture.cpp | 463 +++++++++++++ source/gameengine/VideoTexture/Texture.h | 87 +++ source/gameengine/VideoTexture/VideoBase.cpp | 183 +++++ source/gameengine/VideoTexture/VideoBase.h | 185 +++++ source/gameengine/VideoTexture/VideoFFmpeg.cpp | 747 +++++++++++++++++++++ source/gameengine/VideoTexture/VideoFFmpeg.h | 159 +++++ source/gameengine/VideoTexture/blendVideoTex.cpp | 206 ++++++ 39 files changed, 6728 insertions(+), 2 deletions(-) create mode 100644 source/gameengine/VideoTexture/BlendType.h create mode 100644 source/gameengine/VideoTexture/CMakeLists.txt create mode 100644 source/gameengine/VideoTexture/Common.h create mode 100644 source/gameengine/VideoTexture/Exception.cpp create mode 100644 source/gameengine/VideoTexture/Exception.h create mode 100644 source/gameengine/VideoTexture/FilterBase.cpp create mode 100644 source/gameengine/VideoTexture/FilterBase.h create mode 100644 source/gameengine/VideoTexture/FilterBlueScreen.cpp create mode 100644 source/gameengine/VideoTexture/FilterBlueScreen.h create mode 100644 source/gameengine/VideoTexture/FilterColor.cpp create mode 100644 source/gameengine/VideoTexture/FilterColor.h create mode 100644 source/gameengine/VideoTexture/FilterNormal.cpp create mode 100644 source/gameengine/VideoTexture/FilterNormal.h create mode 100644 source/gameengine/VideoTexture/FilterSource.cpp create mode 100644 source/gameengine/VideoTexture/FilterSource.h create mode 100644 source/gameengine/VideoTexture/ImageBase.cpp create mode 100644 source/gameengine/VideoTexture/ImageBase.h create mode 100644 source/gameengine/VideoTexture/ImageBuff.cpp create mode 100644 source/gameengine/VideoTexture/ImageBuff.h create mode 100644 source/gameengine/VideoTexture/ImageMix.cpp create mode 100644 source/gameengine/VideoTexture/ImageMix.h create mode 100644 source/gameengine/VideoTexture/ImageRender.cpp create mode 100644 source/gameengine/VideoTexture/ImageRender.h create mode 100644 source/gameengine/VideoTexture/ImageViewport.cpp create mode 100644 source/gameengine/VideoTexture/ImageViewport.h create mode 100644 source/gameengine/VideoTexture/Makefile create mode 100644 source/gameengine/VideoTexture/PyTypeList.cpp create mode 100644 source/gameengine/VideoTexture/PyTypeList.h create mode 100644 source/gameengine/VideoTexture/SConscript create mode 100644 source/gameengine/VideoTexture/Texture.cpp create mode 100644 source/gameengine/VideoTexture/Texture.h create mode 100644 source/gameengine/VideoTexture/VideoBase.cpp create mode 100644 source/gameengine/VideoTexture/VideoBase.h create mode 100644 source/gameengine/VideoTexture/VideoFFmpeg.cpp create mode 100644 source/gameengine/VideoTexture/VideoFFmpeg.h create mode 100644 source/gameengine/VideoTexture/blendVideoTex.cpp (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 2b3ef1b31e3..2d91bbcd7c1 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -364,7 +364,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area, initGameKeys(); initPythonConstraintBinding(); initMathutils(); - //initVideoTexture(); + initVideoTexture(); if (sceneconverter) { diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt index 93de588ba00..3ea788791e2 100644 --- a/source/gameengine/CMakeLists.txt +++ b/source/gameengine/CMakeLists.txt @@ -40,6 +40,7 @@ SUBDIRS( SceneGraph Physics/Bullet Physics/Sumo + VideoTexture ) IF(WITH_PLAYER) diff --git a/source/gameengine/SConscript b/source/gameengine/SConscript index c2750d19706..e841f206eee 100644 --- a/source/gameengine/SConscript +++ b/source/gameengine/SConscript @@ -15,7 +15,8 @@ SConscript(['BlenderRoutines/SConscript', 'Rasterizer/RAS_OpenGLRasterizer/SConscript', 'SceneGraph/SConscript', 'Physics/Bullet/SConscript', - 'Physics/Sumo/SConscript' + 'Physics/Sumo/SConscript', + 'VideoTexture/SConscript' ]) if env['WITH_BF_PLAYER']: diff --git a/source/gameengine/VideoTexture/BlendType.h b/source/gameengine/VideoTexture/BlendType.h new file mode 100644 index 00000000000..ac3ed8812a6 --- /dev/null +++ b/source/gameengine/VideoTexture/BlendType.h @@ -0,0 +1,75 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2006 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined BLENDTYPE_H +#define BLENDTYPE_H + + +/// class allows check type of blender python object and access its contained object +template class BlendType +{ +public: + /// constructor + BlendType (char * name) : m_name(name) {} + + /// check blender type and return pointer to contained object or NULL (if type is not valid) + PyObj * checkType (PyObject * obj) + { + // if pointer to type isn't set + if (m_objType == NULL) + { + // compare names of type + if (strcmp(obj->ob_type->tp_name, m_name) == 0) + // if name of type match, save pointer to type + m_objType = obj->ob_type; + else + // if names of type don't match, return NULL + return NULL; + } + // if pointer to type is set and don't match to type of provided object, return NULL + else if (obj->ob_type != m_objType) + return NULL; + // return pointer to object + return (PyObj*)obj; + } + + /// parse arguments to get object + PyObj * parseArg (PyObject * args) + { + // parse arguments + PyObject * obj; + if (PyArg_ParseTuple(args, "O", &obj)) + // if successfully parsed, return pointer to object + return checkType(obj); + // otherwise return NULL + return NULL; + } + +protected: + /// name of Python type + char * m_name; + /// pointer to Python type + PyTypeObject * m_objType; +}; + + +#endif diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt new file mode 100644 index 00000000000..fbae66e0ef4 --- /dev/null +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -0,0 +1,60 @@ +# $Id$ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2006, Blender Foundation +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): Jacques Beaurain. +# +# ***** END GPL LICENSE BLOCK ***** + +FILE(GLOB SRC *.cpp) + +SET(INC + . + ../../../source/gameengine/Ketsji + ../../../source/gameengine/Expressions + ../../../source/gameengine/GameLogic + ../../../source/gameengine/SceneGraph + ../../../source/gameengine/Rasterizer + ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer + ../../../source/gameengine/BlenderRoutines + ../../../source/blender/include + ../../../source/blender/blenlib + ../../../source/blender/blenkernel + ../../../source/blender/makesdna + ../../../source/blender/imbuf + ../../../source/blender/python + ../../../source/blender/gpu + ../../../source/kernel/gen_system + ../../../intern/string + ../../../intern/moto/include + ../../../intern/guardedalloc + ../../../intern/SoundSystem + ../../../extern/glew/include + ${PYTHON_INC} +) + +IF(WITH_FFMPEG) + SET(INC ${INC} ${FFMPEG_INC}) + ADD_DEFINITIONS(-DWITH_FFMPEG) +ENDIF(WITH_FFMPEG) + +BLENDERLIB(bf_videotex "${SRC}" "${INC}") +#env.BlenderLib ( 'bf_videotex', sources, Split(incs), [], libtype=['game','player'], priority=[25, 72], compileflags = cflags ) diff --git a/source/gameengine/VideoTexture/Common.h b/source/gameengine/VideoTexture/Common.h new file mode 100644 index 00000000000..f771077bbba --- /dev/null +++ b/source/gameengine/VideoTexture/Common.h @@ -0,0 +1,55 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2006 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if defined WIN32 +#define WINDOWS_LEAN_AND_MEAN +#endif + +#if !defined NULL +#define NULL 0 +#endif + +#if !defined HRESULT +#define HRESULT long +#endif + +#if !defined DWORD +#define DWORD unsigned long +#endif + +#if !defined S_OK +#define S_OK ((HRESULT)0L) +#endif + +#if !defined BYTE +#define BYTE unsigned char +#endif + +#if !defined WIN32 +#define Sleep(time) sleep(time) +#endif + +#if !defined FAILED +#define FAILED(Status) ((HRESULT)(Status)<0) +#endif + +#include diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp new file mode 100644 index 00000000000..a326430b27a --- /dev/null +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -0,0 +1,198 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2006 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + + +#include +#include + +#include + +#include "Exception.h" + + +// exception identificators +ExceptionID ErrGeneral, ErrNotFound; + +// exception descriptions +ExpDesc errGenerDesc (ErrGeneral, "General Error"); +ExpDesc errNFoundDesc (ErrNotFound, "Error description not found"); + + + +// implementation of ExpDesc + +// constructor +ExpDesc::ExpDesc (ExceptionID & exp, char * desc, RESULT hres) +: m_expID(exp), m_hRslt(hres), m_description(desc) +{ + m_expDescs.push_back(this); +} + +// destructor +ExpDesc::~ExpDesc (void) {} + +// list of descriptions +std::vector ExpDesc::m_expDescs; + + +// class Exception + + +// last exception description +std::string Exception::m_lastError; + +// log file name +char * Exception::m_logFile = NULL; + + +// basic constructor +Exception::Exception () +{ + // default values + m_expID = &ErrNotFound; + m_hRslt = S_OK; + m_line = 0; +} + + +// destructor +Exception::~Exception () throw() { } + + +// copy constructor +Exception::Exception (const Exception & xpt) +{ copy (xpt); } + + +// assignment operator +Exception & Exception::operator= (const Exception & xpt) +{ copy (xpt); return *this; } + + +// get exception description +const char * Exception::what() +{ + // set exception description + setXptDesc(); + // return c string + return m_desc.c_str(); +} + + +// debug version - with file and line of exception +Exception::Exception (ExceptionID & expID, RESULT rslt, char * fil, int lin) +: m_expID (&expID), m_hRslt (rslt) +{ + // set file and line + if (strlen(fil) > 0 || lin > 0) + setFileLine (fil, lin); +} + + +// set file and line +void Exception::setFileLine (char * fil, int lin) +{ + if (fil != NULL) m_fileName = fil; + m_line = lin; +} + + +// report exception +void Exception::report(void) +{ + // set exception description + setXptDesc(); + // set python error + PyErr_SetString(PyExc_RuntimeError, what()); + // if log file is set + if (m_logFile != NULL) + { + // write description to log + std::ofstream logf (m_logFile, std::ios_base::app); + logf << m_fileName << ':' << m_line << ':' << m_desc << std::endl; + logf.flush(); + logf.close(); + } +} + + +// set exception description +void Exception::setXptDesc (void) +{ + // if description is not set + if (m_desc.size() == 0) + { + // start of search -1 + // found description "NotFound" 0 + // found description without matching result 1 + // found description with matching result 2 + int best = -1; + // find exception description + for (std::vector::iterator it = ExpDesc::m_expDescs.begin(); it != ExpDesc::m_expDescs.end(); ++it) + { + // use "NotFound", if there is not better + if (best < 0 && (*it)->isExp(&ErrNotFound) > 0) + { + (*it)->loadDesc(m_desc); + best = 0; + } + // match exception + int nBest = (*it)->isExp(m_expID, m_hRslt); + // if exception is matching better + if (nBest > 0 && best < nBest) + { + // set description + (*it)->loadDesc(m_desc); + best = nBest; + // if matching exactly, finish search + if (best == 2) break; + } + } + // add result code + // length of result code + const size_t rsltSize = 10; + // delimit description + const char delimRslt[] = ": "; + // set text of description + char rsltTxt[rsltSize]; + std::ostrstream os(rsltTxt, rsltSize); + os << std::hex << m_hRslt << delimRslt; + // copy result to description + m_desc.insert(0, rsltTxt, rsltSize); + // copy exception description to last exception string + m_lastError = m_desc; + } +} + + +// copy exception data +void Exception::copy (const Exception & xpt) +{ + // standard data + m_expID = xpt.m_expID; + m_hRslt = xpt.m_hRslt; + m_desc = xpt.m_desc; + + // debug data + m_fileName = xpt.m_fileName; + m_line = xpt.m_line; +} diff --git a/source/gameengine/VideoTexture/Exception.h b/source/gameengine/VideoTexture/Exception.h new file mode 100644 index 00000000000..85865fb3654 --- /dev/null +++ b/source/gameengine/VideoTexture/Exception.h @@ -0,0 +1,195 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2006 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + + +#if !defined EXCEPTION_H +#define EXCEPTION_H + +#include +#include +#include + +#include "Common.h" + + +#define CHCKHRSLTV(fnc,val,err) \ +{ \ + HRESULT macroHRslt = (fnc); \ + if (macroHRslt != val) \ + throw Exception (err, macroHRslt, __FILE__, __LINE__); \ +} + +#define THRWEXCP(err,hRslt) throw Exception (err, hRslt, __FILE__, __LINE__); + + +#if defined WIN32 + +#define CHCKHRSLT(fnc,err) \ +{ \ + HRESULT macroHRslt = (fnc); \ + if (FAILED(macroHRslt)) \ + throw Exception (err, macroHRslt, __FILE__, __LINE__); \ +} + +#else + +#define CHCKHRSLT(fnc,err) CHCKHRSLTV(fnc,S_OK,err) + +#endif + + +// forward declarations +class ExceptionID; +class Exception; + + +// exception identificators +extern ExceptionID ErrGeneral, ErrNotFound; + + +// result type +typedef long RESULT; + + +// class ExceptionID for exception identification +class ExceptionID +{ +public: + // constructor a destructor + ExceptionID (void) {} + ~ExceptionID (void) {} + +private: + // not allowed + ExceptionID (const ExceptionID & obj) throw() {} + ExceptionID & operator= (const ExceptionID & obj) throw() { return *this; } +}; + + +// class ExpDesc for exception description +class ExpDesc +{ +public: + // constructor a destructor + ExpDesc (ExceptionID & exp, char * desc, RESULT hres = S_OK); + ~ExpDesc (void); + + // comparision function + // returns 0, if exception identification don't match at all + // returns 1, if only exception identification is matching + // returns 2, if both exception identification and result are matching + int isExp (ExceptionID * exp, RESULT hres = S_OK) throw() + { + // check exception identification + if (&m_expID == exp) + { + // check result value + if (m_hRslt == hres) return 2; + // only identification match + if (m_hRslt == S_OK) return 1; + } + // no match + return 0; + } + + // get exception description + void loadDesc (std::string & desc) throw() + { + desc = m_description; + } + + // list of exception descriptions + static std::vector m_expDescs; + +private: + // exception ID + ExceptionID & m_expID; + // result + RESULT m_hRslt; + // description + char * m_description; + + // not allowed + ExpDesc (const ExpDesc & obj) : m_expID (ErrNotFound) {} + ExpDesc & operator= (const ExpDesc & obj) { return *this; } +}; + + + +// class Exception +class Exception : public std::exception +{ +public: + // constructor + Exception (); + // destructor + virtual ~Exception () throw(); + // copy constructor + Exception (const Exception & xpt); + // assignment operator + Exception & operator= (const Exception & xpt); + // get exception description + virtual const char * what(void); + + // debug version of constructor + Exception (ExceptionID & expID, RESULT rslt, char * fil, int lin); + // set source file and line of exception + void setFileLine (char * fil, int lin); + + // get description in string + std::string & getDesc (void) throw() { return m_desc; } + + // report exception + virtual void report (void); + + // get exception id + ExceptionID * getID (void) throw() { return m_expID; } + + /// last exception description + static std::string m_lastError; + + /// log file name + static char * m_logFile; + +protected: + // exception identification + ExceptionID * m_expID; + // RESULT code + RESULT m_hRslt; + + // exception description + std::string m_desc; + + // set exception description + virtual void setXptDesc (void); + + // copy exception + void copy (const Exception & xpt); + + // file name where exception was thrown + std::string m_fileName; + // line number in file + int m_line; + +}; + +#endif diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp new file mode 100644 index 00000000000..078a096aff7 --- /dev/null +++ b/source/gameengine/VideoTexture/FilterBase.cpp @@ -0,0 +1,150 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#include "FilterBase.h" + +#include +#include + + +// FilterBase class implementation + +// constructor +FilterBase::FilterBase (void) : m_previous(NULL) {} + + +// destructor +FilterBase::~FilterBase (void) +{ + // release Python objects, if not released yet + release(); +} + + +// release python objects +void FilterBase::release (void) +{ + // release previous filter object + setPrevious(NULL); +} + + +// set new previous filter +void FilterBase::setPrevious (PyFilter * filt, bool useRefCnt) +{ + // if reference counting has to be used + if (useRefCnt) + { + // reference new filter + if (filt != NULL) Py_INCREF(filt); + // release old filter + Py_XDECREF(m_previous); + } + // set new previous filter + m_previous = filt; +} + + +// find first filter +FilterBase * FilterBase::findFirst (void) +{ + // find first filter in chain + FilterBase * frst; + for (frst = this; frst->m_previous != NULL; frst = frst->m_previous->m_filter); + // set first filter + return frst; +} + + + +// list offilter types +PyTypeList pyFilterTypes; + + + +// functions for python interface + + +// object allocation +PyObject * Filter_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds) +{ + // allocate object + PyFilter * self = reinterpret_cast(type->tp_alloc(type, 0)); + // initialize object structure + self->m_filter = NULL; + // return allocated object + return reinterpret_cast(self); +} + +// object deallocation +void Filter_dealloc (PyFilter * self) +{ + // release object attributes + if (self->m_filter != NULL) + { + self->m_filter->release(); + delete self->m_filter; + self->m_filter = NULL; + } +} + + +// get previous pixel filter object +PyObject * Filter_getPrevious (PyFilter * self, void * closure) +{ + // if filter object is available + if (self->m_filter != NULL) + { + // pixel filter object + PyObject * filt = reinterpret_cast(self->m_filter->getPrevious()); + // if filter is present + if (filt != NULL) + { + // return it + Py_INCREF(filt); + return filt; + } + } + // otherwise return none + Py_RETURN_NONE; +} + + +// set previous pixel filter object +int Filter_setPrevious (PyFilter * self, PyObject * value, void * closure) +{ + // if filter object is available + if (self->m_filter != NULL) + { + // check new value + if (value == NULL || !pyFilterTypes.in(value->ob_type)) + { + // report value error + PyErr_SetString(PyExc_TypeError, "Invalid type of value"); + return -1; + } + // set new value + self->m_filter->setPrevious(reinterpret_cast(value)); + } + // return success + return 0; +} diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h new file mode 100644 index 00000000000..fa6f9a754d4 --- /dev/null +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -0,0 +1,132 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined FILTERBASE_H +#define FILTERBASE_H + +#include "Common.h" + +#include + +#include "PyTypeList.h" + + +// forward declaration +class FilterBase; + + +// python structure for filter +struct PyFilter +{ + PyObject_HEAD + // source object + FilterBase * m_filter; +}; + + +/// base class for pixel filters +class FilterBase +{ +public: + /// constructor + FilterBase (void); + /// destructor + virtual ~FilterBase (void); + // release python objects + virtual void release (void); + + /// convert pixel + template unsigned int convert (SRC src, short x, short y, + short * size, unsigned int pixSize) + { + return filter(src, x, y, size, pixSize, + convertPrevious(src, x, y, size, pixSize)); + } + + /// get previous filter + PyFilter * getPrevious (void) { return m_previous; } + /// set previous filter + void setPrevious (PyFilter * filt, bool useRefCnt = true); + + /// find first filter in chain + FilterBase * findFirst (void); + + /// get first filter's source pixel size + unsigned int firstPixelSize (void) { return findFirst()->getPixelSize(); } + +protected: + /// previous pixel filter + PyFilter * m_previous; + + /// filter pixel, source byte buffer + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return val; } + /// filter pixel, source int buffer + virtual unsigned int filter (unsigned int * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return val; } + + /// get source pixel size + virtual unsigned int getPixelSize (void) { return 1; } + + /// get converted pixel from previous filters + template unsigned int convertPrevious (SRC src, short x, short y, + short * size, unsigned int pixSize) + { + // if previous filter doesn't exists, return source pixel + if (m_previous == NULL) return *src; + // otherwise return converted pixel + return m_previous->m_filter->convert(src, x, y, size, pixSize); + } +}; + + +// list of python filter types +extern PyTypeList pyFilterTypes; + + +// functions for python interface + +// object initialization +template static int Filter_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +{ + PyFilter * self = reinterpret_cast(pySelf); + // create filter object + if (self->m_filter != NULL) delete self->m_filter; + self->m_filter = new T(); + // initialization succeded + return 0; +} + +// object allocation +PyObject * Filter_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds); +// object deallocation +void Filter_dealloc (PyFilter * self); + +// get previous pixel filter object +PyObject * Filter_getPrevious (PyFilter * self, void * closure); +// set previous pixel filter object +int Filter_setPrevious (PyFilter * self, PyObject * value, void * closure); + + +#endif \ No newline at end of file diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp new file mode 100644 index 00000000000..d911b1d7743 --- /dev/null +++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp @@ -0,0 +1,178 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + + +#include +#include + +#include "FilterBlueScreen.h" + +#include "FilterBase.h" +#include "PyTypeList.h" + +// implementation FilterBlueScreen + +// constructor +FilterBlueScreen::FilterBlueScreen (void) +{ + // set color to blue + setColor(0, 0, 255); + // set limits + setLimits(64, 64); +} + +// set color +void FilterBlueScreen::setColor (unsigned char red, unsigned char green, unsigned char blue) +{ + m_color[0] = red; + m_color[1] = green; + m_color[2] = blue; +} + +// set limits for color variation +void FilterBlueScreen::setLimits (unsigned short minLimit, unsigned short maxLimit) +{ + m_limits[0] = minLimit; + m_limits[1] = maxLimit > minLimit ? maxLimit : minLimit; + // calculate square values + for (short idx = 0; idx < 2; ++idx) + m_squareLimits[idx] = m_limits[idx] * m_limits[idx]; + // limits distance + m_limitDist = m_squareLimits[1] - m_squareLimits[0]; +} + + + +// cast Filter pointer to FilterBlueScreen +inline FilterBlueScreen * getFilter (PyFilter * self) +{ return static_cast(self->m_filter); } + + +// python methods and get/sets + +// get color +static PyObject * getColor (PyFilter * self, void * closure) +{ + return Py_BuildValue("[BBB]", getFilter(self)->getColor()[0], + getFilter(self)->getColor()[1], getFilter(self)->getColor()[2]); +} + +// set color +static int setColor (PyFilter * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 3 + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0)) + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)) + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 2))) + { + PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 3 ints"); + return -1; + } + // set color + getFilter(self)->setColor((unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))), + (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))), + (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2)))); + // success + return 0; +} + +// get limits +static PyObject * getLimits (PyFilter * self, void * closure) +{ + return Py_BuildValue("[II]", getFilter(self)->getLimits()[0], + getFilter(self)->getLimits()[1]); +} + +// set limit +static int setLimits (PyFilter * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0)) + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1))) + { + PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints"); + return -1; + } + // set limits + getFilter(self)->setLimits((unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))), + (unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1)))); + // success + return 0; +} + + +// attributes structure +static PyGetSetDef filterBSGetSets[] = +{ + {"color", (getter)getColor, (setter)setColor, "blue screen color", NULL}, + {"limits", (getter)getLimits, (setter)setLimits, "blue screen color limits", NULL}, + // attributes from FilterBase class + {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {NULL} +}; + +// define python type +PyTypeObject FilterBlueScreenType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.FilterBlueScreen", /*tp_name*/ + sizeof(PyFilter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Filter_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Filter for Blue Screen objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + NULL, /* tp_methods */ + 0, /* tp_members */ + filterBSGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Filter_init, /* tp_init */ + 0, /* tp_alloc */ + Filter_allocNew, /* tp_new */ +}; + diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.h b/source/gameengine/VideoTexture/FilterBlueScreen.h new file mode 100644 index 00000000000..1871fbc0516 --- /dev/null +++ b/source/gameengine/VideoTexture/FilterBlueScreen.h @@ -0,0 +1,98 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of blendTex library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined FILTERBLUESCREEN_H +#define FILTERBLUESCREEN_H + +#include "Common.h" + +#include "FilterBase.h" + + +/// pixel filter for blue screen +class FilterBlueScreen : public FilterBase +{ +public: + /// constructor + FilterBlueScreen (void); + /// destructor + virtual ~FilterBlueScreen (void) {} + + /// get color + unsigned char * getColor (void) { return m_color; } + /// set color + void setColor (unsigned char red, unsigned char green, unsigned char blue); + + /// get limits for color variation + unsigned short * getLimits (void) { return m_limits; } + /// set limits for color variation + void setLimits (unsigned short minLimit, unsigned short maxLimit); + +protected: + /// blue screen color (red component first) + unsigned char m_color[3]; + /// limits for color variation - first defines, where ends fully transparent + /// color, second defines, where begins fully opaque color + unsigned short m_limits[2]; + /// squared limits for color variation + unsigned int m_squareLimits[2]; + /// distance between squared limits + unsigned int m_limitDist; + + /// filter pixel template, source int buffer + template unsigned int tFilter (SRC src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + // calculate differences + int difRed = int((val >> 16) & 0xFF) - int(m_color[0]); + int difGreen = int((val >> 8) & 0xFF) - int(m_color[1]); + int difBlue = int(val & 0xFF) - int(m_color[2]); + // calc distance from "blue screen" color + unsigned int dist = (unsigned int)(difRed * difRed + difGreen * difGreen + + difBlue * difBlue); + // condition for fully transparent color + if (m_squareLimits[0] >= dist) + // return color with zero alpha + //return 0xFF000000; + return val & 0x00FFFFFF; + // condition for fully opaque color + else if (m_squareLimits[1] <= dist) + // return normal colour + return val | 0xFF000000; + // otherwise calc alpha + else + return (val & 0x00FFFFFF) | ((((dist - m_squareLimits[0]) << 8) + / m_limitDist) << 24); + } + + /// virtual filtering function for byte source + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } + /// virtual filtering function for unsigned int source + virtual unsigned int filter (unsigned int * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } +}; + + +#endif \ No newline at end of file diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp new file mode 100644 index 00000000000..c45804caf9d --- /dev/null +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -0,0 +1,350 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + + +#include +#include + +#include "FilterColor.h" + +#include "FilterBase.h" +#include "PyTypeList.h" + +// implementation FilterGray + +// attributes structure +static PyGetSetDef filterGrayGetSets[] = +{ // attributes from FilterBase class + {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {NULL} +}; + +// define python type +PyTypeObject FilterGrayType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.FilterGray", /*tp_name*/ + sizeof(PyFilter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Filter_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Filter for gray scale effect", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + NULL, /* tp_methods */ + 0, /* tp_members */ + filterGrayGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Filter_init, /* tp_init */ + 0, /* tp_alloc */ + Filter_allocNew, /* tp_new */ +}; + + +// implementation FilterColor + +// constructor +FilterColor::FilterColor (void) +{ + // reset color matrix to identity + for (int r = 0; r < 4; ++r) + for (int c = 0; c < 5; ++c) + m_matrix[r][c] = (r == c) ? 256 : 0; +} + +// set color matrix +void FilterColor::setMatrix (ColorMatrix & mat) +{ + // copy matrix + for (int r = 0; r < 4; ++r) + for (int c = 0; c < 5; ++c) + m_matrix[r][c] = mat[r][c]; +} + + + +// cast Filter pointer to FilterColor +inline FilterColor * getFilterColor (PyFilter * self) +{ return static_cast(self->m_filter); } + + +// python methods and get/sets + +// get color matrix +static PyObject * getMatrix (PyFilter * self, void * closure) +{ + ColorMatrix & mat = getFilterColor(self)->getMatrix(); + return Py_BuildValue("((hhhhh)(hhhhh)(hhhhh)(hhhhh))", + mat[0][0], mat[0][1], mat[0][2], mat[0][3], mat[0][4], + mat[1][0], mat[1][1], mat[1][2], mat[1][3], mat[1][4], + mat[2][0], mat[2][1], mat[2][2], mat[2][3], mat[2][4], + mat[3][0], mat[3][1], mat[3][2], mat[3][3], mat[3][4]); +} + +// set color matrix +static int setMatrix (PyFilter * self, PyObject * value, void * closure) +{ + // matrix to store items + ColorMatrix mat; + // check validity of parameter + bool valid = value != NULL && PySequence_Check(value) + && PySequence_Length(value) == 4; + // check rows + for (int r = 0; valid && r < 4; ++r) + { + // get row object + PyObject * row = PySequence_Fast_GET_ITEM(value, r); + // check sequence + valid = PySequence_Check(row) && PySequence_Length(row) == 5; + // check items + for (int c = 0; valid && c < 5; ++c) + { + // item must be int + valid = PyInt_Check(PySequence_Fast_GET_ITEM(row, c)); + // if it is valid, save it in matrix + if (valid) + mat[r][c] = short(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c))); + } + } + // if parameter is not valid, report error + if (!valid) + { + PyErr_SetString(PyExc_TypeError, "The value must be a matrix [4][5] of ints"); + return -1; + } + // set color matrix + getFilterColor(self)->setMatrix(mat); + // success + return 0; +} + + +// attributes structure +static PyGetSetDef filterColorGetSets[] = +{ + {"matrix", (getter)getMatrix, (setter)setMatrix, "matrix [4][5] for color calculation", NULL}, + // attributes from FilterBase class + {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {NULL} +}; + +// define python type +PyTypeObject FilterColorType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.FilterColor", /*tp_name*/ + sizeof(PyFilter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Filter_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Filter for color calculations", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + NULL, /* tp_methods */ + 0, /* tp_members */ + filterColorGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Filter_init, /* tp_init */ + 0, /* tp_alloc */ + Filter_allocNew, /* tp_new */ +}; + +// implementation FilterLevel + +// constructor +FilterLevel::FilterLevel (void) +{ + // reset color levels + for (int r = 0; r < 4; ++r) + { + levels[r][0] = 0; + levels[r][1] = 0xFF << (r << 3); + levels[r][2] = 0xFF; + } +} + +// set color levels +void FilterLevel::setLevels (ColorLevel & lev) +{ + // copy levels + for (int r = 0; r < 4; ++r) + { + for (int c = 0; c < 2; ++c) + levels[r][c] = lev[r][c] << (r << 3); + levels[r][2] = lev[r][0] < lev[r][1] ? lev[r][1] - lev[r][0] : 1; + } +} + + +// cast Filter pointer to FilterLevel +inline FilterLevel * getFilterLevel (PyFilter * self) +{ return static_cast(self->m_filter); } + + +// python methods and get/sets + +// get color levels +static PyObject * getLevels (PyFilter * self, void * closure) +{ + ColorLevel & lev = getFilterLevel(self)->getLevels(); + return Py_BuildValue("((kk)(kk)(kk)(kk))", + lev[0][0], lev[0][1], lev[1][0] >> 8, lev[1][1] >> 8, + lev[2][0] >> 16, lev[2][1] >> 16, lev[3][0] >> 24, lev[3][1] >> 24); +} + +// set color levels +static int setLevels (PyFilter * self, PyObject * value, void * closure) +{ + // matrix to store items + ColorLevel lev; + // check validity of parameter + bool valid = value != NULL && PySequence_Check(value) + && PySequence_Length(value) == 4; + // check rows + for (int r = 0; valid && r < 4; ++r) + { + // get row object + PyObject * row = PySequence_Fast_GET_ITEM(value, r); + // check sequence + valid = PySequence_Check(row) && PySequence_Length(row) == 2; + // check items + for (int c = 0; valid && c < 2; ++c) + { + // item must be int + valid = PyInt_Check(PySequence_Fast_GET_ITEM(row, c)); + // if it is valid, save it in matrix + if (valid) + lev[r][c] = (unsigned long)(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c))); + } + } + // if parameter is not valid, report error + if (!valid) + { + PyErr_SetString(PyExc_TypeError, "The value must be a matrix [4][2] of ints"); + return -1; + } + // set color matrix + getFilterLevel(self)->setLevels(lev); + // success + return 0; +} + + +// attributes structure +static PyGetSetDef filterLevelGetSets[] = +{ + {"levels", (getter)getLevels, (setter)setLevels, "levels matrix [4] (min, max)", NULL}, + // attributes from FilterBase class + {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {NULL} +}; + +// define python type +PyTypeObject FilterLevelType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.FilterLevel", /*tp_name*/ + sizeof(PyFilter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Filter_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Filter for levels calculations", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + NULL, /* tp_methods */ + 0, /* tp_members */ + filterLevelGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Filter_init, /* tp_init */ + 0, /* tp_alloc */ + Filter_allocNew, /* tp_new */ +}; + diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h new file mode 100644 index 00000000000..4465df97340 --- /dev/null +++ b/source/gameengine/VideoTexture/FilterColor.h @@ -0,0 +1,164 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of blendTex library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined FILTERCOLOR_H +#define FILTERCOLOR_H + +#include "Common.h" + +#include "FilterBase.h" + + +/// pixel filter for gray scale +class FilterGray : public FilterBase +{ +public: + /// constructor + FilterGray (void) {} + /// destructor + virtual ~FilterGray (void) {} + +protected: + /// filter pixel template, source int buffer + template unsigned int tFilter (SRC src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + // calculate gray value + unsigned int gray = (28 * ((val >> 16) & 0xFF) + 151 * ((val >> 8) & 0xFF) + + 77 * (val & 0xFF)) & 0xFF00; + // return gray scale value + return (val & 0xFF000000) | gray << 8 | gray | gray >> 8; + } + + /// virtual filtering function for byte source + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } + /// virtual filtering function for unsigned int source + virtual unsigned int filter (unsigned int * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } +}; + + +/// type for color matrix +typedef short ColorMatrix[4][5]; + +/// pixel filter for color calculation +class FilterColor : public FilterBase +{ +public: + /// constructor + FilterColor (void); + /// destructor + virtual ~FilterColor (void) {} + + /// get color matrix + ColorMatrix & getMatrix (void) { return m_matrix; } + /// set color matrix + void setMatrix (ColorMatrix & mat); + +protected: + /// color calculation matrix + ColorMatrix m_matrix; + + /// calculate one color component + unsigned int calcColor (unsigned int val, short idx) + { + return (((m_matrix[idx][0] * (val & 0xFF) + m_matrix[idx][1] * ((val >> 8) & 0xFF) + + m_matrix[idx][2] * ((val >> 16) & 0xFF) + m_matrix[idx][3] * ((val >> 24) & 0xFF) + + m_matrix[idx][4]) >> 8) & 0xFF) << (idx << 3); + } + + /// filter pixel template, source int buffer + template unsigned int tFilter (SRC src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + // return calculated color + return calcColor(val, 0) | calcColor(val, 1) | calcColor(val, 2) + | calcColor(val, 3); + } + + /// virtual filtering function for byte source + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } + /// virtual filtering function for unsigned int source + virtual unsigned int filter (unsigned int * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } +}; + + +/// type for color levels +typedef unsigned long ColorLevel[4][3]; + +/// pixel filter for color calculation +class FilterLevel : public FilterBase +{ +public: + /// constructor + FilterLevel (void); + /// destructor + virtual ~FilterLevel (void) {} + + /// get color matrix + ColorLevel & getLevels (void) { return levels; } + /// set color matrix + void setLevels (ColorLevel & lev); + +protected: + /// color calculation matrix + ColorLevel levels; + + /// calculate one color component + unsigned int calcColor (unsigned int val, short idx) + { + unsigned int col = val & (0xFF << (idx << 3)); + if (col <= levels[idx][0]) col = 0; + else if (col >= levels[idx][1]) col = 0xFF << (idx << 3); + else if (idx < 3) col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & (0xFF << (idx << 3)); + else col = (((col - levels[idx][0]) / levels[idx][2]) << 8) & (0xFF << (idx << 3)); + return col; + } + + /// filter pixel template, source int buffer + template unsigned int tFilter (SRC src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + // return calculated color + return calcColor(val, 0) | calcColor(val, 1) | calcColor(val, 2) + | calcColor(val, 3); + } + + /// virtual filtering function for byte source + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } + /// virtual filtering function for unsigned int source + virtual unsigned int filter (unsigned int * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } +}; + + +#endif \ No newline at end of file diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp new file mode 100644 index 00000000000..5eeb63b7128 --- /dev/null +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -0,0 +1,162 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + + +#include +#include + +#include "FilterNormal.h" + +#include "FilterBase.h" +#include "PyTypeList.h" + +// implementation FilterNormal + +// constructor +FilterNormal::FilterNormal (void) : m_colShift(0) +{ + // set default depth + setDepth(4); +} + +// set color shift +void FilterNormal::setColor (unsigned short colIdx) +{ + // check validity of index + if (colIdx < 3) + // set color shift + m_colShift = colIdx << 3; +} + +// set depth +void FilterNormal::setDepth (float depth) +{ + m_depth = depth; + m_depthScale = depth / depthScaleKoef; +} + + +// cast Filter pointer to FilterNormal +inline FilterNormal * getFilter (PyFilter * self) +{ return static_cast(self->m_filter); } + + +// python methods and get/sets + +// get index of color used to calculate normal +static PyObject * getColor (PyFilter * self, void * closure) +{ + return Py_BuildValue("H", getFilter(self)->getColor()); +} + +// set index of color used to calculate normal +static int setColor (PyFilter * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PyInt_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a int"); + return -1; + } + // set color index + getFilter(self)->setColor((unsigned short)(PyInt_AsLong(value))); + // success + return 0; +} + + +// get depth +static PyObject * getDepth (PyFilter * self, void * closure) +{ + return Py_BuildValue("f", getFilter(self)->getDepth()); +} + +// set depth +static int setDepth (PyFilter * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PyFloat_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a float"); + return -1; + } + // set depth + getFilter(self)->setDepth(float(PyFloat_AsDouble(value))); + // success + return 0; +} + + +// attributes structure +static PyGetSetDef filterNormalGetSets[] = +{ + {"colorIdx", (getter)getColor, (setter)setColor, "index of color used to calculate normal (0 - red, 1 - green, 2 - blue)", NULL}, + {"depth", (getter)getDepth, (setter)setDepth, "depth of relief", NULL}, + // attributes from FilterBase class + {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {NULL} +}; + +// define python type +PyTypeObject FilterNormalType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.FilterNormal", /*tp_name*/ + sizeof(PyFilter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Filter_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Filter for Blue Screen objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + NULL, /* tp_methods */ + 0, /* tp_members */ + filterNormalGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Filter_init, /* tp_init */ + 0, /* tp_alloc */ + Filter_allocNew, /* tp_new */ +}; + diff --git a/source/gameengine/VideoTexture/FilterNormal.h b/source/gameengine/VideoTexture/FilterNormal.h new file mode 100644 index 00000000000..fa61f04c0b7 --- /dev/null +++ b/source/gameengine/VideoTexture/FilterNormal.h @@ -0,0 +1,98 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of blendTex library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined FILTERNORMAL_H +#define FILTERNORMAL_H + +#include "Common.h" + +#include "FilterBase.h" + + +// scale constants for normals +const float depthScaleKoef = 255.0; +const float normScaleKoef = float(depthScaleKoef / 2.0); + + +/// pixel filter for normal mapping +class FilterNormal : public FilterBase +{ +public: + /// constructor + FilterNormal (void); + /// destructor + virtual ~FilterNormal (void) {} + + /// get index of color used to calculate normals + unsigned short getColor (void) { return m_colShift >> 3; } + /// set index of color used to calculate normals + void setColor (unsigned short colIdx); + + /// get depth + float getDepth (void) { return m_depth; } + /// set depth + void setDepth (float depth); + +protected: + /// depth of normal relief + float m_depth; + /// scale to calculate normals + float m_depthScale; + + /// shift to used color component + unsigned short m_colShift; + + /// filter pixel, source int buffer + template unsigned int tFilter (SRC * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { + // get value of required color + int actPix = int((val >> m_colShift) & 0xFF); + // get upper and left pixel from actual pixel + int upPix = y > 0 ? int((convertPrevious(src - pixSize * size[0], x, y - 1, + size, pixSize) >> m_colShift) & 0xFF) : actPix; + int leftPix = x > 0 ? int((convertPrevious(src - pixSize, x - 1, y, size, pixSize) + >> m_colShift) & 0xFF) : actPix; + // height differences (from blue color) + float dx = (actPix - leftPix) * m_depthScale; + float dy = (actPix - upPix) * m_depthScale; + // normalize vector + float dz = float(normScaleKoef / sqrt(dx * dx + dy * dy + 1.0)); + dx = dx * dz + normScaleKoef; + dy = dy * dz + normScaleKoef; + dz += normScaleKoef; + // return normal vector converted to color + return 0xFF000000 | int(dz) << 16 | int(dy) << 8 | int(dx); + } + + /// filter pixel, source byte buffer + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } + /// filter pixel, source int buffer + virtual unsigned int filter (unsigned int * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return tFilter(src, x, y, size, pixSize, val); } +}; + + +#endif \ No newline at end of file diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp new file mode 100644 index 00000000000..4b96a9792e2 --- /dev/null +++ b/source/gameengine/VideoTexture/FilterSource.cpp @@ -0,0 +1,125 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +// implementation + +#include +#include + +#include "FilterSource.h" + +#include "FilterBase.h" +#include "PyTypeList.h" + + +// FilterRGB24 + +// define python type +PyTypeObject FilterRGB24Type = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.FilterRGB24", /*tp_name*/ + sizeof(PyFilter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Filter_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Source filter RGB24 objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + NULL, /* tp_methods */ + 0, /* tp_members */ + NULL, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Filter_init, /* tp_init */ + 0, /* tp_alloc */ + Filter_allocNew, /* tp_new */ +}; + +// FilterBGR24 + +// define python type +PyTypeObject FilterBGR24Type = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.FilterBGR24", /*tp_name*/ + sizeof(PyFilter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Filter_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Source filter BGR24 objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + NULL, /* tp_methods */ + 0, /* tp_members */ + NULL, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Filter_init, /* tp_init */ + 0, /* tp_alloc */ + Filter_allocNew, /* tp_new */ +}; + diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h new file mode 100644 index 00000000000..b18186210dc --- /dev/null +++ b/source/gameengine/VideoTexture/FilterSource.h @@ -0,0 +1,233 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of blendTex library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined FILTERSOURCE_H +#define FILTERSOURCE_H + +#include "Common.h" + +#include "FilterBase.h" + + +/// class for RGB24 conversion +class FilterRGB24 : public FilterBase +{ +public: + /// constructor + FilterRGB24 (void) {} + /// destructor + virtual ~FilterRGB24 (void) {} + + /// get source pixel size + virtual unsigned int getPixelSize (void) { return 3; } + +protected: + /// filter pixel, source byte buffer + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { return 0xFF000000 | src[0] << 16 | src[1] << 8 | src[2]; } +}; + + +/// class for BGR24 conversion +class FilterBGR24 : public FilterBase +{ +public: + /// constructor + FilterBGR24 (void) {} + /// destructor + virtual ~FilterBGR24 (void) {} + + /// get source pixel size + virtual unsigned int getPixelSize (void) { return 3; } + +protected: + /// filter pixel, source byte buffer + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { return 0xFF000000 | src[2] << 16 | src[1] << 8 | src[0]; } +}; + + +/// class for YV12 conversion +class FilterYV12 : public FilterBase +{ +public: + /// constructor + FilterYV12 (void) {} + /// destructor + virtual ~FilterYV12 (void) {} + + /// get source pixel size + virtual unsigned int getPixelSize (void) { return 1; } + + /// set pointers to color buffers + void setBuffs (unsigned char * buff, short * size) + { + unsigned int buffSize = size[0] * size[1]; + m_buffV = buff + buffSize; + m_buffU = m_buffV + (buffSize >> 2); + m_pitchUV = size[0] >> 1; + } + +protected: + /// begin of V buffer + unsigned char * m_buffV; + /// begin of U buffer + unsigned char * m_buffU; + /// pitch for V & U buffers + short m_pitchUV; + + /// interpolation function + int interpol (int a, int b, int c, int d) + { return (9 * (b + c) - a - d + 8) >> 4; } + + /// common horizontal interpolation + int interpolH (unsigned char * src) + { return interpol(*(src-1), *src, *(src+1), *(src+2)); } + + /// common vertical interpolation + int interpolV (unsigned char * src) + { return interpol(*(src-m_pitchUV), *src, *(src+m_pitchUV), *(src+2*m_pitchUV)); } + + /// common joined vertical and horizontal interpolation + int interpolVH (unsigned char * src) + { + return interpol(interpolV(src-1), interpolV(src), interpolV(src+1), + interpolV(src+2)); + } + + /// is pixel on edge + bool isEdge (short x, short y, short * size) + { return x <= 1 || x >= size[0] - 4 || y <= 1 || y >= size[1] - 4; } + + /// get the first parameter on the low edge + unsigned char * interParA (unsigned char * src, short x, short size, short shift) + { return x > 1 ? src - shift : src; } + /// get the third parameter on the high edge + unsigned char * interParC (unsigned char * src, short x, short size, short shift) + { return x < size - 2 ? src + shift : src; } + /// get the fourth parameter on the high edge + unsigned char * interParD (unsigned char * src, short x, short size, short shift) + { return x < size - 4 ? src + 2 * shift : x < size - 2 ? src + shift : src; } + + /// horizontal interpolation on edges + int interpolEH (unsigned char * src, short x, short size) + { + return interpol(*interParA(src, x, size, 1), *src, + *interParC(src, x, size, 1), *interParD(src, x, size, 1)); + } + + /// vertical interpolation on edges + int interpolEV (unsigned char * src, short y, short size) + { + return interpol(*interParA(src, y, size, m_pitchUV), *src, + *interParC(src, y, size, m_pitchUV), *interParD(src, y, size, m_pitchUV)); + } + + /// joined vertical and horizontal interpolation on edges + int interpolEVH (unsigned char * src, short x, short y, short * size) + { + return interpol(interpolEV(interParA(src, x, size[0], 1), y, size[1]), + interpolEV(src, y, size[1]), interpolEV(interParC(src, x, size[0], 1), y, size[1]), + interpolEV(interParD(src, x, size[0], 1), y, size[1])); + } + + + /// filter pixel, source byte buffer + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + // V & U offset + long offset = (x >> 1) + m_pitchUV * (y >> 1); + // get modified YUV -> CDE: C = Y - 16; D = U - 128; E = V - 128 + int c = *src - 16; + int d = m_buffU[offset] - 128; + int e = m_buffV[offset] - 128; + // if horizontal interpolation is needed + if ((x & 1) == 1) + // if vertical interpolation is needed too + if ((y & 1) == 1) + // if this pixel is on the edge + if (isEdge(x, y, size)) + { + // get U & V from edge + d = interpolEVH(m_buffU + offset, x, y, size) - 128; + e = interpolEVH(m_buffV + offset, x, y, size) - 128; + } + // otherwise get U & V from inner range + else + { + d = interpolVH(m_buffU + offset) - 128; + e = interpolVH(m_buffV + offset) - 128; + } + // otherwise use horizontal interpolation only + else + // if this pixel is on the edge + if (isEdge(x, y, size)) + { + // get U & V from edge + d = interpolEH(m_buffU + offset, x, size[0]) - 128; + e = interpolEH(m_buffV + offset, x, size[0]) - 128; + } + // otherwise get U & V from inner range + else + { + d = interpolH(m_buffU + offset) - 128; + e = interpolH(m_buffV + offset) - 128; + } + // otherwise if only vertical interpolation is needed + else if ((y & 1) == 1) + // if this pixel is on the edge + if (isEdge(x, y, size)) + { + // get U & V from edge + d = interpolEV(m_buffU + offset, y, size[1]) - 128; + e = interpolEV(m_buffV + offset, y, size[1]) - 128; + } + // otherwise get U & V from inner range + else + { + d = interpolV(m_buffU + offset) - 128; + e = interpolV(m_buffV + offset) - 128; + } + // convert to RGB + // R = clip(( 298 * C + 409 * E + 128) >> 8) + // G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8) + // B = clip(( 298 * C + 516 * D + 128) >> 8) + int red = (298 * c + 409 * e + 128) >> 8; + if (red >= 0x100) red = 0xFF; + else if (red < 0) red = 0; + int green = 298 * c - 100 * d - 208 * e; + if (green > 0x10000) green = 0xFF00; + else if (green < 0) green = 0; + int blue = (298 * c + 516 * d + 128) << 8; + if (blue > 0x1000000) blue = 0xFF0000; + else if (blue < 0) blue = 0; + // return result + return 0xFF000000 | blue & 0xFF0000 | green & 0xFF00 + | red & 0xFF; + } +}; + + +#endif \ No newline at end of file diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp new file mode 100644 index 00000000000..28e7ad49224 --- /dev/null +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -0,0 +1,529 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#include "ImageBase.h" + +#include +#include + +#include +#include + +#include "FilterBase.h" + +#include "Exception.h" + + + +// ImageBase class implementation + +// constructor +ImageBase::ImageBase (bool staticSrc) : m_image(NULL), m_imgSize(0), +m_avail(false), m_scale(false), m_scaleChange(false), m_flip(false), +m_staticSources(staticSrc), m_pyfilter(NULL) +{ + m_size[0] = m_size[1] = 0; +} + + +// destructor +ImageBase::~ImageBase (void) +{ + // release image + delete [] m_image; +} + + +// release python objects +bool ImageBase::release (void) +{ + // iterate sources + for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it) + { + // release source object + delete *it; + *it = NULL; + } + // release filter object + Py_XDECREF(m_pyfilter); + m_pyfilter = NULL; + return true; +} + + +// get image +unsigned int * ImageBase::getImage (unsigned int texId) +{ + // if image is not available + if (!m_avail) + { + // if there are any sources + if (!m_sources.empty()) + { + // get images from sources + for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it) + // get source image + (*it)->getImage(); + // init image + init(m_sources[0]->getSize()[0], m_sources[0]->getSize()[1]); + } + // calculate new image + calcImage(texId); + } + // if image is available, return it, otherwise NULL + return m_avail ? m_image : NULL; +} + + +// refresh image source +void ImageBase::refresh (void) +{ + // invalidate this image + m_avail = false; + // refresh all sources + for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it) + (*it)->refresh(); +} + + +// get source object +PyImage * ImageBase::getSource (const char * id) +{ + // find source + ImageSourceList::iterator src = findSource(id); + // return it, if found + return src != m_sources.end() ? (*src)->getSource() : NULL; +} + + +// set source object +bool ImageBase::setSource (const char * id, PyImage * source) +{ + // find source + ImageSourceList::iterator src = findSource(id); + // check source loop + if (source != NULL && source->m_image->loopDetect(this)) + return false; + // if found, set new object + if (src != m_sources.end()) + // if new object is not empty or sources are static + if (source != NULL || m_staticSources) + // replace previous source + (*src)->setSource(source); + // otherwise delete source + else + m_sources.erase(src); + // if source is not found and adding is allowed + else + if (!m_staticSources) + { + // create new source + ImageSource * newSrc = newSource(id); + newSrc->setSource(source); + // if source was created, add it to source list + if (newSrc != NULL) m_sources.push_back(newSrc); + } + // otherwise source wasn't set + else + return false; + // source was set + return true; +} + + +// set pixel filter +void ImageBase::setFilter (PyFilter * filt) +{ + // reference new filter + if (filt != NULL) Py_INCREF(filt); + // release previous filter + Py_XDECREF(m_pyfilter); + // set new filter + m_pyfilter = filt; +} + + +// initialize image data +void ImageBase::init (short width, short height) +{ + // if image has to be scaled + if (m_scale) + { + // recalc sizes of image + width = calcSize(width); + height = calcSize(height); + } + // if sizes differ + if (width != m_size[0] || height != m_size[1]) + { + // new buffer size + unsigned int newSize = width * height; + // if new buffer is larger than previous + if (newSize > m_imgSize) + { + // set new buffer size + m_imgSize = newSize; + // release previous and create new buffer + delete [] m_image; + m_image = new unsigned int[m_imgSize]; + } + // new image size + m_size[0] = width; + m_size[1] = height; + // scale was processed + m_scaleChange = false; + } +} + + +// find source +ImageSourceList::iterator ImageBase::findSource (const char * id) +{ + // iterate sources + ImageSourceList::iterator it; + for (it = m_sources.begin(); it != m_sources.end(); ++it) + // if id matches, return iterator + if ((*it)->is(id)) return it; + // source not found + return it; +} + + +// check sources sizes +bool ImageBase::checkSourceSizes (void) +{ + // reference size + short * refSize = NULL; + // iterate sources + for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it) + { + // get size of current source + short * curSize = (*it)->getSize(); + // if size is available and is not empty + if (curSize[0] != 0 && curSize[1] != 0) + // if reference size is not set + if (refSize == NULL) + // set current size as reference + refSize = curSize; + // otherwise check with current size + else if (curSize[0] != refSize[0] || curSize[1] != refSize[1]) + // if they don't match, report it + return false; + } + // all sizes match + return true; +} + + +// compute nearest power of 2 value +short ImageBase::calcSize (short size) +{ + // while there is more than 1 bit in size value + while ((size & (size - 1)) != 0) + // clear last bit + size = size & (size - 1); + // return result + return size; +} + + +// perform loop detection +bool ImageBase::loopDetect (ImageBase * img) +{ + // if this object is the same as parameter, loop is detected + if (this == img) return true; + // check all sources + for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it) + // if source detected loop, return this result + if ((*it)->getSource() != NULL && (*it)->getSource()->m_image->loopDetect(img)) + return true; + // no loop detected + return false; +} + + +// ImageSource class implementation + +// constructor +ImageSource::ImageSource (const char * id) : m_source(NULL), m_image(NULL) +{ + // copy id + int idx; + for (idx = 0; id[idx] != '\0' && idx < SourceIdSize - 1; ++idx) + m_id[idx] = id[idx]; + m_id[idx] = '\0'; +} + +// destructor +ImageSource::~ImageSource (void) +{ + // release source + setSource(NULL); +} + + +// compare id +bool ImageSource::is (const char * id) +{ + for (char * myId = m_id; *myId != '\0'; ++myId, ++id) + if (*myId != *id) return false; + return *id == '\0'; +} + + +// set source object +void ImageSource::setSource (PyImage * source) +{ + // reference new source + if (source != NULL) Py_INCREF(source); + // release previous source + Py_XDECREF(m_source); + // set new source + m_source = source; +} + + +// get image from source +unsigned int * ImageSource::getImage (void) +{ + // if source is available + if (m_source != NULL) + // get image from source + m_image = m_source->m_image->getImage(); + // otherwise reset buffer + else + m_image = NULL; + // return image + return m_image; +} + + +// refresh source +void ImageSource::refresh (void) +{ + // if source is available, refresh it + if (m_source != NULL) m_source->m_image->refresh(); +} + + + +// list of image types +PyTypeList pyImageTypes; + + + +// functions for python interface + +// object allocation +PyObject * Image_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds) +{ + // allocate object + PyImage * self = reinterpret_cast(type->tp_alloc(type, 0)); + // initialize object structure + self->m_image = NULL; + // return allocated object + return reinterpret_cast(self); +} + +// object deallocation +void Image_dealloc (PyImage * self) +{ + // release object attributes + if (self->m_image != NULL) + { + // if release requires deleting of object, do it + if (self->m_image->release()) + delete self->m_image; + self->m_image = NULL; + } +} + +// get image data +PyObject * Image_getImage (PyImage * self, void * closure) +{ + try + { + // get image + unsigned int * image = self->m_image->getImage(); + return Py_BuildValue("s#", image, self->m_image->getBuffSize()); + } + catch (Exception & exp) + { + exp.report(); + } + Py_RETURN_NONE; +} + +// get image size +PyObject * Image_getSize (PyImage * self, void * closure) +{ + return Py_BuildValue("(hh)", self->m_image->getSize()[0], + self->m_image->getSize()[1]); +} + +// refresh image +PyObject * Image_refresh (PyImage * self) +{ + self->m_image->refresh(); + Py_RETURN_NONE; +} + +// get scale +PyObject * Image_getScale (PyImage * self, void * closure) +{ + if (self->m_image != NULL && self->m_image->getScale()) Py_RETURN_TRUE; + else Py_RETURN_FALSE; +} + +// set scale +int Image_setScale (PyImage * self, PyObject * value, void * closure) +{ + // check parameter, report failure + if (value == NULL || !PyBool_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a bool"); + return -1; + } + // set scale + if (self->m_image != NULL) self->m_image->setScale(value == Py_True); + // success + return 0; +} + +// get flip +PyObject * Image_getFlip (PyImage * self, void * closure) +{ + if (self->m_image != NULL && self->m_image->getFlip()) Py_RETURN_TRUE; + else Py_RETURN_FALSE; +} + +// set flip +int Image_setFlip (PyImage * self, PyObject * value, void * closure) +{ + // check parameter, report failure + if (value == NULL || !PyBool_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a bool"); + return -1; + } + // set scale + if (self->m_image != NULL) self->m_image->setFlip(value == Py_True); + // success + return 0; +} + + +// get filter source object +PyObject * Image_getSource (PyImage * self, PyObject * args) +{ + // get arguments + char * id; + if (self->m_image != NULL && PyArg_ParseTuple(args, "s", &id)) + { + // get source object + PyObject * src = reinterpret_cast(self->m_image->getSource(id)); + // if source is available + if (src != NULL) + { + // return source + Py_INCREF(src); + return src; + } + } + // source was not found + Py_RETURN_NONE; +} + + +// set filter source object +PyObject * Image_setSource (PyImage * self, PyObject * args) +{ + // get arguments + char * id; + PyObject * obj; + if (self->m_image != NULL && PyArg_ParseTuple(args, "sO", &id, &obj)) + { + // check type of object + if (pyImageTypes.in(obj->ob_type)) + { + // convert to image struct + PyImage * img = reinterpret_cast(obj); + // set source + if (!self->m_image->setSource(id, img)) + { + // if not set, retport error + PyErr_SetString(PyExc_RuntimeError, "Invalid source or id"); + return NULL; + } + } + // else report error + else + { + PyErr_SetString(PyExc_RuntimeError, "Invalid type of object"); + return NULL; + } + } + // return none + Py_RETURN_NONE; +} + + +// get pixel filter object +PyObject * Image_getFilter (PyImage * self, void * closure) +{ + // if image object is available + if (self->m_image != NULL) + { + // pixel filter object + PyObject * filt = reinterpret_cast(self->m_image->getFilter()); + // if filter is present + if (filt != NULL) + { + // return it + Py_INCREF(filt); + return filt; + } + } + // otherwise return none + Py_RETURN_NONE; +} + + +// set pixel filter object +int Image_setFilter (PyImage * self, PyObject * value, void * closure) +{ + // if image object is available + if (self->m_image != NULL) + { + // check new value + if (value == NULL || !pyFilterTypes.in(value->ob_type)) + { + // report value error + PyErr_SetString(PyExc_TypeError, "Invalid type of value"); + return -1; + } + // set new value + self->m_image->setFilter(reinterpret_cast(value)); + } + // return success + return 0; +} \ No newline at end of file diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h new file mode 100644 index 00000000000..817223c3d31 --- /dev/null +++ b/source/gameengine/VideoTexture/ImageBase.h @@ -0,0 +1,349 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of blendTex library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined IMAGEBASE_H +#define IMAGEBASE_H + +#include "Common.h" + +#include +#include + +#include "PyTypeList.h" + +#include "FilterBase.h" + + +// forward declarations +struct PyImage; +class ImageSource; + + +/// type for list of image sources +typedef std::vector ImageSourceList; + + +/// base class for image filters +class ImageBase +{ +public: + /// constructor + ImageBase (bool staticSrc = false); + /// destructor + virtual ~ImageBase (void); + /// release contained objects, if returns true, object should be deleted + virtual bool release (void); + + /// get image + unsigned int * getImage (unsigned int texId = 0); + /// get image size + short * getSize (void) { return m_size; } + /// get image buffer size + unsigned long getBuffSize (void) + { return m_size[0] * m_size[1] * sizeof(unsigned int); } + /// refresh image - invalidate its current content + virtual void refresh (void); + + /// get scale + bool getScale (void) { return m_scale; } + /// set scale + void setScale (bool scale) { m_scale = scale; m_scaleChange = true; } + /// get vertical flip + bool getFlip (void) { return m_flip; } + /// set vertical flip + void setFlip (bool flip) { m_flip = flip; } + + /// get source object + PyImage * getSource (const char * id); + /// set source object, return true, if source was set + bool setSource (const char * id, PyImage * source); + + /// get pixel filter + PyFilter * getFilter (void) { return m_pyfilter; } + /// set pixel filter + void setFilter (PyFilter * filt); + + /// calculate size (nearest power of 2) + static short calcSize (short size); + +protected: + /// image buffer + unsigned int * m_image; + /// image buffer size + unsigned int m_imgSize; + /// image size + short m_size[2]; + /// image is available + bool m_avail; + + /// scale image to power 2 sizes + bool m_scale; + /// scale was changed + bool m_scaleChange; + /// flip image vertically + bool m_flip; + + /// source image list + ImageSourceList m_sources; + /// flag for disabling addition and deletion of sources + bool m_staticSources; + + /// pixel filter + PyFilter * m_pyfilter; + + /// initialize image data + void init (short width, short height); + + /// find source + ImageSourceList::iterator findSource (const char * id); + + /// create new source + virtual ImageSource * newSource (const char * id) { return NULL; } + + /// check source sizes + bool checkSourceSizes (void); + + /// calculate image from sources and set its availability + virtual void calcImage (unsigned int texId) {} + + /// perform loop detection + bool loopDetect (ImageBase * img); + + /// template for image conversion + template void convImage (FLT & filter, SRC srcBuff, + short * srcSize) + { + // destination buffer + unsigned int * dstBuff = m_image; + // pixel size from filter + unsigned int pixSize = filter.firstPixelSize(); + // if no scaling is needed + if (srcSize[0] == m_size[0] && srcSize[1] == m_size[1]) + // if flipping isn't required + if (!m_flip) + // copy bitmap + for (short y = 0; y < m_size[1]; ++y) + for (short x = 0; x < m_size[0]; ++x, ++dstBuff, srcBuff += pixSize) + // copy pixel + *dstBuff = filter.convert(srcBuff, x, y, srcSize, pixSize); + // otherwise flip image top to bottom + else + { + // go to last row of image + srcBuff += srcSize[0] * (srcSize[1] - 1) * pixSize; + // copy bitmap + for (short y = m_size[1] - 1; y >= 0; --y, srcBuff -= 2 * srcSize[0] * pixSize) + for (short x = 0; x < m_size[0]; ++x, ++dstBuff, srcBuff += pixSize) + // copy pixel + *dstBuff = filter.convert(srcBuff, x, y, srcSize, pixSize); + } + // else scale picture (nearest neighbour) + else + { + // interpolation accumulator + int accHeight = srcSize[1] >> 1; + // if flipping is required + if (m_flip) + // go to last row of image + srcBuff += srcSize[0] * (srcSize[1] - 1) * pixSize; + // process image rows + for (int y = 0; y < srcSize[1]; ++y) + { + // increase height accum + accHeight += m_size[1]; + // if pixel row has to be drawn + if (accHeight >= srcSize[1]) + { + // decrease accum + accHeight -= srcSize[1]; + // width accum + int accWidth = srcSize[0] >> 1; + // process row + for (int x = 0; x < srcSize[0]; ++x) + { + // increase width accum + accWidth += m_size[0]; + // if pixel has to be drawn + if (accWidth >= srcSize[0]) + { + // decrease accum + accWidth -= srcSize[0]; + // convert pixel + *dstBuff = filter.convert(srcBuff, x, m_flip ? srcSize[1] - y - 1 : y, + srcSize, pixSize); + // next pixel + ++dstBuff; + } + // shift source pointer + srcBuff += pixSize; + } + } + // if pixel row will not be drawn + else + // move source pointer to next row + srcBuff += pixSize * srcSize[0]; + // if y flipping is required + if (m_flip) + // go to previous row of image + srcBuff -= 2 * pixSize * srcSize[0]; + } + } + } + + // template for specific filter preprocessing + template void filterImage (F & filt, SRC srcBuff, short * srcSize) + { + // find first filter in chain + FilterBase * firstFilter = NULL; + if (m_pyfilter != NULL) firstFilter = m_pyfilter->m_filter->findFirst(); + // if first filter is available + if (firstFilter != NULL) + { + // python wrapper for filter + PyFilter pyFilt; + pyFilt.m_filter = &filt; + // set specified filter as first in chain + firstFilter->setPrevious(&pyFilt, false); + // convert video image + convImage(*(m_pyfilter->m_filter), srcBuff, srcSize); + // delete added filter + firstFilter->setPrevious(NULL, false); + } + // otherwise use given filter for conversion + else convImage(filt, srcBuff, srcSize); + // source was processed + m_avail = true; + } +}; + + +// python structure for image filter +struct PyImage +{ + PyObject_HEAD + // source object + ImageBase * m_image; +}; + + +// size of id +const int SourceIdSize = 32; + + +/// class for source of image +class ImageSource +{ +public: + /// constructor + ImageSource (const char * id); + /// destructor + virtual ~ImageSource (void); + + /// get id + const char * getId (void) { return m_id; } + /// compare id to argument + bool is (const char * id); + + /// get source object + PyImage * getSource (void) { return m_source; } + /// set source object + void setSource (PyImage * source); + + /// get image from source + unsigned int * getImage (void); + /// get buffered image + unsigned int * getImageBuf (void) { return m_image; } + /// refresh source + void refresh (void); + + /// get image size + short * getSize (void) + { + static short defSize [] = {0, 0}; + return m_source != NULL ? m_source->m_image->getSize() : defSize; + } + +protected: + /// id of source + char m_id [SourceIdSize]; + /// pointer to source structure + PyImage * m_source; + /// buffered image from source + unsigned int * m_image; + +private: + /// default constructor is forbidden + ImageSource (void) {} +}; + + + +// list of python image types +extern PyTypeList pyImageTypes; + + +// functions for python interface + +// object initialization +template static int Image_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +{ + PyImage * self = reinterpret_cast(pySelf); + // create source object + if (self->m_image != NULL) delete self->m_image; + self->m_image = new T(); + // initialization succeded + return 0; +} + +// object allocation +PyObject * Image_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds); +// object deallocation +void Image_dealloc (PyImage * self); + +// get image data +PyObject * Image_getImage (PyImage * self, void * closure); +// get image size +PyObject * Image_getSize (PyImage * self, void * closure); +// refresh image - invalidate current content +PyObject * Image_refresh (PyImage * self); + +// get scale +PyObject * Image_getScale (PyImage * self, void * closure); +// set scale +int Image_setScale (PyImage * self, PyObject * value, void * closure); +// get flip +PyObject * Image_getFlip (PyImage * self, void * closure); +// set flip +int Image_setFlip (PyImage * self, PyObject * value, void * closure); + +// get filter source object +PyObject * Image_getSource (PyImage * self, PyObject * args); +// set filter source object +PyObject * Image_setSource (PyImage * self, PyObject * args); + +// get pixel filter object +PyObject * Image_getFilter (PyImage * self, void * closure); +// set pixel filter object +int Image_setFilter (PyImage * self, PyObject * value, void * closure); + + +#endif \ No newline at end of file diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp new file mode 100644 index 00000000000..f09514a36f0 --- /dev/null +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -0,0 +1,166 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +// implementation + +#include +#include + +#include "ImageBuff.h" + +#include "ImageBase.h" +#include "FilterSource.h" + + +// default filter +FilterBGR24 defFilter; + + +// load image from buffer +void ImageBuff::load (unsigned char * img, short width, short height) +{ + // initialize image buffer + init(width, height); + // original size + short orgSize[2] = {width, height}; + // is filter available + if (m_pyfilter != NULL) + // use it to process image + convImage(*(m_pyfilter->m_filter), img, orgSize); + else + // otherwise use default filter + convImage(defFilter, img, orgSize); + // image is available + m_avail = true; +} + + + +// cast Image pointer to ImageBuff +inline ImageBuff * getImageBuff (PyImage * self) +{ return static_cast(self->m_image); } + + +// python methods + +// load image +static PyObject * load (PyImage * self, PyObject * args) +{ + // parameters: string image buffer, its size, width, height + unsigned char * buff; + unsigned int buffSize; + short width; + short height; + // parse parameters + if (!PyArg_ParseTuple(args, "s#hh", &buff, &buffSize, &width, &height)) + { + // report error + PyErr_SetString(PyExc_TypeError, "Parameters are not correct"); + return NULL; + } + // else check buffer size + else + { + // calc proper buffer size + unsigned int propSize = width * height; + // use pixel size from filter + if (self->m_image->getFilter() != NULL) + propSize *= self->m_image->getFilter()->m_filter->firstPixelSize(); + else + propSize *= defFilter.firstPixelSize(); + // check if buffer size is correct + if (propSize != buffSize) + { + // if not, report error + PyErr_SetString(PyExc_TypeError, "Buffer hasn't correct size"); + return NULL; + } + else + // if correct, load image + getImageBuff(self)->load(buff, width, height); + } + Py_RETURN_NONE; +} + + +// methods structure +static PyMethodDef imageBuffMethods[] = +{ + {"load", (PyCFunction)load, METH_VARARGS, "Load image from buffer"}, + {NULL} +}; +// attributes structure +static PyGetSetDef imageBuffGetSets[] = +{ // attributes from ImageBase class + {"image", (getter)Image_getImage, NULL, "image data", NULL}, + {"size", (getter)Image_getSize, NULL, "image size", NULL}, + {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, + {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, + {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {NULL} +}; + + +// define python type +PyTypeObject ImageBuffType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.ImageBuff", /*tp_name*/ + sizeof(PyImage), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Image_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Image source from image buffer", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + imageBuffMethods, /* tp_methods */ + 0, /* tp_members */ + imageBuffGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Image_init, /* tp_init */ + 0, /* tp_alloc */ + Image_allocNew, /* tp_new */ +}; + diff --git a/source/gameengine/VideoTexture/ImageBuff.h b/source/gameengine/VideoTexture/ImageBuff.h new file mode 100644 index 00000000000..fa2025fa8c4 --- /dev/null +++ b/source/gameengine/VideoTexture/ImageBuff.h @@ -0,0 +1,51 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined IMAGEBUFF_H +#define IMAGEBUFF_H + + +#include "Common.h" + +#include "ImageBase.h" + + +/// class for image buffer +class ImageBuff : public ImageBase +{ +public: + /// constructor + ImageBuff (void) : ImageBase(true) {} + + /// destructor + virtual ~ImageBuff (void) {} + + /// load image from buffer + void load (unsigned char * img, short width, short height); + + /// refresh image - do nothing + virtual void refresh (void) {} +}; + + +#endif + diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp new file mode 100644 index 00000000000..56503066161 --- /dev/null +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -0,0 +1,205 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +// implementation + +#include +#include + +#include "ImageMix.h" + +#include "ImageBase.h" + +#include "Exception.h" + + +// cast ImageSource pointer to ImageSourceMix +inline ImageSourceMix * getImageSourceMix (ImageSource * src) +{ return static_cast(src); } + + +// get weight +short ImageMix::getWeight (const char * id) +{ + // find source + ImageSourceList::iterator src = findSource(id); + // if found, return its weight + return src != m_sources.end() ? getImageSourceMix(*src)->getWeight() : 0; +} + +// set weight +bool ImageMix::setWeight (const char * id, short weight) +{ + // find source + ImageSourceList::iterator src = findSource(id); + // if source isn't found, report it + if (src == m_sources.end()) return false; + // set its weight + getImageSourceMix(*src)->setWeight(weight); + return true; +} + +static ExceptionID ImageSizesNotMatch; + +static ExpDesc ImageSizesNotMatchDesc (ImageSizesNotMatch, "Image sizes of sources are different"); + +// calculate image from sources and set its availability +void ImageMix::calcImage (unsigned int texId) +{ + // check source sizes + if (!checkSourceSizes()) THRWEXCP(ImageSizesNotMatch, S_OK); + // set offsets to image buffers + for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it) + // if image buffer is available + if ((*it)->getImageBuf() != NULL) + // set its offset + getImageSourceMix(*it)->setOffset(m_sources[0]->getImageBuf()); + // otherwise don't calculate image + else + return; + // if there is only single source + if (m_sources.size() == 1) + { + // use single filter + FilterBase mixFilt; + // fiter and convert image + filterImage(mixFilt, m_sources[0]->getImageBuf(), m_sources[0]->getSize()); + } + // otherwise use mix filter to merge source images + else + { + FilterImageMix mixFilt (m_sources); + // fiter and convert image + filterImage(mixFilt, m_sources[0]->getImageBuf(), m_sources[0]->getSize()); + } +} + + + +// cast Image pointer to ImageMix +inline ImageMix * getImageMix (PyImage * self) +{ return static_cast(self->m_image); } + + +// python methods + +// get source weight +PyObject * getWeight (PyImage * self, PyObject * args) +{ + // weight + short weight = 0; + // get arguments + char * id; + if (self->m_image != NULL && PyArg_ParseTuple(args, "s", &id)) + // get weight + weight = getImageMix(self)->getWeight(id); + // return weight + return Py_BuildValue("h", weight); +} + + +// set source weight +PyObject * setWeight (PyImage * self, PyObject * args) +{ + // get arguments + char * id; + short weight = 0; + if (self->m_image != NULL && PyArg_ParseTuple(args, "sh", &id, &weight)) + // set weight + if (!getImageMix(self)->setWeight(id, weight)) + { + // if not set, report error + PyErr_SetString(PyExc_RuntimeError, "Invalid id of source");; + return NULL; + } + // return none + Py_RETURN_NONE; +} + + +// methods structure +static PyMethodDef imageMixMethods[] = +{ + {"getSource", (PyCFunction)Image_getSource, METH_VARARGS, "get image source"}, + {"setSource", (PyCFunction)Image_setSource, METH_VARARGS, "set image source"}, + {"getWeight", (PyCFunction)getWeight, METH_VARARGS, "get image source weight"}, + {"setWeight", (PyCFunction)setWeight, METH_VARARGS, "set image source weight"}, + // methods from ImageBase class + {"refresh", (PyCFunction)Image_refresh, METH_NOARGS, "Refresh image - invalidate its current content"}, + {NULL} +}; +// attributes structure +static PyGetSetDef imageMixGetSets[] = +{ // attributes from ImageBase class + {"image", (getter)Image_getImage, NULL, "image data", NULL}, + {"size", (getter)Image_getSize, NULL, "image size", NULL}, + {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, + {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, + {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {NULL} +}; + + +// define python type +PyTypeObject ImageMixType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.ImageMix", /*tp_name*/ + sizeof(PyImage), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Image_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Image mixer", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + imageMixMethods, /* tp_methods */ + 0, /* tp_members */ + imageMixGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Image_init, /* tp_init */ + 0, /* tp_alloc */ + Image_allocNew, /* tp_new */ +}; + diff --git a/source/gameengine/VideoTexture/ImageMix.h b/source/gameengine/VideoTexture/ImageMix.h new file mode 100644 index 00000000000..b4842bd6b40 --- /dev/null +++ b/source/gameengine/VideoTexture/ImageMix.h @@ -0,0 +1,123 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined IMAGEMIX_H +#define IMAGEMIX_H + + +#include "Common.h" + +#include "ImageBase.h" +#include "FilterBase.h" + + +/// class for source mixing +class ImageSourceMix : public ImageSource +{ +public: + /// constructor + ImageSourceMix (const char * id) : ImageSource(id), m_weight(0x100) {} + /// destructor + virtual ~ImageSourceMix (void) {} + + /// get offset + long long getOffset (void) { return m_offset; } + /// set offset + void setOffset (unsigned int * firstImg) { m_offset = m_image - firstImg; } + + /// get weight + short getWeight (void) { return m_weight; } + /// set weight + void setWeight (short weight) { m_weight = weight; } + +protected: + /// buffer offset to the first source buffer + long long m_offset; + /// source weight + short m_weight; +}; + + +/// class for image mixer +class ImageMix : public ImageBase +{ +public: + /// constructor + ImageMix (void) : ImageBase(false) {} + + /// destructor + virtual ~ImageMix (void) {} + + /// get weight + short getWeight (const char * id); + /// set weight + bool setWeight (const char * id, short weight); + +protected: + + /// create new source + virtual ImageSource * newSource (const char * id) { return new ImageSourceMix(id); } + + /// calculate image from sources and set its availability + virtual void calcImage (unsigned int texId); +}; + + +/// pixel filter for image mixer +class FilterImageMix : public FilterBase +{ +public: + /// constructor + FilterImageMix (ImageSourceList & sources) : m_sources(sources) {} + /// destructor + virtual ~FilterImageMix (void) {} + +protected: + /// source list + ImageSourceList & m_sources; + + /// filter pixel, source int buffer + virtual unsigned int filter (unsigned int * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { + // resulting pixel color + int color[] = {0, 0, 0, 0}; + // iterate sources + for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it) + { + // get pointer to mixer source + ImageSourceMix * mixSrc = static_cast(*it); + // add weighted source pixel to result + color[0] += mixSrc->getWeight() * (src[mixSrc->getOffset()] & 0xFF); + color[1] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 8) & 0xFF); + color[2] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 16) & 0xFF); + color[3] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 24) & 0xFF); + } + // return resulting color + return ((color[0] >> 8) & 0xFF) | (color[1] & 0xFF00) + | ((color[2] << 8) & 0xFF0000) | ((color[3] << 16) & 0xFF000000); + } +}; + + +#endif + diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp new file mode 100644 index 00000000000..c800b92e71d --- /dev/null +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -0,0 +1,261 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +// implementation + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "ImageRender.h" + +#include "ImageBase.h" +#include "BlendType.h" +#include "Exception.h" + + +// constructor +ImageRender::ImageRender (KX_Scene * scene, KX_Camera * camera) : m_scene(scene), +m_camera(camera) +{ + // create screen area + m_area.winrct.xmin = m_upLeft[0]; + m_area.winrct.ymin = m_upLeft[1]; + m_area.winx = m_size[0]; + m_area.winy = m_size[1]; + // create canvas + m_canvas = new KX_BlenderCanvas(&m_area); + // create render tools + m_rendertools = new KX_BlenderRenderTools(); + // create rasterizer + m_rasterizer = new RAS_OpenGLRasterizer(m_canvas); + m_rasterizer->Init(); + // initialize background colour + setBackground(0, 0, 255); + // refresh lights + refreshLights(); +} + +// destructor +ImageRender::~ImageRender (void) +{ + // release allocated objects + delete m_rasterizer; + delete m_rendertools; + delete m_canvas; +} + + +// set background color +void ImageRender::setBackground (unsigned char red, unsigned char green, unsigned char blue) +{ + m_background[0] = red; + m_background[1] = green; + m_background[2] = blue; + m_rasterizer->SetBackColor(m_background[0], m_background[1], m_background[2], 1.0); +} + + +// capture image from viewport +void ImageRender::calcImage (unsigned int texId) +{ + // setup camera + bool cameraPasive = !m_camera->GetViewport(); + // render scene + Render(); + // reset camera + if (cameraPasive) m_camera->EnableViewport(false); + // get image from viewport + ImageViewport::calcImage(texId); +} + + +// refresh lights +void ImageRender::refreshLights (void) +{ + // clear lights list + //m_rendertools->RemoveAllLights(); + // set lights + //for (int idx = 0; idx < scene->GetLightList()->GetCount(); ++idx) + // m_rendertools->AddLight(((KX_LightObject*)(scene->GetLightList()->GetValue(idx)))->GetLightData()); +} + + + +// cast Image pointer to ImageRender +inline ImageRender * getImageRender (PyImage * self) +{ return static_cast(self->m_image); } + + +// python methods + +// Blender Scene type +BlendType sceneType ("KX_Scene"); +// Blender Camera type +BlendType cameraType ("KX_Camera"); + + +static ExceptionID SceneInvalid, CameraInvalid; +static ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid"); +static ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid"); + +// object initialization +static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +{ + // parameters - scene object + PyObject * scene; + // camera object + PyObject * camera; + // parameter keywords + static char *kwlist[] = {"sceneObj", "cameraObj", NULL}; + // get parameters + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &scene, &camera)) + return -1; + try + { + // get scene pointer + KX_Scene * scenePtr (NULL); + if (scene != NULL) scenePtr = sceneType.checkType(scene); + // throw exception if scene is not available + if (scenePtr == NULL) THRWEXCP(SceneInvalid, S_OK); + + // get camera pointer + KX_Camera * cameraPtr (NULL); + if (camera != NULL) cameraPtr = cameraType.checkType(camera); + // throw exception if camera is not available + if (cameraPtr == NULL) THRWEXCP(CameraInvalid, S_OK); + + // get pointer to image structure + PyImage * self = reinterpret_cast(pySelf); + // create source object + if (self->m_image != NULL) delete self->m_image; + self->m_image = new ImageRender(scenePtr, cameraPtr); + } + catch (Exception & exp) + { + exp.report(); + return -1; + } + // initialization succeded + return 0; +} + + +// get background color +PyObject * getBackground (PyImage * self, void * closure) +{ + return Py_BuildValue("[BBB]", getImageRender(self)->getBackground()[0], + getImageRender(self)->getBackground()[1], getImageRender(self)->getBackground()[2]); +} + +// set color +static int setBackground (PyImage * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 3 + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0)) + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)) + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 2))) + { + PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 3 ints"); + return -1; + } + // set background color + getImageRender(self)->setBackground((unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))), + (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))), + (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2)))); + // success + return 0; +} + + +// methods structure +static PyMethodDef imageRenderMethods[] = +{ // methods from ImageBase class + {"refresh", (PyCFunction)Image_refresh, METH_NOARGS, "Refresh image - invalidate its current content"}, + {NULL} +}; +// attributes structure +static PyGetSetDef imageRenderGetSets[] = +{ + {"background", (getter)getBackground, (setter)setBackground, "background color", NULL}, + // attributes from ImageBase class + {"image", (getter)Image_getImage, NULL, "image data", NULL}, + {"size", (getter)Image_getSize, NULL, "image size", NULL}, + {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, + {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, + {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {NULL} +}; + + +// define python type +PyTypeObject ImageRenderType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.ImageRender", /*tp_name*/ + sizeof(PyImage), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Image_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Image source from render", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + imageRenderMethods, /* tp_methods */ + 0, /* tp_members */ + imageRenderGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ImageRender_init, /* tp_init */ + 0, /* tp_alloc */ + Image_allocNew, /* tp_new */ +}; + + diff --git a/source/gameengine/VideoTexture/ImageRender.h b/source/gameengine/VideoTexture/ImageRender.h new file mode 100644 index 00000000000..66255f04d2c --- /dev/null +++ b/source/gameengine/VideoTexture/ImageRender.h @@ -0,0 +1,90 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined IMAGERENDER_H +#define IMAGERENDER_H + + +#include "Common.h" + +#include +#include +#include +#include +#include +#include + +#include "ImageViewport.h" + + +/// class for render 3d scene +class ImageRender : public ImageViewport +{ +public: + /// constructor + ImageRender (KX_Scene * scene, KX_Camera * camera); + + /// destructor + virtual ~ImageRender (void); + + /// get background color + unsigned char * getBackground (void) { return m_background; } + /// set background color + void setBackground (unsigned char red, unsigned char green, unsigned char blue); + +protected: + /// rendered scene + KX_Scene * m_scene; + /// camera for render + KX_Camera * m_camera; + + /// screen area for rendering + ScrArea m_area; + /// rendering device + RAS_ICanvas * m_canvas; + /// rasterizer + RAS_IRasterizer * m_rasterizer; + /// render tools + RAS_IRenderTools * m_rendertools; + + /// background colour + unsigned char m_background[3]; + + + /// render 3d scene to image + virtual void calcImage (unsigned int texId); + + /// refresh lights + void refreshLights (void); + /// methods from KX_KetsjiEngine + bool BeginFrame(); + void EndFrame(); + void Render(); + void SetupRenderFrame(KX_Scene *scene, KX_Camera* cam); + void RenderFrame(KX_Scene* scene, KX_Camera* cam); + void SetBackGround(KX_WorldInfo* wi); + void SetWorldSettings(KX_WorldInfo* wi); +}; + + +#endif + diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp new file mode 100644 index 00000000000..e1d3316a43e --- /dev/null +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -0,0 +1,298 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +// implementation + +#include +#include + +#include "ImageViewport.h" + +#include + +#include "Texture.h" +#include "ImageBase.h" +#include "FilterSource.h" + + +// constructor +ImageViewport::ImageViewport (void) : m_texInit(false) +{ + // get viewport rectangle + glGetIntegerv(GL_VIEWPORT, m_viewport); + // create buffer for viewport image + m_viewportImage = new BYTE [3 * getViewportSize()[0] * getViewportSize()[1]]; + // set attributes + setWhole(false); +} + +// destructor +ImageViewport::~ImageViewport (void) +{ delete m_viewportImage; } + + +// use whole viewport to capture image +void ImageViewport::setWhole (bool whole) +{ + // set whole + m_whole = whole; + // set capture size to viewport size, if whole, + // otherwise place area in the middle of viewport + for (int idx = 0; idx < 2; ++idx) + { + // capture size + m_capSize[idx] = whole ? short(getViewportSize()[idx]) + : calcSize(short(getViewportSize()[idx])); + // position + m_position[idx] = whole ? 0 : (getViewportSize()[idx] - m_capSize[idx]) >> 1; + } + // init image + init(m_capSize[0], m_capSize[1]); + // set capture position + setPosition(); +} + +void ImageViewport::setCaptureSize (short * size) +{ + m_whole = false; + if (size == NULL) + size = m_capSize; + for (int idx = 0; idx < 2; ++idx) + { + if (size[idx] < 1) + m_capSize[idx] = 1; + else if (size[idx] > getViewportSize()[idx]) + m_capSize[idx] = getViewportSize()[idx]; + else + m_capSize[idx] = size[idx]; + } + init(m_capSize[0], m_capSize[1]); + // set capture position + setPosition(); +} + +// set position of capture rectangle +void ImageViewport::setPosition (int * pos) +{ + // if new position is not provided, use existing position + if (pos == NULL) pos = m_position; + // save position + for (int idx = 0; idx < 2; ++idx) + m_position[idx] = pos[idx] < 0 ? 0 : pos[idx] >= getViewportSize()[idx] + - m_capSize[idx] ? getViewportSize()[idx] - m_capSize[idx] : pos[idx]; + // recalc up left corner + for (int idx = 0; idx < 2; ++idx) + m_upLeft[idx] = m_position[idx] + m_viewport[idx]; +} + + +// capture image from viewport +void ImageViewport::calcImage (unsigned int texId) +{ + // if scale was changed + if (m_scaleChange) + // reset image + init(m_capSize[0], m_capSize[1]); + // if texture wasn't initialized + if (!m_texInit) + { + // initialize it + loadTexture(texId, m_image, m_size); + m_texInit = true; + } + // if texture can be directly created + if (texId != 0 && m_pyfilter == NULL && m_capSize[0] == calcSize(m_capSize[0]) + && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip) + { + // just copy current viewport to texture + glBindTexture(GL_TEXTURE_2D, texId); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], m_capSize[0], m_capSize[1]); + // image is not available + m_avail = false; + } + // otherwise copy viewport to buffer, if image is not available + else if (!m_avail) + { + // get frame buffer data + glReadPixels(m_upLeft[0], m_upLeft[1], m_capSize[0], m_capSize[1], GL_RGB, + GL_UNSIGNED_BYTE, m_viewportImage); + // filter loaded data + FilterBGR24 filt; + filterImage(filt, m_viewportImage, m_capSize); + } +} + + + +// cast Image pointer to ImageViewport +inline ImageViewport * getImageViewport (PyImage * self) +{ return static_cast(self->m_image); } + + +// python methods + + +// get whole +static PyObject * ImageViewport_getWhole (PyImage * self, void * closure) +{ + if (self->m_image != NULL && getImageViewport(self)->getWhole()) Py_RETURN_TRUE; + else Py_RETURN_FALSE; +} + +// set whole +static int ImageViewport_setWhole (PyImage * self, PyObject * value, void * closure) +{ + // check parameter, report failure + if (value == NULL || !PyBool_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a bool"); + return -1; + } + // set whole + if (self->m_image != NULL) getImageViewport(self)->setWhole(value == Py_True); + // success + return 0; +} + + +// get position +static PyObject * ImageViewport_getPosition (PyImage * self, void * closure) +{ + return Py_BuildValue("(ii)", getImageViewport(self)->getPosition()[0], + getImageViewport(self)->getPosition()[1]); +} + +// set position +static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0)) + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1))) + { + PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints"); + return -1; + } + // set position + int pos [] = { + int(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))), + int(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))) + }; + getImageViewport(self)->setPosition(pos); + // success + return 0; +} + +// get capture size +static PyObject * ImageViewport_getCaptureSize (PyImage * self, void * closure) +{ + return Py_BuildValue("(ii)", getImageViewport(self)->getCaptureSize()[0], + getImageViewport(self)->getCaptureSize()[1]); +} + +// set capture size +static int ImageViewport_setCaptureSize (PyImage * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0)) + || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1))) + { + PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints"); + return -1; + } + // set capture size + short size [] = { + short(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))), + short(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))) + }; + getImageViewport(self)->setCaptureSize(size); + // success + return 0; +} + + +// methods structure +static PyMethodDef imageViewportMethods[] = +{ // methods from ImageBase class + {"refresh", (PyCFunction)Image_refresh, METH_NOARGS, "Refresh image - invalidate its current content"}, + {NULL} +}; +// attributes structure +static PyGetSetDef imageViewportGetSets[] = +{ + {"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, "use whole viewport to capture", NULL}, + {"position", (getter)ImageViewport_getPosition, (setter)ImageViewport_setPosition, "upper left corner of captured area", NULL}, + {"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, "size of viewport area being captured", NULL}, + // attributes from ImageBase class + {"image", (getter)Image_getImage, NULL, "image data", NULL}, + {"size", (getter)Image_getSize, NULL, "image size", NULL}, + {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, + {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, + {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {NULL} +}; + + +// define python type +PyTypeObject ImageViewportType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.ImageViewport", /*tp_name*/ + sizeof(PyImage), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Image_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Image source from viewport", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + imageViewportMethods, /* tp_methods */ + 0, /* tp_members */ + imageViewportGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Image_init, /* tp_init */ + 0, /* tp_alloc */ + Image_allocNew, /* tp_new */ +}; diff --git a/source/gameengine/VideoTexture/ImageViewport.h b/source/gameengine/VideoTexture/ImageViewport.h new file mode 100644 index 00000000000..9fd3aeb7ba9 --- /dev/null +++ b/source/gameengine/VideoTexture/ImageViewport.h @@ -0,0 +1,84 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined IMAGEVIEWPORT_H +#define IMAGEVIEWPORT_H + + +#include "Common.h" + +#include "ImageBase.h" + + +/// class for viewport access +class ImageViewport : public ImageBase +{ +public: + /// constructor + ImageViewport (void); + + /// destructor + virtual ~ImageViewport (void); + + /// is whole buffer used + bool getWhole (void) { return m_whole; } + /// set whole buffer use + void setWhole (bool whole); + /// get capture size in viewport + short * getCaptureSize (void) { return m_capSize; } + /// set capture size in viewport + void setCaptureSize (short * size = NULL); + + /// get position in viewport + int * getPosition (void) { return m_position; } + /// set position in viewport + void setPosition (int * pos = NULL); + +protected: + /// frame buffer rectangle + int m_viewport[4]; + + /// size of captured area + short m_capSize[2]; + /// use whole viewport + bool m_whole; + + /// position of capture rectangle in viewport + int m_position[2]; + /// upper left point for capturing + int m_upLeft[2]; + + /// buffer to copy viewport + BYTE * m_viewportImage; + /// texture is initialized + bool m_texInit; + + /// capture image from viewport + virtual void calcImage (unsigned int texId); + + /// get viewport size + int * getViewportSize (void) { return m_viewport + 2; } +}; + + +#endif + diff --git a/source/gameengine/VideoTexture/Makefile b/source/gameengine/VideoTexture/Makefile new file mode 100644 index 00000000000..bead176808b --- /dev/null +++ b/source/gameengine/VideoTexture/Makefile @@ -0,0 +1,65 @@ +# +# $Id$ +# +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. +# All rights reserved. +# +# The Original Code is: all of this file. +# +# Contributor(s): none yet. +# +# ***** END GPL LICENSE BLOCK ***** +# +# + +LIBNAME = videotex +DIR = $(OCGDIR)/gameengine/$(LIBNAME) +SOURCEDIR = source/gameengine/VideoTexture + +include nan_compile.mk + +CCFLAGS += $(LEVEL_1_CPP_WARNINGS) + +CPPFLAGS += $(OGL_CPPFLAGS) +CPPFLAGS += -I$(NAN_GLEW)/include +CPPFLAGS += -I$(OPENGL_HEADERS) +CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) +CPPFLAGS += -I../../blender/python +CPPFLAGS += -I$(NAN_STRING)/include +CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include +CPPFLAGS += -I$(NAN_MOTO)/include +CPPFLAGS += -I../Rasterizer/RAS_OpenGLRasterizer +CPPFLAGS += -I../Rasterizer -I../GameLogic -I../SceneGraph +CPPFLAGS += -I../BlenderRoutines -I../Expressions -I../Ketsji +CPPFLAGS += -I../../kernel/gen_system +CPPFLAGS += -I. +CPPFLAGS += -I../../blender/blenkernel +CPPFLAGS += -I../../blender/blenlib +CPPFLAGS += -I../../blender/include +CPPFLAGS += -I../../blender/makesdna +CPPFLAGS += -I../../blender/imbuf +CPPFLAGS += -I../../blender/gpu +CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include + +ifeq ($(WITH_FFMPEG),true) + CPPFLAGS += -DWITH_FFMPEG + CPPFLAGS += $(NAN_FFMPEGCFLAGS) +endif + + diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp new file mode 100644 index 00000000000..b8c40052e81 --- /dev/null +++ b/source/gameengine/VideoTexture/PyTypeList.cpp @@ -0,0 +1,83 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of blendTex library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + + +#include "PyTypeList.h" + +#include +#include + +#include + + +/// check, if type is in list +bool PyTypeList::in (PyTypeObject * type) +{ + // if list exists + if (m_list.get() != NULL) + // iterate items in list + for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it) + // if item is found, return with success + if ((*it)->getType() == type) return true; + // otherwise return not found + return false; +} + +/// add type to list +void PyTypeList::add (PyTypeObject * type, const char * name) +{ + PyTypeListItem * typeItem; + // if list doesn't exist, create it + if (m_list.get() == NULL) + m_list.reset(new PyTypeListType()); + if (!in(type)) + // add new item to list + m_list->push_back(new PyTypeListItem(type, name)); +} + +/// prepare types +bool PyTypeList::ready (void) +{ + // if list exists + if (m_list.get() != NULL) + // iterate items in list + for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it) + // if preparation failed, report it + if (PyType_Ready((*it)->getType()) < 0) return false; + // success + return true; +} + +/// register types to module +void PyTypeList::reg (PyObject * module) +{ + // if list exists + if (m_list.get() != NULL) + // iterate items in list + for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it) + { + // increase ref count + Py_INCREF((*it)->getType()); + // add type to module + PyModule_AddObject(module, (*it)->getName(), (PyObject*)(*it)->getType()); + } +} diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h new file mode 100644 index 00000000000..7069cf8bb43 --- /dev/null +++ b/source/gameengine/VideoTexture/PyTypeList.h @@ -0,0 +1,85 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of blendTex library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined PYTYPELIST_H +#define PYTYPELIST_H + +#include "Common.h" + +#include +#include + +#include + +// forward declaration +class PyTypeListItem; + +// type for list of types +typedef std::vector PyTypeListType; + + +/// class to store list of python types +class PyTypeList +{ +public: + /// check, if type is in list + bool in (PyTypeObject * type); + + /// add type to list + void add (PyTypeObject * type, const char * name); + + /// prepare types + bool ready (void); + + /// register types to module + void reg (PyObject * module); + +protected: + /// pointer to list of types + std::auto_ptr m_list; +}; + + +/// class for item of python type list +class PyTypeListItem +{ +public: + /// constructor adds type into list + PyTypeListItem (PyTypeObject * type, const char * name) + : m_type(type), m_name(name) + { } + + /// does type match + PyTypeObject * getType (void) { return m_type; } + + /// get name of type + const char * getName (void) { return m_name; } + +protected: + /// pointer to type object + PyTypeObject * m_type; + /// name of type + const char * m_name; +}; + + +#endif \ No newline at end of file diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript new file mode 100644 index 00000000000..e0972e045cc --- /dev/null +++ b/source/gameengine/VideoTexture/SConscript @@ -0,0 +1,32 @@ +#!/usr/bin/python +import sys + +Import ('env') + +sources = env.Glob('*.cpp') + +incs = '. #source/gameengine/Ketsji #source/gameengine/Expressions' +incs += ' #source/gameengine/GameLogic #source/gameengine/SceneGraph #source/gameengine/Rasterizer' +incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' +incs += ' #source/gameengine/BlenderRoutines' +incs += ' #source/blender/include #source/blender/blenlib #source/blender/blenkernel' +incs += ' #source/blender/makesdna #source/blender/imbuf #source/blender/python' +incs += ' #source/blender/gpu #source/kernel/gen_system #intern/string #intern/moto/include' +incs += ' #intern/guardedalloc #intern/SoundSystem' +incs += ' #extern/glew/include' + +cflags = [] +defs = '' +if env['OURPLATFORM'] == 'win32-vc': + cflags.append('/GR') + cflags.append('/Ox') + defs += ' __STDC_CONSTANT_MACROS' + +incs += ' ' + env['BF_PYTHON_INC'] +#incs += ' ' + env['BF_OPENGL_INC'] + +if env['WITH_BF_FFMPEG']: + defs += ' WITH_FFMPEG' + incs += ' ' + env['BF_FFMPEG_INC'] + +env.BlenderLib ( 'bf_videotex', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[25, 72], compileflags = cflags ) diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp new file mode 100644 index 00000000000..d208802675c --- /dev/null +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -0,0 +1,463 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +// implementation + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include "KX_KetsjiEngine.h" +#include "KX_PythonInit.h" +#include "Texture.h" +#include "ImageBase.h" +#include "Exception.h" + +#include +#include + + +// macro for exception handling and logging +#define CATCH_EXCP catch (Exception & exp) \ +{ exp.report(); } + + +// are Blender materials used +bool blendMats = false; + +// Blender GameObject type +BlendType gameObjectType ("KX_GameObject"); + + +// load texture +void loadTexture (unsigned int texId, unsigned int * texture, short * size, + bool mipmap) +{ + // load texture for rendering + glBindTexture(GL_TEXTURE_2D, texId); + if (mipmap) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, texture); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, size[0], size[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, texture); + } + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +} + + +// get pointer to material +RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID) +{ + // if object is available + if (obj != NULL) + { + // get pointer to texture image + KX_GameObject * gameObj = gameObjectType.checkType(obj); + if (gameObj != NULL && gameObj->GetMeshCount() > 0) + { + // get material from mesh + RAS_MeshObject * mesh = gameObj->GetMesh(0); + RAS_MeshMaterial *meshMat = mesh->GetMeshMaterial(matID); + if (meshMat->m_bucket != NULL) + // return pointer to polygon or blender material + return meshMat->m_bucket->GetPolyMaterial(); + } + } + // otherwise material was not found + return NULL; +} + + +// get material ID +short getMaterialID (PyObject * obj, char * name) +{ + // search for material + for (short matID = 0;; ++matID) + { + // get material + RAS_IPolyMaterial * mat = getMaterial(obj, matID); + // if material is not available, report that no material was found + if (mat == NULL) break; + // if material name matches + if (strcmp(mat->GetMaterialName().ReadPtr(), name) == 0) + // matID is found + return matID; + } + // material was not found + return -1; +} + + +// Texture object allocation +PyObject * Texture_new (PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + // allocate object + Texture * self = reinterpret_cast(type->tp_alloc(type, 0)); + // initialize object structure + self->m_actTex = 0; + self->m_orgSaved = false; + self->m_imgTexture = NULL; + self->m_matTexture = NULL; + self->m_mipmap = false; + self->m_scaledImg = NULL; + self->m_scaledImgSize = 0; + self->m_source = NULL; + self->m_lastClock = 0.0; + // return allocated object + return reinterpret_cast(self); +} + + +// forward declaration +PyObject * Texture_close(Texture * self); +int Texture_setSource (Texture * self, PyObject * value, void * closure); + + +// Texture object deallocation +void Texture_dealloc (Texture * self) +{ + // release renderer + Py_XDECREF(self->m_source); + // close texture + Texture_close(self); + // release scaled image buffer + delete [] self->m_scaledImg; + // release object + self->ob_type->tp_free((PyObject*)self); +} + + +static ExceptionID MaterialNotAvail; +static ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is not available"); + +// Texture object initialization +int Texture_init (Texture *self, PyObject *args, PyObject *kwds) +{ + // parameters - game object with video texture + PyObject * obj = NULL; + // material ID + short matID = 0; + // texture ID + short texID = 0; + // texture object with shared texture ID + Texture * texObj = NULL; + + static char *kwlist[] = {"gameObj", "materialID", "textureID", "textureObj", NULL}; + + // get parameters + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|hhO!", kwlist, &obj, &matID, + &texID, &TextureType, &texObj)) + return -1; + + // if parameters are available + if (obj != NULL) + { + // process polygon material or blender material + try + { + // get pointer to texture image + RAS_IPolyMaterial * mat = getMaterial(obj, matID); + if (mat != NULL) + { + // is it blender material or polygon material + blendMats = (mat->GetFlag() & RAS_BLENDERMAT) != 0; + if (blendMats) + // get blender material texture + self->m_matTexture = static_cast(mat)->getTex(texID); + else + { + // get texture pointer from polygon material + MTFace * tface = static_cast(mat)->GetMTFace(); + self->m_imgTexture = (Image*)tface->tpage; + } + } + // check if texture is available, if not, initialization failed + if (self->m_imgTexture == NULL && self->m_matTexture == NULL) + // throw exception if initialization failed + THRWEXCP(MaterialNotAvail, S_OK); + + // if texture object is provided + if (texObj != NULL) + { + // copy texture code + self->m_actTex = texObj->m_actTex; + self->m_mipmap = texObj->m_mipmap; + if (texObj->m_source != NULL) + Texture_setSource(self, reinterpret_cast(texObj->m_source), NULL); + } + else + // otherwise generate texture code + glGenTextures(1, (GLuint*)&self->m_actTex); + } + catch (Exception & exp) + { + exp.report(); + return -1; + } + } + // initialization succeded + return 0; +} + + +// close added texture +PyObject * Texture_close(Texture * self) +{ + // restore texture + if (self->m_orgSaved) + { + self->m_orgSaved = false; + // restore original texture code + if (blendMats) + self->m_matTexture->swapTexture(self->m_orgTex); + else + self->m_imgTexture->bindcode = self->m_orgTex; + // drop actual texture + if (self->m_actTex != 0) + { + glDeleteTextures(1, (GLuint *)&self->m_actTex); + self->m_actTex = 0; + } + } + Py_RETURN_NONE; +} + + +// refresh texture +PyObject * Texture_refresh (Texture * self, PyObject * args) +{ + // get parameter - refresh source + PyObject * param; + if (!PyArg_ParseTuple(args, "O", ¶m) || !PyBool_Check(param)) + { + // report error + PyErr_SetString(PyExc_TypeError, "The value must be a bool"); + return NULL; + } + // some trick here: we are in the business of loading a texture, + // no use to do it if we are still in the same rendering frame. + // We find this out by looking at the engine current clock time + KX_KetsjiEngine* engine = KX_GetActiveEngine(); + if (engine->GetClockTime() != self->m_lastClock) + { + self->m_lastClock = engine->GetClockTime(); + // set source refresh + bool refreshSource = (param == Py_True); + // try to proces texture from source + try + { + // if source is available + if (self->m_source != NULL) + { + // check texture code + if (!self->m_orgSaved) + { + self->m_orgSaved = true; + // save original image code + if (blendMats) + self->m_orgTex = self->m_matTexture->swapTexture(self->m_actTex); + else + { + self->m_orgTex = self->m_imgTexture->bindcode; + self->m_imgTexture->bindcode = self->m_actTex; + } + } + + // get texture + unsigned int * texture = self->m_source->m_image->getImage(self->m_actTex); + // if texture is available + if (texture != NULL) + { + // get texture size + short * orgSize = self->m_source->m_image->getSize(); + // calc scaled sizes + short size[] = {ImageBase::calcSize(orgSize[0]), ImageBase::calcSize(orgSize[1])}; + // scale texture if needed + if (size[0] != orgSize[0] || size[1] != orgSize[1]) + { + // if scaled image buffer is smaller than needed + if (self->m_scaledImgSize < (unsigned int)(size[0] * size[1])) + { + // new size + self->m_scaledImgSize = size[0] * size[1]; + // allocate scaling image + delete [] self->m_scaledImg; + self->m_scaledImg = new unsigned int[self->m_scaledImgSize]; + } + // scale texture + gluScaleImage(GL_RGBA, orgSize[0], orgSize[1], GL_UNSIGNED_BYTE, texture, + size[0], size[1], GL_UNSIGNED_BYTE, self->m_scaledImg); + // use scaled image instead original + texture = self->m_scaledImg; + } + // load texture for rendering + loadTexture (self->m_actTex, texture, size, self->m_mipmap); + + // refresh texture source, if required + if (refreshSource) self->m_source->m_image->refresh(); + } + } + } + CATCH_EXCP; + } + Py_RETURN_NONE; +} + + +// get mipmap value +PyObject * Texture_getMipmap (Texture * self, void * closure) +{ + // return true if flag is set, otherwise false + if (self->m_mipmap) Py_RETURN_TRUE; + else Py_RETURN_FALSE; +} + +// set mipmap value +int Texture_setMipmap (Texture * self, PyObject * value, void * closure) +{ + // check parameter, report failure + if (value == NULL || !PyBool_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a bool"); + return -1; + } + // set mipmap + self->m_mipmap = value == Py_True; + // success + return 0; +} + + +// get source object +PyObject * Texture_getSource (Texture * self, PyObject * value, void * closure) +{ + // if source exists + if (self->m_source != NULL) + { + Py_INCREF(self->m_source); + return reinterpret_cast(self->m_source); + } + // otherwise return None + Py_RETURN_NONE; +} + + +// set source object +int Texture_setSource (Texture * self, PyObject * value, void * closure) +{ + // check new value + if (value == NULL || !pyImageTypes.in(value->ob_type)) + { + // report value error + PyErr_SetString(PyExc_TypeError, "Invalid type of value"); + return -1; + } + // increase ref count for new value + Py_INCREF(value); + // release previous + Py_XDECREF(self->m_source); + // set new value + self->m_source = reinterpret_cast(value); + // return success + return 0; +} + + +// class Texture methods +static PyMethodDef textureMethods[] = +{ + { "close", (PyCFunction)Texture_close, METH_NOARGS, "Close dynamic texture and restore original"}, + { "refresh", (PyCFunction)Texture_refresh, METH_VARARGS, "Refresh texture from source"}, + {NULL} /* Sentinel */ +}; + +// class Texture attributes +static PyGetSetDef textureGetSets[] = +{ + {"source", (getter)Texture_getSource, (setter)Texture_setSource, "source of texture", NULL}, + {"mipmap", (getter)Texture_getMipmap, (setter)Texture_setMipmap, "mipmap texture", NULL}, + {NULL} +}; + + +// class Texture declaration +PyTypeObject TextureType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.Texture", /*tp_name*/ + sizeof(Texture), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Texture_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Texture objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + textureMethods, /* tp_methods */ + 0, /* tp_members */ + textureGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Texture_init, /* tp_init */ + 0, /* tp_alloc */ + Texture_new, /* tp_new */ +}; diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h new file mode 100644 index 00000000000..f19f8da607d --- /dev/null +++ b/source/gameengine/VideoTexture/Texture.h @@ -0,0 +1,87 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2006 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined TEXTURE_H +#define TEXTURE_H + +#include +#include + +#include +#include +#include + +#include "ImageBase.h" +#include "BlendType.h" + + +// type Texture declaration +struct Texture +{ + PyObject_HEAD + + // video texture bind code + unsigned int m_actTex; + + // original texture bind code + unsigned int m_orgTex; + // original texture saved + bool m_orgSaved; + + // texture image for game materials + Image * m_imgTexture; + // texture for blender materials + BL_Texture * m_matTexture; + + // use mipmapping + bool m_mipmap; + + // scaled image buffer + unsigned int * m_scaledImg; + // scaled image buffer size + unsigned int m_scaledImgSize; + // last refresh + double m_lastClock; + + // image source + PyImage * m_source; +}; + + +// Texture type description +extern PyTypeObject TextureType; + +// usage of Blender materials +extern bool blendMats; + +// load texture +void loadTexture (unsigned int texId, unsigned int * texture, short * size, + bool mipmap = false); + +// get material +RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID); + +// get material ID +short getMaterialID (PyObject * obj, char * name); + + +#endif diff --git a/source/gameengine/VideoTexture/VideoBase.cpp b/source/gameengine/VideoTexture/VideoBase.cpp new file mode 100644 index 00000000000..038a04a55a8 --- /dev/null +++ b/source/gameengine/VideoTexture/VideoBase.cpp @@ -0,0 +1,183 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if defined WIN32 +#define WINDOWS_LEAN_AND_MEAN +#include +#endif + +#include "VideoBase.h" + +#include "FilterSource.h" + +// VideoBase implementation + + +// initialize image data +void VideoBase::init(short width, short height) +{ + // save original sizes + m_orgSize[0] = width; + m_orgSize[1] = height; + // call base class initialization + ImageBase::init(width, height); +} + + +// process video frame +void VideoBase::process (BYTE * sample) +{ + // if scale was changed + if (m_scaleChange) + // reset image + init(m_orgSize[0], m_orgSize[1]); + // if image is allocated and is able to store new image + if (m_image != NULL && !m_avail) + { + // filters used + FilterRGB24 filtRGB; + FilterYV12 filtYUV; + // convert video format to image + switch (m_format) + { + case RGB24: + // use filter object for format to convert image + filterImage(filtRGB, sample, m_orgSize); + // finish + break; + case YV12: + // use filter object for format to convert image + filtYUV.setBuffs(sample, m_orgSize); + filterImage(filtYUV, sample, m_orgSize); + // finish + break; + } + } +} + + +// python functions + + +// exceptions for video source initialization +ExceptionID SourceVideoEmpty, SourceVideoCreation; +ExpDesc SourceVideoEmptyDesc (SourceVideoEmpty, "Source Video is empty"); +ExpDesc SourceVideoCreationDesc (SourceVideoCreation, "SourceVideo object was not created"); + +// open video source +void Video_open (VideoBase * self, char * file, short captureID) +{ + // if file is empty, throw exception + if (file == NULL) THRWEXCP(SourceVideoEmpty, S_OK); + + // open video file or capture device + if (captureID >= 0) + self->openCam(file, captureID); + else + self->openFile(file); +} + + +// play video +PyObject * Video_play (PyImage * self) +{ if (getVideo(self)->play()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } + +// stop video +PyObject * Video_stop (PyImage * self) +{ if (getVideo(self)->stop()) Py_RETURN_TRUE; else Py_RETURN_FALSE; } + +// get status +PyObject * Video_getStatus (PyImage * self, void * closure) +{ + return Py_BuildValue("h", getVideo(self)->getStatus()); +} + +// refresh video +PyObject * Video_refresh (PyImage * self) +{ + getVideo(self)->refresh(); + return Video_getStatus(self, NULL); +} + + +// get range +PyObject * Video_getRange (PyImage * self, void * closure) +{ + return Py_BuildValue("[ff]", getVideo(self)->getRange()[0], + getVideo(self)->getRange()[1]); +} + +// set range +int Video_setRange (PyImage * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 + || !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0)) + || !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1))) + { + PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 longs"); + return -1; + } + // set range + getVideo(self)->setRange(PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)), + PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1))); + // success + return 0; +} + +// get repeat +PyObject * Video_getRepeat (PyImage * self, void * closure) +{ return Py_BuildValue("h", getVideo(self)->getRepeat()); } + +// set repeat +int Video_setRepeat (PyImage * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PyInt_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be an int"); + return -1; + } + // set repeat + getVideo(self)->setRepeat(int(PyInt_AsLong(value))); + // success + return 0; +} + +// get frame rate +PyObject * Video_getFrameRate (PyImage * self, void * closure) +{ return Py_BuildValue("f", double(getVideo(self)->getFrameRate())); } + +// set frame rate +int Video_setFrameRate (PyImage * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PyFloat_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a float"); + return -1; + } + // set repeat + getVideo(self)->setFrameRate(float(PyFloat_AsDouble(value))); + // success + return 0; +} diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h new file mode 100644 index 00000000000..78e8ba65909 --- /dev/null +++ b/source/gameengine/VideoTexture/VideoBase.h @@ -0,0 +1,185 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#if !defined VIDEOBASE_H +#define VIDEOBASE_H + + +#include + +#include "ImageBase.h" + +#include "Exception.h" + +// source states +const int SourceError = -1; +const int SourceEmpty = 0; +const int SourceReady = 1; +const int SourcePlaying = 2; +const int SourceStopped = 3; + + +// video source formats +enum VideoFormat { None, RGB24, YV12 }; + + +/// base class for video source +class VideoBase : public ImageBase +{ +public: + /// constructor + VideoBase (void) : ImageBase(true), m_format(None), m_status(SourceEmpty), + m_repeat(0), m_frameRate(1.0) + { + m_orgSize[0] = m_orgSize[1] = 0; + m_range[0] = m_range[1] = 0.0; + } + + /// destructor + virtual ~VideoBase (void) {} + + /// open video file + virtual void openFile (char * file) + { + m_isFile = true; + m_status = SourceReady; + } + /// open video capture device + virtual void openCam (char * file, short camIdx) + { + m_isFile = false; + m_status = SourceReady; + } + + /// play video + virtual bool play (void) + { + if (m_status == SourceReady || m_status == SourceStopped) + { + m_status = SourcePlaying; + return true; + } + return false; + } + /// stop/pause video + virtual bool stop (void) + { + if (m_status == SourcePlaying) + { + m_status = SourceStopped; + return true; + } + return false; + } + + // get video status + int getStatus (void) { return m_status; } + + /// get play range + const double * getRange (void) { return m_range; } + /// set play range + virtual void setRange (double start, double stop) + { + if (m_isFile) + { + m_range[0] = start; + m_range[1] = stop; + } + } + + // get video repeat + int getRepeat (void) { return m_repeat; } + /// set video repeat + virtual void setRepeat (int rep) + { if (m_isFile) m_repeat = rep; } + + /// get frame rate + float getFrameRate (void) { return m_frameRate; } + /// set frame rate + virtual void setFrameRate (float rate) + { if (m_isFile) m_frameRate = rate > 0.0 ? rate : 1.0f; } + +protected: + /// video format + VideoFormat m_format; + /// original video size + short m_orgSize[2]; + + /// video status + int m_status; + + /// is source file + bool m_isFile; + + /// replay range + double m_range[2]; + /// repeat count + int m_repeat; + /// frame rate + float m_frameRate; + + /// initialize image data + void init (short width, short height); + + /// process source data + void process (BYTE * sample); +}; + + + +// python fuctions + + +// cast Image pointer to Video +inline VideoBase * getVideo (PyImage * self) +{ return static_cast(self->m_image); } + + +extern ExceptionID SourceVideoCreation; + +// object initialization +template void Video_init (PyImage * self) +{ + // create source video object + if (self->m_image != NULL) delete self->m_image; + HRESULT hRslt = S_OK; + self->m_image = new T(&hRslt); + CHCKHRSLT(hRslt, SourceVideoCreation); +} + + +// video functions +void Video_open (VideoBase * self, char * file, short captureID); +PyObject * Video_play (PyImage * self); +PyObject * Video_stop (PyImage * self); +PyObject * Video_refresh (PyImage * self); +PyObject * Video_getStatus (PyImage * self, void * closure); +PyObject * Video_getRange (PyImage * self, void * closure); +int Video_setRange (PyImage * self, PyObject * value, void * closure); +PyObject * Video_getRepeat (PyImage * self, void * closure); +int Video_setRepeat (PyImage * self, PyObject * value, void * closure); +PyObject * Video_getFrameRate (PyImage * self, void * closure); +int Video_setFrameRate (PyImage * self, PyObject * value, void * closure); + + +#endif + diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp new file mode 100644 index 00000000000..b12bad4b416 --- /dev/null +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -0,0 +1,747 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#include "MEM_guardedalloc.h" +#include "PIL_time.h" + +#include + +#include "Exception.h" +#include "VideoFFmpeg.h" + +#ifdef WITH_FFMPEG + +// default framerate +const double defFrameRate = 25.0; +// time scale constant +const long timeScale = 1000; + +// macro for exception handling and logging +#define CATCH_EXCP catch (Exception & exp) \ +{ exp.report(); m_status = SourceError; } + +extern "C" void do_init_ffmpeg(); + +// class RenderVideo + +// constructor +VideoFFmpeg::VideoFFmpeg (HRESULT * hRslt) : VideoBase(), +m_codec(NULL), m_formatCtx(NULL), m_codecCtx(NULL), +m_frame(NULL), m_frameDeinterlaced(NULL), m_frameBGR(NULL), m_imgConvertCtx(NULL), +m_deinterlace(false), m_preseek(0), m_videoStream(-1), m_baseFrameRate(25.0), +m_lastFrame(-1), m_curPosition(-1), m_startTime(0), +m_captWidth(0), m_captHeight(0), m_captRate(0.f) +{ + // set video format + m_format = RGB24; + // force flip because ffmpeg always return the image in the wrong orientation for texture + setFlip(true); + // construction is OK + *hRslt = S_OK; +} + +// destructor +VideoFFmpeg::~VideoFFmpeg () +{ +} + + +// release components +bool VideoFFmpeg::release() +{ + // release + if (m_codecCtx) + { + avcodec_close(m_codecCtx); + } + if (m_formatCtx) + { + av_close_input_file(m_formatCtx); + } + if (m_frame) + { + av_free(m_frame); + } + if (m_frameDeinterlaced) + { + MEM_freeN(m_frameDeinterlaced->data[0]); + av_free(m_frameDeinterlaced); + } + if (m_frameBGR) + { + MEM_freeN(m_frameBGR->data[0]); + av_free(m_frameBGR); + } + if (m_imgConvertCtx) + { + sws_freeContext(m_imgConvertCtx); + } + + m_codec = NULL; + m_codecCtx = NULL; + m_formatCtx = NULL; + m_frame = NULL; + m_frame = NULL; + m_frameBGR = NULL; + m_imgConvertCtx = NULL; + + // object will be deleted after that + return true; +} + + +// set initial parameters +void VideoFFmpeg::initParams (short width, short height, float rate) +{ + m_captWidth = width; + m_captHeight = height; + m_captRate = rate; +} + +int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams) +{ + AVFormatContext *formatCtx; + int i, videoStream; + AVCodec *codec; + AVCodecContext *codecCtx; + + if(av_open_input_file(&formatCtx, filename, inputFormat, 0, formatParams)!=0) + return -1; + + if(av_find_stream_info(formatCtx)<0) + { + av_close_input_file(formatCtx); + return -1; + } + + /* Find the first video stream */ + videoStream=-1; + for(i=0; inb_streams; i++) + { + if(formatCtx->streams[i] && + get_codec_from_stream(formatCtx->streams[i]) && + (get_codec_from_stream(formatCtx->streams[i])->codec_type==CODEC_TYPE_VIDEO)) + { + videoStream=i; + break; + } + } + + if(videoStream==-1) + { + av_close_input_file(formatCtx); + return -1; + } + + codecCtx = get_codec_from_stream(formatCtx->streams[videoStream]); + + /* Find the decoder for the video stream */ + codec=avcodec_find_decoder(codecCtx->codec_id); + if(codec==NULL) + { + av_close_input_file(formatCtx); + return -1; + } + codecCtx->workaround_bugs = 1; + if(avcodec_open(codecCtx, codec)<0) + { + av_close_input_file(formatCtx); + return -1; + } + +#ifdef FFMPEG_OLD_FRAME_RATE + if(codecCtx->frame_rate>1000 && codecCtx->frame_rate_base==1) + codecCtx->frame_rate_base=1000; + m_baseFrameRate = (double)codecCtx->frame_rate / (double)codecCtx->frame_rate_base; +#else + m_baseFrameRate = av_q2d(formatCtx->streams[videoStream]->r_frame_rate); +#endif + if (m_baseFrameRate <= 0.0) + m_baseFrameRate = defFrameRate; + + m_codec = codec; + m_codecCtx = codecCtx; + m_formatCtx = formatCtx; + m_videoStream = videoStream; + m_frame = avcodec_alloc_frame(); + m_frameDeinterlaced = avcodec_alloc_frame(); + m_frameBGR = avcodec_alloc_frame(); + + + // allocate buffer if deinterlacing is required + avpicture_fill((AVPicture*)m_frameDeinterlaced, + (uint8_t*)MEM_callocN(avpicture_get_size( + m_codecCtx->pix_fmt, + m_codecCtx->width, m_codecCtx->height), + "ffmpeg deinterlace"), + m_codecCtx->pix_fmt, m_codecCtx->width, m_codecCtx->height); + + // allocate buffer to store final decoded frame + avpicture_fill((AVPicture*)m_frameBGR, + (uint8_t*)MEM_callocN(avpicture_get_size( + PIX_FMT_BGR24, + m_codecCtx->width, m_codecCtx->height), + "ffmpeg bgr"), + PIX_FMT_BGR24, m_codecCtx->width, m_codecCtx->height); + // allocate sws context + m_imgConvertCtx = sws_getContext( + m_codecCtx->width, + m_codecCtx->height, + m_codecCtx->pix_fmt, + m_codecCtx->width, + m_codecCtx->height, + PIX_FMT_BGR24, + SWS_FAST_BILINEAR, + NULL, NULL, NULL); + + if (!m_imgConvertCtx) { + avcodec_close(m_codecCtx); + av_close_input_file(m_formatCtx); + av_free(m_frame); + MEM_freeN(m_frameDeinterlaced->data[0]); + av_free(m_frameDeinterlaced); + MEM_freeN(m_frameBGR->data[0]); + av_free(m_frameBGR); + return -1; + } + return 0; +} + +// open video file +void VideoFFmpeg::openFile (char * filename) +{ + do_init_ffmpeg(); + + if (openStream(filename, NULL, NULL) != 0) + return; + + if (m_codecCtx->gop_size) + m_preseek = (m_codecCtx->gop_size < 25) ? m_codecCtx->gop_size+1 : 25; + else if (m_codecCtx->has_b_frames) + m_preseek = 25; // should determine gopsize + else + m_preseek = 0; + + // get video time range + m_range[0] = 0.0; + m_range[1] = (double)m_formatCtx->duration / AV_TIME_BASE; + + // open base class + VideoBase::openFile(filename); + + if (m_formatCtx->pb->is_streamed) + { + // the file is in fact a streaming source, prevent seeking + m_isFile = false; + // for streaming it is important to do non blocking read + m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK; + } +} + + +// open video capture device +void VideoFFmpeg::openCam (char * file, short camIdx) +{ + // open camera source + AVInputFormat *inputFormat; + AVFormatParameters formatParams; + AVRational frameRate; + char *p, filename[28], rateStr[20]; + + 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"); + if (!inputFormat) + // Video For Windows not supported?? + return; + sprintf(filename, "%d", camIdx); +#else + // In Linux we support two types of devices: VideoForLinux and DV1394. + // the user specify it with the filename: + // [][:] + // : 'v4l' for VideoForLinux, 'dv1394' for DV1394. By default 'v4l' + // : 'pal', 'secam' or 'ntsc'. By default 'ntsc' + // The driver name is constructed automatically from the device type: + // v4l : /dev/video + // dv1394: /dev/dv1394/ + // If you have different driver name, you can specify the driver name explicitely + // instead of device type. Examples of valid filename: + // /dev/v4l/video0:pal + // /dev/ieee1394/1:ntsc + // dv1394:secam + // v4l:pal + if (file && strstr(file, "1394") != NULL) + { + // the user specifies a driver, check if it is v4l or d41394 + inputFormat = av_find_input_format("dv1394"); + sprintf(filename, "/dev/dv1394/%d", camIdx); + } else + { + inputFormat = av_find_input_format("video4linux"); + sprintf(filename, "/dev/video%d", camIdx); + } + if (!inputFormat) + // these format should be supported, check ffmpeg compilation + return; + if (file && strncmp(file, "/dev", 4) == 0) + { + // user does not specify a driver + strncpy(filename, file, sizeof(filename)); + filename[sizeof(filename)-1] = 0; + if ((p = strchr(filename, ':')) != 0) + *p = 0; + } + if (file && (p = strchr(file, ":")) != NULL) + formatParams.standard = p+1; +#endif + //frame rate + if (m_captRate <= 0.f) + m_captRate = defFrameRate; + sprintf(rateStr, "%f", m_captRate); + av_parse_video_frame_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; + + if (openStream(filename, inputFormat, &formatParams) != 0) + return; + + // for video capture it is important to do non blocking read + m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK; + // open base class + VideoBase::openCam(file, camIdx); +} + + +// play video +bool VideoFFmpeg::play (void) +{ + try + { + // if object is able to play + if (VideoBase::play()) + { + // set video position + setPositions(); + // return success + return true; + } + } + CATCH_EXCP; + return false; +} + + +// stop video +bool VideoFFmpeg::stop (void) +{ + try + { + if (VideoBase::stop()) + { + return true; + } + } + CATCH_EXCP; + return false; +} + + +// set video range +void VideoFFmpeg::setRange (double start, double stop) +{ + try + { + // set range + VideoBase::setRange(start, stop); + // set range for video + setPositions(); + } + CATCH_EXCP; +} + +// set framerate +void VideoFFmpeg::setFrameRate (float rate) +{ + VideoBase::setFrameRate(rate); +} + + +// image calculation +void VideoFFmpeg::calcImage (unsigned int texId) +{ + loadFrame(); +} + + +// load frame from video +void VideoFFmpeg::loadFrame (void) +{ + // get actual time + double actTime = PIL_check_seconds_timer() - m_startTime; + // if video has ended + if (m_isFile && actTime * m_frameRate >= m_range[1]) + { + // if repeats are set, decrease them + if (m_repeat > 0) + --m_repeat; + // if video has to be replayed + if (m_repeat != 0) + { + // reset its position + actTime -= (m_range[1] - m_range[0]) / m_frameRate; + m_startTime += (m_range[1] - m_range[0]) / m_frameRate; + } + // if video has to be stopped, stop it + else + m_status = SourceStopped; + } + // if video is playing + if (m_status == SourcePlaying) + { + // actual frame + long actFrame = m_isFile ? long(actTime * actFrameRate()) : m_lastFrame + 1; + // if actual frame differs from last frame + if (actFrame != m_lastFrame) + { + // get image + if(grabFrame(actFrame)) + { + AVFrame* frame = getFrame(); + // save actual frame + m_lastFrame = actFrame; + // init image, if needed + init(short(m_codecCtx->width), short(m_codecCtx->height)); + // process image + process((BYTE*)(frame->data[0])); + } + } + } +} + + +// set actual position +void VideoFFmpeg::setPositions (void) +{ + // set video start time + m_startTime = PIL_check_seconds_timer(); + // if file is played and actual position is before end position + if (m_isFile && m_lastFrame >= 0 && m_lastFrame < m_range[1] * actFrameRate()) + // continue from actual position + m_startTime -= double(m_lastFrame) / actFrameRate(); + else + m_startTime -= m_range[0]; +} + +// position pointer in file, position in second +bool VideoFFmpeg::grabFrame(long position) +{ + AVPacket packet; + int frameFinished; + int posFound = 1; + bool frameLoaded = false; + long long targetTs = 0; + + // first check if the position that we are looking for is in the preseek range + // if so, just read the frame until we get there + if (position > m_curPosition + 1 + && m_preseek + && position - (m_curPosition + 1) < m_preseek) + { + while(av_read_frame(m_formatCtx, &packet)>=0) + { + if (packet.stream_index == m_videoStream) + { + avcodec_decode_video( + m_codecCtx, + m_frame, &frameFinished, + packet.data, packet.size); + if (frameFinished) + m_curPosition++; + } + av_free_packet(&packet); + if (position == m_curPosition+1) + break; + } + } + // if the position is not in preseek, do a direct jump + if (position != m_curPosition + 1) { + double timeBase = av_q2d(m_formatCtx->streams[m_videoStream]->time_base); + long long pos = (long long) + ((long long) (position - m_preseek) * AV_TIME_BASE / m_baseFrameRate); + long long startTs = m_formatCtx->streams[m_videoStream]->start_time; + + if (pos < 0) + pos = 0; + + if (startTs != AV_NOPTS_VALUE) + pos += (long long)(startTs * AV_TIME_BASE * timeBase); + + av_seek_frame(m_formatCtx, -1, pos, AVSEEK_FLAG_BACKWARD); + // current position is now lost, guess a value. + // It's not important because it will be set at this end of this function + m_curPosition = position - m_preseek - 1; + // this is the timestamp of the frame we're looking for + targetTs = (long long)(((double) position) / m_baseFrameRate / timeBase); + if (startTs != AV_NOPTS_VALUE) + targetTs += startTs; + + posFound = 0; + avcodec_flush_buffers(m_codecCtx); + } + + while(av_read_frame(m_formatCtx, &packet)>=0) + { + if(packet.stream_index == m_videoStream) + { + avcodec_decode_video(m_codecCtx, + m_frame, &frameFinished, + packet.data, packet.size); + + if (frameFinished && !posFound) + { + if (packet.dts >= targetTs) + posFound = 1; + } + + if(frameFinished && posFound == 1) + { + AVFrame * input = m_frame; + + /* This means the data wasnt read properly, + this check stops crashing */ + if ( input->data[0]==0 && input->data[1]==0 + && input->data[2]==0 && input->data[3]==0) + { + av_free_packet(&packet); + break; + } + + if (m_deinterlace) + { + if (avpicture_deinterlace( + (AVPicture*) m_frameDeinterlaced, + (const AVPicture*) m_frame, + m_codecCtx->pix_fmt, + m_codecCtx->width, + m_codecCtx->height) >= 0) + { + input = m_frameDeinterlaced; + } + } + // convert to BGR24 + sws_scale(m_imgConvertCtx, + input->data, + input->linesize, + 0, + m_codecCtx->height, + m_frameBGR->data, + m_frameBGR->linesize); + av_free_packet(&packet); + frameLoaded = true; + break; + } + } + av_free_packet(&packet); + } + if (frameLoaded) + m_curPosition = position; + return frameLoaded; +} + + +// python methods + + +// cast Image pointer to VideoFFmpeg +inline VideoFFmpeg * getVideoFFmpeg (PyImage * self) +{ return static_cast(self->m_image); } + + +// object initialization +static int VideoFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +{ + PyImage * self = reinterpret_cast(pySelf); + // parameters - video source + // file name or format type for capture (only for Linux: video4linux or dv1394) + char * file = NULL; + // capture device number + short capt = -1; + // capture width, only if capt is >= 0 + short width = 0; + // capture height, only if capt is >= 0 + short height = 0; + // capture rate, only if capt is >= 0 + float rate = 25.f; + + static char *kwlist[] = {"file", "capture", "rate", "width", "height", NULL}; + + // get parameters + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|hfhh", kwlist, &file, &capt, + &rate, &width, &height)) + return -1; + + try + { + // create video object + Video_init(self); + + // set thread usage + getVideoFFmpeg(self)->initParams(width, height, rate); + + // open video source + Video_open(getVideo(self), file, capt); + } + catch (Exception & exp) + { + exp.report(); + return -1; + } + // initialization succeded + return 0; +} + +PyObject * VideoFFmpeg_getPreseek (PyImage *self, void * closure) +{ + return Py_BuildValue("h", getFFmpeg(self)->getPreseek()); +} + +// set range +int VideoFFmpeg_setPreseek (PyImage * self, PyObject * value, void * closure) +{ + // check validity of parameter + if (value == NULL || !PyInt_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be an integer"); + return -1; + } + // set preseek + getFFmpeg(self)->setPreseek(PyInt_AsLong(value)); + // success + return 0; +} + +// get deinterlace +PyObject * VideoFFmpeg_getDeinterlace (PyImage * self, void * closure) +{ + if (getFFmpeg(self)->getDeinterlace()) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +// set flip +int VideoFFmpeg_setDeinterlace (PyImage * self, PyObject * value, void * closure) +{ + // check parameter, report failure + if (value == NULL || !PyBool_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a bool"); + return -1; + } + // set deinterlace + getFFmpeg(self)->setDeinterlace(value == Py_True); + // success + return 0; +} + +// methods structure +static PyMethodDef videoMethods[] = +{ // methods from VideoBase class + {"play", (PyCFunction)Video_play, METH_NOARGS, "Play video"}, + {"stop", (PyCFunction)Video_stop, METH_NOARGS, "Stop (pause) video"}, + {"refresh", (PyCFunction)Video_refresh, METH_NOARGS, "Refresh video - get its status"}, + {NULL} +}; +// attributes structure +static PyGetSetDef videoGetSets[] = +{ // methods from VideoBase class + {"status", (getter)Video_getStatus, NULL, "video status", NULL}, + {"range", (getter)Video_getRange, (setter)Video_setRange, "replay range", NULL}, + {"repeat", (getter)Video_getRepeat, (setter)Video_setRepeat, "repeat count, -1 for infinite repeat", NULL}, + {"framerate", (getter)Video_getFrameRate, (setter)Video_setFrameRate, "frame rate", NULL}, + // attributes from ImageBase class + {"image", (getter)Image_getImage, NULL, "image data", NULL}, + {"size", (getter)Image_getSize, NULL, "image size", NULL}, + {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, + {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, + {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {"preseek", (getter)VideoFFmpeg_getPreseek, (setter)VideoFFmpeg_setPreseek, "nb of frames of preseek", NULL}, + {"deinterlace", (getter)VideoFFmpeg_getDeinterlace, (setter)VideoFFmpeg_setDeinterlace, "deinterlace image", NULL}, + {NULL} +}; + +// python type declaration +PyTypeObject VideoFFmpegType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.VideoFFmpeg", /*tp_name*/ + sizeof(PyImage), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Image_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "FFmpeg video source", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + videoMethods, /* tp_methods */ + 0, /* tp_members */ + videoGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)VideoFFmpeg_init, /* tp_init */ + 0, /* tp_alloc */ + Image_allocNew, /* tp_new */ +}; + + + +#endif //WITH_FFMPEG + + diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h new file mode 100644 index 00000000000..7980e06686c --- /dev/null +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -0,0 +1,159 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexture library + +Copyright (c) 2007 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ +#if !defined VIDEOFFMPEG_H +#define VIDEOFFMPEG_H + +#ifdef WITH_FFMPEG +extern "C" { +#include +#include +#include +#include +} + +#if LIBAVFORMAT_VERSION_INT < (49 << 16) +#define FFMPEG_OLD_FRAME_RATE 1 +#else +#define FFMPEG_CODEC_IS_POINTER 1 +#endif + +#ifdef FFMPEG_CODEC_IS_POINTER +static inline AVCodecContext* get_codec_from_stream(AVStream* stream) +{ + return stream->codec; +} +#else +static inline AVCodecContext* get_codec_from_stream(AVStream* stream) +{ + return &stream->codec; +} +#endif + +#include "VideoBase.h" + + +// type VideoFFmpeg declaration +class VideoFFmpeg : public VideoBase +{ +public: + /// constructor + VideoFFmpeg (HRESULT * hRslt); + /// destructor + virtual ~VideoFFmpeg (); + + /// set initial parameters + void initParams (short width, short height, float rate); + /// open video file + virtual void openFile (char * file); + /// open video capture device + virtual void openCam (char * driver, short camIdx); + + /// release video source + virtual bool release (void); + + /// play video + virtual bool play (void); + /// stop/pause video + virtual bool stop (void); + + /// set play range + virtual void setRange (double start, double stop); + /// set frame rate + virtual void setFrameRate (float rate); + // some specific getters and setters + int getPreseek(void) { return m_preseek; } + void setPreseek(int preseek) { if (preseek >= 0) m_preseek = preseek; } + bool getDeinterlace(void) { return m_deinterlace; } + void setDeinterlace(bool deinterlace) { m_deinterlace = deinterlace; } + +protected: + + // format and codec information + AVCodec *m_codec; + AVFormatContext *m_formatCtx; + AVCodecContext *m_codecCtx; + // raw frame extracted from video file + AVFrame *m_frame; + // deinterlaced frame if codec requires it + AVFrame *m_frameDeinterlaced; + // decoded RGB24 frame if codec requires it + AVFrame *m_frameBGR; + // conversion from raw to RGB is done with sws_scale + struct SwsContext *m_imgConvertCtx; + // should the codec be deinterlaced? + bool m_deinterlace; + // number of frame of preseek + int m_preseek; + // order number of stream holding the video in format context + int m_videoStream; + + // the actual frame rate + double m_baseFrameRate; + + /// last displayed frame + long m_lastFrame; + + /// current file pointer position in file expressed in frame number + long m_curPosition; + + /// time of video play start + double m_startTime; + + /// width of capture in pixel + short m_captWidth; + + /// height of capture in pixel + short m_captHeight; + + /// frame rate of capture in frames per seconds + float m_captRate; + + /// image calculation + virtual void calcImage (unsigned int texId); + + /// load frame from video + void loadFrame (void); + + /// set actual position + void setPositions (void); + + /// get actual framerate + double actFrameRate (void) { return m_frameRate * m_baseFrameRate; } + + /// common function to video file and capture + int openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams); + + /// check if a frame is available and load it in pFrame, return true if a frame could be retrieved + bool grabFrame(long frame); + + /// return the frame in RGB24 format, the image data is found in AVFrame.data[0] + AVFrame* getFrame(void) { return m_frameBGR; } +}; + +inline VideoFFmpeg * getFFmpeg (PyImage * self) +{ + return static_cast(self->m_image); +} + +#endif //WITH_FFMPEG + +#endif diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp new file mode 100644 index 00000000000..0f15a26db2f --- /dev/null +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -0,0 +1,206 @@ +/* $Id$ +----------------------------------------------------------------------------- +This source file is part of VideoTexure library + +Copyright (c) 2006 The Zdeno Ash Miklas + +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU Lesser General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA, or go to +http://www.gnu.org/copyleft/lesser.txt. +----------------------------------------------------------------------------- +*/ + +#define PY_ARRAY_UNIQUE_SYMBOL numpyPtr + +#include + +#include + +#include + +#include + +//Old API +//#include "TexPlayer.h" +//#include "TexImage.h" +//#include "TexFrameBuff.h" + +//#include "TexPlayerGL.h" + +#include "ImageBase.h" +#include "FilterBase.h" +#include "Texture.h" + +#include "Exception.h" + + +// get material id +static PyObject * getMaterialID (PyObject *self, PyObject *args) +{ + // parameters - game object with video texture + PyObject * obj = NULL; + // material name + char * matName; + + // get parameters + if (!PyArg_ParseTuple(args, "Os", &obj, &matName)) + return NULL; + // get material id + short matID = getMaterialID(obj, matName); + // if material was not found, report errot + if (matID < 0) + { + PyErr_SetString(PyExc_RuntimeError, "object doesn't have material with given name"); + return NULL; + } + // return material ID + return Py_BuildValue("h", matID); +} + + +// get last error description +static PyObject * getLastError (PyObject *self, PyObject *args) +{ + return Py_BuildValue("s", Exception::m_lastError.c_str()); +} + +// set log file +static PyObject * setLogFile (PyObject *self, PyObject *args) +{ + // get parameters + if (!PyArg_ParseTuple(args, "s", &Exception::m_logFile)) + return Py_BuildValue("i", -1); + // log file was loaded + return Py_BuildValue("i", 0); +} + + +// function to initialize numpy structures +static bool initNumpy (void) +{ + // init module and report failure + import_array1(false); + // report success + return true; +} + +// image to numpy array +static PyObject * imageToArray (PyObject * self, PyObject *args) +{ + // parameter is Image object + PyObject * pyImg; + if (!PyArg_ParseTuple(args, "O", &pyImg) || !pyImageTypes.in(pyImg->ob_type)) + { + // if object is incorect, report error + PyErr_SetString(PyExc_TypeError, "The value must be a image source object"); + return NULL; + } + // get image structure + PyImage * img = reinterpret_cast(pyImg); + // check initialization of numpy interface, and initialize it if needed + if (numpyPtr == NULL && !initNumpy()) Py_RETURN_NONE; + // create array object + npy_intp dim[1]; + dim[0] = img->m_image->getBuffSize() / sizeof(unsigned int); + unsigned int * imgBuff = img->m_image->getImage(); + // if image is available, convert it to array + if (imgBuff != NULL) + return PyArray_SimpleNewFromData(1, dim, NPY_UBYTE, imgBuff); + // otherwise return None + Py_RETURN_NONE; +} + + +// metody modulu +static PyMethodDef moduleMethods[] = +{ + {"materialID", getMaterialID, METH_VARARGS, "Gets object's Blender Material ID"}, + {"getLastError", getLastError, METH_NOARGS, "Gets last error description"}, + {"setLogFile", setLogFile, METH_VARARGS, "Sets log file name"}, + {"imageToArray", imageToArray, METH_VARARGS, "get array from image source"}, + {NULL} /* Sentinel */ +}; + +#if WITH_FFMPEG +extern PyTypeObject VideoFFmpegType; +#endif +extern PyTypeObject FilterBlueScreenType; +extern PyTypeObject FilterGrayType; +extern PyTypeObject FilterColorType; +extern PyTypeObject FilterLevelType; +extern PyTypeObject FilterNormalType; +extern PyTypeObject FilterRGB24Type; +extern PyTypeObject FilterBGR24Type; +extern PyTypeObject ImageBuffType; +extern PyTypeObject ImageMixType; +extern PyTypeObject ImageRenderType; +extern PyTypeObject ImageViewportType; +extern PyTypeObject ImageViewportType; + + +static void registerAllTypes(void) +{ +#if WITH_FFMPEG + pyImageTypes.add(&VideoFFmpegType, "VideoFFmpeg"); +#endif + pyImageTypes.add(&ImageBuffType, "ImageBuff"); + pyImageTypes.add(&ImageMixType, "ImageMix"); + //pyImageTypes.add(&ImageRenderType, "ImageRender"); + pyImageTypes.add(&ImageViewportType, "ImageViewport"); + + pyFilterTypes.add(&FilterBlueScreenType, "FilterBlueScreen"); + pyFilterTypes.add(&FilterGrayType, "FilterGray"); + pyFilterTypes.add(&FilterColorType, "FilterColor"); + pyFilterTypes.add(&FilterLevelType, "FilterLevel"); + pyFilterTypes.add(&FilterNormalType, "FilterNormal"); + pyFilterTypes.add(&FilterRGB24Type, "FilterRGB24"); + pyFilterTypes.add(&FilterBGR24Type, "FilterBGR24"); +} + +PyObject* initVideoTexture(void) +{ + // initialize GL extensions + //bgl::InitExtensions(0); + + // prepare classes + registerAllTypes(); + + if (!pyImageTypes.ready()) + return NULL; + if (!pyFilterTypes.ready()) + return NULL; + if (PyType_Ready(&TextureType) < 0) + return NULL; + + PyObject * m = Py_InitModule4("VideoTexture", moduleMethods, + "Module that allows to play video files on textures in GameBlender.", + (PyObject*)NULL,PYTHON_API_VERSION); + if (m == NULL) + return NULL; + + // prepare numpy array + numpyPtr = NULL; + + // initialize classes + pyImageTypes.reg(m); + pyFilterTypes.reg(m); + + Py_INCREF(&TextureType); + PyModule_AddObject(m, "Texture", (PyObject*)&TextureType); + + // init last error description + Exception::m_lastError[0] = '\0'; + return m; +} + +// registration to Image types, put here because of silly linker bug -- cgit v1.2.3 From 48fb0edc7811a7018f4c78cc998eab3274f4e1e9 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Nov 2008 11:15:13 +0000 Subject: Fix Cmake for MSVC 32bit --- source/gameengine/VideoTexture/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt index fbae66e0ef4..1674602edd7 100644 --- a/source/gameengine/VideoTexture/CMakeLists.txt +++ b/source/gameengine/VideoTexture/CMakeLists.txt @@ -54,6 +54,7 @@ SET(INC IF(WITH_FFMPEG) SET(INC ${INC} ${FFMPEG_INC}) ADD_DEFINITIONS(-DWITH_FFMPEG) + ADD_DEFINITIONS(-D__STDC_CONSTANT_MACROS) ENDIF(WITH_FFMPEG) BLENDERLIB(bf_videotex "${SRC}" "${INC}") -- cgit v1.2.3 From 54401d36aadabe38decd9cd64f1385e1757bd303 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Nov 2008 12:48:46 +0000 Subject: BGE Video Texture: fix constant initializer problem with Exception description. Uniformized the line ending. --- source/gameengine/VideoTexture/Exception.cpp | 13 ++++++++++++- source/gameengine/VideoTexture/Exception.h | 15 +++++++++++++++ source/gameengine/VideoTexture/ImageMix.cpp | 4 ++-- source/gameengine/VideoTexture/ImageRender.cpp | 10 +++++++--- source/gameengine/VideoTexture/Texture.cpp | 4 ++-- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 2 +- source/gameengine/VideoTexture/blendVideoTex.cpp | 1 + 7 files changed, 40 insertions(+), 9 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index a326430b27a..c576cebddc8 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -44,7 +44,6 @@ ExpDesc errNFoundDesc (ErrNotFound, "Error description not found"); ExpDesc::ExpDesc (ExceptionID & exp, char * desc, RESULT hres) : m_expID(exp), m_hRslt(hres), m_description(desc) { - m_expDescs.push_back(this); } // destructor @@ -196,3 +195,15 @@ void Exception::copy (const Exception & xpt) m_fileName = xpt.m_fileName; m_line = xpt.m_line; } + +void registerAllExceptions(void) +{ + errGenerDesc.registerDesc(); + errNFoundDesc.registerDesc(); + MaterialNotAvailDesc.registerDesc(); + ImageSizesNotMatchDesc.registerDesc(); + SceneInvalidDesc.registerDesc(); + CameraInvalidDesc.registerDesc(); + SourceVideoEmptyDesc.registerDesc(); + SourceVideoCreationDesc.registerDesc(); +} diff --git a/source/gameengine/VideoTexture/Exception.h b/source/gameengine/VideoTexture/Exception.h index 85865fb3654..5345e87f199 100644 --- a/source/gameengine/VideoTexture/Exception.h +++ b/source/gameengine/VideoTexture/Exception.h @@ -27,6 +27,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include #include #include +#include #include "Common.h" @@ -117,6 +118,11 @@ public: desc = m_description; } + void registerDesc(void) + { + if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == m_expDescs.end()) + m_expDescs.push_back(this); + } // list of exception descriptions static std::vector m_expDescs; @@ -192,4 +198,13 @@ protected: }; +extern ExpDesc MaterialNotAvailDesc; +extern ExpDesc ImageSizesNotMatchDesc; +extern ExpDesc SceneInvalidDesc; +extern ExpDesc CameraInvalidDesc; +extern ExpDesc SourceVideoEmptyDesc; +extern ExpDesc SourceVideoCreationDesc; + + +void registerAllExceptions(void); #endif diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index 56503066161..71250005129 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -58,9 +58,9 @@ bool ImageMix::setWeight (const char * id, short weight) return true; } -static ExceptionID ImageSizesNotMatch; +ExceptionID ImageSizesNotMatch; -static ExpDesc ImageSizesNotMatchDesc (ImageSizesNotMatch, "Image sizes of sources are different"); +ExpDesc ImageSizesNotMatchDesc (ImageSizesNotMatch, "Image sizes of sources are different"); // calculate image from sources and set its availability void ImageMix::calcImage (unsigned int texId) diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index c800b92e71d..ce27a24d35a 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -94,6 +94,10 @@ void ImageRender::calcImage (unsigned int texId) ImageViewport::calcImage(texId); } +void ImageRender::Render() +{ + // +} // refresh lights void ImageRender::refreshLights (void) @@ -120,9 +124,9 @@ BlendType sceneType ("KX_Scene"); BlendType cameraType ("KX_Camera"); -static ExceptionID SceneInvalid, CameraInvalid; -static ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid"); -static ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid"); +ExceptionID SceneInvalid, CameraInvalid; +ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid"); +ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid"); // object initialization static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds) diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index d208802675c..243c5f31db0 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -165,8 +165,8 @@ void Texture_dealloc (Texture * self) } -static ExceptionID MaterialNotAvail; -static ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is not available"); +ExceptionID MaterialNotAvail; +ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is not available"); // Texture object initialization int Texture_init (Texture *self, PyObject *args, PyObject *kwds) diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index b12bad4b416..65bd5f4cbf4 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -265,7 +265,7 @@ void VideoFFmpeg::openCam (char * file, short camIdx) AVInputFormat *inputFormat; AVFormatParameters formatParams; AVRational frameRate; - char *p, filename[28], rateStr[20]; + char filename[28], rateStr[20]; do_init_ffmpeg(); diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 0f15a26db2f..d08762b1d7c 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -174,6 +174,7 @@ PyObject* initVideoTexture(void) // prepare classes registerAllTypes(); + registerAllExceptions(); if (!pyImageTypes.ready()) return NULL; -- cgit v1.2.3 From 00b02f055ae7e649d17ce6fc6a8dafe6138d3743 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 1 Nov 2008 14:00:16 +0000 Subject: Patch 17909: 2D Filter texture coordinates changes, by Dalai Felinto: * The second opengl texture coordinate (gl_TexCoord[1]) are now filled in as well, and will give canvas coordinates from 0.0 to 1.0. The first texture coordinates still give the coordinates in the texture that is being used, which may not match the canvas exactly, so both coordinates are needed. * Also optimization to allow using smaller texture sizes with multiple smaller viewports. * Print the detailed GLSL shader errors (once), for easier debugging. --- .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 179 +++++++++++++-------- source/gameengine/Rasterizer/RAS_2DFilterManager.h | 2 + 2 files changed, 110 insertions(+), 71 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 6e5553d4781..d2cfa7d07f9 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -78,6 +78,7 @@ numberoffilters(0) m_gameObjects[passindex] = NULL; } texname[0] = texname[1] = texname[2] = -1; + errorprinted= false; } RAS_2DFilterManager::~RAS_2DFilterManager() @@ -85,76 +86,107 @@ RAS_2DFilterManager::~RAS_2DFilterManager() FreeTextures(); } +void RAS_2DFilterManager::PrintShaderErrors(unsigned int shader, const char *task, const char *code) +{ + GLcharARB log[5000]; + GLsizei length = 0; + const char *c, *pos, *end; + int line = 1; + + if(errorprinted) + return; + + errorprinted= true; + + glGetInfoLogARB(shader, sizeof(log), &length, log); + end = code + strlen(code); + + printf("2D Filter GLSL Shader: %s error:\n", task); + + c = code; + while ((c < end) && (pos = strchr(c, '\n'))) { + printf("%2d ", line); + fwrite(c, (pos+1)-c, 1, stdout); + c = pos+1; + line++; + } + printf("%s", c); + + printf("%s\n", log); +} + unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource) { - GLuint program = 0; - GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); - GLint success; + GLuint program = 0; + GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER); + GLint success; - glShaderSourceARB(fShader, 1, (const char**)&shadersource, NULL); + glShaderSourceARB(fShader, 1, (const char**)&shadersource, NULL); - glCompileShaderARB(fShader); + glCompileShaderARB(fShader); - glGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success); - if(!success) - { - /*Shader Comile Error*/ - std::cout << "2dFilters - Shader compile error" << std::endl; - return 0; - } - - program = glCreateProgramObjectARB(); - glAttachObjectARB(program, fShader); - glLinkProgramARB(program); - glGetObjectParameterivARB(program, GL_LINK_STATUS, &success); - if (!success) - { - /*Program Link Error*/ - std::cout << "2dFilters - Shader program link error" << std::endl; - return 0; - } - - glValidateProgramARB(program); - glGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success); - if (!success) - { - /*Program Validation Error*/ - std::cout << "2dFilters - Shader program validation error" << std::endl; - return 0; - } + glGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success); + if(!success) + { + /*Shader Comile Error*/ + PrintShaderErrors(fShader, "compile", shadersource); + return 0; + } + + program = glCreateProgramObjectARB(); + glAttachObjectARB(program, fShader); + + glLinkProgramARB(program); + glGetObjectParameterivARB(program, GL_LINK_STATUS, &success); + if (!success) + { + /*Program Link Error*/ + PrintShaderErrors(fShader, "link", shadersource); + return 0; + } + + glValidateProgramARB(program); + glGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success); + if (!success) + { + /*Program Validation Error*/ + PrintShaderErrors(fShader, "validate", shadersource); + return 0; + } - return program; + return program; } unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) { - switch(filtermode) - { - case RAS_2DFILTER_BLUR: - return CreateShaderProgram(BlurFragmentShader); - case RAS_2DFILTER_SHARPEN: - return CreateShaderProgram(SharpenFragmentShader); - case RAS_2DFILTER_DILATION: - return CreateShaderProgram(DilationFragmentShader); - case RAS_2DFILTER_EROSION: - return CreateShaderProgram(ErosionFragmentShader); - case RAS_2DFILTER_LAPLACIAN: - return CreateShaderProgram(LaplacionFragmentShader); - case RAS_2DFILTER_SOBEL: - return CreateShaderProgram(SobelFragmentShader); - case RAS_2DFILTER_PREWITT: - return CreateShaderProgram(PrewittFragmentShader); - case RAS_2DFILTER_GRAYSCALE: - return CreateShaderProgram(GrayScaleFragmentShader); - case RAS_2DFILTER_SEPIA: - return CreateShaderProgram(SepiaFragmentShader); - case RAS_2DFILTER_INVERT: - return CreateShaderProgram(InvertFragmentShader); - } - return 0; + switch(filtermode) + { + case RAS_2DFILTER_BLUR: + return CreateShaderProgram(BlurFragmentShader); + case RAS_2DFILTER_SHARPEN: + return CreateShaderProgram(SharpenFragmentShader); + case RAS_2DFILTER_DILATION: + return CreateShaderProgram(DilationFragmentShader); + case RAS_2DFILTER_EROSION: + return CreateShaderProgram(ErosionFragmentShader); + case RAS_2DFILTER_LAPLACIAN: + return CreateShaderProgram(LaplacionFragmentShader); + case RAS_2DFILTER_SOBEL: + return CreateShaderProgram(SobelFragmentShader); + case RAS_2DFILTER_PREWITT: + return CreateShaderProgram(PrewittFragmentShader); + case RAS_2DFILTER_GRAYSCALE: + return CreateShaderProgram(GrayScaleFragmentShader); + case RAS_2DFILTER_SEPIA: + return CreateShaderProgram(SepiaFragmentShader); + case RAS_2DFILTER_INVERT: + return CreateShaderProgram(InvertFragmentShader); + } + return 0; } -void RAS_2DFilterManager::AnalyseShader(int passindex, vector& propNames) + +void RAS_2DFilterManager::AnalyseShader(int passindex, vector& propNames) { texflag[passindex] = 0; if(glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture") != -1) @@ -249,11 +281,11 @@ void RAS_2DFilterManager::EndShaderProgram() void RAS_2DFilterManager::FreeTextures() { - if(texname[0]!=-1) + if(texname[0]!=(unsigned int)-1) glDeleteTextures(1, (GLuint*)&texname[0]); - if(texname[1]!=-1) + if(texname[1]!=(unsigned int)-1) glDeleteTextures(1, (GLuint*)&texname[1]); - if(texname[2]!=-1) + if(texname[2]!=(unsigned int)-1) glDeleteTextures(1, (GLuint*)&texname[2]); } @@ -300,8 +332,8 @@ void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas) RAS_Rect canvas_rect = canvas->GetWindowArea(); canvaswidth = canvas->GetWidth(); canvasheight = canvas->GetHeight(); - texturewidth = canvaswidth + canvas_rect.GetLeft(); - textureheight = canvasheight + canvas_rect.GetBottom(); + texturewidth = canvaswidth; + textureheight = canvasheight; GLint i,j; i = 0; @@ -365,17 +397,17 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) if(need_depth){ glActiveTextureARB(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texname[1]); - glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, 0, 0, texturewidth,textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, viewport[0], viewport[1], texturewidth,textureheight, 0); } if(need_luminance){ glActiveTextureARB(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, texname[2]); - glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0, 0 , texturewidth,textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, viewport[0], viewport[1] , texturewidth,textureheight, 0); } glGetIntegerv(GL_VIEWPORT,(GLint *)viewport); - glViewport(0,0, texturewidth, textureheight); + glViewport(viewport[0],viewport[1], texturewidth, textureheight); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_TEXTURE); @@ -393,15 +425,20 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glActiveTextureARB(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texname[0]); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, texturewidth, textureheight, 0); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, viewport[0], viewport[1], texturewidth, textureheight, 0); glClear(GL_COLOR_BUFFER_BIT); + float canvascoordx, canvascoordy; + + canvascoordx = (GLfloat) texturewidth / canvaswidth; + canvascoordy = (GLfloat) textureheight / canvasheight; + glBegin(GL_QUADS); glColor4f(1.f, 1.f, 1.f, 1.f); - glTexCoord2f(1.0, 1.0); glVertex2f(1,1); - glTexCoord2f(0.0, 1.0); glVertex2f(-1,1); - glTexCoord2f(0.0, 0.0); glVertex2f(-1,-1); - glTexCoord2f(1.0, 0.0); glVertex2f(1,-1); + glTexCoord2f(1.0, 1.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, canvascoordx, canvascoordy); glVertex2f(1,1); + glTexCoord2f(0.0, 1.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, canvascoordy); glVertex2f(-1,1); + glTexCoord2f(0.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0); glVertex2f(-1,-1); + glTexCoord2f(1.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, canvascoordx, 0.0); glVertex2f(1,-1); glEnd(); } } diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h index c16bd41dd0e..454643a5077 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.h +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h @@ -38,6 +38,7 @@ private: void AnalyseShader(int passindex, vector& propNames); void StartShaderProgram(int passindex); void EndShaderProgram(); + void PrintShaderErrors(unsigned int shader, const char *task, const char *code); void SetupTextures(bool depth, bool luminance); void FreeTextures(); @@ -58,6 +59,7 @@ private: short texflag[MAX_RENDER_PASS]; bool isshadersupported; + bool errorprinted; unsigned int m_filters[MAX_RENDER_PASS]; short m_enabled[MAX_RENDER_PASS]; -- cgit v1.2.3 From bd81d96b78bf0b53128d13ac8655a0397405e403 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Nov 2008 15:58:49 +0000 Subject: Video Texture: missing newlines at the end of several files. --- source/gameengine/VideoTexture/FilterBase.h | 2 +- source/gameengine/VideoTexture/FilterBlueScreen.h | 2 +- source/gameengine/VideoTexture/FilterColor.h | 2 +- source/gameengine/VideoTexture/FilterNormal.h | 2 +- source/gameengine/VideoTexture/FilterSource.h | 2 +- source/gameengine/VideoTexture/ImageBase.cpp | 2 +- source/gameengine/VideoTexture/ImageBase.h | 2 +- source/gameengine/VideoTexture/PyTypeList.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h index fa6f9a754d4..1c9a2b46927 100644 --- a/source/gameengine/VideoTexture/FilterBase.h +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -129,4 +129,4 @@ PyObject * Filter_getPrevious (PyFilter * self, void * closure); int Filter_setPrevious (PyFilter * self, PyObject * value, void * closure); -#endif \ No newline at end of file +#endif diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.h b/source/gameengine/VideoTexture/FilterBlueScreen.h index 1871fbc0516..20660804f78 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.h +++ b/source/gameengine/VideoTexture/FilterBlueScreen.h @@ -95,4 +95,4 @@ protected: }; -#endif \ No newline at end of file +#endif diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h index 4465df97340..ae2e98fa942 100644 --- a/source/gameengine/VideoTexture/FilterColor.h +++ b/source/gameengine/VideoTexture/FilterColor.h @@ -161,4 +161,4 @@ protected: }; -#endif \ No newline at end of file +#endif diff --git a/source/gameengine/VideoTexture/FilterNormal.h b/source/gameengine/VideoTexture/FilterNormal.h index fa61f04c0b7..ec51ca39db9 100644 --- a/source/gameengine/VideoTexture/FilterNormal.h +++ b/source/gameengine/VideoTexture/FilterNormal.h @@ -95,4 +95,4 @@ protected: }; -#endif \ No newline at end of file +#endif diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h index b18186210dc..7bed5c77a4d 100644 --- a/source/gameengine/VideoTexture/FilterSource.h +++ b/source/gameengine/VideoTexture/FilterSource.h @@ -230,4 +230,4 @@ protected: }; -#endif \ No newline at end of file +#endif diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index 28e7ad49224..d2e980d979a 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -526,4 +526,4 @@ int Image_setFilter (PyImage * self, PyObject * value, void * closure) } // return success return 0; -} \ No newline at end of file +} diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h index 817223c3d31..2b923a06ee3 100644 --- a/source/gameengine/VideoTexture/ImageBase.h +++ b/source/gameengine/VideoTexture/ImageBase.h @@ -346,4 +346,4 @@ PyObject * Image_getFilter (PyImage * self, void * closure); int Image_setFilter (PyImage * self, PyObject * value, void * closure); -#endif \ No newline at end of file +#endif diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h index 7069cf8bb43..736fc9aaefd 100644 --- a/source/gameengine/VideoTexture/PyTypeList.h +++ b/source/gameengine/VideoTexture/PyTypeList.h @@ -82,4 +82,4 @@ protected: }; -#endif \ No newline at end of file +#endif -- cgit v1.2.3 From 58d0dc21aa853ee9b6c70547c06ae64739a9f4b5 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sat, 1 Nov 2008 17:06:36 +0000 Subject: Getting video texture closer to compiling under linux --- source/gameengine/VideoTexture/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript index e0972e045cc..f3fe0dab6ad 100644 --- a/source/gameengine/VideoTexture/SConscript +++ b/source/gameengine/VideoTexture/SConscript @@ -20,7 +20,6 @@ defs = '' if env['OURPLATFORM'] == 'win32-vc': cflags.append('/GR') cflags.append('/Ox') - defs += ' __STDC_CONSTANT_MACROS' incs += ' ' + env['BF_PYTHON_INC'] #incs += ' ' + env['BF_OPENGL_INC'] @@ -28,5 +27,6 @@ incs += ' ' + env['BF_PYTHON_INC'] if env['WITH_BF_FFMPEG']: defs += ' WITH_FFMPEG' incs += ' ' + env['BF_FFMPEG_INC'] + defs += ' __STDC_CONSTANT_MACROS' env.BlenderLib ( 'bf_videotex', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[25, 72], compileflags = cflags ) -- cgit v1.2.3 From e6a2ab319f10fa318aa4d9b4e7c5cef0fd95dc87 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Nov 2008 17:15:17 +0000 Subject: VideoTexture: AVFormatContext::pb is not a pointer for avformat library older than 52 (linux uses 51) --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 10 ++++++++-- source/gameengine/VideoTexture/VideoFFmpeg.h | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 65bd5f4cbf4..19e10cf02f8 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -248,7 +248,13 @@ void VideoFFmpeg::openFile (char * filename) // open base class VideoBase::openFile(filename); - if (m_formatCtx->pb->is_streamed) + if ( +#ifdef FFMPEG_PB_IS_POINTER + m_formatCtx->pb->is_streamed +#else + m_formatCtx->pb.is_streamed +#endif + ) { // the file is in fact a streaming source, prevent seeking m_isFile = false; @@ -265,7 +271,7 @@ void VideoFFmpeg::openCam (char * file, short camIdx) AVInputFormat *inputFormat; AVFormatParameters formatParams; AVRational frameRate; - char filename[28], rateStr[20]; + char *p, filename[28], rateStr[20]; do_init_ffmpeg(); diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index 7980e06686c..4720bef1841 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -36,6 +36,10 @@ 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) { -- cgit v1.2.3 From 19cdef1f71ca862254d10ae33500dc24c35d2477 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Nov 2008 17:26:34 +0000 Subject: VideoTexture: typo in linux code --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 19e10cf02f8..272d2695c4b 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -319,7 +319,7 @@ void VideoFFmpeg::openCam (char * file, short camIdx) if ((p = strchr(filename, ':')) != 0) *p = 0; } - if (file && (p = strchr(file, ":")) != NULL) + if (file && (p = strchr(file, ':')) != NULL) formatParams.standard = p+1; #endif //frame rate -- cgit v1.2.3 From b24c6ef70d4c6aa5b4e8539362eaa826b86343e2 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sat, 1 Nov 2008 17:44:12 +0000 Subject: Adding include path for numpy to sconscript. There must be a better way to do this. --- source/gameengine/VideoTexture/SConscript | 1 + 1 file changed, 1 insertion(+) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript index f3fe0dab6ad..bf8d7c133ff 100644 --- a/source/gameengine/VideoTexture/SConscript +++ b/source/gameengine/VideoTexture/SConscript @@ -21,6 +21,7 @@ if env['OURPLATFORM'] == 'win32-vc': cflags.append('/GR') cflags.append('/Ox') +incs += ' ' + env['BF_PYTHON'] + '/lib/python' + env['BF_PYTHON_VERSION'] + "/site-packages/numpy/core/include" incs += ' ' + env['BF_PYTHON_INC'] #incs += ' ' + env['BF_OPENGL_INC'] -- cgit v1.2.3 From e72d6c7bfaee29c0a1c360237299484ca5caaeb7 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Nov 2008 20:18:15 +0000 Subject: VideoTexture: fix NULL pointer crash when material name is not found. --- source/gameengine/VideoTexture/Texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 243c5f31db0..ea3f60b2775 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -96,7 +96,7 @@ RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID) // get material from mesh RAS_MeshObject * mesh = gameObj->GetMesh(0); RAS_MeshMaterial *meshMat = mesh->GetMeshMaterial(matID); - if (meshMat->m_bucket != NULL) + if (meshMat != NULL && meshMat->m_bucket != NULL) // return pointer to polygon or blender material return meshMat->m_bucket->GetPolyMaterial(); } -- cgit v1.2.3 From 68f50e0c6b147d9603d151d99f5085c09c0ce039 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sat, 1 Nov 2008 22:28:27 +0000 Subject: VideoTexture: remove numpy dependency. --- source/gameengine/VideoTexture/blendVideoTex.cpp | 25 ++++-------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index d08762b1d7c..7f55024fe4c 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -20,16 +20,12 @@ http://www.gnu.org/copyleft/lesser.txt. ----------------------------------------------------------------------------- */ -#define PY_ARRAY_UNIQUE_SYMBOL numpyPtr - #include #include #include -#include - //Old API //#include "TexPlayer.h" //#include "TexImage.h" @@ -85,15 +81,6 @@ static PyObject * setLogFile (PyObject *self, PyObject *args) } -// function to initialize numpy structures -static bool initNumpy (void) -{ - // init module and report failure - import_array1(false); - // report success - return true; -} - // image to numpy array static PyObject * imageToArray (PyObject * self, PyObject *args) { @@ -107,15 +94,14 @@ static PyObject * imageToArray (PyObject * self, PyObject *args) } // get image structure PyImage * img = reinterpret_cast(pyImg); - // check initialization of numpy interface, and initialize it if needed - if (numpyPtr == NULL && !initNumpy()) Py_RETURN_NONE; // create array object - npy_intp dim[1]; - dim[0] = img->m_image->getBuffSize() / sizeof(unsigned int); unsigned int * imgBuff = img->m_image->getImage(); // if image is available, convert it to array if (imgBuff != NULL) - return PyArray_SimpleNewFromData(1, dim, NPY_UBYTE, imgBuff); + // Nasty problem here: the image buffer is an array of integers + // in the processor endian format. The user must take care of that in the script. + // Need to find an elegant solution to this problem + return Py_BuildValue("s#", imgBuff, img->m_image->getBuffSize()); // otherwise return None Py_RETURN_NONE; } @@ -189,9 +175,6 @@ PyObject* initVideoTexture(void) if (m == NULL) return NULL; - // prepare numpy array - numpyPtr = NULL; - // initialize classes pyImageTypes.reg(m); pyFilterTypes.reg(m); -- cgit v1.2.3 From 12b2f1c83c09ff75cf0987909f23523a071922a7 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Sun, 2 Nov 2008 14:36:32 +0000 Subject: Include path for numpy no longer needed. --- source/gameengine/VideoTexture/SConscript | 1 - 1 file changed, 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript index bf8d7c133ff..f3fe0dab6ad 100644 --- a/source/gameengine/VideoTexture/SConscript +++ b/source/gameengine/VideoTexture/SConscript @@ -21,7 +21,6 @@ if env['OURPLATFORM'] == 'win32-vc': cflags.append('/GR') cflags.append('/Ox') -incs += ' ' + env['BF_PYTHON'] + '/lib/python' + env['BF_PYTHON_VERSION'] + "/site-packages/numpy/core/include" incs += ' ' + env['BF_PYTHON_INC'] #incs += ' ' + env['BF_OPENGL_INC'] -- cgit v1.2.3 From 2973bd8ea27c83274669051297ee470723dfcf9d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 2 Nov 2008 18:02:31 +0000 Subject: VideoTexture: use PyObjectPlus.h instead of Python.h for compatibility with Python2.3 --- source/gameengine/VideoTexture/Exception.cpp | 2 +- source/gameengine/VideoTexture/FilterBase.cpp | 2 +- source/gameengine/VideoTexture/FilterBase.h | 2 +- source/gameengine/VideoTexture/FilterBlueScreen.cpp | 2 +- source/gameengine/VideoTexture/FilterColor.cpp | 2 +- source/gameengine/VideoTexture/FilterNormal.cpp | 2 +- source/gameengine/VideoTexture/FilterSource.cpp | 2 +- source/gameengine/VideoTexture/FilterSource.h | 2 -- source/gameengine/VideoTexture/ImageBase.cpp | 2 +- source/gameengine/VideoTexture/ImageBase.h | 2 +- source/gameengine/VideoTexture/ImageBuff.cpp | 2 +- source/gameengine/VideoTexture/ImageMix.cpp | 2 +- source/gameengine/VideoTexture/ImageRender.cpp | 2 +- source/gameengine/VideoTexture/ImageViewport.cpp | 2 +- source/gameengine/VideoTexture/PyTypeList.cpp | 2 +- source/gameengine/VideoTexture/PyTypeList.h | 2 +- source/gameengine/VideoTexture/Texture.cpp | 2 +- source/gameengine/VideoTexture/Texture.h | 2 +- source/gameengine/VideoTexture/VideoBase.h | 2 +- source/gameengine/VideoTexture/blendVideoTex.cpp | 2 +- 20 files changed, 19 insertions(+), 21 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index c576cebddc8..3ac8b8e321d 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include #include -#include +#include #include "Exception.h" diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp index 078a096aff7..b0112cd355b 100644 --- a/source/gameengine/VideoTexture/FilterBase.cpp +++ b/source/gameengine/VideoTexture/FilterBase.cpp @@ -22,7 +22,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "FilterBase.h" -#include +#include #include diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h index 1c9a2b46927..c530e385ada 100644 --- a/source/gameengine/VideoTexture/FilterBase.h +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -25,7 +25,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Common.h" -#include +#include #include "PyTypeList.h" diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp index d911b1d7743..50c3a87ffc4 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp +++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp @@ -21,7 +21,7 @@ http://www.gnu.org/copyleft/lesser.txt. */ -#include +#include #include #include "FilterBlueScreen.h" diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp index c45804caf9d..a1ddf581aef 100644 --- a/source/gameengine/VideoTexture/FilterColor.cpp +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -21,7 +21,7 @@ http://www.gnu.org/copyleft/lesser.txt. */ -#include +#include #include #include "FilterColor.h" diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index 5eeb63b7128..514214bec8b 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -21,7 +21,7 @@ http://www.gnu.org/copyleft/lesser.txt. */ -#include +#include #include #include "FilterNormal.h" diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp index 4b96a9792e2..8d8749dbc8f 100644 --- a/source/gameengine/VideoTexture/FilterSource.cpp +++ b/source/gameengine/VideoTexture/FilterSource.cpp @@ -22,7 +22,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include +#include #include #include "FilterSource.h" diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h index 7bed5c77a4d..c3d4e0079f9 100644 --- a/source/gameengine/VideoTexture/FilterSource.h +++ b/source/gameengine/VideoTexture/FilterSource.h @@ -47,7 +47,6 @@ protected: { return 0xFF000000 | src[0] << 16 | src[1] << 8 | src[2]; } }; - /// class for BGR24 conversion class FilterBGR24 : public FilterBase { @@ -67,7 +66,6 @@ protected: { return 0xFF000000 | src[2] << 16 | src[1] << 8 | src[0]; } }; - /// class for YV12 conversion class FilterYV12 : public FilterBase { diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index d2e980d979a..dcca20de24a 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -25,7 +25,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include #include -#include +#include #include #include "FilterBase.h" diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h index 2b923a06ee3..138580ce701 100644 --- a/source/gameengine/VideoTexture/ImageBase.h +++ b/source/gameengine/VideoTexture/ImageBase.h @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Common.h" #include -#include +#include #include "PyTypeList.h" diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index f09514a36f0..a0c6e1f6f74 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -22,7 +22,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include +#include #include #include "ImageBuff.h" diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index 71250005129..8532249f7d8 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -22,7 +22,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include +#include #include #include "ImageMix.h" diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index ce27a24d35a..fb284261d70 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -22,7 +22,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include +#include #include #include diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index e1d3316a43e..e2b4e469e80 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -22,7 +22,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include +#include #include #include "ImageViewport.h" diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp index b8c40052e81..0451d74c8ad 100644 --- a/source/gameengine/VideoTexture/PyTypeList.cpp +++ b/source/gameengine/VideoTexture/PyTypeList.cpp @@ -26,7 +26,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include #include -#include +#include /// check, if type is in list diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h index 736fc9aaefd..4daf88bfa19 100644 --- a/source/gameengine/VideoTexture/PyTypeList.h +++ b/source/gameengine/VideoTexture/PyTypeList.h @@ -28,7 +28,7 @@ http://www.gnu.org/copyleft/lesser.txt. #include #include -#include +#include // forward declaration class PyTypeListItem; diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index ea3f60b2775..ceda39aeff4 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -22,7 +22,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation -#include +#include #include #include diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index f19f8da607d..569e34da121 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -23,7 +23,7 @@ http://www.gnu.org/copyleft/lesser.txt. #if !defined TEXTURE_H #define TEXTURE_H -#include +#include #include #include diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h index 78e8ba65909..5bb635e1f19 100644 --- a/source/gameengine/VideoTexture/VideoBase.h +++ b/source/gameengine/VideoTexture/VideoBase.h @@ -24,7 +24,7 @@ http://www.gnu.org/copyleft/lesser.txt. #define VIDEOBASE_H -#include +#include #include "ImageBase.h" diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 7f55024fe4c..629b589c0e6 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -20,7 +20,7 @@ http://www.gnu.org/copyleft/lesser.txt. ----------------------------------------------------------------------------- */ -#include +#include #include -- cgit v1.2.3 From db24487449b1340eed2f29394fdbcdf2e7acc3ea Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 2 Nov 2008 18:12:45 +0000 Subject: Makefile fixes for compiling with new videotexture code. Also: buttons for logic, controllers, didn't line up correct when multiple objects were selected (too little space) --- source/gameengine/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Makefile b/source/gameengine/Makefile index 1d3bc8c2058..51bc0f7d39f 100644 --- a/source/gameengine/Makefile +++ b/source/gameengine/Makefile @@ -35,7 +35,7 @@ DIR = $(OCGDIR)/gameengine DIRS = BlenderRoutines DIRS += Converter DIRS += Expressions GameLogic Ketsji Rasterizer SceneGraph -DIRS += Network Physics +DIRS += Network Physics VideoTexture ifeq ($(WITH_BF_BLENDERGAMEENGINE),true) DIRS += GamePlayer -- cgit v1.2.3 From 7d63f5a7fe7378f9bea9e39282828f74bba47287 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 2 Nov 2008 18:31:54 +0000 Subject: VideoTexture: fix compile error with GLint in ImageViewport under osx. --- source/gameengine/VideoTexture/ImageViewport.cpp | 11 +++++------ source/gameengine/VideoTexture/ImageViewport.h | 12 ++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index e2b4e469e80..59995198ba1 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -25,13 +25,12 @@ http://www.gnu.org/copyleft/lesser.txt. #include #include -#include "ImageViewport.h" - #include #include "Texture.h" #include "ImageBase.h" #include "FilterSource.h" +#include "ImageViewport.h" // constructor @@ -81,7 +80,7 @@ void ImageViewport::setCaptureSize (short * size) if (size[idx] < 1) m_capSize[idx] = 1; else if (size[idx] > getViewportSize()[idx]) - m_capSize[idx] = getViewportSize()[idx]; + m_capSize[idx] = short(getViewportSize()[idx]); else m_capSize[idx] = size[idx]; } @@ -91,7 +90,7 @@ void ImageViewport::setCaptureSize (short * size) } // set position of capture rectangle -void ImageViewport::setPosition (int * pos) +void ImageViewport::setPosition (GLint * pos) { // if new position is not provided, use existing position if (pos == NULL) pos = m_position; @@ -125,7 +124,7 @@ void ImageViewport::calcImage (unsigned int texId) { // just copy current viewport to texture glBindTexture(GL_TEXTURE_2D, texId); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], m_capSize[0], m_capSize[1]); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1]); // image is not available m_avail = false; } @@ -133,7 +132,7 @@ void ImageViewport::calcImage (unsigned int texId) else if (!m_avail) { // get frame buffer data - glReadPixels(m_upLeft[0], m_upLeft[1], m_capSize[0], m_capSize[1], GL_RGB, + glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB, GL_UNSIGNED_BYTE, m_viewportImage); // filter loaded data FilterBGR24 filt; diff --git a/source/gameengine/VideoTexture/ImageViewport.h b/source/gameengine/VideoTexture/ImageViewport.h index 9fd3aeb7ba9..4265906b8f5 100644 --- a/source/gameengine/VideoTexture/ImageViewport.h +++ b/source/gameengine/VideoTexture/ImageViewport.h @@ -49,13 +49,13 @@ public: void setCaptureSize (short * size = NULL); /// get position in viewport - int * getPosition (void) { return m_position; } + GLint * getPosition (void) { return m_position; } /// set position in viewport - void setPosition (int * pos = NULL); + void setPosition (GLint * pos = NULL); protected: /// frame buffer rectangle - int m_viewport[4]; + GLint m_viewport[4]; /// size of captured area short m_capSize[2]; @@ -63,9 +63,9 @@ protected: bool m_whole; /// position of capture rectangle in viewport - int m_position[2]; + GLint m_position[2]; /// upper left point for capturing - int m_upLeft[2]; + GLint m_upLeft[2]; /// buffer to copy viewport BYTE * m_viewportImage; @@ -76,7 +76,7 @@ protected: virtual void calcImage (unsigned int texId); /// get viewport size - int * getViewportSize (void) { return m_viewport + 2; } + GLint * getViewportSize (void) { return m_viewport + 2; } }; -- cgit v1.2.3 From 17296efd62ff37f0f6f5ae812c3009baaa2c54a1 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 2 Nov 2008 18:41:24 +0000 Subject: VideoTexture: fix compile error with GLint in ImageViewport under osx, part 2 --- source/gameengine/VideoTexture/ImageViewport.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 59995198ba1..4ed1cd9e801 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -192,9 +192,9 @@ static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * c return -1; } // set position - int pos [] = { - int(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))), - int(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))) + GLint pos [] = { + GLint(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))), + GLint(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))) }; getImageViewport(self)->setPosition(pos); // success -- cgit v1.2.3 From b7fdf2ab50ef285fc88cb8a9bf6e39bf27a0ec75 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 3 Nov 2008 23:35:41 +0000 Subject: Add's GSR's INT64_C fix and removes dos line endings... Kent --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 272d2695c4b..2af7228a192 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -20,6 +20,11 @@ http://www.gnu.org/copyleft/lesser.txt. ----------------------------------------------------------------------------- */ +// INT64_C fix for some linux machines (C99ism) +#define __STDC_CONSTANT_MACROS +#include + + #include "MEM_guardedalloc.h" #include "PIL_time.h" -- cgit v1.2.3 From 6eb3bf53dd753d4b00f0f76f9f7739aecb9af2f8 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 4 Nov 2008 09:21:27 +0000 Subject: VideoTexture: Bug report #17946: add (char*) casting to fix compile error with Python get-set method and module object. --- .../gameengine/VideoTexture/FilterBlueScreen.cpp | 6 +++--- source/gameengine/VideoTexture/FilterColor.cpp | 10 +++++----- source/gameengine/VideoTexture/FilterNormal.cpp | 6 +++--- source/gameengine/VideoTexture/ImageBuff.cpp | 10 +++++----- source/gameengine/VideoTexture/ImageMix.cpp | 10 +++++----- source/gameengine/VideoTexture/ImageRender.cpp | 12 ++++++------ source/gameengine/VideoTexture/ImageViewport.cpp | 16 ++++++++-------- source/gameengine/VideoTexture/PyTypeList.cpp | 2 +- source/gameengine/VideoTexture/Texture.cpp | 4 ++-- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 22 +++++++++++----------- source/gameengine/VideoTexture/blendVideoTex.cpp | 2 +- 11 files changed, 50 insertions(+), 50 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp index 50c3a87ffc4..43d7566102a 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.cpp +++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp @@ -125,10 +125,10 @@ static int setLimits (PyFilter * self, PyObject * value, void * closure) // attributes structure static PyGetSetDef filterBSGetSets[] = { - {"color", (getter)getColor, (setter)setColor, "blue screen color", NULL}, - {"limits", (getter)getLimits, (setter)setLimits, "blue screen color limits", NULL}, + {(char*)"color", (getter)getColor, (setter)setColor, (char*)"blue screen color", NULL}, + {(char*)"limits", (getter)getLimits, (setter)setLimits, (char*)"blue screen color limits", NULL}, // attributes from FilterBase class - {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp index a1ddf581aef..eaf6e955003 100644 --- a/source/gameengine/VideoTexture/FilterColor.cpp +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -34,7 +34,7 @@ http://www.gnu.org/copyleft/lesser.txt. // attributes structure static PyGetSetDef filterGrayGetSets[] = { // attributes from FilterBase class - {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL}, {NULL} }; @@ -164,9 +164,9 @@ static int setMatrix (PyFilter * self, PyObject * value, void * closure) // attributes structure static PyGetSetDef filterColorGetSets[] = { - {"matrix", (getter)getMatrix, (setter)setMatrix, "matrix [4][5] for color calculation", NULL}, + {(char*)"matrix", (getter)getMatrix, (setter)setMatrix, (char*)"matrix [4][5] for color calculation", NULL}, // attributes from FilterBase class - {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL}, {NULL} }; @@ -298,9 +298,9 @@ static int setLevels (PyFilter * self, PyObject * value, void * closure) // attributes structure static PyGetSetDef filterLevelGetSets[] = { - {"levels", (getter)getLevels, (setter)setLevels, "levels matrix [4] (min, max)", NULL}, + {(char*)"levels", (getter)getLevels, (setter)setLevels, (char*)"levels matrix [4] (min, max)", NULL}, // attributes from FilterBase class - {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index 514214bec8b..736b9e3b958 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -109,10 +109,10 @@ static int setDepth (PyFilter * self, PyObject * value, void * closure) // attributes structure static PyGetSetDef filterNormalGetSets[] = { - {"colorIdx", (getter)getColor, (setter)setColor, "index of color used to calculate normal (0 - red, 1 - green, 2 - blue)", NULL}, - {"depth", (getter)getDepth, (setter)setDepth, "depth of relief", NULL}, + {(char*)"colorIdx", (getter)getColor, (setter)setColor, (char*)"index of color used to calculate normal (0 - red, 1 - green, 2 - blue)", NULL}, + {(char*)"depth", (getter)getDepth, (setter)setDepth, (char*)"depth of relief", NULL}, // attributes from FilterBase class - {"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, "previous pixel filter", NULL}, + {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index a0c6e1f6f74..a22757dca39 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -111,11 +111,11 @@ static PyMethodDef imageBuffMethods[] = // attributes structure static PyGetSetDef imageBuffGetSets[] = { // attributes from ImageBase class - {"image", (getter)Image_getImage, NULL, "image data", NULL}, - {"size", (getter)Image_getSize, NULL, "image size", NULL}, - {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, - {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, - {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL}, + {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, + {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL}, + {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index 8532249f7d8..b07b362818c 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -150,11 +150,11 @@ static PyMethodDef imageMixMethods[] = // attributes structure static PyGetSetDef imageMixGetSets[] = { // attributes from ImageBase class - {"image", (getter)Image_getImage, NULL, "image data", NULL}, - {"size", (getter)Image_getSize, NULL, "image size", NULL}, - {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, - {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, - {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL}, + {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, + {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL}, + {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index fb284261d70..2f2d9debd48 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -207,13 +207,13 @@ static PyMethodDef imageRenderMethods[] = // attributes structure static PyGetSetDef imageRenderGetSets[] = { - {"background", (getter)getBackground, (setter)setBackground, "background color", NULL}, + {(char*)"background", (getter)getBackground, (setter)setBackground, (char*)"background color", NULL}, // attributes from ImageBase class - {"image", (getter)Image_getImage, NULL, "image data", NULL}, - {"size", (getter)Image_getSize, NULL, "image size", NULL}, - {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, - {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, - {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL}, + {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, + {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL}, + {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 4ed1cd9e801..6bee9fd6624 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -239,15 +239,15 @@ static PyMethodDef imageViewportMethods[] = // attributes structure static PyGetSetDef imageViewportGetSets[] = { - {"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, "use whole viewport to capture", NULL}, - {"position", (getter)ImageViewport_getPosition, (setter)ImageViewport_setPosition, "upper left corner of captured area", NULL}, - {"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, "size of viewport area being captured", NULL}, + {(char*)"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, (char*)"use whole viewport to capture", NULL}, + {(char*)"position", (getter)ImageViewport_getPosition, (setter)ImageViewport_setPosition, (char*)"upper left corner of captured area", NULL}, + {(char*)"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, (char*)"size of viewport area being captured", NULL}, // attributes from ImageBase class - {"image", (getter)Image_getImage, NULL, "image data", NULL}, - {"size", (getter)Image_getSize, NULL, "image size", NULL}, - {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, - {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, - {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, + {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL}, + {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, + {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL}, + {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp index 0451d74c8ad..6d2676dce09 100644 --- a/source/gameengine/VideoTexture/PyTypeList.cpp +++ b/source/gameengine/VideoTexture/PyTypeList.cpp @@ -78,6 +78,6 @@ void PyTypeList::reg (PyObject * module) // increase ref count Py_INCREF((*it)->getType()); // add type to module - PyModule_AddObject(module, (*it)->getName(), (PyObject*)(*it)->getType()); + PyModule_AddObject(module, (char*)(*it)->getName(), (PyObject*)(*it)->getType()); } } diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index ceda39aeff4..e922bbd768d 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -412,8 +412,8 @@ static PyMethodDef textureMethods[] = // class Texture attributes static PyGetSetDef textureGetSets[] = { - {"source", (getter)Texture_getSource, (setter)Texture_setSource, "source of texture", NULL}, - {"mipmap", (getter)Texture_getMipmap, (setter)Texture_setMipmap, "mipmap texture", NULL}, + {(char*)"source", (getter)Texture_getSource, (setter)Texture_setSource, (char*)"source of texture", NULL}, + {(char*)"mipmap", (getter)Texture_getMipmap, (setter)Texture_setMipmap, (char*)"mipmap texture", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 2af7228a192..b97c4d670c4 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -692,18 +692,18 @@ static PyMethodDef videoMethods[] = // attributes structure static PyGetSetDef videoGetSets[] = { // methods from VideoBase class - {"status", (getter)Video_getStatus, NULL, "video status", NULL}, - {"range", (getter)Video_getRange, (setter)Video_setRange, "replay range", NULL}, - {"repeat", (getter)Video_getRepeat, (setter)Video_setRepeat, "repeat count, -1 for infinite repeat", NULL}, - {"framerate", (getter)Video_getFrameRate, (setter)Video_setFrameRate, "frame rate", NULL}, + {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL}, + {(char*)"range", (getter)Video_getRange, (setter)Video_setRange, (char*)"replay range", NULL}, + {(char*)"repeat", (getter)Video_getRepeat, (setter)Video_setRepeat, (char*)"repeat count, -1 for infinite repeat", NULL}, + {(char*)"framerate", (getter)Video_getFrameRate, (setter)Video_setFrameRate, (char*)"frame rate", NULL}, // attributes from ImageBase class - {"image", (getter)Image_getImage, NULL, "image data", NULL}, - {"size", (getter)Image_getSize, NULL, "image size", NULL}, - {"scale", (getter)Image_getScale, (setter)Image_setScale, "fast scale of image (near neighbour)", NULL}, - {"flip", (getter)Image_getFlip, (setter)Image_setFlip, "flip image vertically", NULL}, - {"filter", (getter)Image_getFilter, (setter)Image_setFilter, "pixel filter", NULL}, - {"preseek", (getter)VideoFFmpeg_getPreseek, (setter)VideoFFmpeg_setPreseek, "nb of frames of preseek", NULL}, - {"deinterlace", (getter)VideoFFmpeg_getDeinterlace, (setter)VideoFFmpeg_setDeinterlace, "deinterlace image", NULL}, + {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL}, + {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, + {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL}, + {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, + {(char*)"preseek", (getter)VideoFFmpeg_getPreseek, (setter)VideoFFmpeg_setPreseek, (char*)"nb of frames of preseek", NULL}, + {(char*)"deinterlace", (getter)VideoFFmpeg_getDeinterlace, (setter)VideoFFmpeg_setDeinterlace, (char*)"deinterlace image", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 629b589c0e6..f206e2f71b4 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -180,7 +180,7 @@ PyObject* initVideoTexture(void) pyFilterTypes.reg(m); Py_INCREF(&TextureType); - PyModule_AddObject(m, "Texture", (PyObject*)&TextureType); + PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType); // init last error description Exception::m_lastError[0] = '\0'; -- cgit v1.2.3 From 1886b7bf52f73f03d60967504b474cdde7a4e1e7 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 4 Nov 2008 12:04:59 +0000 Subject: VideoTexture: fix RGB/BGR confusion, make code compatible with big endian CPU, add RGBA source filter. --- source/gameengine/VideoTexture/FilterBase.h | 6 +++ source/gameengine/VideoTexture/FilterBlueScreen.h | 15 ++++---- source/gameengine/VideoTexture/FilterColor.cpp | 12 +++--- source/gameengine/VideoTexture/FilterColor.h | 36 ++++++++++-------- source/gameengine/VideoTexture/FilterNormal.cpp | 4 +- source/gameengine/VideoTexture/FilterNormal.h | 27 ++++++++----- source/gameengine/VideoTexture/FilterSource.cpp | 46 +++++++++++++++++++++++ source/gameengine/VideoTexture/FilterSource.h | 43 +++++++++++++++++---- source/gameengine/VideoTexture/ImageBuff.cpp | 2 +- source/gameengine/VideoTexture/ImageViewport.cpp | 2 +- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 32 ++++++++-------- source/gameengine/VideoTexture/VideoFFmpeg.h | 4 +- source/gameengine/VideoTexture/blendVideoTex.cpp | 2 + 13 files changed, 162 insertions(+), 69 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h index c530e385ada..b6080f018d5 100644 --- a/source/gameengine/VideoTexture/FilterBase.h +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -29,6 +29,12 @@ http://www.gnu.org/copyleft/lesser.txt. #include "PyTypeList.h" +#define VT_C(v,idx) ((unsigned char*)&v)[idx] +#define VT_R(v) ((unsigned char*)&v)[0] +#define VT_G(v) ((unsigned char*)&v)[1] +#define VT_B(v) ((unsigned char*)&v)[2] +#define VT_A(v) ((unsigned char*)&v)[3] +#define VT_RGBA(v,r,g,b,a) VT_R(v)=(unsigned char)r, VT_G(v)=(unsigned char)g, VT_B(v)=(unsigned char)b, VT_A(v)=(unsigned char)a // forward declaration class FilterBase; diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.h b/source/gameengine/VideoTexture/FilterBlueScreen.h index 20660804f78..820e4a44501 100644 --- a/source/gameengine/VideoTexture/FilterBlueScreen.h +++ b/source/gameengine/VideoTexture/FilterBlueScreen.h @@ -63,25 +63,24 @@ protected: short * size, unsigned int pixSize, unsigned int val) { // calculate differences - int difRed = int((val >> 16) & 0xFF) - int(m_color[0]); - int difGreen = int((val >> 8) & 0xFF) - int(m_color[1]); - int difBlue = int(val & 0xFF) - int(m_color[2]); + int difRed = int(VT_R(val)) - int(m_color[0]); + int difGreen = int(VT_G(val)) - int(m_color[1]); + int difBlue = int(VT_B(val)) - int(m_color[2]); // calc distance from "blue screen" color unsigned int dist = (unsigned int)(difRed * difRed + difGreen * difGreen + difBlue * difBlue); // condition for fully transparent color if (m_squareLimits[0] >= dist) // return color with zero alpha - //return 0xFF000000; - return val & 0x00FFFFFF; + VT_A(val) = 0; // condition for fully opaque color else if (m_squareLimits[1] <= dist) // return normal colour - return val | 0xFF000000; + VT_A(val) = 0xFF; // otherwise calc alpha else - return (val & 0x00FFFFFF) | ((((dist - m_squareLimits[0]) << 8) - / m_limitDist) << 24); + VT_A(val) = (((dist - m_squareLimits[0]) << 8) / m_limitDist); + return val; } /// virtual filtering function for byte source diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp index eaf6e955003..22ee729b200 100644 --- a/source/gameengine/VideoTexture/FilterColor.cpp +++ b/source/gameengine/VideoTexture/FilterColor.cpp @@ -223,7 +223,7 @@ FilterLevel::FilterLevel (void) for (int r = 0; r < 4; ++r) { levels[r][0] = 0; - levels[r][1] = 0xFF << (r << 3); + levels[r][1] = 0xFF; levels[r][2] = 0xFF; } } @@ -235,7 +235,7 @@ void FilterLevel::setLevels (ColorLevel & lev) for (int r = 0; r < 4; ++r) { for (int c = 0; c < 2; ++c) - levels[r][c] = lev[r][c] << (r << 3); + levels[r][c] = lev[r][c]; levels[r][2] = lev[r][0] < lev[r][1] ? lev[r][1] - lev[r][0] : 1; } } @@ -252,9 +252,9 @@ inline FilterLevel * getFilterLevel (PyFilter * self) static PyObject * getLevels (PyFilter * self, void * closure) { ColorLevel & lev = getFilterLevel(self)->getLevels(); - return Py_BuildValue("((kk)(kk)(kk)(kk))", - lev[0][0], lev[0][1], lev[1][0] >> 8, lev[1][1] >> 8, - lev[2][0] >> 16, lev[2][1] >> 16, lev[3][0] >> 24, lev[3][1] >> 24); + return Py_BuildValue("((HH)(HH)(HH)(HH))", + lev[0][0], lev[0][1], lev[1][0], lev[1][1], + lev[2][0], lev[2][1], lev[3][0], lev[3][1]); } // set color levels @@ -279,7 +279,7 @@ static int setLevels (PyFilter * self, PyObject * value, void * closure) valid = PyInt_Check(PySequence_Fast_GET_ITEM(row, c)); // if it is valid, save it in matrix if (valid) - lev[r][c] = (unsigned long)(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c))); + lev[r][c] = (unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c))); } } // if parameter is not valid, report error diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h index ae2e98fa942..b7e52c4521c 100644 --- a/source/gameengine/VideoTexture/FilterColor.h +++ b/source/gameengine/VideoTexture/FilterColor.h @@ -43,10 +43,13 @@ protected: short * size, unsigned int pixSize, unsigned int val) { // calculate gray value - unsigned int gray = (28 * ((val >> 16) & 0xFF) + 151 * ((val >> 8) & 0xFF) - + 77 * (val & 0xFF)) & 0xFF00; + unsigned int gray = (28 * (VT_B(val)) + 151 * (VT_G(val)) + + 77 * (VT_R(val))) >> 8; // return gray scale value - return (val & 0xFF000000) | gray << 8 | gray | gray >> 8; + VT_R(val) = gray; + VT_G(val) = gray; + VT_B(val) = gray; + return val; } /// virtual filtering function for byte source @@ -82,11 +85,11 @@ protected: ColorMatrix m_matrix; /// calculate one color component - unsigned int calcColor (unsigned int val, short idx) + unsigned char calcColor (unsigned int val, short idx) { - return (((m_matrix[idx][0] * (val & 0xFF) + m_matrix[idx][1] * ((val >> 8) & 0xFF) - + m_matrix[idx][2] * ((val >> 16) & 0xFF) + m_matrix[idx][3] * ((val >> 24) & 0xFF) - + m_matrix[idx][4]) >> 8) & 0xFF) << (idx << 3); + return (((m_matrix[idx][0] * (VT_R(val)) + m_matrix[idx][1] * (VT_G(val)) + + m_matrix[idx][2] * (VT_B(val)) + m_matrix[idx][3] * (VT_A(val)) + + m_matrix[idx][4]) >> 8) & 0xFF); } /// filter pixel template, source int buffer @@ -94,8 +97,9 @@ protected: short * size, unsigned int pixSize, unsigned int val) { // return calculated color - return calcColor(val, 0) | calcColor(val, 1) | calcColor(val, 2) - | calcColor(val, 3); + int color; + VT_RGBA(color, calcColor(val, 0), calcColor(val, 1), calcColor(val, 2), calcColor(val, 3)); + return color; } /// virtual filtering function for byte source @@ -110,7 +114,7 @@ protected: /// type for color levels -typedef unsigned long ColorLevel[4][3]; +typedef unsigned short ColorLevel[4][3]; /// pixel filter for color calculation class FilterLevel : public FilterBase @@ -133,11 +137,10 @@ protected: /// calculate one color component unsigned int calcColor (unsigned int val, short idx) { - unsigned int col = val & (0xFF << (idx << 3)); + unsigned int col = VT_C(val,idx);; if (col <= levels[idx][0]) col = 0; - else if (col >= levels[idx][1]) col = 0xFF << (idx << 3); - else if (idx < 3) col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & (0xFF << (idx << 3)); - else col = (((col - levels[idx][0]) / levels[idx][2]) << 8) & (0xFF << (idx << 3)); + else if (col >= levels[idx][1]) col = 0xFF; + else col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & 0xFF; return col; } @@ -146,8 +149,9 @@ protected: short * size, unsigned int pixSize, unsigned int val) { // return calculated color - return calcColor(val, 0) | calcColor(val, 1) | calcColor(val, 2) - | calcColor(val, 3); + int color; + VT_RGBA(color, calcColor(val, 0), calcColor(val, 1), calcColor(val, 2), calcColor(val, 3)); + return color; } /// virtual filtering function for byte source diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp index 736b9e3b958..03a79c1c8ce 100644 --- a/source/gameengine/VideoTexture/FilterNormal.cpp +++ b/source/gameengine/VideoTexture/FilterNormal.cpp @@ -32,7 +32,7 @@ http://www.gnu.org/copyleft/lesser.txt. // implementation FilterNormal // constructor -FilterNormal::FilterNormal (void) : m_colShift(0) +FilterNormal::FilterNormal (void) : m_colIdx(0) { // set default depth setDepth(4); @@ -44,7 +44,7 @@ void FilterNormal::setColor (unsigned short colIdx) // check validity of index if (colIdx < 3) // set color shift - m_colShift = colIdx << 3; + m_colIdx = colIdx; } // set depth diff --git a/source/gameengine/VideoTexture/FilterNormal.h b/source/gameengine/VideoTexture/FilterNormal.h index ec51ca39db9..840043be9a1 100644 --- a/source/gameengine/VideoTexture/FilterNormal.h +++ b/source/gameengine/VideoTexture/FilterNormal.h @@ -43,7 +43,7 @@ public: virtual ~FilterNormal (void) {} /// get index of color used to calculate normals - unsigned short getColor (void) { return m_colShift >> 3; } + unsigned short getColor (void) { return m_colIdx; } /// set index of color used to calculate normals void setColor (unsigned short colIdx); @@ -58,20 +58,28 @@ protected: /// scale to calculate normals float m_depthScale; - /// shift to used color component - unsigned short m_colShift; + /// color index, 0=red, 1=green, 2=blue, 3=alpha + unsigned short m_colIdx; /// filter pixel, source int buffer template unsigned int tFilter (SRC * src, short x, short y, short * size, unsigned int pixSize, unsigned int val = 0) { // get value of required color - int actPix = int((val >> m_colShift) & 0xFF); + int actPix = int(VT_C(val,m_colIdx)); + int upPix = actPix; + int leftPix = actPix; // get upper and left pixel from actual pixel - int upPix = y > 0 ? int((convertPrevious(src - pixSize * size[0], x, y - 1, - size, pixSize) >> m_colShift) & 0xFF) : actPix; - int leftPix = x > 0 ? int((convertPrevious(src - pixSize, x - 1, y, size, pixSize) - >> m_colShift) & 0xFF) : actPix; + if (y > 0) + { + val = convertPrevious(src - pixSize * size[0], x, y - 1, size, pixSize); + upPix = VT_C(val,m_colIdx); + } + if (x > 0) + { + val = convertPrevious(src - pixSize, x - 1, y, size, pixSize); + leftPix = VT_C(val,m_colIdx); + } // height differences (from blue color) float dx = (actPix - leftPix) * m_depthScale; float dy = (actPix - upPix) * m_depthScale; @@ -81,7 +89,8 @@ protected: dy = dy * dz + normScaleKoef; dz += normScaleKoef; // return normal vector converted to color - return 0xFF000000 | int(dz) << 16 | int(dy) << 8 | int(dx); + VT_RGBA(val, dx, dy, dz, 0xFF); + return val; } /// filter pixel, source byte buffer diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp index 8d8749dbc8f..f3676e93a6d 100644 --- a/source/gameengine/VideoTexture/FilterSource.cpp +++ b/source/gameengine/VideoTexture/FilterSource.cpp @@ -77,6 +77,52 @@ PyTypeObject FilterRGB24Type = Filter_allocNew, /* tp_new */ }; +// FilterRGBA32 + +// define python type +PyTypeObject FilterRGBA32Type = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.FilterRGBA32", /*tp_name*/ + sizeof(PyFilter), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Filter_dealloc,/*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "Source filter RGBA32 objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + NULL, /* tp_methods */ + 0, /* tp_members */ + NULL, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Filter_init, /* tp_init */ + 0, /* tp_alloc */ + Filter_allocNew, /* tp_new */ +}; + // FilterBGR24 // define python type diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h index c3d4e0079f9..7e90747d252 100644 --- a/source/gameengine/VideoTexture/FilterSource.h +++ b/source/gameengine/VideoTexture/FilterSource.h @@ -44,7 +44,34 @@ protected: /// filter pixel, source byte buffer virtual unsigned int filter (unsigned char * src, short x, short y, short * size, unsigned int pixSize, unsigned int val) - { return 0xFF000000 | src[0] << 16 | src[1] << 8 | src[2]; } + { VT_RGBA(val,src[0],src[1],src[2],0xFF); return val; } +}; + +/// class for RGBA32 conversion +class FilterRGBA32 : public FilterBase +{ +public: + /// constructor + FilterRGBA32 (void) {} + /// destructor + virtual ~FilterRGBA32 (void) {} + + /// get source pixel size + virtual unsigned int getPixelSize (void) { return 4; } + +protected: + /// filter pixel, source byte buffer + virtual unsigned int filter (unsigned char * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + if ((intptr_t(src)&0x3) == 0) + return *(unsigned int*)src; + else + { + VT_RGBA(val,src[0],src[1],src[2],src[3]); + return val; + } + } }; /// class for BGR24 conversion @@ -63,7 +90,7 @@ protected: /// filter pixel, source byte buffer virtual unsigned int filter (unsigned char * src, short x, short y, short * size, unsigned int pixSize, unsigned int val) - { return 0xFF000000 | src[2] << 16 | src[1] << 8 | src[0]; } + { VT_RGBA(val,src[2],src[1],src[0],0xFF); return val; } }; /// class for YV12 conversion @@ -215,15 +242,15 @@ protected: int red = (298 * c + 409 * e + 128) >> 8; if (red >= 0x100) red = 0xFF; else if (red < 0) red = 0; - int green = 298 * c - 100 * d - 208 * e; - if (green > 0x10000) green = 0xFF00; + int green = (298 * c - 100 * d - 208 * e) >> 8; + if (green >= 0x100) green = 0xFF; else if (green < 0) green = 0; - int blue = (298 * c + 516 * d + 128) << 8; - if (blue > 0x1000000) blue = 0xFF0000; + int blue = (298 * c + 516 * d + 128) >> 8; + if (blue >= 0x100) blue = 0xFF; else if (blue < 0) blue = 0; // return result - return 0xFF000000 | blue & 0xFF0000 | green & 0xFF00 - | red & 0xFF; + VT_RGBA(val, red, green, blue, 0xFF); + return val; } }; diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp index a22757dca39..19ad17ac643 100644 --- a/source/gameengine/VideoTexture/ImageBuff.cpp +++ b/source/gameengine/VideoTexture/ImageBuff.cpp @@ -32,7 +32,7 @@ http://www.gnu.org/copyleft/lesser.txt. // default filter -FilterBGR24 defFilter; +FilterRGB24 defFilter; // load image from buffer diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 6bee9fd6624..deb66ffb6ba 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -135,7 +135,7 @@ void ImageViewport::calcImage (unsigned int texId) glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB, GL_UNSIGNED_BYTE, m_viewportImage); // filter loaded data - FilterBGR24 filt; + FilterRGB24 filt; filterImage(filt, m_viewportImage, m_capSize); } } diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index b97c4d670c4..91b8a54dd86 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -51,7 +51,7 @@ extern "C" void do_init_ffmpeg(); // constructor VideoFFmpeg::VideoFFmpeg (HRESULT * hRslt) : VideoBase(), m_codec(NULL), m_formatCtx(NULL), m_codecCtx(NULL), -m_frame(NULL), m_frameDeinterlaced(NULL), m_frameBGR(NULL), m_imgConvertCtx(NULL), +m_frame(NULL), m_frameDeinterlaced(NULL), m_frameRGB(NULL), m_imgConvertCtx(NULL), m_deinterlace(false), m_preseek(0), m_videoStream(-1), m_baseFrameRate(25.0), m_lastFrame(-1), m_curPosition(-1), m_startTime(0), m_captWidth(0), m_captHeight(0), m_captRate(0.f) @@ -91,10 +91,10 @@ bool VideoFFmpeg::release() MEM_freeN(m_frameDeinterlaced->data[0]); av_free(m_frameDeinterlaced); } - if (m_frameBGR) + if (m_frameRGB) { - MEM_freeN(m_frameBGR->data[0]); - av_free(m_frameBGR); + MEM_freeN(m_frameRGB->data[0]); + av_free(m_frameRGB); } if (m_imgConvertCtx) { @@ -106,7 +106,7 @@ bool VideoFFmpeg::release() m_formatCtx = NULL; m_frame = NULL; m_frame = NULL; - m_frameBGR = NULL; + m_frameRGB = NULL; m_imgConvertCtx = NULL; // object will be deleted after that @@ -189,7 +189,7 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV m_videoStream = videoStream; m_frame = avcodec_alloc_frame(); m_frameDeinterlaced = avcodec_alloc_frame(); - m_frameBGR = avcodec_alloc_frame(); + m_frameRGB = avcodec_alloc_frame(); // allocate buffer if deinterlacing is required @@ -201,12 +201,12 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV m_codecCtx->pix_fmt, m_codecCtx->width, m_codecCtx->height); // allocate buffer to store final decoded frame - avpicture_fill((AVPicture*)m_frameBGR, + avpicture_fill((AVPicture*)m_frameRGB, (uint8_t*)MEM_callocN(avpicture_get_size( - PIX_FMT_BGR24, + PIX_FMT_RGB24, m_codecCtx->width, m_codecCtx->height), - "ffmpeg bgr"), - PIX_FMT_BGR24, m_codecCtx->width, m_codecCtx->height); + "ffmpeg rgb"), + PIX_FMT_RGB24, m_codecCtx->width, m_codecCtx->height); // allocate sws context m_imgConvertCtx = sws_getContext( m_codecCtx->width, @@ -214,7 +214,7 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV m_codecCtx->pix_fmt, m_codecCtx->width, m_codecCtx->height, - PIX_FMT_BGR24, + PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL); @@ -224,8 +224,8 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV av_free(m_frame); MEM_freeN(m_frameDeinterlaced->data[0]); av_free(m_frameDeinterlaced); - MEM_freeN(m_frameBGR->data[0]); - av_free(m_frameBGR); + MEM_freeN(m_frameRGB->data[0]); + av_free(m_frameRGB); return -1; } return 0; @@ -565,14 +565,14 @@ bool VideoFFmpeg::grabFrame(long position) input = m_frameDeinterlaced; } } - // convert to BGR24 + // convert to RGB24 sws_scale(m_imgConvertCtx, input->data, input->linesize, 0, m_codecCtx->height, - m_frameBGR->data, - m_frameBGR->linesize); + m_frameRGB->data, + m_frameRGB->linesize); av_free_packet(&packet); frameLoaded = true; break; diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index 4720bef1841..3903116c82c 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -100,7 +100,7 @@ protected: // deinterlaced frame if codec requires it AVFrame *m_frameDeinterlaced; // decoded RGB24 frame if codec requires it - AVFrame *m_frameBGR; + AVFrame *m_frameRGB; // conversion from raw to RGB is done with sws_scale struct SwsContext *m_imgConvertCtx; // should the codec be deinterlaced? @@ -150,7 +150,7 @@ protected: bool grabFrame(long frame); /// return the frame in RGB24 format, the image data is found in AVFrame.data[0] - AVFrame* getFrame(void) { return m_frameBGR; } + AVFrame* getFrame(void) { return m_frameRGB; } }; inline VideoFFmpeg * getFFmpeg (PyImage * self) diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index f206e2f71b4..530ec7a85dd 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -126,6 +126,7 @@ extern PyTypeObject FilterColorType; extern PyTypeObject FilterLevelType; extern PyTypeObject FilterNormalType; extern PyTypeObject FilterRGB24Type; +extern PyTypeObject FilterRGBA32Type; extern PyTypeObject FilterBGR24Type; extern PyTypeObject ImageBuffType; extern PyTypeObject ImageMixType; @@ -150,6 +151,7 @@ static void registerAllTypes(void) pyFilterTypes.add(&FilterLevelType, "FilterLevel"); pyFilterTypes.add(&FilterNormalType, "FilterNormal"); pyFilterTypes.add(&FilterRGB24Type, "FilterRGB24"); + pyFilterTypes.add(&FilterRGBA32Type, "FilterRGBA32"); pyFilterTypes.add(&FilterBGR24Type, "FilterBGR24"); } -- cgit v1.2.3 From 8916f84622ccadbbb4111b03117cc6cc9ad9fe0a Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 5 Nov 2008 13:22:10 +0000 Subject: VideoTexture: Add support for GLSL. FIx small printout bug in Exception printout --- source/gameengine/Ketsji/KX_BlenderMaterial.h | 3 +++ source/gameengine/VideoTexture/Exception.cpp | 6 +++--- source/gameengine/VideoTexture/Texture.cpp | 18 +++++++++++------- source/gameengine/VideoTexture/Texture.h | 7 +++---- 4 files changed, 20 insertions(+), 14 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index b858fa3754c..6e5db1b56c1 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -70,6 +70,9 @@ public: BL_Texture * getTex (unsigned int idx) { return (idx < MAXTEX) ? mTextures + idx : NULL; } + Image * getImage (unsigned int idx) { + return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : NULL; + } // for ipos void UpdateIPO( diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index 3ac8b8e321d..3f939de6bc2 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -168,15 +168,15 @@ void Exception::setXptDesc (void) } // add result code // length of result code - const size_t rsltSize = 10; + const size_t rsltSize = 11; // delimit description const char delimRslt[] = ": "; // set text of description char rsltTxt[rsltSize]; std::ostrstream os(rsltTxt, rsltSize); - os << std::hex << m_hRslt << delimRslt; + os << std::hex << m_hRslt << delimRslt << '\0'; // copy result to description - m_desc.insert(0, rsltTxt, rsltSize); + m_desc.insert(0, rsltTxt); // copy exception description to last exception string m_lastError = m_desc; } diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index e922bbd768d..88a26e3c088 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -54,9 +54,6 @@ http://www.gnu.org/copyleft/lesser.txt. { exp.report(); } -// are Blender materials used -bool blendMats = false; - // Blender GameObject type BlendType gameObjectType ("KX_GameObject"); @@ -198,15 +195,22 @@ int Texture_init (Texture *self, PyObject *args, PyObject *kwds) if (mat != NULL) { // is it blender material or polygon material - blendMats = (mat->GetFlag() & RAS_BLENDERMAT) != 0; - if (blendMats) + if (mat->GetFlag() & RAS_BLENDERGLSL) + { + self->m_imgTexture = static_cast(mat)->getImage(texID); + self->m_useMatTexture = false; + } else if (mat->GetFlag() & RAS_BLENDERMAT) + { // get blender material texture self->m_matTexture = static_cast(mat)->getTex(texID); + self->m_useMatTexture = true; + } else { // get texture pointer from polygon material MTFace * tface = static_cast(mat)->GetMTFace(); self->m_imgTexture = (Image*)tface->tpage; + self->m_useMatTexture = false; } } // check if texture is available, if not, initialization failed @@ -246,7 +250,7 @@ PyObject * Texture_close(Texture * self) { self->m_orgSaved = false; // restore original texture code - if (blendMats) + if (self->m_useMatTexture) self->m_matTexture->swapTexture(self->m_orgTex); else self->m_imgTexture->bindcode = self->m_orgTex; @@ -292,7 +296,7 @@ PyObject * Texture_refresh (Texture * self, PyObject * args) { self->m_orgSaved = true; // save original image code - if (blendMats) + if (self->m_useMatTexture) self->m_orgTex = self->m_matTexture->swapTexture(self->m_actTex); else { diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h index 569e34da121..3c371e51537 100644 --- a/source/gameengine/VideoTexture/Texture.h +++ b/source/gameengine/VideoTexture/Texture.h @@ -39,9 +39,11 @@ struct Texture { PyObject_HEAD + // texture is using blender material + bool m_useMatTexture; + // video texture bind code unsigned int m_actTex; - // original texture bind code unsigned int m_orgTex; // original texture saved @@ -70,9 +72,6 @@ struct Texture // Texture type description extern PyTypeObject TextureType; -// usage of Blender materials -extern bool blendMats; - // load texture void loadTexture (unsigned int texId, unsigned int * texture, short * size, bool mipmap = false); -- cgit v1.2.3 From 0ade815affb7f297e2e85b105e6ddd35be3f5fdb Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 5 Nov 2008 17:38:31 +0000 Subject: VideoTexture: fixing a crash when loading an image as a video file - yes it works, provided that you don't set repeat and also no need to refresh all the time. --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 91b8a54dd86..277ac192686 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -255,7 +255,7 @@ void VideoFFmpeg::openFile (char * filename) if ( #ifdef FFMPEG_PB_IS_POINTER - m_formatCtx->pb->is_streamed + m_formatCtx->pb && m_formatCtx->pb->is_streamed #else m_formatCtx->pb.is_streamed #endif -- cgit v1.2.3 From ce1625ebc0317f6e5f9cd0bdfd9c246e5f8c6fef Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 5 Nov 2008 21:53:22 +0000 Subject: VideoTexture: new VideoTexture.ImageFFmpeg to load and reload images. The FFmpeg library allows to load image files. Although it is possible to load images using the VideoFFmpeg class, it is not very efficient. The new class VideoTexture.ImageFFmpeg is dedicated to image management. Constructor: ----------- VideoTexture.ImageFFmpeg('image_file_name') Opens the file but does not load the texture yet. The file name can also be a network address. It can also be a video file name; in that case only the first image is loaded. Methods: ------- refresh(True) Loads the image to texture. You just need to call it once, the file is automatically closed after that and calling refresh() again will have no effect. reload('new_file_name') Reloads the image (if new_file_name is omitted) or loads a new image. The file is opened but the texture is not updated yet, you need to call refresh() once to load the texture. Attributes: ---------- status returns the image status: 2 : file opened, texture not loaded 3 : file closed, texture loaded image returns the image data as a string of RGBA pixel size returns the image size [x,y] scale get/set the scale flag. If the scale flag is False, the image is rescale to texture format using gluScaleImage() function, slow but good quality. If the scale flag is True, the image is rescaled using a fast but less accurate algorithm. flip get/set Y-flip flag. Set to True by default as FFmpeg always provides the image upside down filter get/set filter(s) on the image. Example: --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 157 +++++++++++++++++++++-- source/gameengine/VideoTexture/VideoFFmpeg.h | 11 +- source/gameengine/VideoTexture/blendVideoTex.cpp | 2 + 3 files changed, 156 insertions(+), 14 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 277ac192686..dfbd61daee8 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -54,7 +54,7 @@ m_codec(NULL), m_formatCtx(NULL), m_codecCtx(NULL), m_frame(NULL), m_frameDeinterlaced(NULL), m_frameRGB(NULL), m_imgConvertCtx(NULL), m_deinterlace(false), m_preseek(0), m_videoStream(-1), m_baseFrameRate(25.0), m_lastFrame(-1), m_curPosition(-1), m_startTime(0), -m_captWidth(0), m_captHeight(0), m_captRate(0.f) +m_captWidth(0), m_captHeight(0), m_captRate(0.f), m_isImage(false) { // set video format m_format = RGB24; @@ -77,49 +77,48 @@ bool VideoFFmpeg::release() if (m_codecCtx) { avcodec_close(m_codecCtx); + m_codecCtx = NULL; } if (m_formatCtx) { av_close_input_file(m_formatCtx); + m_formatCtx = NULL; } if (m_frame) { av_free(m_frame); + m_frame = NULL; } if (m_frameDeinterlaced) { MEM_freeN(m_frameDeinterlaced->data[0]); av_free(m_frameDeinterlaced); + m_frameDeinterlaced = NULL; } if (m_frameRGB) { MEM_freeN(m_frameRGB->data[0]); av_free(m_frameRGB); + m_frameRGB = NULL; } if (m_imgConvertCtx) { sws_freeContext(m_imgConvertCtx); + m_imgConvertCtx = NULL; } - m_codec = NULL; - m_codecCtx = NULL; - m_formatCtx = NULL; - m_frame = NULL; - m_frame = NULL; - m_frameRGB = NULL; - m_imgConvertCtx = NULL; - - // object will be deleted after that + m_status = SourceStopped; return true; } // set initial parameters -void VideoFFmpeg::initParams (short width, short height, float rate) +void VideoFFmpeg::initParams (short width, short height, float rate, bool image) { m_captWidth = width; m_captHeight = height; m_captRate = rate; + m_isImage = image; } int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams) @@ -266,6 +265,18 @@ void VideoFFmpeg::openFile (char * filename) // for streaming it is important to do non blocking read m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK; } + + if (m_isImage) + { + // the file is to be treated as an image, i.e. load the first frame only + m_isFile = false; + // in case of reload, the filename is taken from m_imageName, no need to change it + if (m_imageName.Ptr() != filename) + m_imageName = filename; + m_preseek = 0; + play(); + } + } @@ -348,7 +359,6 @@ void VideoFFmpeg::openCam (char * file, short camIdx) VideoBase::openCam(file, camIdx); } - // play video bool VideoFFmpeg::play (void) { @@ -450,6 +460,13 @@ void VideoFFmpeg::loadFrame (void) init(short(m_codecCtx->width), short(m_codecCtx->height)); // process image process((BYTE*)(frame->data[0])); + // in case it is an image, automatically stop reading it + if (m_isImage) + { + m_status = SourceStopped; + // close the file as we don't need it anymore + release(); + } } } } @@ -751,7 +768,123 @@ PyTypeObject VideoFFmpegType = Image_allocNew, /* tp_new */ }; +// object initialization +static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds) +{ + PyImage * self = reinterpret_cast(pySelf); + // parameters - video source + // file name or format type for capture (only for Linux: video4linux or dv1394) + char * file = NULL; + + // get parameters + if (!PyArg_ParseTuple(args, "s", &file)) + return -1; + + try + { + // create video object + Video_init(self); + + getVideoFFmpeg(self)->initParams(0, 0, 1.0, true); + + // open video source + Video_open(getVideo(self), file, -1); + } + catch (Exception & exp) + { + exp.report(); + return -1; + } + // initialization succeded + return 0; +} + +PyObject * Image_reload (PyImage * self, PyObject *args) +{ + char * newname = NULL; + + if (self->m_image != NULL && PyArg_ParseTuple(args, "|s", &newname)) + { + VideoFFmpeg* video = getFFmpeg(self); + // check type of object + if (!newname) + newname = video->getImageName(); + if (!newname) { + // if not set, retport error + PyErr_SetString(PyExc_RuntimeError, "No image file name given"); + return NULL; + } + // make sure the previous file is cleared + video->release(); + // open the new file + video->openFile(newname); + } + Py_RETURN_NONE; +} + +// methods structure +static PyMethodDef imageMethods[] = +{ // methods from VideoBase class + {"refresh", (PyCFunction)Video_refresh, METH_NOARGS, "Refresh image, i.e. load it"}, + {"reload", (PyCFunction)Image_reload, METH_VARARGS, "Reload image, i.e. reopen it"}, + {NULL} +}; +// attributes structure +static PyGetSetDef imageGetSets[] = +{ // methods from VideoBase class + {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL}, + // attributes from ImageBase class + {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL}, + {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, + {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL}, + {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, + {NULL} +}; +// python type declaration +PyTypeObject ImageFFmpegType = +{ + PyObject_HEAD_INIT(NULL) + 0, /*ob_size*/ + "VideoTexture.ImageFFmpeg", /*tp_name*/ + sizeof(PyImage), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor)Image_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash */ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /*tp_flags*/ + "FFmpeg image source", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + imageMethods, /* tp_methods */ + 0, /* tp_members */ + imageGetSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)ImageFFmpeg_init, /* tp_init */ + 0, /* tp_alloc */ + Image_allocNew, /* tp_new */ +}; #endif //WITH_FFMPEG diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index 3903116c82c..db2cb293d8b 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -65,8 +65,8 @@ public: virtual ~VideoFFmpeg (); /// set initial parameters - void initParams (short width, short height, float rate); - /// open video file + void initParams (short width, short height, float rate, bool image=false); + /// open video/image file virtual void openFile (char * file); /// open video capture device virtual void openCam (char * driver, short camIdx); @@ -88,6 +88,7 @@ public: void setPreseek(int preseek) { if (preseek >= 0) m_preseek = preseek; } bool getDeinterlace(void) { return m_deinterlace; } void setDeinterlace(bool deinterlace) { m_deinterlace = deinterlace; } + char *getImageName(void) { return (m_isImage) ? m_imageName.Ptr() : NULL; } protected: @@ -131,6 +132,12 @@ protected: /// frame rate of capture in frames per seconds float m_captRate; + /// is file an image? + bool m_isImage; + + /// keep last image name + STR_String m_imageName; + /// image calculation virtual void calcImage (unsigned int texId); diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index 530ec7a85dd..b38882f8164 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -119,6 +119,7 @@ static PyMethodDef moduleMethods[] = #if WITH_FFMPEG extern PyTypeObject VideoFFmpegType; +extern PyTypeObject ImageFFmpegType; #endif extern PyTypeObject FilterBlueScreenType; extern PyTypeObject FilterGrayType; @@ -139,6 +140,7 @@ static void registerAllTypes(void) { #if WITH_FFMPEG pyImageTypes.add(&VideoFFmpegType, "VideoFFmpeg"); + pyImageTypes.add(&ImageFFmpegType, "ImageFFmpeg"); #endif pyImageTypes.add(&ImageBuffType, "ImageBuff"); pyImageTypes.add(&ImageMixType, "ImageMix"); -- cgit v1.2.3 From 87538be426221e687687acd68385ce85be206b53 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 6 Nov 2008 16:01:17 +0000 Subject: VideoTexture: fix compile error when FFmpeg is disabled. --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index dfbd61daee8..5657a32aa6c 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -21,6 +21,8 @@ http://www.gnu.org/copyleft/lesser.txt. */ // INT64_C fix for some linux machines (C99ism) +#ifdef WITH_FFMPEG + #define __STDC_CONSTANT_MACROS #include @@ -33,7 +35,6 @@ http://www.gnu.org/copyleft/lesser.txt. #include "Exception.h" #include "VideoFFmpeg.h" -#ifdef WITH_FFMPEG // default framerate const double defFrameRate = 25.0; @@ -274,6 +275,7 @@ void VideoFFmpeg::openFile (char * filename) if (m_imageName.Ptr() != filename) m_imageName = filename; m_preseek = 0; + m_avail = false; play(); } -- cgit v1.2.3 From 5567f3dded3620c870544d586c2f85fe44c08a10 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 6 Nov 2008 23:52:47 +0000 Subject: VideoTexture: comment was misplaced after previous commit. --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 5657a32aa6c..af6dfec8e87 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -20,9 +20,9 @@ http://www.gnu.org/copyleft/lesser.txt. ----------------------------------------------------------------------------- */ -// INT64_C fix for some linux machines (C99ism) #ifdef WITH_FFMPEG +// INT64_C fix for some linux machines (C99ism) #define __STDC_CONSTANT_MACROS #include -- cgit v1.2.3 From 8b2811d9d5539dd880bc78f05e303781511d657b Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Fri, 7 Nov 2008 10:54:32 +0000 Subject: VideoTexture: VideoTexture.materialID() can now take texture image name. You can specify a image name (starting with 'IM') instead of a material name in VideoTexture.materialID() and return the material ID matching this texture. The advantage of this method is that is works with blender material and UV texture. In case of UV texture, it grabs the internal material corresponding to the faces that are assigned to this texture. In case of blender material, it grabs the material that has an image texture matching the name as first texture channel. In both cases, the texture id used in VideoTexture.Texture() should be 0. Ex: matID = VideoTexture.materialID(obj,'IMvideo.png') GameLogic.video = VideoTexture.Texture(obj, matID, 0) --- source/gameengine/VideoTexture/Texture.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp index 88a26e3c088..66c67023e38 100644 --- a/source/gameengine/VideoTexture/Texture.cpp +++ b/source/gameengine/VideoTexture/Texture.cpp @@ -112,11 +112,20 @@ short getMaterialID (PyObject * obj, char * name) // get material RAS_IPolyMaterial * mat = getMaterial(obj, matID); // if material is not available, report that no material was found - if (mat == NULL) break; - // if material name matches - if (strcmp(mat->GetMaterialName().ReadPtr(), name) == 0) - // matID is found - return matID; + if (mat == NULL) + break; + // name is a material name if it starts with MA and a UV texture name if it starts with IM + if (name[0] == 'I' && name[1] == 'M') + { + // if texture name matches + if (strcmp(mat->GetTextureName().ReadPtr(), name) == 0) + return matID; + } else + { + // if material name matches + if (strcmp(mat->GetMaterialName().ReadPtr(), name) == 0) + return matID; + } } // material was not found return -1; -- cgit v1.2.3 From 2de476c88f4268f2dcfccfe6c9ce55a8697ac83e Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 9 Nov 2008 21:42:30 +0000 Subject: VideoTexture: Preserve alpha channel if present in video, images and sequences. Better detection of end of video. --- source/gameengine/VideoTexture/VideoBase.cpp | 34 ++++++---- source/gameengine/VideoTexture/VideoBase.h | 2 +- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 86 ++++++++++++++++++-------- source/gameengine/VideoTexture/VideoFFmpeg.h | 3 + 4 files changed, 87 insertions(+), 38 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/VideoTexture/VideoBase.cpp b/source/gameengine/VideoTexture/VideoBase.cpp index 038a04a55a8..10117c3af9e 100644 --- a/source/gameengine/VideoTexture/VideoBase.cpp +++ b/source/gameengine/VideoTexture/VideoBase.cpp @@ -54,22 +54,34 @@ void VideoBase::process (BYTE * sample) if (m_image != NULL && !m_avail) { // filters used - FilterRGB24 filtRGB; - FilterYV12 filtYUV; // convert video format to image switch (m_format) { + case RGBA32: + { + FilterRGBA32 filtRGBA; + // use filter object for format to convert image + filterImage(filtRGBA, sample, m_orgSize); + // finish + break; + } case RGB24: - // use filter object for format to convert image - filterImage(filtRGB, sample, m_orgSize); - // finish - break; + { + FilterRGB24 filtRGB; + // use filter object for format to convert image + filterImage(filtRGB, sample, m_orgSize); + // finish + break; + } case YV12: - // use filter object for format to convert image - filtYUV.setBuffs(sample, m_orgSize); - filterImage(filtYUV, sample, m_orgSize); - // finish - break; + { + // use filter object for format to convert image + FilterYV12 filtYUV; + filtYUV.setBuffs(sample, m_orgSize); + filterImage(filtYUV, sample, m_orgSize); + // finish + break; + } } } } diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h index 5bb635e1f19..15ecb7a78f4 100644 --- a/source/gameengine/VideoTexture/VideoBase.h +++ b/source/gameengine/VideoTexture/VideoBase.h @@ -39,7 +39,7 @@ const int SourceStopped = 3; // video source formats -enum VideoFormat { None, RGB24, YV12 }; +enum VideoFormat { None, RGB24, YV12, RGBA32 }; /// base class for video source diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index af6dfec8e87..02798c7e596 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -54,7 +54,7 @@ VideoFFmpeg::VideoFFmpeg (HRESULT * hRslt) : VideoBase(), m_codec(NULL), m_formatCtx(NULL), m_codecCtx(NULL), m_frame(NULL), m_frameDeinterlaced(NULL), m_frameRGB(NULL), m_imgConvertCtx(NULL), m_deinterlace(false), m_preseek(0), m_videoStream(-1), m_baseFrameRate(25.0), -m_lastFrame(-1), m_curPosition(-1), m_startTime(0), +m_lastFrame(-1), m_eof(false), m_curPosition(-1), m_startTime(0), m_captWidth(0), m_captHeight(0), m_captRate(0.f), m_isImage(false) { // set video format @@ -191,7 +191,6 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV m_frameDeinterlaced = avcodec_alloc_frame(); m_frameRGB = avcodec_alloc_frame(); - // allocate buffer if deinterlacing is required avpicture_fill((AVPicture*)m_frameDeinterlaced, (uint8_t*)MEM_callocN(avpicture_get_size( @@ -200,24 +199,51 @@ int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AV "ffmpeg deinterlace"), m_codecCtx->pix_fmt, m_codecCtx->width, m_codecCtx->height); - // allocate buffer to store final decoded frame - avpicture_fill((AVPicture*)m_frameRGB, - (uint8_t*)MEM_callocN(avpicture_get_size( - PIX_FMT_RGB24, - m_codecCtx->width, m_codecCtx->height), - "ffmpeg rgb"), - PIX_FMT_RGB24, m_codecCtx->width, m_codecCtx->height); - // allocate sws context - m_imgConvertCtx = sws_getContext( - m_codecCtx->width, - m_codecCtx->height, - m_codecCtx->pix_fmt, - m_codecCtx->width, - m_codecCtx->height, - PIX_FMT_RGB24, - SWS_FAST_BILINEAR, - NULL, NULL, NULL); - + // check if the pixel format supports Alpha + if (m_codecCtx->pix_fmt == PIX_FMT_RGB32 || + m_codecCtx->pix_fmt == PIX_FMT_BGR32 || + m_codecCtx->pix_fmt == PIX_FMT_RGB32_1 || + m_codecCtx->pix_fmt == PIX_FMT_BGR32_1) + { + // allocate buffer to store final decoded frame + m_format = RGBA32; + avpicture_fill((AVPicture*)m_frameRGB, + (uint8_t*)MEM_callocN(avpicture_get_size( + PIX_FMT_RGBA, + m_codecCtx->width, m_codecCtx->height), + "ffmpeg rgba"), + PIX_FMT_RGBA, m_codecCtx->width, m_codecCtx->height); + // allocate sws context + m_imgConvertCtx = sws_getContext( + m_codecCtx->width, + m_codecCtx->height, + m_codecCtx->pix_fmt, + m_codecCtx->width, + m_codecCtx->height, + PIX_FMT_RGBA, + SWS_FAST_BILINEAR, + NULL, NULL, NULL); + } else + { + // allocate buffer to store final decoded frame + m_format = RGB24; + avpicture_fill((AVPicture*)m_frameRGB, + (uint8_t*)MEM_callocN(avpicture_get_size( + PIX_FMT_RGB24, + m_codecCtx->width, m_codecCtx->height), + "ffmpeg rgb"), + PIX_FMT_RGB24, m_codecCtx->width, m_codecCtx->height); + // allocate sws context + m_imgConvertCtx = sws_getContext( + m_codecCtx->width, + m_codecCtx->height, + m_codecCtx->pix_fmt, + m_codecCtx->width, + m_codecCtx->height, + PIX_FMT_RGB24, + SWS_FAST_BILINEAR, + NULL, NULL, NULL); + } if (!m_imgConvertCtx) { avcodec_close(m_codecCtx); av_close_input_file(m_formatCtx); @@ -481,7 +507,7 @@ void VideoFFmpeg::setPositions (void) // set video start time m_startTime = PIL_check_seconds_timer(); // if file is played and actual position is before end position - if (m_isFile && m_lastFrame >= 0 && m_lastFrame < m_range[1] * actFrameRate()) + if (m_isFile && !m_eof && m_lastFrame >= 0 && m_lastFrame < m_range[1] * actFrameRate()) // continue from actual position m_startTime -= double(m_lastFrame) / actFrameRate(); else @@ -520,7 +546,8 @@ bool VideoFFmpeg::grabFrame(long position) } } // if the position is not in preseek, do a direct jump - if (position != m_curPosition + 1) { + if (position != m_curPosition + 1) + { double timeBase = av_q2d(m_formatCtx->streams[m_videoStream]->time_base); long long pos = (long long) ((long long) (position - m_preseek) * AV_TIME_BASE / m_baseFrameRate); @@ -532,10 +559,16 @@ bool VideoFFmpeg::grabFrame(long position) if (startTs != AV_NOPTS_VALUE) pos += (long long)(startTs * AV_TIME_BASE * timeBase); - av_seek_frame(m_formatCtx, -1, pos, AVSEEK_FLAG_BACKWARD); - // current position is now lost, guess a value. - // It's not important because it will be set at this end of this function - m_curPosition = position - m_preseek - 1; + if (position <= m_curPosition || !m_eof) + { + // no need to seek past the end of the file + if (av_seek_frame(m_formatCtx, -1, pos, AVSEEK_FLAG_BACKWARD) >= 0) + { + // current position is now lost, guess a value. + // It's not important because it will be set at this end of this function + m_curPosition = position - m_preseek - 1; + } + } // this is the timestamp of the frame we're looking for targetTs = (long long)(((double) position) / m_baseFrameRate / timeBase); if (startTs != AV_NOPTS_VALUE) @@ -599,6 +632,7 @@ bool VideoFFmpeg::grabFrame(long position) } av_free_packet(&packet); } + m_eof = !frameLoaded; if (frameLoaded) m_curPosition = position; return frameLoaded; diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h index db2cb293d8b..e60f1727aab 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.h +++ b/source/gameengine/VideoTexture/VideoFFmpeg.h @@ -117,6 +117,9 @@ protected: /// last displayed frame long m_lastFrame; + /// end of file reached + bool m_eof; + /// current file pointer position in file expressed in frame number long m_curPosition; -- cgit v1.2.3 From 773824bbea5aeedfaa953f2d88359e91ed93186c Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Mon, 10 Nov 2008 22:17:40 +0000 Subject: VideoTexture: support VideoTexture in blenderplayer --- source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 1 + source/gameengine/GamePlayer/ghost/GPG_Application.cpp | 1 + source/gameengine/VideoTexture/ImageRender.cpp | 10 ++++++---- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 2d91bbcd7c1..4410763ec53 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -656,6 +656,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area, initGameKeys(); initPythonConstraintBinding(); initMathutils(); + initVideoTexture(); if (sceneconverter) { diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index a9196a1a5e3..aa5e5835cdc 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -686,6 +686,7 @@ bool GPG_Application::startEngine(void) initGameKeys(); initPythonConstraintBinding(); initMathutils(); + initVideoTexture(); // Set the GameLogic.globalDict from marshal'd data, so we can // load new blend files and keep data in GameLogic.globalDict diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 2f2d9debd48..a8f7871fa21 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -38,6 +38,11 @@ http://www.gnu.org/copyleft/lesser.txt. #include "BlendType.h" #include "Exception.h" +ExceptionID SceneInvalid, CameraInvalid; +ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid"); +ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid"); + +#if 0 // not yet supported // constructor ImageRender::ImageRender (KX_Scene * scene, KX_Camera * camera) : m_scene(scene), @@ -124,10 +129,6 @@ BlendType sceneType ("KX_Scene"); BlendType cameraType ("KX_Camera"); -ExceptionID SceneInvalid, CameraInvalid; -ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid"); -ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid"); - // object initialization static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds) { @@ -263,3 +264,4 @@ PyTypeObject ImageRenderType = }; +#endif // #if 0 -- cgit v1.2.3 From 483136c8e4d73fafe2b3e0953a6325107558d896 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Nov 2008 14:14:22 +0000 Subject: Adjusted scons files so disabling quicktime, python and sdl also removes their includes when building. writefile.c had usless include. --- source/gameengine/GameLogic/SConscript | 6 ++++-- source/gameengine/Ketsji/SConscript | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'source/gameengine') diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index fa5a3123215..b4e2159dc22 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -8,11 +8,13 @@ incs += ' #/source/gameengine/Expressions #/intern/moto/include' incs += ' #/source/gameengine/Rasterizer' incs += ' ' + env['BF_PYTHON_INC'] -incs += ' ' + env['BF_SDL_INC'] + defs = '' -if not env['WITH_BF_SDL']: +if env['WITH_BF_SDL']: + incs += ' ' + env['BF_SDL_INC'] +else: defs += ' DISABLE_SDL' env.BlenderLib ( 'bf_logic', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[30, 110] ) diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 02e7aed82a5..f5c620b583f 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -41,8 +41,10 @@ if env['OURPLATFORM'] == 'win32-vc': incs += ' ' + env['BF_SOLID_INC'] incs += ' ' + env['BF_PYTHON_INC'] -incs += ' ' + env['BF_SDL_INC'] incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] +if env['WITH_BF_SDL']: + incs += ' ' + env['BF_SDL_INC'] + env.BlenderLib ( 'bf_ketsji', sources, Split(incs), [], libtype=['game','player'], priority=[25, 72], compileflags = cflags ) -- cgit v1.2.3