mData) {
acc->mData = &ResolveLibraryReference(mDataLibrary, acc->mSource);
+ const size_t dataSize = acc->mOffset + acc->mCount * acc->mStride;
+ if (dataSize > acc->mData->mValues.size()) {
+ throw DeadlyImportError("Not enough data for accessor");
+ }
}
}
// For continued primitives, the given count does not come all in one , but only one primitive per
size_t numPrimitives = pNumPrimitives;
- if (pPrimType == Prim_TriFans || pPrimType == Prim_Polygon)
+ if (pPrimType == Prim_TriFans || pPrimType == Prim_Polygon) {
numPrimitives = 1;
+ }
+
// For continued primitives, the given count is actually the number of
's inside the parent tag
if (pPrimType == Prim_TriStrips) {
size_t numberOfVertices = indices.size() / numOffsets;
@@ -2166,15 +2191,15 @@ void ColladaParser::ReadNodeTransformation(XmlNode &node, Node *pNode, Transform
}
// how many parameters to read per transformation type
- static const unsigned int sNumParameters[] = { 9, 4, 3, 3, 7, 16 };
+ static constexpr unsigned int sNumParameters[] = { 9, 4, 3, 3, 7, 16 };
std::string value;
XmlParser::getValueAsString(node, value);
const char *content = value.c_str();
-
+ const char *end = value.c_str() + value.size();
// read as many parameters and store in the transformation
for (unsigned int a = 0; a < sNumParameters[pType]; a++) {
// skip whitespace before the number
- SkipSpacesAndLineEnd(&content);
+ SkipSpacesAndLineEnd(&content, end);
// read a number
content = fast_atoreal_move(content, tf.f[a]);
}
diff --git a/code/AssetLib/Collada/ColladaParser.h b/code/AssetLib/Collada/ColladaParser.h
index 15982934f..d428ad674 100644
--- a/code/AssetLib/Collada/ColladaParser.h
+++ b/code/AssetLib/Collada/ColladaParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
- Copyright (c) 2006-2022, assimp team
+ Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/DXF/DXFHelper.h b/code/AssetLib/DXF/DXFHelper.h
index 4d7893cc4..0bbecdc9e 100644
--- a/code/AssetLib/DXF/DXFHelper.h
+++ b/code/AssetLib/DXF/DXFHelper.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp
index f69cdfce2..0f3da2626 100644
--- a/code/AssetLib/DXF/DXFLoader.cpp
+++ b/code/AssetLib/DXF/DXFLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* @brief Implementation of the DXF importer class
*/
-
#ifndef ASSIMP_BUILD_NO_DXF_IMPORTER
#include "AssetLib/DXF/DXFLoader.h"
@@ -68,25 +67,267 @@ static constexpr size_t AI_DXF_BINARY_IDENT_LEN = sizeof AI_DXF_BINARY_IDENT;
// default vertex color that all uncolored vertices will receive
static const aiColor4D AI_DXF_DEFAULT_COLOR(aiColor4D(0.6f, 0.6f, 0.6f, 0.6f));
-// color indices for DXF - 16 are supported, the table is
-// taken directly from the DXF spec.
-static const aiColor4D g_aclrDxfIndexColors[] = {
- aiColor4D(0.6f, 0.6f, 0.6f, 1.0f),
- aiColor4D (1.0f, 0.0f, 0.0f, 1.0f), // red
- aiColor4D (0.0f, 1.0f, 0.0f, 1.0f), // green
- aiColor4D (0.0f, 0.0f, 1.0f, 1.0f), // blue
- aiColor4D (0.3f, 1.0f, 0.3f, 1.0f), // light green
- aiColor4D (0.3f, 0.3f, 1.0f, 1.0f), // light blue
- aiColor4D (1.0f, 0.3f, 0.3f, 1.0f), // light red
- aiColor4D (1.0f, 0.0f, 1.0f, 1.0f), // pink
- aiColor4D (1.0f, 0.6f, 0.0f, 1.0f), // orange
- aiColor4D (0.6f, 0.3f, 0.0f, 1.0f), // dark orange
- aiColor4D (1.0f, 1.0f, 0.0f, 1.0f), // yellow
- aiColor4D (0.3f, 0.3f, 0.3f, 1.0f), // dark gray
- aiColor4D (0.8f, 0.8f, 0.8f, 1.0f), // light gray
- aiColor4D (0.0f, 00.f, 0.0f, 1.0f), // black
- aiColor4D (1.0f, 1.0f, 1.0f, 1.0f), // white
- aiColor4D (0.6f, 0.0f, 1.0f, 1.0f) // violet
+// color indices for DXF - 256 are supported, the table is
+// taken directly from the AutoCad Index (ACI) table
+// https://gohtx.com/acadcolors.php
+//STH 2024-0126
+static const aiColor4D g_aclrDxfIndexColors[256] = {
+ aiColor4D (0.0f, 0.0f ,0.0f, 1.0f), //dxf color code 0
+ aiColor4D (1.0f, 0.0f ,0.0f, 1.0f), //dxf color code 1
+ aiColor4D (1.0f, 1.0f ,0.0f, 1.0f), //dxf color code 2
+ aiColor4D (0.0f, 1.0f ,0.0f, 1.0f), //dxf color code 3
+ aiColor4D (0.0f, 1.0f ,1.0f, 1.0f), //dxf color code 4
+ aiColor4D (0.0f, 0.0f ,1.0f, 1.0f), //dxf color code 5
+ aiColor4D (1.0f, 0.0f ,1.0f, 1.0f), //dxf color code 6
+ aiColor4D (1.0f, 1.0f ,1.0f, 1.0f), //dxf color code 7
+ aiColor4D (0.3f, 0.3f ,0.3f, 1.0f), //dxf color code 8
+ aiColor4D (0.5f, 0.5f ,0.5f, 1.0f), //dxf color code 9
+ aiColor4D (1.0f, 0.0f ,0.0f, 1.0f), //dxf color code 10
+ aiColor4D (1.0f, 0.7f ,0.7f, 1.0f), //dxf color code 11
+ aiColor4D (0.7f, 0.0f ,0.0f, 1.0f), //dxf color code 12
+ aiColor4D (0.7f, 0.5f ,0.5f, 1.0f), //dxf color code 13
+ aiColor4D (0.5f, 0.0f ,0.0f, 1.0f), //dxf color code 14
+ aiColor4D (0.5f, 0.3f ,0.3f, 1.0f), //dxf color code 15
+ aiColor4D (0.4f, 0.0f ,0.0f, 1.0f), //dxf color code 16
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 17
+ aiColor4D (0.3f, 0.0f ,0.0f, 1.0f), //dxf color code 18
+ aiColor4D (0.3f, 0.2f ,0.2f, 1.0f), //dxf color code 19
+ aiColor4D (1.0f, 0.2f ,0.0f, 1.0f), //dxf color code 20
+ aiColor4D (1.0f, 0.7f ,0.7f, 1.0f), //dxf color code 21
+ aiColor4D (0.7f, 0.2f ,0.0f, 1.0f), //dxf color code 22
+ aiColor4D (0.7f, 0.6f ,0.5f, 1.0f), //dxf color code 23
+ aiColor4D (0.5f, 0.1f ,0.0f, 1.0f), //dxf color code 24
+ aiColor4D (0.5f, 0.4f ,0.3f, 1.0f), //dxf color code 25
+ aiColor4D (0.4f, 0.1f ,0.0f, 1.0f), //dxf color code 26
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 27
+ aiColor4D (0.3f, 0.1f ,0.0f, 1.0f), //dxf color code 28
+ aiColor4D (0.3f, 0.2f ,0.2f, 1.0f), //dxf color code 29
+ aiColor4D (1.0f, 0.5f ,0.0f, 1.0f), //dxf color code 30
+ aiColor4D (1.0f, 0.8f ,0.7f, 1.0f), //dxf color code 31
+ aiColor4D (0.7f, 0.4f ,0.0f, 1.0f), //dxf color code 32
+ aiColor4D (0.7f, 0.6f ,0.5f, 1.0f), //dxf color code 33
+ aiColor4D (0.5f, 0.3f ,0.0f, 1.0f), //dxf color code 34
+ aiColor4D (0.5f, 0.4f ,0.3f, 1.0f), //dxf color code 35
+ aiColor4D (0.4f, 0.2f ,0.0f, 1.0f), //dxf color code 36
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 37
+ aiColor4D (0.3f, 0.2f ,0.0f, 1.0f), //dxf color code 38
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 39
+ aiColor4D (1.0f, 0.7f ,0.0f, 1.0f), //dxf color code 40
+ aiColor4D (1.0f, 0.9f ,0.7f, 1.0f), //dxf color code 41
+ aiColor4D (0.7f, 0.6f ,0.0f, 1.0f), //dxf color code 42
+ aiColor4D (0.7f, 0.7f ,0.5f, 1.0f), //dxf color code 43
+ aiColor4D (0.5f, 0.4f ,0.0f, 1.0f), //dxf color code 44
+ aiColor4D (0.5f, 0.5f ,0.3f, 1.0f), //dxf color code 45
+ aiColor4D (0.4f, 0.3f ,0.0f, 1.0f), //dxf color code 46
+ aiColor4D (0.4f, 0.4f ,0.3f, 1.0f), //dxf color code 47
+ aiColor4D (0.3f, 0.2f ,0.0f, 1.0f), //dxf color code 48
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 49
+ aiColor4D (1.0f, 1.0f ,0.0f, 1.0f), //dxf color code 50
+ aiColor4D (1.0f, 1.0f ,0.7f, 1.0f), //dxf color code 51
+ aiColor4D (0.7f, 0.7f ,0.0f, 1.0f), //dxf color code 52
+ aiColor4D (0.7f, 0.7f ,0.5f, 1.0f), //dxf color code 53
+ aiColor4D (0.5f, 0.5f ,0.0f, 1.0f), //dxf color code 54
+ aiColor4D (0.5f, 0.5f ,0.3f, 1.0f), //dxf color code 55
+ aiColor4D (0.4f, 0.4f ,0.0f, 1.0f), //dxf color code 56
+ aiColor4D (0.4f, 0.4f ,0.3f, 1.0f), //dxf color code 57
+ aiColor4D (0.3f, 0.3f ,0.0f, 1.0f), //dxf color code 58
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 59
+ aiColor4D (0.7f, 1.0f ,0.0f, 1.0f), //dxf color code 60
+ aiColor4D (0.9f, 1.0f ,0.7f, 1.0f), //dxf color code 61
+ aiColor4D (0.6f, 0.7f ,0.0f, 1.0f), //dxf color code 62
+ aiColor4D (0.7f, 0.7f ,0.5f, 1.0f), //dxf color code 63
+ aiColor4D (0.4f, 0.5f ,0.0f, 1.0f), //dxf color code 64
+ aiColor4D (0.5f, 0.5f ,0.3f, 1.0f), //dxf color code 65
+ aiColor4D (0.3f, 0.4f ,0.0f, 1.0f), //dxf color code 66
+ aiColor4D (0.4f, 0.4f ,0.3f, 1.0f), //dxf color code 67
+ aiColor4D (0.2f, 0.3f ,0.0f, 1.0f), //dxf color code 68
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 69
+ aiColor4D (0.5f, 1.0f ,0.0f, 1.0f), //dxf color code 70
+ aiColor4D (0.8f, 1.0f ,0.7f, 1.0f), //dxf color code 71
+ aiColor4D (0.4f, 0.7f ,0.0f, 1.0f), //dxf color code 72
+ aiColor4D (0.6f, 0.7f ,0.5f, 1.0f), //dxf color code 73
+ aiColor4D (0.3f, 0.5f ,0.0f, 1.0f), //dxf color code 74
+ aiColor4D (0.4f, 0.5f ,0.3f, 1.0f), //dxf color code 75
+ aiColor4D (0.2f, 0.4f ,0.0f, 1.0f), //dxf color code 76
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 77
+ aiColor4D (0.2f, 0.3f ,0.0f, 1.0f), //dxf color code 78
+ aiColor4D (0.3f, 0.3f ,0.2f, 1.0f), //dxf color code 79
+ aiColor4D (0.2f, 1.0f ,0.0f, 1.0f), //dxf color code 80
+ aiColor4D (0.7f, 1.0f ,0.7f, 1.0f), //dxf color code 81
+ aiColor4D (0.2f, 0.7f ,0.0f, 1.0f), //dxf color code 82
+ aiColor4D (0.6f, 0.7f ,0.5f, 1.0f), //dxf color code 83
+ aiColor4D (0.1f, 0.5f ,0.0f, 1.0f), //dxf color code 84
+ aiColor4D (0.4f, 0.5f ,0.3f, 1.0f), //dxf color code 85
+ aiColor4D (0.1f, 0.4f ,0.0f, 1.0f), //dxf color code 86
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 87
+ aiColor4D (0.1f, 0.3f ,0.0f, 1.0f), //dxf color code 88
+ aiColor4D (0.2f, 0.3f ,0.2f, 1.0f), //dxf color code 89
+ aiColor4D (0.0f, 1.0f ,0.0f, 1.0f), //dxf color code 90
+ aiColor4D (0.7f, 1.0f ,0.7f, 1.0f), //dxf color code 91
+ aiColor4D (0.0f, 0.7f ,0.0f, 1.0f), //dxf color code 92
+ aiColor4D (0.5f, 0.7f ,0.5f, 1.0f), //dxf color code 93
+ aiColor4D (0.0f, 0.5f ,0.0f, 1.0f), //dxf color code 94
+ aiColor4D (0.3f, 0.5f ,0.3f, 1.0f), //dxf color code 95
+ aiColor4D (0.0f, 0.4f ,0.0f, 1.0f), //dxf color code 96
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 97
+ aiColor4D (0.0f, 0.3f ,0.0f, 1.0f), //dxf color code 98
+ aiColor4D (0.2f, 0.3f ,0.2f, 1.0f), //dxf color code 99
+ aiColor4D (0.0f, 1.0f ,0.2f, 1.0f), //dxf color code 100
+ aiColor4D (0.7f, 1.0f ,0.7f, 1.0f), //dxf color code 101
+ aiColor4D (0.0f, 0.7f ,0.2f, 1.0f), //dxf color code 102
+ aiColor4D (0.5f, 0.7f ,0.6f, 1.0f), //dxf color code 103
+ aiColor4D (0.0f, 0.5f ,0.1f, 1.0f), //dxf color code 104
+ aiColor4D (0.3f, 0.5f ,0.4f, 1.0f), //dxf color code 105
+ aiColor4D (0.0f, 0.4f ,0.1f, 1.0f), //dxf color code 106
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 107
+ aiColor4D (0.0f, 0.3f ,0.1f, 1.0f), //dxf color code 108
+ aiColor4D (0.2f, 0.3f ,0.2f, 1.0f), //dxf color code 109
+ aiColor4D (0.0f, 1.0f ,0.5f, 1.0f), //dxf color code 110
+ aiColor4D (0.7f, 1.0f ,0.8f, 1.0f), //dxf color code 111
+ aiColor4D (0.0f, 0.7f ,0.4f, 1.0f), //dxf color code 112
+ aiColor4D (0.5f, 0.7f ,0.6f, 1.0f), //dxf color code 113
+ aiColor4D (0.0f, 0.5f ,0.3f, 1.0f), //dxf color code 114
+ aiColor4D (0.3f, 0.5f ,0.4f, 1.0f), //dxf color code 115
+ aiColor4D (0.0f, 0.4f ,0.2f, 1.0f), //dxf color code 116
+ aiColor4D (0.3f, 0.4f ,0.3f, 1.0f), //dxf color code 117
+ aiColor4D (0.0f, 0.3f ,0.2f, 1.0f), //dxf color code 118
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 119
+ aiColor4D (0.0f, 1.0f ,0.7f, 1.0f), //dxf color code 120
+ aiColor4D (0.7f, 1.0f ,0.9f, 1.0f), //dxf color code 121
+ aiColor4D (0.0f, 0.7f ,0.6f, 1.0f), //dxf color code 122
+ aiColor4D (0.5f, 0.7f ,0.7f, 1.0f), //dxf color code 123
+ aiColor4D (0.0f, 0.5f ,0.4f, 1.0f), //dxf color code 124
+ aiColor4D (0.3f, 0.5f ,0.5f, 1.0f), //dxf color code 125
+ aiColor4D (0.0f, 0.4f ,0.3f, 1.0f), //dxf color code 126
+ aiColor4D (0.3f, 0.4f ,0.4f, 1.0f), //dxf color code 127
+ aiColor4D (0.0f, 0.3f ,0.2f, 1.0f), //dxf color code 128
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 129
+ aiColor4D (0.0f, 1.0f ,1.0f, 1.0f), //dxf color code 130
+ aiColor4D (0.7f, 1.0f ,1.0f, 1.0f), //dxf color code 131
+ aiColor4D (0.0f, 0.7f ,0.7f, 1.0f), //dxf color code 132
+ aiColor4D (0.5f, 0.7f ,0.7f, 1.0f), //dxf color code 133
+ aiColor4D (0.0f, 0.5f ,0.5f, 1.0f), //dxf color code 134
+ aiColor4D (0.3f, 0.5f ,0.5f, 1.0f), //dxf color code 135
+ aiColor4D (0.0f, 0.4f ,0.4f, 1.0f), //dxf color code 136
+ aiColor4D (0.3f, 0.4f ,0.4f, 1.0f), //dxf color code 137
+ aiColor4D (0.0f, 0.3f ,0.3f, 1.0f), //dxf color code 138
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 139
+ aiColor4D (0.0f, 0.7f ,1.0f, 1.0f), //dxf color code 140
+ aiColor4D (0.7f, 0.9f ,1.0f, 1.0f), //dxf color code 141
+ aiColor4D (0.0f, 0.6f ,0.7f, 1.0f), //dxf color code 142
+ aiColor4D (0.5f, 0.7f ,0.7f, 1.0f), //dxf color code 143
+ aiColor4D (0.0f, 0.4f ,0.5f, 1.0f), //dxf color code 144
+ aiColor4D (0.3f, 0.5f ,0.5f, 1.0f), //dxf color code 145
+ aiColor4D (0.0f, 0.3f ,0.4f, 1.0f), //dxf color code 146
+ aiColor4D (0.3f, 0.4f ,0.4f, 1.0f), //dxf color code 147
+ aiColor4D (0.0f, 0.2f ,0.3f, 1.0f), //dxf color code 148
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 149
+ aiColor4D (0.0f, 0.5f ,1.0f, 1.0f), //dxf color code 150
+ aiColor4D (0.7f, 0.8f ,1.0f, 1.0f), //dxf color code 151
+ aiColor4D (0.0f, 0.4f ,0.7f, 1.0f), //dxf color code 152
+ aiColor4D (0.5f, 0.6f ,0.7f, 1.0f), //dxf color code 153
+ aiColor4D (0.0f, 0.3f ,0.5f, 1.0f), //dxf color code 154
+ aiColor4D (0.3f, 0.4f ,0.5f, 1.0f), //dxf color code 155
+ aiColor4D (0.0f, 0.2f ,0.4f, 1.0f), //dxf color code 156
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 157
+ aiColor4D (0.0f, 0.2f ,0.3f, 1.0f), //dxf color code 158
+ aiColor4D (0.2f, 0.3f ,0.3f, 1.0f), //dxf color code 159
+ aiColor4D (0.0f, 0.2f ,1.0f, 1.0f), //dxf color code 160
+ aiColor4D (0.7f, 0.7f ,1.0f, 1.0f), //dxf color code 161
+ aiColor4D (0.0f, 0.2f ,0.7f, 1.0f), //dxf color code 162
+ aiColor4D (0.5f, 0.6f ,0.7f, 1.0f), //dxf color code 163
+ aiColor4D (0.0f, 0.1f ,0.5f, 1.0f), //dxf color code 164
+ aiColor4D (0.3f, 0.4f ,0.5f, 1.0f), //dxf color code 165
+ aiColor4D (0.0f, 0.1f ,0.4f, 1.0f), //dxf color code 166
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 167
+ aiColor4D (0.0f, 0.1f ,0.3f, 1.0f), //dxf color code 168
+ aiColor4D (0.2f, 0.2f ,0.3f, 1.0f), //dxf color code 169
+ aiColor4D (0.0f, 0.0f ,1.0f, 1.0f), //dxf color code 170
+ aiColor4D (0.7f, 0.7f ,1.0f, 1.0f), //dxf color code 171
+ aiColor4D (0.0f, 0.0f ,0.7f, 1.0f), //dxf color code 172
+ aiColor4D (0.5f, 0.5f ,0.7f, 1.0f), //dxf color code 173
+ aiColor4D (0.0f, 0.0f ,0.5f, 1.0f), //dxf color code 174
+ aiColor4D (0.3f, 0.3f ,0.5f, 1.0f), //dxf color code 175
+ aiColor4D (0.0f, 0.0f ,0.4f, 1.0f), //dxf color code 176
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 177
+ aiColor4D (0.0f, 0.0f ,0.3f, 1.0f), //dxf color code 178
+ aiColor4D (0.2f, 0.2f ,0.3f, 1.0f), //dxf color code 179
+ aiColor4D (0.2f, 0.0f ,1.0f, 1.0f), //dxf color code 180
+ aiColor4D (0.7f, 0.7f ,1.0f, 1.0f), //dxf color code 181
+ aiColor4D (0.2f, 0.0f ,0.7f, 1.0f), //dxf color code 182
+ aiColor4D (0.6f, 0.5f ,0.7f, 1.0f), //dxf color code 183
+ aiColor4D (0.1f, 0.0f ,0.5f, 1.0f), //dxf color code 184
+ aiColor4D (0.4f, 0.3f ,0.5f, 1.0f), //dxf color code 185
+ aiColor4D (0.1f, 0.0f ,0.4f, 1.0f), //dxf color code 186
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 187
+ aiColor4D (0.1f, 0.0f ,0.3f, 1.0f), //dxf color code 188
+ aiColor4D (0.2f, 0.2f ,0.3f, 1.0f), //dxf color code 189
+ aiColor4D (0.5f, 0.0f ,1.0f, 1.0f), //dxf color code 190
+ aiColor4D (0.8f, 0.7f ,1.0f, 1.0f), //dxf color code 191
+ aiColor4D (0.4f, 0.0f ,0.7f, 1.0f), //dxf color code 192
+ aiColor4D (0.6f, 0.5f ,0.7f, 1.0f), //dxf color code 193
+ aiColor4D (0.3f, 0.0f ,0.5f, 1.0f), //dxf color code 194
+ aiColor4D (0.4f, 0.3f ,0.5f, 1.0f), //dxf color code 195
+ aiColor4D (0.2f, 0.0f ,0.4f, 1.0f), //dxf color code 196
+ aiColor4D (0.3f, 0.3f ,0.4f, 1.0f), //dxf color code 197
+ aiColor4D (0.2f, 0.0f ,0.3f, 1.0f), //dxf color code 198
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 199
+ aiColor4D (0.7f, 0.0f ,1.0f, 1.0f), //dxf color code 200
+ aiColor4D (0.9f, 0.7f ,1.0f, 1.0f), //dxf color code 201
+ aiColor4D (0.6f, 0.0f ,0.7f, 1.0f), //dxf color code 202
+ aiColor4D (0.7f, 0.5f ,0.7f, 1.0f), //dxf color code 203
+ aiColor4D (0.4f, 0.0f ,0.5f, 1.0f), //dxf color code 204
+ aiColor4D (0.5f, 0.3f ,0.5f, 1.0f), //dxf color code 205
+ aiColor4D (0.3f, 0.0f ,0.4f, 1.0f), //dxf color code 206
+ aiColor4D (0.4f, 0.3f ,0.4f, 1.0f), //dxf color code 207
+ aiColor4D (0.2f, 0.0f ,0.3f, 1.0f), //dxf color code 208
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 209
+ aiColor4D (1.0f, 0.0f ,1.0f, 1.0f), //dxf color code 210
+ aiColor4D (1.0f, 0.7f ,1.0f, 1.0f), //dxf color code 211
+ aiColor4D (0.7f, 0.0f ,0.7f, 1.0f), //dxf color code 212
+ aiColor4D (0.7f, 0.5f ,0.7f, 1.0f), //dxf color code 213
+ aiColor4D (0.5f, 0.0f ,0.5f, 1.0f), //dxf color code 214
+ aiColor4D (0.5f, 0.3f ,0.5f, 1.0f), //dxf color code 215
+ aiColor4D (0.4f, 0.0f ,0.4f, 1.0f), //dxf color code 216
+ aiColor4D (0.4f, 0.3f ,0.4f, 1.0f), //dxf color code 217
+ aiColor4D (0.3f, 0.0f ,0.3f, 1.0f), //dxf color code 218
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 219
+ aiColor4D (1.0f, 0.0f ,0.7f, 1.0f), //dxf color code 220
+ aiColor4D (1.0f, 0.7f ,0.9f, 1.0f), //dxf color code 221
+ aiColor4D (0.7f, 0.0f ,0.6f, 1.0f), //dxf color code 222
+ aiColor4D (0.7f, 0.5f ,0.7f, 1.0f), //dxf color code 223
+ aiColor4D (0.5f, 0.0f ,0.4f, 1.0f), //dxf color code 224
+ aiColor4D (0.5f, 0.3f ,0.5f, 1.0f), //dxf color code 225
+ aiColor4D (0.4f, 0.0f ,0.3f, 1.0f), //dxf color code 226
+ aiColor4D (0.4f, 0.3f ,0.4f, 1.0f), //dxf color code 227
+ aiColor4D (0.3f, 0.0f ,0.2f, 1.0f), //dxf color code 228
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 229
+ aiColor4D (1.0f, 0.0f ,0.5f, 1.0f), //dxf color code 230
+ aiColor4D (1.0f, 0.7f ,0.8f, 1.0f), //dxf color code 231
+ aiColor4D (0.7f, 0.0f ,0.4f, 1.0f), //dxf color code 232
+ aiColor4D (0.7f, 0.5f ,0.6f, 1.0f), //dxf color code 233
+ aiColor4D (0.5f, 0.0f ,0.3f, 1.0f), //dxf color code 234
+ aiColor4D (0.5f, 0.3f ,0.4f, 1.0f), //dxf color code 235
+ aiColor4D (0.4f, 0.0f ,0.2f, 1.0f), //dxf color code 236
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 237
+ aiColor4D (0.3f, 0.0f ,0.2f, 1.0f), //dxf color code 238
+ aiColor4D (0.3f, 0.2f ,0.3f, 1.0f), //dxf color code 239
+ aiColor4D (1.0f, 0.0f ,0.2f, 1.0f), //dxf color code 240
+ aiColor4D (1.0f, 0.7f ,0.7f, 1.0f), //dxf color code 241
+ aiColor4D (0.7f, 0.0f ,0.2f, 1.0f), //dxf color code 242
+ aiColor4D (0.7f, 0.5f ,0.6f, 1.0f), //dxf color code 243
+ aiColor4D (0.5f, 0.0f ,0.1f, 1.0f), //dxf color code 244
+ aiColor4D (0.5f, 0.3f ,0.4f, 1.0f), //dxf color code 245
+ aiColor4D (0.4f, 0.0f ,0.1f, 1.0f), //dxf color code 246
+ aiColor4D (0.4f, 0.3f ,0.3f, 1.0f), //dxf color code 247
+ aiColor4D (0.3f, 0.0f ,0.1f, 1.0f), //dxf color code 248
+ aiColor4D (0.3f, 0.2f ,0.2f, 1.0f), //dxf color code 249
+ aiColor4D (0.2f, 0.2f ,0.2f, 1.0f), //dxf color code 250
+ aiColor4D (0.3f, 0.3f ,0.3f, 1.0f), //dxf color code 251
+ aiColor4D (0.4f, 0.4f ,0.4f, 1.0f), //dxf color code 252
+ aiColor4D (0.5f, 0.5f ,0.5f, 1.0f), //dxf color code 253
+ aiColor4D (0.7f, 0.7f ,0.7f, 1.0f), //dxf color code 254
+ aiColor4D (1.0f, 1.0f ,1.0f, 1.0f) //dxf color code 255
};
#define AI_DXF_NUM_INDEX_COLORS (sizeof(g_aclrDxfIndexColors)/sizeof(g_aclrDxfIndexColors[0]))
@@ -372,8 +613,12 @@ void DXFImporter::ExpandBlockReferences(DXF::Block& bl,const DXF::BlockMap& bloc
// XXX order
aiMatrix4x4 trafo, tmp;
aiMatrix4x4::Translation(-bl_src.base,trafo);
- trafo *= aiMatrix4x4::Scaling(insert.scale,tmp);
+ //Need to translate position before scaling the insert
+ //otherwise the position ends up being the position*scaling
+ //STH 2024.01.17
trafo *= aiMatrix4x4::Translation(insert.pos,tmp);
+ trafo *= aiMatrix4x4::Scaling(insert.scale,tmp);
+ //trafo *= aiMatrix4x4::Translation(insert.pos,tmp);
// XXX rotation currently ignored - I didn't find an appropriate sample model.
if (insert.angle != 0.f) {
diff --git a/code/AssetLib/DXF/DXFLoader.h b/code/AssetLib/DXF/DXFLoader.h
index 89a0b79c2..9230bccbd 100644
--- a/code/AssetLib/DXF/DXFLoader.h
+++ b/code/AssetLib/DXF/DXFLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXAnimation.cpp b/code/AssetLib/FBX/FBXAnimation.cpp
index af92ebe51..fdde37f24 100644
--- a/code/AssetLib/FBX/FBXAnimation.cpp
+++ b/code/AssetLib/FBX/FBXAnimation.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
index 55424a6a8..b828090e5 100644
--- a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
+++ b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXCommon.h b/code/AssetLib/FBX/FBXCommon.h
index c3d715892..7e0fb2553 100644
--- a/code/AssetLib/FBX/FBXCommon.h
+++ b/code/AssetLib/FBX/FBXCommon.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXCompileConfig.h b/code/AssetLib/FBX/FBXCompileConfig.h
index 927a3c5f6..9885ca346 100644
--- a/code/AssetLib/FBX/FBXCompileConfig.h
+++ b/code/AssetLib/FBX/FBXCompileConfig.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp
index 62ada774f..cc73756fb 100644
--- a/code/AssetLib/FBX/FBXConverter.cpp
+++ b/code/AssetLib/FBX/FBXConverter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -76,6 +76,53 @@ using namespace Util;
#define CONVERT_FBX_TIME(time) static_cast(time) / 46186158000LL
+static void correctRootTransform(const aiScene *scene) {
+ if (scene == nullptr) {
+ return;
+ }
+
+ if (scene->mMetaData == nullptr) {
+ return;
+ }
+
+ int32_t UpAxis = 1, UpAxisSign = 1, FrontAxis = 2, FrontAxisSign = 1, CoordAxis = 0, CoordAxisSign = 1;
+ double UnitScaleFactor = 1.0;
+ for (unsigned MetadataIndex = 0; MetadataIndex < scene->mMetaData->mNumProperties; ++MetadataIndex) {
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "UpAxis") == 0) {
+ scene->mMetaData->Get(MetadataIndex, UpAxis);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "UpAxisSign") == 0) {
+ scene->mMetaData->Get(MetadataIndex, UpAxisSign);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "FrontAxis") == 0) {
+ scene->mMetaData->Get(MetadataIndex, FrontAxis);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "FrontAxisSign") == 0) {
+ scene->mMetaData->Get(MetadataIndex, FrontAxisSign);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "CoordAxis") == 0) {
+ scene->mMetaData->Get(MetadataIndex, CoordAxis);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "CoordAxisSign") == 0) {
+ scene->mMetaData->Get(MetadataIndex, CoordAxisSign);
+ }
+ if (strcmp(scene->mMetaData->mKeys[MetadataIndex].C_Str(), "UnitScaleFactor") == 0) {
+ scene->mMetaData->Get(MetadataIndex, UnitScaleFactor);
+ }
+ }
+
+ aiVector3D upVec, forwardVec, rightVec;
+ upVec[UpAxis] = UpAxisSign * static_cast(UnitScaleFactor);
+ forwardVec[FrontAxis] = FrontAxisSign * static_cast(UnitScaleFactor);
+ rightVec[CoordAxis] = CoordAxisSign * (float)UnitScaleFactor;
+
+ aiMatrix4x4 mat(rightVec.x, rightVec.y, rightVec.z, 0.0f,
+ upVec.x, upVec.y, upVec.z, 0.0f,
+ forwardVec.x, forwardVec.y, forwardVec.z, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f);
+ scene->mRootNode->mTransformation *= mat;
+}
+
FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) :
defaultMaterialIndex(),
mMeshes(),
@@ -133,6 +180,8 @@ FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBo
// need not contain geometry (i.e. camera animations, raw armatures).
if (out->mNumMeshes == 0) {
out->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;
+ } else {
+ correctRootTransform(mSceneOut);
}
}
@@ -3239,9 +3288,9 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
}
if (keyframeLists[TransformationComp_Rotation].size() > 0) {
- InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], AI_DEG_TO_RAD(defRotation), maxTime, minTime, rotOrder);
+ InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder);
} else {
- aiQuaternion defQuat = EulerToQuaternion(AI_DEG_TO_RAD(defRotation), rotOrder);
+ aiQuaternion defQuat = EulerToQuaternion(defRotation, rotOrder);
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outRotations[i].mValue = defQuat;
@@ -3263,7 +3312,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
const aiVector3D& preRotation = PropertyGet(props, "PreRotation", ok);
if (ok && preRotation.SquareLength() > zero_epsilon) {
- const aiQuaternion preQuat = EulerToQuaternion(AI_DEG_TO_RAD(preRotation), Model::RotOrder_EulerXYZ);
+ const aiQuaternion preQuat = EulerToQuaternion(preRotation, Model::RotOrder_EulerXYZ);
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mValue = preQuat * outRotations[i].mValue;
}
@@ -3271,7 +3320,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
const aiVector3D& postRotation = PropertyGet(props, "PostRotation", ok);
if (ok && postRotation.SquareLength() > zero_epsilon) {
- const aiQuaternion postQuat = EulerToQuaternion(AI_DEG_TO_RAD(postRotation), Model::RotOrder_EulerXYZ);
+ const aiQuaternion postQuat = EulerToQuaternion(postRotation, Model::RotOrder_EulerXYZ);
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mValue = outRotations[i].mValue * postQuat;
}
diff --git a/code/AssetLib/FBX/FBXConverter.h b/code/AssetLib/FBX/FBXConverter.h
index 41acb6ffe..73dc9e5a7 100644
--- a/code/AssetLib/FBX/FBXConverter.h
+++ b/code/AssetLib/FBX/FBXConverter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXDeformer.cpp b/code/AssetLib/FBX/FBXDeformer.cpp
index 8f944527a..582042360 100644
--- a/code/AssetLib/FBX/FBXDeformer.cpp
+++ b/code/AssetLib/FBX/FBXDeformer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXDocument.cpp b/code/AssetLib/FBX/FBXDocument.cpp
index ee4a6632b..3fb0964c4 100644
--- a/code/AssetLib/FBX/FBXDocument.cpp
+++ b/code/AssetLib/FBX/FBXDocument.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXDocument.h b/code/AssetLib/FBX/FBXDocument.h
index 3af757a19..a103321c0 100644
--- a/code/AssetLib/FBX/FBXDocument.h
+++ b/code/AssetLib/FBX/FBXDocument.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXDocumentUtil.cpp b/code/AssetLib/FBX/FBXDocumentUtil.cpp
index c41eb2747..64105f351 100644
--- a/code/AssetLib/FBX/FBXDocumentUtil.cpp
+++ b/code/AssetLib/FBX/FBXDocumentUtil.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExportNode.cpp b/code/AssetLib/FBX/FBXExportNode.cpp
index 21e591425..ae9586968 100644
--- a/code/AssetLib/FBX/FBXExportNode.cpp
+++ b/code/AssetLib/FBX/FBXExportNode.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExportNode.h b/code/AssetLib/FBX/FBXExportNode.h
index 99644b216..7661ab1be 100644
--- a/code/AssetLib/FBX/FBXExportNode.h
+++ b/code/AssetLib/FBX/FBXExportNode.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExportProperty.cpp b/code/AssetLib/FBX/FBXExportProperty.cpp
index 3216d7d85..5fbe84fa7 100644
--- a/code/AssetLib/FBX/FBXExportProperty.cpp
+++ b/code/AssetLib/FBX/FBXExportProperty.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExportProperty.h b/code/AssetLib/FBX/FBXExportProperty.h
index 26d0cf223..93f8cfbe0 100644
--- a/code/AssetLib/FBX/FBXExportProperty.h
+++ b/code/AssetLib/FBX/FBXExportProperty.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp
index 28299544a..ae210eb1a 100644
--- a/code/AssetLib/FBX/FBXExporter.cpp
+++ b/code/AssetLib/FBX/FBXExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -69,6 +69,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#include
#include
+#include
// RESOURCES:
// https://code.blender.org/2013/08/fbx-binary-file-format-specification/
@@ -1062,7 +1063,7 @@ aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene)
}
inline int64_t to_ktime(double ticks, const aiAnimation* anim) {
- if (anim->mTicksPerSecond <= 0) {
+ if (FP_ZERO == std::fpclassify(anim->mTicksPerSecond)) {
return static_cast(ticks) * FBX::SECOND;
}
return (static_cast(ticks / anim->mTicksPerSecond)) * FBX::SECOND;
@@ -1088,6 +1089,8 @@ void FBXExporter::WriteObjects ()
bool bJoinIdenticalVertices = mProperties->GetPropertyBool("bJoinIdenticalVertices", true);
std::vector> vVertexIndice;//save vertex_indices as it is needed later
+ const auto bTransparencyFactorReferencedToOpacity = mProperties->GetPropertyBool(AI_CONFIG_EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY, false);
+
// geometry (aiMesh)
mesh_uids.clear();
indent = 1;
@@ -1444,13 +1447,21 @@ void FBXExporter::WriteObjects ()
// "TransparentColor" / "TransparencyFactor"...
// thanks FBX, for your insightful interpretation of consistency
p.AddP70colorA("TransparentColor", c.r, c.g, c.b);
- // TransparencyFactor defaults to 0.0, so set it to 1.0.
- // note: Maya always sets this to 1.0,
- // so we can't use it sensibly as "Opacity".
- // In stead we rely on the legacy "Opacity" value, below.
- // Blender also relies on "Opacity" not "TransparencyFactor",
- // probably for a similar reason.
- p.AddP70numberA("TransparencyFactor", 1.0);
+
+ if (!bTransparencyFactorReferencedToOpacity) {
+ // TransparencyFactor defaults to 0.0, so set it to 1.0.
+ // note: Maya always sets this to 1.0,
+ // so we can't use it sensibly as "Opacity".
+ // In stead we rely on the legacy "Opacity" value, below.
+ // Blender also relies on "Opacity" not "TransparencyFactor",
+ // probably for a similar reason.
+ p.AddP70numberA("TransparencyFactor", 1.0);
+ }
+ }
+ if (bTransparencyFactorReferencedToOpacity) {
+ if (m->Get(AI_MATKEY_OPACITY, f) == aiReturn_SUCCESS) {
+ p.AddP70numberA("TransparencyFactor", 1.0 - f);
+ }
}
if (m->Get(AI_MATKEY_COLOR_REFLECTIVE, c) == aiReturn_SUCCESS) {
p.AddP70colorA("ReflectionColor", c.r, c.g, c.b);
@@ -1748,7 +1759,7 @@ void FBXExporter::WriteObjects ()
int64_t blendshape_uid = generate_uid();
mesh_uids.push_back(blendshape_uid);
bsnode.AddProperty(blendshape_uid);
- bsnode.AddProperty(blendshape_name + FBX::SEPARATOR + "Blendshape");
+ bsnode.AddProperty(blendshape_name + FBX::SEPARATOR + "Geometry");
bsnode.AddProperty("Shape");
bsnode.AddChild("Version", int32_t(100));
bsnode.Begin(outstream, binary, indent);
@@ -1807,7 +1818,7 @@ void FBXExporter::WriteObjects ()
p.AddP70numberA("DeformPercent", 0.0);
sdnode.AddChild(p);
// TODO: Normally just one weight per channel, adding stub for later development
- std::vectorfFullWeights;
+ std::vectorfFullWeights;
fFullWeights.push_back(100.);
sdnode.AddChild("FullWeights", fFullWeights);
sdnode.Dump(outstream, binary, indent);
diff --git a/code/AssetLib/FBX/FBXExporter.h b/code/AssetLib/FBX/FBXExporter.h
index 659f9368a..df9029196 100644
--- a/code/AssetLib/FBX/FBXExporter.h
+++ b/code/AssetLib/FBX/FBXExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXImportSettings.h b/code/AssetLib/FBX/FBXImportSettings.h
index 698901180..74290f7e0 100644
--- a/code/AssetLib/FBX/FBXImportSettings.h
+++ b/code/AssetLib/FBX/FBXImportSettings.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXImporter.cpp b/code/AssetLib/FBX/FBXImporter.cpp
index afd4b11c1..3a8fb8b8a 100644
--- a/code/AssetLib/FBX/FBXImporter.cpp
+++ b/code/AssetLib/FBX/FBXImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXImporter.h b/code/AssetLib/FBX/FBXImporter.h
index d12b45969..8e8a7db78 100644
--- a/code/AssetLib/FBX/FBXImporter.h
+++ b/code/AssetLib/FBX/FBXImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXMaterial.cpp b/code/AssetLib/FBX/FBXMaterial.cpp
index bcb9bc42a..3872a4b38 100644
--- a/code/AssetLib/FBX/FBXMaterial.cpp
+++ b/code/AssetLib/FBX/FBXMaterial.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp
index 8c6499a91..3b706727a 100644
--- a/code/AssetLib/FBX/FBXMeshGeometry.cpp
+++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXMeshGeometry.h b/code/AssetLib/FBX/FBXMeshGeometry.h
index 3d67ec567..980d1a334 100644
--- a/code/AssetLib/FBX/FBXMeshGeometry.h
+++ b/code/AssetLib/FBX/FBXMeshGeometry.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXModel.cpp b/code/AssetLib/FBX/FBXModel.cpp
index d731d2e29..c108dd78b 100644
--- a/code/AssetLib/FBX/FBXModel.cpp
+++ b/code/AssetLib/FBX/FBXModel.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXNodeAttribute.cpp b/code/AssetLib/FBX/FBXNodeAttribute.cpp
index 34fcdcf77..1e7dfa8c0 100644
--- a/code/AssetLib/FBX/FBXNodeAttribute.cpp
+++ b/code/AssetLib/FBX/FBXNodeAttribute.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXParser.cpp b/code/AssetLib/FBX/FBXParser.cpp
index 7baa7ed39..d0482e067 100644
--- a/code/AssetLib/FBX/FBXParser.cpp
+++ b/code/AssetLib/FBX/FBXParser.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXParser.h b/code/AssetLib/FBX/FBXParser.h
index 5f231738d..63dbb023b 100644
--- a/code/AssetLib/FBX/FBXParser.h
+++ b/code/AssetLib/FBX/FBXParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXProperties.cpp b/code/AssetLib/FBX/FBXProperties.cpp
index 1c050617d..df39098fa 100644
--- a/code/AssetLib/FBX/FBXProperties.cpp
+++ b/code/AssetLib/FBX/FBXProperties.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXProperties.h b/code/AssetLib/FBX/FBXProperties.h
index 18816117a..4799b8056 100644
--- a/code/AssetLib/FBX/FBXProperties.h
+++ b/code/AssetLib/FBX/FBXProperties.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXTokenizer.cpp b/code/AssetLib/FBX/FBXTokenizer.cpp
index 45d5e7750..007e08d46 100644
--- a/code/AssetLib/FBX/FBXTokenizer.cpp
+++ b/code/AssetLib/FBX/FBXTokenizer.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXTokenizer.h b/code/AssetLib/FBX/FBXTokenizer.h
index 05a0725bd..dedfab66a 100644
--- a/code/AssetLib/FBX/FBXTokenizer.h
+++ b/code/AssetLib/FBX/FBXTokenizer.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXUtil.cpp b/code/AssetLib/FBX/FBXUtil.cpp
index e2903c536..a787a9f1d 100644
--- a/code/AssetLib/FBX/FBXUtil.cpp
+++ b/code/AssetLib/FBX/FBXUtil.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/FBX/FBXUtil.h b/code/AssetLib/FBX/FBXUtil.h
index 4674a5054..eb9ae14ed 100644
--- a/code/AssetLib/FBX/FBXUtil.h
+++ b/code/AssetLib/FBX/FBXUtil.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/HMP/HMPFileData.h b/code/AssetLib/HMP/HMPFileData.h
index b297136ba..5f6ca4f55 100644
--- a/code/AssetLib/HMP/HMPFileData.h
+++ b/code/AssetLib/HMP/HMPFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -49,7 +49,7 @@ namespace HMP {
#include
#include
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
#define AI_HMP_MAGIC_NUMBER_BE_4 AI_MAKE_MAGIC("HMP4")
#define AI_HMP_MAGIC_NUMBER_LE_4 AI_MAKE_MAGIC("4PMH")
diff --git a/code/AssetLib/HMP/HMPLoader.cpp b/code/AssetLib/HMP/HMPLoader.cpp
index 5ccb2b474..30931a920 100644
--- a/code/AssetLib/HMP/HMPLoader.cpp
+++ b/code/AssetLib/HMP/HMPLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/HMP/HMPLoader.h b/code/AssetLib/HMP/HMPLoader.h
index 4d5f5f22f..e665b8d18 100644
--- a/code/AssetLib/HMP/HMPLoader.h
+++ b/code/AssetLib/HMP/HMPLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/HMP/HalfLifeFileData.h b/code/AssetLib/HMP/HalfLifeFileData.h
index f47862b7a..687b6108c 100644
--- a/code/AssetLib/HMP/HalfLifeFileData.h
+++ b/code/AssetLib/HMP/HalfLifeFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCBoolean.cpp b/code/AssetLib/IFC/IFCBoolean.cpp
index f4d53990e..559bd7b2f 100644
--- a/code/AssetLib/IFC/IFCBoolean.cpp
+++ b/code/AssetLib/IFC/IFCBoolean.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/IFC/IFCCurve.cpp b/code/AssetLib/IFC/IFCCurve.cpp
index 44165befc..847803dfa 100644
--- a/code/AssetLib/IFC/IFCCurve.cpp
+++ b/code/AssetLib/IFC/IFCCurve.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCGeometry.cpp b/code/AssetLib/IFC/IFCGeometry.cpp
index 83afd2b59..d488b2376 100644
--- a/code/AssetLib/IFC/IFCGeometry.cpp
+++ b/code/AssetLib/IFC/IFCGeometry.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/IFC/IFCLoader.cpp b/code/AssetLib/IFC/IFCLoader.cpp
index c919d9982..9414697df 100644
--- a/code/AssetLib/IFC/IFCLoader.cpp
+++ b/code/AssetLib/IFC/IFCLoader.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCLoader.h b/code/AssetLib/IFC/IFCLoader.h
index 9651b633a..d518650b7 100644
--- a/code/AssetLib/IFC/IFCLoader.h
+++ b/code/AssetLib/IFC/IFCLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCMaterial.cpp b/code/AssetLib/IFC/IFCMaterial.cpp
index 0b7b83e7c..fd4003a67 100644
--- a/code/AssetLib/IFC/IFCMaterial.cpp
+++ b/code/AssetLib/IFC/IFCMaterial.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCOpenings.cpp b/code/AssetLib/IFC/IFCOpenings.cpp
index c47446dda..1d37dd8ef 100644
--- a/code/AssetLib/IFC/IFCOpenings.cpp
+++ b/code/AssetLib/IFC/IFCOpenings.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/IFC/IFCProfile.cpp b/code/AssetLib/IFC/IFCProfile.cpp
index 0e4670560..72a96c29b 100644
--- a/code/AssetLib/IFC/IFCProfile.cpp
+++ b/code/AssetLib/IFC/IFCProfile.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp b/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp
index 73e3c91d8..c625f1daf 100644
--- a/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp
+++ b/code/AssetLib/IFC/IFCReaderGen1_2x3.cpp
@@ -2725,6 +2725,10 @@ template <> size_t GenericFill(const DB& db, const L
do { // convert the 'CompositionType' argument
std::shared_ptr arg = params[base++];
if (dynamic_cast(&*arg)) { in->ObjectHelper::aux_is_derived[1]=true; break; }
+ if (dynamic_cast(&*arg)) {
+ // Consider assigning the default value as in->CompositionType = "ELEMENT".
+ break;
+ }
try { GenericConvert( in->CompositionType, arg, db ); break; }
catch (const TypeError& t) { throw TypeError(t.what() + std::string(" - expected argument 8 to IfcSpatialStructureElement to be a `IfcElementCompositionEnum`")); }
} while (false);
diff --git a/code/AssetLib/IFC/IFCUtil.cpp b/code/AssetLib/IFC/IFCUtil.cpp
index 27f3141c8..3977e22b5 100644
--- a/code/AssetLib/IFC/IFCUtil.cpp
+++ b/code/AssetLib/IFC/IFCUtil.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/IFC/IFCUtil.h b/code/AssetLib/IFC/IFCUtil.h
index f9063ce22..885bcb48f 100644
--- a/code/AssetLib/IFC/IFCUtil.h
+++ b/code/AssetLib/IFC/IFCUtil.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Irr/IRRLoader.cpp b/code/AssetLib/Irr/IRRLoader.cpp
index 99e053892..f41a2543d 100644
--- a/code/AssetLib/Irr/IRRLoader.cpp
+++ b/code/AssetLib/Irr/IRRLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -1234,7 +1234,10 @@ void IRRImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// Parse the XML
// Find the scene root from document root.
const pugi::xml_node &sceneRoot = documentRoot.child("irr_scene");
- if (!sceneRoot) throw new DeadlyImportError("IRR: not found in file");
+ if (!sceneRoot) {
+ delete root;
+ throw new DeadlyImportError("IRR: not found in file");
+ }
for (pugi::xml_node &child : sceneRoot.children()) {
// XML elements are either nodes, animators, attributes, or materials
if (!ASSIMP_stricmp(child.name(), "node")) {
diff --git a/code/AssetLib/Irr/IRRLoader.h b/code/AssetLib/Irr/IRRLoader.h
index 72ad5d35e..2a8bfd562 100644
--- a/code/AssetLib/Irr/IRRLoader.h
+++ b/code/AssetLib/Irr/IRRLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Irr/IRRMeshLoader.cpp b/code/AssetLib/Irr/IRRMeshLoader.cpp
index b35a95c12..4a2f70882 100644
--- a/code/AssetLib/Irr/IRRMeshLoader.cpp
+++ b/code/AssetLib/Irr/IRRMeshLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -69,14 +69,6 @@ static constexpr aiImporterDesc desc = {
"xml irrmesh"
};
-// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-IRRMeshImporter::IRRMeshImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-IRRMeshImporter::~IRRMeshImporter() = default;
-
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool IRRMeshImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
@@ -116,8 +108,9 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
std::unique_ptr file(pIOHandler->Open(pFile));
// Check whether we can read from the file
- if (file == nullptr)
+ if (file == nullptr) {
throw DeadlyImportError("Failed to open IRRMESH file ", pFile);
+ }
// Construct the irrXML parser
XmlParser parser;
@@ -148,13 +141,11 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// int vertexFormat = 0; // 0 = normal; 1 = 2 tcoords, 2 = tangents
bool useColors = false;
- /*
- ** irrmesh files have a top level owning multiple nodes.
- ** Each contains , , and
- ** tags here directly owns the material data specs
- ** are a vertex per line, contains position, UV1 coords, maybe UV2, normal, tangent, bitangent
- ** is ignored, I think assimp recalculates those?
- */
+ // irrmesh files have a top level owning multiple nodes.
+ // Each contains , , and
+ // tags here directly owns the material data specs
+ // are a vertex per line, contains position, UV1 coords, maybe UV2, normal, tangent, bitangent
+ // is ignored, I think assimp recalculates those?
// Parse the XML file
pugi::xml_node const &meshNode = root.child("mesh");
@@ -201,7 +192,6 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// This is possible ... remove the mesh from the list and skip further reading
ASSIMP_LOG_WARN("IRRMESH: Found mesh with zero vertices");
releaseMaterial(&curMat);
- // releaseMesh(&curMesh);
continue; // Bail out early
};
@@ -250,7 +240,9 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
};
// We know what format buffer is, collect numbers
- ParseBufferVertices(verticesNode.text().get(), vertexFormat,
+ std::string v = verticesNode.text().get();
+ const char *end = v.c_str() + v.size();
+ ParseBufferVertices(v.c_str(), end, vertexFormat,
curVertices, curNormals,
curTangents, curBitangents,
curUVs, curUV2s, curColors, useColors);
@@ -329,8 +321,10 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// NOTE this might explode for UTF-16 and wchars
const char *sz = indicesNode.text().get();
+ const char *end = sz + std::strlen(sz);
+
// For each index loop over aiMesh faces
- while (SkipSpacesAndLineEnd(&sz)) {
+ while (SkipSpacesAndLineEnd(&sz, end)) {
if (curFace >= faceEnd) {
ASSIMP_LOG_ERROR("IRRMESH: Too many indices");
break;
@@ -354,12 +348,18 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
// Copy over data to aiMesh
*pcV++ = curVertices[idx];
- if (pcN) *pcN++ = curNormals[idx];
- if (pcT) *pcT++ = curTangents[idx];
- if (pcB) *pcB++ = curBitangents[idx];
- if (pcC0) *pcC0++ = curColors[idx];
- if (pcT0) *pcT0++ = curUVs[idx];
- if (pcT1) *pcT1++ = curUV2s[idx];
+ if (pcN)
+ *pcN++ = curNormals[idx];
+ if (pcT)
+ *pcT++ = curTangents[idx];
+ if (pcB)
+ *pcB++ = curBitangents[idx];
+ if (pcC0)
+ *pcC0++ = curColors[idx];
+ if (pcT0)
+ *pcT0++ = curUVs[idx];
+ if (pcT1)
+ *pcT1++ = curUV2s[idx];
// start new face
if (++curIdx == 3) {
@@ -368,8 +368,9 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
}
}
// We should be at the end of mFaces
- if (curFace != faceEnd)
+ if (curFace != faceEnd) {
ASSIMP_LOG_ERROR("IRRMESH: Not enough indices");
+ }
}
// Finish processing the mesh - do some small material workarounds
@@ -379,8 +380,7 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
aiMaterial *mat = (aiMaterial *)curMat;
mat->AddProperty(&curColors[0].a, 1, AI_MATKEY_OPACITY);
}
- // textMeaning = 2;
-
+
// end of previous buffer. A material and a mesh should be there
if (!curMat || !curMesh) {
ASSIMP_LOG_ERROR("IRRMESH: A buffer must contain a mesh and a material");
@@ -421,37 +421,37 @@ void IRRMeshImporter::InternReadFile(const std::string &pFile,
};
}
-void IRRMeshImporter::ParseBufferVertices(const char *sz, VertexFormat vertexFormat,
+void IRRMeshImporter::ParseBufferVertices(const char *sz, const char *end, VertexFormat vertexFormat,
std::vector &vertices, std::vector &normals,
std::vector &tangents, std::vector &bitangents,
std::vector &UVs, std::vector &UV2s,
std::vector &colors, bool &useColors) {
// read vertices
do {
- SkipSpacesAndLineEnd(&sz);
+ SkipSpacesAndLineEnd(&sz, end);
aiVector3D temp;
aiColor4D c;
// Read the vertex position
sz = fast_atoreal_move(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.z);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
vertices.push_back(temp);
// Read the vertex normals
sz = fast_atoreal_move(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.z);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
normals.push_back(temp);
// read the vertex colors
@@ -463,14 +463,14 @@ void IRRMeshImporter::ParseBufferVertices(const char *sz, VertexFormat vertexFor
useColors = true;
colors.push_back(c);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
// read the first UV coordinate set
sz = fast_atoreal_move(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
temp.z = 0.f;
temp.y = 1.f - temp.y; // DX to OGL
UVs.push_back(temp);
@@ -480,7 +480,7 @@ void IRRMeshImporter::ParseBufferVertices(const char *sz, VertexFormat vertexFor
// read the (optional) second UV coordinate set
if (vertexFormat == VertexFormat::t2coord) {
sz = fast_atoreal_move(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.y);
temp.y = 1.f - temp.y; // DX to OGL
@@ -490,33 +490,32 @@ void IRRMeshImporter::ParseBufferVertices(const char *sz, VertexFormat vertexFor
else if (vertexFormat == VertexFormat::tangent) {
// tangents
sz = fast_atoreal_move(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.z);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
temp.y *= -1.0f;
tangents.push_back(temp);
// bitangents
sz = fast_atoreal_move(sz, (float &)temp.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.z);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
sz = fast_atoreal_move(sz, (float &)temp.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, end);
temp.y *= -1.0f;
bitangents.push_back(temp);
}
- } while (SkipLine(&sz));
- /* IMPORTANT: We assume that each vertex is specified in one
- line. So we can skip the rest of the line - unknown vertex
- elements are ignored.
- */
+ } while (SkipLine(&sz, end));
+ // IMPORTANT: We assume that each vertex is specified in one
+ // line. So we can skip the rest of the line - unknown vertex
+ // elements are ignored.
}
#endif // !! ASSIMP_BUILD_NO_IRRMESH_IMPORTER
diff --git a/code/AssetLib/Irr/IRRMeshLoader.h b/code/AssetLib/Irr/IRRMeshLoader.h
index 620e40dba..4ab3615ee 100644
--- a/code/AssetLib/Irr/IRRMeshLoader.h
+++ b/code/AssetLib/Irr/IRRMeshLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -62,8 +62,11 @@ namespace Assimp {
*/
class IRRMeshImporter : public BaseImporter, public IrrlichtBase {
public:
- IRRMeshImporter();
- ~IRRMeshImporter() override;
+ /// @brief The class constructor.
+ IRRMeshImporter() = default;
+
+ /// @brief The class destructor.
+ ~IRRMeshImporter() override = default;
// -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file.
@@ -93,7 +96,7 @@ private:
tangent = 2, // "tangents" - standard + tangents and bitangents
};
- void ParseBufferVertices(const char *sz, VertexFormat vertexFormat,
+ void ParseBufferVertices(const char *sz, const char *end, VertexFormat vertexFormat,
std::vector &vertices, std::vector &normals,
std::vector &tangents, std::vector &bitangents,
std::vector &UVs, std::vector &UV2s,
diff --git a/code/AssetLib/Irr/IRRShared.cpp b/code/AssetLib/Irr/IRRShared.cpp
index a47aeccba..20d56bb02 100644
--- a/code/AssetLib/Irr/IRRShared.cpp
+++ b/code/AssetLib/Irr/IRRShared.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -135,21 +135,23 @@ void IrrlichtBase::ReadVectorProperty(VectorProperty &out, pugi::xml_node& vecto
} else if (!ASSIMP_stricmp(attrib.name(), "value")) {
// three floats, separated with commas
const char *ptr = attrib.value();
+ size_t len = std::strlen(ptr);
+ const char *end = ptr + len;
- SkipSpaces(&ptr);
+ SkipSpaces(&ptr, end);
ptr = fast_atoreal_move(ptr, (float &)out.value.x);
- SkipSpaces(&ptr);
+ SkipSpaces(&ptr, end);
if (',' != *ptr) {
ASSIMP_LOG_ERROR("IRR(MESH): Expected comma in vector definition");
} else {
- SkipSpaces(ptr + 1, &ptr);
+ SkipSpaces(ptr + 1, &ptr, end);
}
ptr = fast_atoreal_move(ptr, (float &)out.value.y);
- SkipSpaces(&ptr);
+ SkipSpaces(&ptr, end);
if (',' != *ptr) {
ASSIMP_LOG_ERROR("IRR(MESH): Expected comma in vector definition");
} else {
- SkipSpaces(ptr + 1, &ptr);
+ SkipSpaces(ptr + 1, &ptr, end);
}
ptr = fast_atoreal_move(ptr, (float &)out.value.z);
}
diff --git a/code/AssetLib/LWO/LWOAnimation.cpp b/code/AssetLib/LWO/LWOAnimation.cpp
index 8dda4586f..5b9c6882e 100644
--- a/code/AssetLib/LWO/LWOAnimation.cpp
+++ b/code/AssetLib/LWO/LWOAnimation.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOAnimation.h b/code/AssetLib/LWO/LWOAnimation.h
index 1e419d461..9daa7009c 100644
--- a/code/AssetLib/LWO/LWOAnimation.h
+++ b/code/AssetLib/LWO/LWOAnimation.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOBLoader.cpp b/code/AssetLib/LWO/LWOBLoader.cpp
index 4a9792b79..b5c14f158 100644
--- a/code/AssetLib/LWO/LWOBLoader.cpp
+++ b/code/AssetLib/LWO/LWOBLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
@@ -152,7 +152,7 @@ void LWOImporter::CountVertsAndFacesLWOB(unsigned int& verts, unsigned int& face
}
// ------------------------------------------------------------------------------------------------
-void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator& it,
+void LWOImporter::CopyFaceIndicesLWOB(FaceList::iterator &it,
LE_NCONST uint16_t*& cursor,
const uint16_t* const end,
unsigned int max) {
diff --git a/code/AssetLib/LWO/LWOFileData.h b/code/AssetLib/LWO/LWOFileData.h
index 656dd4529..c81111251 100644
--- a/code/AssetLib/LWO/LWOFileData.h
+++ b/code/AssetLib/LWO/LWOFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOLoader.cpp b/code/AssetLib/LWO/LWOLoader.cpp
index 7e93b65f8..025ca7408 100644
--- a/code/AssetLib/LWO/LWOLoader.cpp
+++ b/code/AssetLib/LWO/LWOLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOLoader.h b/code/AssetLib/LWO/LWOLoader.h
index 9e116a3cc..3f81ff449 100644
--- a/code/AssetLib/LWO/LWOLoader.h
+++ b/code/AssetLib/LWO/LWOLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/LWO/LWOMaterial.cpp b/code/AssetLib/LWO/LWOMaterial.cpp
index 8d83dfb67..1d7d137e1 100644
--- a/code/AssetLib/LWO/LWOMaterial.cpp
+++ b/code/AssetLib/LWO/LWOMaterial.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/AssetLib/LWS/LWSLoader.cpp b/code/AssetLib/LWS/LWSLoader.cpp
index dec834495..4c3a44785 100644
--- a/code/AssetLib/LWS/LWSLoader.cpp
+++ b/code/AssetLib/LWS/LWSLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -78,14 +78,14 @@ static constexpr aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Recursive parsing of LWS files
-void LWS::Element::Parse(const char *&buffer) {
- for (; SkipSpacesAndLineEnd(&buffer); SkipLine(&buffer)) {
+void LWS::Element::Parse(const char *&buffer, const char *end) {
+ for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
// begin of a new element with children
bool sub = false;
if (*buffer == '{') {
++buffer;
- SkipSpaces(&buffer);
+ SkipSpaces(&buffer, end);
sub = true;
} else if (*buffer == '}')
return;
@@ -98,16 +98,15 @@ void LWS::Element::Parse(const char *&buffer) {
while (!IsSpaceOrNewLine(*buffer))
++buffer;
children.back().tokens[0] = std::string(cur, (size_t)(buffer - cur));
- SkipSpaces(&buffer);
+ SkipSpaces(&buffer, end);
if (children.back().tokens[0] == "Plugin") {
ASSIMP_LOG_VERBOSE_DEBUG("LWS: Skipping over plugin-specific data");
// strange stuff inside Plugin/Endplugin blocks. Needn't
// follow LWS syntax, so we skip over it
- for (; SkipSpacesAndLineEnd(&buffer); SkipLine(&buffer)) {
+ for (; SkipSpacesAndLineEnd(&buffer, end); SkipLine(&buffer, end)) {
if (!::strncmp(buffer, "EndPlugin", 9)) {
- //SkipLine(&buffer);
break;
}
}
@@ -122,7 +121,7 @@ void LWS::Element::Parse(const char *&buffer) {
// parse more elements recursively
if (sub) {
- children.back().Parse(buffer);
+ children.back().Parse(buffer, end);
}
}
}
@@ -155,6 +154,8 @@ const aiImporterDesc *LWSImporter::GetInfo() const {
return &desc;
}
+static constexpr int MagicHackNo = 150392;
+
// ------------------------------------------------------------------------------------------------
// Setup configuration properties
void LWSImporter::SetupProperties(const Importer *pImp) {
@@ -163,11 +164,11 @@ void LWSImporter::SetupProperties(const Importer *pImp) {
// AI_CONFIG_IMPORT_LWS_ANIM_START
first = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_LWS_ANIM_START,
- 150392 /* magic hack */);
+ MagicHackNo /* magic hack */);
// AI_CONFIG_IMPORT_LWS_ANIM_END
last = pImp->GetPropertyInteger(AI_CONFIG_IMPORT_LWS_ANIM_END,
- 150392 /* magic hack */);
+ MagicHackNo /* magic hack */);
if (last < first) {
std::swap(last, first);
@@ -191,15 +192,16 @@ void LWSImporter::ReadEnvelope(const LWS::Element &dad, LWO::Envelope &fill) {
for (++it; it != dad.children.end(); ++it) {
const char *c = (*it).tokens[1].c_str();
+ const char *end = c + (*it).tokens[1].size();
if ((*it).tokens[0] == "Key") {
fill.keys.emplace_back();
LWO::Key &key = fill.keys.back();
float f;
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move(c, key.value);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move(c, f);
key.time = f;
@@ -231,13 +233,13 @@ void LWSImporter::ReadEnvelope(const LWS::Element &dad, LWO::Envelope &fill) {
ASSIMP_LOG_ERROR("LWS: Unknown span type");
}
for (unsigned int i = 0; i < num; ++i) {
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move(c, key.params[i]);
}
} else if ((*it).tokens[0] == "Behaviors") {
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
fill.pre = (LWO::PrePostBehaviour)strtoul10(c, &c);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
fill.post = (LWO::PrePostBehaviour)strtoul10(c, &c);
}
}
@@ -245,47 +247,45 @@ void LWSImporter::ReadEnvelope(const LWS::Element &dad, LWO::Envelope &fill) {
// ------------------------------------------------------------------------------------------------
// Read animation channels in the old LightWave animation format
-void LWSImporter::ReadEnvelope_Old(
- std::list::const_iterator &it,
- const std::list::const_iterator &end,
- LWS::NodeDesc &nodes,
- unsigned int /*version*/) {
- unsigned int num, sub_num;
- if (++it == end) goto unexpected_end;
+void LWSImporter::ReadEnvelope_Old(std::list::const_iterator &it,const std::list::const_iterator &endIt,
+ LWS::NodeDesc &nodes, unsigned int) {
+ if (++it == endIt) {
+ ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion");
+ return;
+ }
- num = strtoul10((*it).tokens[0].c_str());
+ const unsigned int num = strtoul10((*it).tokens[0].c_str());
for (unsigned int i = 0; i < num; ++i) {
-
nodes.channels.emplace_back();
LWO::Envelope &envl = nodes.channels.back();
envl.index = i;
envl.type = (LWO::EnvelopeType)(i + 1);
- if (++it == end) {
- goto unexpected_end;
+ if (++it == endIt) {
+ ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion");
+ return;
}
- sub_num = strtoul10((*it).tokens[0].c_str());
-
+
+ const unsigned int sub_num = strtoul10((*it).tokens[0].c_str());
for (unsigned int n = 0; n < sub_num; ++n) {
-
- if (++it == end) goto unexpected_end;
+ if (++it == endIt) {
+ ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion");
+ return;
+ }
// parse value and time, skip the rest for the moment.
LWO::Key key;
const char *c = fast_atoreal_move((*it).tokens[0].c_str(), key.value);
- SkipSpaces(&c);
+ const char *end = c + (*it).tokens[0].size();
+ SkipSpaces(&c, end);
float f;
fast_atoreal_move((*it).tokens[0].c_str(), f);
key.time = f;
- envl.keys.push_back(key);
+ envl.keys.emplace_back(key);
}
}
- return;
-
-unexpected_end:
- ASSIMP_LOG_ERROR("LWS: Encountered unexpected end of file while parsing object motion");
}
// ------------------------------------------------------------------------------------------------
@@ -296,7 +296,6 @@ void LWSImporter::SetupNodeName(aiNode *nd, LWS::NodeDesc &src) {
// the name depends on the type. We break LWS's strange naming convention
// and return human-readable, but still machine-parsable and unique, strings.
if (src.type == LWS::NodeDesc::OBJECT) {
-
if (src.path.length()) {
std::string::size_type s = src.path.find_last_of("\\/");
if (s == std::string::npos) {
@@ -501,7 +500,8 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// Parse the file structure
LWS::Element root;
const char *dummy = &mBuffer[0];
- root.Parse(dummy);
+ const char *dummyEnd = dummy + mBuffer.size();
+ root.Parse(dummy, dummyEnd);
// Construct a Batch-importer to read more files recursively
BatchLoader batch(pIOHandler);
@@ -540,6 +540,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// Now read all elements in a very straightforward manner
for (; it != root.children.end(); ++it) {
const char *c = (*it).tokens[1].c_str();
+ const char *end = c + (*it).tokens[1].size();
// 'FirstFrame': begin of animation slice
if ((*it).tokens[0] == "FirstFrame") {
@@ -567,14 +568,14 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
LWS::NodeDesc d;
d.type = LWS::NodeDesc::OBJECT;
if (version >= 4) { // handle LWSC 4 explicit ID
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
d.number = strtoul16(c, &c) & AI_LWS_MASK;
} else {
d.number = cur_object++;
}
// and add the file to the import list
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
std::string path = FindLWOFile(c);
d.path = path;
d.id = batch.AddLoadRequest(path, 0, &props);
@@ -588,7 +589,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (version >= 4) { // handle LWSC 4 explicit ID
d.number = strtoul16(c, &c) & AI_LWS_MASK;
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
} else {
d.number = cur_object++;
}
@@ -604,7 +605,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
d.type = LWS::NodeDesc::OBJECT;
if (version >= 4) { // handle LWSC 4 explicit ID
d.number = strtoul16(c, &c) & AI_LWS_MASK;
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
} else {
d.number = cur_object++;
}
@@ -668,26 +669,25 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// two ints per envelope
LWO::Envelope &env = *envelopeIt;
env.pre = (LWO::PrePostBehaviour)strtoul10(c, &c);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
env.post = (LWO::PrePostBehaviour)strtoul10(c, &c);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
}
}
}
// 'ParentItem': specifies the parent of the current element
else if ((*it).tokens[0] == "ParentItem") {
- if (nodes.empty())
+ if (nodes.empty()) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'ParentItem\'");
-
- else
+ } else {
nodes.back().parent = strtoul16(c, &c);
+ }
}
// 'ParentObject': deprecated one for older formats
else if (version < 3 && (*it).tokens[0] == "ParentObject") {
- if (nodes.empty())
+ if (nodes.empty()) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'ParentObject\'");
-
- else {
+ } else {
nodes.back().parent = strtoul10(c, &c) | (1u << 28u);
}
}
@@ -700,19 +700,20 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (version >= 4) { // handle LWSC 4 explicit ID
d.number = strtoul16(c, &c) & AI_LWS_MASK;
- } else
+ } else {
d.number = cur_camera++;
+ }
nodes.push_back(d);
num_camera++;
}
// 'CameraName': set name of currently active camera
else if ((*it).tokens[0] == "CameraName") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::CAMERA)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::CAMERA) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'CameraName\'");
-
- else
+ } else {
nodes.back().name = c;
+ }
}
// 'AddLight': add a light to the scenegraph
else if ((*it).tokens[0] == "AddLight") {
@@ -723,19 +724,20 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
if (version >= 4) { // handle LWSC 4 explicit ID
d.number = strtoul16(c, &c) & AI_LWS_MASK;
- } else
+ } else {
d.number = cur_light++;
+ }
nodes.push_back(d);
num_light++;
}
// 'LightName': set name of currently active light
else if ((*it).tokens[0] == "LightName") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightName\'");
-
- else
+ } else {
nodes.back().name = c;
+ }
}
// 'LightIntensity': set intensity of currently active light
else if ((*it).tokens[0] == "LightIntensity" || (*it).tokens[0] == "LgtIntensity") {
@@ -753,62 +755,58 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
}
// 'LightType': set type of currently active light
else if ((*it).tokens[0] == "LightType") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightType\'");
-
- else
+ } else {
nodes.back().lightType = strtoul10(c);
-
+ }
}
// 'LightFalloffType': set falloff type of currently active light
else if ((*it).tokens[0] == "LightFalloffType") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightFalloffType\'");
- else
+ } else {
nodes.back().lightFalloffType = strtoul10(c);
-
+ }
}
// 'LightConeAngle': set cone angle of currently active light
else if ((*it).tokens[0] == "LightConeAngle") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightConeAngle\'");
-
- else
+ } else {
nodes.back().lightConeAngle = fast_atof(c);
-
+ }
}
// 'LightEdgeAngle': set area where we're smoothing from min to max intensity
else if ((*it).tokens[0] == "LightEdgeAngle") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightEdgeAngle\'");
-
- else
+ } else {
nodes.back().lightEdgeAngle = fast_atof(c);
-
+ }
}
// 'LightColor': set color of currently active light
else if ((*it).tokens[0] == "LightColor") {
- if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
+ if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightColor\'");
-
- else {
+ } else {
c = fast_atoreal_move(c, (float &)nodes.back().lightColor.r);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move(c, (float &)nodes.back().lightColor.g);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move(c, (float &)nodes.back().lightColor.b);
}
}
// 'PivotPosition': position of local transformation origin
else if ((*it).tokens[0] == "PivotPosition" || (*it).tokens[0] == "PivotPoint") {
- if (nodes.empty())
+ if (nodes.empty()) {
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'PivotPosition\'");
- else {
+ } else {
c = fast_atoreal_move(c, (float &)nodes.back().pivotPos.x);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move(c, (float &)nodes.back().pivotPos.y);
- SkipSpaces(&c);
+ SkipSpaces(&c, end);
c = fast_atoreal_move(c, (float &)nodes.back().pivotPos.z);
// Mark pivotPos as set
nodes.back().isPivotSet = true;
@@ -818,7 +816,6 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// resolve parenting
for (std::list::iterator ndIt = nodes.begin(); ndIt != nodes.end(); ++ndIt) {
-
// check whether there is another node which calls us a parent
for (std::list::iterator dit = nodes.begin(); dit != nodes.end(); ++dit) {
if (dit != ndIt && *ndIt == (*dit).parent) {
@@ -854,7 +851,7 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
aiNode *nd = master->mRootNode = new aiNode();
// allocate storage for cameras&lights
- if (num_camera) {
+ if (num_camera > 0u) {
master->mCameras = new aiCamera *[master->mNumCameras = num_camera];
}
aiCamera **cams = master->mCameras;
diff --git a/code/AssetLib/LWS/LWSLoader.h b/code/AssetLib/LWS/LWSLoader.h
index 4e92ef0d5..f66688249 100644
--- a/code/AssetLib/LWS/LWSLoader.h
+++ b/code/AssetLib/LWS/LWSLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -76,7 +76,7 @@ public:
std::list children;
//! Recursive parsing function
- void Parse(const char *&buffer);
+ void Parse(const char *&buffer, const char *end);
};
#define AI_LWS_MASK (0xffffffff >> 4u)
diff --git a/code/AssetLib/M3D/M3DExporter.cpp b/code/AssetLib/M3D/M3DExporter.cpp
index cf87b6221..5545be415 100644
--- a/code/AssetLib/M3D/M3DExporter.cpp
+++ b/code/AssetLib/M3D/M3DExporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DExporter.h b/code/AssetLib/M3D/M3DExporter.h
index d77743f56..0e9ab4305 100644
--- a/code/AssetLib/M3D/M3DExporter.h
+++ b/code/AssetLib/M3D/M3DExporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DImporter.cpp b/code/AssetLib/M3D/M3DImporter.cpp
index 71f416139..b74b72dc8 100644
--- a/code/AssetLib/M3D/M3DImporter.cpp
+++ b/code/AssetLib/M3D/M3DImporter.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DImporter.h b/code/AssetLib/M3D/M3DImporter.h
index 9ca8f9211..d9e546f39 100644
--- a/code/AssetLib/M3D/M3DImporter.h
+++ b/code/AssetLib/M3D/M3DImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DMaterials.h b/code/AssetLib/M3D/M3DMaterials.h
index a1b0fd742..dc87a99c7 100644
--- a/code/AssetLib/M3D/M3DMaterials.h
+++ b/code/AssetLib/M3D/M3DMaterials.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DWrapper.cpp b/code/AssetLib/M3D/M3DWrapper.cpp
index 05087d592..3741bbca3 100644
--- a/code/AssetLib/M3D/M3DWrapper.cpp
+++ b/code/AssetLib/M3D/M3DWrapper.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/M3D/M3DWrapper.h b/code/AssetLib/M3D/M3DWrapper.h
index 880aca996..8a3fd92be 100644
--- a/code/AssetLib/M3D/M3DWrapper.h
+++ b/code/AssetLib/M3D/M3DWrapper.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
Copyright (c) 2019 bzt
All rights reserved.
diff --git a/code/AssetLib/MD2/MD2FileData.h b/code/AssetLib/MD2/MD2FileData.h
index 3bce8feee..0dba71e56 100644
--- a/code/AssetLib/MD2/MD2FileData.h
+++ b/code/AssetLib/MD2/MD2FileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -55,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace MD2 {
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
#define AI_MD2_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDP2")
#define AI_MD2_MAGIC_NUMBER_LE AI_MAKE_MAGIC("2PDI")
diff --git a/code/AssetLib/MD2/MD2Loader.cpp b/code/AssetLib/MD2/MD2Loader.cpp
index 596d26414..99dc70d08 100644
--- a/code/AssetLib/MD2/MD2Loader.cpp
+++ b/code/AssetLib/MD2/MD2Loader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MD2/MD2Loader.h b/code/AssetLib/MD2/MD2Loader.h
index bab026ea0..5ac34ad4c 100644
--- a/code/AssetLib/MD2/MD2Loader.h
+++ b/code/AssetLib/MD2/MD2Loader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MD2/MD2NormalTable.h b/code/AssetLib/MD2/MD2NormalTable.h
index 1837939e8..7d13b9ad1 100644
--- a/code/AssetLib/MD2/MD2NormalTable.h
+++ b/code/AssetLib/MD2/MD2NormalTable.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MD3/MD3FileData.h b/code/AssetLib/MD3/MD3FileData.h
index 01475e679..86d2647b6 100644
--- a/code/AssetLib/MD3/MD3FileData.h
+++ b/code/AssetLib/MD3/MD3FileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -62,7 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace MD3 {
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
#define AI_MD3_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDP3")
#define AI_MD3_MAGIC_NUMBER_LE AI_MAKE_MAGIC("3PDI")
diff --git a/code/AssetLib/MD3/MD3Loader.cpp b/code/AssetLib/MD3/MD3Loader.cpp
index e743889e3..3dd8d9c66 100644
--- a/code/AssetLib/MD3/MD3Loader.cpp
+++ b/code/AssetLib/MD3/MD3Loader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
@@ -123,12 +123,12 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
// remove comments from it (C++ style)
CommentRemover::RemoveLineComments("//", &_buff[0]);
const char *buff = &_buff[0];
-
+ const char *end = buff + _buff.size();
Q3Shader::ShaderDataBlock *curData = nullptr;
Q3Shader::ShaderMapBlock *curMap = nullptr;
// read line per line
- for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) {
+ for (; SkipSpacesAndLineEnd(&buff, end); SkipLine(&buff, end)) {
if (*buff == '{') {
++buff;
@@ -140,21 +140,21 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
}
// read this data section
- for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) {
+ for (; SkipSpacesAndLineEnd(&buff, end); SkipLine(&buff, end)) {
if (*buff == '{') {
++buff;
// add new map section
curData->maps.emplace_back();
curMap = &curData->maps.back();
- for (; SkipSpacesAndLineEnd(&buff); SkipLine(&buff)) {
+ for (; SkipSpacesAndLineEnd(&buff, end); SkipLine(&buff, end)) {
// 'map' - Specifies texture file name
if (TokenMatchI(buff, "map", 3) || TokenMatchI(buff, "clampmap", 8)) {
- curMap->name = GetNextToken(buff);
+ curMap->name = GetNextToken(buff, end);
}
// 'blendfunc' - Alpha blending mode
else if (TokenMatchI(buff, "blendfunc", 9)) {
- const std::string blend_src = GetNextToken(buff);
+ const std::string blend_src = GetNextToken(buff, end);
if (blend_src == "add") {
curMap->blend_src = Q3Shader::BLEND_GL_ONE;
curMap->blend_dest = Q3Shader::BLEND_GL_ONE;
@@ -166,12 +166,12 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
curMap->blend_dest = Q3Shader::BLEND_GL_ONE_MINUS_SRC_ALPHA;
} else {
curMap->blend_src = StringToBlendFunc(blend_src);
- curMap->blend_dest = StringToBlendFunc(GetNextToken(buff));
+ curMap->blend_dest = StringToBlendFunc(GetNextToken(buff, end));
}
}
// 'alphafunc' - Alpha testing mode
else if (TokenMatchI(buff, "alphafunc", 9)) {
- const std::string at = GetNextToken(buff);
+ const std::string at = GetNextToken(buff, end);
if (at == "GT0") {
curMap->alpha_test = Q3Shader::AT_GT0;
} else if (at == "LT128") {
@@ -186,7 +186,6 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
break;
}
}
-
} else if (*buff == '}') {
++buff;
curData = nullptr;
@@ -195,7 +194,7 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
// 'cull' specifies culling behaviour for the model
else if (TokenMatchI(buff, "cull", 4)) {
- SkipSpaces(&buff);
+ SkipSpaces(&buff, end);
if (!ASSIMP_strincmp(buff, "back", 4)) { // render face's backside, does not function in Q3 engine (bug)
curData->cull = Q3Shader::CULL_CCW;
} else if (!ASSIMP_strincmp(buff, "front", 5)) { // is not valid keyword in Q3, but occurs in shaders
@@ -213,9 +212,10 @@ bool Q3Shader::LoadShader(ShaderData &fill, const std::string &pFile, IOSystem *
curData = &fill.blocks.back();
// get the name of this section
- curData->name = GetNextToken(buff);
+ curData->name = GetNextToken(buff, end);
}
}
+
return true;
}
@@ -232,6 +232,7 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io)
const size_t s = file->FileSize();
std::vector _buff(s + 1);
const char *buff = &_buff[0];
+ const char *end = buff + _buff.size();
file->Read(&_buff[0], s, 1);
_buff[s] = 0;
@@ -240,10 +241,10 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io)
// read token by token and fill output table
for (; *buff;) {
- SkipSpacesAndLineEnd(&buff);
+ SkipSpacesAndLineEnd(&buff, end);
// get first identifier
- std::string ss = GetNextToken(buff);
+ std::string ss = GetNextToken(buff, end);
// ignore tokens starting with tag_
if (!::strncmp(&ss[0], "tag_", std::min((size_t)4, ss.length())))
@@ -253,8 +254,9 @@ bool Q3Shader::LoadSkin(SkinData &fill, const std::string &pFile, IOSystem *io)
SkinData::TextureEntry &entry = fill.textures.back();
entry.first = ss;
- entry.second = GetNextToken(buff);
+ entry.second = GetNextToken(buff, end);
}
+
return true;
}
@@ -293,7 +295,7 @@ void Q3Shader::ConvertShaderToMaterial(aiMaterial *out, const ShaderDataBlock &s
// - in any case: set it as diffuse texture
//
// If the texture is using 'filter' blending
- // - take as lightmap
+ // - take as light-map
//
// Textures with alpha funcs
// - aiTextureFlags_UseAlpha is set (otherwise aiTextureFlags_NoAlpha is explicitly set)
diff --git a/code/AssetLib/MD3/MD3Loader.h b/code/AssetLib/MD3/MD3Loader.h
index d911bb1da..eee66a3df 100644
--- a/code/AssetLib/MD3/MD3Loader.h
+++ b/code/AssetLib/MD3/MD3Loader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MD5/MD5Loader.cpp b/code/AssetLib/MD5/MD5Loader.cpp
index 697e758fb..0976484a4 100644
--- a/code/AssetLib/MD5/MD5Loader.cpp
+++ b/code/AssetLib/MD5/MD5Loader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -210,7 +210,7 @@ void MD5Importer::MakeDataUnique(MD5::MeshDesc &meshSrc) {
const unsigned int guess = (unsigned int)(fWeightsPerVert * iNewNum);
meshSrc.mWeights.reserve(guess + (guess >> 3)); // + 12.5% as buffer
- for (FaceList::const_iterator iter = meshSrc.mFaces.begin(), iterEnd = meshSrc.mFaces.end(); iter != iterEnd; ++iter) {
+ for (FaceArray::const_iterator iter = meshSrc.mFaces.begin(), iterEnd = meshSrc.mFaces.end(); iter != iterEnd; ++iter) {
const aiFace &face = *iter;
for (unsigned int i = 0; i < 3; ++i) {
if (face.mIndices[0] >= meshSrc.mVertices.size()) {
@@ -231,7 +231,7 @@ void MD5Importer::MakeDataUnique(MD5::MeshDesc &meshSrc) {
// ------------------------------------------------------------------------------------------------
// Recursive node graph construction from a MD5MESH
-void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &bones) {
+void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneArray &bones) {
ai_assert(nullptr != piParent);
ai_assert(!piParent->mNumChildren);
@@ -282,7 +282,7 @@ void MD5Importer::AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &b
// ------------------------------------------------------------------------------------------------
// Recursive node graph construction from a MD5ANIM
-void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneList &bones, const aiNodeAnim **node_anims) {
+void MD5Importer::AttachChilds_Anim(int iParentID, aiNode *piParent, AnimBoneArray &bones, const aiNodeAnim **node_anims) {
ai_assert(nullptr != piParent);
ai_assert(!piParent->mNumChildren);
@@ -402,7 +402,7 @@ void MD5Importer::LoadMD5MeshFile() {
// copy texture coordinates
aiVector3D *pv = mesh->mTextureCoords[0];
- for (MD5::VertexList::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
+ for (MD5::VertexArray::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
pv->x = (*iter).mUV.x;
pv->y = 1.0f - (*iter).mUV.y; // D3D to OpenGL
pv->z = 0.0f;
@@ -412,7 +412,7 @@ void MD5Importer::LoadMD5MeshFile() {
unsigned int *piCount = new unsigned int[meshParser.mJoints.size()];
::memset(piCount, 0, sizeof(unsigned int) * meshParser.mJoints.size());
- for (MD5::VertexList::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
+ for (MD5::VertexArray::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights; ++w) {
MD5::WeightDesc &weightDesc = meshSrc.mWeights[w];
/* FIX for some invalid exporters */
@@ -447,7 +447,7 @@ void MD5Importer::LoadMD5MeshFile() {
}
pv = mesh->mVertices;
- for (MD5::VertexList::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
+ for (MD5::VertexArray::const_iterator iter = meshSrc.mVertices.begin(); iter != meshSrc.mVertices.end(); ++iter, ++pv) {
// compute the final vertex position from all single weights
*pv = aiVector3D();
@@ -585,14 +585,14 @@ void MD5Importer::LoadMD5AnimFile() {
// 1 tick == 1 frame
anim->mTicksPerSecond = animParser.fFrameRate;
- for (FrameList::const_iterator iter = animParser.mFrames.begin(), iterEnd = animParser.mFrames.end(); iter != iterEnd; ++iter) {
+ for (FrameArray::const_iterator iter = animParser.mFrames.begin(), iterEnd = animParser.mFrames.end(); iter != iterEnd; ++iter) {
double dTime = (double)(*iter).iIndex;
aiNodeAnim **pcAnimNode = anim->mChannels;
if (!(*iter).mValues.empty() || iter == animParser.mFrames.begin()) /* be sure we have at least one frame */
{
// now process all values in there ... read all joints
MD5::BaseFrameDesc *pcBaseFrame = &animParser.mBaseFrames[0];
- for (AnimBoneList::const_iterator iter2 = animParser.mAnimatedBones.begin(); iter2 != animParser.mAnimatedBones.end(); ++iter2,
+ for (AnimBoneArray::const_iterator iter2 = animParser.mAnimatedBones.begin(); iter2 != animParser.mAnimatedBones.end(); ++iter2,
++pcAnimNode, ++pcBaseFrame) {
if ((*iter2).iFirstKeyIndex >= (*iter).mValues.size()) {
diff --git a/code/AssetLib/MD5/MD5Loader.h b/code/AssetLib/MD5/MD5Loader.h
index c213c04e6..d64d6f5b8 100644
--- a/code/AssetLib/MD5/MD5Loader.h
+++ b/code/AssetLib/MD5/MD5Loader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -118,7 +118,7 @@ protected:
* @param node_anims Generated node animations
*/
void AttachChilds_Anim(int iParentID, aiNode *piParent,
- AnimBoneList &bones, const aiNodeAnim **node_anims);
+ AnimBoneArray &bones, const aiNodeAnim **node_anims);
// -------------------------------------------------------------------
/** Construct node hierarchy from a given MD5MESH
@@ -126,7 +126,7 @@ protected:
* @param piParent Parent node to attach to
* @param bones Input bones
*/
- void AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneList &bones);
+ void AttachChilds_Mesh(int iParentID, aiNode *piParent, BoneArray &bones);
// -------------------------------------------------------------------
/** Build unique vertex buffers from a given MD5ANIM
diff --git a/code/AssetLib/MD5/MD5Parser.cpp b/code/AssetLib/MD5/MD5Parser.cpp
index 8da30e28f..24882af7e 100644
--- a/code/AssetLib/MD5/MD5Parser.cpp
+++ b/code/AssetLib/MD5/MD5Parser.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -138,14 +138,16 @@ bool MD5Parser::ParseSection(Section &out) {
char *sz = buffer;
while (!IsSpaceOrNewLine(*buffer)) {
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
out.mName = std::string(sz, (uintptr_t)(buffer - sz));
while (IsSpace(*buffer)) {
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
bool running = true;
@@ -153,14 +155,16 @@ bool MD5Parser::ParseSection(Section &out) {
if ('{' == *buffer) {
// it is a normal section so read all lines
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
bool run = true;
while (run) {
while (IsSpaceOrNewLine(*buffer)) {
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
if ('\0' == *buffer) {
return false; // seems this was the last section
@@ -175,18 +179,21 @@ bool MD5Parser::ParseSection(Section &out) {
elem.iLineNumber = lineNumber;
elem.szStart = buffer;
+ elem.end = bufferEnd;
// terminate the line with zero
while (!IsLineEnd(*buffer)) {
++buffer;
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
if (*buffer) {
++lineNumber;
*buffer++ = '\0';
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
}
break;
@@ -194,89 +201,107 @@ bool MD5Parser::ParseSection(Section &out) {
// it is an element at global scope. Parse its value and go on
sz = buffer;
while (!IsSpaceOrNewLine(*buffer++)) {
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
}
out.mGlobalValue = std::string(sz, (uintptr_t)(buffer - sz));
continue;
}
break;
}
- if (buffer == bufferEnd)
+ if (buffer == bufferEnd) {
return false;
+ }
while (IsSpaceOrNewLine(*buffer)) {
+ if (buffer == bufferEnd) {
+ break;
+ }
++buffer;
- if (buffer == bufferEnd)
- return false;
}
return '\0' != *buffer;
}
-// ------------------------------------------------------------------------------------------------
-// Some dirty macros just because they're so funny and easy to debug
-
// skip all spaces ... handle EOL correctly
-#define AI_MD5_SKIP_SPACES() \
- if (!SkipSpaces(&sz)) \
- MD5Parser::ReportWarning("Unexpected end of line", elem.iLineNumber);
+inline void AI_MD5_SKIP_SPACES(const char **sz, const char *bufferEnd, int linenumber) {
+ if (!SkipSpaces(sz, bufferEnd)) {
+ MD5Parser::ReportWarning("Unexpected end of line", linenumber);
+ }
+}
// read a triple float in brackets: (1.0 1.0 1.0)
-#define AI_MD5_READ_TRIPLE(vec) \
- AI_MD5_SKIP_SPACES(); \
- if ('(' != *sz++) \
- MD5Parser::ReportWarning("Unexpected token: ( was expected", elem.iLineNumber); \
- AI_MD5_SKIP_SPACES(); \
- sz = fast_atoreal_move(sz, (float &)vec.x); \
- AI_MD5_SKIP_SPACES(); \
- sz = fast_atoreal_move(sz, (float &)vec.y); \
- AI_MD5_SKIP_SPACES(); \
- sz = fast_atoreal_move(sz, (float &)vec.z); \
- AI_MD5_SKIP_SPACES(); \
- if (')' != *sz++) \
- MD5Parser::ReportWarning("Unexpected token: ) was expected", elem.iLineNumber);
+inline void AI_MD5_READ_TRIPLE(aiVector3D &vec, const char **sz, const char *bufferEnd, int linenumber) {
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ if ('(' != **sz) {
+ MD5Parser::ReportWarning("Unexpected token: ( was expected", linenumber);
+ ++*sz;
+ }
+ ++*sz;
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ *sz = fast_atoreal_move(*sz, (float &)vec.x);
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ *sz = fast_atoreal_move(*sz, (float &)vec.y);
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ *sz = fast_atoreal_move(*sz, (float &)vec.z);
+ AI_MD5_SKIP_SPACES(sz, bufferEnd, linenumber);
+ if (')' != **sz) {
+ MD5Parser::ReportWarning("Unexpected token: ) was expected", linenumber);
+ }
+ ++*sz;
+}
// parse a string, enclosed in quotation marks or not
-#define AI_MD5_PARSE_STRING(out) \
- bool bQuota = (*sz == '\"'); \
- const char *szStart = sz; \
- while (!IsSpaceOrNewLine(*sz)) \
- ++sz; \
- const char *szEnd = sz; \
- if (bQuota) { \
- szStart++; \
- if ('\"' != *(szEnd -= 1)) { \
- MD5Parser::ReportWarning("Expected closing quotation marks in string", \
- elem.iLineNumber); \
- continue; \
- } \
- } \
- out.length = (size_t)(szEnd - szStart); \
- ::memcpy(out.data, szStart, out.length); \
+inline bool AI_MD5_PARSE_STRING(const char **sz, const char *bufferEnd, aiString &out, int linenumber) {
+ bool bQuota = (**sz == '\"');
+ const char *szStart = *sz;
+ while (!IsSpaceOrNewLine(**sz)) {
+ ++*sz;
+ if (*sz == bufferEnd) break;
+ }
+ const char *szEnd = *sz;
+ if (bQuota) {
+ szStart++;
+ if ('\"' != *(szEnd -= 1)) {
+ MD5Parser::ReportWarning("Expected closing quotation marks in string", linenumber);
+ ++*sz;
+ }
+ }
+ out.length = (ai_uint32)(szEnd - szStart);
+ ::memcpy(out.data, szStart, out.length);
out.data[out.length] = '\0';
+ return true;
+}
+
// parse a string, enclosed in quotation marks
-#define AI_MD5_PARSE_STRING_IN_QUOTATION(out) \
- out.length = 0; \
- while ('\"' != *sz && '\0' != *sz) \
- ++sz; \
- if ('\0' != *sz) { \
- const char *szStart = ++sz; \
- while ('\"' != *sz && '\0' != *sz) \
- ++sz; \
- if ('\0' != *sz) { \
- const char *szEnd = (sz++); \
- out.length = (ai_uint32)(szEnd - szStart); \
- ::memcpy(out.data, szStart, out.length); \
- } \
- } \
+inline void AI_MD5_PARSE_STRING_IN_QUOTATION(const char **sz, const char *bufferEnd, aiString &out) {
+ out.length = 0u;
+ while (('\"' != **sz && '\0' != **sz) && *sz != bufferEnd) {
+ ++*sz;
+ }
+ if ('\0' != **sz) {
+ const char *szStart = ++(*sz);
+
+ while (('\"' != **sz && '\0' != **sz) && *sz != bufferEnd) {
+ ++*sz;
+ }
+ if ('\0' != **sz) {
+ const char *szEnd = *sz;
+ ++*sz;
+ out.length = (ai_uint32)(szEnd - szStart);
+ ::memcpy(out.data, szStart, out.length);
+ }
+ }
out.data[out.length] = '\0';
+}
+
// ------------------------------------------------------------------------------------------------
// .MD5MESH parsing function
-MD5MeshParser::MD5MeshParser(SectionList &mSections) {
+MD5MeshParser::MD5MeshParser(SectionArray &mSections) {
ASSIMP_LOG_DEBUG("MD5MeshParser begin");
// now parse all sections
- for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+ for (SectionArray::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
if ((*iter).mName == "numMeshes") {
mMeshes.reserve(::strtoul10((*iter).mGlobalValue.c_str()));
} else if ((*iter).mName == "numJoints") {
@@ -288,14 +313,15 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) {
BoneDesc &desc = mJoints.back();
const char *sz = elem.szStart;
- AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_PARSE_STRING_IN_QUOTATION(&sz, elem.end, desc.mName);
+
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
// negative values, at least -1, is allowed here
desc.mParentIndex = (int)strtol10(sz, &sz);
- AI_MD5_READ_TRIPLE(desc.mPositionXYZ);
- AI_MD5_READ_TRIPLE(desc.mRotationQuat); // normalized quaternion, so w is not there
+ AI_MD5_READ_TRIPLE(desc.mPositionXYZ, &sz, elem.end, elem.iLineNumber);
+ AI_MD5_READ_TRIPLE(desc.mRotationQuat, &sz, elem.end, elem.iLineNumber); // normalized quaternion, so w is not there
}
} else if ((*iter).mName == "mesh") {
mMeshes.emplace_back();
@@ -306,52 +332,52 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) {
// shader attribute
if (TokenMatch(sz, "shader", 6)) {
- AI_MD5_SKIP_SPACES();
- AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mShader);
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
+ AI_MD5_PARSE_STRING_IN_QUOTATION(&sz, elem.end, desc.mShader);
}
// numverts attribute
else if (TokenMatch(sz, "numverts", 8)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
desc.mVertices.resize(strtoul10(sz));
}
// numtris attribute
else if (TokenMatch(sz, "numtris", 7)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
desc.mFaces.resize(strtoul10(sz));
}
// numweights attribute
else if (TokenMatch(sz, "numweights", 10)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
desc.mWeights.resize(strtoul10(sz));
}
// vert attribute
// "vert 0 ( 0.394531 0.513672 ) 0 1"
else if (TokenMatch(sz, "vert", 4)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
const unsigned int idx = ::strtoul10(sz, &sz);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
if (idx >= desc.mVertices.size())
desc.mVertices.resize(idx + 1);
VertexDesc &vert = desc.mVertices[idx];
if ('(' != *sz++)
MD5Parser::ReportWarning("Unexpected token: ( was expected", elem.iLineNumber);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
sz = fast_atoreal_move(sz, (float &)vert.mUV.x);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
sz = fast_atoreal_move(sz, (float &)vert.mUV.y);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
if (')' != *sz++)
MD5Parser::ReportWarning("Unexpected token: ) was expected", elem.iLineNumber);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
vert.mFirstWeight = ::strtoul10(sz, &sz);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
vert.mNumWeights = ::strtoul10(sz, &sz);
}
// tri attribute
// "tri 0 15 13 12"
else if (TokenMatch(sz, "tri", 3)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
const unsigned int idx = strtoul10(sz, &sz);
if (idx >= desc.mFaces.size())
desc.mFaces.resize(idx + 1);
@@ -359,24 +385,24 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) {
aiFace &face = desc.mFaces[idx];
face.mIndices = new unsigned int[face.mNumIndices = 3];
for (unsigned int i = 0; i < 3; ++i) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
face.mIndices[i] = strtoul10(sz, &sz);
}
}
// weight attribute
// "weight 362 5 0.500000 ( -3.553583 11.893474 9.719339 )"
else if (TokenMatch(sz, "weight", 6)) {
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
const unsigned int idx = strtoul10(sz, &sz);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
if (idx >= desc.mWeights.size())
desc.mWeights.resize(idx + 1);
WeightDesc &weight = desc.mWeights[idx];
weight.mBone = strtoul10(sz, &sz);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
sz = fast_atoreal_move(sz, weight.mWeight);
- AI_MD5_READ_TRIPLE(weight.vOffsetPosition);
+ AI_MD5_READ_TRIPLE(weight.vOffsetPosition, &sz, elem.end, elem.iLineNumber);
}
}
}
@@ -386,12 +412,12 @@ MD5MeshParser::MD5MeshParser(SectionList &mSections) {
// ------------------------------------------------------------------------------------------------
// .MD5ANIM parsing function
-MD5AnimParser::MD5AnimParser(SectionList &mSections) {
+MD5AnimParser::MD5AnimParser(SectionArray &mSections) {
ASSIMP_LOG_DEBUG("MD5AnimParser begin");
fFrameRate = 24.0f;
mNumAnimatedComponents = UINT_MAX;
- for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+ for (SectionArray::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
if ((*iter).mName == "hierarchy") {
// "sheath" 0 63 6
for (const auto &elem : (*iter).mElements) {
@@ -399,18 +425,18 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) {
AnimBoneDesc &desc = mAnimatedBones.back();
const char *sz = elem.szStart;
- AI_MD5_PARSE_STRING_IN_QUOTATION(desc.mName);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_PARSE_STRING_IN_QUOTATION(&sz, elem.end, desc.mName);
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
// parent index - negative values are allowed (at least -1)
desc.mParentIndex = ::strtol10(sz, &sz);
// flags (highest is 2^6-1)
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
if (63 < (desc.iFlags = ::strtoul10(sz, &sz))) {
MD5Parser::ReportWarning("Invalid flag combination in hierarchy section", elem.iLineNumber);
}
- AI_MD5_SKIP_SPACES();
+ AI_MD5_SKIP_SPACES(& sz, elem.end, elem.iLineNumber);
// index of the first animation keyframe component for this joint
desc.iFirstKeyIndex = ::strtoul10(sz, &sz);
@@ -423,8 +449,8 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) {
mBaseFrames.emplace_back();
BaseFrameDesc &desc = mBaseFrames.back();
- AI_MD5_READ_TRIPLE(desc.vPositionXYZ);
- AI_MD5_READ_TRIPLE(desc.vRotationQuat);
+ AI_MD5_READ_TRIPLE(desc.vPositionXYZ, &sz, elem.end, elem.iLineNumber);
+ AI_MD5_READ_TRIPLE(desc.vRotationQuat, &sz, elem.end, elem.iLineNumber);
}
} else if ((*iter).mName == "frame") {
if (!(*iter).mGlobalValue.length()) {
@@ -444,7 +470,7 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) {
// now read all elements (continuous list of floats)
for (const auto &elem : (*iter).mElements) {
const char *sz = elem.szStart;
- while (SkipSpacesAndLineEnd(&sz)) {
+ while (SkipSpacesAndLineEnd(&sz, elem.end)) {
float f;
sz = fast_atoreal_move(sz, f);
desc.mValues.push_back(f);
@@ -471,11 +497,11 @@ MD5AnimParser::MD5AnimParser(SectionList &mSections) {
// ------------------------------------------------------------------------------------------------
// .MD5CAMERA parsing function
-MD5CameraParser::MD5CameraParser(SectionList &mSections) {
+MD5CameraParser::MD5CameraParser(SectionArray &mSections) {
ASSIMP_LOG_DEBUG("MD5CameraParser begin");
fFrameRate = 24.0f;
- for (SectionList::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
+ for (SectionArray::const_iterator iter = mSections.begin(), iterEnd = mSections.end(); iter != iterEnd; ++iter) {
if ((*iter).mName == "numFrames") {
frames.reserve(strtoul10((*iter).mGlobalValue.c_str()));
} else if ((*iter).mName == "frameRate") {
@@ -492,9 +518,9 @@ MD5CameraParser::MD5CameraParser(SectionList &mSections) {
frames.emplace_back();
CameraAnimFrameDesc &cur = frames.back();
- AI_MD5_READ_TRIPLE(cur.vPositionXYZ);
- AI_MD5_READ_TRIPLE(cur.vRotationQuat);
- AI_MD5_SKIP_SPACES();
+ AI_MD5_READ_TRIPLE(cur.vPositionXYZ, &sz, elem.end, elem.iLineNumber);
+ AI_MD5_READ_TRIPLE(cur.vRotationQuat, &sz, elem.end, elem.iLineNumber);
+ AI_MD5_SKIP_SPACES(&sz, elem.end, elem.iLineNumber);
cur.fFOV = fast_atof(sz);
}
}
diff --git a/code/AssetLib/MD5/MD5Parser.h b/code/AssetLib/MD5/MD5Parser.h
index 9b29fbe85..75e3c22f2 100644
--- a/code/AssetLib/MD5/MD5Parser.h
+++ b/code/AssetLib/MD5/MD5Parser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2023, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -68,12 +68,14 @@ struct Element {
//! Elements are terminated with \0
char* szStart;
+ const char *end;
+
//! Original line number (can be used in error messages
//! if a parsing error occurs)
unsigned int iLineNumber;
};
-using ElementList = std::vector;
+using ElementArray = std::vector;
// ---------------------------------------------------------------------------
/** Represents a section of a MD5 file (such as the mesh or the joints section)
@@ -86,7 +88,7 @@ struct Section {
unsigned int iLineNumber;
//! List of all elements which have been parsed in this section.
- ElementList mElements;
+ ElementArray mElements;
//! Name of the section
std::string mName;
@@ -96,7 +98,7 @@ struct Section {
std::string mGlobalValue;
};
-using SectionList = std::vector;
+using SectionArray = std::vector;
// ---------------------------------------------------------------------------
/** Basic information about a joint
@@ -132,7 +134,7 @@ struct BoneDesc : BaseJointDescription {
unsigned int mMap;
};
-using BoneList = std::vector;
+using BoneArray = std::vector;
// ---------------------------------------------------------------------------
/** Represents a bone (joint) descriptor in a MD5Anim file
@@ -145,7 +147,7 @@ struct AnimBoneDesc : BaseJointDescription {
unsigned int iFirstKeyIndex;
};
-using AnimBoneList = std::vector< AnimBoneDesc >;
+using AnimBoneArray = std::vector< AnimBoneDesc >;
// ---------------------------------------------------------------------------
/** Represents a base frame descriptor in a MD5Anim file
@@ -155,7 +157,7 @@ struct BaseFrameDesc {
aiVector3D vRotationQuat;
};
-using BaseFrameList = std::vector;
+using BaseFrameArray = std::vector;
// ---------------------------------------------------------------------------
/** Represents a camera animation frame in a MDCamera file
@@ -164,7 +166,7 @@ struct CameraAnimFrameDesc : BaseFrameDesc {
float fFOV;
};
-using CameraFrameList = std::vector;
+using CameraFrameArray = std::vector;
// ---------------------------------------------------------------------------
/** Represents a frame descriptor in a MD5Anim file
@@ -177,7 +179,7 @@ struct FrameDesc {
std::vector< float > mValues;
};
-using FrameList = std::vector;
+using FrameArray = std::vector;
// ---------------------------------------------------------------------------
/** Represents a vertex descriptor in a MD5 file
@@ -199,7 +201,7 @@ struct VertexDesc {
unsigned int mNumWeights;
};
-using VertexList = std::vector;
+using VertexArray = std::vector;
// ---------------------------------------------------------------------------
/** Represents a vertex weight descriptor in a MD5 file
@@ -216,27 +218,27 @@ struct WeightDesc {
aiVector3D vOffsetPosition;
};
-using WeightList = std::vector;
-using FaceList = std::vector;
+using WeightArray = std::vector;
+using FaceArray = std::vector;
// ---------------------------------------------------------------------------
/** Represents a mesh in a MD5 file
*/
struct MeshDesc {
//! Weights of the mesh
- WeightList mWeights;
+ WeightArray mWeights;
//! Vertices of the mesh
- VertexList mVertices;
+ VertexArray mVertices;
//! Faces of the mesh
- FaceList mFaces;
+ FaceArray mFaces;
//! Name of the shader (=texture) to be assigned to the mesh
aiString mShader;
};
-using MeshList = std::vector;
+using MeshArray = std::vector;
// ---------------------------------------------------------------------------
// Convert a quaternion to its usual representation
@@ -269,13 +271,13 @@ public:
*
* @param mSections List of file sections (output of MD5Parser)
*/
- explicit MD5MeshParser(SectionList& mSections);
+ explicit MD5MeshParser(SectionArray& mSections);
//! List of all meshes
- MeshList mMeshes;
+ MeshArray mMeshes;
//! List of all joints
- BoneList mJoints;
+ BoneArray mJoints;
};
// remove this flag if you need to the bounding box data
@@ -292,20 +294,20 @@ public:
*
* @param mSections List of file sections (output of MD5Parser)
*/
- explicit MD5AnimParser(SectionList& mSections);
+ explicit MD5AnimParser(SectionArray& mSections);
//! Output frame rate
float fFrameRate;
//! List of animation bones
- AnimBoneList mAnimatedBones;
+ AnimBoneArray mAnimatedBones;
//! List of base frames
- BaseFrameList mBaseFrames;
+ BaseFrameArray mBaseFrames;
//! List of animation frames
- FrameList mFrames;
+ FrameArray mFrames;
//! Number of animated components
unsigned int mNumAnimatedComponents;
@@ -322,7 +324,7 @@ public:
*
* @param mSections List of file sections (output of MD5Parser)
*/
- explicit MD5CameraParser(SectionList& mSections);
+ explicit MD5CameraParser(SectionArray& mSections);
//! Output frame rate
float fFrameRate;
@@ -331,7 +333,7 @@ public:
std::vector cuts;
//! Frames
- CameraFrameList frames;
+ CameraFrameArray frames;
};
// ---------------------------------------------------------------------------
@@ -375,7 +377,7 @@ public:
void ReportWarning (const char* warn);
//! List of all sections which have been read
- SectionList mSections;
+ SectionArray mSections;
private:
bool ParseSection(Section& out);
@@ -388,7 +390,7 @@ private:
private:
char* buffer;
- char* bufferEnd;
+ const char* bufferEnd;
unsigned int fileSize;
unsigned int lineNumber;
};
@@ -406,7 +408,7 @@ inline void MD5Parser::ReportError(const char* error) {
// -------------------------------------------------------------------
inline bool MD5Parser::SkipLine(const char* in, const char** out) {
++lineNumber;
- return Assimp::SkipLine(in ,out);
+ return Assimp::SkipLine(in, out, bufferEnd);
}
// -------------------------------------------------------------------
@@ -450,7 +452,7 @@ inline bool MD5Parser::SkipSpacesAndLineEnd() {
// -------------------------------------------------------------------
inline bool MD5Parser::SkipSpaces() {
- return Assimp::SkipSpaces((const char**)&buffer);
+ return Assimp::SkipSpaces((const char**)&buffer, bufferEnd);
}
} // namespace Assimp
diff --git a/code/AssetLib/MDC/MDCFileData.h b/code/AssetLib/MDC/MDCFileData.h
index 36c589e91..4c5b4127c 100644
--- a/code/AssetLib/MDC/MDCFileData.h
+++ b/code/AssetLib/MDC/MDCFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -61,7 +61,7 @@ http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf
namespace Assimp {
namespace MDC {
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
#define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI")
#define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC")
diff --git a/code/AssetLib/MDC/MDCLoader.cpp b/code/AssetLib/MDC/MDCLoader.cpp
index 87247adec..c81ba67a6 100644
--- a/code/AssetLib/MDC/MDCLoader.cpp
+++ b/code/AssetLib/MDC/MDCLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDC/MDCLoader.h b/code/AssetLib/MDC/MDCLoader.h
index a1f8d9fc9..09ecc6865 100644
--- a/code/AssetLib/MDC/MDCLoader.h
+++ b/code/AssetLib/MDC/MDCLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1FileData.h b/code/AssetLib/MDL/HalfLife/HL1FileData.h
index 28b1b2822..485f538ab 100644
--- a/code/AssetLib/MDL/HalfLife/HL1FileData.h
+++ b/code/AssetLib/MDL/HalfLife/HL1FileData.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h b/code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h
index d412aeede..344574d24 100644
--- a/code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h
+++ b/code/AssetLib/MDL/HalfLife/HL1ImportDefinitions.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1ImportSettings.h b/code/AssetLib/MDL/HalfLife/HL1ImportSettings.h
index 340ba2da5..52f98cb58 100644
--- a/code/AssetLib/MDL/HalfLife/HL1ImportSettings.h
+++ b/code/AssetLib/MDL/HalfLife/HL1ImportSettings.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
index a8141fcc1..2d7f6a7c2 100644
--- a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
+++ b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h
index 286b6e64c..ab5bb6942 100644
--- a/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h
+++ b/code/AssetLib/MDL/HalfLife/HL1MDLLoader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h b/code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h
index 4ef8a13ce..9c389a659 100644
--- a/code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h
+++ b/code/AssetLib/MDL/HalfLife/HL1MeshTrivert.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h b/code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h
index c7808c401..25ef27bca 100644
--- a/code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h
+++ b/code/AssetLib/MDL/HalfLife/HalfLifeMDLBaseHeader.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/LogFunctions.h b/code/AssetLib/MDL/HalfLife/LogFunctions.h
index 003774dc1..c8cdf9b15 100644
--- a/code/AssetLib/MDL/HalfLife/LogFunctions.h
+++ b/code/AssetLib/MDL/HalfLife/LogFunctions.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp
index 3cca8c558..b79ec3613 100644
--- a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp
+++ b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h
index 73b6f9e74..cf190bc3b 100644
--- a/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h
+++ b/code/AssetLib/MDL/HalfLife/UniqueNameGenerator.h
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/MDLDefaultColorMap.h b/code/AssetLib/MDL/MDLDefaultColorMap.h
index 2eecac2dc..cbdc977ad 100644
--- a/code/AssetLib/MDL/MDLDefaultColorMap.h
+++ b/code/AssetLib/MDL/MDLDefaultColorMap.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/MDLFileData.h b/code/AssetLib/MDL/MDLFileData.h
index 7ec2afe9a..2aff59856 100644
--- a/code/AssetLib/MDL/MDLFileData.h
+++ b/code/AssetLib/MDL/MDLFileData.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -67,7 +67,7 @@ namespace Assimp {
namespace MDL {
// -------------------------------------------------------------------------------------
-// to make it easier for us, we test the magic word against both "endianesses"
+// to make it easier for us, we test the magic word against both "endiannesses"
// magic bytes used in Quake 1 MDL meshes
#define AI_MDL_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDPO")
diff --git a/code/AssetLib/MDL/MDLLoader.cpp b/code/AssetLib/MDL/MDLLoader.cpp
index 2b14fe980..99b0145af 100644
--- a/code/AssetLib/MDL/MDLLoader.cpp
+++ b/code/AssetLib/MDL/MDLLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/MDLLoader.h b/code/AssetLib/MDL/MDLLoader.h
index 333f7c8b1..f99f061ce 100644
--- a/code/AssetLib/MDL/MDLLoader.h
+++ b/code/AssetLib/MDL/MDLLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MDL/MDLMaterialLoader.cpp b/code/AssetLib/MDL/MDLMaterialLoader.cpp
index 3d39fa645..38c42c1a5 100644
--- a/code/AssetLib/MDL/MDLMaterialLoader.cpp
+++ b/code/AssetLib/MDL/MDLMaterialLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -123,9 +123,8 @@ aiColor4D MDLImporter::ReplaceTextureWithColor(const aiTexture *pcTexture) {
// Read a texture from a MDL3 file
void MDLImporter::CreateTextureARGB8_3DGS_MDL3(const unsigned char *szData) {
const MDL::Header *pcHeader = (const MDL::Header *)mBuffer; //the endianness is already corrected in the InternReadFile_3DGS_MDL345 function
-
- VALIDATE_FILE_SIZE(szData + pcHeader->skinwidth *
- pcHeader->skinheight);
+ const size_t len = pcHeader->skinwidth * pcHeader->skinheight;
+ VALIDATE_FILE_SIZE(szData + len);
// allocate a new texture object
aiTexture *pcNew = new aiTexture();
diff --git a/code/AssetLib/MMD/MMDCpp14.h b/code/AssetLib/MMD/MMDCpp14.h
index 10d376829..4a04bf69e 100644
--- a/code/AssetLib/MMD/MMDCpp14.h
+++ b/code/AssetLib/MMD/MMDCpp14.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MMD/MMDImporter.cpp b/code/AssetLib/MMD/MMDImporter.cpp
index b96d45c98..1e88cefd2 100644
--- a/code/AssetLib/MMD/MMDImporter.cpp
+++ b/code/AssetLib/MMD/MMDImporter.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MMD/MMDImporter.h b/code/AssetLib/MMD/MMDImporter.h
index 1f584bf12..71fc534a4 100644
--- a/code/AssetLib/MMD/MMDImporter.h
+++ b/code/AssetLib/MMD/MMDImporter.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/MMD/MMDPmdParser.h b/code/AssetLib/MMD/MMDPmdParser.h
index 23aaac555..b11c72f8d 100644
--- a/code/AssetLib/MMD/MMDPmdParser.h
+++ b/code/AssetLib/MMD/MMDPmdParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MMD/MMDPmxParser.cpp b/code/AssetLib/MMD/MMDPmxParser.cpp
index 6b04f02e9..5a3e61dcd 100644
--- a/code/AssetLib/MMD/MMDPmxParser.cpp
+++ b/code/AssetLib/MMD/MMDPmxParser.cpp
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MMD/MMDPmxParser.h b/code/AssetLib/MMD/MMDPmxParser.h
index 424fc725a..e90e554e7 100644
--- a/code/AssetLib/MMD/MMDPmxParser.h
+++ b/code/AssetLib/MMD/MMDPmxParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MMD/MMDVmdParser.h b/code/AssetLib/MMD/MMDVmdParser.h
index d5c7dedff..2ba9fb931 100644
--- a/code/AssetLib/MMD/MMDVmdParser.h
+++ b/code/AssetLib/MMD/MMDVmdParser.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/MS3D/MS3DLoader.cpp b/code/AssetLib/MS3D/MS3DLoader.cpp
index e0f0f8b5a..fac102f5f 100644
--- a/code/AssetLib/MS3D/MS3DLoader.cpp
+++ b/code/AssetLib/MS3D/MS3DLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
diff --git a/code/AssetLib/MS3D/MS3DLoader.h b/code/AssetLib/MS3D/MS3DLoader.h
index 3e25f1f59..5a28391eb 100644
--- a/code/AssetLib/MS3D/MS3DLoader.h
+++ b/code/AssetLib/MS3D/MS3DLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/NDO/NDOLoader.cpp b/code/AssetLib/NDO/NDOLoader.cpp
index 405438dfc..3515c14b4 100644
--- a/code/AssetLib/NDO/NDOLoader.cpp
+++ b/code/AssetLib/NDO/NDOLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/NDO/NDOLoader.h b/code/AssetLib/NDO/NDOLoader.h
index c4f127851..c3ab15230 100644
--- a/code/AssetLib/NDO/NDOLoader.h
+++ b/code/AssetLib/NDO/NDOLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
diff --git a/code/AssetLib/NFF/NFFLoader.cpp b/code/AssetLib/NFF/NFFLoader.cpp
index 78adc27bd..481a4bc19 100644
--- a/code/AssetLib/NFF/NFFLoader.cpp
+++ b/code/AssetLib/NFF/NFFLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -85,7 +85,7 @@ const aiImporterDesc *NFFImporter::GetInfo() const {
// ------------------------------------------------------------------------------------------------
#define AI_NFF_PARSE_FLOAT(f) \
- SkipSpaces(&sz); \
+ SkipSpaces(&sz, lineEnd); \
if (!IsLineEnd(*sz)) sz = fast_atoreal_move(sz, (ai_real &)f);
// ------------------------------------------------------------------------------------------------
@@ -111,7 +111,7 @@ const aiImporterDesc *NFFImporter::GetInfo() const {
ASSIMP_LOG_WARN("NFF2: Unexpected EOF, can't read next token"); \
break; \
} \
- SkipSpaces(line, &sz); \
+ SkipSpaces(line, &sz, lineEnd); \
} while (IsLineEnd(*sz))
// ------------------------------------------------------------------------------------------------
@@ -148,9 +148,9 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector &output,
// No read the file line per line
char line[4096];
- const char *sz;
+ const char *sz, *lineEnd = &line[2095]+1;
while (GetNextLine(buffer, line)) {
- SkipSpaces(line, &sz);
+ SkipSpaces(line, &sz, lineEnd);
// 'version' defines the version of the file format
if (TokenMatch(sz, "version", 7)) {
@@ -198,18 +198,16 @@ void NFFImporter::LoadNFF2MaterialTable(std::vector &output,
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
-void NFFImporter::InternReadFile(const std::string &pFile,
- aiScene *pScene, IOSystem *pIOHandler) {
- std::unique_ptr file(pIOHandler->Open(pFile, "rb"));
-
- // Check whether we can read from the file
- if (!file)
- throw DeadlyImportError("Failed to open NFF file ", pFile, ".");
+void NFFImporter::InternReadFile(const std::string &file, aiScene *pScene, IOSystem *pIOHandler) {
+ std::unique_ptr stream(pIOHandler->Open(file, "rb"));
+ if (!stream) {
+ throw DeadlyImportError("Failed to open NFF file ", file, ".");
+ }
// allocate storage and copy the contents of the file to a memory buffer
// (terminate it with zero)
std::vector mBuffer2;
- TextFileToBuffer(file.get(), mBuffer2);
+ TextFileToBuffer(stream.get(), mBuffer2);
const char *buffer = &mBuffer2[0];
// mesh arrays - separate here to make the handling of the pointers below easier.
@@ -219,8 +217,10 @@ void NFFImporter::InternReadFile(const std::string &pFile,
std::vector meshesLocked;
char line[4096];
+ const char *lineEnd = &line[4096];
const char *sz;
+
// camera parameters
aiVector3D camPos, camUp(0.f, 1.f, 0.f), camLookAt(0.f, 0.f, 1.f);
ai_real angle = 45.f;
@@ -265,7 +265,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
CommentRemover::RemoveLineComments("//", &mBuffer2[0]);
while (GetNextLine(buffer, line)) {
- SkipSpaces(line, &sz);
+ SkipSpaces(line, &sz, lineEnd);
if (TokenMatch(sz, "version", 7)) {
ASSIMP_LOG_INFO("NFF (Sense8) file format: ", sz);
} else if (TokenMatch(sz, "viewpos", 7)) {
@@ -295,7 +295,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// material table - an external file
if (TokenMatch(sz, "mtable", 6)) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz3 = sz;
while (!IsSpaceOrNewLine(*sz))
++sz;
@@ -316,12 +316,12 @@ void NFFImporter::InternReadFile(const std::string &pFile,
std::string::size_type sepPos;
if ((std::string::npos == (sepPos = path.find_last_of('\\')) || !sepPos) &&
(std::string::npos == (sepPos = path.find_last_of('/')) || !sepPos)) {
- sepPos = pFile.find_last_of('\\');
+ sepPos = file.find_last_of('\\');
if (std::string::npos == sepPos) {
- sepPos = pFile.find_last_of('/');
+ sepPos = file.find_last_of('/');
}
if (std::string::npos != sepPos) {
- path = pFile.substr(0, sepPos + 1) + path;
+ path = file.substr(0, sepPos + 1) + path;
}
}
LoadNFF2MaterialTable(materialTable, path, pIOHandler);
@@ -351,7 +351,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// parse all other attributes in the line
while (true) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
if (IsLineEnd(*sz)) break;
// color definition
@@ -403,23 +403,20 @@ void NFFImporter::InternReadFile(const std::string &pFile,
tempIdx.reserve(10);
for (unsigned int i = 0; i < num; ++i) {
AI_NFF2_GET_NEXT_TOKEN();
- SkipSpaces(line, &sz);
+ SkipSpaces(line, &sz, lineEnd);
unsigned int numIdx = strtoul10(sz, &sz);
// read all faces indices
if (numIdx) {
- // mesh.faces.push_back(numIdx);
- // tempIdx.erase(tempIdx.begin(),tempIdx.end());
tempIdx.resize(numIdx);
for (unsigned int a = 0; a < numIdx; ++a) {
- SkipSpaces(sz, &sz);
+ SkipSpaces(sz, &sz, lineEnd);
unsigned int m = strtoul10(sz, &sz);
if (m >= (unsigned int)tempPositions.size()) {
ASSIMP_LOG_ERROR("NFF2: Vertex index overflow");
m = 0;
}
- // mesh.vertices.push_back (tempPositions[idx]);
tempIdx[a] = m;
}
}
@@ -432,7 +429,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
shader.color = aiColor3D(1.f, 1.f, 1.f);
aiColor4D c = aiColor4D(1.f, 1.f, 1.f, 1.f);
while (true) {
- SkipSpaces(sz, &sz);
+ SkipSpaces(sz, &sz, lineEnd);
if (IsLineEnd(*sz)) break;
// per-polygon colors
@@ -510,7 +507,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// Material ID?
else if (!materialTable.empty() && TokenMatch(sz, "matid", 5)) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
matIdx = strtoul10(sz, &sz);
if (matIdx >= materialTable.size()) {
ASSIMP_LOG_ERROR("NFF2: Material index overflow.");
@@ -527,7 +524,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
shader.specular = mat.specular;
shader.shininess = mat.shininess;
} else
- SkipToken(sz);
+ SkipToken(sz, lineEnd);
}
// search the list of all shaders we have for this object whether
@@ -649,7 +646,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
sz = &line[1];
out = currentMesh;
}
- SkipSpaces(sz, &sz);
+ SkipSpaces(sz, &sz, lineEnd);
unsigned int m = strtoul10(sz);
// ---- flip the face order
@@ -677,13 +674,13 @@ void NFFImporter::InternReadFile(const std::string &pFile,
}
if (out == currentMeshWithUVCoords) {
// FIX: in one test file this wraps over multiple lines
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
if (IsLineEnd(*sz)) {
GetNextLine(buffer, line);
sz = line;
}
AI_NFF_PARSE_FLOAT(v.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
if (IsLineEnd(*sz)) {
GetNextLine(buffer, line);
sz = line;
@@ -717,7 +714,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// if the next one is NOT a number we assume it is a texture file name
// this feature is used by some NFF files on the internet and it has
// been implemented as it can be really useful
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
if (!IsNumeric(*sz)) {
// TODO: Support full file names with spaces and quotation marks ...
const char *p = sz;
@@ -731,10 +728,8 @@ void NFFImporter::InternReadFile(const std::string &pFile,
} else {
AI_NFF_PARSE_FLOAT(s.ambient); // optional
}
- }
- // 'shader' - other way to specify a texture
- else if (TokenMatch(sz, "shader", 6)) {
- SkipSpaces(&sz);
+ } else if (TokenMatch(sz, "shader", 6)) { // 'shader' - other way to specify a texture
+ SkipSpaces(&sz, lineEnd);
const char *old = sz;
while (!IsSpaceOrNewLine(*sz))
++sz;
@@ -889,7 +884,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
}
// 'tess' - tessellation
else if (TokenMatch(sz, "tess", 4)) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
iTesselation = strtoul10(sz);
}
// 'from' - camera position
@@ -929,7 +924,7 @@ void NFFImporter::InternReadFile(const std::string &pFile,
// '' - comment
else if ('#' == line[0]) {
const char *space;
- SkipSpaces(&line[1], &space);
+ SkipSpaces(&line[1], &space, lineEnd);
if (!IsLineEnd(*space)) {
ASSIMP_LOG_INFO(space);
}
diff --git a/code/AssetLib/NFF/NFFLoader.h b/code/AssetLib/NFF/NFFLoader.h
index b402aec84..dfa6a882f 100644
--- a/code/AssetLib/NFF/NFFLoader.h
+++ b/code/AssetLib/NFF/NFFLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/OFF/OFFLoader.cpp b/code/AssetLib/OFF/OFFLoader.cpp
index ce8dfc2d4..566e3212e 100644
--- a/code/AssetLib/OFF/OFFLoader.cpp
+++ b/code/AssetLib/OFF/OFFLoader.cpp
@@ -3,7 +3,7 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
@@ -84,10 +84,10 @@ const aiImporterDesc *OFFImporter::GetInfo() const {
// skip blank space, lines and comments
static void NextToken(const char **car, const char *end) {
- SkipSpacesAndLineEnd(car);
+ SkipSpacesAndLineEnd(car, end);
while (*car < end && (**car == '#' || **car == '\n' || **car == '\r')) {
- SkipLine(car);
- SkipSpacesAndLineEnd(car);
+ SkipLine(car, end);
+ SkipSpacesAndLineEnd(car, end);
}
}
@@ -195,6 +195,7 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
char line[4096];
buffer = car;
const char *sz = car;
+ const char *lineEnd = &line[4096];
// now read all vertex lines
for (unsigned int i = 0; i < numVertices; ++i) {
@@ -210,13 +211,13 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// stop at dimensions: this allows loading 1D or 2D coordinate vertices
for (unsigned int dim = 0; dim < dimensions; ++dim) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz = fast_atoreal_move(sz, *vec[dim]);
}
// if has homogeneous coordinate, divide others by this one
if (hasHomogenous) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
ai_real w = 1.;
sz = fast_atoreal_move(sz, w);
for (unsigned int dim = 0; dim < dimensions; ++dim) {
@@ -227,11 +228,11 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// read optional normals
if (hasNormals) {
aiVector3D &n = mesh->mNormals[i];
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz = fast_atoreal_move(sz, (ai_real &)n.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz = fast_atoreal_move(sz, (ai_real &)n.y);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
fast_atoreal_move(sz, (ai_real &)n.z);
}
@@ -241,22 +242,22 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// in theory should be testing type !
if (hasColors) {
aiColor4D &c = mesh->mColors[0][i];
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz = fast_atoreal_move(sz, (ai_real &)c.r);
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz = fast_atoreal_move(sz, (ai_real &)c.g);
} else {
c.g = 0.;
}
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz = fast_atoreal_move(sz, (ai_real &)c.b);
} else {
c.b = 0.;
}
if (*sz != '#' && *sz != '\n' && *sz != '\r') {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz = fast_atoreal_move(sz, (ai_real &)c.a);
} else {
c.a = 1.;
@@ -264,9 +265,9 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
}
if (hasTexCoord) {
aiVector3D &t = mesh->mTextureCoords[0][i];
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
sz = fast_atoreal_move(sz, (ai_real &)t.x);
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
fast_atoreal_move(sz, (ai_real &)t.y);
}
}
@@ -280,7 +281,7 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
}
unsigned int idx;
sz = line;
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
idx = strtoul10(sz, &sz);
if (!idx || idx > 9) {
ASSIMP_LOG_ERROR("OFF: Faces with zero indices aren't allowed");
@@ -291,7 +292,7 @@ void OFFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
faces->mNumIndices = idx;
faces->mIndices = new unsigned int[faces->mNumIndices];
for (unsigned int m = 0; m < faces->mNumIndices; ++m) {
- SkipSpaces(&sz);
+ SkipSpaces(&sz, lineEnd);
idx = strtoul10(sz, &sz);
if (idx >= numVertices) {
ASSIMP_LOG_ERROR("OFF: Vertex index is out of range");
diff --git a/code/AssetLib/OFF/OFFLoader.h b/code/AssetLib/OFF/OFFLoader.h
index b8577e507..02829d360 100644
--- a/code/AssetLib/OFF/OFFLoader.h
+++ b/code/AssetLib/OFF/OFFLoader.h
@@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2022, assimp team
+Copyright (c) 2006-2024, assimp team
All rights reserved.
diff --git a/code/AssetLib/Obj/ObjExporter.cpp b/code/AssetLib/Obj/ObjExporter.cpp
index a5d8325fc..7c5c051f3 100644
--- a/code/AssetLib/Obj/ObjExporter.cpp
+++ b/code/AssetLib/Obj/ObjExporter.cpp
@@ -59,9 +59,9 @@ namespace Assimp {
// ------------------------------------------------------------------------------------------------
// Worker function for exporting a scene to Wavefront OBJ. Prototyped and registered in Exporter.cpp
-void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/) {
+void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* props) {
// invoke the exporter
- ObjExporter exporter(pFile, pScene);
+ ObjExporter exporter(pFile, pScene, false, props);
if (exporter.mOutput.fail() || exporter.mOutputMat.fail()) {
throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
@@ -86,9 +86,9 @@ void ExportSceneObj(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
// ------------------------------------------------------------------------------------------------
// Worker function for exporting a scene to Wavefront OBJ without the material file. Prototyped and registered in Exporter.cpp
-void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* ) {
+void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* props) {
// invoke the exporter
- ObjExporter exporter(pFile, pScene, true);
+ ObjExporter exporter(pFile, pScene, true, props);
if (exporter.mOutput.fail() || exporter.mOutputMat.fail()) {
throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
@@ -111,7 +111,7 @@ void ExportSceneObjNoMtl(const char* pFile,IOSystem* pIOSystem, const aiScene* p
static const std::string MaterialExt = ".mtl";
// ------------------------------------------------------------------------------------------------
-ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMtl)
+ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMtl, const ExportProperties* props)
: filename(_filename)
, pScene(pScene)
, vn()
@@ -130,7 +130,10 @@ ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMt
mOutputMat.imbue(l);
mOutputMat.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
- WriteGeometryFile(noMtl);
+ WriteGeometryFile(
+ noMtl,
+ props == nullptr ? true : props->GetPropertyBool("bJoinIdenticalVertices", true)
+ );
if ( !noMtl ) {
WriteMaterialFile();
}
@@ -255,14 +258,14 @@ void ObjExporter::WriteMaterialFile() {
}
}
-void ObjExporter::WriteGeometryFile(bool noMtl) {
+void ObjExporter::WriteGeometryFile(bool noMtl, bool merge_identical_vertices) {
WriteHeader(mOutput);
if (!noMtl)
mOutput << "mtllib " << GetMaterialLibName() << endl << endl;
// collect mesh geometry
aiMatrix4x4 mBase;
- AddNode(pScene->mRootNode, mBase);
+ AddNode(pScene->mRootNode, mBase, merge_identical_vertices);
// write vertex positions with colors, if any
mVpMap.getKeys( vp );
@@ -330,7 +333,7 @@ void ObjExporter::WriteGeometryFile(bool noMtl) {
}
// ------------------------------------------------------------------------------------------------
-void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat) {
+void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4x4& mat, bool merge_identical_vertices) {
mMeshes.emplace_back();
MeshInstance& mesh = mMeshes.back();
@@ -362,13 +365,14 @@ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4
for(unsigned int a = 0; a < f.mNumIndices; ++a) {
const unsigned int idx = f.mIndices[a];
+ const unsigned int fi = merge_identical_vertices ? 0 : idx;
aiVector3D vert = mat * m->mVertices[idx];
if ( nullptr != m->mColors[ 0 ] ) {
aiColor4D col4 = m->mColors[ 0 ][ idx ];
- face.indices[a].vp = mVpMap.getIndex({vert, aiColor3D(col4.r, col4.g, col4.b)});
+ face.indices[a].vp = mVpMap.getIndex({vert, aiColor3D(col4.r, col4.g, col4.b), fi});
} else {
- face.indices[a].vp = mVpMap.getIndex({vert, aiColor3D(0,0,0)});
+ face.indices[a].vp = mVpMap.getIndex({vert, aiColor3D(0,0,0), fi});
}
if (m->mNormals) {
@@ -388,21 +392,21 @@ void ObjExporter::AddMesh(const aiString& name, const aiMesh* m, const aiMatrix4
}
// ------------------------------------------------------------------------------------------------
-void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent) {
+void ObjExporter::AddNode(const aiNode* nd, const aiMatrix4x4& mParent, bool merge_identical_vertices) {
const aiMatrix4x4& mAbs = mParent * nd->mTransformation;
aiMesh *cm( nullptr );
for(unsigned int i = 0; i < nd->mNumMeshes; ++i) {
cm = pScene->mMeshes[nd->mMeshes[i]];
if (nullptr != cm) {
- AddMesh(cm->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs);
+ AddMesh(cm->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs, merge_identical_vertices);
} else {
- AddMesh(nd->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs);
+ AddMesh(nd->mName, pScene->mMeshes[nd->mMeshes[i]], mAbs, merge_identical_vertices);
}
}
for(unsigned int i = 0; i < nd->mNumChildren; ++i) {
- AddNode(nd->mChildren[i], mAbs);
+ AddNode(nd->mChildren[i], mAbs, merge_identical_vertices);
}
}
diff --git a/code/AssetLib/Obj/ObjExporter.h b/code/AssetLib/Obj/ObjExporter.h
index a64f38f74..4c92aa16f 100644
--- a/code/AssetLib/Obj/ObjExporter.h
+++ b/code/AssetLib/Obj/ObjExporter.h
@@ -51,6 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
#include