Fix TestUniverse
This commit is contained in:
parent
de53f8c7d7
commit
994b0fe3cf
@ -418,7 +418,7 @@ void ClientApplication::render() {
|
|||||||
LogMap::set("client_render_world_client", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - clientStart));
|
LogMap::set("client_render_world_client", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - clientStart));
|
||||||
|
|
||||||
auto paintStart = Time::monotonicMicroseconds();
|
auto paintStart = Time::monotonicMicroseconds();
|
||||||
m_worldPainter->render(m_renderData, [&]() { worldClient->waitForLighting(); });
|
m_worldPainter->render(m_renderData, [&]() { worldClient->waitForLighting(&m_renderData.lightMap); });
|
||||||
LogMap::set("client_render_world_painter", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - paintStart));
|
LogMap::set("client_render_world_painter", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - paintStart));
|
||||||
LogMap::set("client_render_world_total", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - totalStart));
|
LogMap::set("client_render_world_total", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - totalStart));
|
||||||
}
|
}
|
||||||
|
@ -155,24 +155,27 @@ String ClientCommandProcessor::boxes() {
|
|||||||
if (!adminCommandAllowed())
|
if (!adminCommandAllowed())
|
||||||
return "You must be an admin to use this command.";
|
return "You must be an admin to use this command.";
|
||||||
|
|
||||||
return strf("Geometry debug display {}",
|
auto worldClient = m_universeClient->worldClient();
|
||||||
m_universeClient->worldClient()->toggleCollisionDebug()
|
bool state = !worldClient->collisionDebug();
|
||||||
? "enabled" : "disabled");
|
worldClient->setCollisionDebug(state);
|
||||||
|
return strf("Geometry debug display {}", state ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ClientCommandProcessor::fullbright() {
|
String ClientCommandProcessor::fullbright() {
|
||||||
if (!adminCommandAllowed())
|
if (!adminCommandAllowed())
|
||||||
return "You must be an admin to use this command.";
|
return "You must be an admin to use this command.";
|
||||||
|
|
||||||
return strf("Fullbright render lighting {}",
|
auto worldClient = m_universeClient->worldClient();
|
||||||
m_universeClient->worldClient()->toggleFullbright()
|
bool state = !worldClient->fullBright();
|
||||||
? "enabled" : "disabled");
|
worldClient->setFullBright(state);
|
||||||
|
return strf("Fullbright render lighting {}", state ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ClientCommandProcessor::asyncLighting() {
|
String ClientCommandProcessor::asyncLighting() {
|
||||||
return strf("Asynchronous render lighting {}",
|
auto worldClient = m_universeClient->worldClient();
|
||||||
m_universeClient->worldClient()->toggleAsyncLighting()
|
bool state = !worldClient->asyncLighting();
|
||||||
? "enabled" : "disabled");
|
worldClient->setAsyncLighting(state);
|
||||||
|
return strf("Asynchronous render lighting {}", state ? "enabled" : "disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
String ClientCommandProcessor::setGravity(String const& argumentsString) {
|
String ClientCommandProcessor::setGravity(String const& argumentsString) {
|
||||||
|
@ -123,6 +123,7 @@ Maybe<String> UniverseClient::connect(UniverseConnection connection, bool allowA
|
|||||||
m_mainPlayer->setClientContext(m_clientContext);
|
m_mainPlayer->setClientContext(m_clientContext);
|
||||||
m_mainPlayer->setStatistics(m_statistics);
|
m_mainPlayer->setStatistics(m_statistics);
|
||||||
m_worldClient = make_shared<WorldClient>(m_mainPlayer);
|
m_worldClient = make_shared<WorldClient>(m_mainPlayer);
|
||||||
|
m_worldClient->setAsyncLighting(true);
|
||||||
for (auto& pair : m_luaCallbacks)
|
for (auto& pair : m_luaCallbacks)
|
||||||
m_worldClient->setLuaCallbacks(pair.first, pair.second);
|
m_worldClient->setLuaCallbacks(pair.first, pair.second);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ WorldClient::WorldClient(PlayerPtr mainPlayer) {
|
|||||||
m_currentStep = 0;
|
m_currentStep = 0;
|
||||||
m_currentServerStep = 0.0;
|
m_currentServerStep = 0.0;
|
||||||
m_fullBright = false;
|
m_fullBright = false;
|
||||||
m_asyncLighting = true;
|
m_asyncLighting = false;
|
||||||
m_worldDimTimer = GameTimer(m_clientConfig.getFloat("worldDimTime"));
|
m_worldDimTimer = GameTimer(m_clientConfig.getFloat("worldDimTime"));
|
||||||
m_worldDimTimer.setDone();
|
m_worldDimTimer.setDone();
|
||||||
m_worldDimLevel = 0.0f;
|
m_worldDimLevel = 0.0f;
|
||||||
@ -90,13 +90,12 @@ WorldClient::WorldClient(PlayerPtr mainPlayer) {
|
|||||||
m_altMusicActive = false;
|
m_altMusicActive = false;
|
||||||
|
|
||||||
m_stopLightingThread = false;
|
m_stopLightingThread = false;
|
||||||
m_lightingThread = Thread::invoke("WorldClient::lightingMain", mem_fn(&WorldClient::lightingMain), this);
|
|
||||||
m_renderData = nullptr;
|
|
||||||
|
|
||||||
clearWorld();
|
clearWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldClient::~WorldClient() {
|
WorldClient::~WorldClient() {
|
||||||
|
if (m_lightingThread) {
|
||||||
m_stopLightingThread = true;
|
m_stopLightingThread = true;
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_lightingMutex);
|
MutexLocker locker(m_lightingMutex);
|
||||||
@ -104,6 +103,7 @@ WorldClient::~WorldClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_lightingThread.finish();
|
m_lightingThread.finish();
|
||||||
|
}
|
||||||
clearWorld();
|
clearWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,6 +404,9 @@ RectI WorldClient::clientWindow() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
|
void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
|
||||||
|
if (!m_lightingThread && m_asyncLighting)
|
||||||
|
m_lightingThread = Thread::invoke("WorldClient::lightingMain", mem_fn(&WorldClient::lightingMain), this);
|
||||||
|
|
||||||
renderData.clear();
|
renderData.clear();
|
||||||
if (!inWorld())
|
if (!inWorld())
|
||||||
return;
|
return;
|
||||||
@ -474,13 +477,10 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
|
|||||||
m_lightingCalculator.addSpreadLight(position, Color::v3bToFloat(lightPair.second));
|
m_lightingCalculator.addSpreadLight(position, Color::v3bToFloat(lightPair.second));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_asyncLighting) {
|
if (m_asyncLighting)
|
||||||
m_renderData = &renderData;
|
|
||||||
m_lightingCond.signal();
|
m_lightingCond.signal();
|
||||||
}
|
else
|
||||||
else {
|
m_lightingCalculator.calculate(m_lightMap);
|
||||||
m_lightingCalculator.calculate(renderData.lightMap);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float pulseAmount = Root::singleton().assets()->json("/highlights.config:interactivePulseAmount").toFloat();
|
float pulseAmount = Root::singleton().assets()->json("/highlights.config:interactivePulseAmount").toFloat();
|
||||||
@ -725,21 +725,30 @@ void WorldClient::resetGravity() {
|
|||||||
m_overrideGravity = {};
|
m_overrideGravity = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldClient::toggleFullbright() {
|
bool WorldClient::fullBright() const {
|
||||||
m_fullBright = !m_fullBright;
|
|
||||||
return m_fullBright;
|
return m_fullBright;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldClient::toggleAsyncLighting() {
|
void WorldClient::setFullBright(bool fullBright) {
|
||||||
m_asyncLighting = !m_asyncLighting;
|
m_fullBright = fullBright;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorldClient::asyncLighting() const {
|
||||||
return m_asyncLighting;
|
return m_asyncLighting;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WorldClient::toggleCollisionDebug() {
|
void WorldClient::setAsyncLighting(bool asyncLighting) {
|
||||||
m_collisionDebug = !m_collisionDebug;
|
m_asyncLighting = asyncLighting;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WorldClient::collisionDebug() const {
|
||||||
return m_collisionDebug;
|
return m_collisionDebug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WorldClient::setCollisionDebug(bool collisionDebug) {
|
||||||
|
m_collisionDebug = collisionDebug;
|
||||||
|
}
|
||||||
|
|
||||||
void WorldClient::handleIncomingPackets(List<PacketPtr> const& packets) {
|
void WorldClient::handleIncomingPackets(List<PacketPtr> const& packets) {
|
||||||
auto& root = Root::singleton();
|
auto& root = Root::singleton();
|
||||||
auto materialDatabase = root.materialDatabase();
|
auto materialDatabase = root.materialDatabase();
|
||||||
@ -1393,8 +1402,10 @@ void WorldClient::collectLiquid(List<Vec2I> const& tilePositions, LiquidId liqui
|
|||||||
m_outgoingPackets.append(make_shared<CollectLiquidPacket>(tilePositions, liquidId));
|
m_outgoingPackets.append(make_shared<CollectLiquidPacket>(tilePositions, liquidId));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldClient::waitForLighting() {
|
void WorldClient::waitForLighting(Image* out) {
|
||||||
MutexLocker lock(m_lightingMutex);
|
MutexLocker lock(m_lightingMutex);
|
||||||
|
if (out)
|
||||||
|
*out = move(m_lightMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
WorldClient::BroadcastCallback& WorldClient::broadcastCallback() {
|
WorldClient::BroadcastCallback& WorldClient::broadcastCallback() {
|
||||||
@ -1644,15 +1655,10 @@ void WorldClient::lightingMain() {
|
|||||||
if (m_stopLightingThread)
|
if (m_stopLightingThread)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (WorldRenderData* renderData = m_renderData) {
|
|
||||||
int64_t start = Time::monotonicMicroseconds();
|
int64_t start = Time::monotonicMicroseconds();
|
||||||
|
|
||||||
lightingTileGather();
|
lightingTileGather();
|
||||||
|
m_lightingCalculator.calculate(m_lightMap);
|
||||||
m_lightingCalculator.calculate(renderData->lightMap);
|
|
||||||
m_renderData = nullptr;
|
|
||||||
LogMap::set("client_render_world_async_light_calc", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
|
LogMap::set("client_render_world_async_light_calc", strf(u8"{:05d}\u00b5s", Time::monotonicMicroseconds() - start));
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -122,11 +122,14 @@ public:
|
|||||||
void resetGravity();
|
void resetGravity();
|
||||||
|
|
||||||
// Disable normal client-side lighting algorithm, everything full brightness.
|
// Disable normal client-side lighting algorithm, everything full brightness.
|
||||||
bool toggleFullbright();
|
bool fullBright() const;
|
||||||
|
void setFullBright(bool fullBright);
|
||||||
// Disable asynchronous client-side lighting algorithm, run on main thread.
|
// Disable asynchronous client-side lighting algorithm, run on main thread.
|
||||||
bool toggleAsyncLighting();
|
bool asyncLighting() const;
|
||||||
|
void setAsyncLighting(bool asyncLighting);
|
||||||
// Spatial log generated collision geometry.
|
// Spatial log generated collision geometry.
|
||||||
bool toggleCollisionDebug();
|
bool collisionDebug() const;
|
||||||
|
void setCollisionDebug(bool collisionDebug);
|
||||||
|
|
||||||
void handleIncomingPackets(List<PacketPtr> const& packets);
|
void handleIncomingPackets(List<PacketPtr> const& packets);
|
||||||
List<PacketPtr> getOutgoingPackets();
|
List<PacketPtr> getOutgoingPackets();
|
||||||
@ -167,7 +170,7 @@ public:
|
|||||||
|
|
||||||
void collectLiquid(List<Vec2I> const& tilePositions, LiquidId liquidId);
|
void collectLiquid(List<Vec2I> const& tilePositions, LiquidId liquidId);
|
||||||
|
|
||||||
void waitForLighting();
|
void waitForLighting(Image* out = nullptr);
|
||||||
|
|
||||||
typedef std::function<bool(PlayerPtr, StringView)> BroadcastCallback;
|
typedef std::function<bool(PlayerPtr, StringView)> BroadcastCallback;
|
||||||
BroadcastCallback& broadcastCallback();
|
BroadcastCallback& broadcastCallback();
|
||||||
@ -269,7 +272,7 @@ private:
|
|||||||
|
|
||||||
Mutex m_lightingMutex;
|
Mutex m_lightingMutex;
|
||||||
ConditionVariable m_lightingCond;
|
ConditionVariable m_lightingCond;
|
||||||
atomic<WorldRenderData*> m_renderData;
|
Image m_lightMap;
|
||||||
atomic<bool> m_stopLightingThread;
|
atomic<bool> m_stopLightingThread;
|
||||||
|
|
||||||
SkyPtr m_sky;
|
SkyPtr m_sky;
|
||||||
|
@ -269,7 +269,7 @@ void WorldServerThread::update(WorldServerFidelity fidelity) {
|
|||||||
|
|
||||||
float dt = ServerGlobalTimestep * GlobalTimescale;
|
float dt = ServerGlobalTimestep * GlobalTimescale;
|
||||||
m_worldServer->setFidelity(fidelity);
|
m_worldServer->setFidelity(fidelity);
|
||||||
if (!m_pause || *m_pause == false)
|
if (dt > 0.0f && (!m_pause || *m_pause == false))
|
||||||
m_worldServer->update(dt);
|
m_worldServer->update(dt);
|
||||||
|
|
||||||
List<Message> messages;
|
List<Message> messages;
|
||||||
|
@ -42,7 +42,7 @@ TestUniverse::~TestUniverse() {
|
|||||||
void TestUniverse::warpPlayer(WorldId worldId) {
|
void TestUniverse::warpPlayer(WorldId worldId) {
|
||||||
m_client->warpPlayer(WarpToWorld(worldId), true);
|
m_client->warpPlayer(WarpToWorld(worldId), true);
|
||||||
while (m_mainPlayer->isTeleporting() || m_client->playerWorld().empty()) {
|
while (m_mainPlayer->isTeleporting() || m_client->playerWorld().empty()) {
|
||||||
m_client->update();
|
m_client->update(0.016f);
|
||||||
Thread::sleep(16);
|
Thread::sleep(16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ WorldId TestUniverse::currentPlayerWorld() const {
|
|||||||
|
|
||||||
void TestUniverse::update(unsigned times) {
|
void TestUniverse::update(unsigned times) {
|
||||||
for (unsigned i = 0; i < times; ++i) {
|
for (unsigned i = 0; i < times; ++i) {
|
||||||
m_client->update();
|
m_client->update(0.016f);
|
||||||
Thread::sleep(16);
|
Thread::sleep(16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user