mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-10 16:00:46 +00:00
Updated Assimp
Added initial behavior for ImageAssets to hold a list of GFX resources of different texture profiles to avoid mem leaks with incorrect-typed usages Added function to ImageAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Added function to ShapeAsset to get best-fit asset, allowing for fallbacks if the requested assetID is not found Disabled fields for dynamic and static shadowmap refresh rates Moved noShape model to core/rendering/shapes to place it in a more logical module position Added an include to avoid undefined type compile error and removed unneeded semicolon from zone code Added call to reload probe textures when a reloadTextures call is made Adjusted default directional light shadowmap settings to not be as extreme Added utility function to probe manager to allow any class to request a 'best fit' list of probes that would affect a given location, allowing other classes such as fog or particles to utilize IBL. Also updated probeManager's forward rendering to utilize same function to reduce code duplication. Shifted shape loader code to utilize assimp for loader consistency and testing Changed render bin used for SSAO postfx so it runs at the right time Made Core_Rendering module scan for assets Updated loose file references to a number of assets to follow proper formatting Refactored asset import code to follow a more consistent object heirarchy structure on importing assets, allowing more reliable cross-referencing between inbound items Updated asset import logic for materials/images so that they properly utilize ImageType. Images correctly save out the assigned image type, materials reference the images' type to know what map slot they should be used in. Importer logic also updated to better find-and-add associated images based on type. Cleaned up a bunch of old, outdated code in the asset importer Added initial handling for in-place importing of files without needing to process them through the UI. Added ability to edit module script from RMB context menu if torsion path is set Updated list field code for variable inspector to utilize correct ownerObject field
This commit is contained in:
parent
2d015bc426
commit
6ade6f08ce
545 changed files with 15077 additions and 8437 deletions
|
|
@ -3,7 +3,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2019, assimp team
|
||||
Copyright (c) 2006-2020, assimp team
|
||||
|
||||
|
||||
|
||||
|
|
@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <sstream>
|
||||
#include <stdarg.h>
|
||||
#include "ColladaParser.h"
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/fast_atof.h>
|
||||
#include <assimp/ParsingUtils.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
|
@ -249,6 +250,9 @@ void ColladaParser::UriDecodePath(aiString& ss)
|
|||
bool ColladaParser::ReadBoolFromTextContent()
|
||||
{
|
||||
const char* cur = GetTextContent();
|
||||
if ( nullptr == cur) {
|
||||
return false;
|
||||
}
|
||||
return (!ASSIMP_strincmp(cur, "true", 4) || '0' != *cur);
|
||||
}
|
||||
|
||||
|
|
@ -257,6 +261,9 @@ bool ColladaParser::ReadBoolFromTextContent()
|
|||
ai_real ColladaParser::ReadFloatFromTextContent()
|
||||
{
|
||||
const char* cur = GetTextContent();
|
||||
if ( nullptr == cur ) {
|
||||
return 0.0;
|
||||
}
|
||||
return fast_atof(cur);
|
||||
}
|
||||
|
||||
|
|
@ -276,6 +283,11 @@ void ColladaParser::ReadContents()
|
|||
if (attrib != -1) {
|
||||
const char* version = mReader->getAttributeValue(attrib);
|
||||
|
||||
// Store declared format version string
|
||||
aiString v;
|
||||
v.Set(version);
|
||||
mAssetMetaData.emplace(AI_METADATA_SOURCE_FORMAT_VERSION, v );
|
||||
|
||||
if (!::strncmp(version, "1.5", 3)) {
|
||||
mFormat = FV_1_5_n;
|
||||
ASSIMP_LOG_DEBUG("Collada schema version is 1.5.n");
|
||||
|
|
@ -434,23 +446,39 @@ void ColladaParser::ReadContributorInfo()
|
|||
}
|
||||
}
|
||||
|
||||
static bool FindCommonKey(const std::string &collada_key, const MetaKeyPairVector &key_renaming, size_t &found_index) {
|
||||
for (size_t i = 0; i < key_renaming.size(); ++i) {
|
||||
if (key_renaming[i].first == collada_key) {
|
||||
found_index = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
found_index = std::numeric_limits<size_t>::max();
|
||||
return false;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads a single string metadata item
|
||||
void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
||||
{
|
||||
// Metadata such as created, keywords, subject etc
|
||||
const char* key_char = mReader->getNodeName();
|
||||
if (key_char != nullptr)
|
||||
{
|
||||
void ColladaParser::ReadMetaDataItem(StringMetaData &metadata) {
|
||||
const Collada::MetaKeyPairVector &key_renaming = GetColladaAssimpMetaKeysCamelCase();
|
||||
// Metadata such as created, keywords, subject etc
|
||||
const char *key_char = mReader->getNodeName();
|
||||
if (key_char != nullptr) {
|
||||
const std::string key_str(key_char);
|
||||
const char* value_char = TestTextContent();
|
||||
if (value_char != nullptr)
|
||||
{
|
||||
std::string camel_key_str = key_str;
|
||||
ToCamelCase(camel_key_str);
|
||||
const char *value_char = TestTextContent();
|
||||
if (value_char != nullptr) {
|
||||
aiString aistr;
|
||||
aistr.Set(value_char);
|
||||
metadata.emplace(camel_key_str, aistr);
|
||||
aistr.Set(value_char);
|
||||
|
||||
std::string camel_key_str(key_str);
|
||||
ToCamelCase(camel_key_str);
|
||||
|
||||
size_t found_index;
|
||||
if (FindCommonKey(camel_key_str, key_renaming, found_index)) {
|
||||
metadata.emplace(key_renaming[found_index].second, aistr);
|
||||
} else {
|
||||
metadata.emplace(camel_key_str, aistr);
|
||||
}
|
||||
}
|
||||
TestClosing(key_str.c_str());
|
||||
}
|
||||
|
|
@ -458,27 +486,6 @@ void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
|||
SkipElement();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Convert underscore_seperated to CamelCase: "authoring_tool" becomes "AuthoringTool"
|
||||
void ColladaParser::ToCamelCase(std::string &text)
|
||||
{
|
||||
if (text.empty())
|
||||
return;
|
||||
// Capitalise first character
|
||||
text[0] = ToUpper(text[0]);
|
||||
for (auto it = text.begin(); it != text.end(); /*iterated below*/)
|
||||
{
|
||||
if ((*it) == '_')
|
||||
{
|
||||
it = text.erase(it);
|
||||
if (it != text.end())
|
||||
(*it) = ToUpper(*it);
|
||||
}
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Reads the animation clips
|
||||
void ColladaParser::ReadAnimationClipLibrary()
|
||||
|
|
@ -3234,13 +3241,12 @@ void ColladaParser::ReadScene()
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Aborts the file reading with an exception
|
||||
AI_WONT_RETURN void ColladaParser::ThrowException(const std::string& pError) const
|
||||
{
|
||||
AI_WONT_RETURN void ColladaParser::ThrowException(const std::string& pError) const {
|
||||
throw DeadlyImportError(format() << "Collada: " << mFileName << " - " << pError);
|
||||
}
|
||||
void ColladaParser::ReportWarning(const char* msg, ...)
|
||||
{
|
||||
ai_assert(NULL != msg);
|
||||
|
||||
void ColladaParser::ReportWarning(const char* msg, ...) {
|
||||
ai_assert(nullptr != msg);
|
||||
|
||||
va_list args;
|
||||
va_start(args, msg);
|
||||
|
|
@ -3255,11 +3261,11 @@ void ColladaParser::ReportWarning(const char* msg, ...)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Skips all data until the end node of the current element
|
||||
void ColladaParser::SkipElement()
|
||||
{
|
||||
void ColladaParser::SkipElement() {
|
||||
// nothing to skip if it's an <element />
|
||||
if (mReader->isEmptyElement())
|
||||
if (mReader->isEmptyElement()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// reroute
|
||||
SkipElement(mReader->getNodeName());
|
||||
|
|
@ -3267,63 +3273,75 @@ void ColladaParser::SkipElement()
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Skips all data until the end node of the given element
|
||||
void ColladaParser::SkipElement(const char* pElement)
|
||||
{
|
||||
void ColladaParser::SkipElement(const char* pElement) {
|
||||
// copy the current node's name because it'a pointer to the reader's internal buffer,
|
||||
// which is going to change with the upcoming parsing
|
||||
std::string element = pElement;
|
||||
while (mReader->read())
|
||||
{
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END)
|
||||
if (mReader->getNodeName() == element)
|
||||
while (mReader->read()) {
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {
|
||||
if (mReader->getNodeName() == element) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for an opening element of the given name, throws an exception if not found
|
||||
void ColladaParser::TestOpening(const char* pName)
|
||||
{
|
||||
void ColladaParser::TestOpening(const char* pName) {
|
||||
// read element start
|
||||
if (!mReader->read())
|
||||
if (!mReader->read()) {
|
||||
ThrowException(format() << "Unexpected end of file while beginning of <" << pName << "> element.");
|
||||
}
|
||||
// whitespace in front is ok, just read again if found
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT)
|
||||
if (!mReader->read())
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT) {
|
||||
if (!mReader->read()) {
|
||||
ThrowException(format() << "Unexpected end of file while reading beginning of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT || strcmp(mReader->getNodeName(), pName) != 0)
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT || strcmp(mReader->getNodeName(), pName) != 0) {
|
||||
ThrowException(format() << "Expected start of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Tests for the closing tag of the given element, throws an exception if not found
|
||||
void ColladaParser::TestClosing(const char* pName)
|
||||
{
|
||||
// check if we're already on the closing tag and return right away
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END && strcmp(mReader->getNodeName(), pName) == 0)
|
||||
void ColladaParser::TestClosing(const char* pName) {
|
||||
// check if we have an empty (self-closing) element
|
||||
if (mReader->isEmptyElement()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if we're already on the closing tag and return right away
|
||||
if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END && strcmp(mReader->getNodeName(), pName) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if not, read some more
|
||||
if (!mReader->read())
|
||||
if (!mReader->read()) {
|
||||
ThrowException(format() << "Unexpected end of file while reading end of <" << pName << "> element.");
|
||||
}
|
||||
// whitespace in front is ok, just read again if found
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT)
|
||||
if (!mReader->read())
|
||||
if (mReader->getNodeType() == irr::io::EXN_TEXT) {
|
||||
if (!mReader->read()) {
|
||||
ThrowException(format() << "Unexpected end of file while reading end of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// but this has the be the closing tag, or we're lost
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT_END || strcmp(mReader->getNodeName(), pName) != 0)
|
||||
if (mReader->getNodeType() != irr::io::EXN_ELEMENT_END || strcmp(mReader->getNodeName(), pName) != 0) {
|
||||
ThrowException(format() << "Expected end of <" << pName << "> element.");
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns the index of the named attribute or -1 if not found. Does not throw, therefore useful for optional attributes
|
||||
int ColladaParser::GetAttribute(const char* pAttr) const
|
||||
{
|
||||
int ColladaParser::GetAttribute(const char* pAttr) const {
|
||||
int index = TestAttribute(pAttr);
|
||||
if (index != -1)
|
||||
if (index != -1) {
|
||||
return index;
|
||||
}
|
||||
|
||||
// attribute not found -> throw an exception
|
||||
ThrowException(format() << "Expected attribute \"" << pAttr << "\" for element <" << mReader->getNodeName() << ">.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue