Skip to content

Commit

Permalink
Revert "Update RTTs for all entities in their materials after setting…
Browse files Browse the repository at this point in the history
… rtt name in set_camera()"

This reverts commit 4ce0693.
  • Loading branch information
Andrey2470T committed Mar 16, 2024
1 parent 4ce0693 commit ba2d125
Show file tree
Hide file tree
Showing 18 changed files with 0 additions and 190 deletions.
23 changes: 0 additions & 23 deletions src/client/activeobjectmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <log.h>
#include "profiler.h"
#include "activeobjectmgr.h"
#include "content_cao.h"

namespace client
{
Expand Down Expand Up @@ -106,28 +105,6 @@ void ActiveObjectMgr::getActiveObjects(const v3f &origin, f32 max_d,
}
}

void ActiveObjectMgr::updateRTTexturesOnDemand(const std::string &name)
{
if (m_active_objects.empty())
return;

u16 id = 1;

for (; id <= m_active_objects.size(); ++id) {
auto cao = getActiveObject(id);

if (!cao)
continue;

GenericCAO *generic_cao = dynamic_cast<GenericCAO*>(cao);

if (!generic_cao)
continue;

generic_cao->updateRTTextures(name);
}
}

std::vector<DistanceSortedActiveObject> ActiveObjectMgr::getActiveSelectableObjects(const core::line3d<f32> &shootline)
{
std::vector<DistanceSortedActiveObject> dest;
Expand Down
2 changes: 0 additions & 2 deletions src/client/activeobjectmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class ActiveObjectMgr final : public ::ActiveObjectMgr<ClientActiveObject>
void getActiveObjects(const v3f &origin, f32 max_d,
std::vector<DistanceSortedActiveObject> &dest);

void updateRTTexturesOnDemand(const std::string &name);

/// Gets all CAOs whose selection boxes may intersect the @p shootline.
/// @note CAOs without a selection box are not returned.
/// @note Distances are along the @p shootline.
Expand Down
11 changes: 0 additions & 11 deletions src/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2133,14 +2133,3 @@ const std::string &Client::getFormspecPrepend() const
{
return m_env.getLocalPlayer()->formspec_prepend;
}

void Client::demandUpdateRTTs(const std::string &name)
{
m_nodedef->reloadRTTexturesOnDemand(this, name);

ClientEnvironment &env = getEnv();

env.getClientMap().updateVisibleMapblocksMeshes();

env.updateRTTexturesOnDemand(name);
}
2 changes: 0 additions & 2 deletions src/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
return m_mesh_grid;
}

void demandUpdateRTTs(const std::string &name);

bool inhibit_inventory_revert = false;

private:
Expand Down
2 changes: 0 additions & 2 deletions src/client/clientenvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ class ClientEnvironment : public Environment
return m_ao_manager.getActiveObjects(origin, max_d, dest);
}

void updateRTTexturesOnDemand(const std::string &name) { m_ao_manager.updateRTTexturesOnDemand(name); }

bool hasClientEnvEvents() const { return !m_client_event_queue.empty(); }

// Get event from queue. If queue is empty, it triggers an assertion failure.
Expand Down
13 changes: 0 additions & 13 deletions src/client/clientmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,6 @@ void ClientMap::updateDrawList()
g_profiler->avg("MapBlocks occlusion culled [#]", blocks_occlusion_culled);
g_profiler->avg("MapBlocks frustum culled [#]", blocks_frustum_culled);
g_profiler->avg("MapBlocks drawn [#]", m_drawlist.size());

// Update meshes for all visible mapblocks
if (m_update_visible_mapblocks_meshes) {
m_update_visible_mapblocks_meshes = false;

doUpdateVisibleMapblocksMeshes();
}
}

void ClientMap::touchMapBlocks()
Expand Down Expand Up @@ -1409,9 +1402,3 @@ bool ClientMap::isMeshOccluded(MapBlock *mesh_block, u16 mesh_size, v3s16 cam_po

return true;
}

void ClientMap::doUpdateVisibleMapblocksMeshes()
{
for (auto &p : m_drawlist)
m_client->addUpdateMeshTask(p.first, false, true);
}
7 changes: 0 additions & 7 deletions src/client/clientmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ class ClientMap : public Map, public scene::ISceneNode

void onSettingChanged(const std::string &name);

// Whether reload rtts for all tile layers of mesh buffers having MATERIAL_FLAG_RTT flag enabled in the mapblocks within the view range?
void updateVisibleMapblocksMeshes() { m_update_visible_mapblocks_meshes = true; }

void doUpdateVisibleMapblocksMeshes();

protected:
void reportMetrics(u64 save_time_us, u32 saved_blocks, u32 all_blocks) override;
private:
Expand Down Expand Up @@ -204,6 +199,4 @@ class ClientMap : public Map, public scene::ISceneNode

