Просмотр исходного кода

Fixed wall pushing back too far when colliding (since there may be two overlapping wall elements)

Sanjay Madhav 8 лет назад
Родитель
Сommit
718bc28700

+ 6 - 4
Chapter10/FPSActor.cpp

@@ -7,7 +7,7 @@
 // ----------------------------------------------------------------
 
 #include "FPSActor.h"
-#include "PlayerMove.h"
+#include "MoveComponent.h"
 #include "SDL/SDL_scancode.h"
 #include "Renderer.h"
 #include "AudioSystem.h"
@@ -22,7 +22,7 @@
 FPSActor::FPSActor(Game* game)
 	:Actor(game)
 {
-	mMoveComp = new PlayerMove(this);
+	mMoveComp = new MoveComponent(this);
 	mAudioComp = new AudioComponent(this);
 	mLastFootstep = 0.0f;
 	mFootstep = mAudioComp->PlayEvent("event:/Footstep");
@@ -209,8 +209,10 @@ void FPSActor::FixCollisions()
 			{
 				pos.z += dz;
 			}
+
+			// Need to set position and update box component
+			SetPosition(pos);
+			mBoxComp->OnUpdateWorldTransform();
 		}
 	}
-
-	SetPosition(pos);
 }

+ 0 - 2
Chapter10/Game.vcxproj

@@ -30,7 +30,6 @@
     <ClCompile Include="MoveComponent.cpp" />
     <ClCompile Include="PhysWorld.cpp" />
     <ClCompile Include="PlaneActor.cpp" />
-    <ClCompile Include="PlayerMove.cpp" />
     <ClCompile Include="Renderer.cpp" />
     <ClCompile Include="Shader.cpp" />
     <ClCompile Include="SoundEvent.cpp" />
@@ -58,7 +57,6 @@
     <ClInclude Include="MoveComponent.h" />
     <ClInclude Include="PhysWorld.h" />
     <ClInclude Include="PlaneActor.h" />
-    <ClInclude Include="PlayerMove.h" />
     <ClInclude Include="Renderer.h" />
     <ClInclude Include="Shader.h" />
     <ClInclude Include="SoundEvent.h" />

+ 0 - 6
Chapter10/Game.vcxproj.filters

@@ -85,9 +85,6 @@
     <ClCompile Include="PhysWorld.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="PlayerMove.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="TargetActor.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
@@ -165,9 +162,6 @@
     <ClInclude Include="PhysWorld.h">
       <Filter>Source Files</Filter>
     </ClInclude>
-    <ClInclude Include="PlayerMove.h">
-      <Filter>Source Files</Filter>
-    </ClInclude>
     <ClInclude Include="TargetActor.h">
       <Filter>Source Files</Filter>
     </ClInclude>

+ 0 - 25
Chapter10/PlayerMove.cpp

@@ -1,25 +0,0 @@
-// ----------------------------------------------------------------
-// From Game Programming in C++ by Sanjay Madhav
-// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-// 
-// Released under the BSD License
-// See LICENSE in root directory for full details.
-// ----------------------------------------------------------------
-
-#include "PlayerMove.h"
-#include "Actor.h"
-#include "Game.h"
-#include "PhysWorld.h"
-
-PlayerMove::PlayerMove(Actor* owner)
-	:MoveComponent(owner)
-{
-}
-
-void PlayerMove::Update(float deltaTime)
-{
-	// Move component does (forward/strafe/rotate)
-	MoveComponent::Update(deltaTime);
-
-	// Test my AABB versus every plane
-}

+ 0 - 19
Chapter10/PlayerMove.h

@@ -1,19 +0,0 @@
-// ----------------------------------------------------------------
-// From Game Programming in C++ by Sanjay Madhav
-// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
-// 
-// Released under the BSD License
-// See LICENSE in root directory for full details.
-// ----------------------------------------------------------------
-
-#pragma once
-#include "MoveComponent.h"
-
-class PlayerMove : public MoveComponent
-{
-public:
-	PlayerMove(class Actor* owner);
-
-	void Update(float deltaTime) override;
-protected:
-};