new object lighting toggle, log non-master entity render/update exceptions
This commit is contained in:
parent
ed8b22c472
commit
227e60ca4c
@ -1,6 +1,9 @@
|
||||
function patch(image)
|
||||
-- Camera Pan Speed
|
||||
image:copyInto({119, 68}, image:process("?crop=19;68;117;87"))
|
||||
local checkbox = image:process("?crop=19;26;117;35")
|
||||
-- Anti-Aliasing
|
||||
image:copyInto({119, 26}, image:process("?crop=19;26;117;35"))
|
||||
image:copyInto({119, 26}, checkbox)
|
||||
-- Object Lighting
|
||||
image:copyInto({19, 15}, checkbox)
|
||||
end
|
@ -28,6 +28,8 @@ function patch(config)
|
||||
-- Create anti-aliasing toggle
|
||||
shift(clone(layout, "multiTextureLabel", "antiAliasingLabel"), 98).value = "SUPER-SAMPLED AA"
|
||||
shift(clone(layout, "multiTextureCheckbox", "antiAliasingCheckbox"), 99)
|
||||
|
||||
-- Create object lighting toggle
|
||||
shift(clone(layout, "multiTextureLabel", "objectLightingLabel"), 0, -11).value = "NEW OBJECT LIGHTS"
|
||||
shift(clone(layout, "multiTextureCheckbox", "objectLightingCheckbox"), 0, -11)
|
||||
return config
|
||||
end
|
BIN
assets/opensb/rendering/error.png
Normal file
BIN
assets/opensb/rendering/error.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 B |
BIN
assets/opensb/rendering/error_left.png
Normal file
BIN
assets/opensb/rendering/error_left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 B |
BIN
assets/opensb/rendering/error_right.png
Normal file
BIN
assets/opensb/rendering/error_right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 174 B |
@ -67,7 +67,7 @@ void CellularLightArray<ScalarLightTraits>::calculatePointLighting(size_t xmin,
|
||||
auto newLight = ScalarLightTraits::subtract(light.value, attenuation);
|
||||
if (ScalarLightTraits::maxIntensity(newLight) > 0.0001f) {
|
||||
if (light.asSpread)
|
||||
setLight(x, y, lvalue + newLight * 0.25f);
|
||||
setLight(x, y, lvalue + newLight * 0.15f);
|
||||
else
|
||||
setLight(x, y, lvalue + newLight);
|
||||
}
|
||||
@ -140,7 +140,7 @@ void CellularLightArray<ColoredLightTraits>::calculatePointLighting(size_t xmin,
|
||||
auto newLight = ColoredLightTraits::subtract(light.value, attenuation);
|
||||
if (ColoredLightTraits::maxIntensity(newLight) > 0.0001f) {
|
||||
if (light.asSpread)
|
||||
setLight(x, y, lvalue + newLight * 0.25f);
|
||||
setLight(x, y, lvalue + newLight * 0.15f);
|
||||
else
|
||||
setLight(x, y, lvalue + newLight);
|
||||
}
|
||||
|
@ -461,6 +461,13 @@ ByteArray LuaEngine::compile(ByteArray const& contents, String const& name) {
|
||||
return compile(contents.ptr(), contents.size(), name.empty() ? nullptr : name.utf8Ptr());
|
||||
}
|
||||
|
||||
lua_Debug const& LuaEngine::debugInfo(int level, const char* what) {
|
||||
lua_Debug& debug = m_debugInfo = lua_Debug();
|
||||
lua_getstack(m_state, level, &debug);
|
||||
lua_getinfo(m_state, what, &debug);
|
||||
return debug;
|
||||
}
|
||||
|
||||
LuaString LuaEngine::createString(String const& str) {
|
||||
lua_checkstack(m_state, 1);
|
||||
|
||||
|
@ -519,6 +519,9 @@ public:
|
||||
ByteArray compile(char const* contents, size_t size, char const* name = nullptr);
|
||||
ByteArray compile(String const& contents, String const& name = String());
|
||||
ByteArray compile(ByteArray const& contents, String const& name = String());
|
||||
|
||||
// Returns the debug info of the state.
|
||||
lua_Debug const& debugInfo(int level = 1, const char* what = "nSlu");
|
||||
|
||||
// Generic from/to lua conversion, calls template specialization of
|
||||
// LuaConverter for actual conversion.
|
||||
@ -734,6 +737,7 @@ private:
|
||||
unsigned m_recursionLimit;
|
||||
int m_nullTerminated;
|
||||
HashMap<tuple<String, unsigned>, shared_ptr<LuaProfileEntry>> m_profileEntries;
|
||||
lua_Debug m_debugInfo;
|
||||
};
|
||||
|
||||
// Built in conversions
|
||||
|
@ -86,6 +86,12 @@ GraphicsMenu::GraphicsMenu() {
|
||||
Root::singleton().configuration()->set("monochromeLighting", checked);
|
||||
syncGui();
|
||||
});
|
||||
reader.registerCallback("objectLightingCheckbox", [=](Widget*) {
|
||||
bool checked = fetchChild<ButtonWidget>("objectLightingCheckbox")->isChecked();
|
||||
m_localChanges.set("newObjectLighting", checked);
|
||||
Root::singleton().configuration()->set("newObjectLighting", checked);
|
||||
syncGui();
|
||||
});
|
||||
|
||||
auto assets = Root::singleton().assets();
|
||||
|
||||
@ -140,7 +146,8 @@ StringList const GraphicsMenu::ConfigKeys = {
|
||||
"limitTextureAtlasSize",
|
||||
"useMultiTexturing",
|
||||
"antiAliasing",
|
||||
"monochromeLighting"
|
||||
"monochromeLighting",
|
||||
"newObjectLighting"
|
||||
};
|
||||
|
||||
void GraphicsMenu::initConfig() {
|
||||
@ -196,6 +203,7 @@ void GraphicsMenu::syncGui() {
|
||||
fetchChild<ButtonWidget>("multiTextureCheckbox")->setChecked(m_localChanges.get("useMultiTexturing").optBool().value(true));
|
||||
fetchChild<ButtonWidget>("antiAliasingCheckbox")->setChecked(m_localChanges.get("antiAliasing").toBool());
|
||||
fetchChild<ButtonWidget>("monochromeCheckbox")->setChecked(m_localChanges.get("monochromeLighting").toBool());
|
||||
fetchChild<ButtonWidget>("objectLightingCheckbox")->setChecked(m_localChanges.get("newObjectLighting").optBool().value(true));
|
||||
}
|
||||
|
||||
void GraphicsMenu::apply() {
|
||||
|
@ -489,7 +489,21 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
|
||||
|
||||
ClientRenderCallback renderCallback;
|
||||
|
||||
entity->render(&renderCallback);
|
||||
try { entity->render(&renderCallback); }
|
||||
catch (StarException const& e) {
|
||||
if (entity->isMaster()) // this is YOUR problem!!
|
||||
throw e;
|
||||
else { // this is THEIR problem!!
|
||||
Logger::error("WorldClient: Exception caught in {}::render ({}): {}", EntityTypeNames.getRight(entity->entityType()), entity->entityId(), e.what());
|
||||
auto toolUser = as<ToolUserEntity>(entity);
|
||||
String image = toolUser ? strf("/rendering/error_{}.png", DirectionNames.getRight(toolUser->facingDirection())) : "/rendering/error.png";
|
||||
Color color = Color::rgbf(0.8f + (float)sin(m_currentTime * Constants::pi * 0.5) * 0.2f, 0.0f, 0.0f);
|
||||
auto drawable = Drawable::makeImage(image, 1.0f / TilePixels, true, entity->position(), color);
|
||||
drawable.fullbright = true;
|
||||
renderCallback.addDrawable(std::move(drawable), RenderLayerMiddleParticle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EntityDrawables ed;
|
||||
for (auto& p : renderCallback.drawables) {
|
||||
@ -1110,7 +1124,13 @@ void WorldClient::update(float dt) {
|
||||
List<EntityId> toRemove;
|
||||
List<EntityId> clientPresenceEntities;
|
||||
m_entityMap->updateAllEntities([&](EntityPtr const& entity) {
|
||||
entity->update(dt, m_currentStep);
|
||||
try { entity->update(dt, m_currentStep); }
|
||||
catch (StarException const& e) {
|
||||
if (entity->isMaster()) // this is YOUR problem!!
|
||||
throw e;
|
||||
else // this is THEIR problem!!
|
||||
Logger::error("WorldClient: Exception caught in {}::update ({}): {}", EntityTypeNames.getRight(entity->entityType()), entity->entityId(), e.what());
|
||||
}
|
||||
|
||||
if (entity->shouldDestroy() && entity->entityMode() == EntityMode::Master)
|
||||
toRemove.append(entity->entityId());
|
||||
@ -1649,23 +1669,27 @@ void WorldClient::lightingCalc() {
|
||||
RectI lightRange = m_pendingLightRange;
|
||||
List<LightSource> lights = std::move(m_pendingLights);
|
||||
List<std::pair<Vec2F, Vec3F>> particleLights = std::move(m_pendingParticleLights);
|
||||
m_lightingCalculator.setMonochrome(Root::singleton().configuration()->get("monochromeLighting").toBool());
|
||||
auto configuration = Root::singleton().configuration();
|
||||
bool monochrome = configuration->get("monochromeLighting").toBool();
|
||||
m_lightingCalculator.setMonochrome(monochrome);
|
||||
m_lightingCalculator.begin(lightRange);
|
||||
lightingTileGather();
|
||||
|
||||
prepLocker.unlock();
|
||||
|
||||
|
||||
|
||||
bool useHybridPointLights = configuration->get("newObjectLighting").optBool().value(true);
|
||||
for (auto const& light : lights) {
|
||||
Vec2F position = m_geometry.nearestTo(Vec2F(m_lightingCalculator.calculationRegion().min()), light.position);
|
||||
if (light.type == LightType::Spread)
|
||||
m_lightingCalculator.addSpreadLight(position, light.color);
|
||||
else {
|
||||
if (light.type == LightType::PointAsSpread) {
|
||||
// hybrid (used for auto-converted object lights) - 75% spread, 25% point (2nd is applied elsewhere)
|
||||
m_lightingCalculator.addSpreadLight(position, light.color * 0.75f);
|
||||
m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience, true);
|
||||
if (!useHybridPointLights)
|
||||
m_lightingCalculator.addSpreadLight(position, light.color);
|
||||
else { // hybrid (used for auto-converted object lights) - 85% spread, 15% point (2nd is applied elsewhere)
|
||||
m_lightingCalculator.addSpreadLight(position, light.color * 0.85f);
|
||||
m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience, true);
|
||||
}
|
||||
} else // fully additive point light
|
||||
m_lightingCalculator.addPointLight(position, light.color, light.pointBeam, light.beamAngle, light.beamAmbience);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ const FontTextureGroup::GlyphTexture& FontTextureGroup::glyphTexture(String::Cha
|
||||
|
||||
res.first->second.offset = (preSize - Vec2F(image.size())) / 2;
|
||||
}
|
||||
catch (StarException&) {
|
||||
catch (StarException const&) {
|
||||
image.forEachPixel([](unsigned x, unsigned y, Vec4B& pixel) {
|
||||
pixel = ((x + y) % 2 == 0) ? Vec4B(255, 0, 255, pixel[3]) : Vec4B(0, 0, 0, pixel[3]);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user