bool m_loops_occlusion_culler;
bool m_enable_raytraced_culling;

bool m_update_visible_mapblocks_meshes = false;
};
53 changes: 0 additions & 53 deletions src/client/content_cao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1510,59 +1510,6 @@ void GenericCAO::updateTextures(std::string mod)
updateMeshCulling();
}

void GenericCAO::updateRTTextures(const std::string &name)
{
ITextureSource *tsrc = m_client->tsrc();
video::ITexture *texture = tsrc->getTextureForMesh(name);

if (m_prop.textures.empty())
return;

if (m_spritenode) {
if (m_prop.visual == "sprite") {
if (m_prop.textures[0] == name) {
auto &material = m_spritenode->getMaterial(0);
material.setTexture(0, texture);
}
}
}
else if (m_animated_meshnode) {
if (m_prop.visual == "mesh") {
for (u32 i = 0; i < m_prop.textures.size(); ++i)
if (m_prop.textures[i] == name) {
auto &material = m_animated_meshnode->getMaterial(i);
material.setTexture(0,texture);
}
}
}
else if (m_meshnode) {
if (m_prop.visual == "cube") {
for (u32 i = 0; i < 6; ++i)
if (m_prop.textures[i] == name) {
auto &material = m_meshnode->getMaterial(i);
material.setTexture(0, texture);
material.getTextureMatrix(0).makeIdentity();
}
}
else if (m_prop.visual == "upright_sprite") {
if (m_prop.textures[0] == name) {
auto &material = m_meshnode->getMaterial(0);
material.setTexture(0, texture);
}

std::string next_texname = m_prop.textures[0];

if (m_prop.textures.size() >= 2)
next_texname = m_prop.textures[1];

if (next_texname == name) {
auto &material = m_meshnode->getMaterial(1);
material.setTexture(0, texture);
}
}
}
}

void GenericCAO::updateAnimation()
{
if (!m_animated_meshnode)
Expand Down
2 changes: 0 additions & 2 deletions src/client/content_cao.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ class GenericCAO : public ClientActiveObject
// Reason: updateTextures(m_previous_texture_modifier);
void updateTextures(std::string mod);

void updateRTTextures(const std::string &name);

void updateAnimation();

void updateAnimationSpeed();
Expand Down
19 changes: 0 additions & 19 deletions src/client/mapblock_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,14 +736,6 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset):
// Replace tile texture with the first animation frame
p.layer.texture = (*p.layer.frames)[0].texture;
}
// RTT layers
if (p.layer.material_flags & MATERIAL_FLAG_RTT) {
m_update_rtts = true;

m_rtt_layers.insert(std::make_pair(
std::pair<u8, u32>(layer, i), p.layer.texture)
);
}

if (!m_enable_shaders) {
// Extract colors for day-night animation
Expand Down Expand Up @@ -902,17 +894,6 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack,
}
}

// RTT layers
if (m_update_rtts) {
m_update_rtts = false;

for (auto &it : m_rtt_layers) {
scene::IMeshBuffer *buf = m_mesh[it.first.first]->getMeshBuffer(it.first.second);

buf->getMaterial().setTexture(0, it.second);
}
}

// Day-night transition
if (!m_enable_shaders && (daynight_ratio != m_last_daynight_ratio)) {
// Force reload mesh to VBO
Expand Down
4 changes: 0 additions & 4 deletions src/client/mapblock_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ class MapBlockMesh
// Keys are pairs of (mesh index, buffer index in the mesh)
std::map<std::pair<u8, u32>, AnimationInfo> m_animation_info;

std::map<std::pair<u8, u32>, video::ITexture*> m_rtt_layers;

// Animation info: day/night transitions
// Last daynight_ratio value passed to animate()
u32 m_last_daynight_ratio;
Expand All @@ -283,8 +281,6 @@ class MapBlockMesh
MapBlockBspTree m_bsp_tree;
// Ordered list of references to parts of transparent buffers to draw
std::vector<PartialMeshBuffer> m_transparent_buffers;

bool m_update_rtts = false;
};

