Skip to content

Commit

Permalink
Merge pull request #209 from Esri/develop
Browse files Browse the repository at this point in the history
Release 2.0.0-beta.2
  • Loading branch information
mistafunk authored Mar 28, 2023
2 parents 67d0804 + ecb3b56 commit d4bfdec
Show file tree
Hide file tree
Showing 27 changed files with 933 additions and 415 deletions.
401 changes: 245 additions & 156 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions conan/cesdk/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class CESDKConan(ConanFile):
name = "cesdk"
settings = "os", "compiler", "arch"
description = "Develop 3D applications using the procedural geometry engine of Esri CityEngine."
url = "https://github.com/Esri/esri-cityengine-sdk"
url = "https://github.com/Esri/cityengine-sdk"
license = "CityEngine EULA"
baseURL = "https://github.com/esri/esri-cityengine-sdk/releases/download/{}/esri_ce_sdk-{}-{}-{}-x86_64-rel-opt.zip"
baseURL = "https://github.com/esri/cityengine-sdk/releases/download/{}/esri_ce_sdk-{}-{}-{}-x86_64-rel-opt.zip"

def build(self):
if self.settings.os == "Windows":
Expand Down
602 changes: 509 additions & 93 deletions conan/conan-0.15.cmake → conan/conan-0.18.1.cmake

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(HOUDINI_RELATIVE_PALLADIO_PATH "${HOUDINI_RELATIVE_PACKAGES_PATH}/palladio")
set(PLD_VERSION_MAJOR 2)
set(PLD_VERSION_MINOR 0)
set(PLD_VERSION_PATCH 0)
set(PLD_VERSION_PRE "-beta.1") # set to empty string for final releases
set(PLD_VERSION_PRE "-beta.2") # set to empty string for final releases
if (NOT PLD_VERSION_BUILD)
set(PLD_VERSION_BUILD DEV)
endif ()
Expand Down Expand Up @@ -54,5 +54,10 @@ pld_setup_packaging()
### setup test target

enable_testing()
add_subdirectory(test EXCLUDE_FROM_ALL)
if (PLD_GEN_VISUAL_STUDIO)
add_subdirectory(test)
else()
add_subdirectory(test EXCLUDE_FROM_ALL)
endif()

add_dependencies(${TGT_TEST} ${TGT_CODEC})
28 changes: 26 additions & 2 deletions src/cmake/common.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
cmake_minimum_required(VERSION 3.13)


### generator detection

if (CMAKE_GENERATOR MATCHES "Visual Studio")
set(PLD_GEN_VISUAL_STUDIO 1)
endif()


### platform configuration

if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
Expand All @@ -23,13 +30,30 @@ function(pld_set_common_compiler_flags TGT)
if (PLD_WINDOWS)
target_compile_definitions(${TGT} PRIVATE -DPLD_WINDOWS=1 -DPLD_TC_VC=1)

string(FIND ${CMAKE_GENERATOR} "Visual Studio" DETECTED_VISUAL_STUDIO)
if(${DETECTED_VISUAL_STUDIO} GREATER -1)
if (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
target_compile_options(${TGT} PRIVATE -Od -Zi)
endif()

if(PLD_GEN_VISUAL_STUDIO)
target_compile_options(${TGT} PRIVATE -MP) # enable parallel building in Visual Studio generators
endif()

elseif (PLD_LINUX)
target_compile_definitions(${TGT} PRIVATE -DPLD_LINUX=1 -DPLD_TC_GCC=1)

if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
target_compile_options(${TGT} PRIVATE -O3 -flto)
target_compile_definitions(${TGT} PRIVATE -DNDEBUG)
elseif (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
target_compile_options(${TGT} PRIVATE -O0 -ggdb -pg)
target_compile_definitions(${TGT} PRIVATE -DNDEBUG)
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options(${TGT} PRIVATE -O0 -ggdb -pg)
target_compile_definitions(${TGT} PRIVATE -DDEBUG)
endif ()

target_compile_options(${TGT} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)

endif ()
endfunction()

Expand Down
13 changes: 6 additions & 7 deletions src/cmake/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### setup conan

set(PLD_CONAN_TOOLS "${CMAKE_SOURCE_DIR}/../conan")
include(${PLD_CONAN_TOOLS}/conan-0.15.cmake)
include(${PLD_CONAN_TOOLS}/conan-0.18.1.cmake)
conan_check(VERSION 1.20 REQUIRED)


Expand Down Expand Up @@ -30,11 +30,6 @@ elseif (${PLD_HDN_VER_MAJ} STREQUAL "18" AND ${PLD_HDN_VER_MIN} STREQUAL "5")
message(STATUS "Asking Conan for Houdini 18.5...")
set(PLD_CONANFILE "conanfile-h185.py")

# Houdini 18.0
elseif (${PLD_HDN_VER_MAJ} STREQUAL "18" AND ${PLD_HDN_VER_MIN} STREQUAL "0")
message(STATUS "Asking Conan for Houdini 18.0...")
set(PLD_CONANFILE "conanfile-h180.py")

endif()


Expand All @@ -54,6 +49,10 @@ elseif(PLD_LINUX)
set(PLD_CONAN_PROFILE "${PLD_CONAN_TOOLS}/profiles/linux-gcc93")
endif()

if (PLD_GEN_VISUAL_STUDIO AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo") # workaround for using conan with the Visual Studio multi-generator
endif()

conan_cmake_run(CONANFILE ${PLD_CONANFILE} PROFILE ${PLD_CONAN_PROFILE} BASIC_SETUP NO_OUTPUT_DIRS CMAKE_TARGETS ENV ${PLD_CONAN_ENV})


Expand All @@ -76,7 +75,7 @@ install(FILES ${PLD_PRT_LIBRARIES} DESTINATION ${HOUDINI_RELATIVE_PALLADIO_PATH}

# allow-list required PRT extension libraries
set(PLD_PRT_EXT_LIBRARIES ${PRT_EXT_LIBRARIES})
list(FILTER PLD_PRT_EXT_LIBRARIES INCLUDE REGEX "com\\.esri\\.prt\\.(codecs|oda|usd|adaptors)|libcrypto|tbb|usd_ms|VueExport")
list(FILTER PLD_PRT_EXT_LIBRARIES INCLUDE REGEX "com\\.esri\\.prt\\.(codecs|oda|usd|adaptors)|libcrypto|tbb|usd_ms")
install(FILES ${PLD_PRT_EXT_LIBRARIES} DESTINATION "${HOUDINI_RELATIVE_PALLADIO_PATH}/${PRT_RELATIVE_EXTENSION_PATH}")

# the USD codecs need resource files
Expand Down
14 changes: 0 additions & 14 deletions src/codec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,6 @@ add_library(${TGT_CODEC} SHARED
pld_set_common_compiler_flags(${TGT_CODEC})
pld_set_prtx_compiler_flags(${TGT_CODEC})

if (PLD_LINUX)
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
target_compile_options(${TGT_CODEC} PRIVATE -O3 -flto)
target_compile_definitions(${TGT_CODEC} PRIVATE -DNDEBUG)
elseif (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
target_compile_options(${TGT_CODEC} PRIVATE -O3 -ggdb -pg)
target_compile_definitions(${TGT_CODEC} PRIVATE -DNDEBUG)
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options(${TGT_CODEC} PRIVATE -O0 -ggdb -pg)
target_compile_definitions(${TGT_CODEC} PRIVATE -DDEBUG)
endif ()

endif ()


### dependencies

Expand Down
9 changes: 6 additions & 3 deletions src/codec/encoder/HoudiniCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ class HoudiniCallbacks : public prt::Callbacks {
* @param nrmSize length of vertex normal array
* @param counts polygon count array
* @param countsSize length of polygon count array
* @param indices vertex attribute index array (grouped by counts)
* @param indicesSize vertex attribute index array
* @param vertexIndices vertex attribute index array (grouped by counts)
* @param vertexIndicesSize vertex attribute index array
* @param normalIndices vertex normal attribute index array (grouped by counts)
* @param normalIndicesSize vertex normal attribute index array
* @param uvs array of texture coordinate arrays (same indexing as vertices per uv set)
* @param uvsSizes lengths of uv arrays per uv set
* @param uvCounts uv index count per face per uv set (values are either 0 or same as vertex count for each face)
Expand All @@ -51,7 +53,8 @@ class HoudiniCallbacks : public prt::Callbacks {
* @param shapeIDs shape ids per face, contains faceRangesSize-1 values
*/
virtual void add(const wchar_t* name, const double* vtx, size_t vtxSize, const double* nrm, size_t nrmSize,
const uint32_t* counts, size_t countsSize, const uint32_t* indices, size_t indicesSize,
const uint32_t* counts, size_t countsSize, const uint32_t* vertexIndices, size_t vertexIndicesSize,
const uint32_t* normalIndices, size_t normalIndicesSize,

double const* const* uvs, size_t const* uvsSizes, uint32_t const* const* uvCounts,
size_t const* uvCountsSizes, uint32_t const* const* uvIndices, size_t const* uvIndicesSizes,
Expand Down
22 changes: 16 additions & 6 deletions src/codec/encoder/HoudiniEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ constexpr const wchar_t* ENC_DESCRIPTION = L"Encodes geometry into the Houdini f
const prtx::EncodePreparator::PreparationFlags PREP_FLAGS =
prtx::EncodePreparator::PreparationFlags()
.instancing(false)
.mergeByMaterial(false)
.meshMerging(prtx::MeshMerging::NONE)
.triangulate(false)
.processHoles(prtx::HoleProcessor::TRIANGULATE_FACES_WITH_HOLES)
.mergeVertices(true)
.cleanupVertexNormals(true)
.cleanupUVs(true)
.processVertexNormals(prtx::VertexNormalProcessor::SET_MISSING_TO_FACE_NORMALS)
.indexSharing(prtx::EncodePreparator::PreparationFlags::INDICES_SAME_FOR_ALL_VERTEX_ATTRIBUTES);
.indexSharing(prtx::EncodePreparator::PreparationFlags::INDICES_SEPARATE_FOR_ALL_VERTEX_ATTRIBUTES);

std::vector<const wchar_t*> toPtrVec(const prtx::WStringVector& wsv) {
std::vector<const wchar_t*> pw(wsv.size());
Expand Down Expand Up @@ -423,6 +423,7 @@ SerializedGeometry serializeGeometry(const prtx::GeometryPtrVector& geometries,

// PASS 2: copy
uint32_t vertexIndexBase = 0;
uint32_t normalIndexBase = 0;
std::vector<uint32_t> uvIndexBases(maxNumUVSets, 0u);
for (const auto& geo : geometries) {
const prtx::MeshPtrVector& meshes = geo->getMeshes();
Expand Down Expand Up @@ -480,14 +481,22 @@ SerializedGeometry serializeGeometry(const prtx::GeometryPtrVector& geometries,

// append counts and indices for vertices and vertex normals
for (uint32_t fi = 0, faceCount = mesh->getFaceCount(); fi < faceCount; ++fi) {
const uint32_t* vtxIdx = mesh->getFaceVertexIndices(fi);
const uint32_t vtxCnt = mesh->getFaceVertexCount(fi);

const uint32_t* vtxIdx = mesh->getFaceVertexIndices(fi);
const uint32_t* nrmIdx = mesh->getFaceVertexNormalIndices(fi);
const size_t nrmCnt = mesh->getFaceVertexNormalCount(fi);
sg.counts.push_back(vtxCnt);
for (uint32_t vi = 0; vi < vtxCnt; vi++)
sg.indices.push_back(vertexIndexBase + vtxIdx[vtxCnt - vi - 1]); // reverse winding
for (uint32_t vi = 0; vi < vtxCnt; vi++) {
uint32_t viReversed = vtxCnt - vi - 1; // reverse winding
sg.vertexIndices.push_back(vertexIndexBase + vtxIdx[viReversed]);
if (nrmCnt > viReversed && nrmIdx != nullptr)
sg.normalIndices.push_back(normalIndexBase + nrmIdx[viReversed]);
}
}

vertexIndexBase += (uint32_t)verts.size() / 3u;
normalIndexBase += (uint32_t)norms.size() / 3u;
} // for all meshes
} // for all geometries

Expand Down Expand Up @@ -623,7 +632,8 @@ void HoudiniEncoder::convertGeometry(const prtx::InitialShape& initialShape,
assert(sg.uvs.size() == puvCounts.second.size());

cb->add(initialShape.getName(), sg.coords.data(), sg.coords.size(), sg.normals.data(), sg.normals.size(),
sg.counts.data(), sg.counts.size(), sg.indices.data(), sg.indices.size(),
sg.counts.data(), sg.counts.size(), sg.vertexIndices.data(), sg.vertexIndices.size(),
sg.normalIndices.data(), sg.normalIndices.size(),

puvs.first.data(), puvs.second.data(), puvCounts.first.data(), puvCounts.second.data(),
puvIndices.first.data(), puvIndices.second.data(), static_cast<uint32_t>(sg.uvs.size()),
Expand Down
8 changes: 5 additions & 3 deletions src/codec/encoder/HoudiniEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ namespace detail {

struct SerializedGeometry {
prtx::DoubleVector coords;
prtx::DoubleVector normals; // uses same indexing as coords
prtx::DoubleVector normals;
std::vector<uint32_t> counts;
std::vector<uint32_t> indices;
std::vector<uint32_t> vertexIndices;
std::vector<uint32_t> normalIndices;

std::vector<prtx::DoubleVector> uvs;
std::vector<prtx::IndexVector> uvCounts;
Expand All @@ -54,7 +55,8 @@ struct SerializedGeometry {
coords.reserve(3 * numCoords);
normals.reserve(3 * numNormalCoords);
counts.reserve(numCounts);
indices.reserve(numIndices);
vertexIndices.reserve(numIndices);
normalIndices.reserve(numIndices);
}
};

Expand Down
22 changes: 0 additions & 22 deletions src/conanfile-h180.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/conanfile-h185.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def requirements(self):
if "PLD_CONAN_CESDK_VERSION" in os.environ:
cesdk_version = os.environ["PLD_CONAN_CESDK_VERSION"]
else:
cesdk_version = "2.6.8300"
cesdk_version = "2.7.8538"
self.requires("cesdk/{}@esri-rd-zurich/stable".format(cesdk_version))
2 changes: 1 addition & 1 deletion src/conanfile-h190.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def requirements(self):
if "PLD_CONAN_CESDK_VERSION" in os.environ:
cesdk_version = os.environ["PLD_CONAN_CESDK_VERSION"]
else:
cesdk_version = "2.6.8300"
cesdk_version = "2.7.8538"
self.requires("cesdk/{}@esri-rd-zurich/stable".format(cesdk_version))
2 changes: 1 addition & 1 deletion src/conanfile-h195.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ def requirements(self):
if "PLD_CONAN_CESDK_VERSION" in os.environ:
cesdk_version = os.environ["PLD_CONAN_CESDK_VERSION"]
else:
cesdk_version = "2.6.8300"
cesdk_version = "2.7.8538"
self.requires("cesdk/{}@esri-rd-zurich/stable".format(cesdk_version))
16 changes: 1 addition & 15 deletions src/palladio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,7 @@ if (PLD_TEST)
target_compile_definitions(palladio PRIVATE -DPLD_TEST_EXPORTS)
endif ()

if (PLD_WINDOWS)
# nothing, inheriting compiler flags from houdini

elseif (PLD_LINUX)
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
target_compile_options(${TGT_PALLADIO} PRIVATE -O3 -flto)
target_compile_definitions(${TGT_PALLADIO} PRIVATE -DNDEBUG)
elseif (${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
target_compile_options(${TGT_PALLADIO} PRIVATE -O3 -ggdb -pg)
target_compile_definitions(${TGT_PALLADIO} PRIVATE -DNDEBUG)
elseif (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options(${TGT_PALLADIO} PRIVATE -O0 -ggdb -pg)
target_compile_definitions(${TGT_PALLADIO} PRIVATE -DDEBUG)
endif ()

if (PLD_LINUX)
set_target_properties(${TGT_PALLADIO} PROPERTIES
INSTALL_RPATH "\$ORIGIN/../packages/palladio"
INSTALL_RPATH_USE_LINK_PATH FALSE
Expand Down
20 changes: 12 additions & 8 deletions src/palladio/ModelConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ UTVector3FVector convertVertices(const double* vtx, size_t vtxSize) {
}

void setVertexNormals(GA_RWHandleV3& handle, const GA_Detail::OffsetMarker& marker, const double* nrm, size_t nrmSize,
const uint32_t* indices) {
const uint32_t* indices, size_t indicesSize) {
uint32_t vi = 0;
for (GA_Iterator it(marker.vertexRange()); !it.atEnd(); ++it, ++vi) {
assert(vi < indicesSize);
const auto nrmIdx = indices[vi];
const auto nrmPos = nrmIdx * 3;
assert(nrmPos + 2 < nrmSize);
Expand All @@ -65,8 +66,9 @@ namespace ModelConversion {

GA_Offset createPrimitives(GU_Detail* mDetail, GroupCreation gc, const wchar_t* name, const double* vtx, size_t vtxSize,
const double* nrm, size_t nrmSize, const uint32_t* counts, size_t countsSize,
const uint32_t* indices, size_t indicesSize, double const* const* uvs,
size_t const* uvsSizes, uint32_t const* const* uvCounts, size_t const* uvCountsSizes,
const uint32_t* vertexIndices, size_t vertexIndicesSize, const uint32_t* normalIndices,
size_t normalIndicesSize, double const* const* uvs, size_t const* uvsSizes,
uint32_t const* const* uvCounts, size_t const* uvCountsSizes,
uint32_t const* const* uvIndices, size_t const* uvIndicesSizes, uint32_t uvSets) {
WA("all");

Expand All @@ -80,12 +82,12 @@ GA_Offset createPrimitives(GU_Detail* mDetail, GroupCreation gc, const wchar_t*
return pc;
}();
const GA_Offset primStartOffset = GU_PrimPoly::buildBlock(mDetail, utPoints.data(), utPoints.size(), geoPolyCounts,
reinterpret_cast<const int*>(indices));
reinterpret_cast<const int*>(vertexIndices));

// -- add vertex normals
if (nrmSize > 0) {
GA_RWHandleV3 nrmh(mDetail->addNormalAttribute(GA_ATTRIB_VERTEX, GA_STORE_REAL32));
setVertexNormals(nrmh, marker, nrm, nrmSize, indices);
setVertexNormals(nrmh, marker, nrm, vertexIndicesSize, normalIndices, normalIndicesSize);
}

// -- add texture coordinates
Expand Down Expand Up @@ -153,7 +155,8 @@ ModelConverter::ModelConverter(GU_Detail* detail, GroupCreation gc, std::vector<
: mDetail(detail), mGroupCreation(gc), mStatuses(statuses), mAutoInterrupt(autoInterrupt) {}

void ModelConverter::add(const wchar_t* name, const double* vtx, size_t vtxSize, const double* nrm, size_t nrmSize,
const uint32_t* counts, size_t countsSize, const uint32_t* indices, size_t indicesSize,
const uint32_t* counts, size_t countsSize, const uint32_t* vertexIndices,
size_t vertexIndicesSize, const uint32_t* normalIndices, size_t normalIndicesSize,
double const* const* uvs, size_t const* uvsSizes, uint32_t const* const* uvCounts,
size_t const* uvCountsSizes, uint32_t const* const* uvIndices, size_t const* uvIndicesSizes,
uint32_t uvSets, const uint32_t* faceRanges, size_t faceRangesSize,
Expand All @@ -163,8 +166,9 @@ void ModelConverter::add(const wchar_t* name, const double* vtx, size_t vtxSize,
std::lock_guard<std::mutex> guard(mDetailMutex);

const GA_Offset primStartOffset = ModelConversion::createPrimitives(
mDetail, mGroupCreation, name, vtx, vtxSize, nrm, nrmSize, counts, countsSize, indices, indicesSize, uvs,
uvsSizes, uvCounts, uvCountsSizes, uvIndices, uvIndicesSizes, uvSets);
mDetail, mGroupCreation, name, vtx, vtxSize, nrm, nrmSize, counts, countsSize, vertexIndices,
vertexIndicesSize, normalIndices, normalIndicesSize, uvs, uvsSizes, uvCounts, uvCountsSizes, uvIndices,
uvIndicesSizes, uvSets);

// -- convert materials/reports into primitive attributes based on face ranges
if (DBG)
Expand Down
10 changes: 5 additions & 5 deletions src/palladio/ModelConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ class ModelConverter : public HoudiniCallbacks {

protected:
void add(const wchar_t* name, const double* vtx, size_t vtxSize, const double* nrm, size_t nrmSize,
const uint32_t* counts, size_t countsSize, const uint32_t* indices, size_t indicesSize,
double const* const* uvs, size_t const* uvsSizes, uint32_t const* const* uvCounts,
size_t const* uvCountsSizes, uint32_t const* const* uvIndices, size_t const* uvIndicesSizes,
uint32_t uvSets, const uint32_t* faceRanges, size_t faceRangesSize, const prt::AttributeMap** materials,
const prt::AttributeMap** reports, const int32_t* shapeIDs) override;
const uint32_t* counts, size_t countsSize, const uint32_t* vertexIndices, size_t vertexIndicesSize,
const uint32_t* normalIndices, size_t normalIndicesSize, double const* const* uvs, size_t const* uvsSizes,
uint32_t const* const* uvCounts, size_t const* uvCountsSizes, uint32_t const* const* uvIndices,
size_t const* uvIndicesSizes, uint32_t uvSets, const uint32_t* faceRanges, size_t faceRangesSize,
const prt::AttributeMap** materials, const prt::AttributeMap** reports, const int32_t* shapeIDs) override;

prt::Status generateError(size_t isIndex, prt::Status status, const wchar_t* message) override;
prt::Status assetError(size_t isIndex, prt::CGAErrorLevel level, const wchar_t* key, const wchar_t* uri,
Expand Down
Loading

0 comments on commit d4bfdec

Please sign in to comment.