-fixed issue with denormals in half precission, closes #1073
-added h_offset and v_offset to 3D Camera, should allow to do the same as in #1102
This commit is contained in:
parent
60afd79a6e
commit
cef3bd026f
|
@ -80,6 +80,7 @@ MainLoop* test() {
|
|||
|
||||
{
|
||||
|
||||
|
||||
// print_line("NUM: "+itos(237641278346127));
|
||||
print_line("NUM: "+itos(-128));
|
||||
return NULL;
|
||||
|
|
|
@ -250,7 +250,7 @@ Error JSON::_get_token(const CharType *p_str, int &idx, int p_len, Token& r_toke
|
|||
if (p_str[idx]=='-' || (p_str[idx]>='0' && p_str[idx]<='9')) {
|
||||
//a number
|
||||
const CharType *rptr;
|
||||
double number = String::to_double(&p_str[idx],-1,&rptr);
|
||||
double number = String::to_double(&p_str[idx],&rptr);
|
||||
idx+=(rptr - &p_str[idx]);
|
||||
r_token.type=TK_NUMBER;
|
||||
r_token.value=number;
|
||||
|
|
|
@ -626,7 +626,7 @@ Vector<float> String::split_floats(const String &p_splitter,bool p_allow_empty)
|
|||
if (end<0)
|
||||
end=len;
|
||||
if (p_allow_empty || (end>from))
|
||||
ret.push_back(String::to_double(&c_str()[from],end-from));
|
||||
ret.push_back(String::to_double(&c_str()[from]));
|
||||
|
||||
if (end==len)
|
||||
break;
|
||||
|
@ -654,8 +654,11 @@ Vector<float> String::split_floats_mk(const Vector<String> &p_splitters,bool p_a
|
|||
spl_len=p_splitters[idx].length();
|
||||
}
|
||||
|
||||
if (p_allow_empty || (end>from))
|
||||
ret.push_back(String::to_double(&c_str()[from],end-from));
|
||||
if (p_allow_empty || (end>from)) {
|
||||
double d = String::to_double(&c_str()[from]);
|
||||
print_line("get db: "+rtos(d));
|
||||
ret.push_back(String::to_double(&c_str()[from]));
|
||||
}
|
||||
|
||||
if (end==len)
|
||||
break;
|
||||
|
@ -1959,8 +1962,10 @@ float String::to_float() const {
|
|||
return to_double();
|
||||
}
|
||||
|
||||
double String::to_double(const CharType* p_str, int p_len, const CharType **r_end) {
|
||||
double String::to_double(const CharType* p_str, const CharType **r_end) {
|
||||
|
||||
return built_in_strtod<CharType>(p_str,(CharType**)r_end);
|
||||
#if 0
|
||||
#if 0
|
||||
//ndef NO_USE_STDLIB
|
||||
return wcstod(p_str,p_len<0?NULL:p_str+p_len);
|
||||
|
@ -2053,6 +2058,7 @@ double String::to_double(const CharType* p_str, int p_len, const CharType **r_en
|
|||
|
||||
return sign*(integer+decimal)*Math::pow(10,exp_sign*exp);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t String::to_int(const CharType* p_str,int p_len) {
|
||||
|
@ -3437,7 +3443,7 @@ String String::percent_encode() const {
|
|||
uint8_t c = cs[i];
|
||||
if ( (c>='A' && c<='Z') || (c>='a' && c<='z') || (c>='0' && c<='9') || c=='-' || c=='_' || c=='~' || c=='.') {
|
||||
|
||||
char p[2]={c,0};
|
||||
char p[2]={(char)c,0};
|
||||
encoded+=p;
|
||||
} else {
|
||||
char p[4]={'%',0,0,0};
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
int64_t to_int64() const;
|
||||
static int to_int(const char* p_str);
|
||||
static double to_double(const char* p_str);
|
||||
static double to_double(const CharType* p_str, int p_len=-1, const CharType **r_end=NULL);
|
||||
static double to_double(const CharType* p_str, const CharType **r_end=NULL);
|
||||
static int64_t to_int(const CharType* p_str,int p_len=-1);
|
||||
String capitalize() const;
|
||||
|
||||
|
|
|
@ -139,11 +139,13 @@ static _FORCE_INLINE_ uint16_t make_half_float(float f) {
|
|||
else if (exp <= 0x38000000)
|
||||
{
|
||||
|
||||
// store a denorm half-float value or zero
|
||||
/*// store a denorm half-float value or zero
|
||||
exp = (0x38000000 - exp) >> 23;
|
||||
mantissa >>= (14 + exp);
|
||||
|
||||
hf = (((uint16_t)sign) << 15) | (uint16_t)(mantissa);
|
||||
*/
|
||||
hf=0; //denormals do not work for 3D
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -86,6 +86,10 @@ bool Camera::_set(const StringName& p_name, const Variant& p_value) {
|
|||
set_keep_aspect_mode(KeepAspect(int(p_value)));
|
||||
else if (p_name=="vaspect")
|
||||
set_keep_aspect_mode(p_value?KEEP_WIDTH:KEEP_HEIGHT);
|
||||
else if (p_name=="h_offset")
|
||||
h_offset=p_value;
|
||||
else if (p_name=="v_offset")
|
||||
v_offset=p_value;
|
||||
else if (p_name=="current") {
|
||||
if (p_value.operator bool()) {
|
||||
make_current();
|
||||
|
@ -128,6 +132,10 @@ bool Camera::_get(const StringName& p_name,Variant &r_ret) const {
|
|||
}
|
||||
} else if (p_name=="visible_layers") {
|
||||
r_ret=get_visible_layers();
|
||||
} else if (p_name=="h_offset") {
|
||||
r_ret=get_h_offset();
|
||||
} else if (p_name=="v_offset") {
|
||||
r_ret=get_v_offset();
|
||||
} else if (p_name=="environment") {
|
||||
r_ret=get_environment();
|
||||
} else
|
||||
|
@ -170,12 +178,16 @@ void Camera::_get_property_list( List<PropertyInfo> *p_list) const {
|
|||
p_list->push_back( PropertyInfo( Variant::BOOL, "current" ) );
|
||||
p_list->push_back( PropertyInfo( Variant::INT, "visible_layers",PROPERTY_HINT_ALL_FLAGS ) );
|
||||
p_list->push_back( PropertyInfo( Variant::OBJECT, "environment",PROPERTY_HINT_RESOURCE_TYPE,"Environment" ) );
|
||||
p_list->push_back( PropertyInfo( Variant::REAL, "h_offset" ) );
|
||||
p_list->push_back( PropertyInfo( Variant::REAL, "v_offset" ) );
|
||||
|
||||
}
|
||||
|
||||
void Camera::_update_camera() {
|
||||
|
||||
Transform tr = get_camera_transform();
|
||||
tr.origin+=tr.basis.get_axis(1)*v_offset;
|
||||
tr.origin+=tr.basis.get_axis(0)*h_offset;
|
||||
VisualServer::get_singleton()->camera_set_transform( camera, tr );
|
||||
|
||||
// here goes listener stuff
|
||||
|
@ -757,6 +769,27 @@ void Camera::look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, cons
|
|||
|
||||
}
|
||||
|
||||
void Camera::set_v_offset(float p_offset) {
|
||||
|
||||
v_offset=p_offset;
|
||||
_update_camera();;
|
||||
}
|
||||
|
||||
float Camera::get_v_offset() const {
|
||||
|
||||
return v_offset;
|
||||
}
|
||||
|
||||
void Camera::set_h_offset(float p_offset) {
|
||||
h_offset=p_offset;
|
||||
_update_camera();
|
||||
}
|
||||
|
||||
float Camera::get_h_offset() const {
|
||||
|
||||
return h_offset;
|
||||
}
|
||||
|
||||
|
||||
Camera::Camera() {
|
||||
|
||||
|
@ -772,6 +805,8 @@ Camera::Camera() {
|
|||
set_perspective(60.0,0.1,100.0);
|
||||
keep_aspect=KEEP_HEIGHT;
|
||||
layers=0xfffff;
|
||||
v_offset=0;
|
||||
h_offset=0;
|
||||
VisualServer::get_singleton()->camera_set_visible_layers(camera,layers);
|
||||
//active=false;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ private:
|
|||
float fov;
|
||||
float size;
|
||||
float near,far;
|
||||
float v_offset;
|
||||
float h_offset;
|
||||
KeepAspect keep_aspect;
|
||||
|
||||
RID camera;
|
||||
|
@ -140,6 +142,12 @@ public:
|
|||
void look_at(const Vector3& p_target, const Vector3& p_up_normal);
|
||||
void look_at_from_pos(const Vector3& p_pos,const Vector3& p_target, const Vector3& p_up_normal);
|
||||
|
||||
void set_v_offset(float p_offset);
|
||||
float get_v_offset() const;
|
||||
|
||||
void set_h_offset(float p_offset);
|
||||
float get_h_offset() const;
|
||||
|
||||
|
||||
Camera();
|
||||
~Camera();
|
||||
|
|
Loading…
Reference in New Issue