49 lines
1.1 KiB
Plaintext
49 lines
1.1 KiB
Plaintext
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
|
// See the file tools.license for terms.
|
|
|
|
#ifndef tools_box_3f
|
|
#define tools_box_3f
|
|
|
|
#include "../mnmx"
|
|
|
|
#include <cfloat> // FLT_MAX
|
|
|
|
namespace tools {
|
|
|
|
// optimization (used in exlib/sg/text_hershey) :
|
|
|
|
inline void box_3f_make_empty(float& a_mn_x,float& a_mn_y,float& a_mn_z,
|
|
float& a_mx_x,float& a_mx_y,float& a_mx_z){
|
|
a_mn_x = FLT_MAX;
|
|
a_mn_y = FLT_MAX;
|
|
a_mn_z = FLT_MAX;
|
|
a_mx_x = -FLT_MAX;
|
|
a_mx_y = -FLT_MAX;
|
|
a_mx_z = -FLT_MAX;
|
|
}
|
|
inline void box_3f_extend_by(float& a_mn_x,float& a_mn_y,float& a_mn_z,
|
|
float& a_mx_x,float& a_mx_y,float& a_mx_z,
|
|
float a_x,float a_y,float a_z){
|
|
if(a_mx_x<a_mn_x){ //is empty.
|
|
a_mn_x = a_x;
|
|
a_mn_y = a_y;
|
|
a_mn_z = a_z;
|
|
|
|
a_mx_x = a_x;
|
|
a_mx_y = a_y;
|
|
a_mx_z = a_z;
|
|
} else {
|
|
a_mn_x = min_of<float>(a_x,a_mn_x);
|
|
a_mn_y = min_of<float>(a_y,a_mn_y);
|
|
a_mn_z = min_of<float>(a_z,a_mn_z);
|
|
|
|
a_mx_x = max_of<float>(a_x,a_mx_x);
|
|
a_mx_y = max_of<float>(a_y,a_mx_y);
|
|
a_mx_z = max_of<float>(a_z,a_mx_z);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|