Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Aug 27, 2024
1 parent 8d795f9 commit e41cc2b
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 19 deletions.
40 changes: 28 additions & 12 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,6 @@ struct GameRunData {
v3f update_draw_list_last_cam_pos;
unsigned int autoexit = 0;
bool profiler_state = false;
//
//freeminer:
bool headless_optimize = false;
bool no_output = false;
float dedicated_server_step = 0.1;
Expand Down Expand Up @@ -931,9 +929,12 @@ class Game {
GUITable *playerlist = nullptr;
video::SColor console_bg {};
async_step_runner updateDrawList_async;
async_step_runner update_shadows_async;
bool m_cinematic = false;
std::unique_ptr<FarMesh> farmesh;
async_step_runner farmesh_async;
std::unique_ptr<RaycastState> pointedRaycastState;
PointedThing pointed;
// minetest:


Expand Down Expand Up @@ -3728,7 +3729,7 @@ void Game::processPlayerInteraction(f32 dtime, bool show_hud)
}
#endif

PointedThing pointed = updatePointedThing(shootline,
updatePointedThing(shootline,
selected_def.liquids_pointable,
!runData.btn_down_for_dig,
camera_offset);
Expand Down Expand Up @@ -3854,7 +3855,21 @@ PointedThing Game::updatePointedThing(

RaycastState s(shootline, look_for_object, liquids_pointable);
PointedThing result;
env.continueRaycast(&s, &result);

if (!pointedRaycastState || pointedRaycastState->finished) {
pointedRaycastState = std::make_unique<RaycastState>(
shootline, look_for_object, liquids_pointable);
}
pointedRaycastState->end_ms = porting::getTimeMs() + 3;

env.continueRaycast(pointedRaycastState.get(), &result);

if (!pointedRaycastState->finished) {
result = pointed;
} else {
pointed = result;
}

if (result.type == POINTEDTHING_OBJECT) {
hud->pointing_at_object = true;

Expand Down Expand Up @@ -4639,20 +4654,21 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
runData.update_draw_list_last_cam_pos.getDistanceFrom(camera_position) >
MAP_BLOCKSIZE * BS * 1 ||
m_camera_offset_changed) {
updateDrawList_async.step(
[&](const float dtime) {
client->m_new_meshes = 0;
runData.update_draw_list_timer = 0;
updateDrawList_async.step(
[&](const float dtime) {
client->m_new_meshes = 0;
runData.update_draw_list_timer = 0;
runData.update_draw_list_last_cam_pos = camera_position;
client->getEnv().getClientMap().updateDrawListFm(dtime, 10000);
},
runData.update_draw_list_timer);

},
runData.update_draw_list_timer);
}

if (!runData.headless_optimize)
if (!runData.headless_optimize)
if (RenderingEngine::get_shadow_renderer()) {
update_shadows_async.step([&]() {
updateShadows();
});
}


Expand Down
5 changes: 5 additions & 0 deletions src/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ void Environment::continueRaycast(RaycastState *state, PointedThing *result)
// Next node
state->m_previous_node = state->m_iterator.m_current_node_pos;
state->m_iterator.next();

if (state->end_ms && porting::getTimeMs() > state->end_ms) {
return;
}
}
state->finished = true;
// Return empty PointedThing if nothing left on the ray
if (state->m_found.empty()) {
result->type = POINTEDTHING_NOTHING;
Expand Down
2 changes: 1 addition & 1 deletion src/mapblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ struct abm_trigger_one {
////

class MapBlock
: public locker<>
: public shared_locker
{
public:
MapBlock(Map *parent, v3s16 pos, IGameDef *gamedef);
Expand Down
2 changes: 1 addition & 1 deletion src/noise.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ along with Freeminer. If not, see <http://www.gnu.org/licenses/>.
extern FlagDesc flagdesc_noiseparams[];


#if FARSCALE_LIMIT > 32768
#if MAX_MAP_GENERATION_LIMIT > FARSCALE_LIMIT

template <typename type_scale, typename type_coord>
inline type_scale farscale(type_scale scale, type_coord z) {
Expand Down
6 changes: 6 additions & 0 deletions src/raycast.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ struct RaycastSort
class RaycastState
{
public:

// fm:
bool finished = false;
uint64_t end_ms = 0;
// ==

/*!
* Creates a raycast.
* @param objects_pointable if false, only nodes will be found
Expand Down
10 changes: 5 additions & 5 deletions src/threading/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ class async_step_runner

inline bool valid() { return future.valid(); }

constexpr static uint8_t UNKNOWN = 2;
// 0 : started
// 1 : skipped
// 2 : unknown ?
constexpr static uint8_t IN_PROGRESS = 2;
// 0 : started and finished
// 1 : started
// 2 : in progress, skip
template <class Func, typename... Args>
uint8_t step(Func func, Args &&...args)
{
Expand All @@ -70,7 +70,7 @@ class async_step_runner
#if defined(DUMP_STREAM)
++skips;
#endif
return UNKNOWN;
return IN_PROGRESS;
}
}

Expand Down

0 comments on commit e41cc2b

Please sign in to comment.