Patch - Doc Update - V12.8.1

This commit is contained in:
2025-07-28 17:37:15 +02:00
parent 9431552316
commit ccd0d045f9
201 changed files with 9244 additions and 3316 deletions

View File

@@ -13,16 +13,27 @@
class Logger
{
public:
/**
* Get the singleton instance of the Logger class.
* @return A reference to the Logger instance.
*/
static Logger& Get()
{
static Logger instance;
return instance;
}
/**
* Delete the copy constructor and assignment operator to prevent copying.
*/
Logger(Logger const&) = delete;
void operator=(Logger const&) = delete;
/**
* Enum class representing different log levels.
* Each log level has a corresponding color for display purposes.
* The last entry, Count, is used to determine the number of log levels.
*/
enum class LogLevel
{
Info,
@@ -47,12 +58,20 @@ public:
// Return the size of the enum class LogLevel as a constant integer
static constexpr int LogLevelCount = static_cast<int>(LogLevel::Count);
/**
* Struct representing a log entry.
* Contains the log message and its associated log level.
*/
struct LogEntry
{
std::string message;
LogLevel level;
};
/**
* Struct containing information about a log level.
* This includes the name of the log level, its value, and its color for display.
*/
struct LogLevelInfo
{
const char* name;
@@ -60,6 +79,12 @@ public:
ImVec4 color;
};
/**
* Get the LogLevelInfo for a given log level.
* This function returns a LogLevelInfo struct containing the name, value, and color of the log level.
* @param level The log level for which to get the information.
* @return A LogLevelInfo struct containing the information for the specified log level.
*/
static const LogLevelInfo GetLogLevelInfo(LogLevel level)
{
switch (level)
@@ -84,6 +109,10 @@ public:
}
}
/**
* Constructor for the Logger class.
* Initializes the logger, sets up the log file path, and manages log files.
*/
Logger()
{
char* appdata = nullptr;
@@ -119,7 +148,13 @@ public:
}
// ecrit un message dans le fichier de log et le stocke dans le buffer
/**
* Write a log message to the log file and console.
* @param message
* @param fileName
* @param lineNumber
* @param level
*/
void Log(const std::string& message, const std::string& fileName, int lineNumber, LogLevel level = LogLevel::Info)
{
@@ -152,7 +187,16 @@ public:
}
}
// ecrit un message dans la console
/**
* Write a log message to the log buffer.
* This is the fonction wich is used to send log messages to the gui.
* It's using a buffer to store the log messages with a maximum size.
* The buffer default size is 100 messages.
* This limit can be changed by changing the logBufferSize variable.
* But it is not recommended to change it because it can cause performance issues.
* @param message The log message to write.
* @param level The log level for the message.
*/
void Log(const std::string& message, LogLevel level)
{
@@ -169,8 +213,20 @@ public:
logBuffer.push_back({ message, level });
}
/**
* Get the loggBuffer deque.
* @return A constant reference to the logBuffer deque containing log entries.
*/
const std::deque<LogEntry>& GetLogBuffer() const { return logBuffer; }
/**
* This function manages log files in the specified directory.
* It checks for log files with the ".log" extension,
* Then it keeps only the three most recent log files,
* deleting the oldest ones if there are more than three.
* It also creates a new log file for the current execution with a timestamp in its name.
* @param directoryPath
*/
void ManageLogFiles(const std::string& directoryPath)
{
std::vector<std::filesystem::path> logFiles;

View File

@@ -8,11 +8,24 @@ class Skybox
{
public:
/**
* @brief Constructor for the Skybox class.
* Initializes the skybox with a reference to the d_3d_class instance.
*/
Skybox();
~Skybox();
/**
* Initializes the Skybox with the given d_3d_class reference.
* @param d3dClassRef
*/
void Initialize(d_3d_class* d3dClassRef); // Get all the required references
/**
* Create the skybox object.
* @param app
* @return Pointer to the created skybox object.
*/
object* ConstructSkybox(application_class* app);

View File

@@ -18,21 +18,68 @@ using namespace DirectX;
class camera_class
{
public:
/**
* @brief Default constructor for camera_class.
* Initializes the camera position and rotation to zero.
*/
camera_class();
camera_class(const camera_class&);
~camera_class();
/**
* @brief Sets the position of the camera in 3D space.
*
* @param position_x The x-coordinate of the camera's position.
* @param position_y The y-coordinate of the camera's position.
* @param position_z The z-coordinate of the camera's position.
*/
void set_position(float, float, float);
/**
* @brief Sets the rotation of the camera in 3D space.
*
* @param rotation_x The rotation around the x-axis in degrees.
* @param rotation_y The rotation around the y-axis in degrees.
* @param rotation_z The rotation around the z-axis in degrees.
*/
void set_rotation(float, float, float);
/**
* @brief Gets the current position of the camera.
*
* @return A 3D vector representing the camera's position.
*/
XMFLOAT3 get_position();
/**
* @brief Gets the current rotation of the camera.
*
* @return A 3D vector representing the camera's rotation in degrees.
*/
XMFLOAT3 get_rotation();
/**
* @brief Updates the camera's view matrix based on its position and rotation.
* This method recalculates the view matrix to reflect the current camera state.
*/
void render();
/**
* @brief Retrieves the current view matrix of the camera.
*
* @return The view matrix representing the camera's orientation and position.
*/
XMMATRIX get_view_matrix(XMMATRIX& view_matrix) const;
/**
* @brief Renders the reflection of the scene from the camera's perspective.
*
* @param reflection_plane_y The y-coordinate of the reflection plane.
*/
void render_reflection(float);
/**
* @brief Retrieves the reflection view matrix of the camera.
*
* @param reflection_view_matrix The matrix to store the reflection view matrix.
*/
void get_reflection_view_matrix(XMMATRIX&) const;
private:

View File

@@ -30,41 +30,139 @@ using namespace DirectX;
class d_3d_class
{
public:
/**
* @brief Default constructor for d_3d_class.
*/
d_3d_class();
d_3d_class(const d_3d_class&);
~d_3d_class();
/**
* @brief Initializes the Direct3D device and related resources.
*
* @param screenWidth Width of the screen.
* @param screenHeight Height of the screen.
* @param vsync Whether to enable vertical sync.
* @param hwnd Handle to the window.
* @param fullscreen Whether to run in fullscreen mode.
* @param screenDepth Depth of the screen.
* @param screenNear Near clipping plane distance.
* @return True if initialization was successful, false otherwise.
*/
virtual bool initialize(int, int, bool, HWND, bool, float, float);
/**
* @brief Releases Direct3D resources.
*/
void shutdown();
/**
* @brief Begins the rendering process for a new frame.
*
* @param red Red component of the clear color.
* @param green Green component of the clear color.
* @param blue Blue component of the clear color.
* @param alpha Alpha component of the clear color.
*/
virtual void begin_scene(float, float, float, float);
/**
* @brief Ends the rendering process for the current frame.
*/
virtual void end_scene();
/**
* @brief Gets the Direct3D device.
*
* @return Pointer to the ID3D11Device interface.
*/
ID3D11Device* get_device();
/**
* @brief Gets the Direct3D device context.
*
* @return Pointer to the ID3D11DeviceContext interface.
*/
ID3D11DeviceContext* get_device_context();
//XMMATRIX get_projection_matrix(XMMATRIX& projectionMatrix);
IDXGISwapChain* swap_chain;
/**
* Get the swap chain associated with the Direct3D device.
* @return Pointer to the IDXGISwapChain interface.
*/
IDXGISwapChain* get_swap_chain();
void resize_swap_chain(int, int);
/**
* Resizes the swap chain to the specified width and height.
* @param width New width of the swap chain.
* @param height New height of the swap chain.
*/
void resize_swap_chain(int width, int height);
/**
* @brief Sets the vertical sync state.
*
* @param vsync True to enable vertical sync, false to disable.
*/
void set_vsync(bool vsync);
/**
* Get the projection matrix.
*
* @return XMMATRIX representing the projection matrix.
*/
XMMATRIX get_projection_matrix() const { return projection_matrix_; };
/**
* Get the world matrix.
*
* @return XMMATRIX representing the world matrix.
*/
XMMATRIX get_world_matrix() const { return world_matrix_;};
/**
* Get the orthographic matrix.
*
* @return XMMATRIX representing the orthographic matrix.
*/
XMMATRIX get_ortho_matrix() const { return ortho_matrix_; };
void get_video_card_info(char*, int&);
/**
* Get the Video Card information.
* @param description Pointer to a character array to store the video card description.
* @param memory Reference to an integer to store the video card memory size.
*/
void get_video_card_info(char* description, int& memory);
/**
* Set the render target to the back buffer.
*/
void set_back_buffer_render_target();
/**
* Resets the viewport to the default settings.
*/
void reset_viewport();
/**
* Release all Direct3D resources.
*/
void release_resources();
/**
* Reset Direct3D resources based on the new width and height.
* @param newWidth
* @param newHeight
*/
void reset_resources(int newWidth, int newHeight);
/**
* Turn on the Z-buffer to enable depth.
*/
void turn_z_buffer_on();
/**
* Turn off the Z-buffer to disable depth.
*/
void turn_z_buffer_off();
/**
* Turn on alpha blending for transparency effects.
*/
void enable_alpha_blending();
/**
* Turn off alpha blending to disable transparency effects.
*/
void disable_alpha_blending();
private:

View File

@@ -25,6 +25,7 @@ public:
display_plane_class(const display_plane_class&);
~display_plane_class();
bool Initialize(ID3D11Device*, float, float);
void Shutdown();
void Render(ID3D11DeviceContext*);

View File

@@ -3,10 +3,19 @@
class fps_limiter {
public:
/**
* Builder for fps_limiter class
* This class is used to limit the execution rate of a loop based on a target frames per second (FPS).
* @param target_fps Target frames per second for the limiter. The default is 60.0f FPS.
*/
explicit fps_limiter(const float target_fps = 60.0f)
: min_delta_(1.0f / target_fps), last_time_(std::chrono::high_resolution_clock::now()) {}
// Retourne true si la fonction peut etre executee
/**
* Function to check if enough time has passed since the last execution.
* @return True if the time since the last call is greater than or equal to the minimum delta time, otherwise false.
*/
bool should_run() {
const auto now = std::chrono::high_resolution_clock::now();
if (const float elapsed = std::chrono::duration<float>(now - last_time_).count(); elapsed >= min_delta_) {

View File

@@ -4,7 +4,20 @@ using namespace DirectX;
class frustum
{
public:
/**
* Create a frustum object.
* @param screenDepth
* @param projectionMatrix
* @param viewMatrix
*/
void ConstructFrustum(float screenDepth, XMMATRIX projectionMatrix, XMMATRIX viewMatrix);
/**
* Check if a point is inside the frustum.
* @param x X coordinate of the point.
* @param y Y coordinate of the point.
* @param z Z coordinate of the point.
* @return True if the point is inside the frustum, otherwise false.
*/
bool CheckCube(float xCenter, float yCenter, float zCenter, float radius, float tolerance);
private:

View File

@@ -18,7 +18,7 @@ public:
FrustumClass();
FrustumClass(const FrustumClass&);
~FrustumClass();
void ConstructFrustum(XMMATRIX, XMMATRIX, float);
bool CheckPoint(float, float, float);

View File

@@ -19,6 +19,11 @@
class application_class;
class stats;
/**
* Struct to hold widget entries for ImGui.
* This struct contains a pointer to a boolean that determines if the widget should be shown,
* and a function that will be called when the widget is rendered.
*/
struct widget_entry
{
bool* show;
@@ -28,35 +33,112 @@ struct widget_entry
class imguiManager
{
public:
/**
* Constructor for imguiManager class.
* Initializes the ImGui manager with default values.
*/
imguiManager();
~imguiManager();
/**
* Initializes the ImGui manager.
* @param hwnd Handle to the window where ImGui will be rendered.
* @param device Pointer to the Direct3D 11 device.
* @param deviceContext Pointer to the Direct3D 11 device context.
* @return True if initialization was successful, otherwise false.
*/
bool Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext);
/**
* Shuts down the ImGui manager.
*/
void Shutdown();
/**
* Renders the ImGui interface.
*/
void Render();
/**
* Starts a new ImGui frame.
*/
void NewFrame();
/**
* Sets up the ImGui dockspace.
* This function creates a dockspace for the ImGui interface.
*/
void SetupDockspace();
// Widgets
/**
* Creates a slider widget to control the speed of the demo spinning cube.
* @param speed
*/
void WidgetSpeedSlider(float* speed);
/**
* Creates a button widget.
*/
void WidgetButton();
/**
* Shows the FPS in a widget.
*/
void WidgetFPS();
/**
* Create a widget to add a button wich will add an object to the scene.
*/
void WidgetAddObject();
/**
* create a window to display the object list and their properties.
*/
void WidgetObjectWindow();
/**
* Create a window to display the terrain generation options.
*/
void WidgetTerrainWindow();
/**
* Create a window to display the light settings.
*/
void WidgetLightWindow();
/**
* Create a window to display the Engine settings.
*/
void WidgetEngineSettingsWindow();
/**
* Create a window to display the scene.
* This window isn't used anymore.
*/
void WidgetRenderWindow(ImVec2 availableSize);
/**
* Create a window to display the log messages from the Logger.
*/
void WidgetLogWindow();
/**
* Create a window to display the stats of the engine.
* This includes FPS, draw calls, triangle count, etc.
* As well as the GPU, CPU information and RAM information.
*/
void WidgetRenderStats();
/**
* Function to render the ImGui widgets.
* This function use the struct widget_entry to render the widgets that are registered.
* @return True if the ImGui widgets were rendered successfully, otherwise false.
*/
bool ImGuiWidgetRenderer();
/**
* set the Old scene window size.
* @param size
*/
void SetWindowSize(ImVec2 size) { windowSize = size; }
/**
* Get the current window size.
* @return The current window size as an ImVec2.
*/
ImVec2 GetWindowSize() const { return windowSize; }
// Getters
/**
* Set the application class pointer for the ImGui manager.
* @param app
*/
void SetApp(std::shared_ptr<application_class> app) { app_ = app; }
// Shader toggles

View File

@@ -16,14 +16,50 @@ public:
scene_manager();
~scene_manager();
/**
* Initialize the scene manager with the application instance.
* @param app Pointer to the application class instance.
* @return True if initialization is successful, otherwise false.
*/
bool initialize(application_class* app);
/**
* Shutdown the scene manager and release resources.
* @return True if shutdown is successful, otherwise false.
*/
bool shutdown();
/**
* Function to save the current scene as a new file.
* The scene is saved in a .ker file format.
* This function will prompt the user to choose a file location and name.
* Then it will call the save_scene function to perform the actual saving.
* @return
*/
bool save_scene_as();
/**
* Function to save the current scene.
* This function will save the current scene to the path specified in scene_path_.
* If the scene_path_ is empty, it will call save_scene_as() to prompt the user for a file location.
* @return True if the scene was saved successfully, otherwise false.
*/
bool save_scene();
/**
* Function to load a scene from a file.
* This function will prompt the user to choose a file to load.
* @return True if the scene was loaded successfully, otherwise false.
*/
bool load_scene();
/**
* Get the current scene path.
* @return The path to the current scene as a string.
*/
std::wstring get_scene_path();
/**
* Convert a wide string to a standard string.
* @param w_str
* @return The converted string.
*/
std::string convert_w_string_to_string(const std::wstring& w_str);
private:

View File

@@ -297,8 +297,11 @@ bool scene_manager::save_scene() {
entity_ = app_->get_entity_manager()->GetAllEntities();
if (scene_path_.empty()) {
Logger::Get().Log("Scene path is empty. Cannot save scene.", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
// Si le chemin de la sc<73>ne est vide, fallback vers la fonction de sauvegarde as
if (!save_scene_as()) {
Logger::Get().Log("Scene save cancelled by user", __FILE__, __LINE__, Logger::LogLevel::Info);
return false;
}
}
std::ofstream outFile(scene_path_);