Debug: Support frame tracing via Tracy
Use CMake FetchContent to pull tracy sources and build it if frame tracing is enabled. As frame tracing requires annotations in the code, create a wrapper that replaces them with our own defines that are empty when tracing is not enabled.
This commit is contained in:
parent
8199fd3449
commit
7241ed7321
4 changed files with 50 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <imgui.h>
|
||||
#include <imgui-SFML.h>
|
||||
#endif
|
||||
#include "FrameTracing.h"
|
||||
|
||||
World::World(int w, int h, sf::Color groundColor, sf::Color ceilingColor, std::vector<BlockType> worldMap) :
|
||||
player(0,0,0), w(w), h(h), map(std::move(worldMap)),
|
||||
|
@ -117,6 +118,7 @@ RaycastResult World::castRay(float originX, float originY, float orientation) co
|
|||
* built around left-handed axes (x→,y↓), so the rendered world is
|
||||
* mirrored. This also explains some weird signs for rotations.
|
||||
*/
|
||||
FTrace_Scope;
|
||||
/* Offsets to get back on the grid from the ray's origin. */
|
||||
float hOffsetX;
|
||||
float hOffsetY;
|
||||
|
@ -234,6 +236,7 @@ RaycastResult World::castRay(float originX, float originY, float orientation) co
|
|||
void World::fillColumn(sf::RenderWindow& window, unsigned int column,
|
||||
float scale, sf::Color fillColor)
|
||||
{
|
||||
FTrace_Scope;
|
||||
float columnHeight = static_cast<float>(window.getSize().y)*scale;
|
||||
sf::RectangleShape& pixelColumn = renderColumns[column];
|
||||
if (pixelColumn.getSize().y != columnHeight) {
|
||||
|
@ -249,6 +252,7 @@ void World::fillColumn(sf::RenderWindow& window, unsigned int column,
|
|||
|
||||
void World::render(sf::RenderWindow& window)
|
||||
{
|
||||
FTrace_Scope;
|
||||
float windowX = static_cast<float>(window.getSize().x);
|
||||
float windowY = static_cast<float>(window.getSize().y);
|
||||
/*
|
||||
|
@ -291,6 +295,7 @@ void World::render(sf::RenderWindow& window)
|
|||
}
|
||||
|
||||
void World::step(const float& stepTime) {
|
||||
FTrace_Scope;
|
||||
player.move(player.currentMoveSpeedX*stepTime,
|
||||
player.currentMoveSpeedY*stepTime);
|
||||
/* Undo last move if the player would end up in a wall. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue