diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/SCsub | 15 | ||||
-rw-r--r-- | drivers/convex_decomp/SCsub | 17 | ||||
-rw-r--r-- | drivers/convex_decomp/b2d_decompose.cpp | 162 | ||||
-rw-r--r-- | drivers/convex_decomp/b2d_decompose.h | 39 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_canvas_gles2.cpp | 15 | ||||
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.cpp | 4 | ||||
-rw-r--r-- | drivers/gles2/shaders/canvas.glsl | 4 | ||||
-rw-r--r-- | drivers/gles2/shaders/scene.glsl | 3 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.cpp | 15 | ||||
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 4 | ||||
-rw-r--r-- | drivers/gles3/shaders/canvas.glsl | 2 | ||||
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 4 | ||||
-rw-r--r-- | drivers/register_driver_types.cpp | 13 |
13 files changed, 47 insertions, 250 deletions
diff --git a/drivers/SCsub b/drivers/SCsub index 583973c025..d91d98a713 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -33,11 +33,6 @@ else: # Core dependencies SConscript("png/SCsub") -# Tools override -# FIXME: Should likely be integrated in the tools/ codebase -if env['tools']: - SConscript("convex_decomp/SCsub") - if env['vsproj']: import os path = os.getcwd() @@ -46,9 +41,7 @@ if env['vsproj']: env.AddToVSProject(env.drivers_sources) os.chdir(path) -if env.split_drivers: - env.split_lib("drivers") -else: - env.add_source_files(env.drivers_sources, "*.cpp") - lib = env.add_library("drivers", env.drivers_sources) - env.Prepend(LIBS=[lib]) +env.add_source_files(env.drivers_sources, "*.cpp") + +lib = env.add_library("drivers", env.drivers_sources) +env.Prepend(LIBS=[lib]) diff --git a/drivers/convex_decomp/SCsub b/drivers/convex_decomp/SCsub deleted file mode 100644 index 65ba5332b7..0000000000 --- a/drivers/convex_decomp/SCsub +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python - -Import('env') - -env.add_source_files(env.drivers_sources, "*.cpp") - -# Thirdparty dependencies -thirdparty_dir = "#thirdparty/b2d_convexdecomp/" -thirdparty_sources = [ - "b2Polygon.cpp", - "b2Triangle.cpp", -] -thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - -env_thirdparty = env.Clone() -env_thirdparty.disable_warnings() -env_thirdparty.add_source_files(env.drivers_sources, thirdparty_sources) diff --git a/drivers/convex_decomp/b2d_decompose.cpp b/drivers/convex_decomp/b2d_decompose.cpp deleted file mode 100644 index 7b16b6e752..0000000000 --- a/drivers/convex_decomp/b2d_decompose.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/*************************************************************************/ -/* b2d_decompose.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "b2d_decompose.h" - -#include "thirdparty/b2d_convexdecomp/b2Polygon.h" - -namespace b2ConvexDecomp { - -void add_to_res(Vector<Vector<Vector2> > &res, const b2Polygon &p_poly) { - - Vector<Vector2> arr; - for (int i = 0; i < p_poly.nVertices; i++) { - - arr.push_back(Vector2(p_poly.x[i], p_poly.y[i])); - } - - res.push_back(arr); -} - -static Vector<Vector<Vector2> > _b2d_decompose(const Vector<Vector2> &p_polygon) { - - Vector<Vector<Vector2> > res; - if (p_polygon.size() < 3) - return res; - - b2Vec2 *polys = memnew_arr(b2Vec2, p_polygon.size()); - for (int i = 0; i < p_polygon.size(); i++) - polys[i] = b2Vec2(p_polygon[i].x, p_polygon[i].y); - - b2Polygon *p = new b2Polygon(polys, p_polygon.size()); - b2Polygon *decomposed = new b2Polygon[p->nVertices - 2]; //maximum number of polys - - memdelete_arr(polys); - - int32 nPolys = DecomposeConvex(p, decomposed, p->nVertices - 2); - //int32 extra = 0; - for (int32 i = 0; i < nPolys; ++i) { - // b2FixtureDef* toAdd = &pdarray[i+extra]; - // *toAdd = *prototype; - //Hmm, shouldn't have to do all this... - b2Polygon curr = decomposed[i]; - //TODO ewjordan: move this triangle handling to a better place so that - //it happens even if this convenience function is not called. - if (curr.nVertices == 3) { - //Check here for near-parallel edges, since we can't - //handle this in merge routine - for (int j = 0; j < 3; ++j) { - int32 lower = (j == 0) ? (curr.nVertices - 1) : (j - 1); - int32 middle = j; - int32 upper = (j == curr.nVertices - 1) ? (0) : (j + 1); - float32 dx0 = curr.x[middle] - curr.x[lower]; - float32 dy0 = curr.y[middle] - curr.y[lower]; - float32 dx1 = curr.x[upper] - curr.x[middle]; - float32 dy1 = curr.y[upper] - curr.y[middle]; - float32 norm0 = sqrtf(dx0 * dx0 + dy0 * dy0); - float32 norm1 = sqrtf(dx1 * dx1 + dy1 * dy1); - if (!(norm0 > 0.0f && norm1 > 0.0f)) { - //Identical points, don't do anything! - goto Skip; - } - dx0 /= norm0; - dy0 /= norm0; - dx1 /= norm1; - dy1 /= norm1; - float32 cross = dx0 * dy1 - dx1 * dy0; - float32 dot = dx0 * dx1 + dy0 * dy1; - if (fabs(cross) < b2_angularSlop && dot > 0) { - //Angle too close, split the triangle across from this point. - //This is guaranteed to result in two triangles that satisfy - //the tolerance (one of the angles is 90 degrees) - float32 dx2 = curr.x[lower] - curr.x[upper]; - float32 dy2 = curr.y[lower] - curr.y[upper]; - float32 norm2 = sqrtf(dx2 * dx2 + dy2 * dy2); - if (norm2 == 0.0f) { - goto Skip; - } - dx2 /= norm2; - dy2 /= norm2; - float32 thisArea = curr.GetArea(); - float32 thisHeight = 2.0f * thisArea / norm2; - float32 buffer2 = dx2; - dx2 = dy2; - dy2 = -buffer2; - //Make two new polygons - //printf("dx2: %f, dy2: %f, thisHeight: %f, middle: %d\n",dx2,dy2,thisHeight,middle); - float32 newX1[3] = { curr.x[middle] + dx2 * thisHeight, curr.x[lower], curr.x[middle] }; - float32 newY1[3] = { curr.y[middle] + dy2 * thisHeight, curr.y[lower], curr.y[middle] }; - float32 newX2[3] = { newX1[0], curr.x[middle], curr.x[upper] }; - float32 newY2[3] = { newY1[0], curr.y[middle], curr.y[upper] }; - b2Polygon p1(newX1, newY1, 3); - b2Polygon p2(newX2, newY2, 3); - if (p1.IsUsable()) { - add_to_res(res, p1); - //++extra; - } else if (B2_POLYGON_REPORT_ERRORS) { - printf("Didn't add unusable polygon. Dumping vertices:\n"); - p1.print(); - } - if (p2.IsUsable()) { - add_to_res(res, p2); - - //p2.AddTo(pdarray[i+extra]); - - //bd->CreateFixture(toAdd); - } else if (B2_POLYGON_REPORT_ERRORS) { - printf("Didn't add unusable polygon. Dumping vertices:\n"); - p2.print(); - } - goto Skip; - } - } - } - if (decomposed[i].IsUsable()) { - add_to_res(res, decomposed[i]); - - //decomposed[i].AddTo(*toAdd); - //bd->CreateFixture((const b2FixtureDef*)toAdd); - } else if (B2_POLYGON_REPORT_ERRORS) { - printf("Didn't add unusable polygon. Dumping vertices:\n"); - decomposed[i].print(); - } - Skip:; - } - //delete[] pdarray; - delete[] decomposed; - delete p; - return res; // pdarray; //needs to be deleted after body is created -} -} // namespace b2ConvexDecomp - -Vector<Vector<Vector2> > b2d_decompose(const Vector<Vector2> &p_polygon) { - - return b2ConvexDecomp::_b2d_decompose(p_polygon); -} diff --git a/drivers/convex_decomp/b2d_decompose.h b/drivers/convex_decomp/b2d_decompose.h deleted file mode 100644 index e79f692852..0000000000 --- a/drivers/convex_decomp/b2d_decompose.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************/ -/* b2d_decompose.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef B2D_DECOMPOSE_H -#define B2D_DECOMPOSE_H - -#include "core/math/vector2.h" -#include "core/vector.h" - -Vector<Vector<Vector2> > b2d_decompose(const Vector<Vector2> &p_polygon); - -#endif // B2D_DECOMPOSE_H diff --git a/drivers/gles2/rasterizer_canvas_gles2.cpp b/drivers/gles2/rasterizer_canvas_gles2.cpp index 1db1625194..3b2851fbcd 100644 --- a/drivers/gles2/rasterizer_canvas_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_gles2.cpp @@ -1898,9 +1898,20 @@ void RasterizerCanvasGLES2::canvas_light_shadow_buffer_update(RID p_buffer, cons } state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES2::WORLD_MATRIX, instance->xform_cache); - if (cull != instance->cull_cache) { - cull = instance->cull_cache; + VS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache; + + if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED && + (p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) { + transformed_cull_cache = + transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ? + VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE : + VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE; + } + + if (cull != transformed_cull_cache) { + + cull = transformed_cull_cache; switch (cull) { case VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: { diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 7e9b6fdb82..94cb286b0e 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -911,7 +911,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[VS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy"; actions[VS::SHADER_CANVAS_ITEM].renames["UV"] = "uv"; - actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "gl_PointSize"; + actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size"; actions[VS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix"; actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix"; @@ -986,7 +986,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[VS::SHADER_SPATIAL].renames["UV"] = "uv_interp"; actions[VS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp"; actions[VS::SHADER_SPATIAL].renames["COLOR"] = "color_interp"; - actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "gl_PointSize"; + actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size"; // gl_InstanceID is not available in OpenGL ES 2.0 actions[VS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "0"; diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl index 08548ded17..afce403a9f 100644 --- a/drivers/gles2/shaders/canvas.glsl +++ b/drivers/gles2/shaders/canvas.glsl @@ -149,6 +149,8 @@ void main() { uv = uv_attrib; #endif + float point_size = 1.0; + { vec2 src_vtx = outvec.xy; /* clang-format off */ @@ -158,6 +160,8 @@ VERTEX_SHADER_CODE /* clang-format on */ } + gl_PointSize = point_size; + #if !defined(SKIP_TRANSFORM_USED) outvec = extra_matrix_instance * outvec; outvec = modelview_matrix * outvec; diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index 930d3cd9d4..63eee4eb87 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -423,6 +423,8 @@ void main() { #define projection_matrix local_projection_matrix #define world_transform world_matrix + float point_size = 1.0; + { /* clang-format off */ @@ -431,6 +433,7 @@ VERTEX_SHADER_CODE /* clang-format on */ } + gl_PointSize = point_size; vec4 outvec = vertex; // use local coordinates diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index c798dff839..1803a3dbbe 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -1887,9 +1887,20 @@ void RasterizerCanvasGLES3::canvas_light_shadow_buffer_update(RID p_buffer, cons } state.canvas_shadow_shader.set_uniform(CanvasShadowShaderGLES3::WORLD_MATRIX, instance->xform_cache); - if (cull != instance->cull_cache) { - cull = instance->cull_cache; + VS::CanvasOccluderPolygonCullMode transformed_cull_cache = instance->cull_cache; + + if (transformed_cull_cache != VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED && + (p_light_xform.basis_determinant() * instance->xform_cache.basis_determinant()) < 0) { + transformed_cull_cache = + transformed_cull_cache == VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE ? + VS::CANVAS_OCCLUDER_POLYGON_CULL_COUNTER_CLOCKWISE : + VS::CANVAS_OCCLUDER_POLYGON_CULL_CLOCKWISE; + } + + if (cull != transformed_cull_cache) { + + cull = transformed_cull_cache; switch (cull) { case VS::CANVAS_OCCLUDER_POLYGON_CULL_DISABLED: { diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 7499962da3..e78ecbae34 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -913,7 +913,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].renames["VERTEX"] = "outvec.xy"; actions[VS::SHADER_CANVAS_ITEM].renames["UV"] = "uv"; - actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "gl_PointSize"; + actions[VS::SHADER_CANVAS_ITEM].renames["POINT_SIZE"] = "point_size"; actions[VS::SHADER_CANVAS_ITEM].renames["WORLD_MATRIX"] = "modelview_matrix"; actions[VS::SHADER_CANVAS_ITEM].renames["PROJECTION_MATRIX"] = "projection_matrix"; @@ -970,7 +970,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].renames["UV"] = "uv_interp"; actions[VS::SHADER_SPATIAL].renames["UV2"] = "uv2_interp"; actions[VS::SHADER_SPATIAL].renames["COLOR"] = "color_interp"; - actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "gl_PointSize"; + actions[VS::SHADER_SPATIAL].renames["POINT_SIZE"] = "point_size"; actions[VS::SHADER_SPATIAL].renames["INSTANCE_ID"] = "gl_InstanceID"; //builtins diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 7255b0425c..53f84abf51 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -150,6 +150,7 @@ void main() { #define extra_matrix extra_matrix_instance + float point_size = 1.0; //for compatibility with the fragment shader we need to use uv here vec2 uv = uv_interp; { @@ -160,6 +161,7 @@ VERTEX_SHADER_CODE /* clang-format on */ } + gl_PointSize = point_size; uv_interp = uv; #ifdef USE_NINEPATCH diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index b4ceb7dcfd..549a36817e 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -432,6 +432,8 @@ void main() { } #endif + float point_size = 1.0; + highp mat4 modelview = camera_inverse_matrix * world_matrix; { /* clang-format off */ @@ -441,6 +443,8 @@ VERTEX_SHADER_CODE /* clang-format on */ } + gl_PointSize = point_size; + // using local coordinates (default) #if !defined(SKIP_TRANSFORM_USED) && !defined(VERTEX_WORLD_COORDS_USED) diff --git a/drivers/register_driver_types.cpp b/drivers/register_driver_types.cpp index 20556d98af..148f69872a 100644 --- a/drivers/register_driver_types.cpp +++ b/drivers/register_driver_types.cpp @@ -30,18 +30,9 @@ #include "register_driver_types.h" -#include "core/math/geometry.h" #include "drivers/png/image_loader_png.h" #include "drivers/png/resource_saver_png.h" -#ifdef TOOLS_ENABLED -#include "drivers/convex_decomp/b2d_decompose.h" -#endif - -#ifdef TOOLS_ENABLED -#include "platform/windows/export/export.h" -#endif - static ImageLoaderPNG *image_loader_png; static Ref<ResourceSaverPNG> resource_saver_png; @@ -64,10 +55,6 @@ void unregister_core_driver_types() { } void register_driver_types() { - -#ifdef TOOLS_ENABLED - Geometry::_decompose_func = b2d_decompose; -#endif } void unregister_driver_types() { |