Skip to content

Commit 5d644d5

Browse files
committed
Bugfix for objects in nordic special map with no position or orient properties
Our current guess is that they were using that map to play around and learn the map editor. Positions are calculated as the center of the bmin. All objects are required to have bmin/bmax so this should always work
1 parent 2df3d4d commit 5d644d5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Nanoforge/BuildConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace BuildConfig
1616

1717
#define NanoforgeVersionMajor 0
1818
#define NanoforgeVersionMinor 21
19-
#define NanoforgeVersionPatch 0
19+
#define NanoforgeVersionPatch 1
2020
#define NanoforgeVersionSuffix ""
2121
static const std::string Version = MAKE_VERSION_STRING(NanoforgeVersionMajor, NanoforgeVersionMinor, NanoforgeVersionPatch, NanoforgeVersionSuffix);
2222
}

Nanoforge/rfg/Territory.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,28 @@ void Territory::LoadThread(Handle<Task> task, Handle<Scene> scene, GuiState* sta
132132
}
133133
}
134134

135-
//Add description to objects missing them
135+
//Fix issues on objects that caused bugs in the past
136+
//Typically done here and in the importers so existing maps don't need to be re-imported
136137
for (ObjectHandle zone : Object.GetObjectList("Zones"))
137138
{
138139
for (ObjectHandle obj : zone.GetObjectList("Objects"))
139140
{
141+
//Add description to objects missing them
140142
if (!obj.Has("Description"))
141143
{
142144
obj.Set<string>("Description", "");
143145
}
146+
//Add missing position and orient
147+
if (!obj.Has("Orient"))
148+
{
149+
obj.Set<Mat3>("Orient", Mat3());
150+
}
151+
if (!obj.Has("Position"))
152+
{
153+
Vec3 bboxSize = obj.Get<Vec3>("Bmax") - obj.Get<Vec3>("Bmin");
154+
Vec3 position = obj.Get<Vec3>("Bmin") + (bboxSize / 2.0f);
155+
obj.Set<Vec3>("Position", position);
156+
}
144157
}
145158
}
146159

0 commit comments

Comments
 (0)