mirror of
https://gitlab.com/splashmapper/splash.git
synced 2026-06-16 12:33:50 +02:00
Change object culling attribute to a choices list
This commit is contained in:
@@ -135,7 +135,7 @@
|
||||
"rotation" : [ 0, 0, 0 ],
|
||||
"savable" : [ true ],
|
||||
"scale" : [ 1, 1, 1 ],
|
||||
"culling" : [ 0 ],
|
||||
"culling" : [ "double sided" ],
|
||||
"timestamp" : [ 1853296687 ],
|
||||
"type" : "object"
|
||||
},
|
||||
@@ -211,7 +211,7 @@
|
||||
"swapInterval" : [ 1 ]
|
||||
}
|
||||
},
|
||||
"version" : "0.11.5",
|
||||
"version" : "0.11.7",
|
||||
"world" : {
|
||||
"clock" : [ 1884832083 ],
|
||||
"clockDeviceName" : [ "" ],
|
||||
|
||||
+38
-4
@@ -625,12 +625,46 @@ void Object::registerAttributes()
|
||||
addAttribute(
|
||||
"culling",
|
||||
[&](const Values& args) {
|
||||
_culling = static_cast<Shader::Culling>(args[0].as<int>());
|
||||
const auto mode = args[0].as<std::string>();
|
||||
if (mode == "double sided")
|
||||
_culling = Shader::Culling::doubleSided;
|
||||
else if (mode == "front-face culling")
|
||||
_culling = Shader::Culling::singleSided;
|
||||
else if (mode == "back-face culling")
|
||||
_culling = Shader::Culling::inverted;
|
||||
else
|
||||
_culling = Shader::Culling::doubleSided;
|
||||
return true;
|
||||
},
|
||||
[&]() -> Values { return {_culling}; },
|
||||
{'i'});
|
||||
setAttributeDescription("culling", "Set the side culling for the object: 0 for double sided, 1 for front-face visible, 2 for back-face visible");
|
||||
[&]() -> Values {
|
||||
Values values;
|
||||
switch(_culling)
|
||||
{
|
||||
default:
|
||||
assert(false);
|
||||
values.push_back("double sided");
|
||||
break;
|
||||
case Shader::Culling::doubleSided:
|
||||
values.push_back("double sided");
|
||||
break;
|
||||
case Shader::Culling::singleSided:
|
||||
values.push_back("front-face culling");
|
||||
break;
|
||||
case Shader::Culling::inverted:
|
||||
values.push_back("back-face culling");
|
||||
break;
|
||||
}
|
||||
|
||||
// Possible values
|
||||
values.push_back("double sided");
|
||||
values.push_back("front-face culling");
|
||||
values.push_back("back-face culling");
|
||||
|
||||
return values;
|
||||
},
|
||||
{'s'},
|
||||
Attribute::Choices::Generated);
|
||||
setAttributeDescription("culling", "Set the side culling for the object");
|
||||
|
||||
addAttribute(
|
||||
"fill",
|
||||
|
||||
@@ -275,6 +275,32 @@ bool checkAndUpgradeConfiguration(Json::Value& configuration)
|
||||
|
||||
configuration = newConfig;
|
||||
}
|
||||
if ((versionMajor == 0 && versionMinor < 11) || (versionMajor == 0 && versionMinor == 11 && versionMaintainance < 7))
|
||||
{
|
||||
Json::Value newConfig = configuration;
|
||||
for (auto& scene : newConfig["scenes"])
|
||||
{
|
||||
if (!scene.isMember("objects"))
|
||||
continue;
|
||||
|
||||
for (auto& object : scene["objects"])
|
||||
{
|
||||
if (object["type"] != "object" && !object.isMember("culling"))
|
||||
continue;
|
||||
|
||||
const auto culling = object["culling"][0].asInt();
|
||||
if (culling == 0)
|
||||
object["culling"] = "double sided";
|
||||
else if (culling == 1)
|
||||
object["culling"] = "front-face culling";
|
||||
else if (culling == 1)
|
||||
object["culling"] = "back-face culling";
|
||||
else
|
||||
object["culling"] = "double sided";
|
||||
}
|
||||
}
|
||||
configuration = newConfig;
|
||||
}
|
||||
|
||||
configuration["version"] = std::string(PACKAGE_VERSION);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user