Skip to content

Commit

Permalink
refactor: Shorten render entity class name in world render stage.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Oct 3, 2024
1 parent 09dc947 commit 95c9d1a
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions libopenage/gamestate/game_entity.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2023 the openage authors. See copying.md for legal info.
// Copyright 2022-2024 the openage authors. See copying.md for legal info.

#include "game_entity.h"

Expand Down Expand Up @@ -30,7 +30,7 @@ entity_id_t GameEntity::get_id() const {
return this->id;
}

void GameEntity::set_render_entity(const std::shared_ptr<renderer::world::WorldRenderEntity> &entity) {
void GameEntity::set_render_entity(const std::shared_ptr<renderer::world::RenderEntity> &entity) {
// TODO: Transfer state from old render entity to new one?

this->render_entity = entity;
Expand Down
6 changes: 3 additions & 3 deletions libopenage/gamestate/game_entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace openage {

namespace renderer::world {
class WorldRenderEntity;
class RenderEntity;
}

namespace gamestate {
Expand Down Expand Up @@ -62,7 +62,7 @@ class GameEntity {
*
* @param entity New render entity.
*/
void set_render_entity(const std::shared_ptr<renderer::world::WorldRenderEntity> &entity);
void set_render_entity(const std::shared_ptr<renderer::world::RenderEntity> &entity);

/**
* Set the event manager of this entity.
Expand Down Expand Up @@ -142,7 +142,7 @@ class GameEntity {
/**
* Render entity for pushing updates to the renderer. Can be \p nullptr.
*/
std::shared_ptr<renderer::world::WorldRenderEntity> render_entity;
std::shared_ptr<renderer::world::RenderEntity> render_entity;

/**
* Event manager.
Expand Down
2 changes: 1 addition & 1 deletion libopenage/renderer/demo/stresstest_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void renderer_stresstest_0(const util::Path &path) {
terrain0->update(terrain_size, tiles);

// World entities
std::vector<std::shared_ptr<renderer::world::WorldRenderEntity>> render_entities{};
std::vector<std::shared_ptr<renderer::world::RenderEntity>> render_entities{};
auto add_world_entity = [&](const coord::phys3 initial_pos,
const time::time_t time) {
const auto animation_path = "./textures/test_tank_mirrored.sprite";
Expand Down
2 changes: 1 addition & 1 deletion libopenage/renderer/demo/stresstest_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void renderer_stresstest_1(const util::Path &path) {
// send the terrain data to the terrain renderer
terrain0->update(terrain_size, tiles);

std::vector<std::shared_ptr<renderer::world::WorldRenderEntity>> render_entities{};
std::vector<std::shared_ptr<renderer::world::RenderEntity>> render_entities{};
auto add_world_entity = [&](const coord::phys3 initial_pos,
const time::time_t time) {
const auto animation_path = "./textures/test_tank_mirrored.sprite";
Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/render_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ std::shared_ptr<terrain::RenderEntity> RenderFactory::add_terrain_render_entity(
return entity;
}

std::shared_ptr<world::WorldRenderEntity> RenderFactory::add_world_render_entity() {
auto entity = std::make_shared<world::WorldRenderEntity>();
std::shared_ptr<world::RenderEntity> RenderFactory::add_world_render_entity() {
auto entity = std::make_shared<world::RenderEntity>();
this->world_renderer->add_render_entity(entity);

return entity;
Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/render_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class RenderEntity;

namespace world {
class WorldRenderStage;
class WorldRenderEntity;
class RenderEntity;
} // namespace world

/**
Expand Down Expand Up @@ -55,7 +55,7 @@ class RenderFactory {
*
* @return Render entity for pushing terrain updates.
*/
std::shared_ptr<world::WorldRenderEntity> add_world_render_entity();
std::shared_ptr<world::RenderEntity> add_world_render_entity();

private:
/**
Expand Down
2 changes: 1 addition & 1 deletion libopenage/renderer/stages/world/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ WorldObject::WorldObject(const std::shared_ptr<renderer::resources::AssetManager
last_update{0.0} {
}

void WorldObject::set_render_entity(const std::shared_ptr<WorldRenderEntity> &entity) {
void WorldObject::set_render_entity(const std::shared_ptr<RenderEntity> &entity) {
this->render_entity = entity;
this->fetch_updates();
}
Expand Down
6 changes: 3 additions & 3 deletions libopenage/renderer/stages/world/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Animation2dInfo;
} // namespace resources

namespace world {
class WorldRenderEntity;
class RenderEntity;

/**
* Stores the state of a renderable object in the World render stage.
Expand All @@ -49,7 +49,7 @@ class WorldObject {
*
* @param entity New world render entity.
*/
void set_render_entity(const std::shared_ptr<WorldRenderEntity> &entity);
void set_render_entity(const std::shared_ptr<RenderEntity> &entity);

/**
* Fetch updates from the render entity.
Expand Down Expand Up @@ -177,7 +177,7 @@ class WorldObject {
* Entity that gets updates from the gamestate, e.g. the position and
* requested animation data.
*/
std::shared_ptr<WorldRenderEntity> render_entity;
std::shared_ptr<RenderEntity> render_entity;

/**
* Reference ID for passing interaction with the graphic (e.g. mouse clicks) back to
Expand Down
30 changes: 15 additions & 15 deletions libopenage/renderer/stages/world/render_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

namespace openage::renderer::world {

WorldRenderEntity::WorldRenderEntity() :
RenderEntity{},
RenderEntity::RenderEntity() :
renderer::RenderEntity{},
ref_id{0},
position{nullptr, 0, "", nullptr, SCENE_ORIGIN},
angle{nullptr, 0, "", nullptr, 0},
animation_path{nullptr, 0} {
}

void WorldRenderEntity::update(const uint32_t ref_id,
const curve::Continuous<coord::phys3> &position,
const curve::Segmented<coord::phys_angle_t> &angle,
const std::string animation_path,
const time::time_t time) {
void RenderEntity::update(const uint32_t ref_id,
const curve::Continuous<coord::phys3> &position,
const curve::Segmented<coord::phys_angle_t> &angle,
const std::string animation_path,
const time::time_t time) {
std::unique_lock lock{this->mutex};

this->ref_id = ref_id;
Expand All @@ -40,10 +40,10 @@ void WorldRenderEntity::update(const uint32_t ref_id,
this->last_update = time;
}

void WorldRenderEntity::update(const uint32_t ref_id,
const coord::phys3 position,
const std::string animation_path,
const time::time_t time) {
void RenderEntity::update(const uint32_t ref_id,
const coord::phys3 position,
const std::string animation_path,
const time::time_t time) {
std::unique_lock lock{this->mutex};

this->ref_id = ref_id;
Expand All @@ -53,25 +53,25 @@ void WorldRenderEntity::update(const uint32_t ref_id,
this->last_update = time;
}

uint32_t WorldRenderEntity::get_id() {
uint32_t RenderEntity::get_id() {
std::shared_lock lock{this->mutex};

return this->ref_id;
}

const curve::Continuous<coord::scene3> &WorldRenderEntity::get_position() {
const curve::Continuous<coord::scene3> &RenderEntity::get_position() {
std::shared_lock lock{this->mutex};

return this->position;
}

const curve::Segmented<coord::phys_angle_t> &WorldRenderEntity::get_angle() {
const curve::Segmented<coord::phys_angle_t> &RenderEntity::get_angle() {
std::shared_lock lock{this->mutex};

return this->angle;
}

const curve::Discrete<std::string> &WorldRenderEntity::get_animation_path() {
const curve::Discrete<std::string> &RenderEntity::get_animation_path() {
std::shared_lock lock{this->mutex};

return this->animation_path;
Expand Down
6 changes: 3 additions & 3 deletions libopenage/renderer/stages/world/render_entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace openage::renderer::world {
/**
* Render entity for pushing updates to the World renderer.
*/
class WorldRenderEntity final : public renderer::RenderEntity {
class RenderEntity final : public renderer::RenderEntity {
public:
WorldRenderEntity();
~WorldRenderEntity() = default;
RenderEntity();
~RenderEntity() = default;

/**
* Update the render entity with information from the gamestate.
Expand Down
2 changes: 1 addition & 1 deletion libopenage/renderer/stages/world/render_stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ std::shared_ptr<renderer::RenderPass> WorldRenderStage::get_render_pass() {
return this->render_pass;
}

void WorldRenderStage::add_render_entity(const std::shared_ptr<WorldRenderEntity> entity) {
void WorldRenderStage::add_render_entity(const std::shared_ptr<RenderEntity> entity) {
std::unique_lock lock{this->mutex};

auto world_object = std::make_shared<WorldObject>(this->asset_manager);
Expand Down
4 changes: 2 additions & 2 deletions libopenage/renderer/stages/world/render_stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AssetManager;
}

namespace world {
class WorldRenderEntity;
class RenderEntity;
class WorldObject;

/**
Expand Down Expand Up @@ -74,7 +74,7 @@ class WorldRenderStage {
*
* @param render_entity New render entity.
*/
void add_render_entity(const std::shared_ptr<WorldRenderEntity> entity);
void add_render_entity(const std::shared_ptr<RenderEntity> entity);

/**
* Update the render entities and render positions.
Expand Down

0 comments on commit 95c9d1a

Please sign in to comment.