mirror of
https://github.com/open-goal/jak-project
synced 2026-09-02 18:12:50 -04:00
custom levels: add support for more res types in actor lumps (#1754)
* add support for more res types in actor lumps * floatm -> meters
This commit is contained in:
@@ -20,6 +20,17 @@
|
||||
// this makes collision 2x slower and bigger, so only use if really needed
|
||||
"double_sided_collide": false,
|
||||
|
||||
// available res-lump tag data types:
|
||||
// int32, float, meters, vector, vector4m (meters)
|
||||
//
|
||||
// examples:
|
||||
//
|
||||
// adds a float tag 'spring-height' with value of 200 meters (1 meter = 4096.0 units):
|
||||
// "spring-height": ["meters", 200.0]
|
||||
//
|
||||
// adds a vector tag 'movie-pos':
|
||||
// "movie-pos": ["vector", [4096000.0, -176128.0, 1353973.76, 1.0]]
|
||||
|
||||
"actors" : [
|
||||
{
|
||||
"trans": [-21.6238, 20.0496, 17.1191], // translation
|
||||
|
||||
@@ -113,6 +113,30 @@ std::unique_ptr<Res> res_from_json_array(const std::string& name,
|
||||
data.push_back(json_array[i].get<int>());
|
||||
}
|
||||
return std::make_unique<ResInt32>(name, data, -1000000000.0000);
|
||||
} else if (array_type == "vector") {
|
||||
std::vector<math::Vector4f> data;
|
||||
for (size_t i = 1; i < json_array.size(); i++) {
|
||||
data.push_back(vector_from_json(json_array[i]));
|
||||
}
|
||||
return std::make_unique<ResVector>(name, data, -1000000000.0000);
|
||||
} else if (array_type == "vector4m") {
|
||||
std::vector<math::Vector4f> data;
|
||||
for (size_t i = 1; i < json_array.size(); i++) {
|
||||
data.push_back(vectorm4_from_json(json_array[i]));
|
||||
}
|
||||
return std::make_unique<ResVector>(name, data, -1000000000.0000);
|
||||
} else if (array_type == "float") {
|
||||
std::vector<float> data;
|
||||
for (size_t i = 1; i < json_array.size(); i++) {
|
||||
data.push_back(json_array[i].get<float>());
|
||||
}
|
||||
return std::make_unique<ResFloat>(name, data, -1000000000.0000);
|
||||
} else if (array_type == "meters") {
|
||||
std::vector<float> data;
|
||||
for (size_t i = 1; i < json_array.size(); i++) {
|
||||
data.push_back(json_array[i].get<float>() * METER_LENGTH);
|
||||
}
|
||||
return std::make_unique<ResFloat>(name, data, -1000000000.0000);
|
||||
} else {
|
||||
ASSERT_MSG(false, fmt::format("unsupported array type: {}\n", array_type));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user