Skip to content

Commit 35fb0c7

Browse files
committed
Merge branch 'master' of https://github.com/ryobg/obj2hmap
2 parents 1f52652 + 074ae96 commit 35fb0c7

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ development I used GCC 6.2. No other external dependencies.
3030
c++ obj2hmap.cpp -o obj2hmap -O2
3131
```
3232

33+
Or MacOS:
34+
35+
```
36+
clang++ -std=c++14 -stdlib=libc++ -Weverything obj2hmap.cpp -o obj2hmap -O2
37+
```
38+
3339
Is enough. You can skip even the optimization level `-O2` and the named executable `-o obj2hmap`.
3440

3541
I have tested with Visual Studio Community 2015 and succeeded to build:

hmap2obj.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class hmap2obj
5858
std::string hmap; ///< Input *.* heightmap binary file to read from
5959
std::string obj; ///< Output *.obj file to write to
6060
uvec2 hmap_size; ///< How big is the integer grid of the input heighmap file
61-
vec3 obj_blo; ///< The lowest corner of the obj bounding box
62-
vec3 obj_bhi; ///< The highest corner of the obj bounding box
61+
dvec3 obj_blo; ///< The lowest corner of the obj bounding box
62+
dvec3 obj_bhi; ///< The highest corner of the obj bounding box
6363
bool absolute; ///< Whether height values shall occupy the whole input grid range
6464
};
6565

@@ -116,8 +116,8 @@ hmap2obj::param_type hmap2obj::parse_cli (std::vector<std::string> const& args)
116116
param_type p;
117117
p.absolute = false;
118118
p.hmap_size.fill (0);
119-
p.obj_blo.fill (numeric_limits<float>::quiet_NaN ());
120-
p.obj_bhi.fill (numeric_limits<float>::quiet_NaN ());
119+
p.obj_blo.fill (numeric_limits<decltype(p.obj_blo)::value_type>::quiet_NaN ());
120+
p.obj_bhi.fill (numeric_limits<decltype(p.obj_bhi)::value_type>::quiet_NaN ());
121121

122122
for (auto& arg: args)
123123
{
@@ -158,7 +158,7 @@ hmap2obj::param_type hmap2obj::parse_cli (std::vector<std::string> const& args)
158158
try
159159
{
160160
bool succ = false;
161-
float x = stof (arg);
161+
auto x = stod (arg);
162162

163163
for (size_t i = 0, n = p.obj_blo.size (); i < n; ++i)
164164
if (isnan (p.obj_blo[i]))

obj2hmap.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class obj2hmap
6161
std::string hmap; ///< Output *.* binary file to write to
6262
uvec3 hmap_size; ///< Says how big is the integer grid for the heightmap
6363
bvec3 height_coord; ///< Toggles which one of the 3 coords is the displacement axis
64-
float objmin; ///< Optional, real OBJ lowest displacement coordinate value
65-
float objmax; ///< Optional, real OBJ highest displacement coordinate value
64+
double objmin; ///< Optional, real OBJ lowest displacement coordinate value
65+
double objmax; ///< Optional, real OBJ highest displacement coordinate value
6666
enum file_type ///< Talks about what kind of heightmap values we should output
6767
{
6868
u8, u16, u32, f32, ///< Binary 8/16/32 unsigned and 32 bit float
@@ -145,8 +145,8 @@ obj2hmap::param_type obj2hmap::parse_cli (std::vector<std::string> const& args)
145145
using namespace std;
146146

147147
param_type p;
148-
p.objmin = numeric_limits<float>::quiet_NaN ();
149-
p.objmax = numeric_limits<float>::quiet_NaN ();
148+
p.objmin = numeric_limits<decltype(p.objmin)>::quiet_NaN ();
149+
p.objmax = numeric_limits<decltype(p.objmax)>::quiet_NaN ();
150150
p.hmap_size.fill (0);
151151
p.height_coord.fill (false);
152152

@@ -219,7 +219,7 @@ obj2hmap::param_type obj2hmap::parse_cli (std::vector<std::string> const& args)
219219

220220
try
221221
{
222-
float n = stof (arg);
222+
auto n = stod (arg);
223223
if (isnan (p.objmin))
224224
{
225225
p.objmin = n;
@@ -412,12 +412,12 @@ void obj2hmap::dump_heightmap ()
412412

413413
size_t haxis = find_disp_axis ();
414414

415-
double objmin = params.objmin;
416-
double objmax = params.objmax;
415+
double objmin = blo[haxis];
416+
double objmax = bhi[haxis];
417417
if (!isnan (params.objmin) && !isnan (params.objmax))
418418
{
419-
objmin = min<double> (objmin, params.objmin);
420-
objmax = max<double> (objmax, params.objmax);
419+
objmin = min (objmin, params.objmin);
420+
objmax = max (objmax, params.objmax);
421421
}
422422

423423
auto height = params.hmap_size.at (haxis) / (objmax - objmin);

0 commit comments

Comments
 (0)