message: Fix flags, make CPLYWriter work

diff:
@@ -208,9 +208,9 @@ bool CPLYMeshWriter::writeAsset(io::IWriteFile* _file, const SAssetWriteParams&
file->write(header.c_str(), header.size());
if (flags & asset::EWF_BINARY)
- writeBinary(file, mesh->getMeshBuffer(0), vtxCount, faceCount, idxT, indices, forceFaces, vaidToWrite);
+ writeBinary(file, mesh->getMeshBuffer(0), vtxCount, faceCount, idxT, indices, forceFaces, vaidToWrite, _params);
else
- writeText(file, mesh->getMeshBuffer(0), vtxCount, faceCount, idxT, indices, forceFaces, vaidToWrite);
+ writeText(file, mesh->getMeshBuffer(0), vtxCount, faceCount, idxT, indices, forceFaces, vaidToWrite, _params);
if (needToFreeIndices)
_IRR_ALIGNED_FREE(indices);
@@ -218,10 +218,12 @@ bool CPLYMeshWriter::writeAsset(io::IWriteFile* _file, const SAssetWriteParams&
return true;
}
-void CPLYMeshWriter::writeBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, size_t _vtxCount, size_t _fcCount, asset::E_INDEX_TYPE _idxType, void* const _indices, bool _forceFaces, const bool _vaidToWrite[4]) const
+void CPLYMeshWriter::writeBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, size_t _vtxCount, size_t _fcCount, asset::E_INDEX_TYPE _idxType, void* const _indices, bool _forceFaces, const bool _vaidToWrite[4], const SAssetWriteParams& _params) const
{
const size_t colCpa = asset::getFormatChannelCount(_mbuf->getMeshDataAndFormat()->getAttribFormat(asset::EVAI_ATTR1));
+ bool flipVectors = (!(_params.writerFlags & IAssetWriter::EWPF_MESH_IS_RIGHT_HANDED)) ? true : false;
+
asset::ICPUMeshBuffer* mbCopy = createCopyMBuffNormalizedReplacedWithTrueInt(_mbuf);
for (size_t i = 0u; i < _vtxCount; ++i)
{
@@ -229,7 +231,7 @@ void CPLYMeshWriter::writeBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _
uint32_t ui[4];
if (_vaidToWrite[asset::EVAI_ATTR0])
{
- writeAttribBinary(_file, mbCopy, asset::EVAI_ATTR0, i, 3u);
+ writeAttribBinary(_file, mbCopy, asset::EVAI_ATTR0, i, 3u, flipVectors);
/*_mbuf->getAttribute(f, EVAI_ATTR0, i);
_file->write(f.pointer, 3*sizeof(float));*/
}
@@ -243,7 +245,7 @@ void CPLYMeshWriter::writeBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _
}
if (_vaidToWrite[asset::EVAI_ATTR3])
{
- writeAttribBinary(_file, mbCopy, asset::EVAI_ATTR3, i, 3u);
+ writeAttribBinary(_file, mbCopy, asset::EVAI_ATTR3, i, 3u, flipVectors);
}
}
mbCopy->drop();
@@ -290,12 +292,17 @@ void CPLYMeshWriter::writeBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _
_IRR_ALIGNED_FREE(indices);
}
-void CPLYMeshWriter::writeText(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, size_t _vtxCount, size_t _fcCount, asset::E_INDEX_TYPE _idxType, void* const _indices, bool _forceFaces, const bool _vaidToWrite[4]) const
+void CPLYMeshWriter::writeText(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, size_t _vtxCount, size_t _fcCount, asset::E_INDEX_TYPE _idxType, void* const _indices, bool _forceFaces, const bool _vaidToWrite[4], const SAssetWriteParams& _params) const
{
asset::ICPUMeshBuffer* mbCopy = createCopyMBuffNormalizedReplacedWithTrueInt(_mbuf);
- auto writefunc = [&_file,&mbCopy,this](asset::E_VERTEX_ATTRIBUTE_ID _vaid, size_t _ix, size_t _cpa)
+ auto writefunc = [&_file,&mbCopy, &_params, this](asset::E_VERTEX_ATTRIBUTE_ID _vaid, size_t _ix, size_t _cpa)
{
+ bool flipVerteciesAndNormals = false;
+ if (!(_params.writerFlags & IAssetWriter::EWPF_MESH_IS_RIGHT_HANDED))
+ if(_vaid == asset::E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0 || _vaid == asset::E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3)
+ flipVerteciesAndNormals = true;
+
uint32_t ui[4];
core::vectorSIMDf f;
const asset::E_FORMAT t = mbCopy->getMeshDataAndFormat()->getAttribFormat(_vaid);
@@ -303,18 +310,18 @@ void CPLYMeshWriter::writeText(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mb
{
mbCopy->getAttribute(ui, _vaid, _ix);
if (!asset::isSignedFormat(t))
- writeVectorAsText(_file, ui, _cpa);
+ writeVectorAsText(_file, ui, _cpa, flipVerteciesAndNormals);
else
{
int32_t ii[4];
memcpy(ii, ui, 4*4);
- writeVectorAsText(_file, ii, _cpa);
+ writeVectorAsText(_file, ii, _cpa, flipVerteciesAndNormals);
}
}
else
{
mbCopy->getAttribute(f, _vaid, _ix);
- writeVectorAsText(_file, f.pointer, _cpa);
+ writeVectorAsText(_file, f.pointer, _cpa, flipVerteciesAndNormals);
}
};
@@ -388,14 +395,17 @@ void CPLYMeshWriter::writeText(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mb
_IRR_ALIGNED_FREE(indices);
}
-void CPLYMeshWriter::writeAttribBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, asset::E_VERTEX_ATTRIBUTE_ID _vaid, size_t _ix, size_t _cpa) const
+void CPLYMeshWriter::writeAttribBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, asset::E_VERTEX_ATTRIBUTE_ID _vaid, size_t _ix, size_t _cpa, bool flipVectors) const
{
uint32_t ui[4];
core::vectorSIMDf f;
asset::E_FORMAT t = _mbuf->getMeshDataAndFormat()->getAttribFormat(_vaid);
if (asset::isScaledFormat(t) || asset::isIntegerFormat(t))
{
+ constexpr size_t xID = 0u;
_mbuf->getAttribute(ui, _vaid, _ix);
+ if (flipVectors)
+ ui[xID] = -ui[xID];
const uint32_t bytesPerCh = asset::getTexelOrBlockBytesize(t)/asset::getFormatChannelCount(t);
if (bytesPerCh == 1u || t == asset::EF_A2B10G10R10_UINT_PACK32 || t == asset::EF_A2B10G10R10_SINT_PACK32 || t == asset::EF_A2B10G10R10_SSCALED_PACK32 || t == asset::EF_A2B10G10R10_USCALED_PACK32)

diff:
@@ -36,10 +36,10 @@ namespace asset
virtual bool writeAsset(io::IWriteFile* _file, const SAssetWriteParams& _params, IAssetWriterOverride* _override = nullptr) override;
private:
- void writeBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, size_t _vtxCount, size_t _fcCount, asset::E_INDEX_TYPE _idxType, void* const _indices, bool _forceFaces, const bool _vaidToWrite[4]) const;
- void writeText(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, size_t _vtxCount, size_t _fcCount, asset::E_INDEX_TYPE _idxType, void* const _indices, bool _forceFaces, const bool _vaidToWrite[4]) const;
+ void writeBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, size_t _vtxCount, size_t _fcCount, asset::E_INDEX_TYPE _idxType, void* const _indices, bool _forceFaces, const bool _vaidToWrite[4], const SAssetWriteParams& _params) const;
+ void writeText(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, size_t _vtxCount, size_t _fcCount, asset::E_INDEX_TYPE _idxType, void* const _indices, bool _forceFaces, const bool _vaidToWrite[4], const SAssetWriteParams& _params) const;
- void writeAttribBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, asset::E_VERTEX_ATTRIBUTE_ID _vaid, size_t _ix, size_t _cpa) const;
+ void writeAttribBinary(io::IWriteFile* _file, asset::ICPUMeshBuffer* _mbuf, asset::E_VERTEX_ATTRIBUTE_ID _vaid, size_t _ix, size_t _cpa, bool flipVectors = false) const;
//! Creates new mesh buffer with the same attribute buffers mapped but with normalized types changed to corresponding true integer types.
static asset::ICPUMeshBuffer* createCopyMBuffNormalizedReplacedWithTrueInt(const asset::ICPUMeshBuffer* _mbuf);
@@ -47,12 +47,21 @@ namespace asset
static std::string getTypeString(asset::E_FORMAT _t);
template<typename T>
- void writeVectorAsText(io::IWriteFile* _file, const T* _vec, size_t _elementsToWrite) const
+ void writeVectorAsText(io::IWriteFile* _file, const T* _vec, size_t _elementsToWrite, bool flipVectors = false) const
{
+ constexpr size_t xID = 0u;
std::stringstream ss;
ss << std::fixed;
+ bool currentFlipOnVariable = false;
for (size_t i = 0u; i < _elementsToWrite; ++i)
- ss << std::setprecision(6) << _vec[i] << " ";
+ {
+ if (flipVectors && i == xID)
+ currentFlipOnVariable = true;
+ else
+ currentFlipOnVariable = false;
+
+ ss << std::setprecision(6) << _vec[i] * (currentFlipOnVariable ? -1 : 1) << " ";
+ }
auto str = ss.str();
_file->write(str.c_str(), str.size());
}

