From ae9233a5b05ebfc925fd542afbdb3bb9220ed65c Mon Sep 17 00:00:00 2001 From: Kester Maddock Date: Sun, 11 Apr 2004 02:50:02 +0000 Subject: 1. Check material names passed to the physics engine (for collision sensors.) Consider: gameobj->getClientInfo()->m_auxilary_info = (matname ? (void*)(matname+2) : NULL); It works if matname is "MAblah", but not if matname is "". 2. Added constructor for struct RAS_CameraData. 3. Added initializers to the struct KX_ClientObjectInfo constructor 4. Collision sensors won't detect near sensors. 5. A stack of minor tweaks, adjusting whitespace, using ++it for stl stuff. --- .../Converter/BL_BlenderDataConversion.cpp | 6 +- source/gameengine/GamePlayer/Makefile | 2 + .../GamePlayer/common/GPC_PolygonMaterial.cpp | 2 +- .../GamePlayer/ghost/GPG_Application.cpp | 16 +- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 4 +- source/gameengine/Ketsji/KX_ClientObjectInfo.h | 10 +- .../gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 18 +- source/gameengine/Ketsji/KX_GameObject.cpp | 3 +- source/gameengine/Ketsji/KX_GameObject.h | 22 +-- source/gameengine/Ketsji/KX_NearSensor.cpp | 11 +- source/gameengine/Ketsji/KX_TouchSensor.cpp | 23 ++- source/gameengine/Ketsji/KX_TouchSensor.h | 12 +- .../NG_LoopBackNetworkDeviceInterface.cpp | 2 +- .../Physics/Sumo/Fuzzics/src/SM_Object.cpp | 36 +++- .../Physics/Sumo/Fuzzics/src/SM_Scene.cpp | 10 +- .../Physics/Sumo/SumoPhysicsController.cpp | 1 + .../Physics/Sumo/SumoPhysicsEnvironment.cpp | 1 + source/gameengine/Physics/Sumo/include/solid.h | 196 --------------------- .../Physics/Sumo/include/solid_broadphase.h | 39 ---- .../gameengine/Physics/Sumo/include/solid_types.h | 15 -- source/gameengine/Rasterizer/RAS_CameraData.h | 9 + source/gameengine/Rasterizer/RAS_IRasterizer.h | 35 +++- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 12 +- .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 3 +- .../RAS_VAOpenGLRasterizer.cpp | 15 +- 25 files changed, 170 insertions(+), 333 deletions(-) delete mode 100644 source/gameengine/Physics/Sumo/include/solid.h delete mode 100644 source/gameengine/Physics/Sumo/include/solid_broadphase.h delete mode 100644 source/gameengine/Physics/Sumo/include/solid_types.h diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 0a5b30118a3..ac66bfba4b8 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -820,13 +820,9 @@ static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX } static KX_Camera *gamecamera_from_bcamera(Camera *ca, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) { - RAS_CameraData camdata; + RAS_CameraData camdata(ca->lens, ca->clipsta, ca->clipend, ca->type == CAM_PERSP); KX_Camera *gamecamera; - camdata.m_lens= ca->lens; - camdata.m_clipend= ca->clipend; - camdata.m_clipstart= ca->clipsta; - gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata); gamecamera->SetName(ca->id.name + 2); diff --git a/source/gameengine/GamePlayer/Makefile b/source/gameengine/GamePlayer/Makefile index fab44ad9bc7..c9a568f708d 100644 --- a/source/gameengine/GamePlayer/Makefile +++ b/source/gameengine/GamePlayer/Makefile @@ -37,6 +37,7 @@ SOURCEDIR = source/gameengine/GamePlayer DIR = $(OCGDIR)/gameengine/GamePlayer DIRS = common ghost +ifneq ($(NAN_NO_PLUGIN),true) ifeq ($(OS),$(findstring $(OS), "freebsd irix windows")) ifneq ($(FREE_WINDOWS),true) DIRS += netscape @@ -54,5 +55,6 @@ ifeq ($(OS),$(findstring $(OS), "solaris")) DIRS += netscape endif endif +endif include nan_subdirs.mk diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp index 26b4926ec97..75286c4fbad 100644 --- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp +++ b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp @@ -118,7 +118,7 @@ int my_set_tpage(TFace *tface) unsigned int *rect, *bind; int tpx, tpy, tilemode, tileXRep,tileYRep; - /* afschakelen */ + /* disable */ if(tface==0) { if(lasttface==0) return 0; diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 8aedb666c87..68ff43f73c8 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -144,10 +144,10 @@ bool GPG_Application::startWindow(STR_String& title, //STR_String title ("Blender Player - GHOST"); m_mainWindow = fSystem->createWindow(title, windowLeft, windowTop, windowWidth, windowHeight, GHOST_kWindowStateNormal, GHOST_kDrawingContextTypeOpenGL, stereoVisual); - if (!m_mainWindow) { + if (!m_mainWindow) { printf("error: could not create main window\n"); - exit(-1); - } + exit(-1); + } /* Check the size of the client rectangle of the window and resize the window * so that the client rectangle has the size requested. @@ -396,14 +396,14 @@ bool GPG_Application::startEngine(void) } // Temporary hack to disable banner display for NaN approved content. - /* + m_canvas->SetBannerDisplayEnabled(true); - Camera* cam; +/* Camera* cam; cam = (Camera*)G.scene->camera->data; if (cam) { - if (((cam->flag) & 48)==48) { - m_canvas->SetBannerDisplayEnabled(false); - } + if (((cam->flag) & 48)==48) { + m_canvas->SetBannerDisplayEnabled(false); + } } else { showError(CString("Camera data invalid.")); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 253a7e47b2d..acdf3027f19 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -104,8 +104,8 @@ void usage(char* program) consoleoption = ""; #endif - printf("usage: %s -w [-p l t w h] %s[-g gamengineoptions] " - "-s stereomode filename.blend\n", program, consoleoption); + printf("usage: %s [-w [-p l t w h]] %s[-g gamengineoptions] " + "[-s stereomode] filename.blend\n", program, consoleoption); printf(" -w: display in a window\n"); printf(" -p: specify window position\n"); printf(" l = window left coordinate\n"); diff --git a/source/gameengine/Ketsji/KX_ClientObjectInfo.h b/source/gameengine/Ketsji/KX_ClientObjectInfo.h index 51cb19e8935..0ef1a1b86fe 100644 --- a/source/gameengine/Ketsji/KX_ClientObjectInfo.h +++ b/source/gameengine/Ketsji/KX_ClientObjectInfo.h @@ -37,7 +37,7 @@ */ struct KX_ClientObjectInfo { - enum { + enum clienttype { STATIC, ACTOR, RESERVED1, @@ -47,9 +47,13 @@ struct KX_ClientObjectInfo void* m_clientobject; void* m_auxilary_info; public: - KX_ClientObjectInfo(void *clientobject) : - m_clientobject(clientobject) + KX_ClientObjectInfo(void *clientobject, clienttype type = STATIC, void *auxilary_info = NULL) : + m_type(type), + m_clientobject(clientobject), + m_auxilary_info(auxilary_info) {} + + bool isActor() { return m_type <= ACTOR; } }; #endif //__KX_CLIENTOBJECT_INFO_H diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index 96716214edc..488584b0567 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -80,7 +80,7 @@ GEN_Map map_gamemesh_to_sumoshape; // forward declarations -void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_SceneHandle solidscene,class SM_Object* sumoObj,const char* matname,bool isDynamic,bool isActor); +void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_SceneHandle solidscene,class SM_Object* sumoObj,const STR_String& matname,bool isDynamic,bool isActor); DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj); @@ -158,7 +158,7 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj, sumoObj->setRigidBody(objprop->m_angular_rigidbody?true:false); objprop->m_isactor = objprop->m_dyna = true; - BL_RegisterSumoObject(gameobj,sceneptr,sumoEnv->GetSolidScene(),sumoObj,NULL,true, true); + BL_RegisterSumoObject(gameobj,sceneptr,sumoEnv->GetSolidScene(),sumoObj,"",true, true); } else { @@ -229,7 +229,7 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj, BL_RegisterSumoObject(gameobj,sceneptr, sumoEnv->GetSolidScene(),sumoObj, - matname.ReadPtr(), + matname, objprop->m_dyna, objprop->m_isactor); } @@ -251,7 +251,15 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj, -void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_SceneHandle solidscene,class SM_Object* sumoObj,const char* matname,bool isDynamic,bool isActor) { +void BL_RegisterSumoObject( + KX_GameObject* gameobj, + class SM_Scene* sumoScene, + DT_SceneHandle solidscene, + class SM_Object* sumoObj, + const STR_String& matname, + bool isDynamic, + bool isActor) +{ @@ -274,7 +282,7 @@ void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_S //gameobj->GetClientInfo()->m_clientobject = gameobj; // store materialname in auxinfo, needed for touchsensors - gameobj->getClientInfo()->m_auxilary_info = (matname? (void*)(matname+2) : NULL); + gameobj->getClientInfo()->m_auxilary_info = (matname.Length() ? (void*)(matname.ReadPtr()+2) : NULL); physicscontroller->SetObject(gameobj->GetSGNode()); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index f49090acc0d..91ff9e62459 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -73,8 +73,7 @@ KX_GameObject::KX_GameObject( m_pPhysicsController1(NULL) { m_ignore_activity_culling = false; - m_pClient_info = new KX_ClientObjectInfo(this); - m_pClient_info->m_type = KX_ClientObjectInfo::ACTOR; + 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. diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 9fb11f1f31d..84ce0778fbb 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -63,25 +63,25 @@ class KX_GameObject : public SCA_IObject { Py_Header; - bool m_bDyna; - KX_ClientObjectInfo* m_pClient_info; - STR_String m_name; - STR_String m_text; + bool m_bDyna; + KX_ClientObjectInfo* m_pClient_info; + STR_String m_name; + STR_String m_text; std::vector m_meshes; - bool m_bSuspendDynamics; - bool m_bUseObjectColor; - MT_Vector4 m_objectColor; + bool m_bSuspendDynamics; + bool m_bUseObjectColor; + MT_Vector4 m_objectColor; // Is this object set to be visible? Only useful for the // visibility subsystem right now. - bool m_bVisible; + bool m_bVisible; - KX_IPhysicsController* m_pPhysicsController1; - SG_Node* m_pSGNode; + KX_IPhysicsController* m_pPhysicsController1; + SG_Node* m_pSGNode; protected: - MT_CmMatrix4x4 m_OpenGL_4x4Matrix; + MT_CmMatrix4x4 m_OpenGL_4x4Matrix; public: virtual void /* This function should be virtual - derived classed override it */ diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index 0b32c748646..880d0d61c16 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -62,8 +62,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr, m_ResetMargin(resetmargin) { - m_client_info = new KX_ClientObjectInfo(gameobj); - m_client_info->m_type = KX_ClientObjectInfo::NEAR; + m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::NEAR); DT_ShapeHandle shape = (DT_ShapeHandle) vshape; m_sumoObj = new SM_Object(shape,NULL,NULL,NULL); @@ -91,9 +90,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr, m_ResetMargin(resetmargin) { - m_client_info = new KX_ClientObjectInfo(gameobj); - m_client_info->m_type = KX_ClientObjectInfo::NEAR; - m_client_info->m_auxilary_info = NULL; + m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::NEAR); m_sumoObj = new SM_Object(DT_NewSphere(0.0),NULL,NULL,NULL); m_sumoObj->setMargin(m_Margin); @@ -118,9 +115,7 @@ CValue* KX_NearSensor::GetReplica() // this will copy properties and so on... CValue::AddDataToReplica(replica); - replica->m_client_info = new KX_ClientObjectInfo(m_client_info->m_clientobject); - replica->m_client_info->m_type = KX_ClientObjectInfo::NEAR; - replica->m_client_info->m_auxilary_info = NULL; + replica->m_client_info = new KX_ClientObjectInfo(m_client_info->m_clientobject, KX_ClientObjectInfo::NEAR); replica->m_sumoObj = new SM_Object(DT_NewSphere(0.0),NULL,NULL,NULL); replica->m_sumoObj->setMargin(m_Margin); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 6ae670a842c..29d9109c272 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -119,6 +119,19 @@ KX_TouchSensor::~KX_TouchSensor() m_colliders->Release(); } +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; + // this will copy properties and so on... + CValue::AddDataToReplica(replica); + return replica; +} + void KX_TouchSensor::ReParent(SCA_IObject* parent) { KX_GameObject *gameobj = static_cast(parent); @@ -159,7 +172,7 @@ DT_Bool KX_TouchSensor::HandleCollision(void* obj1,void* obj2,const DT_CollDa (KX_GameObject*)client_info->m_clientobject : NULL); - if (gameobj && (gameobj != parent)) + if (gameobj && (gameobj != parent) && client_info->isActor()) { if (!m_colliders->SearchValue(gameobj)) m_colliders->Add(gameobj->AddRef()); @@ -171,14 +184,8 @@ DT_Bool KX_TouchSensor::HandleCollision(void* obj1,void* obj2,const DT_CollDa { if (client_info->m_auxilary_info) { - found = (m_touchedpropname == ((char*)client_info->m_auxilary_info)); + found = (m_touchedpropname == STR_String((char*)client_info->m_auxilary_info)); } - - if (found) - { - int i=0; - } - } else { found = (gameobj->GetProperty(m_touchedpropname) != NULL); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h index 50338827694..4f2ac2d99fa 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.h +++ b/source/gameengine/Ketsji/KX_TouchSensor.h @@ -77,17 +77,7 @@ public: PyTypeObject* T=&Type) ; virtual ~KX_TouchSensor(); - virtual CValue* 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; - // this will copy properties and so on... - CValue::AddDataToReplica(replica); - return replica; - }; + virtual CValue* GetReplica(); virtual void SynchronizeTransform(); virtual bool Evaluate(CValue* event); virtual void ReParent(SCA_IObject* parent); diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp index fe135210b91..ec86e510c49 100644 --- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp +++ b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.cpp @@ -92,7 +92,7 @@ vector NG_LoopBackNetworkDeviceInterface::RetrieveNetworkMes vector messages; std::deque::iterator mesit=m_messages[m_currentQueue].begin(); - for (; !(mesit == m_messages[m_currentQueue].end());mesit++) + for (; !(mesit == m_messages[m_currentQueue].end()); ++mesit) { // We don't increase the reference count for these messages. We diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp index ee8a7da953c..fb02091d4f9 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Object.cpp @@ -374,6 +374,8 @@ DT_Bool SM_Object::boing( if (obj2->isDynamic()) obj2->dynamicCollision(local2, -normal, dist, -rel_vel, restitution, friction_factor, invMass); + //fix(client_data, (void*) obj1, (void*) obj2, coll_data); + return DT_CONTINUE; } @@ -411,6 +413,9 @@ DT_Bool SM_Object::fix( MT_Point3 local1(p1), local2(p2); // Get collision data from SOLID MT_Vector3 normal(local2 - local1); + + if (normal.dot(normal) < MT_EPSILON) + return DT_CONTINUE; // This distinction between dynamic and non-dynamic objects should not be // necessary. Non-dynamic objects are assumed to have infinite mass. @@ -439,7 +444,7 @@ DT_Bool SM_Object::fix( MT_Scalar rel_vel_normal = -0.99*(normal.dot(rel_vel)); obj2->addLinearVelocity(rel_vel_normal*normal); - } + } } return DT_CONTINUE; @@ -461,9 +466,34 @@ void SM_Object::relax(void) notifyClient(); } -SM_Object::SM_Object( -) { +SM_Object::SM_Object() : + m_dynamicParent(0), + m_client_object(0), + + m_shape(0), + m_materialProps(0), + m_materialPropsBackup(0), + m_shapeProps(0), + m_shapePropsBackup(0), + m_object(0), + m_margin(0.0), + m_scaling(1.0, 1.0, 1.0), + m_reaction_impulse(0.0, 0.0, 0.0), + m_reaction_force(0.0, 0.0, 0.0), + m_kinematic(false), + m_prev_kinematic(false), + m_is_rigid_body(false), + m_lin_mom(0.0, 0.0, 0.0), + m_ang_mom(0.0, 0.0, 0.0), + m_force(0.0, 0.0, 0.0), + m_torque(0.0, 0.0, 0.0), + m_error(0.0, 0.0, 0.0), + m_combined_lin_vel (0.0, 0.0, 0.0), + m_combined_ang_vel (0.0, 0.0, 0.0), + m_fh_object(0) +{ // warning no initialization of variables done by moto. + std::cout << "SM_Object::SM_Object()" << std::endl; } SM_Object:: diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp index 38c2b48e460..f7057fecb6e 100644 --- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp +++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp @@ -162,8 +162,8 @@ void SM_Scene::remove(SM_Object& object) { void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) { // Don't waste time...but it's OK to spill a little. - if (timeStep < 0.001) - return; + //if (timeStep < 0.001) + // return; // Divide the timeStep into a number of subsamples of size roughly // equal to subSampling (might be a little smaller). @@ -208,14 +208,16 @@ void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) { #if 0 clearObjectCombinedVelocities(); #endif - if (DT_Test(m_scene, m_fixRespTable)) +/* if (DT_Test(m_scene, m_fixRespTable)) for (i = m_objectList.begin(); i != m_objectList.end(); ++i) - (*i)->relax(); + (*i)->relax(); */ + DT_Test(m_scene, m_fixRespTable); // Finish this timestep by saving al state information for the next // timestep and clearing the accumulated forces. for (i = m_objectList.begin(); i != m_objectList.end(); ++i) { + (*i)->relax(); (*i)->proceedKinematic(timeStep); (*i)->saveReactionForce(timeStep); (*i)->clearForce(); diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp index c08c20cf9b9..5a3c6e19e9b 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp +++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.cpp @@ -71,6 +71,7 @@ SumoPhysicsController::~SumoPhysicsController() m_sumoScene->remove(*m_sumoObj); delete m_sumoObj; + m_sumoObj = NULL; } } diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp index 3e59be6a816..a44642de056 100644 --- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp @@ -56,6 +56,7 @@ SumoPhysicsEnvironment::SumoPhysicsEnvironment() SumoPhysicsEnvironment::~SumoPhysicsEnvironment() { + std::cout << "delete m_sumoScene " << m_sumoScene << std::endl; delete m_sumoScene; DT_DestroyScene(m_solidScene); //DT_DestroyRespTable(m_respTable); diff --git a/source/gameengine/Physics/Sumo/include/solid.h b/source/gameengine/Physics/Sumo/include/solid.h deleted file mode 100644 index 00f282ed2a7..00000000000 --- a/source/gameengine/Physics/Sumo/include/solid.h +++ /dev/null @@ -1,196 +0,0 @@ -#ifndef SOLID_H -#define SOLID_H - -#include "solid_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -DT_DECLARE_HANDLE(DT_ObjectHandle); -DT_DECLARE_HANDLE(DT_SceneHandle); -DT_DECLARE_HANDLE(DT_ShapeHandle); -DT_DECLARE_HANDLE(DT_RespTableHandle); - -typedef enum DT_ScalarType { - DT_FLOAT, - DT_DOUBLE -} DT_ScalarType; - -typedef enum DT_ResponseType { - DT_NO_RESPONSE, - DT_SIMPLE_RESPONSE, - DT_WITNESSED_RESPONSE, - DT_DEPTH_RESPONSE, -} DT_ResponseType; - -typedef struct DT_CollData { - DT_Vector3 point1; - DT_Vector3 point2; - DT_Vector3 normal; -} DT_CollData; - -typedef void (*DT_ResponseCallback)( - void *client_data, - void *client_object1, - void *client_object2, - const DT_CollData *coll_data); - -/* Shape definition, similar to OpenGL */ - -extern DT_ShapeHandle DT_Box(DT_Scalar x, DT_Scalar y, DT_Scalar z); -extern DT_ShapeHandle DT_Cone(DT_Scalar radius, DT_Scalar height); -extern DT_ShapeHandle DT_Cylinder(DT_Scalar radius, DT_Scalar height); -extern DT_ShapeHandle DT_Sphere(DT_Scalar radius); -extern DT_ShapeHandle DT_Ray(DT_Scalar x, DT_Scalar y, DT_Scalar z); - -extern DT_ShapeHandle DT_NewComplexShape(); -extern void DT_EndComplexShape(); - -extern DT_ShapeHandle DT_NewPolyhedron(); -extern void DT_EndPolyhedron(); - -extern void DT_Begin(); -extern void DT_End(); - -extern void DT_Vertex(DT_Scalar x, DT_Scalar y, DT_Scalar z); - -/* Vertex arrays maintained by the client application can be accessed directly - by SUMO. For instance, you have a vertex struct in the client of the form: - - struct Vertex { - float xyz[3]; - float uv[2]; - float normal[3]; - }; - - And maintain vertex arrays e.g. as - - struct Vertex vertices[328]; - - Within a Polyhedron or a ComplexShape you can use this data by specifying - - DT_VertexBase(vertices, DT_FLOAT, sizeof(struct Vertex)); - - and refer to vertices in the array using - - DT_VertexIndex(10); - - or - - DT_Index indices[5] = { 6, 4, 8, 1, 3 }; - DT_VertexIndices(5, indices); - - or even - - DT_VertexRange(8, 4); - - for the range 8, 9, 10, 11. -*/ - - -extern void DT_SetVertexBase(const void *base, DT_ScalarType type, - DT_Size stride); -extern void DT_VertexIndex(DT_Index index); -extern void DT_VertexIndices(DT_Count count, const DT_Index *indices); -extern void DT_VertexRange(DT_Index first, DT_Count count); - - -/* currently not implemented */ -extern void DT_ChangeVertexBase(DT_ShapeHandle shape, const void *base); - -extern void DT_DeleteShape(DT_ShapeHandle shape); - -/* Scene */ - -extern DT_SceneHandle DT_CreateScene(); -extern void DT_DeleteScene(DT_SceneHandle scene); - -extern void DT_AddObject(DT_SceneHandle scene, DT_ObjectHandle object); -extern void DT_RemoveObject(DT_SceneHandle scene, DT_ObjectHandle object); - - - -/* Object */ - -extern DT_ObjectHandle DT_CreateObject( - void *client_object, /* pointer to object in client memory */ - DT_ShapeHandle shape /* the shape or geometry of the object */ - ); - -extern void DT_DeleteObject(DT_ObjectHandle object); - -extern void DT_SetScaling(DT_ObjectHandle object, const DT_Vector3 scaling); -extern void DT_SetPosition(DT_ObjectHandle object, const DT_Vector3 position); -extern void DT_SetOrientation(DT_ObjectHandle object, const DT_Quaternion orientation); - -extern void DT_SetMargin(DT_ObjectHandle object, DT_Scalar margin); - -extern void DT_SetMatrixf(DT_ObjectHandle object, const float *m); -extern void DT_GetMatrixf(DT_ObjectHandle object, float *m); - -extern void DT_SetMatrixd(DT_ObjectHandle object, const double *m); -extern void DT_GetMatrixd(DT_ObjectHandle object, double *m); - -extern void DT_GetWorldCoord(DT_ObjectHandle object, - const DT_Vector3 local, - DT_Vector3 world); - -extern DT_Scalar DT_GetClosestPair(DT_ObjectHandle object1, DT_ObjectHandle object2, - DT_Vector3 point1, DT_Vector3 point2); - - -/* Response, see SOLID user manual */ - -extern DT_RespTableHandle DT_CreateRespTable(); -extern void DT_DeleteRespTable(DT_RespTableHandle respTable); - -extern void DT_CallResponse(DT_RespTableHandle respTable, - DT_ObjectHandle object1, - DT_ObjectHandle object2, - const DT_CollData *coll_data); - -extern void DT_SetDefaultResponse(DT_RespTableHandle respTable, - DT_ResponseCallback response, - DT_ResponseType type, - void *client_data); - -extern void DT_ClearDefaultResponse(DT_RespTableHandle respTable); - -extern void DT_SetObjectResponse(DT_RespTableHandle respTable, - DT_ObjectHandle object, - DT_ResponseCallback response, - DT_ResponseType type, void *client_data); -extern void DT_ClearObjectResponse(DT_RespTableHandle respTable, - DT_ObjectHandle object); - -extern void DT_SetPairResponse(DT_RespTableHandle respTable, - DT_ObjectHandle object1, - DT_ObjectHandle object2, - DT_ResponseCallback response, - DT_ResponseType type, - void *client_data); -extern void DT_ClearPairResponse(DT_RespTableHandle respTable, - DT_ObjectHandle object1, - DT_ObjectHandle object2); - - - -/* Perform a collision test for a given scene, using a response table */ - -extern DT_Count DT_Test(DT_SceneHandle scene, DT_RespTableHandle respTable); - -extern void *DT_RayTest(DT_SceneHandle scene, void *ignore_client, - const DT_Vector3 from, const DT_Vector3 to, - DT_Vector3 spot, DT_Vector3 normal); - -extern int DT_ObjectRayTest(DT_ObjectHandle object, - const DT_Vector3 from, const DT_Vector3 to, - DT_Vector3 spot, DT_Vector3 normal); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/source/gameengine/Physics/Sumo/include/solid_broadphase.h b/source/gameengine/Physics/Sumo/include/solid_broadphase.h deleted file mode 100644 index 20847898091..00000000000 --- a/source/gameengine/Physics/Sumo/include/solid_broadphase.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef SOLID_BROADPHASE_H -#define SOLID_BROADPHASE_H - -#include "solid_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -DT_DECLARE_HANDLE(BP_SceneHandle); -DT_DECLARE_HANDLE(BP_ProxyHandle); - -typedef void (*BP_Callback)(void *client_data, - void *object1, - void *object2); - -extern BP_SceneHandle BP_CreateScene(void *client_data, - BP_Callback beginOverlap, - BP_Callback endOverlap); - -extern void BP_DeleteScene(BP_SceneHandle scene); - -extern BP_ProxyHandle BP_CreateProxy(BP_SceneHandle scene, void *object, - const DT_Vector3 lower, - const DT_Vector3 upper); - -extern void BP_DeleteProxy(BP_SceneHandle scene, - BP_ProxyHandle proxy); - -extern void BP_SetBBox(BP_ProxyHandle proxy, - const DT_Vector3 lower, - const DT_Vector3 upper); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/source/gameengine/Physics/Sumo/include/solid_types.h b/source/gameengine/Physics/Sumo/include/solid_types.h deleted file mode 100644 index 64b345c1e09..00000000000 --- a/source/gameengine/Physics/Sumo/include/solid_types.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SOLID_TYPES_H -#define SOLID_TYPES_H - -#define DT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name - -typedef double DT_Scalar; -typedef unsigned int DT_Count; -typedef unsigned int DT_Index; -typedef unsigned int DT_Size; - -typedef DT_Scalar DT_Vector3[3]; -typedef DT_Scalar DT_Quaternion[4]; - -#endif - diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index b136aedf405..a4245025f2a 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -37,6 +37,15 @@ struct RAS_CameraData float m_lens; float m_clipstart; float m_clipend; + bool m_perspective; + + RAS_CameraData(float lens = 35., float clipstart = 0.1, float clipend = 100., bool perspective = true) : + m_lens(lens), + m_clipstart(clipstart), + m_clipend(clipend), + m_perspective(perspective) + { + } }; #endif //__RAS_CAMERADATA_H diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 144342e86cf..9871c0b67d6 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -94,8 +94,12 @@ public: virtual void ClearDepthBuffer()=0; virtual void ClearCachingInfo(void)=0; virtual void EndFrame()=0; + /** + * SetRenderArea sets the render area in the 2d canvas + */ virtual void SetRenderArea()=0; + // Stereo Functions virtual void SetStereoMode(const int stereomode)=0; virtual bool Stereo()=0; virtual void SetEye(const int eye)=0; @@ -103,6 +107,20 @@ public: virtual void SetFocalLength(const float focallength)=0; virtual void SwapBuffers()=0; + + // 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: + * 0 triangles + * 1 lines (default) + * 2 quads + * @param polymat (reserved) + * @param useObjectColor will render the object using @param rgbacolor instead of + * vertex colours. + */ virtual void IndexPrimitives( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, int mode, @@ -110,6 +128,10 @@ public: class RAS_IRenderTools* rendertools, bool useObjectColor, const MT_Vector4& rgbacolor)=0; + /** + * IndexPrimitivesEx: See IndexPrimitives. + * IndexPrimitivesEx will renormalize faces if @param vertexarrays[i].getFlag() & TV_CALCFACENORMAL + */ virtual void IndexPrimitives_Ex( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, int mode, @@ -117,6 +139,10 @@ public: 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. + */ virtual void IndexPrimitives_3DText( const vecVertexArray& vertexarrays, const vecIndexArrays & indexarrays, int mode, @@ -161,12 +187,18 @@ public: float blue, float alpha)=0; + /** + * @param drawingmode = KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED. + */ virtual void SetDrawingMode(int drawingmode)=0; virtual int GetDrawingMode()=0; virtual void EnableTextures(bool enable)=0; virtual void SetCullFace(bool enable)=0; + /** + * Sets wireframe mode. + */ virtual void SetLines(bool enable)=0; virtual double GetTime()=0; @@ -177,7 +209,8 @@ public: float bottom, float top, float frustnear, - float frustfar + float frustfar, + bool perspective = true )=0; virtual void SetSpecularity(float specX, diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index b7f375e770c..647fb21988a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -68,7 +68,7 @@ RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer() -void Myinit_gl_stuff(void) +static void Myinit_gl_stuff(void) { float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 }; float mat_shininess[] = { 35.0 }; @@ -259,7 +259,7 @@ void RAS_OpenGLRasterizer::Exit() glClearDepth(1.0); glClearColor(m_redback, m_greenback, m_blueback, m_alphaback); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glDepthMask (GL_TRUE); + glDepthMask (GL_TRUE); glDepthFunc(GL_LEQUAL); glBlendFunc(GL_ONE, GL_ZERO); @@ -292,7 +292,7 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time) glShadeModel(GL_SMOOTH); - m_2DCanvas->BeginFrame(); + m_2DCanvas->BeginFrame(); return true; } @@ -1083,7 +1083,8 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( float bottom, float top, float frustnear, - float frustfar + float frustfar, + bool perspective ){ MT_Matrix4x4 result; double mat[16]; @@ -1110,10 +1111,11 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( } // leave bottom, top, bottom and top untouched } - + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(left, right, bottom, top, frustnear, frustfar); + glGetDoublev(GL_PROJECTION_MATRIX, mat); result.setValue(mat); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 24f0e42c91d..d7488b9901a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -203,7 +203,8 @@ public: float bottom, float top, float frustnear, - float frustfar + float frustfar, + bool perspective ); virtual void SetSpecularity( diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index 4ce030ed484..8a51a25e6aa 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -73,10 +73,6 @@ bool RAS_VAOpenGLRasterizer::Init(void) if (result) { - // if possible, add extensions to other platforms too, if this - // rasterizer becomes messy just derive one for each platform - // (ie. KX_Win32Rasterizer, KX_LinuxRasterizer etc.) - glEnableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); @@ -187,6 +183,17 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays glColor3d(0,0,0); } // use glDrawElements to draw each vertexarray + static bool doWarning = true; + if (vertexarrays.size() > 1 && doWarning) + { + /* TODO: if vertexarrays.size() == 1 then if we are multitexturing + we can glLockArraysEXT the vertex arrays - GL will be able to cache + the vertex transforms. */ + std::cout << "# vertex arrays: " << vertexarrays.size() << std::endl; + std::cout << "I wondered if this could happen: please inform the proper authorities." << std::endl; + doWarning = false; + } + for (vt=0;vt