From 8bb68b3c5535e620463a482fc4f7463afced02bc Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Wed, 5 Dec 2018 16:26:00 -0800 Subject: [PATCH] Rename MeshIO class to MeshReader. This makes the name symmetrical with MeshWriter. --- libs/filameshio/CMakeLists.txt | 6 ++-- .../filameshio/{MeshIO.h => MeshReader.h} | 8 ++--- .../src/{MeshIO.cpp => MeshReader.cpp} | 8 ++--- libs/filameshio/tests/test_filamesh.cpp | 6 ++-- samples/sample_cloth.cpp | 6 ++-- samples/sample_normal_map.cpp | 6 ++-- samples/vk_hellopbr.cpp | 6 ++-- web/filament-js/jsbindings.cpp | 36 +++++++++---------- web/filament-js/utilities.js | 4 +-- 9 files changed, 43 insertions(+), 43 deletions(-) rename libs/filameshio/include/filameshio/{MeshIO.h => MeshReader.h} (94%) rename libs/filameshio/src/{MeshIO.cpp => MeshReader.cpp} (97%) diff --git a/libs/filameshio/CMakeLists.txt b/libs/filameshio/CMakeLists.txt index e3a54cca07..ce8b5f5817 100644 --- a/libs/filameshio/CMakeLists.txt +++ b/libs/filameshio/CMakeLists.txt @@ -9,11 +9,11 @@ set(PUBLIC_HDR_DIR include) # ================================================================================================== set(PUBLIC_HDRS ${PUBLIC_HDR_DIR}/${TARGET}/filamesh.h - ${PUBLIC_HDR_DIR}/${TARGET}/MeshIO.h + ${PUBLIC_HDR_DIR}/${TARGET}/MeshReader.h ) -set(DIST_HDRS ${PUBLIC_HDR_DIR}/${TARGET}/MeshIO.h) -set(SRCS src/MeshIO.cpp) +set(DIST_HDRS ${PUBLIC_HDR_DIR}/${TARGET}/MeshReader.h) +set(SRCS src/MeshReader.cpp) # ================================================================================================== # Includes and target definition diff --git a/libs/filameshio/include/filameshio/MeshIO.h b/libs/filameshio/include/filameshio/MeshReader.h similarity index 94% rename from libs/filameshio/include/filameshio/MeshIO.h rename to libs/filameshio/include/filameshio/MeshReader.h index 1b4e24b3a1..24dfef2272 100644 --- a/libs/filameshio/include/filameshio/MeshIO.h +++ b/libs/filameshio/include/filameshio/MeshReader.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef TNT_FILAMENT_FILAMESHIO_MESHIO_H -#define TNT_FILAMENT_FILAMESHIO_MESHIO_H +#ifndef TNT_FILAMENT_FILAMESHIO_MESHREADER_H +#define TNT_FILAMENT_FILAMESHIO_MESHREADER_H #include #include @@ -35,7 +35,7 @@ namespace filament { * by the command line tool of the same name. This file format is documented in * "docs/filamesh.md" in the Filament distribution. */ -class MeshIO { +class MeshReader { public: using Callback = void(*)(void* buffer, size_t size, void* user); using MaterialRegistry = std::map; @@ -78,4 +78,4 @@ public: filament::MaterialInstance* defaultMaterial); }; -#endif // TNT_FILAMENT_FILAMESHIO_MESHIO_H +#endif // TNT_FILAMENT_FILAMESHIO_MESHREADER_H diff --git a/libs/filameshio/src/MeshIO.cpp b/libs/filameshio/src/MeshReader.cpp similarity index 97% rename from libs/filameshio/src/MeshIO.cpp rename to libs/filameshio/src/MeshReader.cpp index fe9ff92b38..d6e8ee723f 100644 --- a/libs/filameshio/src/MeshIO.cpp +++ b/libs/filameshio/src/MeshReader.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include #include @@ -53,7 +53,7 @@ static size_t fileSize(int fd) { return filesize; } -MeshIO::Mesh MeshIO::loadMeshFromFile(filament::Engine* engine, const utils::Path& path, +MeshReader::Mesh MeshReader::loadMeshFromFile(filament::Engine* engine, const utils::Path& path, const MaterialRegistry& materials) { Mesh mesh; @@ -81,7 +81,7 @@ MeshIO::Mesh MeshIO::loadMeshFromFile(filament::Engine* engine, const utils::Pat return mesh; } -MeshIO::Mesh MeshIO::loadMeshFromBuffer(filament::Engine* engine, +MeshReader::Mesh MeshReader::loadMeshFromBuffer(filament::Engine* engine, void const* data, Callback destructor, void* user, MaterialInstance* defaultMaterial) { MaterialRegistry reg; @@ -89,7 +89,7 @@ MeshIO::Mesh MeshIO::loadMeshFromBuffer(filament::Engine* engine, return loadMeshFromBuffer(engine, data, destructor, user, reg); } -MeshIO::Mesh MeshIO::loadMeshFromBuffer(filament::Engine* engine, +MeshReader::Mesh MeshReader::loadMeshFromBuffer(filament::Engine* engine, void const* data, Callback destructor, void* user, const MaterialRegistry& materials) { const uint8_t* p = (const uint8_t*) data; diff --git a/libs/filameshio/tests/test_filamesh.cpp b/libs/filameshio/tests/test_filamesh.cpp index 705cacdd86..7c1a17cdb9 100644 --- a/libs/filameshio/tests/test_filamesh.cpp +++ b/libs/filameshio/tests/test_filamesh.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include @@ -157,7 +157,7 @@ TEST_F(FilameshTest, NonInterleaved) { // Deserialize the mesh as a smoke test. MaterialInstance* mi = engine->getDefaultMaterial()->createInstance(); - auto mesh = MeshIO::loadMeshFromBuffer(engine, stream.str().data(), nullptr, nullptr, mi); + auto mesh = MeshReader::loadMeshFromBuffer(engine, stream.str().data(), nullptr, nullptr, mi); auto& rm = engine->getRenderableManager(); auto inst = rm.getInstance(mesh.renderable); EXPECT_EQ(rm.getPrimitiveCount(inst), 1); @@ -206,7 +206,7 @@ TEST_F(FilameshTest, Interleaved) { // Deserialize the mesh as a smoke test. MaterialInstance* mi = engine->getDefaultMaterial()->createInstance(); - auto mesh = MeshIO::loadMeshFromBuffer(engine, stream.str().data(), nullptr, nullptr, mi); + auto mesh = MeshReader::loadMeshFromBuffer(engine, stream.str().data(), nullptr, nullptr, mi); auto& rm = engine->getRenderableManager(); auto inst = rm.getInstance(mesh.renderable); EXPECT_EQ(rm.getPrimitiveCount(inst), 1); diff --git a/samples/sample_cloth.cpp b/samples/sample_cloth.cpp index 09e2f7afe7..bede597480 100644 --- a/samples/sample_cloth.cpp +++ b/samples/sample_cloth.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include using namespace math; using namespace filament; @@ -53,7 +53,7 @@ using namespace utils; static std::vector g_filenames; static std::map g_materialInstances; -static std::vector g_meshes; +static std::vector g_meshes; static const Material* g_material; static Entity g_light; static std::map g_maps; @@ -216,7 +216,7 @@ static void setup(Engine* engine, View* view, Scene* scene) { auto& tcm = engine->getTransformManager(); for (const auto& filename : g_filenames) { - MeshIO::Mesh mesh = MeshIO::loadMeshFromFile(engine, filename, g_materialInstances); + MeshReader::Mesh mesh = MeshReader::loadMeshFromFile(engine, filename, g_materialInstances); if (mesh.renderable) { auto ei = tcm.getInstance(mesh.renderable); tcm.setTransform(ei, mat4f{ mat3f(g_config.scale), float3(0.0f, 0.0f, -4.0f) } * diff --git a/samples/sample_normal_map.cpp b/samples/sample_normal_map.cpp index ce48ab9b33..3a2b2bed79 100644 --- a/samples/sample_normal_map.cpp +++ b/samples/sample_normal_map.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include using namespace math; using namespace filament; @@ -52,7 +52,7 @@ using namespace utils; static std::vector g_filenames; static std::map g_materialInstances; -static std::vector g_meshes; +static std::vector g_meshes; static const Material* g_material; static Entity g_light; static Texture* g_normalMap = nullptr; @@ -306,7 +306,7 @@ static void setup(Engine* engine, View*, Scene* scene) { auto& tcm = engine->getTransformManager(); for (const auto& filename : g_filenames) { - MeshIO::Mesh mesh = MeshIO::loadMeshFromFile(engine, filename, g_materialInstances); + MeshReader::Mesh mesh = MeshReader::loadMeshFromFile(engine, filename, g_materialInstances); if (mesh.renderable) { auto ei = tcm.getInstance(mesh.renderable); tcm.setTransform(ei, mat4f{ mat3f(g_config.scale), float3(0.0f, 0.0f, -4.0f) } * diff --git a/samples/vk_hellopbr.cpp b/samples/vk_hellopbr.cpp index 09ffd4c229..b0097e9bed 100644 --- a/samples/vk_hellopbr.cpp +++ b/samples/vk_hellopbr.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include "app/Config.h" #include "app/FilamentApp.h" @@ -36,7 +36,7 @@ struct App { utils::Entity light; Material* material; MaterialInstance* materialInstance; - MeshIO::Mesh mesh; + MeshReader::Mesh mesh; mat4f transform; }; @@ -64,7 +64,7 @@ int main(int argc, char** argv) { mi->setParameter("reflectance", 0.5f); // Add geometry into the scene. - app.mesh = MeshIO::loadMeshFromBuffer(engine, RESOURCES_SUZANNE_DATA, nullptr, nullptr, mi); + app.mesh = MeshReader::loadMeshFromBuffer(engine, RESOURCES_SUZANNE_DATA, nullptr, nullptr, mi); auto ti = tcm.getInstance(app.mesh.renderable); app.transform = mat4f{ mat3f(1), float3(0, 0, -4) } * tcm.getWorldTransform(ti); rcm.setCastShadows(rcm.getInstance(app.mesh.renderable), false); diff --git a/web/filament-js/jsbindings.cpp b/web/filament-js/jsbindings.cpp index 101bed8357..a0d9370e4e 100644 --- a/web/filament-js/jsbindings.cpp +++ b/web/filament-js/jsbindings.cpp @@ -32,7 +32,7 @@ * this explicit rather than mysterious. */ -#include +#include #include #include @@ -873,12 +873,12 @@ class_("KtxInfo") register_vector("RegistryKeys"); -class_("MeshIO$MaterialRegistry") +class_("MeshReader$MaterialRegistry") .constructor<>() - .function("size", &MeshIO::MaterialRegistry::size) - .function("get", internal::MapAccess::get) - .function("set", internal::MapAccess::set) - .function("keys", EMBIND_LAMBDA(std::vector, (MeshIO::MaterialRegistry* self), { + .function("size", &MeshReader::MaterialRegistry::size) + .function("get", internal::MapAccess::get) + .function("set", internal::MapAccess::set) + .function("keys", EMBIND_LAMBDA(std::vector, (MeshReader::MaterialRegistry* self), { std::vector result; for (const auto& pair : *self) { result.emplace_back(pair.first); @@ -886,17 +886,17 @@ class_("MeshIO$MaterialRegistry") return result; }), allow_raw_pointers()); -// MeshIO ::class:: Simple parser for filamesh files. +// MeshReader ::class:: Simple parser for filamesh files. // JavaScript clients are encouraged to use the [loadFilamesh] helper function instead of using // this class directly. -class_("MeshIO") +class_("MeshReader") // loadMeshFromBuffer ::static method:: Parses a filamesh buffer. // engine ::argument:: [Engine] // buffer ::argument:: [Buffer] - // materials ::argument:: [MeshIO$MaterialRegistry] - // ::retval:: the [MeshIO$Mesh] object - .class_function("loadMeshFromBuffer", EMBIND_LAMBDA(MeshIO::Mesh, - (Engine* engine, BufferDescriptor buffer, const MeshIO::MaterialRegistry& matreg), { + // materials ::argument:: [MeshReader$MaterialRegistry] + // ::retval:: the [MeshReader$Mesh] object + .class_function("loadMeshFromBuffer", EMBIND_LAMBDA(MeshReader::Mesh, + (Engine* engine, BufferDescriptor buffer, const MeshReader::MaterialRegistry& matreg), { // This destruction lambda is called for the vertex buffer AND index buffer, so release // CPU memory only after both have been uploaded to the GPU. struct Bundle { int count; BufferDescriptor buffer; }; @@ -908,23 +908,23 @@ class_("MeshIO") } }; // Parse the filamesh buffer. This creates the VB, IB, and renderable. - return MeshIO::loadMeshFromBuffer( + return MeshReader::loadMeshFromBuffer( engine, buffer.bd->buffer, destructor, bundle, matreg); }), allow_raw_pointers()); -// MeshIO$Mesh ::class:: Property accessor for objects created by [MeshIO]. +// MeshReader$Mesh ::class:: Property accessor for objects created by [MeshReader]. // This exposes three getter methods: `renderable()`, `vertexBuffer()`, and `indexBuffer()`. These // are of type [Entity], [VertexBuffer], and [IndexBuffer]. JavaScript clients are encouraged to // use the [loadFilamesh] helper function instead of using this class directly. -class_("MeshIO$Mesh") - .function("renderable", EMBIND_LAMBDA(utils::Entity, (MeshIO::Mesh mesh), { +class_("MeshReader$Mesh") + .function("renderable", EMBIND_LAMBDA(utils::Entity, (MeshReader::Mesh mesh), { return mesh.renderable; }), allow_raw_pointers()) - .function("vertexBuffer", EMBIND_LAMBDA(VertexBuffer*, (MeshIO::Mesh mesh), { + .function("vertexBuffer", EMBIND_LAMBDA(VertexBuffer*, (MeshReader::Mesh mesh), { return mesh.vertexBuffer; }), allow_raw_pointers()) - .function("indexBuffer", EMBIND_LAMBDA(IndexBuffer*, (MeshIO::Mesh mesh), { + .function("indexBuffer", EMBIND_LAMBDA(IndexBuffer*, (MeshReader::Mesh mesh), { return mesh.indexBuffer; }), allow_raw_pointers()); diff --git a/web/filament-js/utilities.js b/web/filament-js/utilities.js index 23618a5e43..9b5b7454a9 100644 --- a/web/filament-js/utilities.js +++ b/web/filament-js/utilities.js @@ -81,14 +81,14 @@ Filament.CompressedPixelBuffer = function(typedarray, cdatatype, faceSize) { Filament._loadFilamesh = function(engine, buffer, definstance, matinstances) { matinstances = matinstances || {}; - const registry = new Filament.MeshIO$MaterialRegistry(); + const registry = new Filament.MeshReader$MaterialRegistry(); for (var key in matinstances) { registry.set(key, matinstances[key]); } if (definstance) { registry.set("DefaultMaterial", definstance); } - const mesh = Filament.MeshIO.loadMeshFromBuffer(engine, buffer, registry); + const mesh = Filament.MeshReader.loadMeshFromBuffer(engine, buffer, registry); const keys = registry.keys(); for (var i = 0; i < keys.size(); i++) { const key = keys.get(i);