diff:
@@ -125,24 +125,8 @@ inline void writeFacesBinary(asset::ICPUMeshBuffer* buffer, const bool& noIndice
normal = core::plane3dSIMDf(vertex1, vertex2, vertex3).getNormal();
};
- if (_params.writerFlags & IAssetWriter::EWPF_WRITE_RIGHT_HANDED)
- {
- if (_params.writerFlags & IAssetWriter::EWPF_MESH_IS_RIGHT_HANDED)
- {
- // do nothing
- }
- else
- flipVectors();
- }
- else
- {
if (!(_params.writerFlags & IAssetWriter::EWPF_MESH_IS_RIGHT_HANDED))
- {
- // do nothing
- }
- else
flipVectors();
- }
file->write(&normal, 12);
file->write(&vertex1, 12);
@@ -293,7 +277,7 @@ void CSTLMeshWriter::writeFaceText(io::IWriteFile* file,
core::vectorSIMDf vertex1 = v3;
core::vectorSIMDf vertex2 = v2;
core::vectorSIMDf vertex3 = v1;
- core::vector3df_SIMD normal = core::plane3dSIMDf(vertex1, vertex2, vertex3).getNormal();
+ core::vectorSIMDf normal = core::plane3dSIMDf(vertex1, vertex2, vertex3).getNormal();
core::stringc tmp;
auto flipVectors = [&]()
@@ -304,24 +288,8 @@ void CSTLMeshWriter::writeFaceText(io::IWriteFile* file,
normal = core::plane3dSIMDf(vertex1, vertex2, vertex3).getNormal();
};
- if(_params.writerFlags & IAssetWriter::EWPF_WRITE_RIGHT_HANDED)
- {
- if(_params.writerFlags & IAssetWriter::EWPF_MESH_IS_RIGHT_HANDED)
- {
- // do nothing
- }
- else
- flipVectors();
- }
- else
- {
if (!(_params.writerFlags & IAssetWriter::EWPF_MESH_IS_RIGHT_HANDED))
- {
- // do nothing
- }
- else
flipVectors();
- }
file->write("facet normal ",13);
getVectorAsStringLine(normal, tmp);

original_message: Fix flags, make CPLYWriter work


message: Fork GLM and GLEW, specify tags

change_type: MODIFY

old_path: .gitmodules

new_path: .gitmodules

diff:
branch = master
[submodule "3rdparty/glm"]
path = 3rdparty/glm
- url = https://github.com/g-truc/glm.git
+ url = https://github.com/AnastaZIuk/glm.git
[submodule "3rdparty/freetype2"]
path = 3rdparty/freetype2
url = https://git.sv.nongnu.org/r/freetype/freetype2.git
url = https://github.com/svn2github/pcre.git
[submodule "3rdparty/CEGUI/glew-cmake"]
path = 3rdparty/CEGUI/glew
- url = https://github.com/achalpandeyy/glew-cmake.git
+ url = https://github.com/AnastaZIuk/glew-cmake.git

license: Apache License 2.0

repo: buildaworldnet/irrlichtbaw

original_message: Fork GLM and GLEW, specify tags


message:
Fix zlib on master
But png_static project doesn't have a path to configuration zconf.h files
It's weird, because path to it is placed in COMMON_INCLUDE_DIRS though,
and both Irrlicht and IrrlichtServer projects see it, but png_static doesn't

diff:
@@ -35,6 +35,22 @@ update_git_submodule(./glm)
update_git_submodule(./freetype2)
update_git_submodule(./portable-file-dialogs)
+# zlib (target is zlibstatic)
+set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+set(_OLD_SKIP_INSTALL_ALL ${SKIP_INSTALL_ALL})
+set(BUILD_SHARED_LIBS OFF)
+set(SKIP_INSTALL_ALL ON)
+add_subdirectory(zlib zlib EXCLUDE_FROM_ALL)
+set(SKIP_INSTALL_ALL ${_OLD_SKIP_INSTALL_ALL})
+set(BUILD_SHARED_LIBS ${_OLD_BUILD_SHARED_LIBS})
+get_target_property(ZLIB_BINARY_DIR zlibstatic "BINARY_DIR")
+get_target_property(ZLIB_NAME zlibstatic "NAME")
+get_target_property(ZLIB_DEBUG_POSTFIX zlibstatic "DEBUG_POSTFIX")
+#message(FATAL_ERROR ${THIRD_PARTY_SOURCE_DIR})
+set(ZLIB_INCLUDE_DIR "${THIRD_PARTY_SOURCE_DIR}/zlib;${THIRD_PARTY_BINARY_DIR}/zlib" CACHE STRING "" FORCE)
+# This probably breaks the non-MSVC build in like 50 different ways
+set(ZLIB_LIBRARY_DEBUG "${ZLIB_BINARY_DIR}/Debug/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_NAME}${ZLIB_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE STRING "" FORCE)
+set(ZLIB_LIBRARY_RELEASE "${ZLIB_BINARY_DIR}/Release/${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE STRING "" FORCE)
set(SPIRV_HEADERS_SKIP_EXAMPLES ON CACHE BOOL "Skip SPIRV-Headers examples")
@@ -71,29 +87,14 @@ add_subdirectory(libjpeg libjpeg EXCLUDE_FROM_ALL)
#manipulating libpng cmake options from within cmake script
option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF)
-set(PNG_BUILD_ZLIB ON)
-set(ZLIB_INCLUDE_DIR ${THIRD_PARTY_SOURCE_DIR}/zlib) #for pnglib
-set(ZLIB_LIBRARY "$<TARGET_OBJECTS:zlib>") #for pnglib
+set(PNG_BUILD_ZLIB OFF)
option(PNG_SHARED "Build shared lib" OFF)
option(PNG_TESTS "Build libpng tests" OFF)
add_subdirectory(libpng libpng EXCLUDE_FROM_ALL)
-add_dependencies(png_static zlib) #CMake doesn't get it itself
+add_dependencies(png_static zlibstatic) #CMake doesn't get it itself
irr_adjust_flags()
-add_library(zlib OBJECT
- zlib/adler32.c
- zlib/crc32.c
- zlib/deflate.c
- zlib/infback.c
- zlib/inffast.c
- zlib/inflate.c
- zlib/inftrees.c
- zlib/trees.c
- zlib/uncompr.c
- #zlib/zcompress.c
- zlib/zutil.c
-)
add_library(lzma OBJECT
lzma/C/Alloc.c
lzma/C/LzFind.c

diff:
@@ -202,6 +202,7 @@ set(IRRLICHT_SRCS_SERVER
set(COMMON_INCLUDE_DIRS
${THIRD_PARTY_SOURCE_DIR}/convertutf
${THIRD_PARTY_SOURCE_DIR}/utfcpp/source
+ $<TARGET_PROPERTY:zlibstatic,BINARY_DIR> #for dynamically generated zconf.h
$<TARGET_PROPERTY:png_static,BINARY_DIR> #for dynamically generated pnglibconf.h
$<TARGET_PROPERTY:jpeg,BINARY_DIR> #for dynamically generated jconfig.h
)
@@ -209,6 +210,13 @@ set(COMMON_INCLUDE_DIRS
irr_adjust_flags() # macro defined in root CMakeLists
irr_adjust_definitions() # macro defined in root CMakeLists
+macro(irr_target_link_zlib _trgt)
+ add_dependencies(${_trgt} zlibstatic)
+ target_link_libraries(${_trgt} INTERFACE
+ zlibstatic
+ )
+ target_include_directories(${_trgt} PUBLIC ${THIRD_PARTY_SOURCE_DIR}/zlib)
+endmacro()
macro(irr_target_link_openssl _trgt)
if(WIN32)
target_link_libraries(${_trgt} INTERFACE
@@ -262,6 +270,7 @@ add_library(Irrlicht STATIC
)
add_dependencies(Irrlicht openssl_build)
+irr_target_link_zlib(Irrlicht)
irr_target_link_openssl(Irrlicht)
irr_target_link_shaderc(Irrlicht)
irr_target_link_libjpeg(Irrlicht)
@@ -334,10 +343,10 @@ add_library(IrrlichtServer STATIC
$<TARGET_OBJECTS:convert_utf>
$<TARGET_OBJECTS:lz4>
$<TARGET_OBJECTS:lzma>
- $<TARGET_OBJECTS:zlib>
)
add_dependencies(IrrlichtServer openssl_build)
+irr_target_link_zlib(IrrlichtServer)
irr_target_link_openssl(IrrlichtServer)
irr_target_link_shaderc(IrrlichtServer)
irr_target_link_libjpeg(IrrlichtServer)


message: Perform tests and make sure zlib works

diff:
@@ -35,6 +35,9 @@ update_git_submodule(./glm)
update_git_submodule(./freetype2)
update_git_submodule(./portable-file-dialogs)
+
+add_subdirectory(openssl openssl EXCLUDE_FROM_ALL)
+
# zlib (target is zlibstatic)
set(_OLD_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(_OLD_SKIP_INSTALL_ALL ${SKIP_INSTALL_ALL})
@@ -75,8 +78,6 @@ if (UNIX)
endif()
add_subdirectory(shaderc shaderc EXCLUDE_FROM_ALL)
-add_subdirectory(openssl openssl EXCLUDE_FROM_ALL)
-
#manipulating libjpeg cmake options from within cmake script
#option(ENABLE_SHARED "jpeg-turbo" OFF)
#set(CMAKE_INSTALL_DOCDIR "${CMAKE_CURRENT_BINARY_DIR}/doc" CACHE PATH "For libjpeg-turbo" FORCE)

diff:
@@ -186,6 +186,7 @@ option(IRR_BUILD_BULLET "Enable Bullet Physics building and integration?" OFF)
option(IRR_BUILD_DOCS "Enable building documentation?" ON)
set(THIRD_PARTY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/3rdparty")
+set(THIRD_PARTY_BINARY_DIR "${PROJECT_BINARY_DIR}/3rdparty")
execute_process(COMMAND git submodule init
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")

original_message: Perform tests and make sure zlib works


message: Bump into V3, prepare myself for patching meshbuffer to use rh/lh flag

diff:
@@ -336,7 +336,7 @@ currently only supports zip archives, though. */
#endif
-#define _IRR_BAW_FORMAT_VERSION 2
+#define _IRR_BAW_FORMAT_VERSION 3
//! @see @ref CBlobsLoadingManager
#define _IRR_ADD_BLOB_SUPPORT(BlobClassName, EnumValue, Function, ...) \
@@ -345,13 +345,13 @@ case asset::Blob::EnumValue:\
//! Used inside CBlobsLoadingManager. Adds support of given blob types.
#define _IRR_SUPPORTED_BLOBS(Function, ...) \
-_IRR_ADD_BLOB_SUPPORT(RawBufferBlobV2, EBT_RAW_DATA_BUFFER, Function, __VA_ARGS__)\
-_IRR_ADD_BLOB_SUPPORT(TexturePathBlobV2, EBT_TEXTURE_PATH, Function, __VA_ARGS__)\
-_IRR_ADD_BLOB_SUPPORT(MeshBlobV2, EBT_MESH, Function, __VA_ARGS__)\
-_IRR_ADD_BLOB_SUPPORT(SkinnedMeshBlobV2, EBT_SKINNED_MESH, Function, __VA_ARGS__)\
-_IRR_ADD_BLOB_SUPPORT(MeshBufferBlobV2, EBT_MESH_BUFFER, Function, __VA_ARGS__)\
-_IRR_ADD_BLOB_SUPPORT(SkinnedMeshBufferBlobV2, EBT_SKINNED_MESH_BUFFER, Function, __VA_ARGS__)\
-_IRR_ADD_BLOB_SUPPORT(MeshDataFormatDescBlobV2, EBT_DATA_FORMAT_DESC, Function, __VA_ARGS__)\
-_IRR_ADD_BLOB_SUPPORT(FinalBoneHierarchyBlobV2, EBT_FINAL_BONE_HIERARCHY, Function, __VA_ARGS__)
+_IRR_ADD_BLOB_SUPPORT(RawBufferBlobV3, EBT_RAW_DATA_BUFFER, Function, __VA_ARGS__)\
+_IRR_ADD_BLOB_SUPPORT(TexturePathBlobV3, EBT_TEXTURE_PATH, Function, __VA_ARGS__)\
+_IRR_ADD_BLOB_SUPPORT(MeshBlobV3, EBT_MESH, Function, __VA_ARGS__)\
+_IRR_ADD_BLOB_SUPPORT(SkinnedMeshBlobV3, EBT_SKINNED_MESH, Function, __VA_ARGS__)\
+_IRR_ADD_BLOB_SUPPORT(MeshBufferBlobV3, EBT_MESH_BUFFER, Function, __VA_ARGS__)\
+_IRR_ADD_BLOB_SUPPORT(SkinnedMeshBufferBlobV3, EBT_SKINNED_MESH_BUFFER, Function, __VA_ARGS__)\
+_IRR_ADD_BLOB_SUPPORT(MeshDataFormatDescBlobV3, EBT_DATA_FORMAT_DESC, Function, __VA_ARGS__)\
+_IRR_ADD_BLOB_SUPPORT(FinalBoneHierarchyBlobV3, EBT_FINAL_BONE_HIERARCHY, Function, __VA_ARGS__)
#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__

diff:
@@ -103,11 +103,11 @@ namespace asset
// ===============
// .baw VERSION
// ===============
- constexpr uint32_t CurrentBAWFormatVersion = 2u;
- using BlobHeaderV2 = BlobHeaderVn<CurrentBAWFormatVersion>;
- using BAWFileV2 = BAWFileVn<CurrentBAWFormatVersion>;
+ constexpr uint32_t CurrentBAWFormatVersion = 3u;
+ using BlobHeaderV3 = BlobHeaderVn<CurrentBAWFormatVersion>;
+ using BAWFileV3 = BAWFileVn<CurrentBAWFormatVersion>;
- using BlobHeaderLatest = BlobHeaderV2;
+ using BlobHeaderLatest = BlobHeaderV3;
bool encAes128gcm(const void* _input, size_t _inSize, void* _output, size_t _outSize, const unsigned char* _key, const unsigned char* _iv, void* _tag);
bool decAes128gcm(const void* _input, size_t _inSize, void* _output, size_t _outSize, const unsigned char* _key, const unsigned char* _iv, void* _tag);

diff:
@@ -90,8 +90,10 @@ static_assert(
"FinalBoneHierarchyBlobV2: Size of blob is not sum of its contents!"
);
+using FinalBoneHierarchyBlobV3 = FinalBoneHierarchyBlobV2;
+
template<>
-struct CorrespondingBlobTypeFor<CFinalBoneHierarchy> { typedef FinalBoneHierarchyBlobV2 type; };
+struct CorrespondingBlobTypeFor<CFinalBoneHierarchy> { typedef FinalBoneHierarchyBlobV3 type; };
}
} // irr::asset

diff:
@@ -40,9 +40,10 @@ static_assert(
using MeshBlobV1 = MeshBlobV0;
using MeshBlobV2 = MeshBlobV1;
+using MeshBlobV3 = MeshBlobV2;
template<>
-struct CorrespondingBlobTypeFor<ICPUMesh> { typedef MeshBlobV2 type; };
+struct CorrespondingBlobTypeFor<ICPUMesh> { typedef MeshBlobV3 type; };
}
} // irr::asset

diff:
@@ -45,10 +45,11 @@ static_assert(
using MeshBufferBlobV1 = MeshBufferBlobV0;
using MeshBufferBlobV2 = MeshBufferBlobV1;
+using MeshBufferBlobV3 = MeshBufferBlobV2;
template<>
-struct CorrespondingBlobTypeFor<ICPUMeshBuffer> { typedef MeshBufferBlobV2 type; };
+struct CorrespondingBlobTypeFor<ICPUMeshBuffer> { typedef MeshBufferBlobV3 type; };
}
} // irr::asset

diff:
@@ -47,14 +47,15 @@ static_assert(
);
using MeshDataFormatDescBlobV2 = MeshDataFormatDescBlobV1;
+using MeshDataFormatDescBlobV3 = MeshDataFormatDescBlobV2;
template<>
-struct CorrespondingBlobTypeFor<IMeshDataFormatDesc<ICPUBuffer> > { typedef MeshDataFormatDescBlobV2 type; };
+struct CorrespondingBlobTypeFor<IMeshDataFormatDesc<ICPUBuffer> > { typedef MeshDataFormatDescBlobV3 type; };
template<>
-inline size_t SizedBlob<FixedSizeBlob, MeshDataFormatDescBlobV2, IMeshDataFormatDesc<ICPUBuffer> >::calcBlobSizeForObj(const IMeshDataFormatDesc<ICPUBuffer>* _obj)
+inline size_t SizedBlob<FixedSizeBlob, MeshDataFormatDescBlobV3, IMeshDataFormatDesc<ICPUBuffer> >::calcBlobSizeForObj(const IMeshDataFormatDesc<ICPUBuffer>* _obj)
{
- return sizeof(MeshDataFormatDescBlobV2);
+ return sizeof(MeshDataFormatDescBlobV3);
}

diff:
@@ -22,9 +22,10 @@ struct IRR_FORCE_EBO RawBufferBlobV0 : TypedBlob<RawBufferBlobV0, ICPUBuffer>, V
using RawBufferBlobV1 = RawBufferBlobV0;
using RawBufferBlobV2 = RawBufferBlobV1;
+using RawBufferBlobV3 = RawBufferBlobV2;
template<>
-struct CorrespondingBlobTypeFor<ICPUBuffer> { typedef RawBufferBlobV2 type; };
+struct CorrespondingBlobTypeFor<ICPUBuffer> { typedef RawBufferBlobV3 type; };
}
} // irr::asset

diff:
@@ -37,9 +37,10 @@ static_assert(
using SkinnedMeshBlobV1 = SkinnedMeshBlobV0;
using SkinnedMeshBlobV2 = SkinnedMeshBlobV1;
+using SkinnedMeshBlobV3 = SkinnedMeshBlobV2;
template<>
-struct CorrespondingBlobTypeFor<ICPUSkinnedMesh> { typedef SkinnedMeshBlobV2 type; };
+struct CorrespondingBlobTypeFor<ICPUSkinnedMesh> { typedef SkinnedMeshBlobV3 type; };
}
} // irr::asset

diff:
@@ -46,9 +46,10 @@ static_assert(
using SkinnedMeshBufferBlobV1 = SkinnedMeshBufferBlobV0;
using SkinnedMeshBufferBlobV2 = SkinnedMeshBufferBlobV1;
+using SkinnedMeshBufferBlobV3 = SkinnedMeshBufferBlobV2;
template<>
-struct CorrespondingBlobTypeFor<ICPUSkinnedMeshBuffer> { typedef SkinnedMeshBufferBlobV2 type; };
+struct CorrespondingBlobTypeFor<ICPUSkinnedMeshBuffer> { typedef SkinnedMeshBufferBlobV3 type; };
}

diff:
@@ -24,9 +24,10 @@ struct IRR_FORCE_EBO TexturePathBlobV0 : TypedBlob<TexturePathBlobV0, ICPUTextur
using TexturePathBlobV1 = TexturePathBlobV0;
using TexturePathBlobV2 = TexturePathBlobV1;
+using TexturePathBlobV3 = TexturePathBlobV2;
template<>
-struct CorrespondingBlobTypeFor<video::IVirtualTexture> { typedef TexturePathBlobV2 type; };
+struct CorrespondingBlobTypeFor<video::IVirtualTexture> { typedef TexturePathBlobV3 type; };
}
} // irr::asset

