Skip to content

Commit

Permalink
Merge pull request #302 from carboncopies/296-add-all-camera-config-p…
Browse files Browse the repository at this point in the history
…arams-to-scenecamera

296 add all camera config params to scenecamera
  • Loading branch information
datacrystals authored Aug 14, 2022
2 parents 10cdd64 + 5394519 commit 9fc4654
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,18 @@ void GUI_Window_ObjectProperties::Draw() {
ImGui::SameLine();
ImGui::HelpMarker("Sets the maximum distance after which geometry is ignored.");


ImGui::Spacing();


ImGui::SliderInt("Asset Streaming Priority", &Camera->StreamingPriority_, 0, 10);
ImGui::SameLine();
ImGui::HelpMarker("Sets the priority of the camera on a scale from 1-10.");


ImGui::Spacing();


ImGui::Checkbox("Enforce Aspect Ratio", &Camera->EnforceAspectRatio_);
ImGui::SameLine();
ImGui::HelpMarker("Manually override the camera's aspect ratio. Will cause letterboxing if the ratios don't match.");
Expand Down Expand Up @@ -368,25 +378,15 @@ void GUI_Window_ObjectProperties::Draw() {
}
ImGui::EndChild();





}





}

// End System Controls Window
ImGui::End();

}



}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ void GUI_Window_RenderingSettings::Draw() {
}
}

// FOV Slider
ImGui::SliderFloat("FOV", &Settings->FOV_, 0.0f, 180.0f);





ImGui::Separator();
ImGui::TextColored(ImVec4(0.2f, 0.8f, 0.2f, 1.0f), "Shadow Maps");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ std::map<unsigned int, int> ERS_CLASS_AssetStreamingManager::CalculateCameraMaxU
for (unsigned int i = 0; i < Cameras.size(); i++) {
TotalCameraPriorities += Cameras[i]->GetStreamingPriority();
}
TotalCameraPriorities = std::max(1, TotalCameraPriorities);

// Calculate Percentage Of Total Updates Each Camera Should Have
std::vector<float> CameraUpdatePercentages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ void ERS_CLASS_VisualRenderer::UpdateViewports(float DeltaTime, ERS_CLASS_SceneM
ProjectUtils_->ModelLoader_->AssetStreamingManager_->UpdateSceneStreamingQueue(SceneManager->Scenes_[SceneManager->ActiveScene_].get(), Cameras);


// // Update Camera Location If System Running
// if (!IsEditorMode_ && Index == 0 && Scene->ActiveSceneCameraIndex != -1) {
// Viewport->Camera->SetPosition(Scene->SceneCameras[Scene->ActiveSceneCameraIndex]->Pos_);
// Viewport->Camera->SetRotation(Scene->SceneCameras[Scene->ActiveSceneCameraIndex]->Rot_);
// }

// Apply Scene Camera Transforms
ERS_STRUCT_Scene* Scene = ProjectUtils_->SceneManager_->Scenes_[ProjectUtils_->SceneManager_->ActiveScene_].get();
if (!IsEditorMode_ && Scene->ActiveSceneCameraIndex != -1) {
ERS_STRUCT_Camera* Camera = Viewports_[0]->Camera.get();
ERS_STRUCT_SceneCamera* SceneCamera = Scene->SceneCameras[Scene->ActiveSceneCameraIndex].get();
if (SceneCamera->EnforceAspectRatio_) {
Camera->SetAspectRatio(SceneCamera->AspectRatio_);
}
Camera->SetClipBoundries(SceneCamera->NearClip_, SceneCamera->FarClip_);
Camera->SetFOV(SceneCamera->FOV_);
Camera->SetPosition(SceneCamera->Pos_);
Camera->SetRotation(SceneCamera->Rot_);
Camera->SetStreamingPriority(SceneCamera->StreamingPriority_);
}

// Set Depth Shader For Shadow System
DepthMapShader_ = Shaders_[ERS_FUNCTION_FindShaderByName(std::string("_DepthMap"), &Shaders_)].get();
Expand Down Expand Up @@ -324,10 +344,7 @@ void ERS_CLASS_VisualRenderer::UpdateViewport(int Index, ERS_CLASS_SceneManager*
bool MouseXInRange = (MousePositionX >= WindowTopLeftCornerX) && (MousePositionX < WindowBottomRightCornerX);
bool MouseYInRange = (MousePositionY >= WindowTopLeftCornerY) && (MousePositionY < WindowBottomRightCornerY);
bool MouseInRange = MouseXInRange && MouseYInRange;


// Update FOV
Viewport->Camera->SetFOV(SystemUtils_->RendererSettings_->FOV_);

// Check If Input Enabled
bool EnableCameraMovement = !Cursors3D_->IsUsing();
Expand Down Expand Up @@ -445,12 +462,12 @@ void ERS_CLASS_VisualRenderer::UpdateViewport(int Index, ERS_CLASS_SceneManager*
}


// Update Camera Location If System Running
if (!IsEditorMode_ && Index == 0 && Scene->ActiveSceneCameraIndex != -1) {
Viewport->Camera->SetPosition(Scene->SceneCameras[Scene->ActiveSceneCameraIndex]->Pos_);
Viewport->Camera->SetRotation(Scene->SceneCameras[Scene->ActiveSceneCameraIndex]->Rot_);
// // Update Camera Location If System Running
// if (!IsEditorMode_ && Index == 0 && Scene->ActiveSceneCameraIndex != -1) {
// Viewport->Camera->SetPosition(Scene->SceneCameras[Scene->ActiveSceneCameraIndex]->Pos_);
// Viewport->Camera->SetRotation(Scene->SceneCameras[Scene->ActiveSceneCameraIndex]->Rot_);

}
// }


// Render
Expand Down
82 changes: 0 additions & 82 deletions Source/Core/Structures/ERS_STRUCT_Camera/ERS_STRUCT_Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,65 +13,6 @@ ERS_STRUCT_Camera::~ERS_STRUCT_Camera() {
}


// // Callbacks
// void ERS_STRUCT_Camera::ProcessKeyboard(CameraMovement Direction, float DeltaTime) {

// // Calculate Velocity
// float Velocity = MovementSpeed_ * DeltaTime;

// // Update Position(s)
// if (Direction == FORWARD)
// Position_ += Front_ * Velocity;
// if (Direction == BACKWARD)
// Position_ -= Front_ * Velocity;
// if (Direction == LEFT)
// Position_ -= Right_ * Velocity;
// if (Direction == RIGHT)
// Position_ += Right_ * Velocity;
// if (Direction == UP)
// Position_ += Up_ * Velocity;
// if (Direction == DOWN)
// Position_ -= Up_ * Velocity;

// }
// void ERS_STRUCT_Camera::ProcessMouseMovement(float XOffset, float YOffset, GLboolean ConstrainPitch) {

// // Change Offset By Sensitivity
// XOffset *= MouseSensitivity_;
// YOffset *= MouseSensitivity_;

// // Update Pitch/Yaw
// Orientation_.y += XOffset;
// Orientation_.p += YOffset;



// // Bound Pitch
// if (ConstrainPitch) {

// if (Orientation_.p > 89.0f) {
// Orientation_.p = 89.0f;
// }
// if (Orientation_.p < -89.0f) {
// Orientation_.p = -89.0f;
// }
// }

// }
// void ERS_STRUCT_Camera::ProcessMouseScroll(float YOffset) {

// // Update Movement Speed
// MovementSpeed_ += (MovementSpeed_*(float)YOffset/10.0f);

// // Adjust Movement Speed
// if (MovementSpeed_ < MinMovementSpeed_)
// MovementSpeed_ = MinMovementSpeed_;
// if (MovementSpeed_ > MaxMovementSpeed_)
// MovementSpeed_ = MaxMovementSpeed_;

// }


// Update Matricies
void ERS_STRUCT_Camera::Update() {

Expand Down Expand Up @@ -109,23 +50,6 @@ void ERS_STRUCT_Camera::GetClipBoundires(float &NearClip, float &FarClip) {
NearClip = NearClip_;
FarClip = FarClip_;
}
// void ERS_STRUCT_Camera::SetMovementSpeedBoundries(float MinSpeed, float MaxSpeed) {
// MinMovementSpeed_ = MinSpeed;
// MaxMovementSpeed_ = MaxSpeed;
// }
// void ERS_STRUCT_Camera::GetMovementSpeedBoundries(float &MinSpeed, float &MaxSpeed) {
// MinSpeed = MinMovementSpeed_;
// MaxSpeed = MaxMovementSpeed_;
// }
// void ERS_STRUCT_Camera::SetMovementSpeed(float Speed, bool EnforceSpeedBoundries) {
// if (EnforceSpeedBoundries) {
// Speed = std::max(MinMovementSpeed_, Speed);
// Speed = std::min(MaxMovementSpeed_, Speed);
// MovementSpeed_ = Speed;
// } else {
// MovementSpeed_ = Speed;
// }
// }
void ERS_STRUCT_Camera::SetFOV(float FOV) {
FOV_ = FOV;
}
Expand All @@ -138,12 +62,6 @@ float ERS_STRUCT_Camera::GetFOV() {
void ERS_STRUCT_Camera::SetAspectRatio(float AspectRatio) {
AspectRatio_ = AspectRatio;
}
// void ERS_STRUCT_Camera::GetMouseSensitivity(float &Sensitivity) {
// Sensitivity = MouseSensitivity_;
// }
// void ERS_STRUCT_Camera::SetMouseSensitivity(float Sensitivity) {
// MouseSensitivity_ = Sensitivity;
// }
void ERS_STRUCT_Camera::SetRotation(glm::vec3 Rotation) {
Orientation_ = Rotation;
}
Expand Down
66 changes: 1 addition & 65 deletions Source/Core/Structures/ERS_STRUCT_Camera/ERS_STRUCT_Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,6 @@ struct ERS_STRUCT_Camera {
~ERS_STRUCT_Camera();



// /**
// * @brief Processes keyboard input for the camera.
// *
// * @param Direction Direction currently being pressed.
// * @param DeltaTime Frame time used to ensure speed isn't tied to framerate
// */
// void ProcessKeyboard(CameraMovement Direction, float DeltaTime);

// /**
// * @brief Processed mouse movement across the camera's viewport.
// *
// * @param XOffset Pixels moved in the x direction
// * @param Yoffset Pixels moved in the y direction
// * @param ConstrainPitch Stops the camera from turning above/bleow vertical
// */
// void ProcessMouseMovement(float XOffset, float Yoffset, GLboolean ConstrainPitch = true);

// /**
// * @brief Handles the mouse scrolling inputs
// *
// * @param YOffset mouse scroll amount
// */
// void ProcessMouseScroll(float YOffset);



/**
* @brief Updates the camera's matricies, should be called once per frame.
Expand Down Expand Up @@ -115,44 +89,6 @@ struct ERS_STRUCT_Camera {
*/
void GetClipBoundires(float &NearClip, float &FarClip);

// /**
// * @brief Helper function, sets the camera's maximum and minimum freeflying movement speeds.
// *
// * @param MinSpeed Slowest speed that the user can set the camera's keys to move in units per second.
// * @param MaxSpeed Fastest speed that the user can set the camera's keys to move in units per second.
// */
// void SetMovementSpeedBoundries(float MinSpeed, float MaxSpeed);

// /**
// * @brief Helper Function, gets the camera's maximum and minimum freeflying movement speeds.
// *
// * @param MinSpeed Slowest speed that the user can set the camera's keys to move in units per second.
// * @param MaxSpeed Fastest speed that the user can set the camera's keys to move in units per second.
// */
// void GetMovementSpeedBoundries(float &MinSpeed, float &MaxSpeed);

// /**
// * @brief Helper function, Sets the speed of the camera.
// *
// * @param Speed Desired speed in units per second.
// * @param EnforceSpeedBoundries Enable/disable hard boundry enforcement.
// */
// void SetMovementSpeed(float Speed, bool EnforceSpeedBoundries = true);

// /**
// * @brief Gets the mouse sensitivity multiplier.
// *
// * @param Sensitivity Mouse sensitivity multiplier.
// */
// void GetMouseSensitivity(float &Sensitivity);

// /**
// * @brief Sets the mouse sensitivity multiplier.
// *
// * @param Sensitivity Mouse sensitivity multiplier.
// */
// void SetMouseSensitivity(float Sensitivity);

/**
* @brief Gets the current field of view angle.
*
Expand Down Expand Up @@ -232,7 +168,7 @@ struct ERS_STRUCT_Camera {
// Internal Camera State Information
float MovementSpeed_ = 0.2f; /**<Current Movement Speed*/
float MouseSensitivity_ = 0.05f; /**<Mouse sensitivity multiplier*/
float FOV_ = 50.0f; /**<Field of view in degrees*/
float FOV_ = 70.0f; /**<Field of view in degrees*/
float AspectRatio_ = 1.25f; /**<Internal variable used to setup the projection matrix*/

glm::vec3 Orientation_; /**<Rotation of the camera in degrees. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,4 @@ struct ERS_STRUCT_RendererSettings {
unsigned long long CurrentVRAMUsage_ = 0;
unsigned long long CurrentRAMUsage_ = 0;


float FOV_ = 70.0f;

};

0 comments on commit 9fc4654

Please sign in to comment.