Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gwaldron/osgearth
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Apr 2, 2024
2 parents 80c1a42 + 74d0bf9 commit 8d661f5
Show file tree
Hide file tree
Showing 11 changed files with 797 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ find_package(WEBP)
find_package(Blend2D)
find_package(Blosc)
find_package(spdlog)
find_package(meshoptimizer)

# Configure OSGEARTH_HAVE_XXX variables for the BuildConfig
IF(Protobuf_FOUND AND Protobuf_PROTOC_EXECUTABLE)
Expand All @@ -160,6 +161,10 @@ if(draco_FOUND)
set(OSGEARTH_HAVE_DRACO ON)
endif(draco_FOUND)

if (meshoptimizer_FOUND)
set(OSGEARTH_HAVE_MESH_OPTIMIZER ON)
endif()

if(OSGEARTH_BUILD_CESIUM_NODEKIT)
find_package(CesiumNative)
endif()
Expand Down
1 change: 1 addition & 0 deletions src/osgEarth/BuildConfig.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
#cmakedefine OSGEARTH_HAVE_DRACO
#cmakedefine OSGEARTH_HAVE_GEOCODER
#cmakedefine OSGEARTH_HAVE_BLEND2D
#cmakedefine OSGEARTH_HAVE_MESH_OPTIMIZER

#endif // OSGEARTH_BUILDCONFIG_H
8 changes: 8 additions & 0 deletions src/osgEarth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ IF(WIN32)
LIST(APPEND TARGET_EXTERNAL_LIBRARIES psapi)
ENDIF(WIN32)


LIST(APPEND TARGET_EXTERNAL_LIBRARIES meshoptimizer::meshoptimizer)


# Generate the Version header.
# set(OSGEARTH_SOVERSION_VALUE "${OSGEARTH_SOVERSION}")
set(OSGEARTH_VERSION_HEADER "${OSGEARTH_BUILDTIME_INCLUDE_DIR}/osgEarth/Version")
Expand Down Expand Up @@ -86,6 +90,7 @@ set(TARGET_GLSL
set(SHADERS_CPP "${CMAKE_CURRENT_BINARY_DIR}/AutoGenShaders.cpp")

set(TARGET_IN
BuildConfig.in
Version.in
Shaders.cpp.in)

Expand Down Expand Up @@ -144,6 +149,7 @@ SET(LIB_PUBLIC_HEADERS
ColorFilter
Common
Composite
CompressedArray
CompositeTiledModelLayer
Config
Containers
Expand Down Expand Up @@ -449,6 +455,7 @@ SET(LIB_PUBLIC_HEADERS
weemesh.h
weejobs.h

${OSGEARTH_BUILDCONFIG_HEADER}
${OSGEARTH_VERSION_HEADER}
)

Expand Down Expand Up @@ -568,6 +575,7 @@ set(TARGET_SRC
Composite.cpp
CompositeTiledModelLayer.cpp
Compressors.cpp
CompressedArray.cpp
Config.cpp
ContourMap.cpp
Controls.cpp
Expand Down
107 changes: 107 additions & 0 deletions src/osgEarth/CompressedArray
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#ifndef OSGEARTHUTIL_COMPRESSED_ARRAY_H
#define OSGEARTHUTIL_COMPRESSED_ARRAY_H

#include <osgEarth/Common>

#ifdef OSGEARTH_HAVE_MESH_OPTIMIZER

#include <osg/Array>
#include <osg/PrimitiveSet>

namespace osgEarth
{
using namespace osgEarth;

class OSGEARTH_EXPORT CompressedVec3Array : public osg::Vec3Array
{
public:
enum QuantizationType
{
QUANTIZE_NONE,
QUANTIZE_VERTEX,
QUANTIZE_NORMAL,
QUANTIZE_HALF
};

CompressedVec3Array();

CompressedVec3Array(osg::Vec3Array& va, QuantizationType quantization = CompressedVec3Array::QUANTIZE_NONE);

CompressedVec3Array(const CompressedVec3Array& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);

META_Object(osgEarth, CompressedVec3Array);

QuantizationType getQuantization() const { return _quantization; }
void setQuantization(QuantizationType quantization) { _quantization = quantization; }

private:
QuantizationType _quantization = QUANTIZE_NONE;
};

class OSGEARTH_EXPORT CompressedVec2Array : public osg::Vec2Array
{
public:
CompressedVec2Array();

CompressedVec2Array(osg::Vec2Array& va);

CompressedVec2Array(const CompressedVec2Array& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);

META_Object(osgEarth, CompressedVec2Array);
};

class OSGEARTH_EXPORT CompressedDrawElementsUShort : public osg::DrawElementsUShort
{
public:
CompressedDrawElementsUShort();

CompressedDrawElementsUShort(osg::DrawElementsUShort& de);

CompressedDrawElementsUShort(const CompressedDrawElementsUShort& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);

META_Object(osgEarth, CompressedDrawElementsUShort);
};

class OSGEARTH_EXPORT CompressedDrawElementsUByte : public osg::DrawElementsUByte
{
public:
CompressedDrawElementsUByte();

CompressedDrawElementsUByte(osg::DrawElementsUByte& de);

CompressedDrawElementsUByte(const CompressedDrawElementsUByte& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);

META_Object(osgEarth, CompressedDrawElementsUByte);
};

class OSGEARTH_EXPORT CompressedDrawElementsUInt : public osg::DrawElementsUInt
{
public:
CompressedDrawElementsUInt();

CompressedDrawElementsUInt(osg::DrawElementsUInt& de);

CompressedDrawElementsUInt(const CompressedDrawElementsUInt& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);

META_Object(osgEarth, CompressedDrawElementsUInt);
};

class OSGEARTH_EXPORT CompressedUIntArray : public osg::UIntArray
{
public:
CompressedUIntArray();

CompressedUIntArray(osg::UIntArray& array);

CompressedUIntArray(const CompressedUIntArray& rhs, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);

META_Object(osgEarth, CompressedUIntArray);
};


}
#else
#pragma message("Warning: MeshOptimizer not available. CompressedArray classes will not be available.")
#endif

#endif

0 comments on commit 8d661f5

Please sign in to comment.