diff:
@@ -231,6 +231,109 @@ bool CBAWMeshFileLoader::decompressLz4(void * _dst, size_t _dstSize, const void
return res >= 0;
}
+template<>
+io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx, io::IReadFile* _baw2file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<2>& _common)
+{
+ uint32_t blobCnt{};
+ asset::legacyv2::BlobHeaderV2* headers = nullptr;
+ uint32_t* offsets = nullptr;
+ uint32_t baseOffsetv2{};
+ uint32_t baseOffsetv3{};
+ std::tie(blobCnt, headers, offsets, baseOffsetv2, baseOffsetv3) = _common;
+
+ io::CMemoryWriteFile* const baw3mem = new io::CMemoryWriteFile(0u, _baw2file->getFileName());
+
+ std::vector<uint32_t> newoffsets(blobCnt);
+ int32_t offsetDiff = 0;
+ for (uint32_t i = 0u; i < blobCnt; ++i)
+ {
+ asset::legacyv2::BlobHeaderV2& hdr = headers[i];
+ const uint32_t offset = offsets[i];
+ uint32_t& newoffset = newoffsets[i];
+
+ newoffset = offset + offsetDiff;
+
+ if (hdr.blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
+ {
+ const uint32_t offset = offsets[i];
+
+ uint8_t stackmem[1u << 10];
+ uint32_t attempt = 0u;
+ uint8_t decrKey[16];
+ size_t decrKeyLen = 16u;
+ void* blob = nullptr;
+ /* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
+ however we don't need to do this here since we know format's version (baw v1) and so we can be sure that hierarchy level for FinalBoneHierarchy is 3 (won't be true for v2 to v3 conversion)
+ */
+ constexpr uint32_t FINALBONEHIERARCHY_HIERARCHY_LVL = 3u;
+ while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw2file, "", genSubAssetCacheKey(_baw2file->getFileName().c_str(), hdr.handle), _ctx.inner, FINALBONEHIERARCHY_HIERARCHY_LVL))
+ {
+ if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
+ blob = tryReadBlobOnStack<asset::legacyv2::BlobHeaderV2>(SBlobData_t<asset::legacyv2::BlobHeaderV2>(&hdr, baseOffsetv2 + offset), _ctx, decrKey, stackmem, sizeof(stackmem));
+ if (blob)
+ break;
+ ++attempt;
+ }
+
+ // patch for meshbuffer blob
+ // TODO
+
+ offsetDiff += static_cast<int32_t>(hdr.blobSizeDecompr) - static_cast<int32_t>(hdr.effectiveSize());
+ hdr.compressionType = asset::Blob::EBCT_RAW;
+ core::XXHash_256(blob, hdr.blobSizeDecompr, hdr.blobHash);
+ hdr.blobSize = hdr.blobSizeDecompr;
+
+ if (blob)
+ _IRR_ALIGNED_FREE(blob);
+ }
+ }
+ uint64_t fileHeader[4]{ 0u, 0u, 0u, 2u/*baw v2*/ };
+ memcpy(fileHeader, BAWFileV3::HEADER_STRING, strlen(BAWFileV3::HEADER_STRING));
+ baw3mem->seek(0u);
+ baw3mem->write(fileHeader, sizeof(fileHeader));
+ baw3mem->write(&blobCnt, 4);
+ baw3mem->write(_ctx.iv, 16);
+ baw3mem->write(newoffsets.data(), newoffsets.size() * 4);
+ baw3mem->write(headers, blobCnt * sizeof(headers[0])); // blob header in v2 and in v3 is exact same thing, so we can do this
+
+ uint8_t stackmem[1u << 13]{};
+ size_t newFileSz = 0u;
+ for (uint32_t i = 0u; i < blobCnt; ++i)
+ {
+ uint32_t sz = headers[i].effectiveSize();
+ void* blob = nullptr;
+ if (headers[i].blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
+ {
+ sz = 0u;
+ }
+ else
+ {
+ _baw2file->seek(baseOffsetv2 + offsets[i]);
+ if (sz <= sizeof(stackmem))
+ blob = stackmem;
+ else
+ blob = _IRR_ALIGNED_MALLOC(sz, _IRR_SIMD_ALIGNMENT);
+
+ _baw2file->read(blob, sz);
+ }
+
+ baw3mem->seek(baseOffsetv2 + newoffsets[i]);
+ baw3mem->write(blob, sz);
+
+ if (headers[i].blobType != asset::Blob::EBT_DATA_FORMAT_DESC && blob != stackmem)
+ _IRR_ALIGNED_FREE(blob);
+
+ newFileSz = baseOffsetv3 + newoffsets[i] + sz;
+ }
+
+ _IRR_ALIGNED_FREE(offsets);
+ _IRR_ALIGNED_FREE(headers);
+
+ auto ret = new io::CMemoryReadFile(baw3mem->getPointer(), baw3mem->getSize(), _baw2file->getFileName());
+ baw3mem->drop();
+ return ret;
+}
+
//! These should be moved to some legacy baw loader .cpp file
template<>
io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<2>(SContext& _ctx, io::IReadFile* _baw1file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<1>& _common)
@@ -318,7 +421,7 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<2>(SContext& _ctx,
}
}
uint64_t fileHeader[4] {0u, 0u, 0u, 2u/*baw v2*/};
- memcpy(fileHeader, BAWFileV2::HEADER_STRING, strlen(BAWFileV2::HEADER_STRING));
+ memcpy(fileHeader, asset::legacyv2::BAWFileV2::HEADER_STRING, strlen(asset::legacyv2::BAWFileV2::HEADER_STRING));
baw2mem->seek(0u);
baw2mem->write(fileHeader, sizeof(fileHeader));
baw2mem->write(&blobCnt, 4);

diff:
@@ -26,7 +26,7 @@ class IAssetManager;
class CBAWMeshFileLoader : public asset::IAssetLoader
{
- friend struct TypedBlob<TexturePathBlobV2, asset::ICPUTexture>; // needed for loading textures
+ friend struct TypedBlob<TexturePathBlobV3, asset::ICPUTexture>; // needed for loading textures
private:
template<typename HeaderT>
@@ -144,7 +144,8 @@ private:
{
case 0ull: return verifyFile<asset::legacyv0::BAWFileV0>(_ctx);
case 1ull: return verifyFile<asset::legacyv1::BAWFileV1>(_ctx);
- case 2ull: return verifyFile<asset::BAWFileV2>(_ctx);
+ case 2ull: return verifyFile<asset::legacyv2::BAWFileV2>(_ctx);
+ case 3ull: return verifyFile<asset::BAWFileV3>(_ctx);
default: return false;
}
}

