mirror of
https://github.com/godotengine/godot.git
synced 2025-02-17 22:43:01 +08:00
Use real_t in GridMap and VariantParser
This commit is contained in:
parent
47cf9985eb
commit
affe3c817a
@ -381,7 +381,6 @@ Error VariantParser::get_token(Stream *p_stream, Token &r_token, int &line, Stri
|
|||||||
r_token.value = num.as_int();
|
r_token.value = num.as_int();
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
|
} else if ((cchar >= 'A' && cchar <= 'Z') || (cchar >= 'a' && cchar <= 'z') || cchar == '_') {
|
||||||
StringBuffer<> id;
|
StringBuffer<> id;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
@ -508,8 +507,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
} else if (id == "nan") {
|
} else if (id == "nan") {
|
||||||
value = Math_NAN;
|
value = Math_NAN;
|
||||||
} else if (id == "Vector2") {
|
} else if (id == "Vector2") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -534,8 +533,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = Vector2i(args[0], args[1]);
|
value = Vector2i(args[0], args[1]);
|
||||||
} else if (id == "Rect2") {
|
} else if (id == "Rect2") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -560,8 +559,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = Rect2i(args[0], args[1], args[2], args[3]);
|
value = Rect2i(args[0], args[1], args[2], args[3]);
|
||||||
} else if (id == "Vector3") {
|
} else if (id == "Vector3") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -586,8 +585,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = Vector3i(args[0], args[1], args[2]);
|
value = Vector3i(args[0], args[1], args[2]);
|
||||||
} else if (id == "Transform2D" || id == "Matrix32") { //compatibility
|
} else if (id == "Transform2D" || id == "Matrix32") { //compatibility
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -603,8 +602,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
m[2] = Vector2(args[4], args[5]);
|
m[2] = Vector2(args[4], args[5]);
|
||||||
value = m;
|
value = m;
|
||||||
} else if (id == "Plane") {
|
} else if (id == "Plane") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -616,8 +615,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = Plane(args[0], args[1], args[2], args[3]);
|
value = Plane(args[0], args[1], args[2], args[3]);
|
||||||
} else if (id == "Quat") {
|
} else if (id == "Quat") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -629,8 +628,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = Quat(args[0], args[1], args[2], args[3]);
|
value = Quat(args[0], args[1], args[2], args[3]);
|
||||||
} else if (id == "AABB" || id == "Rect3") {
|
} else if (id == "AABB" || id == "Rect3") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -642,8 +641,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = AABB(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5]));
|
value = AABB(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5]));
|
||||||
} else if (id == "Basis" || id == "Matrix3") { //compatibility
|
} else if (id == "Basis" || id == "Matrix3") { //compatibility
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -655,8 +654,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = Basis(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
|
value = Basis(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
|
||||||
} else if (id == "Transform") {
|
} else if (id == "Transform") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -1006,8 +1005,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = arr;
|
value = arr;
|
||||||
} else if (id == "PackedVector2Array" || id == "PoolVector2Array" || id == "Vector2Array") {
|
} else if (id == "PackedVector2Array" || id == "PoolVector2Array" || id == "Vector2Array") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -1024,8 +1023,8 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
|
|||||||
|
|
||||||
value = arr;
|
value = arr;
|
||||||
} else if (id == "PackedVector3Array" || id == "PoolVector3Array" || id == "Vector3Array") {
|
} else if (id == "PackedVector3Array" || id == "PoolVector3Array" || id == "Vector3Array") {
|
||||||
Vector<float> args;
|
Vector<real_t> args;
|
||||||
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
|
Error err = _parse_construct<real_t>(p_stream, args, line, r_err_str);
|
||||||
if (err) {
|
if (err) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -386,13 +386,13 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
int cell[3];
|
int cell[3];
|
||||||
float cell_size[3] = { node->get_cell_size().x, node->get_cell_size().y, node->get_cell_size().z };
|
Vector3 cell_size = node->get_cell_size();
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (i == edit_axis) {
|
if (i == edit_axis) {
|
||||||
cell[i] = edit_floor[i];
|
cell[i] = edit_floor[i];
|
||||||
} else {
|
} else {
|
||||||
cell[i] = inters[i] / node->get_cell_size()[i];
|
cell[i] = inters[i] / cell_size[i];
|
||||||
if (inters[i] < 0) {
|
if (inters[i] < 0) {
|
||||||
cell[i] -= 1; // Compensate negative.
|
cell[i] -= 1; // Compensate negative.
|
||||||
}
|
}
|
||||||
@ -436,6 +436,7 @@ bool GridMapEditor::do_input_action(Camera3D *p_camera, const Point2 &p_point, b
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_action == INPUT_PAINT) {
|
if (input_action == INPUT_PAINT) {
|
||||||
SetItem si;
|
SetItem si;
|
||||||
si.position = Vector3i(cell[0], cell[1], cell[2]);
|
si.position = Vector3i(cell[0], cell[1], cell[2]);
|
||||||
@ -545,7 +546,7 @@ void GridMapEditor::_update_paste_indicator() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 center = 0.5 * Vector3(float(node->get_center_x()), float(node->get_center_y()), float(node->get_center_z()));
|
Vector3 center = 0.5 * Vector3(real_t(node->get_center_x()), real_t(node->get_center_y()), real_t(node->get_center_z()));
|
||||||
Vector3 scale = (Vector3(1, 1, 1) + (paste_indicator.end - paste_indicator.begin)) * node->get_cell_size();
|
Vector3 scale = (Vector3(1, 1, 1) + (paste_indicator.end - paste_indicator.begin)) * node->get_cell_size();
|
||||||
Transform xf;
|
Transform xf;
|
||||||
xf.scale(scale);
|
xf.scale(scale);
|
||||||
|
Loading…
Reference in New Issue
Block a user