/*!
Expand Down
5 changes: 0 additions & 5 deletions src/client/render/cameras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ void DrawSecondaryCameras::run(PipelineContext &context)
if (!cam->isVisible())
continue;

if (cam->render_texture_set) {
cam->render_texture_set = false;
cam->render_texture_updated = true;
}

if (cam->getRenderTextureName().size() != 0)
overrides->mapName(cam->getRenderTextureName(), textures->getTexture(idx));
else {
Expand Down
2 changes: 0 additions & 2 deletions src/client/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ enum MaterialType{
//#define MATERIAL_FLAG_HIGHLIGHTED 0x10
#define MATERIAL_FLAG_TILEABLE_HORIZONTAL 0x20
#define MATERIAL_FLAG_TILEABLE_VERTICAL 0x40
// Is RTT texture?
#define MATERIAL_FLAG_RTT 0x80

/*
This fully defines the looks of a tile.
Expand Down
5 changes: 0 additions & 5 deletions src/client/universalcamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,6 @@ void UniversalCamera::step()
const v3f current_offset = m_camera_offset;
setCameraOffset(m_env->getCameraOffset());

if (render_texture_updated) {
render_texture_updated = false;
m_env->getGameDef()->demandUpdateRTTs(m_render_texture_name);
}

// Camera not attached to a parent
if (m_parent_id == -1)
return;
Expand Down
6 changes: 0 additions & 6 deletions src/client/universalcamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ class UniversalCamera : public scene::ICameraSceneNode
{
m_render_texture_name = name;
m_render_texture_aspect_ratio = aspect_ratio;

render_texture_set = true;
//infostream << "setRenderTexture(): texture is set with name \'" << name << "\' for camera with id = " << getID() << std::endl;
}

void setPosition(const v3f &pos, bool interpolation = false, f32 speed = 0.f);
Expand All @@ -144,9 +141,6 @@ class UniversalCamera : public scene::ICameraSceneNode
void attachTo(ClientActiveObject *object, bool follow = true);
inline void detach() { m_parent_id = -1; }

bool render_texture_set {false};
bool render_texture_updated {false};

private:
void interpolate();
void manipulate(u32 time);
Expand Down
23 changes: 0 additions & 23 deletions src/nodedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ void TileDef::serialize(std::ostream &os, u16 protocol_version) const
os << serializeString16("blank.png^" + name);
}
animation.serialize(os, version);

writeU8(os, (u8)rtt);

bool has_scale = scale > 0;
u16 flags = 0;
if (backface_culling)
Expand Down Expand Up @@ -261,7 +258,6 @@ void TileDef::deSerialize(std::istream &is, NodeDrawType drawtype, u16 protocol_

name = deSerializeString16(is);
animation.deSerialize(is, protocol_version);
rtt = (bool)readU8(is);
u16 flags = readU16(is);
backface_culling = flags & TILE_FLAG_BACKFACE_CULLING;
tileable_horizontal = flags & TILE_FLAG_TILEABLE_HORIZONTAL;
Expand Down Expand Up @@ -726,8 +722,6 @@ static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer,
layer->material_flags |= MATERIAL_FLAG_TILEABLE_HORIZONTAL;
if (tiledef.tileable_vertical)
layer->material_flags |= MATERIAL_FLAG_TILEABLE_VERTICAL;
if (tiledef.rtt)
layer->material_flags |= MATERIAL_FLAG_RTT;

// Color
layer->has_color = tiledef.has_color;
Expand Down Expand Up @@ -808,7 +802,6 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
TileDef tdef_overlay[6];
for (u32 j = 0; j < 6; j++)
tdef_overlay[j] = tiledef_overlay[j];

// also the special tiles
TileDef tdef_spec[6];
for (u32 j = 0; j < CF_SPECIAL_COUNT; j++) {
Expand Down Expand Up @@ -1682,22 +1675,6 @@ void NodeDefManager::resolveCrossrefs()
}
}

void NodeDefManager::reloadRTTexturesOnDemand(IGameDef *gamedef, const std::string &name) {
Client *client = (Client*)gamedef;
ITextureSource *tsrc = client->tsrc();

for (auto &f : m_content_features) {
for (int i = 0; i < 6; i++) {
TileDef &tdef = f.tiledef[i];

if (tdef.rtt && tdef.name == name) {
TileLayer &layer = f.tiles[i].layers[0];
layer.texture = tsrc->getTextureForMesh(tdef.name, &layer.texture_id);
}
}
}
}

bool NodeDefManager::nodeboxConnects(MapNode from, MapNode to,
u8 connect_face) const
{
Expand Down
10 changes: 0 additions & 10 deletions src/nodedef.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,6 @@ struct TileDef

struct TileAnimationParams animation;

// Whether the tile contains the RTT texture
bool rtt = false;

TileDef()
{
animation.type = TAT_NONE;
Expand Down Expand Up @@ -757,13 +754,6 @@ class NodeDefManager {
*/
void resolveCrossrefs();

/*!
* Updates all RTTs in tile layers having name `name`.
* Actually it just attempts to take current generated textures from
* DynamicTextureSource mappings, otherwise loads/takes from cache as usually.
*/
void reloadRTTexturesOnDemand(IGameDef *gamedef, const std::string &name);

private:
/*!
* Resets the manager to its initial state.
Expand Down
1 change: 0 additions & 1 deletion src/script/common/c_content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,6 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype, bool special)
lua_getfield(L, index, "animation");
tiledef.animation = read_animation_definition(L, -1);
lua_pop(L, 1);
tiledef.rtt = getboolfield_default(L, index, "rtt", tiledef.rtt);
}

return tiledef;
Expand Down

0 comments on commit ba2d125

Please sign in to comment.