diff:
@@ -47,13 +47,13 @@ struct LzmaMemMngmnt
void CBAWMeshWriter::exportAsBlob<ICPUMesh>(ICPUMesh* _obj, uint32_t _headerIdx, io::IWriteFile* _file, SContext& _ctx)
{
uint8_t stackData[1u<<14];
- auto data = MeshBlobV2::createAndTryOnStack(_obj, stackData, sizeof(stackData));
+ auto data = MeshBlobV3::createAndTryOnStack(_obj, stackData, sizeof(stackData));
const E_WRITER_FLAGS flags = _ctx.writerOverride->getAssetWritingFlags(_ctx.inner, _obj, 0u);
const uint8_t* encrPwd = nullptr;
_ctx.writerOverride->getEncryptionKey(encrPwd, _ctx.inner, _obj, 0u);
const float comprLvl = _ctx.writerOverride->getAssetCompressionLevel(_ctx.inner, _obj, 0u);
- tryWrite(data, _file, _ctx, MeshBlobV2::calcBlobSizeForObj(_obj), _headerIdx, flags, encrPwd, comprLvl);
+ tryWrite(data, _file, _ctx, MeshBlobV3::calcBlobSizeForObj(_obj), _headerIdx, flags, encrPwd, comprLvl);
if ((uint8_t*)data != stackData)
_IRR_ALIGNED_FREE(data);
@@ -62,13 +62,13 @@ struct LzmaMemMngmnt
void CBAWMeshWriter::exportAsBlob<ICPUSkinnedMesh>(ICPUSkinnedMesh* _obj, uint32_t _headerIdx, io::IWriteFile* _file, SContext& _ctx)
{
uint8_t stackData[1u << 14];
- SkinnedMeshBlobV2* data = SkinnedMeshBlobV1::createAndTryOnStack(_obj,stackData,sizeof(stackData));
+ SkinnedMeshBlobV3* data = SkinnedMeshBlobV3::createAndTryOnStack(_obj,stackData,sizeof(stackData));
const E_WRITER_FLAGS flags = _ctx.writerOverride->getAssetWritingFlags(_ctx.inner, _obj, 0u);
const uint8_t* encrPwd = nullptr;
_ctx.writerOverride->getEncryptionKey(encrPwd, _ctx.inner, _obj, 0u);
const float comprLvl = _ctx.writerOverride->getAssetCompressionLevel(_ctx.inner, _obj, 0u);
- tryWrite(data, _file, _ctx, SkinnedMeshBlobV2::calcBlobSizeForObj(_obj), _headerIdx, flags, encrPwd, comprLvl);
+ tryWrite(data, _file, _ctx, SkinnedMeshBlobV3::calcBlobSizeForObj(_obj), _headerIdx, flags, encrPwd, comprLvl);
if ((uint8_t*)data != stackData)
_IRR_ALIGNED_FREE(data);
@@ -76,7 +76,7 @@ struct LzmaMemMngmnt
template<>
void CBAWMeshWriter::exportAsBlob<ICPUMeshBuffer>(ICPUMeshBuffer* _obj, uint32_t _headerIdx, io::IWriteFile* _file, SContext& _ctx)
{
- MeshBufferBlobV2 data(_obj);
+ MeshBufferBlobV3 data(_obj);
const E_WRITER_FLAGS flags = _ctx.writerOverride->getAssetWritingFlags(_ctx.inner, _obj, 1u);
const uint8_t* encrPwd = nullptr;
@@ -87,7 +87,7 @@ struct LzmaMemMngmnt
template<>
void CBAWMeshWriter::exportAsBlob<ICPUSkinnedMeshBuffer>(ICPUSkinnedMeshBuffer* _obj, uint32_t _headerIdx, io::IWriteFile* _file, SContext& _ctx)
{
- SkinnedMeshBufferBlobV2 data(_obj);
+ SkinnedMeshBufferBlobV3 data(_obj);
const E_WRITER_FLAGS flags = _ctx.writerOverride->getAssetWritingFlags(_ctx.inner, _obj, 1u);
const uint8_t* encrPwd = nullptr;
@@ -115,9 +115,9 @@ struct LzmaMemMngmnt
void CBAWMeshWriter::exportAsBlob<CFinalBoneHierarchy>(CFinalBoneHierarchy* _obj, uint32_t _headerIdx, io::IWriteFile* _file, SContext& _ctx)
{
uint8_t stackData[1u<<14]; // 16kB
- auto data = FinalBoneHierarchyBlobV2::createAndTryOnStack(_obj,stackData,sizeof(stackData));
+ auto data = FinalBoneHierarchyBlobV3::createAndTryOnStack(_obj,stackData,sizeof(stackData));
- tryWrite(data, _file, _ctx, FinalBoneHierarchyBlobV2::calcBlobSizeForObj(_obj), _headerIdx, EWF_NONE);
+ tryWrite(data, _file, _ctx, FinalBoneHierarchyBlobV3::calcBlobSizeForObj(_obj), _headerIdx, EWF_NONE);
if ((uint8_t*)data != stackData)
_IRR_ALIGNED_FREE(data);
@@ -125,7 +125,7 @@ struct LzmaMemMngmnt
template<>
void CBAWMeshWriter::exportAsBlob<IMeshDataFormatDesc<ICPUBuffer> >(IMeshDataFormatDesc<ICPUBuffer>* _obj, uint32_t _headerIdx, io::IWriteFile* _file, SContext& _ctx)
{
- MeshDataFormatDescBlobV2 data(_obj);
+ MeshDataFormatDescBlobV3 data(_obj);
tryWrite(&data, _file, _ctx, sizeof(data), _headerIdx, EWF_NONE);
}
@@ -154,7 +154,7 @@ struct LzmaMemMngmnt
const ICPUMesh* mesh = static_cast<const ICPUMesh*>(_params.rootAsset);
constexpr uint32_t FILE_HEADER_SIZE = 32;
- static_assert(FILE_HEADER_SIZE == sizeof(BAWFileV2::fileHeader), "BAW header is not 32 bytes long!");
+ static_assert(FILE_HEADER_SIZE == sizeof(BAWFileV3::fileHeader), "BAW header is not 32 bytes long!");
uint64_t header[4];
memcpy(header, BAW_FILE_HEADER, FILE_HEADER_SIZE);
@@ -165,7 +165,7 @@ struct LzmaMemMngmnt
SContext ctx{ IAssetWriter::SAssetWriteContext{_params, _file}, _override }; // context of this call of `writeMesh`
const uint32_t numOfInternalBlobs = genHeaders(mesh, ctx);
- const uint32_t OFFSETS_FILE_OFFSET = FILE_HEADER_SIZE + sizeof(uint32_t) + sizeof(BAWFileV2::iv);
+ const uint32_t OFFSETS_FILE_OFFSET = FILE_HEADER_SIZE + sizeof(uint32_t) + sizeof(BAWFileV3::iv);
const uint32_t HEADERS_FILE_OFFSET = OFFSETS_FILE_OFFSET + numOfInternalBlobs * sizeof(ctx.offsets[0]);
ctx.offsets.resize(numOfInternalBlobs);

diff:
@@ -127,6 +127,16 @@ using BlobHeaderV1 = BlobHeaderVn<1>;
using FinalBoneHierarchyBlobV1 = legacyv0::FinalBoneHierarchyBlobV0;
+}
+
+namespace legacyv2
+{
+
+
+using BAWFileV2 = BAWFileVn<2>;
+using BlobHeaderV2 = BlobHeaderVn<2>;
+
+
}
}


message: Make baw flipping, perform tests, move old conversion functions to CBAWVersionUpFunctions

diff:
@@ -101,6 +101,7 @@ set(IRRLICHT_SRCS_COMMON
# Other mesh-related stuff
${IRR_ROOT_PATH}/src/irr/asset/bawformat/CBAWFile.cpp
${IRR_ROOT_PATH}/src/irr/asset/bawformat/legacy/CBAWLegacy.cpp
+ ${IRR_ROOT_PATH}/src/irr/asset/bawformat/legacy/CBAWVersionUpFunctions.cpp
${IRR_ROOT_PATH}/src/irr/asset/bawformat/CBlobsLoadingManager.cpp
${IRR_ROOT_PATH}/src/irr/asset/CForsythVertexCacheOptimizer.cpp
${IRR_ROOT_PATH}/src/irr/asset/CSmoothNormalGenerator.cpp

diff:
#include "CFinalBoneHierarchy.h"
#include "irr/asset/IAssetManager.h"
#include "irr/asset/bawformat/legacy/CBAWLegacy.h"
+#include "irr/asset/bawformat/legacy/CBAWVersionUpFunctions.h"
#include "irr/video/CGPUMesh.h"
#include "irr/video/CGPUSkinnedMesh.h"
@@ -202,6 +203,30 @@ SAssetBundle CBAWMeshFileLoader::loadAsset(io::IReadFile* _file, const asset::IA
#endif // _IRR_DEBUG
asset::ICPUMesh* mesh = reinterpret_cast<asset::ICPUMesh*>(retval);
+
+ if(_params.loaderFlags & E_LOADER_PARAMETER_FLAGS::ELPF_RIGHT_HANDED_MESHES)
+ for (auto index = 0l; index < mesh->getMeshBufferCount(); ++index)
+ {
+ auto meshBuffer = mesh->getMeshBuffer(index);
+
+ for (auto pos = 0l; pos < meshBuffer->getIndexCount(); ++pos)
+ {
+ core::vectorSIMDf outPos(0.f, 0.f, 0.f, 1.f);
+ meshBuffer->getAttribute(outPos, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0, pos);
+
+ outPos.X = -outPos.X;
+ meshBuffer->setAttribute(outPos, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0, pos);
+
+ core::vectorSIMDf outNormal(0.f, 0.f, 0.f, 1.f);
+ bool status = meshBuffer->getAttribute(outNormal, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, pos);
+ if (status)
+ {
+ outNormal.X = -outNormal.X;
+ meshBuffer->setAttribute(outNormal, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, pos);
+ }
+ }
+ }
+
return SAssetBundle({core::smart_refctd_ptr<asset::IAsset>(mesh,core::dont_grab)});
}
@@ -231,6 +256,10 @@ bool CBAWMeshFileLoader::decompressLz4(void * _dst, size_t _dstSize, const void
return res >= 0;
}
+// Always keep the latest version of converting function to the newest one here
+// If you write new one, put the old definition to CBAWVersionUpFunctions.cpp and
+// the declaration to CBAWVersionUpFunctions.h
+
template<>
io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx, io::IReadFile* _baw2file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<2>& _common)
{
@@ -253,20 +282,20 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx,
newoffset = offset + offsetDiff;
- if (hdr.blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
- {
- const uint32_t offset = offsets[i];
-
uint8_t stackmem[1u << 10];
uint32_t attempt = 0u;
uint8_t decrKey[16];
size_t decrKeyLen = 16u;
+
void* blob = nullptr;
+
/* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
however we don't need to do this here since we know format's version (baw v1) and so we can be sure that hierarchy level for FinalBoneHierarchy is 3 (won't be true for v2 to v3 conversion)
*/
- constexpr uint32_t FINALBONEHIERARCHY_HIERARCHY_LVL = 3u;
- while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw2file, "", genSubAssetCacheKey(_baw2file->getFileName().c_str(), hdr.handle), _ctx.inner, FINALBONEHIERARCHY_HIERARCHY_LVL))
+
+ auto fetchRawBlob = [&](uint32_t hierarchyLevel)
+ {
+ while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw2file, "", genSubAssetCacheKey(_baw2file->getFileName().c_str(), hdr.handle), _ctx.inner, hierarchyLevel))
{
if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
blob = tryReadBlobOnStack<asset::legacyv2::BlobHeaderV2>(SBlobData_t<asset::legacyv2::BlobHeaderV2>(&hdr, baseOffsetv2 + offset), _ctx, decrKey, stackmem, sizeof(stackmem));
@@ -274,9 +303,40 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx,
break;
++attempt;
}
+ };
+
+ // should I actually do anything with meshes if their flipping is dependent on flag placed somewhere in IAssetLoader/Writer?
+ // so it isn't a member of any of blobs
+
+ switch (hdr.blobType)
+ {
+ case asset::Blob::EBT_FINAL_BONE_HIERARCHY:
+ {
+ constexpr uint32_t FINALBONEHIERARCHY_HIERARCHY_LVL = 3u;
+ fetchRawBlob(FINALBONEHIERARCHY_HIERARCHY_LVL);
+ break;
+ }
+ /*case asset::Blob::EBT_SKINNED_MESH:
+ {
+ constexpr uint32_t SKINNED_MESH_HIERARCHY_LVL = 0; // what's it's hierarchy lvl?
+ fetchRawBlob(SKINNED_MESH_HIERARCHY_LVL);
+ auto skinnedMeshBlob = reinterpret_cast<asset::SkinnedMeshBlobV2*>(blob);
+
+ // flip if
+
+ break;
+ }
+ case asset::Blob::EBT_MESH:
+ {
+ constexpr uint32_t MESH_HIERARCHY_LVL = 1; // what's it's hierarchy lvl?
+ fetchRawBlob(MESH_HIERARCHY_LVL);
+ auto meshBlob = reinterpret_cast<asset::MeshBlobV2*>(blob);
+
+ // flip if
- // patch for meshbuffer blob
- // TODO
+ break;
+ }*/
+ }
offsetDiff += static_cast<int32_t>(hdr.blobSizeDecompr) - static_cast<int32_t>(hdr.effectiveSize());
hdr.compressionType = asset::Blob::EBCT_RAW;
@@ -286,7 +346,6 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx,
if (blob)
_IRR_ALIGNED_FREE(blob);
}
- }
uint64_t fileHeader[4]{ 0u, 0u, 0u, 2u/*baw v2*/ };
memcpy(fileHeader, BAWFileV3::HEADER_STRING, strlen(BAWFileV3::HEADER_STRING));
baw3mem->seek(0u);
@@ -334,247 +393,4 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx,
return ret;
}
-//! These should be moved to some legacy baw loader .cpp file
-template<>
-io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<2>(SContext& _ctx, io::IReadFile* _baw1file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<1>& _common)
-{
- uint32_t blobCnt{};
- asset::legacyv1::BlobHeaderV1* headers = nullptr;
- uint32_t* offsets = nullptr;
- uint32_t baseOffsetv1{};
- uint32_t baseOffsetv2{};
- std::tie(blobCnt, headers, offsets, baseOffsetv1, baseOffsetv2) = _common;
-
- io::CMemoryWriteFile* const baw2mem = new io::CMemoryWriteFile(0u, _baw1file->getFileName());
-
- std::vector<uint32_t> newoffsets(blobCnt);
- int32_t offsetDiff = 0;
- for (uint32_t i = 0u; i < blobCnt; ++i)
- {
- asset::legacyv1::BlobHeaderV1& hdr = headers[i];
- const uint32_t offset = offsets[i];
- uint32_t& newoffset = newoffsets[i];
-
- newoffset = offset + offsetDiff;
-
- if (hdr.blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
- {
- const uint32_t offset = offsets[i];
-
- uint8_t stackmem[1u<<10];
- uint32_t attempt = 0u;
- uint8_t decrKey[16];
- size_t decrKeyLen = 16u;
- void* blob = nullptr;
- /* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
- however we don't need to do this here since we know format's version (baw v1) and so we can be sure that hierarchy level for FinalBoneHierarchy is 3 (won't be true for v2 to v3 conversion)
- */
- constexpr uint32_t FINALBONEHIERARCHY_HIERARCHY_LVL = 3u;
- while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw1file, "", genSubAssetCacheKey(_baw1file->getFileName().c_str(), hdr.handle), _ctx.inner, FINALBONEHIERARCHY_HIERARCHY_LVL))
- {
- if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
- blob = tryReadBlobOnStack<asset::legacyv1::BlobHeaderV1>(SBlobData_t<asset::legacyv1::BlobHeaderV1>(&hdr, baseOffsetv1+offset), _ctx, decrKey, stackmem, sizeof(stackmem));
- if (blob)
- break;
- ++attempt;
- }
-
- // patch the blob
- if (blob)
- {
- auto* hierarchy = reinterpret_cast<legacyv1::FinalBoneHierarchyBlobV1*>(blob);
-
- auto bones = hierarchy->getBoneData();
- for (auto j=0u; j<hierarchy->boneCount; j++)
- {
- core::matrix3x4SIMD mtx = bones[j].PoseBindMatrix;
- const auto* in = mtx.rows[0].pointer;
- auto* out = bones[j].PoseBindMatrix.rows[0].pointer;
- out[0] = in[0];
- out[4] = in[1];
- out[8] = in[2];
- out[1] = in[3];
- out[5] = in[4];
- out[9] = in[5];
- out[2] = in[6];
- out[6] = in[7];
- out[10] = in[8];
- out[3] = in[9];
- out[7] = in[10];
- out[11] = in[11];
- }
-
- const uint32_t absOffset = baseOffsetv2 + newoffset;
- baw2mem->seek(absOffset);
- baw2mem->write(blob, hdr.blobSizeDecompr);
- }
- else
- baw2mem->seek(baseOffsetv2 + newoffset + hdr.blobSizeDecompr);
-
- offsetDiff += static_cast<int32_t>(hdr.blobSizeDecompr) - static_cast<int32_t>(hdr.effectiveSize());
- hdr.compressionType = asset::Blob::EBCT_RAW;
- core::XXHash_256(blob, hdr.blobSizeDecompr, hdr.blobHash);
- hdr.blobSize = hdr.blobSizeDecompr;
-
- if (blob)
- _IRR_ALIGNED_FREE(blob);
- }
- }
- uint64_t fileHeader[4] {0u, 0u, 0u, 2u/*baw v2*/};
- memcpy(fileHeader, asset::legacyv2::BAWFileV2::HEADER_STRING, strlen(asset::legacyv2::BAWFileV2::HEADER_STRING));
- baw2mem->seek(0u);
- baw2mem->write(fileHeader, sizeof(fileHeader));
- baw2mem->write(&blobCnt, 4);
- baw2mem->write(_ctx.iv, 16);
- baw2mem->write(newoffsets.data(), newoffsets.size()*4);
- baw2mem->write(headers, blobCnt*sizeof(headers[0])); // blob header in v1 and in v2 is exact same thing, so we can do this
-
- uint8_t stackmem[1u<<13]{};
- size_t newFileSz = 0u;
- for (uint32_t i = 0u; i < blobCnt; ++i)
- {
- uint32_t sz = headers[i].effectiveSize();
- void* blob = nullptr;
- if (headers[i].blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
- {
- sz = 0u;
- }
- else
- {
- _baw1file->seek(baseOffsetv1 + offsets[i]);
- if (sz <= sizeof(stackmem))
- blob = stackmem;
- else
- blob = _IRR_ALIGNED_MALLOC(sz, _IRR_SIMD_ALIGNMENT);
-
- _baw1file->read(blob, sz);
- }
-
- baw2mem->seek(baseOffsetv2 + newoffsets[i]);
- baw2mem->write(blob, sz);
-
- if (headers[i].blobType != asset::Blob::EBT_DATA_FORMAT_DESC && blob != stackmem)
- _IRR_ALIGNED_FREE(blob);
-
- newFileSz = baseOffsetv2 + newoffsets[i] + sz;
- }
-
- _IRR_ALIGNED_FREE(offsets);
- _IRR_ALIGNED_FREE(headers);
-
- auto ret = new io::CMemoryReadFile(baw2mem->getPointer(), baw2mem->getSize(), _baw1file->getFileName());
- baw2mem->drop();
- return ret;
-}
-
-
-template<>
-io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<1>(SContext& _ctx, io::IReadFile* _baw0file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<0>& _common)
-{
- uint32_t blobCnt{};
- asset::legacyv0::BlobHeaderV0* headers = nullptr;
- uint32_t* offsets = nullptr;
- uint32_t baseOffsetv0{};
- uint32_t baseOffsetv1{};
- std::tie(blobCnt, headers, offsets, baseOffsetv0, baseOffsetv1) = _common;
-
- io::CMemoryWriteFile* const baw1mem = new io::CMemoryWriteFile(0u, _baw0file->getFileName());
-
- std::vector<uint32_t> newoffsets(blobCnt);
- int32_t offsetDiff = 0;
- for (uint32_t i = 0u; i < blobCnt; ++i)
- {
- asset::legacyv0::BlobHeaderV0& hdr = headers[i];
- const uint32_t offset = offsets[i];
- uint32_t& newoffset = newoffsets[i];
-
- newoffset = offset + offsetDiff;
-
- bool adjustDiff = false;
- uint32_t prevBlobSz{};
- if (hdr.blobType == asset::Blob::EBT_DATA_FORMAT_DESC)
- {
- uint8_t stackmem[1u<<10];
- uint32_t attempt = 0u;
- uint8_t decrKey[16];
- size_t decrKeyLen = 16u;
- void* blob = nullptr;
- /* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
- however we don't need to do this here since we know format's version (baw v0) and so we can be sure that hierarchy level for mesh data descriptors is 2
- */
- constexpr uint32_t ICPUMESHDATAFORMATDESC_HIERARCHY_LVL = 2u;
- while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw0file, "", genSubAssetCacheKey(_baw0file->getFileName().c_str(), hdr.handle), _ctx.inner, ICPUMESHDATAFORMATDESC_HIERARCHY_LVL))
- {
- if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
- blob = tryReadBlobOnStack<asset::legacyv0::BlobHeaderV0>(SBlobData_t<asset::legacyv0::BlobHeaderV0>(&hdr, baseOffsetv0+offset), _ctx, decrKey, stackmem, sizeof(stackmem));
- if (blob)
- break;
- ++attempt;
- }
- assert(!blob || blob==stackmem); // its a fixed size blob so should always use stack
-
- const uint32_t absOffset = baseOffsetv1 + newoffset;
- baw1mem->seek(absOffset);
- baw1mem->write(
- asset::MeshDataFormatDescBlobV1(reinterpret_cast<asset::legacyv0::MeshDataFormatDescBlobV0*>(blob)[0]).getData(),
- sizeof(asset::MeshDataFormatDescBlobV1)
- );
-
- prevBlobSz = hdr.effectiveSize();
- hdr.compressionType = asset::Blob::EBCT_RAW;
- core::XXHash_256(reinterpret_cast<uint8_t*>(baw1mem->getPointer())+absOffset, sizeof(asset::MeshDataFormatDescBlobV1), hdr.blobHash);
- hdr.blobSizeDecompr = hdr.blobSize = sizeof(asset::MeshDataFormatDescBlobV1);
-
- adjustDiff = true;
- }
- if (adjustDiff)
- offsetDiff += static_cast<int32_t>(sizeof(asset::MeshDataFormatDescBlobV1)) - static_cast<int32_t>(prevBlobSz);
- }
- uint64_t fileHeader[4] {0u, 0u, 0u, 1u/*baw v1*/};
- memcpy(fileHeader, asset::legacyv1::BAWFileV1::HEADER_STRING, strlen(asset::legacyv1::BAWFileV1::HEADER_STRING));
- baw1mem->seek(0u);
- baw1mem->write(fileHeader, sizeof(fileHeader));
- baw1mem->write(&blobCnt, 4);
- baw1mem->write(_ctx.iv, 16);
- baw1mem->write(newoffsets.data(), newoffsets.size()*4);
- baw1mem->write(headers, blobCnt*sizeof(headers[0])); // blob header in v0 and in v1 is exact same thing, so we can do this
-
- uint8_t stackmem[1u<<13]{};
- size_t newFileSz = 0u;
- for (uint32_t i = 0u; i < blobCnt; ++i)
- {
- uint32_t sz = headers[i].effectiveSize();
- void* blob = nullptr;
- if (headers[i].blobType == asset::Blob::EBT_DATA_FORMAT_DESC)
- {
- sz = 0u;
- }
- else
- {
- _baw0file->seek(baseOffsetv0 + offsets[i]);
- if (sz <= sizeof(stackmem))
- blob = stackmem;
- else
- blob = _IRR_ALIGNED_MALLOC(sz, _IRR_SIMD_ALIGNMENT);
-
- _baw0file->read(blob, sz);
- }
-
- baw1mem->seek(baseOffsetv1 + newoffsets[i]);
- baw1mem->write(blob, sz);
-
- if (headers[i].blobType != asset::Blob::EBT_DATA_FORMAT_DESC && blob != stackmem)
- _IRR_ALIGNED_FREE(blob);
-
- newFileSz = baseOffsetv1 + newoffsets[i] + sz;
- }
-
- _IRR_ALIGNED_FREE(offsets);
- _IRR_ALIGNED_FREE(headers);
-
- auto ret = new io::CMemoryReadFile(baw1mem->getPointer(), baw1mem->getSize(), _baw0file->getFileName());
- baw1mem->drop();
- return ret;
-}
-
}} // irr::scene

diff:
@@ -88,6 +88,12 @@ private:
unsigned char iv[16];
};
+ template<typename aType>
+ static inline void performActionBasedOnOrientationSystem(aType& varToHandle, void (*performOnCertainOrientation)(aType& varToHandle))
+ {
+ performOnCertainOrientation(varToHandle);
+ }
+
protected:
//! Destructor
virtual ~CBAWMeshFileLoader();

diff:
@@ -153,6 +153,29 @@ struct LzmaMemMngmnt
const ICPUMesh* mesh = static_cast<const ICPUMesh*>(_params.rootAsset);
+ if (!(_params.writerFlags & IAssetWriter::EWPF_MESH_IS_RIGHT_HANDED))
+ for (auto index = 0l; index < mesh->getMeshBufferCount(); ++index)
+ {
+ auto meshBuffer = mesh->getMeshBuffer(index);
+
+ for (auto pos = 0l; pos < meshBuffer->getIndexCount(); ++pos)
+ {
+ core::vectorSIMDf outPos(0.f, 0.f, 0.f, 1.f);
+ meshBuffer->getAttribute(outPos, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0, pos);
+
+ outPos.X = -outPos.X;
+ meshBuffer->setAttribute(outPos, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0, pos);
+
+ core::vectorSIMDf outNormal(0.f, 0.f, 0.f, 1.f);
+ bool status = meshBuffer->getAttribute(outNormal, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, pos);
+ if (status)
+ {
+ outNormal.X = -outNormal.X;
+ meshBuffer->setAttribute(outNormal, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, pos);
+ }
+ }
+ }
+
constexpr uint32_t FILE_HEADER_SIZE = 32;
static_assert(FILE_HEADER_SIZE == sizeof(BAWFileV3::fileHeader), "BAW header is not 32 bytes long!");

change_type: ADD

