mirror of
https://github.com/rwengine/openrw.git
synced 2025-04-28 12:58:05 +03:00
Avoid using shared_ptr for InstanceData
This commit is contained in:
parent
44148c528a
commit
f15f3cefdd
4 changed files with 13 additions and 12 deletions
|
@ -116,9 +116,9 @@ bool GameWorld::placeItems(const std::string& name) {
|
|||
if (ipll.load(name)) {
|
||||
// Find the object.
|
||||
for (const auto& inst : ipll.m_instances) {
|
||||
if (!createInstance(inst->id, inst->pos, inst->rot)) {
|
||||
if (!createInstance(inst.id, inst.pos, inst.rot)) {
|
||||
logger->error("World", "No object data for instance " +
|
||||
std::to_string(inst->id) + " in " +
|
||||
std::to_string(inst.id) + " in " +
|
||||
name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,18 +80,18 @@ bool LoaderIPL::load(std::istream &str) {
|
|||
getline(strstream, rotZ, ',');
|
||||
getline(strstream, rotW, ',');
|
||||
|
||||
auto instance = std::make_shared<InstanceData>(
|
||||
m_instances.emplace_back(
|
||||
lexical_cast<int>(id), // ID
|
||||
model.substr(1, model.size() - 1),
|
||||
glm::vec3(lexical_cast<float>(posX), lexical_cast<float>(posY),
|
||||
glm::vec3(lexical_cast<float>(posX),
|
||||
lexical_cast<float>(posY),
|
||||
lexical_cast<float>(posZ)),
|
||||
glm::vec3(lexical_cast<float>(scaleX), lexical_cast<float>(scaleY),
|
||||
glm::vec3(lexical_cast<float>(scaleX),
|
||||
lexical_cast<float>(scaleY),
|
||||
lexical_cast<float>(scaleZ)),
|
||||
glm::normalize(
|
||||
glm::quat(-lexical_cast<float>(rotW), lexical_cast<float>(rotX),
|
||||
lexical_cast<float>(rotY), lexical_cast<float>(rotZ))));
|
||||
|
||||
m_instances.push_back(instance);
|
||||
glm::normalize(glm::quat(
|
||||
-lexical_cast<float>(rotW), lexical_cast<float>(rotX),
|
||||
lexical_cast<float>(rotY), lexical_cast<float>(rotZ))));
|
||||
} else if (section == ZONE) {
|
||||
ZoneData zone;
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include <data/ZoneData.hpp>
|
||||
#include <data/InstanceData.hpp>
|
||||
|
||||
struct InstanceData;
|
||||
|
||||
|
@ -22,7 +23,7 @@ public:
|
|||
bool load(std::istream& stream);
|
||||
|
||||
/// The list of instances from the IPL file
|
||||
std::vector<std::shared_ptr<InstanceData>> m_instances;
|
||||
std::vector<InstanceData> m_instances;
|
||||
|
||||
/// List of Zones
|
||||
ZoneDataList zones;
|
||||
|
|
|
@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(instance_data_is_correct) {
|
|||
BOOST_REQUIRE(loader.load(test_data_stream));
|
||||
|
||||
const auto expectedInstance = InstanceData(112, "ModelB", {10.0f, 12.0f, 5.0f}, {1.f, 1.f, 1.f}, {0.0f, 0.f, 0.f, 1.0f});
|
||||
BOOST_TEST(*loader.m_instances[1] == expectedInstance);
|
||||
BOOST_TEST(loader.m_instances[1] == expectedInstance);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue