From a17074ece30ee8205df87f1f4d41326a3c30af91 Mon Sep 17 00:00:00 2001
From: Joseph Walton-Rivers <joseph@walton-rivers.uk>
Date: Sat, 30 Apr 2022 19:51:15 +0100
Subject: [PATCH] force rollball to use the player-tracking camera

---
 demo/demo/rollball.cpp | 40 ----------------------------------------
 1 file changed, 40 deletions(-)

diff --git a/demo/demo/rollball.cpp b/demo/demo/rollball.cpp
index 4f81014..6b4f0df 100644
--- a/demo/demo/rollball.cpp
+++ b/demo/demo/rollball.cpp
@@ -128,15 +128,6 @@ static void setupCamera(fggl::ecs3::World& world) {
 
 	// setup camera components
 	world.add<fggl::gfx::Camera>(prototype);
-	auto* cameraKeys = world.add<fggl::input::FreeCamKeys>(prototype);
-	if ( cameraKeys != nullptr ) {
-		cameraKeys->forward = glfwGetKeyScancode(GLFW_KEY_W);
-		cameraKeys->backward = glfwGetKeyScancode(GLFW_KEY_S);
-		cameraKeys->left = glfwGetKeyScancode(GLFW_KEY_A);
-		cameraKeys->right = glfwGetKeyScancode(GLFW_KEY_D);
-		cameraKeys->rotate_cw = glfwGetKeyScancode(GLFW_KEY_Q);
-		cameraKeys->rotate_ccw = glfwGetKeyScancode(GLFW_KEY_E);
-	}
 }
 
 static fggl::ecs3::entity_t setupEnvironment(fggl::ecs3::World& world, const Prefabs prefabs, fggl::math::vec2& size) {
@@ -195,33 +186,6 @@ static fggl::ecs3::entity_t setupEnvironment(fggl::ecs3::World& world, const Pre
 	return player;
 }
 
-enum camera_type { cam_free, cam_arcball };
-static camera_type cam_mode = cam_free;
-
-static void process_camera(fggl::ecs3::World& ecs, const fggl::input::Input& input) {
-	auto cameras = ecs.findMatching<fggl::gfx::Camera>();
-	fggl::ecs3::entity_t cam = cameras[0];
-
-	auto camTransform = ecs.get<fggl::math::Transform>(cam);
-	auto camComp = ecs.get<fggl::gfx::Camera>(cam);
-
-	const glm::vec3 dir = ( camTransform->origin() - camComp->target );
-	const glm::vec3 forward = glm::normalize( dir );
-
-	// scroll wheel
-	glm::vec3 motion(0.0f);
-	float delta = input.mouse.axis( fggl::input::MouseAxis::SCROLL_Y );
-	if ( (glm::length( dir ) < 25.0f && delta < 0.0f) || (glm::length( dir ) > 2.5f && delta > 0.0f) )
-		motion -= (forward * delta);
-	camTransform->origin( camTransform->origin() + motion );
-
-	if ( input.mouse.down( fggl::input::MouseButton::MIDDLE ) ) {
-		fggl::input::process_arcball(ecs, input, cam);
-	} else {
-		fggl::input::process_freecam(ecs, input, cam);
-	}
-	fggl::input::process_edgescroll( ecs, input, cam );
-}
 
 namespace demo {
 
@@ -246,9 +210,6 @@ namespace demo {
 		Game::update();
 		auto& input = this->input();
 
-		if ( input.keyboard.down(glfwGetKeyScancode(GLFW_KEY_F1))) {
-			process_camera(world(), input);
-		} else {
 			if ( player != fggl::ecs3::NULL_ENTITY ) {
 				auto &world = this->world();
 
@@ -295,7 +256,6 @@ namespace demo {
 					camTransform->origin( camComp->target - (fggl::math::FORWARD * 15.0F) + (fggl::math::UP * 15.0F) );
 				}
 
-			}
 		}
 	}
 
-- 
GitLab