diff:
+#include "CBAWVersionUpFunctions.h"
+
+namespace irr
+{
+ namespace asset
+ {
+ template<>
+ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<2>(SContext& _ctx, io::IReadFile* _baw1file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<1>& _common)
+ {
+ uint32_t blobCnt{};
+ asset::legacyv1::BlobHeaderV1* headers = nullptr;
+ uint32_t* offsets = nullptr;
+ uint32_t baseOffsetv1{};
+ uint32_t baseOffsetv2{};
+ std::tie(blobCnt, headers, offsets, baseOffsetv1, baseOffsetv2) = _common;
+
+ io::CMemoryWriteFile* const baw2mem = new io::CMemoryWriteFile(0u, _baw1file->getFileName());
+
+ std::vector<uint32_t> newoffsets(blobCnt);
+ int32_t offsetDiff = 0;
+ for (uint32_t i = 0u; i < blobCnt; ++i)
+ {
+ asset::legacyv1::BlobHeaderV1& hdr = headers[i];
+ const uint32_t offset = offsets[i];
+ uint32_t& newoffset = newoffsets[i];
+
+ newoffset = offset + offsetDiff;
+
+ if (hdr.blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
+ {
+ const uint32_t offset = offsets[i];
+
+ uint8_t stackmem[1u << 10];
+ uint32_t attempt = 0u;
+ uint8_t decrKey[16];
+ size_t decrKeyLen = 16u;
+ void* blob = nullptr;
+ /* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
+ however we don't need to do this here since we know format's version (baw v1) and so we can be sure that hierarchy level for FinalBoneHierarchy is 3 (won't be true for v2 to v3 conversion)
+ */
+ constexpr uint32_t FINALBONEHIERARCHY_HIERARCHY_LVL = 3u;
+ while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw1file, "", genSubAssetCacheKey(_baw1file->getFileName().c_str(), hdr.handle), _ctx.inner, FINALBONEHIERARCHY_HIERARCHY_LVL))
+ {
+ if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
+ blob = tryReadBlobOnStack<asset::legacyv1::BlobHeaderV1>(SBlobData_t<asset::legacyv1::BlobHeaderV1>(&hdr, baseOffsetv1 + offset), _ctx, decrKey, stackmem, sizeof(stackmem));
+ if (blob)
+ break;
+ ++attempt;
+ }
+
+ // patch the blob
+ if (blob)
+ {
+ auto* hierarchy = reinterpret_cast<legacyv1::FinalBoneHierarchyBlobV1*>(blob);
+
+ auto bones = hierarchy->getBoneData();
+ for (auto j = 0u; j < hierarchy->boneCount; j++)
+ {
+ core::matrix3x4SIMD mtx = bones[j].PoseBindMatrix;
+ const auto* in = mtx.rows[0].pointer;
+ auto* out = bones[j].PoseBindMatrix.rows[0].pointer;
+ out[0] = in[0];
+ out[4] = in[1];
+ out[8] = in[2];
+ out[1] = in[3];
+ out[5] = in[4];
+ out[9] = in[5];
+ out[2] = in[6];
+ out[6] = in[7];
+ out[10] = in[8];
+ out[3] = in[9];
+ out[7] = in[10];
+ out[11] = in[11];
+ }
+
+ const uint32_t absOffset = baseOffsetv2 + newoffset;
+ baw2mem->seek(absOffset);
+ baw2mem->write(blob, hdr.blobSizeDecompr);
+ }
+ else
+ baw2mem->seek(baseOffsetv2 + newoffset + hdr.blobSizeDecompr);
+
+ offsetDiff += static_cast<int32_t>(hdr.blobSizeDecompr) - static_cast<int32_t>(hdr.effectiveSize());
+ hdr.compressionType = asset::Blob::EBCT_RAW;
+ core::XXHash_256(blob, hdr.blobSizeDecompr, hdr.blobHash);
+ hdr.blobSize = hdr.blobSizeDecompr;
+
+ if (blob)
+ _IRR_ALIGNED_FREE(blob);
+ }
+ }
+ uint64_t fileHeader[4]{ 0u, 0u, 0u, 2u/*baw v2*/ };
+ memcpy(fileHeader, asset::legacyv2::BAWFileV2::HEADER_STRING, strlen(asset::legacyv2::BAWFileV2::HEADER_STRING));
+ baw2mem->seek(0u);
+ baw2mem->write(fileHeader, sizeof(fileHeader));
+ baw2mem->write(&blobCnt, 4);
+ baw2mem->write(_ctx.iv, 16);
+ baw2mem->write(newoffsets.data(), newoffsets.size() * 4);
+ baw2mem->write(headers, blobCnt * sizeof(headers[0])); // blob header in v1 and in v2 is exact same thing, so we can do this
+
+ uint8_t stackmem[1u << 13]{};
+ size_t newFileSz = 0u;
+ for (uint32_t i = 0u; i < blobCnt; ++i)
+ {
+ uint32_t sz = headers[i].effectiveSize();
+ void* blob = nullptr;
+ if (headers[i].blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
+ {
+ sz = 0u;
+ }
+ else
+ {
+ _baw1file->seek(baseOffsetv1 + offsets[i]);
+ if (sz <= sizeof(stackmem))
+ blob = stackmem;
+ else
+ blob = _IRR_ALIGNED_MALLOC(sz, _IRR_SIMD_ALIGNMENT);
+
+ _baw1file->read(blob, sz);
+ }
+
+ baw2mem->seek(baseOffsetv2 + newoffsets[i]);
+ baw2mem->write(blob, sz);
+
+ if (headers[i].blobType != asset::Blob::EBT_DATA_FORMAT_DESC && blob != stackmem)
+ _IRR_ALIGNED_FREE(blob);
+
+ newFileSz = baseOffsetv2 + newoffsets[i] + sz;
+ }
+
+ _IRR_ALIGNED_FREE(offsets);
+ _IRR_ALIGNED_FREE(headers);
+
+ auto ret = new io::CMemoryReadFile(baw2mem->getPointer(), baw2mem->getSize(), _baw1file->getFileName());
+ baw2mem->drop();
+ return ret;
+ }
+
+ template<>
+ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<1>(SContext& _ctx, io::IReadFile* _baw0file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<0>& _common)
+ {
+ uint32_t blobCnt{};
+ asset::legacyv0::BlobHeaderV0* headers = nullptr;
+ uint32_t* offsets = nullptr;
+ uint32_t baseOffsetv0{};
+ uint32_t baseOffsetv1{};
+ std::tie(blobCnt, headers, offsets, baseOffsetv0, baseOffsetv1) = _common;
+
+ io::CMemoryWriteFile* const baw1mem = new io::CMemoryWriteFile(0u, _baw0file->getFileName());
+
+ std::vector<uint32_t> newoffsets(blobCnt);
+ int32_t offsetDiff = 0;
+ for (uint32_t i = 0u; i < blobCnt; ++i)
+ {
+ asset::legacyv0::BlobHeaderV0& hdr = headers[i];
+ const uint32_t offset = offsets[i];
+ uint32_t& newoffset = newoffsets[i];
+
+ newoffset = offset + offsetDiff;
+
+ bool adjustDiff = false;
+ uint32_t prevBlobSz{};
+ if (hdr.blobType == asset::Blob::EBT_DATA_FORMAT_DESC)
+ {
+ uint8_t stackmem[1u << 10];
+ uint32_t attempt = 0u;
+ uint8_t decrKey[16];
+ size_t decrKeyLen = 16u;
+ void* blob = nullptr;
+ /* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
+ however we don't need to do this here since we know format's version (baw v0) and so we can be sure that hierarchy level for mesh data descriptors is 2
+ */
+ constexpr uint32_t ICPUMESHDATAFORMATDESC_HIERARCHY_LVL = 2u;
+ while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw0file, "", genSubAssetCacheKey(_baw0file->getFileName().c_str(), hdr.handle), _ctx.inner, ICPUMESHDATAFORMATDESC_HIERARCHY_LVL))
+ {
+ if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
+ blob = tryReadBlobOnStack<asset::legacyv0::BlobHeaderV0>(SBlobData_t<asset::legacyv0::BlobHeaderV0>(&hdr, baseOffsetv0 + offset), _ctx, decrKey, stackmem, sizeof(stackmem));
+ if (blob)
+ break;
+ ++attempt;
+ }
+ assert(!blob || blob == stackmem); // its a fixed size blob so should always use stack
+
+ const uint32_t absOffset = baseOffsetv1 + newoffset;
+ baw1mem->seek(absOffset);
+ baw1mem->write(
+ asset::MeshDataFormatDescBlobV1(reinterpret_cast<asset::legacyv0::MeshDataFormatDescBlobV0*>(blob)[0]).getData(),
+ sizeof(asset::MeshDataFormatDescBlobV1)
+ );
+
+ prevBlobSz = hdr.effectiveSize();
+ hdr.compressionType = asset::Blob::EBCT_RAW;
+ core::XXHash_256(reinterpret_cast<uint8_t*>(baw1mem->getPointer()) + absOffset, sizeof(asset::MeshDataFormatDescBlobV1), hdr.blobHash);
+ hdr.blobSizeDecompr = hdr.blobSize = sizeof(asset::MeshDataFormatDescBlobV1);
+
+ adjustDiff = true;
+ }
+ if (adjustDiff)
+ offsetDiff += static_cast<int32_t>(sizeof(asset::MeshDataFormatDescBlobV1)) - static_cast<int32_t>(prevBlobSz);
+ }
+ uint64_t fileHeader[4]{ 0u, 0u, 0u, 1u/*baw v1*/ };
+ memcpy(fileHeader, asset::legacyv1::BAWFileV1::HEADER_STRING, strlen(asset::legacyv1::BAWFileV1::HEADER_STRING));
+ baw1mem->seek(0u);
+ baw1mem->write(fileHeader, sizeof(fileHeader));
+ baw1mem->write(&blobCnt, 4);
+ baw1mem->write(_ctx.iv, 16);
+ baw1mem->write(newoffsets.data(), newoffsets.size() * 4);
+ baw1mem->write(headers, blobCnt * sizeof(headers[0])); // blob header in v0 and in v1 is exact same thing, so we can do this
+
+ uint8_t stackmem[1u << 13]{};
+ size_t newFileSz = 0u;
+ for (uint32_t i = 0u; i < blobCnt; ++i)
+ {
+ uint32_t sz = headers[i].effectiveSize();
+ void* blob = nullptr;
+ if (headers[i].blobType == asset::Blob::EBT_DATA_FORMAT_DESC)
+ {
+ sz = 0u;
+ }
+ else
+ {
+ _baw0file->seek(baseOffsetv0 + offsets[i]);
+ if (sz <= sizeof(stackmem))
+ blob = stackmem;
+ else
+ blob = _IRR_ALIGNED_MALLOC(sz, _IRR_SIMD_ALIGNMENT);
+
+ _baw0file->read(blob, sz);
+ }
+
+ baw1mem->seek(baseOffsetv1 + newoffsets[i]);
+ baw1mem->write(blob, sz);
+
+ if (headers[i].blobType != asset::Blob::EBT_DATA_FORMAT_DESC && blob != stackmem)
+ _IRR_ALIGNED_FREE(blob);
+
+ newFileSz = baseOffsetv1 + newoffsets[i] + sz;
+ }
+
+ _IRR_ALIGNED_FREE(offsets);
+ _IRR_ALIGNED_FREE(headers);
+
+ auto ret = new io::CMemoryReadFile(baw1mem->getPointer(), baw1mem->getSize(), _baw0file->getFileName());
+ baw1mem->drop();
+ return ret;
+ }
+
+ }
+}
\ No newline at end of file

diff:
+namespace irr
+{
+ namespace asset
+ {
+ template<> // V1 to V2 conversion
+ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<2>(SContext& _ctx, io::IReadFile* _baw1file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<1>& _common);
+
+ template<> // V0 to V1 conversion
+ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<1>(SContext& _ctx, io::IReadFile* _baw0file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<0>& _common);
+ }
+}
\ No newline at end of file


message: Go back to beginning, bump meshbuffer to v3, create converting constructor

diff:
#ifndef __IRR_MESH_BUFFER_BLOB_H_INCLUDED__
#define __IRR_MESH_BUFFER_BLOB_H_INCLUDED__
-
namespace irr
{
namespace asset
{
+namespace legacyv2
+{
+ struct MeshBufferBlobV2;
+}
+
class ICPUMeshBuffer;
#include "irr/irrpack.h"
//! Simple struct of essential data of ICPUMeshBuffer that has to be exported
-struct IRR_FORCE_EBO MeshBufferBlobV0 : TypedBlob<MeshBufferBlobV0, ICPUMeshBuffer>, FixedSizeBlob<MeshBufferBlobV0, ICPUMeshBuffer>
+struct IRR_FORCE_EBO MeshBufferBlobV3 : TypedBlob<MeshBufferBlobV3, ICPUMeshBuffer>, FixedSizeBlob<MeshBufferBlobV3, ICPUMeshBuffer>
{
//! Constructor filling all members
- explicit MeshBufferBlobV0(const ICPUMeshBuffer*);
+ explicit MeshBufferBlobV3(const ICPUMeshBuffer*);
+ explicit MeshBufferBlobV3(const legacyv2::MeshBufferBlobV2* meshBufferV2);
video::SCPUMaterial mat;
core::aabbox3df box;
@@ -32,22 +37,18 @@ struct IRR_FORCE_EBO MeshBufferBlobV0 : TypedBlob<MeshBufferBlobV0, ICPUMeshBuff
uint32_t baseInstance;
uint32_t primitiveType;
uint32_t posAttrId;
+ bool isRightHandedCoordinateSystem;
} PACK_STRUCT;
#include "irr/irrunpack.h"
-static_assert(sizeof(MeshBufferBlobV0::mat)==197, "sizeof(MeshBufferBlobV0::mat) must be 197");
+static_assert(sizeof(MeshBufferBlobV3::mat)==197, "sizeof(MeshBufferBlobV0::mat) must be 197");
static_assert(
- sizeof(MeshBufferBlobV0) ==
- sizeof(MeshBufferBlobV0::mat) + sizeof(MeshBufferBlobV0::box) + sizeof(MeshBufferBlobV0::descPtr) + sizeof(MeshBufferBlobV0::indexType) + sizeof(MeshBufferBlobV0::baseVertex)
- + sizeof(MeshBufferBlobV0::indexCount) + sizeof(MeshBufferBlobV0::indexBufOffset) + sizeof(MeshBufferBlobV0::instanceCount) + sizeof(MeshBufferBlobV0::baseInstance)
- + sizeof(MeshBufferBlobV0::primitiveType) + sizeof(MeshBufferBlobV0::posAttrId),
+ sizeof(MeshBufferBlobV3) ==
+ sizeof(MeshBufferBlobV3::mat) + sizeof(MeshBufferBlobV3::box) + sizeof(MeshBufferBlobV3::descPtr) + sizeof(MeshBufferBlobV3::indexType) + sizeof(MeshBufferBlobV3::baseVertex)
+ + sizeof(MeshBufferBlobV3::indexCount) + sizeof(MeshBufferBlobV3::indexBufOffset) + sizeof(MeshBufferBlobV3::instanceCount) + sizeof(MeshBufferBlobV3::baseInstance)
+ + sizeof(MeshBufferBlobV3::primitiveType) + sizeof(MeshBufferBlobV3::posAttrId) + sizeof(MeshBufferBlobV3::isRightHandedCoordinateSystem),
"MeshBufferBlobV0: Size of blob is not sum of its contents!"
);
-using MeshBufferBlobV1 = MeshBufferBlobV0;
-using MeshBufferBlobV2 = MeshBufferBlobV1;
-using MeshBufferBlobV3 = MeshBufferBlobV2;
-
-
template<>
struct CorrespondingBlobTypeFor<ICPUMeshBuffer> { typedef MeshBufferBlobV3 type; };

diff:
#include "CFinalBoneHierarchy.h"
#include "irr/asset/IAssetManager.h"
#include "irr/asset/bawformat/legacy/CBAWLegacy.h"
+#include "irr/asset/bawformat/legacy/CBAWVersionUpFunctions.h"
#include "irr/video/CGPUMesh.h"
#include "irr/video/CGPUSkinnedMesh.h"
@@ -202,6 +203,32 @@ SAssetBundle CBAWMeshFileLoader::loadAsset(io::IReadFile* _file, const asset::IA
#endif // _IRR_DEBUG
asset::ICPUMesh* mesh = reinterpret_cast<asset::ICPUMesh*>(retval);
+
+ /* TO CHANGE A LITTLE BIT
+ if (_params.loaderFlags & E_LOADER_PARAMETER_FLAGS::ELPF_RIGHT_HANDED_MESHES)
+ for (auto index = 0l; index < mesh->getMeshBufferCount(); ++index)
+ {
+ auto meshBuffer = mesh->getMeshBuffer(index);
+
+ for (auto pos = 0l; pos < meshBuffer->getIndexCount(); ++pos)
+ {
+ core::vectorSIMDf outPos(0.f, 0.f, 0.f, 1.f);
+ meshBuffer->getAttribute(outPos, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0, pos);
+
+ outPos.X = -outPos.X;
+ meshBuffer->setAttribute(outPos, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0, pos);
+
+ core::vectorSIMDf outNormal(0.f, 0.f, 0.f, 1.f);
+ bool status = meshBuffer->getAttribute(outNormal, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, pos);
+ if (status)
+ {
+ outNormal.X = -outNormal.X;
+ meshBuffer->setAttribute(outNormal, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, pos);
+ }
+ }
+ }
+ */
+
return SAssetBundle({core::smart_refctd_ptr<asset::IAsset>(mesh,core::dont_grab)});
}
@@ -231,6 +258,10 @@ bool CBAWMeshFileLoader::decompressLz4(void * _dst, size_t _dstSize, const void
return res >= 0;
}
+// Always keep the latest version of converting function to the newest one here
+// If you write new one, put the old definition to CBAWVersionUpFunctions.cpp and
+// the declaration to CBAWVersionUpFunctions.h
+
template<>
io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx, io::IReadFile* _baw2file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<2>& _common)
{
@@ -253,20 +284,20 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx,
newoffset = offset + offsetDiff;
- if (hdr.blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
- {
- const uint32_t offset = offsets[i];
-
uint8_t stackmem[1u << 10];
uint32_t attempt = 0u;
uint8_t decrKey[16];
size_t decrKeyLen = 16u;
+
void* blob = nullptr;
+
/* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
however we don't need to do this here since we know format's version (baw v1) and so we can be sure that hierarchy level for FinalBoneHierarchy is 3 (won't be true for v2 to v3 conversion)
*/
- constexpr uint32_t FINALBONEHIERARCHY_HIERARCHY_LVL = 3u;
- while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw2file, "", genSubAssetCacheKey(_baw2file->getFileName().c_str(), hdr.handle), _ctx.inner, FINALBONEHIERARCHY_HIERARCHY_LVL))
+
+ auto fetchRawBlob = [&](uint32_t hierarchyLevel)
+ {
+ while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw2file, "", genSubAssetCacheKey(_baw2file->getFileName().c_str(), hdr.handle), _ctx.inner, hierarchyLevel))
{
if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
blob = tryReadBlobOnStack<asset::legacyv2::BlobHeaderV2>(SBlobData_t<asset::legacyv2::BlobHeaderV2>(&hdr, baseOffsetv2 + offset), _ctx, decrKey, stackmem, sizeof(stackmem));
@@ -274,9 +305,20 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx,
break;
++attempt;
}
+ };
- // patch for meshbuffer blob
- // TODO
+ // should I actually do anything with meshes if their flipping is dependent on flag placed somewhere in IAssetLoader/Writer?
+ // so it isn't a member of any of blobs
+
+ switch (hdr.blobType)
+ {
+ case asset::Blob::EBT_MESH_BUFFER:
+ {
+ constexpr uint32_t MESH_BUFFER_HIERARCHY_LVL = 3u;
+ fetchRawBlob(MESH_BUFFER_HIERARCHY_LVL);
+ break;
+ }
+ }
offsetDiff += static_cast<int32_t>(hdr.blobSizeDecompr) - static_cast<int32_t>(hdr.effectiveSize());
hdr.compressionType = asset::Blob::EBCT_RAW;
@@ -286,7 +328,6 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx,
if (blob)
_IRR_ALIGNED_FREE(blob);
}
- }
uint64_t fileHeader[4]{ 0u, 0u, 0u, 2u/*baw v2*/ };
memcpy(fileHeader, BAWFileV3::HEADER_STRING, strlen(BAWFileV3::HEADER_STRING));
baw3mem->seek(0u);
@@ -334,247 +375,4 @@ io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<3>(SContext& _ctx,
return ret;
}
-//! These should be moved to some legacy baw loader .cpp file
-template<>
-io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<2>(SContext& _ctx, io::IReadFile* _baw1file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<1>& _common)
-{
- uint32_t blobCnt{};
- asset::legacyv1::BlobHeaderV1* headers = nullptr;
- uint32_t* offsets = nullptr;
- uint32_t baseOffsetv1{};
- uint32_t baseOffsetv2{};
- std::tie(blobCnt, headers, offsets, baseOffsetv1, baseOffsetv2) = _common;
-
- io::CMemoryWriteFile* const baw2mem = new io::CMemoryWriteFile(0u, _baw1file->getFileName());
-
- std::vector<uint32_t> newoffsets(blobCnt);
- int32_t offsetDiff = 0;
- for (uint32_t i = 0u; i < blobCnt; ++i)
- {
- asset::legacyv1::BlobHeaderV1& hdr = headers[i];
- const uint32_t offset = offsets[i];
- uint32_t& newoffset = newoffsets[i];
-
- newoffset = offset + offsetDiff;
-
- if (hdr.blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
- {
- const uint32_t offset = offsets[i];
-
- uint8_t stackmem[1u<<10];
- uint32_t attempt = 0u;
- uint8_t decrKey[16];
- size_t decrKeyLen = 16u;
- void* blob = nullptr;
- /* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
- however we don't need to do this here since we know format's version (baw v1) and so we can be sure that hierarchy level for FinalBoneHierarchy is 3 (won't be true for v2 to v3 conversion)
- */
- constexpr uint32_t FINALBONEHIERARCHY_HIERARCHY_LVL = 3u;
- while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw1file, "", genSubAssetCacheKey(_baw1file->getFileName().c_str(), hdr.handle), _ctx.inner, FINALBONEHIERARCHY_HIERARCHY_LVL))
- {
- if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
- blob = tryReadBlobOnStack<asset::legacyv1::BlobHeaderV1>(SBlobData_t<asset::legacyv1::BlobHeaderV1>(&hdr, baseOffsetv1+offset), _ctx, decrKey, stackmem, sizeof(stackmem));
- if (blob)
- break;
- ++attempt;
- }
-
- // patch the blob
- if (blob)
- {
- auto* hierarchy = reinterpret_cast<legacyv1::FinalBoneHierarchyBlobV1*>(blob);
-
- auto bones = hierarchy->getBoneData();
- for (auto j=0u; j<hierarchy->boneCount; j++)
- {
- core::matrix3x4SIMD mtx = bones[j].PoseBindMatrix;
- const auto* in = mtx.rows[0].pointer;
- auto* out = bones[j].PoseBindMatrix.rows[0].pointer;
- out[0] = in[0];
- out[4] = in[1];
- out[8] = in[2];
- out[1] = in[3];
- out[5] = in[4];
- out[9] = in[5];
- out[2] = in[6];
- out[6] = in[7];
- out[10] = in[8];
- out[3] = in[9];
- out[7] = in[10];
- out[11] = in[11];
- }
-
- const uint32_t absOffset = baseOffsetv2 + newoffset;
- baw2mem->seek(absOffset);
- baw2mem->write(blob, hdr.blobSizeDecompr);
- }
- else
- baw2mem->seek(baseOffsetv2 + newoffset + hdr.blobSizeDecompr);
-
- offsetDiff += static_cast<int32_t>(hdr.blobSizeDecompr) - static_cast<int32_t>(hdr.effectiveSize());
- hdr.compressionType = asset::Blob::EBCT_RAW;
- core::XXHash_256(blob, hdr.blobSizeDecompr, hdr.blobHash);
- hdr.blobSize = hdr.blobSizeDecompr;
-
- if (blob)
- _IRR_ALIGNED_FREE(blob);
- }
- }
- uint64_t fileHeader[4] {0u, 0u, 0u, 2u/*baw v2*/};
- memcpy(fileHeader, asset::legacyv2::BAWFileV2::HEADER_STRING, strlen(asset::legacyv2::BAWFileV2::HEADER_STRING));
- baw2mem->seek(0u);
- baw2mem->write(fileHeader, sizeof(fileHeader));
- baw2mem->write(&blobCnt, 4);
- baw2mem->write(_ctx.iv, 16);
- baw2mem->write(newoffsets.data(), newoffsets.size()*4);
- baw2mem->write(headers, blobCnt*sizeof(headers[0])); // blob header in v1 and in v2 is exact same thing, so we can do this
-
- uint8_t stackmem[1u<<13]{};
- size_t newFileSz = 0u;
- for (uint32_t i = 0u; i < blobCnt; ++i)
- {
- uint32_t sz = headers[i].effectiveSize();
- void* blob = nullptr;
- if (headers[i].blobType == asset::Blob::EBT_FINAL_BONE_HIERARCHY)
- {
- sz = 0u;
- }
- else
- {
- _baw1file->seek(baseOffsetv1 + offsets[i]);
- if (sz <= sizeof(stackmem))
- blob = stackmem;
- else
- blob = _IRR_ALIGNED_MALLOC(sz, _IRR_SIMD_ALIGNMENT);
-
- _baw1file->read(blob, sz);
- }
-
- baw2mem->seek(baseOffsetv2 + newoffsets[i]);
- baw2mem->write(blob, sz);
-
- if (headers[i].blobType != asset::Blob::EBT_DATA_FORMAT_DESC && blob != stackmem)
- _IRR_ALIGNED_FREE(blob);
-
- newFileSz = baseOffsetv2 + newoffsets[i] + sz;
- }
-
- _IRR_ALIGNED_FREE(offsets);
- _IRR_ALIGNED_FREE(headers);
-
- auto ret = new io::CMemoryReadFile(baw2mem->getPointer(), baw2mem->getSize(), _baw1file->getFileName());
- baw2mem->drop();
- return ret;
-}
-
-
-template<>
-io::IReadFile* CBAWMeshFileLoader::createConvertIntoVer_spec<1>(SContext& _ctx, io::IReadFile* _baw0file, asset::IAssetLoader::IAssetLoaderOverride* _override, const CommonDataTuple<0>& _common)
-{
- uint32_t blobCnt{};
- asset::legacyv0::BlobHeaderV0* headers = nullptr;
- uint32_t* offsets = nullptr;
- uint32_t baseOffsetv0{};
- uint32_t baseOffsetv1{};
- std::tie(blobCnt, headers, offsets, baseOffsetv0, baseOffsetv1) = _common;
-
- io::CMemoryWriteFile* const baw1mem = new io::CMemoryWriteFile(0u, _baw0file->getFileName());
-
- std::vector<uint32_t> newoffsets(blobCnt);
- int32_t offsetDiff = 0;
- for (uint32_t i = 0u; i < blobCnt; ++i)
- {
- asset::legacyv0::BlobHeaderV0& hdr = headers[i];
- const uint32_t offset = offsets[i];
- uint32_t& newoffset = newoffsets[i];
-
- newoffset = offset + offsetDiff;
-
- bool adjustDiff = false;
- uint32_t prevBlobSz{};
- if (hdr.blobType == asset::Blob::EBT_DATA_FORMAT_DESC)
- {
- uint8_t stackmem[1u<<10];
- uint32_t attempt = 0u;
- uint8_t decrKey[16];
- size_t decrKeyLen = 16u;
- void* blob = nullptr;
- /* to state blob's/asset's hierarchy level we'd have to load (and possibly decrypt and decompress) the blob
- however we don't need to do this here since we know format's version (baw v0) and so we can be sure that hierarchy level for mesh data descriptors is 2
- */
- constexpr uint32_t ICPUMESHDATAFORMATDESC_HIERARCHY_LVL = 2u;
- while (_override->getDecryptionKey(decrKey, decrKeyLen, attempt, _baw0file, "", genSubAssetCacheKey(_baw0file->getFileName().c_str(), hdr.handle), _ctx.inner, ICPUMESHDATAFORMATDESC_HIERARCHY_LVL))
- {
- if (!((hdr.compressionType & asset::Blob::EBCT_AES128_GCM) && decrKeyLen != 16u))
- blob = tryReadBlobOnStack<asset::legacyv0::BlobHeaderV0>(SBlobData_t<asset::legacyv0::BlobHeaderV0>(&hdr, baseOffsetv0+offset), _ctx, decrKey, stackmem, sizeof(stackmem));
- if (blob)
- break;
- ++attempt;
- }
- assert(!blob || blob==stackmem); // its a fixed size blob so should always use stack
-
- const uint32_t absOffset = baseOffsetv1 + newoffset;
- baw1mem->seek(absOffset);
- baw1mem->write(
- asset::MeshDataFormatDescBlobV1(reinterpret_cast<asset::legacyv0::MeshDataFormatDescBlobV0*>(blob)[0]).getData(),
- sizeof(asset::MeshDataFormatDescBlobV1)
- );
-
- prevBlobSz = hdr.effectiveSize();
- hdr.compressionType = asset::Blob::EBCT_RAW;
- core::XXHash_256(reinterpret_cast<uint8_t*>(baw1mem->getPointer())+absOffset, sizeof(asset::MeshDataFormatDescBlobV1), hdr.blobHash);
- hdr.blobSizeDecompr = hdr.blobSize = sizeof(asset::MeshDataFormatDescBlobV1);
-
- adjustDiff = true;
- }
- if (adjustDiff)
- offsetDiff += static_cast<int32_t>(sizeof(asset::MeshDataFormatDescBlobV1)) - static_cast<int32_t>(prevBlobSz);
- }
- uint64_t fileHeader[4] {0u, 0u, 0u, 1u/*baw v1*/};
- memcpy(fileHeader, asset::legacyv1::BAWFileV1::HEADER_STRING, strlen(asset::legacyv1::BAWFileV1::HEADER_STRING));
- baw1mem->seek(0u);
- baw1mem->write(fileHeader, sizeof(fileHeader));
- baw1mem->write(&blobCnt, 4);
- baw1mem->write(_ctx.iv, 16);
- baw1mem->write(newoffsets.data(), newoffsets.size()*4);
- baw1mem->write(headers, blobCnt*sizeof(headers[0])); // blob header in v0 and in v1 is exact same thing, so we can do this
-
- uint8_t stackmem[1u<<13]{};
- size_t newFileSz = 0u;
- for (uint32_t i = 0u; i < blobCnt; ++i)
- {
- uint32_t sz = headers[i].effectiveSize();
- void* blob = nullptr;
- if (headers[i].blobType == asset::Blob::EBT_DATA_FORMAT_DESC)
- {
- sz = 0u;
- }
- else
- {
- _baw0file->seek(baseOffsetv0 + offsets[i]);
- if (sz <= sizeof(stackmem))
- blob = stackmem;
- else
- blob = _IRR_ALIGNED_MALLOC(sz, _IRR_SIMD_ALIGNMENT);
-
- _baw0file->read(blob, sz);
- }
-
- baw1mem->seek(baseOffsetv1 + newoffsets[i]);
- baw1mem->write(blob, sz);
-
- if (headers[i].blobType != asset::Blob::EBT_DATA_FORMAT_DESC && blob != stackmem)
- _IRR_ALIGNED_FREE(blob);
-
- newFileSz = baseOffsetv1 + newoffsets[i] + sz;
- }
-
- _IRR_ALIGNED_FREE(offsets);
- _IRR_ALIGNED_FREE(headers);
-
- auto ret = new io::CMemoryReadFile(baw1mem->getPointer(), baw1mem->getSize(), _baw0file->getFileName());
- baw1mem->drop();
- return ret;
-}
-
}} // irr::scene

diff:
@@ -63,7 +63,7 @@ size_t SizedBlob<VariableSizeBlob, SkinnedMeshBlobV0, asset::ICPUSkinnedMesh>::c
return sizeof(SkinnedMeshBlobV0) + (_obj->getMeshBufferCount() - 1) * sizeof(uint64_t);
}
-MeshBufferBlobV0::MeshBufferBlobV0(const asset::ICPUMeshBuffer* _mb)
+MeshBufferBlobV3::MeshBufferBlobV3(const asset::ICPUMeshBuffer* _mb)
{
memcpy(&mat, &_mb->getMaterial(), sizeof(video::SCPUMaterial));
_mb->getMaterial().serializeBitfields(mat.bitfieldsPtr());
@@ -82,10 +82,28 @@ MeshBufferBlobV0::MeshBufferBlobV0(const asset::ICPUMeshBuffer* _mb)
posAttrId = _mb->getPositionAttributeIx();
}
+MeshBufferBlobV3::MeshBufferBlobV3(const legacyv2::MeshBufferBlobV2* meshBufferV2)
+{
+ mat = meshBufferV2->mat;
+ box = meshBufferV2->box;
+
+ descPtr = meshBufferV2->descPtr;
+ indexType = meshBufferV2->indexType;
+ baseVertex = meshBufferV2->baseVertex;
+ indexCount = meshBufferV2->indexCount;
+ indexBufOffset = meshBufferV2->indexBufOffset;
+ instanceCount = meshBufferV2->instanceCount;
+ baseInstance = meshBufferV2->baseInstance;
+ primitiveType = meshBufferV2->primitiveType;
+ posAttrId = meshBufferV2->posAttrId;
+
+ isRightHandedCoordinateSystem = false;
+}
+
template<>
-size_t SizedBlob<FixedSizeBlob, MeshBufferBlobV0, asset::ICPUMeshBuffer>::calcBlobSizeForObj(const asset::ICPUMeshBuffer* _obj)
+size_t SizedBlob<FixedSizeBlob, MeshBufferBlobV3, asset::ICPUMeshBuffer>::calcBlobSizeForObj(const asset::ICPUMeshBuffer* _obj)
{
- return sizeof(MeshBufferBlobV0);
+ return sizeof(MeshBufferBlobV3);
}
SkinnedMeshBufferBlobV0::SkinnedMeshBufferBlobV0(const asset::ICPUSkinnedMeshBuffer* _smb)
@@ -290,8 +308,6 @@ MeshDataFormatDescBlobV1::MeshDataFormatDescBlobV1(const asset::legacyv0::MeshDa
idxBufPtr = _v0blob.idxBufPtr;
}
-
-
bool encAes128gcm(const void* _input, size_t _inSize, void* _output, size_t _outSize, const unsigned char* _key, const unsigned char* _iv, void* _tag)
{
#ifdef _IRR_COMPILE_WITH_OPENSSL_

diff:
@@ -205,9 +205,9 @@ void TypedBlob<SkinnedMeshBlobV2, asset::ICPUSkinnedMesh>::releaseObj(const void
}
template<>
-core::unordered_set<uint64_t> TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>::getNeededDeps(const void* _blob)
+core::unordered_set<uint64_t> TypedBlob<MeshBufferBlobV3, asset::ICPUMeshBuffer>::getNeededDeps(const void* _blob)
{
- auto* blob = (MeshBufferBlobV2*)_blob;
+ auto* blob = (MeshBufferBlobV3*)_blob;
core::unordered_set<uint64_t> deps;
deps.insert(blob->descPtr);
for (uint32_t i = 0; i < _IRR_MATERIAL_MAX_TEXTURES_; ++i)
@@ -220,12 +220,12 @@ core::unordered_set<uint64_t> TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>
}
template<>
-void* TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>::instantiateEmpty(const void* _blob, size_t _blobSize, const BlobLoadingParams& _params)
+void* TypedBlob<MeshBufferBlobV3, asset::ICPUMeshBuffer>::instantiateEmpty(const void* _blob, size_t _blobSize, const BlobLoadingParams& _params)
{
if (!_blob)
return nullptr;
- const auto* blob = (const MeshBufferBlobV2*)_blob;
+ const auto* blob = (const MeshBufferBlobV3*)_blob;
asset::ICPUMeshBuffer* buf = new asset::ICPUMeshBuffer();
memcpy(&buf->getMaterial(), &blob->mat, sizeof(video::SCPUMaterial));
buf->getMaterial().setBitfields(*(blob)->mat.bitfieldsPtr());
@@ -249,12 +249,12 @@ void* TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>::instantiateEmpty(const
}
template<>
-void* TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>::finalize(void* _obj, const void* _blob, size_t _blobSize, core::unordered_map<uint64_t, void*>& _deps, const BlobLoadingParams& _params)
+void* TypedBlob<MeshBufferBlobV3, asset::ICPUMeshBuffer>::finalize(void* _obj, const void* _blob, size_t _blobSize, core::unordered_map<uint64_t, void*>& _deps, const BlobLoadingParams& _params)
{
if (!_obj || !_blob)
return nullptr;
- const auto* blob = (const MeshBufferBlobV2*)_blob;
+ const auto* blob = (const MeshBufferBlobV3*)_blob;
asset::ICPUMeshBuffer* buf = reinterpret_cast<asset::ICPUMeshBuffer*>(_obj);
buf->setMeshDataAndFormat(impl::castPtrAndRefcount<asset::IMeshDataFormatDesc<asset::ICPUBuffer> >(_deps[blob->descPtr]));
for (uint32_t i = 0; i < _IRR_MATERIAL_MAX_TEXTURES_; ++i)
@@ -267,7 +267,7 @@ void* TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>::finalize(void* _obj, c
}
template<>
-void TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>::releaseObj(const void* _obj)
+void TypedBlob<MeshBufferBlobV3, asset::ICPUMeshBuffer>::releaseObj(const void* _obj)
{
if (_obj)
reinterpret_cast<const asset::ICPUMeshBuffer*>(_obj)->drop();
@@ -276,7 +276,7 @@ void TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>::releaseObj(const void*
template<>
core::unordered_set<uint64_t> TypedBlob<SkinnedMeshBufferBlobV2, asset::ICPUSkinnedMeshBuffer>::getNeededDeps(const void* _blob)
{
- return TypedBlob<MeshBufferBlobV2, asset::ICPUMeshBuffer>::getNeededDeps(_blob);
+ return TypedBlob<MeshBufferBlobV3, asset::ICPUMeshBuffer>::getNeededDeps(_blob);
}
template<>

diff:
@@ -137,6 +137,52 @@ using BAWFileV2 = BAWFileVn<2>;
using BlobHeaderV2 = BlobHeaderVn<2>;
+#include "irr/irrpack.h"
+//! Simple struct of essential data of ICPUMeshBuffer that has to be exported
+struct IRR_FORCE_EBO MeshBufferBlobV2 : TypedBlob<MeshBufferBlobV2, ICPUMeshBuffer>, FixedSizeBlob<MeshBufferBlobV2, ICPUMeshBuffer>
+{
+ //! Constructor filling all members
+ explicit MeshBufferBlobV2(const ICPUMeshBuffer* _mb)
+ {
+ memcpy(&mat, &_mb->getMaterial(), sizeof(video::SCPUMaterial));
+ _mb->getMaterial().serializeBitfields(mat.bitfieldsPtr());
+ for (size_t i = 0; i < _IRR_MATERIAL_MAX_TEXTURES_; ++i)
+ _mb->getMaterial().TextureLayer[i].SamplingParams.serializeBitfields(mat.TextureLayer[i].SamplingParams.bitfieldsPtr());
+
+ memcpy(&box, &_mb->getBoundingBox(), sizeof(core::aabbox3df));
+ descPtr = reinterpret_cast<uint64_t>(_mb->getMeshDataAndFormat());
+ indexType = _mb->getIndexType();
+ baseVertex = _mb->getBaseVertex();
+ indexCount = _mb->getIndexCount();
+ indexBufOffset = _mb->getIndexBufferOffset();
+ instanceCount = _mb->getInstanceCount();
+ baseInstance = _mb->getBaseInstance();
+ primitiveType = _mb->getPrimitiveType();
+ posAttrId = _mb->getPositionAttributeIx();
+ }
+
+ video::SCPUMaterial mat;
+ core::aabbox3df box;
+ uint64_t descPtr;
+ uint32_t indexType;
+ uint32_t baseVertex;
+ uint64_t indexCount;
+ size_t indexBufOffset;
+ size_t instanceCount;
+ uint32_t baseInstance;
+ uint32_t primitiveType;
+ uint32_t posAttrId;
+} PACK_STRUCT;
+#include "irr/irrunpack.h"
+static_assert(sizeof(MeshBufferBlobV2::mat) == 197, "sizeof(MeshBufferBlobV0::mat) must be 197");
+static_assert(
+ sizeof(MeshBufferBlobV2) ==
+ sizeof(MeshBufferBlobV2::mat) + sizeof(MeshBufferBlobV2::box) + sizeof(MeshBufferBlobV2::descPtr) + sizeof(MeshBufferBlobV2::indexType) + sizeof(MeshBufferBlobV2::baseVertex)
+ + sizeof(MeshBufferBlobV2::indexCount) + sizeof(MeshBufferBlobV2::indexBufOffset) + sizeof(MeshBufferBlobV2::instanceCount) + sizeof(MeshBufferBlobV2::baseInstance)
+ + sizeof(MeshBufferBlobV2::primitiveType) + sizeof(MeshBufferBlobV2::posAttrId),
+ "MeshBufferBlobV0: Size of blob is not sum of its contents!"
+ );
+
}
}


message: Get rid of BAWWriter flipping

diff:
@@ -153,29 +153,6 @@ struct LzmaMemMngmnt
const ICPUMesh* mesh = static_cast<const ICPUMesh*>(_params.rootAsset);
- if (!(_params.writerFlags & IAssetWriter::EWPF_MESH_IS_RIGHT_HANDED))
- for (auto index = 0l; index < mesh->getMeshBufferCount(); ++index)
- {
- auto meshBuffer = mesh->getMeshBuffer(index);
-
- for (auto pos = 0l; pos < meshBuffer->getIndexCount(); ++pos)
- {
- core::vectorSIMDf outPos(0.f, 0.f, 0.f, 1.f);
- meshBuffer->getAttribute(outPos, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0, pos);
-
- outPos.X = -outPos.X;
- meshBuffer->setAttribute(outPos, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR0, pos);
-
- core::vectorSIMDf outNormal(0.f, 0.f, 0.f, 1.f);
- bool status = meshBuffer->getAttribute(outNormal, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, pos);
- if (status)
- {
- outNormal.X = -outNormal.X;
- meshBuffer->setAttribute(outNormal, E_VERTEX_ATTRIBUTE_ID::EVAI_ATTR3, pos);
- }
- }
- }
-
constexpr uint32_t FILE_HEADER_SIZE = 32;
static_assert(FILE_HEADER_SIZE == sizeof(BAWFileV3::fileHeader), "BAW header is not 32 bytes long!");

original_message: Get rid of BAWWriter flipping


message: Modify the blob lh/rh flag depending on writer params

diff:
@@ -94,6 +94,12 @@ public:
return ctx.params.flags;
}
+ //! It allows you to get writer flags which specify some information on saving process like handedness coordinate system
+ inline virtual IAssetWriter::E_WRITER_PARAMETER_FLAGS getAssetWritingParameterFlags(const SAssetWriteContext& ctx, const IAsset* assetToWrite, const uint32_t& hierarchyLevel)
+ {
+ return ctx.params.writerFlags;
+ }
+
//! For altering the compression level for individual assets, i.e. images, etc.
inline virtual float getAssetCompressionLevel(const SAssetWriteContext& ctx, const IAsset* assetToWrite, const uint32_t& hierarchyLevel)
{

diff:
@@ -37,7 +37,7 @@ struct IRR_FORCE_EBO MeshBufferBlobV3 : TypedBlob<MeshBufferBlobV3, ICPUMeshBuff
uint32_t baseInstance;
uint32_t primitiveType;
uint32_t posAttrId;
- bool isRightHandedCoordinateSystem;
+ uint8_t isRightHandedCoordinateSystem;
} PACK_STRUCT;
#include "irr/irrunpack.h"
static_assert(sizeof(MeshBufferBlobV3::mat)==197, "sizeof(MeshBufferBlobV0::mat) must be 197");

diff:
@@ -79,6 +79,13 @@ struct LzmaMemMngmnt
MeshBufferBlobV3 data(_obj);
const E_WRITER_FLAGS flags = _ctx.writerOverride->getAssetWritingFlags(_ctx.inner, _obj, 1u);
+ const auto parameterFlags = _ctx.writerOverride->getAssetWritingParameterFlags(_ctx.inner, _obj, 1u);
+
+ if (parameterFlags & IAssetWriter::E_WRITER_PARAMETER_FLAGS::EWPF_MESH_IS_RIGHT_HANDED)
+ data.isRightHandedCoordinateSystem = 1;
+ else
+ data.isRightHandedCoordinateSystem = 0;
+
const uint8_t* encrPwd = nullptr;
_ctx.writerOverride->getEncryptionKey(encrPwd, _ctx.inner, _obj, 1u);
const float comprLvl = _ctx.writerOverride->getAssetCompressionLevel(_ctx.inner, _obj, 1u);

diff:
@@ -80,6 +80,8 @@ MeshBufferBlobV3::MeshBufferBlobV3(const asset::ICPUMeshBuffer* _mb)
baseInstance = _mb->getBaseInstance();
primitiveType = _mb->getPrimitiveType();
posAttrId = _mb->getPositionAttributeIx();
+
+ isRightHandedCoordinateSystem = 0; // false
}
MeshBufferBlobV3::MeshBufferBlobV3(const legacyv2::MeshBufferBlobV2* meshBufferV2)
@@ -97,7 +99,7 @@ MeshBufferBlobV3::MeshBufferBlobV3(const legacyv2::MeshBufferBlobV2* meshBufferV
primitiveType = meshBufferV2->primitiveType;
posAttrId = meshBufferV2->posAttrId;
- isRightHandedCoordinateSystem = false;
+ isRightHandedCoordinateSystem = 0; // false
}
template<>


message: Adjust to comments

diff:
# IrrlichtBAW
-![Windows Build Status](https://github.com/google/filament/workflows/Windows/badge.svg) ![Linux Build Status](https://github.com/google/filament/workflows/Linux/badge.svg) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
+[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
-**IrrlichtBAW** is a new renovated version of old **[Irrlicht](http://irrlicht.sourceforge.net/)** engine. The project currently aims for a thread-able and *Vulkan*-centered API, but currently works on *OpenGL* only. This framework has been kindly begun and almost entirely sponsored by **Build A World Aps**., and the `stable-ish` branch is used in production releases of **[Build A World EDU](https://edu.buildaworld.net/)**, since 2015.
+**IrrlichtBAW** is a new renovated version of old **[Irrlicht](http://irrlicht.sourceforge.net/)** engine. The project currently aims for a thread-able and *Vulkan*-centered API, but currently works on *OpenGL* only. This framework has been kindly begun and almost entirely sponsored by **Build A World Aps**., and now by **[Ditt](https://www.ditt.nl/)** company. The `stable-ish` branch is used in production releases of **[Build A World EDU](https://edu.buildaworld.net/)**, since 2015.
## Showcase
### Screen Shots
+![](https://github.com/AnastaZIuk/IrrScreenShots/blob/master/IrrSS/brdf.png?raw=true)
+
+
+
![](https://raw.githubusercontent.com/AnastaZIuk/IrrScreenShots/master/IrrSS/1.png)
-![](https://raw.githubusercontent.com/AnastaZIuk/IrrScreenShots/master/IrrSS/11.png)
+![](https://github.com/AnastaZIuk/IrrScreenShots/blob/master/IrrSS/balls.png?raw=true)
-![](https://raw.githubusercontent.com/AnastaZIuk/IrrScreenShots/master/IrrSS/12.png)
+![](https://raw.githubusercontent.com/AnastaZIuk/IrrScreenShots/master/IrrSS/11.png)
-![](https://raw.githubusercontent.com/AnastaZIuk/IrrScreenShots/master/IrrSS/8.png)
-
-
-
![](https://raw.githubusercontent.com/AnastaZIuk/IrrScreenShots/master/IrrSS/9.png)
-## Platforms
+## Main Features
+
+- **Asset management pipeline**
+- **Automatic pipeline layout creation**
+- **Shader introspection**
+- **Using SPRIV shaders in OpenGL**
+- **Libraries of GLSL shader functions**
+- **Compute shaders**
+- **Virtual Texturing**
+- **CUDA and OpenGL interop**
+- **OpenCL and OpenGL interop**
+- **CPU image filtering**
+
+## Main Delivered Extensions
+
+- **Mitsuba scene loader (auto-generated shaders)**
+- **Tonemapper**
+- **Fastest blur on the planet**
+- **Bullet physics beginner integration**
+- **OptiX interop**
+- **Radeon rays interop**
-- [x] #### Windows
+## Platforms
-- [x] #### Linux
+- [x] #### **Windows**
-- [ ] #### Android 7.0 +
+- [x] #### **Linux**
-- [ ] #### Mac OS
+- [ ] #### **Android 7.0 +**
-- [ ] #### iOS
+- [ ] #### **Mac OS**
+- [ ] #### **iOS**
## Required Build Tools and SDK's
### Vanilla + CUDA Build
-**IrrlichtBAW** only supports *CUDA* interop using the Driver API not the Runtime API.
+**IrrlichtBAW** only supports *CUDA* interop using the Driver API not the Runtime API. We use the runtime compiled CUDA.
Because *CUDA* needs its own version the GeForce (Quadro or Tesla) Driver, its often a few minor versions behind your automatically updated Windows driver, the install will fail even if it prompts you to agree to installing an older driver.
@@ -117,8 +138,6 @@ So basically first remove your driver, then install *CUDA SDK*.
On Windows *CMake* has trouble finding new packages installed after *CMake*, so its the perfect time to visit **[it's website](https://cmake.org/)** and check for a new version installer after installing *CUDA SDK*.
-Because *CUDA* hijacks your C++ compiler, its best that you don't use the `IRR_BUILD_WITH_CUDA` *CMake* option unless necessary, overall it may lead to the library and extensions being compiled with wrong (sub-par) optimization and tuning flags, as well as a lower version of the C++ standard (*C++20* is currently on the horizon, **IrrlichtBaW** supports *C++17*, and *CUDA 10.1* only supports *C++14*).
-
You can also thank NVidia for making the CUDA SDK a whole whopping 2.5 GB on Windows.
### Vanilla + CUDA + Optix Build
@@ -226,17 +245,21 @@ We recommend the ***[Codelite IDE](https://codelite.org/)*** as that has a *CMak
***[Clang](https://clang.llvm.org/) toolset*** is unmaintained and untested on Linux.
+## First examples launching, significant notes
+
+Remember you have to set up **starting target project** in *Visual Studio* before you begin to launch your example. To to that click on **Solution Explorer**, find the example name, hover on it and click on **Set as StartUp Project**. You can disable building examples by `IRR_BUILD_EXAMPLES` option in *CMake*.
+
## License
-**IrrlichtBAW** is donated under the **[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)** license. See **LICENSE.md** for more details.
+**IrrlichtBAW** is released under the **[Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0)** license. See [**LICENSE.md**](https://github.com/buildaworldnet/IrrlichtBAW/blob/master/LICENSE.md) for more details.
## API documentation, help and extra improvements
-If you would like to take care of documenting some files, please **[click it](https://github.com/buildaworldnet/IrrlichtBAW/wiki/Documentation)**. If you feel like you'd be interesting in improving and maintaining this repository's wiki, contact **@devsh** on **[Discord](https://discord.gg/4MTCVaN)**.
+If you would like to take care of documenting some files, please **[click it](https://github.com/buildaworldnet/IrrlichtBAW/wiki/Documentation)**. If you feel like you'd be interesting in improving and maintaining this repository's wiki, contact ***[@devshgraphicsprogramming](https://github.com/devshgraphicsprogramming)*** on **[Discord](https://discord.gg/4MTCVaN)**.
## Official Support (Discord)
-Permament members of *Devsh Graphics Programming Sp. z O.O.* use this to organise publicly visible work. **[Join to the server](https://discord.gg/4MTCVaN)** to get into more details. There's also a skype support group, reach **@devsh** for a private invite.
+Permament members of *Devsh Graphics Programming Sp. z O.O.* use this to organise publicly visible work. **[Join to the server](https://discord.gg/4MTCVaN)** to get into more details. There's also a skype support group, reach ***[@devshgraphicsprogramming](https://github.com/devshgraphicsprogramming)*** for a private invite.
## Credits and Attribution

original_message: Adjust to comments


message: render and add denoising gifs

diff:
-### Gifs
+### Gifs - [Raytracing flythrough](https://www.youtube.com/watch?v=bwVVoAsRjHI)
+
+
![](https://github.com/AnastaZIuk/IrrScreenShots/blob/master/raytracingg1.gif?raw=true)
+### Gifs - [Raytracing With Optix AI Denoising [Albedo and Normals]](https://www.youtube.com/watch?v=VFad-Y-dSxQ&feature=youtu.be)
+
+
+
+![](https://github.com/AnastaZIuk/IrrScreenShots/blob/master/denoising/den1.gif?raw=true)
+
+
+
+![](https://github.com/AnastaZIuk/IrrScreenShots/blob/master/denoising/den2.gif?raw=true)
+
+
+
+![](https://github.com/AnastaZIuk/IrrScreenShots/blob/master/denoising/den3.gif?raw=true)
+
+
+
+![](https://github.com/AnastaZIuk/IrrScreenShots/blob/master/denoising/den4.gif?raw=true)
+
+
+
+![](https://github.com/AnastaZIuk/IrrScreenShots/blob/master/denoising/den7.gif?raw=true)
+
+
+
## Main Features
- **Asset management pipeline**

original_message: render and add denoising gifs


message: exchange to https links

diff:
**BRDF Explorer**
-![](site_media\readme\screenshots\BRDF Explorer.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/BRDF%20Explorer.png?raw=true)
**Many light raytracing**
-![](site_media\readme\screenshots\Many light raytracing.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Many%20light%20raytracing.png?raw=true)
**Many light raytracing**
-![](site_media\readme\screenshots\Many light raytracing 2.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Many%20light%20raytracing%202.png?raw=true)
**Cylindrical light source**
-![](site_media\readme\screenshots\Cylindrical light source.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Cylindrical%20light%20source.png?raw=true)
**Two area lights**
-![](site_media\readme\screenshots\Two area lights.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Two%20area%20lights.png?raw=true)
**.OBJ Loader with MTL pipeline integration**
-![](site_media\readme\screenshots\.OBJ Loader with MTL pipeline integration.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/.OBJ%20Loader%20with%20MTL%20pipeline%20integration.png?raw=true)
**Over 10 area lights**
-![](site_media\readme\screenshots\Over 10 area lights.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Over%2010%20area%20lights.png?raw=true)
**Raytracing sample**
-![](site_media\readme\screenshots\Raytracing sample.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Raytracing%20sample.png?raw=true)
**Raytracing sample**
-![](site_media\readme\screenshots\Raytracing sample 2.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Raytracing%20sample%202.png?raw=true)
**Light emitters**
-![](site_media\readme\screenshots\Light emitters.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Light%20emitters.png?raw=true)
**Raytracing sample**
-![](site_media\readme\screenshots\Raytracing sample 3.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/Raytracing%20sample%203.png?raw=true)
**1 Megapixel, 1 Million Samples**
-![](site_media\readme\screenshots\1 Megapixel, 1 Million Samples.png)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/screenshots/1%20Megapixel,%201%20Million%20Samples.png?raw=true)
-![](site_media\readme\gifs\raytracingflythrough\raytracing 1.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/raytracingflythrough/raytracing%201.gif?raw=true)
-![](site_media\readme\gifs\raytracingflythrough\raytracing 2.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/raytracingflythrough/raytracing%202.gif?raw=true)
-![](site_media\readme\gifs\raytracingflythrough\raytracing 3.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/raytracingflythrough/raytracing%203.gif?raw=true)
-![](site_media\readme\gifs\raytracingflythrough\raytracing 4.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/raytracingflythrough/raytracing%204.gif?raw=true)
-![](site_media\readme\gifs\raytracingflythrough\raytracing 5.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/raytracingflythrough/raytracing%205.gif?raw=true)
-![](site_media\readme\gifs\denoisingalbedoandnormals\denoising 1.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/denoisingalbedoandnormals/denoising%201.gif?raw=true)
-![](site_media\readme\gifs\denoisingalbedoandnormals\denoising 2.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/denoisingalbedoandnormals/denoising%202.gif?raw=true)
-![](site_media\readme\gifs\denoisingalbedoandnormals\denoising 3.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/denoisingalbedoandnormals/denoising%203.gif?raw=true)
-![](site_media\readme\gifs\denoisingalbedoandnormals\denoising 4.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/denoisingalbedoandnormals/denoising%204.gif?raw=true)
-![](site_media\readme\gifs\denoisingalbedoandnormals\denoising 5.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/denoisingalbedoandnormals/denoising%205.gif?raw=true)
-![](site_media\readme\gifs\denoisingalbedoandnormals\denoising 7.gif)
+![](https://github.com/buildaworldnet/IrrlichtBAW/blob/6e4842588ef02ffb619242a08c0c037bba59c244/site_media/readme/gifs/denoisingalbedoandnormals/denoising%207.gif?raw=true)

original_message: exchange to https links


message: Stop playing any video on disappearing of MXKAttachmentsViewController

diff:
}
- (void)viewWillDisappear:(BOOL)animated
-
-
{
if (tempFile)
{
currentAlert = nil;
}
+ // Stop playing any video
+ for (MXKMediaCollectionViewCell *cell in self.attachmentsCollection.visibleCells)
+ {
+ [cell.moviePlayer stop];
+ }
+
// Restore audio category
if (savedAVAudioSessionCategory)
{

diff:
return self;
}
+- (void)prepareForReuse
+{
+ [super prepareForReuse];
+ [self.moviePlayer stop];
+ self.moviePlayer = nil;
+}
+
+- (void)dealloc
+{
+ [self.moviePlayer stop];
+}
+
@end

repo: matrix-org/matrix-ios-kit


message: Prevent MXKAlert from being retained in action handler

diff:
{
index = [(UIAlertController *)_alert actions].count;
+ __weak typeof(self) weakSelf = self;
UIAlertAction* action = [UIAlertAction actionWithTitle:title
style:(UIAlertActionStyle)style
handler:^(UIAlertAction * action) {
if (handler)
{
- handler(self);
+ handler(weakSelf);
}
}];


message: Fix for issue 1101

diff:
@@ -628,9 +628,11 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
[audioPlayer stop];
}
+ NSString *soundName = [self soundNameForCallEnding];
+ if (soundName)
+ {
NSError *error = nil;
- NSURL *audioUrl;
- audioUrl = [self audioURLWithName:@"callend"];
+ NSURL *audioUrl = [self audioURLWithName:soundName];
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioUrl error:&error];
if (error)
{
@@ -643,6 +645,7 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
audioPlayer.numberOfLoops = 0;
[audioPlayer play];
+ }
// Except in case of call error, quit the screen right now
if (!errorAlert)
@@ -779,6 +782,20 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
return isBuiltInReceiverUsed;
}
+- (NSString *)soundNameForCallEnding
+{
+ if (mxCall.endReason == MXCallEndReasonUnknown)
+ return nil;
+
+ if (mxCall.isEstablished)
+ return @"callend";
+
+ if (!mxCall.isEstablished && !mxCall.isIncoming && (mxCall.endReason == MXCallEndReasonHangupRemote || mxCall.endReason == MXCallEndReasonTimeout))
+ return @"busy";
+
+ return nil;
+}
+
#pragma mark - UI methods
- (void)updateLocalPreviewLayout

original_message: Fix for issue 1101


message: Fix due to changes in MXCallEndReason

diff:
@@ -790,7 +790,7 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
if (mxCall.isEstablished)
return @"callend";
- if (!mxCall.isEstablished && !mxCall.isIncoming && (mxCall.endReason == MXCallEndReasonHangupRemote || mxCall.endReason == MXCallEndReasonTimeout))
+ if (mxCall.endReason == MXCallEndReasonBusy || (!mxCall.isIncoming && mxCall.endReason == MXCallEndReasonMissed))
return @"busy";
return nil;

original_message: Fix due to changes in MXCallEndReason


message: Add waiting status string for MXCallViewController

diff:
// Settings keys
// call string
+"call_waiting" = "Waiting...";
"call_connecting" = "Call connecting...";
"call_ended" = "Call ended";
"call_ring" = "Calling...";

diff:
@@ -559,7 +559,7 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
{
case MXCallStateFledgling:
self.isRinging = NO;
- callStatusLabel.text = nil;
+ callStatusLabel.text = [NSBundle mxk_localizedStringForKey:@"call_waiting"];;
break;
case MXCallStateWaitLocalMedia:
self.isRinging = NO;


message: Small fixes in MXCallViewController

diff:
@@ -566,7 +566,6 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
[localPreviewActivityView startAnimating];
break;
case MXCallStateCreateOffer:
- case MXCallStateInviteSent:
self.isRinging = YES;
callStatusLabel.text = [NSBundle mxk_localizedStringForKey:@"call_ring"];
break;
@@ -585,7 +584,6 @@ NSString *const kMXKCallViewControllerBackToAppNotification = @"kMXKCallViewCont
rejectCallButton.hidden = NO;
answerCallButton.hidden = NO;
break;
- case MXCallStateCreateAnswer:
case MXCallStateConnecting:
self.isRinging = NO;
callStatusLabel.text = [NSBundle mxk_localizedStringForKey:@"call_connecting"];

original_message: Small fixes in MXCallViewController