Merge branch 'master' into master
commit
d10bf9a0d3
|
@ -3481,11 +3481,12 @@ void FBXConverter::ConvertOrphanedEmbeddedTextures() {
|
|||
const char *obtype = key.begin();
|
||||
const size_t length = static_cast<size_t>(key.end() - key.begin());
|
||||
if (strncmp(obtype, "Texture", length) == 0) {
|
||||
const Texture *texture = static_cast<const Texture *>(object->Get());
|
||||
if (const Texture *texture = static_cast<const Texture *>(object->Get())) {
|
||||
if (texture->Media() && texture->Media()->ContentLength() > 0) {
|
||||
realTexture = texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
// do nothing
|
||||
}
|
||||
|
|
|
@ -750,12 +750,17 @@ void LWSImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
}
|
||||
// 'LightIntensity': set intensity of currently active light
|
||||
else if ((*it).tokens[0] == "LightIntensity" || (*it).tokens[0] == "LgtIntensity") {
|
||||
if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT)
|
||||
if (nodes.empty() || nodes.back().type != LWS::NodeDesc::LIGHT) {
|
||||
ASSIMP_LOG_ERROR("LWS: Unexpected keyword: \'LightIntensity\'");
|
||||
|
||||
else
|
||||
} else {
|
||||
const std::string env = "(envelope)";
|
||||
if (0 == strncmp(c, env.c_str(), env.size())) {
|
||||
ASSIMP_LOG_ERROR("LWS: envelopes for LightIntensity not supported, set to 1.0");
|
||||
nodes.back().lightIntensity = (ai_real)1.0;
|
||||
} else {
|
||||
fast_atoreal_move<float>(c, nodes.back().lightIntensity);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// 'LightType': set type of currently active light
|
||||
else if ((*it).tokens[0] == "LightType") {
|
||||
|
|
|
@ -289,7 +289,8 @@ Ref<T> LazyDict<T>::Retrieve(unsigned int i) {
|
|||
|
||||
// Unique ptr prevents memory leak in case of Read throws an exception
|
||||
auto inst = std::unique_ptr<T>(new T());
|
||||
inst->id = std::string(mDictId) + "_" + to_string(i);
|
||||
// Try to make this human readable so it can be used in error messages.
|
||||
inst->id = std::string(mDictId) + "[" + to_string(i) + "]";
|
||||
inst->oIndex = i;
|
||||
ReadMember(obj, "name", inst->name);
|
||||
inst->Read(obj, mAsset);
|
||||
|
@ -637,6 +638,7 @@ inline void Accessor::Read(Value &obj, Asset &r) {
|
|||
const char *typestr;
|
||||
type = ReadMember(obj, "type", typestr) ? AttribType::FromString(typestr) : AttribType::SCALAR;
|
||||
|
||||
if (bufferView) {
|
||||
// Check length
|
||||
unsigned long long byteLength = (unsigned long long)GetBytesPerComponent() * (unsigned long long)count;
|
||||
if ((byteOffset + byteLength) > bufferView->byteLength || (bufferView->byteOffset + byteOffset + byteLength) > bufferView->buffer->byteLength) {
|
||||
|
@ -647,6 +649,7 @@ inline void Accessor::Read(Value &obj, Asset &r) {
|
|||
ai_snprintf(val, val_size, "%llu, %llu", (unsigned long long)byteOffset, (unsigned long long)byteLength);
|
||||
throw DeadlyImportError("GLTF: Accessor with offset/length (", val, ") is out of range.");
|
||||
}
|
||||
}
|
||||
|
||||
if (Value *sparseValue = FindObject(obj, "sparse")) {
|
||||
sparse.reset(new Sparse);
|
||||
|
@ -737,13 +740,22 @@ inline void CopyData(size_t count,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string getContextForErrorMessages(const std::string& id, const std::string& name) {
|
||||
std::string context = id;
|
||||
if (!name.empty()) {
|
||||
context += " (\"" + name + "\")";
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
template <class T>
|
||||
void Accessor::ExtractData(T *&outData) {
|
||||
uint8_t *data = GetPointer();
|
||||
if (!data) {
|
||||
throw DeadlyImportError("GLTF2: data is nullptr.");
|
||||
throw DeadlyImportError("GLTF2: data is null when extracting data from ", getContextForErrorMessages(id, name));
|
||||
}
|
||||
|
||||
const size_t elemSize = GetElementSize();
|
||||
|
@ -823,9 +835,11 @@ template <class T>
|
|||
T Accessor::Indexer::GetValue(int i) {
|
||||
ai_assert(data);
|
||||
ai_assert(i * stride < accessor.bufferView->byteLength);
|
||||
// Ensure that the memcpy doesn't overwrite the local.
|
||||
const size_t sizeToCopy = std::min(elemSize, sizeof(T));
|
||||
T value = T();
|
||||
memcpy(&value, data + i * stride, elemSize);
|
||||
//value >>= 8 * (sizeof(T) - elemSize);
|
||||
// Assume platform endianness matches GLTF binary data (which is little-endian).
|
||||
memcpy(&value, data + i * stride, sizeToCopy);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -854,6 +868,14 @@ inline void Image::Read(Value &obj, Asset &r) {
|
|||
}
|
||||
} else if (Value *bufferViewVal = FindUInt(obj, "bufferView")) {
|
||||
this->bufferView = r.bufferViews.Retrieve(bufferViewVal->GetUint());
|
||||
if (Value *mtype = FindString(obj, "mimeType")) {
|
||||
this->mimeType = mtype->GetString();
|
||||
}
|
||||
if (!this->bufferView || this->mimeType.empty())
|
||||
{
|
||||
throw DeadlyImportError("GLTF2: ", getContextForErrorMessages(id, name), " does not have a URI, so it must have a valid bufferView and mimetype");
|
||||
}
|
||||
|
||||
Ref<Buffer> buffer = this->bufferView->buffer;
|
||||
|
||||
this->mDataLength = this->bufferView->byteLength;
|
||||
|
@ -861,10 +883,10 @@ inline void Image::Read(Value &obj, Asset &r) {
|
|||
|
||||
this->mData.reset(new uint8_t[this->mDataLength]);
|
||||
memcpy(this->mData.get(), buffer->GetPointer() + this->bufferView->byteOffset, this->mDataLength);
|
||||
|
||||
if (Value *mtype = FindString(obj, "mimeType")) {
|
||||
this->mimeType = mtype->GetString();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw DeadlyImportError("GLTF2: ", getContextForErrorMessages(id, name), " should have either a URI of a bufferView and mimetype" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1260,7 +1282,7 @@ inline void Light::Read(Value &obj, Asset & /*r*/) {
|
|||
Value *spot = FindObject(obj, "spot");
|
||||
if (!spot) throw DeadlyImportError("GLTF: Light missing its spot parameters");
|
||||
innerConeAngle = MemberOrDefault(*spot, "innerConeAngle", 0.0f);
|
||||
outerConeAngle = MemberOrDefault(*spot, "outerConeAngle", M_PI / 4.0f);
|
||||
outerConeAngle = MemberOrDefault(*spot, "outerConeAngle", static_cast<float>(M_PI / 4.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -232,6 +232,8 @@ SET_PROPERTY( TARGET assimp PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} )
|
|||
|
||||
IF( WIN32 )
|
||||
SET( platform_libs )
|
||||
ELSEIF(ANDROID)
|
||||
SET( platform_libs )
|
||||
ELSE()
|
||||
SET( platform_libs pthread )
|
||||
ENDIF()
|
||||
|
|
Loading…
Reference in New Issue