feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -103,7 +103,7 @@ void PrimitiveMesh::_update() const {
|
|||
Vector<Vector2> uv = arr[RS::ARRAY_TEX_UV];
|
||||
Vector<Vector2> uv2 = arr[RS::ARRAY_TEX_UV2];
|
||||
|
||||
if (uv.size() > 0 && uv2.size() == 0) {
|
||||
if (uv.size() > 0 && uv2.is_empty()) {
|
||||
Vector2 uv2_scale = get_uv2_scale();
|
||||
uv2.resize(uv.size());
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ void CapsuleMesh::_update_lightmap_size() {
|
|||
Size2i _lightmap_size_hint;
|
||||
float padding = get_uv2_padding();
|
||||
|
||||
float radial_length = radius * Math_PI * 0.5; // circumference of 90 degree bend
|
||||
float radial_length = radius * Math::PI * 0.5; // circumference of 90 degree bend
|
||||
float vertical_length = radial_length * 2 + (height - 2.0 * radius); // total vertical length
|
||||
|
||||
_lightmap_size_hint.x = MAX(1.0, 4.0 * radial_length / texel_size) + padding;
|
||||
|
|
@ -413,9 +413,9 @@ void CapsuleMesh::create_mesh_array(Array &p_arr, const float radius, const floa
|
|||
float twothirds = 2.0 / 3.0;
|
||||
|
||||
// Only used if we calculate UV2
|
||||
float radial_width = 2.0 * radius * Math_PI;
|
||||
float radial_width = 2.0 * radius * Math::PI;
|
||||
float radial_h = radial_width / (radial_width + p_uv2_padding);
|
||||
float radial_length = radius * Math_PI * 0.5; // circumference of 90 degree bend
|
||||
float radial_length = radius * Math::PI * 0.5; // circumference of 90 degree bend
|
||||
float vertical_length = radial_length * 2 + (height - 2.0 * radius) + p_uv2_padding; // total vertical length
|
||||
float radial_v = radial_length / vertical_length; // v size of top and bottom section
|
||||
float height_v = (height - 2.0 * radius) / vertical_length; // v size of height section
|
||||
|
|
@ -447,8 +447,8 @@ void CapsuleMesh::create_mesh_array(Array &p_arr, const float radius, const floa
|
|||
w = 1.0;
|
||||
y = 0.0;
|
||||
} else {
|
||||
w = Math::sin(0.5 * Math_PI * v);
|
||||
y = Math::cos(0.5 * Math_PI * v);
|
||||
w = Math::sin(0.5 * Math::PI * v);
|
||||
y = Math::cos(0.5 * Math::PI * v);
|
||||
}
|
||||
|
||||
for (i = 0; i <= radial_segments; i++) {
|
||||
|
|
@ -459,8 +459,8 @@ void CapsuleMesh::create_mesh_array(Array &p_arr, const float radius, const floa
|
|||
x = 0.0;
|
||||
z = 1.0;
|
||||
} else {
|
||||
x = -Math::sin(u * Math_TAU);
|
||||
z = Math::cos(u * Math_TAU);
|
||||
x = -Math::sin(u * Math::TAU);
|
||||
z = Math::cos(u * Math::TAU);
|
||||
}
|
||||
|
||||
Vector3 p = Vector3(x * w, y, -z * w);
|
||||
|
|
@ -506,8 +506,8 @@ void CapsuleMesh::create_mesh_array(Array &p_arr, const float radius, const floa
|
|||
x = 0.0;
|
||||
z = 1.0;
|
||||
} else {
|
||||
x = -Math::sin(u * Math_TAU);
|
||||
z = Math::cos(u * Math_TAU);
|
||||
x = -Math::sin(u * Math::TAU);
|
||||
z = Math::cos(u * Math::TAU);
|
||||
}
|
||||
|
||||
Vector3 p = Vector3(x * radius, y, -z * radius);
|
||||
|
|
@ -546,8 +546,8 @@ void CapsuleMesh::create_mesh_array(Array &p_arr, const float radius, const floa
|
|||
w = 0.0;
|
||||
y = -1.0;
|
||||
} else {
|
||||
w = Math::cos(0.5 * Math_PI * v);
|
||||
y = -Math::sin(0.5 * Math_PI * v);
|
||||
w = Math::cos(0.5 * Math::PI * v);
|
||||
y = -Math::sin(0.5 * Math::PI * v);
|
||||
}
|
||||
|
||||
for (i = 0; i <= radial_segments; i++) {
|
||||
|
|
@ -558,8 +558,8 @@ void CapsuleMesh::create_mesh_array(Array &p_arr, const float radius, const floa
|
|||
x = 0.0;
|
||||
z = 1.0;
|
||||
} else {
|
||||
x = -Math::sin(u * Math_TAU);
|
||||
z = Math::cos(u * Math_TAU);
|
||||
x = -Math::sin(u * Math::TAU);
|
||||
z = Math::cos(u * Math::TAU);
|
||||
}
|
||||
|
||||
Vector3 p = Vector3(x * w, y, -z * w);
|
||||
|
|
@ -1028,8 +1028,8 @@ void CylinderMesh::_update_lightmap_size() {
|
|||
Size2i _lightmap_size_hint;
|
||||
float padding = get_uv2_padding();
|
||||
|
||||
float top_circumference = top_radius * Math_PI * 2.0;
|
||||
float bottom_circumference = bottom_radius * Math_PI * 2.0;
|
||||
float top_circumference = top_radius * Math::PI * 2.0;
|
||||
float bottom_circumference = bottom_radius * Math::PI * 2.0;
|
||||
|
||||
float _width = MAX(top_circumference, bottom_circumference) / texel_size + padding;
|
||||
_width = MAX(_width, (((top_radius + bottom_radius) / texel_size) + padding) * 2.0); // this is extremely unlikely to be larger, will only happen if padding is larger then our diameter.
|
||||
|
|
@ -1055,8 +1055,8 @@ void CylinderMesh::create_mesh_array(Array &p_arr, float top_radius, float botto
|
|||
float x, y, z, u, v, radius, radius_h;
|
||||
|
||||
// Only used if we calculate UV2
|
||||
float top_circumference = top_radius * Math_PI * 2.0;
|
||||
float bottom_circumference = bottom_radius * Math_PI * 2.0;
|
||||
float top_circumference = top_radius * Math::PI * 2.0;
|
||||
float bottom_circumference = bottom_radius * Math::PI * 2.0;
|
||||
float vertical_length = height + MAX(2.0 * top_radius, 2.0 * bottom_radius) + (2.0 * p_uv2_padding);
|
||||
float height_v = height / vertical_length;
|
||||
float padding_v = p_uv2_padding / vertical_length;
|
||||
|
|
@ -1102,8 +1102,8 @@ void CylinderMesh::create_mesh_array(Array &p_arr, float top_radius, float botto
|
|||
x = 0.0;
|
||||
z = 1.0;
|
||||
} else {
|
||||
x = Math::sin(u * Math_TAU);
|
||||
z = Math::cos(u * Math_TAU);
|
||||
x = Math::sin(u * Math::TAU);
|
||||
z = Math::cos(u * Math::TAU);
|
||||
}
|
||||
|
||||
Vector3 p = Vector3(x * radius, y, z * radius);
|
||||
|
|
@ -1159,8 +1159,8 @@ void CylinderMesh::create_mesh_array(Array &p_arr, float top_radius, float botto
|
|||
x = 0.0;
|
||||
z = 1.0;
|
||||
} else {
|
||||
x = Math::sin(r * Math_TAU);
|
||||
z = Math::cos(r * Math_TAU);
|
||||
x = Math::sin(r * Math::TAU);
|
||||
z = Math::cos(r * Math::TAU);
|
||||
}
|
||||
|
||||
u = ((x + 1.0) * 0.25);
|
||||
|
|
@ -1206,8 +1206,8 @@ void CylinderMesh::create_mesh_array(Array &p_arr, float top_radius, float botto
|
|||
x = 0.0;
|
||||
z = 1.0;
|
||||
} else {
|
||||
x = Math::sin(r * Math_TAU);
|
||||
z = Math::cos(r * Math_TAU);
|
||||
x = Math::sin(r * Math::TAU);
|
||||
z = Math::cos(r * Math::TAU);
|
||||
}
|
||||
|
||||
u = 0.5 + ((x + 1.0) * 0.25);
|
||||
|
|
@ -1921,9 +1921,9 @@ void SphereMesh::_update_lightmap_size() {
|
|||
Size2i _lightmap_size_hint;
|
||||
float padding = get_uv2_padding();
|
||||
|
||||
float _width = radius * Math_TAU;
|
||||
float _width = radius * Math::TAU;
|
||||
_lightmap_size_hint.x = MAX(1.0, (_width / texel_size) + padding);
|
||||
float _height = (is_hemisphere ? 1.0 : 0.5) * height * Math_PI; // note, with hemisphere height is our radius, while with a full sphere it is the diameter..
|
||||
float _height = (is_hemisphere ? 1.0 : 0.5) * height * Math::PI; // note, with hemisphere height is our radius, while with a full sphere it is the diameter..
|
||||
_lightmap_size_hint.y = MAX(1.0, (_height / texel_size) + padding);
|
||||
|
||||
set_lightmap_size_hint(_lightmap_size_hint);
|
||||
|
|
@ -1944,11 +1944,11 @@ void SphereMesh::create_mesh_array(Array &p_arr, float radius, float height, int
|
|||
float scale = height / radius * (is_hemisphere ? 1.0 : 0.5);
|
||||
|
||||
// Only used if we calculate UV2
|
||||
float circumference = radius * Math_TAU;
|
||||
float circumference = radius * Math::TAU;
|
||||
float horizontal_length = circumference + p_uv2_padding;
|
||||
float center_h = 0.5 * circumference / horizontal_length;
|
||||
|
||||
float height_v = scale * Math_PI / ((scale * Math_PI) + p_uv2_padding / radius);
|
||||
float height_v = scale * Math::PI / ((scale * Math::PI) + p_uv2_padding / radius);
|
||||
|
||||
// set our bounding box
|
||||
|
||||
|
|
@ -1977,8 +1977,8 @@ void SphereMesh::create_mesh_array(Array &p_arr, float radius, float height, int
|
|||
w = 0.0;
|
||||
y = -1.0;
|
||||
} else {
|
||||
w = Math::sin(Math_PI * v);
|
||||
y = Math::cos(Math_PI * v);
|
||||
w = Math::sin(Math::PI * v);
|
||||
y = Math::cos(Math::PI * v);
|
||||
}
|
||||
|
||||
for (i = 0; i <= radial_segments; i++) {
|
||||
|
|
@ -1989,8 +1989,8 @@ void SphereMesh::create_mesh_array(Array &p_arr, float radius, float height, int
|
|||
x = 0.0;
|
||||
z = 1.0;
|
||||
} else {
|
||||
x = Math::sin(u * Math_TAU);
|
||||
z = Math::cos(u * Math_TAU);
|
||||
x = Math::sin(u * Math::TAU);
|
||||
z = Math::cos(u * Math::TAU);
|
||||
}
|
||||
|
||||
if (is_hemisphere && y < 0.0) {
|
||||
|
|
@ -2141,9 +2141,9 @@ void TorusMesh::_update_lightmap_size() {
|
|||
|
||||
float radius = (max_radius - min_radius) * 0.5;
|
||||
|
||||
float _width = max_radius * Math_TAU;
|
||||
float _width = max_radius * Math::TAU;
|
||||
_lightmap_size_hint.x = MAX(1.0, (_width / texel_size) + padding);
|
||||
float _height = radius * Math_TAU;
|
||||
float _height = radius * Math::TAU;
|
||||
_lightmap_size_hint.y = MAX(1.0, (_height / texel_size) + padding);
|
||||
|
||||
set_lightmap_size_hint(_lightmap_size_hint);
|
||||
|
|
@ -2181,23 +2181,23 @@ void TorusMesh::_create_mesh_array(Array &p_arr) const {
|
|||
bool _add_uv2 = get_add_uv2();
|
||||
float _uv2_padding = get_uv2_padding() * texel_size;
|
||||
|
||||
float horizontal_total = max_radius * Math_TAU + _uv2_padding;
|
||||
float max_h = max_radius * Math_TAU / horizontal_total;
|
||||
float delta_h = (max_radius - min_radius) * Math_TAU / horizontal_total;
|
||||
float horizontal_total = max_radius * Math::TAU + _uv2_padding;
|
||||
float max_h = max_radius * Math::TAU / horizontal_total;
|
||||
float delta_h = (max_radius - min_radius) * Math::TAU / horizontal_total;
|
||||
|
||||
float height_v = radius * Math_TAU / (radius * Math_TAU + _uv2_padding);
|
||||
float height_v = radius * Math::TAU / (radius * Math::TAU + _uv2_padding);
|
||||
|
||||
for (int i = 0; i <= rings; i++) {
|
||||
int prevrow = (i - 1) * (ring_segments + 1);
|
||||
int thisrow = i * (ring_segments + 1);
|
||||
float inci = float(i) / rings;
|
||||
float angi = inci * Math_TAU;
|
||||
float angi = inci * Math::TAU;
|
||||
|
||||
Vector2 normali = (i == rings) ? Vector2(0.0, -1.0) : Vector2(-Math::sin(angi), -Math::cos(angi));
|
||||
|
||||
for (int j = 0; j <= ring_segments; j++) {
|
||||
float incj = float(j) / ring_segments;
|
||||
float angj = incj * Math_TAU;
|
||||
float angj = incj * Math::TAU;
|
||||
|
||||
Vector2 normalj = (j == ring_segments) ? Vector2(-1.0, 0.0) : Vector2(-Math::cos(angj), Math::sin(angj));
|
||||
Vector2 normalk = normalj * radius + Vector2(min_radius + radius, 0);
|
||||
|
|
@ -2486,8 +2486,8 @@ void TubeTrailMesh::_create_mesh_array(Array &p_arr) const {
|
|||
float x = 0.0;
|
||||
float z = 1.0;
|
||||
if (i < radial_steps) {
|
||||
x = Math::sin(u * Math_TAU);
|
||||
z = Math::cos(u * Math_TAU);
|
||||
x = Math::sin(u * Math::TAU);
|
||||
z = Math::cos(u * Math::TAU);
|
||||
}
|
||||
|
||||
Vector3 p = Vector3(x * r, y, z * r);
|
||||
|
|
@ -2559,8 +2559,8 @@ void TubeTrailMesh::_create_mesh_array(Array &p_arr) const {
|
|||
float x = 0.0;
|
||||
float z = 1.0;
|
||||
if (i < radial_steps) {
|
||||
x = Math::sin(r * Math_TAU);
|
||||
z = Math::cos(r * Math_TAU);
|
||||
x = Math::sin(r * Math::TAU);
|
||||
z = Math::cos(r * Math::TAU);
|
||||
}
|
||||
|
||||
float u = ((x + 1.0) * 0.25);
|
||||
|
|
@ -2628,8 +2628,8 @@ void TubeTrailMesh::_create_mesh_array(Array &p_arr) const {
|
|||
float x = 0.0;
|
||||
float z = 1.0;
|
||||
if (i < radial_steps) {
|
||||
x = Math::sin(r * Math_TAU);
|
||||
z = Math::cos(r * Math_TAU);
|
||||
x = Math::sin(r * Math::TAU);
|
||||
z = Math::cos(r * Math::TAU);
|
||||
}
|
||||
|
||||
float u = 0.5 + ((x + 1.0) * 0.25);
|
||||
|
|
@ -2972,7 +2972,7 @@ void TextMesh::_generate_glyph_mesh_data(const GlyphMeshKey &p_key, const Glyph
|
|||
PackedInt32Array contours = d["contours"];
|
||||
bool orientation = d["orientation"];
|
||||
|
||||
if (points.size() < 3 || contours.size() < 1) {
|
||||
if (points.size() < 3 || contours.is_empty()) {
|
||||
return; // No full contours, only glyph control points (or nothing), ignore.
|
||||
}
|
||||
|
||||
|
|
@ -3105,14 +3105,13 @@ void TextMesh::_generate_glyph_mesh_data(const GlyphMeshKey &p_key, const Glyph
|
|||
ERR_FAIL_MSG("Convex decomposing failed. Make sure the font doesn't contain self-intersecting lines, as these are not supported in TextMesh.");
|
||||
}
|
||||
List<TPPLPoly> out_tris;
|
||||
for (List<TPPLPoly>::Element *I = out_poly.front(); I; I = I->next()) {
|
||||
if (tpart.Triangulate_OPT(&(I->get()), &out_tris) == 0) {
|
||||
for (TPPLPoly &tp : out_poly) {
|
||||
if (tpart.Triangulate_OPT(&tp, &out_tris) == 0) {
|
||||
ERR_FAIL_MSG("Triangulation failed. Make sure the font doesn't contain self-intersecting lines, as these are not supported in TextMesh.");
|
||||
}
|
||||
}
|
||||
|
||||
for (List<TPPLPoly>::Element *I = out_tris.front(); I; I = I->next()) {
|
||||
TPPLPoly &tp = I->get();
|
||||
for (const TPPLPoly &tp : out_tris) {
|
||||
ERR_FAIL_COND(tp.GetNumPoints() != 3); // Triangles only.
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
|
@ -3249,8 +3248,8 @@ void TextMesh::_create_mesh_array(Array &p_arr) const {
|
|||
Vector<Vector2> uvs;
|
||||
Vector<int32_t> indices;
|
||||
|
||||
Vector2 min_p = Vector2(INFINITY, INFINITY);
|
||||
Vector2 max_p = Vector2(-INFINITY, -INFINITY);
|
||||
Vector2 min_p = Vector2(Math::INF, Math::INF);
|
||||
Vector2 max_p = Vector2(-Math::INF, -Math::INF);
|
||||
|
||||
int32_t p_size = 0;
|
||||
int32_t i_size = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue