From 745a3802dcc215a50543c9bcfc37f15aaea0cbfc Mon Sep 17 00:00:00 2001 From: lanariel Date: Thu, 20 Feb 2014 09:00:02 +0100 Subject: [PATCH 1/4] touched up SSAO and fixed wireframe rendering in release --- .../GameClient/GameClientState/GameState.cpp | 82 +++++++++---------- .../GameClientState/NetLoadState.cpp | 8 +- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 20 +++++ .../Shader/Passes/Light/SSAO.hlsli | 4 +- 4 files changed, 67 insertions(+), 47 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 61e1d9fc..763563ff 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -89,7 +89,7 @@ bool GameState::Init( SharedStateContent &shared ) Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y; this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f ); Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() ); - gfxOp.AmbientValue = 2.0f; + gfxOp.AmbientValue = 1.0f; Graphics::API::SetOptions(gfxOp); //tell server ready @@ -193,45 +193,45 @@ bool GameState::Render() }*/ // RB DEBUG render wire frame - //if(this->privData->renderWhireframe) - //{ - // Oyster::Graphics::API::StartRenderWireFrame(); - // - // Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); - // Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); - // Oyster::Math3D::Float4x4 world = translation * scale; - // Oyster::Graphics::API::RenderDebugCube( world ); - // Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); - // - // staticObject = this->privData->staticObjects->begin(); - // for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) - // { - // if( staticObject->second->getBRtype() == RB_Type_Cube) - // { - // Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); - // } - // if( staticObject->second->getBRtype() == RB_Type_Sphere) - // { - // Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); - // } - // } - // - // dynamicObject = this->privData->dynamicObjects->begin(); - // for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) - // { - // if( dynamicObject->second ) - // { - // if( dynamicObject->second->getBRtype() == RB_Type_Cube) - // { - // Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); - // } - // if( dynamicObject->second->getBRtype() == RB_Type_Sphere) - // { - // Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); - // } - // } - // } - //} + if(this->privData->renderWhireframe) + { + Oyster::Graphics::API::StartRenderWireFrame(); + + Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); + Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); + Oyster::Math3D::Float4x4 world = translation * scale; + Oyster::Graphics::API::RenderDebugCube( world ); + Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); + + staticObject = this->privData->staticObjects->begin(); + for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) + { + if( staticObject->second->getBRtype() == RB_Type_Cube) + { + Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); + } + if( staticObject->second->getBRtype() == RB_Type_Sphere) + { + Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); + } + } + + dynamicObject = this->privData->dynamicObjects->begin(); + for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) + { + if( dynamicObject->second ) + { + if( dynamicObject->second->getBRtype() == RB_Type_Cube) + { + Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); + } + if( dynamicObject->second->getBRtype() == RB_Type_Sphere) + { + Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); + } + } + } + } // !RB DEBUG Oyster::Graphics::API::EndFrame(); @@ -487,7 +487,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState if( !Within(position.Dot(position), 2500.0f, 90000.0f) ) { // HACK: bug trap const char *breakPoint = "Something is wrong."; - //position = Float3( 0.0f, 160.0f, 0.0f ); + position = Float3( 0.0f, 160.0f, 0.0f ); } this->privData->camera.SetPosition( position ); diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.cpp b/Code/Game/GameClient/GameClientState/NetLoadState.cpp index b2475cc6..e3e453ad 100644 --- a/Code/Game/GameClient/GameClientState/NetLoadState.cpp +++ b/Code/Game/GameClient/GameClientState/NetLoadState.cpp @@ -154,7 +154,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation - RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; + RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size*2; RBData.type = RB_Type_Cube; staticObject->InitRB( RBData ); } @@ -163,7 +163,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation - RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; + RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius*2; RBData.type = RB_Type_Sphere; staticObject->InitRB( RBData ); } @@ -198,7 +198,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation - RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size; + RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size*2; RBData.type = RB_Type_Cube; dynamicObject->InitRB( RBData ); } @@ -207,7 +207,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) { RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation - RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius; + RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius*2; RBData.type = RB_Type_Sphere; dynamicObject->InitRB( RBData ); } diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 89849f03..36cbfd54 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -221,6 +221,26 @@ namespace Oyster sphere->WorldMatrix = world; Render::DefaultRenderer::RenderScene(sphere,1,View,Projection); } +#else + API::State API::ReloadShaders() + { + + } + + void API::StartRenderWireFrame() + { + + } + + void API::RenderDebugCube(Math::Matrix world) + { + + } + + void API::RenderDebugSphere(Math::Matrix world) + { + + } #endif API::Option API::GetOption() diff --git a/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli b/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli index bf71b92b..f2258905 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli +++ b/Code/OysterGraphics/Shader/Passes/Light/SSAO.hlsli @@ -1,7 +1,7 @@ #include "Defines.hlsli" #include "PosManipulation.hlsli" -static float Radius = 100; +static float Radius = 10; float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) { @@ -41,7 +41,7 @@ float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) float sampleDepth = ViewPos.z; //compare to depth from sample - float rangeCheck = (abs(pos.z - sampleDepth) < Radius) ? 1.0f : 0.0f; + float rangeCheck = (abs(pos.z - sampleDepth) > Radius) ? 1.0f : 0.0f; occlusion += (sampleDepth <= sampled.z ? 1.0f : 0.0f) * rangeCheck; } occlusion /= (float)(SSAOKernel.Length.x); From 3527d3acb0059ab850d7015172abe73068095b34 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 20 Feb 2014 09:07:02 +0100 Subject: [PATCH 2/4] Network - Fixed memory leak in NetworkServer. --- Code/Network/NetworkAPI/NetworkServer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Code/Network/NetworkAPI/NetworkServer.cpp b/Code/Network/NetworkAPI/NetworkServer.cpp index 028ca58e..7d1cbdc5 100644 --- a/Code/Network/NetworkAPI/NetworkServer.cpp +++ b/Code/Network/NetworkAPI/NetworkServer.cpp @@ -83,7 +83,13 @@ public: , broadcastTime(1.0f, 0.0f) { } ~PrivateData() - { } + { + if(listener) + { + delete listener; + listener = NULL; + } + } bool DoWork(); From d80dec600b4c9326c8065585fee27cdc164b189d Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Thu, 20 Feb 2014 09:20:26 +0100 Subject: [PATCH 3/4] Memory leak dealt with + removed obsolete debug trap --- Code/Game/GameClient/GameClient.vcxproj.user | 2 +- Code/Game/GameClient/GameClientState/C_Object.cpp | 4 +++- Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp | 5 ----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Code/Game/GameClient/GameClient.vcxproj.user b/Code/Game/GameClient/GameClient.vcxproj.user index 2e28d6f7..4b847ee6 100644 --- a/Code/Game/GameClient/GameClient.vcxproj.user +++ b/Code/Game/GameClient/GameClient.vcxproj.user @@ -1,7 +1,7 @@  - true + false $(OutDir) diff --git a/Code/Game/GameClient/GameClientState/C_Object.cpp b/Code/Game/GameClient/GameClientState/C_Object.cpp index ccea9a86..50664a92 100644 --- a/Code/Game/GameClient/GameClientState/C_Object.cpp +++ b/Code/Game/GameClient/GameClientState/C_Object.cpp @@ -16,8 +16,10 @@ C_Object::C_Object() } C_Object::~C_Object() { - + if( this->model ) + this->Release(); } + bool C_Object::Init(ModelInitData modelInit) { position = modelInit.position; diff --git a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp index 0cf4500d..14b16838 100644 --- a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp +++ b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp @@ -136,11 +136,6 @@ void Camera_FPSV2::StrafeLeft( Float distance ) void Camera_FPSV2::PitchUp( Float radian ) { - if( radian >= 0.5f ) - { // HACK: debugging - const char *breakPoint = ""; - } - this->pitchUp = Clamp( this->pitchUp + radian, -0.48f * pi, 0.48f * pi ); this->pitchHaveChanged = true; } From 7b877077144933cfe8d23ed4b261dd70433c73b0 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 09:21:38 +0100 Subject: [PATCH 4/4] GmaeClient fix RBsphere radius --- .../GameClientState/NetLoadState.cpp | 8 +-- Code/Game/GameLogic/Level.cpp | 4 +- Code/Game/GameLogic/Player.cpp | 72 +++++++++---------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/NetLoadState.cpp b/Code/Game/GameClient/GameClientState/NetLoadState.cpp index 8eb65fa8..de4f57d5 100644 --- a/Code/Game/GameClient/GameClientState/NetLoadState.cpp +++ b/Code/Game/GameClient/GameClientState/NetLoadState.cpp @@ -152,7 +152,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBInitData RBData; if(oh->boundingVolume.geoType == CollisionGeometryType_Box) { - RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; + RBData.position = ((Float3)oh->position + (Float3)oh->boundingVolume.box.position) * (Float3)oh->scale; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size * 2; RBData.type = RB_Type_Cube; @@ -161,7 +161,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) if(oh->boundingVolume.geoType == CollisionGeometryType_Sphere) { - RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; + RBData.position = ((Float3)oh->position + (Float3)oh->boundingVolume.box.position) * (Float3)oh->scale; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius * 2; RBData.type = RB_Type_Sphere; @@ -196,7 +196,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) RBInitData RBData; if(oh->boundingVolume.geoType == CollisionGeometryType_Box) { - RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.box.position; + RBData.position = ((Float3)oh->position + (Float3)oh->boundingVolume.box.position) * (Float3)oh->scale; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * (Float3)oh->boundingVolume.box.size * 2; RBData.type = RB_Type_Cube; @@ -205,7 +205,7 @@ void NetLoadState::LoadGame( const ::std::string &fileName ) if(oh->boundingVolume.geoType == CollisionGeometryType_Sphere) { - RBData.position = (Float3)oh->position + (Float3)oh->boundingVolume.sphere.position; + RBData.position = ((Float3)oh->position + (Float3)oh->boundingVolume.box.position) * (Float3)oh->scale; RBData.rotation = ArrayToQuaternion( oh->rotation ); // Only model rotation RBData.scale = (Float3)oh->scale * oh->boundingVolume.sphere.radius * 2; RBData.type = RB_Type_Sphere; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 82cd4364..9febbe47 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -196,8 +196,8 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj) rigidBodyMass = obj->scale[0] * obj->scale[1] * obj->scale[2] * obj->boundingVolume.sphere.mass; //Radius scaled - //rigidBodyRadius = (staticObjData->scale[0] + staticObjData->scale[1] + staticObjData->scale[2] / 3) * staticObjData->boundingVolume.sphere.radius; - rigidBodyRadius = (obj->scale[0] * obj->scale[1] * obj->scale[2]) * obj->boundingVolume.sphere.radius; + rigidBodyRadius = (obj->scale[0]) * obj->boundingVolume.sphere.radius; + //rigidBodyRadius = (obj->scale[0] * obj->scale[1] * obj->scale[2]) * obj->boundingVolume.sphere.radius; //create the rigid body rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 93ba37be..77953d43 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -79,22 +79,22 @@ void Player::BeginFrame() Oyster::Math::Float maxSpeed = 30; - /*Oyster::Math::Float4x4 xform; - xform = this->rigidBody->GetState().GetOrientation();*/ + Oyster::Math::Float4x4 xform; + xform = this->rigidBody->GetState().GetOrientation(); /* Handle turning */ /*if (left) m_turnAngle -= dt * m_turnVelocity; if (right) - m_turnAngle += dt * m_turnVelocity;*/ + m_turnAngle += dt * m_turnVelocity; - //xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle)); + xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle));*/ - Oyster::Math::Float3 linearVelocity(0,0,0); // = this->rigidBody->GetLinearVelocity(); + Oyster::Math::Float3 linearVelocity = this->rigidBody->GetLinearVelocity(); Oyster::Math::Float speed = this->rigidBody->GetLinearVelocity().GetLength(); - Oyster::Math::Float3 forwardDir(0,0,1); //= xform.v[2]; - Oyster::Math::Float3 rightDir(1,0,0); // = xform.v[0]; + Oyster::Math::Float3 forwardDir = xform.v[2]; + Oyster::Math::Float3 rightDir = xform.v[0]; forwardDir.Normalize(); rightDir.Normalize(); Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0); @@ -102,28 +102,28 @@ void Player::BeginFrame() if (key_forward > 0.001) { - key_forward -= gameInstance->GetFrameTime(); - walkDirection += forwardDir; - walkDirection.Normalize(); + key_forward -= gameInstance->GetFrameTime(); + walkDirection += forwardDir; + walkDirection.Normalize(); } if (key_backward > 0.001) { - key_backward -= gameInstance->GetFrameTime(); - walkDirection -= forwardDir; - walkDirection.Normalize(); + key_backward -= gameInstance->GetFrameTime(); + walkDirection -= forwardDir; + walkDirection.Normalize(); } if (key_strafeRight > 0.001) { - key_strafeRight -= gameInstance->GetFrameTime(); - walkDirection -= rightDir; - walkDirection.Normalize(); + key_strafeRight -= gameInstance->GetFrameTime(); + walkDirection -= rightDir; + walkDirection.Normalize(); } if (key_strafeLeft > 0.001) { - key_strafeLeft -= gameInstance->GetFrameTime(); - walkDirection += rightDir; - walkDirection.Normalize(); - maxSpeed = 40; + key_strafeLeft -= gameInstance->GetFrameTime(); + walkDirection += rightDir; + walkDirection.Normalize(); + maxSpeed = 40; } @@ -131,21 +131,21 @@ void Player::BeginFrame() { /* Dampen when on the ground and not being moved by the player */ linearVelocity *= 0.2f; - //this->rigidBody->SetLinearVelocity (linearVelocity); + this->rigidBody->SetLinearVelocity (linearVelocity); } - //else - //{ - // if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f) - // { - // Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; - // this->rigidBody->SetLinearVelocity(velocity); - // } - // else if(speed < maxSpeed) - // { - // Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; - // this->rigidBody->SetLinearVelocity(velocity); - // } - //} + else + { + if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f) + { + Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; + this->rigidBody->SetLinearVelocity(velocity); + } + else if(speed < maxSpeed) + { + Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; + this->rigidBody->SetLinearVelocity(velocity); + } + } if (key_jump > 0.001) { @@ -158,7 +158,7 @@ void Player::BeginFrame() } } Oyster::Math::Float3 pos = this->rigidBody->GetState().centerPos; - if(pos.x < -300000) + if(pos == Oyster::Math::Float3(0,0,0)) int i =0; //this->weapon->Update(0.01f); @@ -169,7 +169,7 @@ void Player::EndFrame() // snap to axis Oyster::Math::Float4 rotation; - //this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); + this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); //Object::EndFrame(); }