Merge branch 'pugi_xml' of https://github.com/assimp/assimp into pugi_xml

This commit is contained in:
Kim Kulling
2020-02-03 21:19:30 +01:00
68 changed files with 163 additions and 83 deletions

View File

@@ -413,7 +413,8 @@ protected:
Write<unsigned int>(&chunk,tex->mWidth);
Write<unsigned int>(&chunk,tex->mHeight);
chunk.Write( tex->achFormatHint, sizeof(char), 4 );
// Write the texture format, but don't include the null terminator.
chunk.Write( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 );
if(!shortened) {
if (!tex->mHeight) {

View File

@@ -535,7 +535,7 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) {
tex->mWidth = Read<unsigned int>(stream);
tex->mHeight = Read<unsigned int>(stream);
stream->Read( tex->achFormatHint, sizeof(char), 4 );
stream->Read( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 );
if(!shortened) {
if (!tex->mHeight) {

View File

@@ -1213,10 +1213,6 @@ SET_TARGET_PROPERTIES( assimp PROPERTIES
)
if (APPLE)
SET_TARGET_PROPERTIES( assimp PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${ASSIMP_LIB_INSTALL_DIR}"
)
if (BUILD_FRAMEWORK)
SET_TARGET_PROPERTIES( assimp PROPERTIES
FRAMEWORK TRUE

View File

@@ -182,6 +182,13 @@ void HL1MDLLoader::load_file() {
read_global_info();
if (!header_->numbodyparts) {
// This could be an MDL external texture file. In this case,
// add this flag to allow the scene to be loaded even if it
// has no meshes.
scene_->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
}
// Append children to root node.
if (rootnode_children_.size()) {
scene_->mRootNode->addChildren(
@@ -218,21 +225,6 @@ void HL1MDLLoader::validate_header(const Header_HL1 *header, bool is_texture_hea
}
} else {
// Every single Half-Life model is assumed to have at least one bodypart.
if (!header->numbodyparts) {
throw DeadlyImportError(MDL_HALFLIFE_LOG_HEADER "Model has no bodyparts");
}
// Every single Half-Life model is assumed to have at least one bone.
if (!header->numbones) {
throw DeadlyImportError(MDL_HALFLIFE_LOG_HEADER "Model has no bones");
}
// Every single Half-Life model is assumed to have at least one sequence group,
// which is the "default" sequence group.
if (!header->numseqgroups) {
throw DeadlyImportError(MDL_HALFLIFE_LOG_HEADER "Model has no sequence groups");
}
if (header->numbodyparts > AI_MDL_HL1_MAX_BODYPARTS) {
log_warning_limit_exceeded<AI_MDL_HL1_MAX_BODYPARTS>(header->numbodyparts, "bodyparts");
@@ -381,9 +373,9 @@ void HL1MDLLoader::read_texture(const Texture_HL1 *ptexture,
pResult->mFilename = ptexture->name;
pResult->mWidth = outwidth;
pResult->mHeight = outheight;
pResult->achFormatHint[0] = 'b';
pResult->achFormatHint[0] = 'r';
pResult->achFormatHint[1] = 'g';
pResult->achFormatHint[2] = 'r';
pResult->achFormatHint[2] = 'b';
pResult->achFormatHint[3] = 'a';
pResult->achFormatHint[4] = '8';
pResult->achFormatHint[5] = '8';
@@ -498,6 +490,10 @@ void HL1MDLLoader::read_skins() {
// ------------------------------------------------------------------------------------------------
void HL1MDLLoader::read_bones() {
if (!header_->numbones) {
return;
}
const Bone_HL1 *pbone = (const Bone_HL1 *)((uint8_t *)header_ + header_->boneindex);
std::vector<std::string> unique_bones_names(header_->numbones);
@@ -588,6 +584,9 @@ void HL1MDLLoader::read_bones() {
triangles, respectively (3 indices per face).
*/
void HL1MDLLoader::read_meshes() {
if (!header_->numbodyparts) {
return;
}
int total_verts = 0;
int total_triangles = 0;
@@ -964,8 +963,9 @@ void HL1MDLLoader::read_meshes() {
// ------------------------------------------------------------------------------------------------
void HL1MDLLoader::read_animations() {
if (!header_->numseq)
if (!header_->numseq) {
return;
}
const SequenceDesc_HL1 *pseqdesc = (const SequenceDesc_HL1 *)((uint8_t *)header_ + header_->seqindex);
const SequenceGroup_HL1 *pseqgroup = nullptr;
@@ -1067,6 +1067,9 @@ void HL1MDLLoader::read_animations() {
// ------------------------------------------------------------------------------------------------
void HL1MDLLoader::read_sequence_groups_info() {
if (!header_->numseqgroups) {
return;
}
aiNode *sequence_groups_node = new aiNode(AI_MDL_HL1_NODE_SEQUENCE_GROUPS);
rootnode_children_.push_back(sequence_groups_node);

View File

@@ -798,7 +798,7 @@ void ValidateDSProcess::Validate( const aiTexture* pTexture)
if (!pTexture->mWidth) {
ReportError("aiTexture::mWidth is zero (compressed texture)");
}
if ('\0' != pTexture->achFormatHint[3]) {
if ('\0' != pTexture->achFormatHint[HINTMAXTEXTURELEN - 1]) {
ReportWarning("aiTexture::achFormatHint must be zero-terminated");
}
else if ('.' == pTexture->achFormatHint[0]) {