DXInput::~DXInput() { m_pDIMouse->Unacquire(); m_pDIKeyboard->Unacquire(); ReleasePtr(m_pDIMouse); ReleasePtr(m_pDIKeyboard); ReleasePtr(m_pDirectInput); }
bool DX10_Obj_LitTex::Initialise(DX10_Renderer* _pRenderer, DX10_Mesh* _pMesh, DX10_Shader_LitTex* _pShader, std::vector<std::string>* _pTexNames, float _textureTime) { if (_pRenderer == 0 || _pMesh == 0 || _pShader == 0 || _pTexNames == 0|| _textureTime < 0) { // If any pointers are NULL, Object cannot be initialized return false; } if (_textureTime == 0.0f && _pTexNames->size() != 1) { return false; } // Assign Member Variables m_pRenderer = _pRenderer; m_pMesh = _pMesh; m_pShader = _pShader; m_texIndex = 0; m_texTimer = _textureTime; m_pTextures = new std::vector<ID3D10ShaderResourceView*>; for (UINT i = 0; i < _pTexNames->size(); i++) { ID3D10ShaderResourceView* pTempTex = 0; VALIDATE(m_pRenderer->CreateTexture((*_pTexNames)[i], pTempTex)); m_pTextures->push_back(pTempTex); } // Delete allocated memory ReleasePtr(_pTexNames); return true; }
SoundManager::~SoundManager() { // Release the sound system and files ReleasePtr(m_pMusic_DNB); ReleasePtr(m_pEffect_splash_ps); ReleasePtr(m_pEffect_menu_nav); ReleasePtr(m_pEffect_menu_back); ReleasePtr(m_pEffect_menu_accept); ReleasePtr(m_pEffect_menu_tog); ReleasePtr(m_pEffect_player_hit); ReleasePtr(m_pEffect_player_death); ReleasePtr(m_pSoundSystem); }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void CCatalogsHttpTransaction::SetConnection( CCatalogsConnection& aConnection ) { DLTRACEIN(("")); ReleasePtr( iConnection ); iConnection = &aConnection; iConnection->AddRef(); Config().SetConnectionMethod( aConnection.ConnectionMethod() ); }
void DX10_Renderer::ShutDown() { if (m_fullScreen == true) { m_pDX10SwapChain->SetFullscreenState(true, NULL); } // Delete the Graphics memory stored as DX10 Textures std::map<std::string, ID3D10ShaderResourceView*>::iterator iterTexture = m_textures.begin(); while (iterTexture != m_textures.end()) { ReleaseCOM(iterTexture->second); iterTexture++; } // Delete the Graphics memory stored as DX10 InputLayers std::map<UINT, ID3D10InputLayout*>::iterator iterInputLayout = m_inputLayouts.begin(); while (iterInputLayout != m_inputLayouts.end()) { ReleaseCOM(iterInputLayout->second); iterInputLayout++; } // Delete the Graphics memory stored as DX10 Effects std::map<std::string, ID3D10Effect*>::iterator iterFX = m_fxFiles.begin(); while (iterFX != m_fxFiles.end()) { ReleaseCOM(iterFX->second); iterFX++; } // Delete the Graphics memory stored as Buffers std::map<UINT, DX10_Buffer*>::iterator iterBuffers = m_buffers.begin(); while (iterBuffers != m_buffers.end()) { ReleasePtr(iterBuffers->second); iterBuffers++; } ReleaseCOM(m_pDepthStencilStateNormal); ReleaseCOM(m_pDepthStencilStateZDisabled); ReleaseCOM(m_pDepthStencilView); ReleaseCOM(m_pDepthStencilBuffer); ReleaseCOM(m_pRenderTargetView); ReleaseCOM(m_pDX10SwapChain); ReleaseCOM(m_pRasterizerState); ReleaseCOM(m_pRasterizerState_Reflection); if (m_pDX10Device != 0) { m_pDX10Device->ClearState(); } ReleaseCOM(m_pDX10Device); }
Menu::~Menu() { // Release all sprite related resources ReleasePtr(m_pShader_Sprite); ReleasePtr(m_title); while (!m_sprites.empty()) { ReleasePtr(m_sprites.back()); m_sprites.pop_back(); } while (!m_toggleButtons.empty()) { ReleasePtr(m_toggleButtons.back()); m_toggleButtons.pop_back(); } while (!m_buttons.empty()) { ReleasePtr(m_buttons.back()); m_buttons.pop_back(); } }
// --------------------------------------------------------------------------- // Destructor // --------------------------------------------------------------------------- // CCatalogsHttpTransaction::~CCatalogsHttpTransaction() { DLTRACEIN(( "Deleting Operation: %i, id: %i", reinterpret_cast<TInt>( this ), OperationId().Id() )); SetTransferring( EFalse ); ReleasePtr( iConnection ); DLTRACE(( "Removing from owner" )); delete iHttp; iOwner.RemoveOperation( this ); iOwner.CompleteOperation( this ); DLTRACE(( "Deleting config" )); delete iConfig; DLTRACE(( "Deleting response headers" )); delete iResponseHeaders; DLTRACE(( "Deleting request body" )); delete iRequestBody; DLTRACE(( "Deleting content type" )); delete iContentType; delete iUri; delete iEncodedUri; delete iResponseStatusText; delete iCallBack; DLTRACEOUT(( "" )); }
* File Name : DX10_Camera_FirstPerson.h * Description : First Person Camera for DirectX 10 * Author : Callan Moore * Mail : [email protected] */ // Local Includes #include "DX10_Camera_FirstPerson.h" DX10_Camera_FirstPerson::DX10_Camera_FirstPerson() { } DX10_Camera_FirstPerson::~DX10_Camera_FirstPerson() { ReleasePtr(m_pDirectInput) } bool DX10_Camera_FirstPerson::Initialise(DX10_Renderer* _pRenderer, HINSTANCE _hInstance, HWND _hWnd) { m_pRenderer = _pRenderer; m_pDirectInput = new DirectInput(); VALIDATE(m_pDirectInput->Initialise(_hInstance, _hWnd)); m_position = D3DXVECTOR3(0.0f, 25.0f, -50.0f); m_target = D3DXVECTOR3(0.0f, 0.0f, 0.0f); m_up = D3DXVECTOR3(0.0f, 1.0f, 0.0f); m_forward = D3DXVECTOR3(0.0f, 0.0f, 1.0f); m_right = D3DXVECTOR3(1.0f, 0.0f, 0.0f); m_defaultForward = D3DXVECTOR3(0.0f, 0.0f, 1.0f); m_defaultRight = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
bool Physics_Cloth::ResetCloth() { // Clear Memory ReleaseCloth(); ReleaseSelected(); m_contraints.clear(); m_nextIndex = 0; if (m_initialisedParticles == false) { ReleasePtr(m_pMesh); ReleasePtrArray(m_pParticles); // Create memory for all the particles m_particleCount = m_particlesWidthCount * m_particlesHeightCount; m_pParticles = new Physics_Particle[m_particleCount]; m_pVertices = new TVertexColor[m_particleCount]; // Calculate how many indices there are with be based on how many particles there are using line list int immediateConstraintCount = (m_particlesWidthCount - 1) * (m_particlesHeightCount - 1) * 4 + (m_particlesWidthCount - 1) + (m_particlesHeightCount - 1); int secondaryConstraintCount = 0; if (m_complexWeave == true) { // Calculate the secondary indices count only if the weave is set to complex secondaryConstraintCount = (m_particlesWidthCount - 2) * (m_particlesHeightCount - 2) * 4 + ((m_particlesWidthCount - 2) * 2) + ((m_particlesHeightCount - 2) * 2); } // Create the indices buffer with the amount of calculated constraints m_indexCount = (immediateConstraintCount + secondaryConstraintCount) * 2; m_pIndices = new DWORD[m_indexCount]; } // Cycle through all the particles for (int col = 0; col < m_particlesWidthCount; col++) { for (int row = 0; row < m_particlesHeightCount; row++) { // Calculate the position based on the particles row and column v3float pos; pos.x = m_width * (col / (float)m_width) - ((float)m_width / 2.0f); pos.y = -m_height * (row / (float)m_height) + ((float)m_height / 2.0f); pos.z = 0.0f; int index = row * m_particlesWidthCount + col; if (m_initialisedParticles == false) { // First time. Initialise m_pVertices[index] = { { pos.x, pos.y, pos.z }, d3dxColors::White }; VALIDATE(m_pParticles[index].Initialise(index, &m_pVertices[index], pos, m_timeStep, m_damping)); } else { // Particle has already been initialized so just reset the position m_pParticles[index].Reset(); m_pParticles[index].SetPosition(pos, true); m_pVertices[index].color = d3dxColors::White; } } } // Connect Particles that are immediately to the right and below (include diagonals) for (int col = 0; col < m_particlesWidthCount; col++) { for (int row = 0; row < m_particlesHeightCount; row++) { // Particle to the Right exists if (col < m_particlesWidthCount - 1) { VALIDATE(MakeConstraint(GetParticleIndex(col, row), GetParticleIndex(col + 1, row), true)); // Add the constraint index to each attached particle GetParticle(col, row)->AddContraintIndex(m_contraints.size() - 1); GetParticle(col + 1, row)->AddContraintIndex(m_contraints.size() - 1); } // Particle below exists if (row < m_particlesHeightCount - 1) { VALIDATE(MakeConstraint(GetParticleIndex(col, row), GetParticleIndex(col, row + 1), true)); // Add the constraint index to each attached particle GetParticle(col, row)->AddContraintIndex(m_contraints.size() - 1); GetParticle(col, row + 1)->AddContraintIndex(m_contraints.size() - 1); } // Particle to the right and below exists if ((col < m_particlesWidthCount - 1) && (row < m_particlesHeightCount - 1)) { VALIDATE(MakeConstraint(GetParticleIndex(col, row), GetParticleIndex(col + 1, row + 1), true)); // Add the constraint index to each attached particle GetParticle(col, row)->AddContraintIndex(m_contraints.size() - 1); GetParticle(col + 1, row + 1)->AddContraintIndex(m_contraints.size() - 1); VALIDATE(MakeConstraint(GetParticleIndex(col + 1, row), GetParticleIndex(col, row + 1), true)); // Add the constraint index to each attached particle GetParticle(col + 1, row)->AddContraintIndex(m_contraints.size() - 1); GetParticle(col, row + 1)->AddContraintIndex(m_contraints.size() - 1); } } } if (m_complexWeave == true) { // Connect Particles the are one step further away than previous loop for (int col = 0; col < m_particlesWidthCount; col++) { for (int row = 0; row < m_particlesHeightCount; row++) { // Particle to the Right exists if (col < m_particlesWidthCount - 2) { VALIDATE(MakeConstraint(GetParticleIndex(col, row), GetParticleIndex(col + 2, row), false)); // Add the constraint index to each attached particle GetParticle(col, row)->AddContraintIndex(m_contraints.size() - 1); GetParticle(col + 2, row)->AddContraintIndex(m_contraints.size() - 1); } // Particle below exists if (row < m_particlesHeightCount - 2) { VALIDATE(MakeConstraint(GetParticleIndex(col, row), GetParticleIndex(col, row + 2), false)); // Add the constraint index to each attached particle GetParticle(col, row)->AddContraintIndex(m_contraints.size() - 1); GetParticle(col, row + 2)->AddContraintIndex(m_contraints.size() - 1); } // Particle to the right and below exists if ((col < m_particlesWidthCount - 2) && (row < m_particlesHeightCount - 2)) { VALIDATE(MakeConstraint(GetParticleIndex(col, row), GetParticleIndex(col + 2, row + 2), false)); // Add the constraint index to each attached particle GetParticle(col, row)->AddContraintIndex(m_contraints.size() - 1); GetParticle(col + 2, row + 2)->AddContraintIndex(m_contraints.size() - 1); VALIDATE(MakeConstraint(GetParticleIndex(col + 2, row), GetParticleIndex(col, row + 2), false)); // Add the constraint index to each attached particle GetParticle(col + 2, row)->AddContraintIndex(m_contraints.size() - 1); GetParticle(col, row + 2)->AddContraintIndex(m_contraints.size() - 1); } } } } if (m_initialisedParticles == false) { // Create a new Cloth Mesh m_pMesh = new DX10_Mesh(); VALIDATE(m_pMesh->InitialiseCloth(m_pRenderer, m_pVertices, m_pIndices, m_particleCount, m_indexCount, sizeof(TVertexColor), D3D10_PRIMITIVE_TOPOLOGY_LINELIST, D3D10_USAGE_DYNAMIC, D3D10_USAGE_DYNAMIC)); } // Create the hooks and pin the cloth CreateHooks(); // Add a wind force of 1 down the Z axis to settle the cloth AddForce({ 0.0f, 0.0f, 1.0f }, FT_GENERIC, false); Process(CT_NONE); m_initialisedParticles = true; return true; }
Physics_Cloth::~Physics_Cloth() { // Release allocated memory ReleasePtr(m_pMesh); ReleasePtrArray(m_pParticles); }
// --------------------------------------------------------------------------- // Request completed // --------------------------------------------------------------------------- // void CCatalogsHttpTransaction::DoRequestCompletedL( TInt aError ) { DLTRACEIN( ("Error: %d", aError ) ); iOwner.CompleteOperation( this ); if ( ( aError == KErrDisconnected ) && iRetryCount && iState.iProgressState < ECatalogsHttpResponseHeaderReceived ) { DLTRACE(("Retrying")); iRetryCount--; // This ensures that connection is reset for this op ReleasePtr( iConnection ); iState.iOperationState = ECatalogsHttpOpCreated; iState.iProgressState = ECatalogsHttpNone; // Start asynchronously so that CCatalogsHttpStack is not deleted // inside an MHFRunL-callback AsyncStartL(); return; } if ( aError == KErrNone ) { iState.iOperationState = ECatalogsHttpOpCompleted; iState.iProgressState = ECatalogsHttpDone; // Report to the observer NotifyObserver(); } else { DLTRACE(("Handling error")); iState.iOperationState = ECatalogsHttpOpFailed; // HandleHttpError would also Cancel the operation but it's // already been complete by CompleteOperation if ( aError < KErrNone ) { UpdateAccessPoint( TCatalogsConnectionMethod() ); // Symbian error codes iObserver->HandleHttpError( *this, TCatalogsHttpError( ECatalogsHttpErrorGeneral, aError ) ); } else { // HTTP errors iObserver->HandleHttpError( *this, TCatalogsHttpError( ECatalogsHttpErrorHttp, KCatalogsErrorHttpBase - aError ) ); } } DLTRACEOUT(("")); }
GDI_Spring::~GDI_Spring() { ReleasePtr(m_pSpring); }
DX10_Obj_LitTex::~DX10_Obj_LitTex() { ReleasePtr(m_pTextures); }
void Physics_Collision_Listener::ResolveBreak(b2Contact* _contact) { int numPoints = _contact->GetManifold()->pointCount; // Get the collision points from the contact manifold b2WorldManifold worldmanifold; _contact->GetWorldManifold(&worldmanifold); b2Vec2* collisionPoint = worldmanifold.points; // Convert the collision points into v2floats v2float* pPoints = new v2float[numPoints]; for (int i = 0; i < numPoints; i++) { pPoints[i] = { collisionPoint[i].x, collisionPoint[i].y }; } // Get the velocity of each object in the collision b2Vec2 velocityA = _contact->GetFixtureA()->GetBody()->GetLinearVelocityFromWorldPoint(collisionPoint[0]); b2Vec2 velocityB = _contact->GetFixtureB()->GetBody()->GetLinearVelocityFromWorldPoint(collisionPoint[0]); Physics_Body_2D* pPhysicsBody = 0; v2float impactVelocity; b2Vec2 linearVelocity; float impactSpeed; // Set the break properties of the first object if its breakable if (_contact->GetFixtureA()->GetFilterData().categoryBits == CT_BREAKABLE) { // Calculate the impact velocity of the other object b2Vec2 b2ImpactVelocity = velocityA - velocityB; impactVelocity = { b2ImpactVelocity.x, b2ImpactVelocity.y }; impactSpeed = impactVelocity.Magnitude(); if (impactSpeed > 1.0f) { // Retrieve the physics body of the object that needs breaking pPhysicsBody = (Physics_Body_2D*)(_contact->GetFixtureA()->GetBody()->GetUserData()); linearVelocity = _contact->GetFixtureA()->GetBody()->GetLinearVelocity(); // Set the collision properties of the object to be broken TCollisionProperties collisionProps; collisionProps.isBreaking = true; collisionProps.pCollisionWorldPoints = pPoints; collisionProps.impactVelocity = impactVelocity; collisionProps.linearVelocity = { linearVelocity.x, linearVelocity.y }; pPhysicsBody->SetCollisionProperties(collisionProps); } else { // Delete allocated memory that will not be stored ReleasePtr(pPoints); } } // Set the break properties of the second object if its breakable if (_contact->GetFixtureB()->GetFilterData().categoryBits == CT_BREAKABLE) { // Calculate the impact velocity of the other object b2Vec2 b2ImpactVelocity = velocityB - velocityA; impactVelocity = { b2ImpactVelocity.x, b2ImpactVelocity.y }; impactSpeed = impactVelocity.Magnitude(); if (impactSpeed > 1.0f) { // Retrieve the physics body of the object that needs breaking pPhysicsBody = (Physics_Body_2D*)(_contact->GetFixtureB()->GetBody()->GetUserData()); linearVelocity = _contact->GetFixtureB()->GetBody()->GetLinearVelocity(); // Set the collision properties of the object to be broken TCollisionProperties collisionProps; collisionProps.isBreaking = true; collisionProps.pCollisionWorldPoints = pPoints; collisionProps.impactVelocity = impactVelocity; collisionProps.linearVelocity = { linearVelocity.x, linearVelocity.y }; pPhysicsBody->SetCollisionProperties(collisionProps); } else { // Delete allocated memory that will not be stored ReleasePtr(pPoints); } } }