summaryrefslogtreecommitdiff
path: root/thirdparty
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty')
-rw-r--r--thirdparty/enet/enet/godot.h4
-rw-r--r--thirdparty/enet/godot.cpp4
-rw-r--r--thirdparty/thekla_atlas/godot-changes.patch154
-rw-r--r--thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp36
-rw-r--r--thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h4
-rw-r--r--thirdparty/thekla_atlas/thekla/thekla_atlas.cpp23
6 files changed, 206 insertions, 19 deletions
diff --git a/thirdparty/enet/enet/godot.h b/thirdparty/enet/enet/godot.h
index 937c4fa60e..7e2be12b22 100644
--- a/thirdparty/enet/enet/godot.h
+++ b/thirdparty/enet/enet/godot.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 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 */
diff --git a/thirdparty/enet/godot.cpp b/thirdparty/enet/godot.cpp
index 2fc264345b..7813b70286 100644
--- a/thirdparty/enet/godot.cpp
+++ b/thirdparty/enet/godot.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2018 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 */
diff --git a/thirdparty/thekla_atlas/godot-changes.patch b/thirdparty/thekla_atlas/godot-changes.patch
new file mode 100644
index 0000000000..0e56403336
--- /dev/null
+++ b/thirdparty/thekla_atlas/godot-changes.patch
@@ -0,0 +1,154 @@
+diff --git a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
+index 5ce452c..11e635d 100644
+--- a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
++++ b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
+@@ -142,9 +142,11 @@ AtlasPacker::AtlasPacker(Atlas * atlas) : m_atlas(atlas), m_bitmap(256, 256)
+ {
+ m_width = 0;
+ m_height = 0;
+-
+- m_debug_bitmap.allocate(256, 256);
+- m_debug_bitmap.fill(Color32(0,0,0,0));
++
++ // -- GODOT start --
++ //m_debug_bitmap.allocate(256, 256);
++ //m_debug_bitmap.fill(Color32(0,0,0,0));
++ // -- GODOT end --
+ }
+
+ AtlasPacker::~AtlasPacker()
+@@ -465,7 +467,11 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
+ nvDebug("origin: %f %f\n", origin.x, origin.y);
+ nvDebug("majorAxis: %f %f\n", majorAxis.x, majorAxis.y);
+ nvDebug("minorAxis: %f %f\n", minorAxis.x, minorAxis.y);
+- nvDebugBreak();
++ // -- GODOT start --
++ //nvDebugBreak();
++ m_atlas->setFailed();
++ return;
++ // -- GODOT end --
+ }
+ //nvCheck(tmp.x >= 0 && tmp.y >= 0);
+
+@@ -597,8 +603,10 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
+ m_bitmap.clearAll();
+ if (approximateExtent > m_bitmap.width()) {
+ m_bitmap.resize(approximateExtent, approximateExtent, false);
+- m_debug_bitmap.resize(approximateExtent, approximateExtent);
+- m_debug_bitmap.fill(Color32(0,0,0,0));
++ // -- GODOT start --
++ //m_debug_bitmap.resize(approximateExtent, approximateExtent);
++ //m_debug_bitmap.fill(Color32(0,0,0,0));
++ // -- GODOT end --
+ }
+
+
+@@ -680,20 +688,24 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
+ {
+ //nvDebug("Resize bitmap (%d, %d).\n", nextPowerOfTwo(w), nextPowerOfTwo(h));
+ m_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h)), false);
+- m_debug_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h)));
++ // -- GODOT start --
++ //m_debug_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h)));
++ // -- GODOT end --
+ }
+
+ //nvDebug("Add chart at (%d, %d).\n", best_x, best_y);
+
+ addChart(&chart_bitmap, w, h, best_x, best_y, best_r, /*debugOutput=*/NULL);
+
++ // -- GODOT start --
+ // IC: Output chart again to debug bitmap.
+- if (chart->isVertexMapped()) {
++ /*if (chart->isVertexMapped()) {
+ addChart(&chart_bitmap, w, h, best_x, best_y, best_r, &m_debug_bitmap);
+ }
+ else {
+ addChart(chart, w, h, best_x, best_y, best_r, &m_debug_bitmap);
+- }
++ }*/
++ // -- GODOT end --
+
+ //float best_angle = 2 * PI * best_r;
+
+@@ -842,8 +854,10 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
+ nvCheck(isAligned(m_width, 4));
+ nvCheck(isAligned(m_height, 4));
+
+- m_debug_bitmap.resize(m_width, m_height);
+- m_debug_bitmap.setFormat(Image::Format_ARGB);
++ // -- GODOT start --
++ //m_debug_bitmap.resize(m_width, m_height);
++ //m_debug_bitmap.setFormat(Image::Format_ARGB);
++ // -- GODOT end --
+
+ #if DEBUG_OUTPUT
+ //outputDebugBitmap("debug_packer_final.tga", m_bitmap, w, h);
+diff --git a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h
+index 2d305f3..845dbfb 100644
+--- a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h
++++ b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h
+@@ -48,7 +48,9 @@ namespace nv
+
+ Atlas * m_atlas;
+ BitMap m_bitmap;
+- Image m_debug_bitmap;
++ // -- GODOT start --
++ //Image m_debug_bitmap;
++ // -- GODOT end --
+ RadixSort m_radix;
+
+ uint m_width;
+diff --git a/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp b/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp
+index d6f0acc..de1953d 100644
+--- a/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp
++++ b/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp
+@@ -2,6 +2,9 @@
+ #include "thekla_atlas.h"
+
+ #include <cfloat>
++// -- GODOT start --
++#include <stdio.h>
++// -- GODOT end --
+
+ #include "nvmesh/halfedge/Edge.h"
+ #include "nvmesh/halfedge/Mesh.h"
+@@ -112,6 +115,8 @@ static Atlas_Output_Mesh * mesh_atlas_to_output(const HalfEdge::Mesh * mesh, con
+ output->index_count = face_count * 3;
+ output->index_array = new int[face_count * 3];
+
++ // -- GODOT start --
++ int face_ofs = 0;
+ // Set face indices.
+ for (int f = 0; f < face_count; f++) {
+ uint c = charts->faceChartAt(f);
+@@ -121,14 +126,26 @@ static Atlas_Output_Mesh * mesh_atlas_to_output(const HalfEdge::Mesh * mesh, con
+ const Chart * chart = charts->chartAt(c);
+ nvDebugCheck(chart->faceAt(i) == f);
+
++ if (i >= chart->chartMesh()->faceCount()) {
++ printf("WARNING: Faces may be missing in the final vertex, which could not be packed\n");
++ continue;
++ }
++
+ const HalfEdge::Face * face = chart->chartMesh()->faceAt(i);
+ const HalfEdge::Edge * edge = face->edge;
+
+- output->index_array[3*f+0] = vertexOffset + edge->vertex->id;
+- output->index_array[3*f+1] = vertexOffset + edge->next->vertex->id;
+- output->index_array[3*f+2] = vertexOffset + edge->next->next->vertex->id;
++ //output->index_array[3*f+0] = vertexOffset + edge->vertex->id;
++ //output->index_array[3*f+1] = vertexOffset + edge->next->vertex->id;
++ //output->index_array[3*f+2] = vertexOffset + edge->next->next->vertex->id;
++ output->index_array[3 * face_ofs + 0] = vertexOffset + edge->vertex->id;
++ output->index_array[3 * face_ofs + 1] = vertexOffset + edge->next->vertex->id;
++ output->index_array[3 * face_ofs + 2] = vertexOffset + edge->next->next->vertex->id;
++ face_ofs++;
+ }
+
++ output->index_count = face_ofs * 3;
++ // -- GODOT end --
++
+ *error = Atlas_Error_Success;
+ output->atlas_width = w;
+ output->atlas_height = h;
diff --git a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
index 5ce452cb9e..11e635db17 100644
--- a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
+++ b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.cpp
@@ -142,9 +142,11 @@ AtlasPacker::AtlasPacker(Atlas * atlas) : m_atlas(atlas), m_bitmap(256, 256)
{
m_width = 0;
m_height = 0;
-
- m_debug_bitmap.allocate(256, 256);
- m_debug_bitmap.fill(Color32(0,0,0,0));
+
+ // -- GODOT start --
+ //m_debug_bitmap.allocate(256, 256);
+ //m_debug_bitmap.fill(Color32(0,0,0,0));
+ // -- GODOT end --
}
AtlasPacker::~AtlasPacker()
@@ -465,7 +467,11 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
nvDebug("origin: %f %f\n", origin.x, origin.y);
nvDebug("majorAxis: %f %f\n", majorAxis.x, majorAxis.y);
nvDebug("minorAxis: %f %f\n", minorAxis.x, minorAxis.y);
- nvDebugBreak();
+ // -- GODOT start --
+ //nvDebugBreak();
+ m_atlas->setFailed();
+ return;
+ // -- GODOT end --
}
//nvCheck(tmp.x >= 0 && tmp.y >= 0);
@@ -597,8 +603,10 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
m_bitmap.clearAll();
if (approximateExtent > m_bitmap.width()) {
m_bitmap.resize(approximateExtent, approximateExtent, false);
- m_debug_bitmap.resize(approximateExtent, approximateExtent);
- m_debug_bitmap.fill(Color32(0,0,0,0));
+ // -- GODOT start --
+ //m_debug_bitmap.resize(approximateExtent, approximateExtent);
+ //m_debug_bitmap.fill(Color32(0,0,0,0));
+ // -- GODOT end --
}
@@ -680,20 +688,24 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
{
//nvDebug("Resize bitmap (%d, %d).\n", nextPowerOfTwo(w), nextPowerOfTwo(h));
m_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h)), false);
- m_debug_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h)));
+ // -- GODOT start --
+ //m_debug_bitmap.resize(nextPowerOfTwo(U32(w)), nextPowerOfTwo(U32(h)));
+ // -- GODOT end --
}
//nvDebug("Add chart at (%d, %d).\n", best_x, best_y);
addChart(&chart_bitmap, w, h, best_x, best_y, best_r, /*debugOutput=*/NULL);
+ // -- GODOT start --
// IC: Output chart again to debug bitmap.
- if (chart->isVertexMapped()) {
+ /*if (chart->isVertexMapped()) {
addChart(&chart_bitmap, w, h, best_x, best_y, best_r, &m_debug_bitmap);
}
else {
addChart(chart, w, h, best_x, best_y, best_r, &m_debug_bitmap);
- }
+ }*/
+ // -- GODOT end --
//float best_angle = 2 * PI * best_r;
@@ -842,8 +854,10 @@ void AtlasPacker::packCharts(int quality, float texelsPerUnit, bool blockAligned
nvCheck(isAligned(m_width, 4));
nvCheck(isAligned(m_height, 4));
- m_debug_bitmap.resize(m_width, m_height);
- m_debug_bitmap.setFormat(Image::Format_ARGB);
+ // -- GODOT start --
+ //m_debug_bitmap.resize(m_width, m_height);
+ //m_debug_bitmap.setFormat(Image::Format_ARGB);
+ // -- GODOT end --
#if DEBUG_OUTPUT
//outputDebugBitmap("debug_packer_final.tga", m_bitmap, w, h);
diff --git a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h
index 2d305f38cd..845dbfb6f3 100644
--- a/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h
+++ b/thirdparty/thekla_atlas/nvmesh/param/AtlasPacker.h
@@ -48,7 +48,9 @@ namespace nv
Atlas * m_atlas;
BitMap m_bitmap;
- Image m_debug_bitmap;
+ // -- GODOT start --
+ //Image m_debug_bitmap;
+ // -- GODOT end --
RadixSort m_radix;
uint m_width;
diff --git a/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp b/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp
index d6f0accf54..de1953db8a 100644
--- a/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp
+++ b/thirdparty/thekla_atlas/thekla/thekla_atlas.cpp
@@ -2,6 +2,9 @@
#include "thekla_atlas.h"
#include <cfloat>
+// -- GODOT start --
+#include <stdio.h>
+// -- GODOT end --
#include "nvmesh/halfedge/Edge.h"
#include "nvmesh/halfedge/Mesh.h"
@@ -112,6 +115,8 @@ static Atlas_Output_Mesh * mesh_atlas_to_output(const HalfEdge::Mesh * mesh, con
output->index_count = face_count * 3;
output->index_array = new int[face_count * 3];
+ // -- GODOT start --
+ int face_ofs = 0;
// Set face indices.
for (int f = 0; f < face_count; f++) {
uint c = charts->faceChartAt(f);
@@ -121,14 +126,26 @@ static Atlas_Output_Mesh * mesh_atlas_to_output(const HalfEdge::Mesh * mesh, con
const Chart * chart = charts->chartAt(c);
nvDebugCheck(chart->faceAt(i) == f);
+ if (i >= chart->chartMesh()->faceCount()) {
+ printf("WARNING: Faces may be missing in the final vertex, which could not be packed\n");
+ continue;
+ }
+
const HalfEdge::Face * face = chart->chartMesh()->faceAt(i);
const HalfEdge::Edge * edge = face->edge;
- output->index_array[3*f+0] = vertexOffset + edge->vertex->id;
- output->index_array[3*f+1] = vertexOffset + edge->next->vertex->id;
- output->index_array[3*f+2] = vertexOffset + edge->next->next->vertex->id;
+ //output->index_array[3*f+0] = vertexOffset + edge->vertex->id;
+ //output->index_array[3*f+1] = vertexOffset + edge->next->vertex->id;
+ //output->index_array[3*f+2] = vertexOffset + edge->next->next->vertex->id;
+ output->index_array[3 * face_ofs + 0] = vertexOffset + edge->vertex->id;
+ output->index_array[3 * face_ofs + 1] = vertexOffset + edge->next->vertex->id;
+ output->index_array[3 * face_ofs + 2] = vertexOffset + edge->next->next->vertex->id;
+ face_ofs++;
}
+ output->index_count = face_ofs * 3;
+ // -- GODOT end --
+
*error = Atlas_Error_Success;
output->atlas_width = w;
output->atlas_height = h;