diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-06-15 23:45:24 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-02-11 11:53:27 +0100 |
commit | 9b0dd4f571ff431e23b9097e7f29746f4157be12 (patch) | |
tree | aa18fc6803e8733f8f270666e691153c72b6066d /scene/3d/sprite_3d.cpp | |
parent | 836c2109a0b1371653e3c82100199dfdabd47da9 (diff) |
A lot of progress with canvas rendering, still far from working.
Diffstat (limited to 'scene/3d/sprite_3d.cpp')
-rw-r--r-- | scene/3d/sprite_3d.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 6656f8d751..50965b5a93 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -483,7 +483,7 @@ void Sprite3D::_draw() { RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y); VS::get_singleton()->immediate_set_material(immediate, mat); - VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid()); + VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid()); int x_axis = ((axis + 1) % 3); int y_axis = ((axis + 2) % 3); @@ -504,15 +504,18 @@ void Sprite3D::_draw() { AABB aabb; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 6; i++) { + + static const int index[6] = { 0, 1, 2, 0, 2, 3 }; + VS::get_singleton()->immediate_normal(immediate, normal); VS::get_singleton()->immediate_tangent(immediate, tangent); VS::get_singleton()->immediate_color(immediate, color); VS::get_singleton()->immediate_uv(immediate, uvs[i]); Vector3 vtx; - vtx[x_axis] = vertices[i][0]; - vtx[y_axis] = vertices[i][1]; + vtx[x_axis] = vertices[index[i]][0]; + vtx[y_axis] = vertices[index[i]][1]; VS::get_singleton()->immediate_vertex(immediate, vtx); if (i == 0) { aabb.position = vtx; @@ -811,7 +814,7 @@ void AnimatedSprite3D::_draw() { VS::get_singleton()->immediate_set_material(immediate, mat); - VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid()); + VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid()); int x_axis = ((axis + 1) % 3); int y_axis = ((axis + 2) % 3); @@ -832,15 +835,21 @@ void AnimatedSprite3D::_draw() { AABB aabb; - for (int i = 0; i < 4; i++) { + for (int i = 0; i < 6; i++) { + + static const int indices[6] = { + 0, 1, 2, + 0, 2, 3 + }; + VS::get_singleton()->immediate_normal(immediate, normal); VS::get_singleton()->immediate_tangent(immediate, tangent); VS::get_singleton()->immediate_color(immediate, color); VS::get_singleton()->immediate_uv(immediate, uvs[i]); Vector3 vtx; - vtx[x_axis] = vertices[i][0]; - vtx[y_axis] = vertices[i][1]; + vtx[x_axis] = vertices[indices[i]][0]; + vtx[y_axis] = vertices[indices[i]][1]; VS::get_singleton()->immediate_vertex(immediate, vtx); if (i == 0) { aabb.position = vtx; |