Skip to content

Commit

Permalink
IO_Assimp: WIP3
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Nov 9, 2023
1 parent f90ca94 commit 6e2ed1c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
16 changes: 15 additions & 1 deletion mayo.pro
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,41 @@ versionAtLeast(OCC_VERSION_STR, 7.4.0) {
src/io_occ/io_occ_base_mesh.cpp \
src/io_occ/io_occ_gltf_reader.cpp \
src/io_occ/io_occ_obj_reader.cpp

message(glTF reader disabled because OpenCascade < v7.4)
message(OBJ reader disabled because OpenCascade < v7.4)
}

!versionAtLeast(OCC_VERSION_STR, 7.5.0) {
SOURCES -= src/io_occ/io_occ_gltf_writer.cpp
message(glTF writer disabled because OpenCascade < v7.5)
}

!versionAtLeast(OCC_VERSION_STR, 7.6.0) {
SOURCES -= src/io_occ/io_occ_obj_writer.cpp
message(OBJ writer disabled because OpenCascade < v7.6)
}
# -- VRML support
LIBS += -lTKVRML
!versionAtLeast(OCC_VERSION_STR, 7.7.0) {
SOURCES -= src/io_occ/io_occ_vrml_reader.cpp
message(VRML reader disabled because OpenCascade < v7.7)
}

# assimp
isEmpty(ASSIMP_INC_DIR) | isEmpty(ASSIMP_LIB_DIR) {
message(assimp OFF)
} else {
message(assimp ON)
!versionAtLeast(OCC_VERSION_STR, 7.5.0) {
message(assimp reader disabled because OpenCascade < v7.5)
}
else {
message(assimp ON)
ASSIMP_IS_ON = 1
}
}

defined(ASSIMP_IS_ON, var) {
HEADERS += $$files(src/io_assimp/*.h)
SOURCES += $$files(src/io_assimp/*.cpp)

Expand Down
14 changes: 12 additions & 2 deletions src/io_assimp/io_assimp_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ aiVector3D aiMatrixScaling(const aiMatrix4x4& trsf)

bool hasScaleFactor(const gp_Trsf& trsf)
{
return (Abs(Abs(trsf.ScaleFactor()) - 1.) > TopLoc_Location::ScalePrec()) || trsf.IsNegative();
const double topLocationScalePrec =
#if OCC_VERSION_HEX >= OCC_VERSION_CHECK(7, 6, 0)
TopLoc_Location::ScalePrec();
#else
1.e-14;
#endif
return (Abs(Abs(trsf.ScaleFactor()) - 1.) > topLocationScalePrec) || trsf.IsNegative();
}

bool hasScaleFactor(const aiVector3D& scaling)
Expand Down Expand Up @@ -443,11 +449,15 @@ Handle(XCAFDoc_VisMaterial) AssimpReader::createOccVisMaterial(
{
int flag;
if (material->Get(AI_MATKEY_TWOSIDED, flag) == aiReturn_SUCCESS) {
#if OCC_VERSION_HEX >= OCC_VERSION_CHECK(7, 6, 0)
mat->SetFaceCulling(
flag ?
Graphic3d_TypeOfBackfacingModel_DoubleSided
: Graphic3d_TypeOfBackfacingModel_BackCulled
);
);
#else
mat->SetDoubleSided(flag != 0);
#endif
}
}

Expand Down

0 comments on commit 6e2ed1c

Please sign in to comment.