Permalink
Browse files

apply patch of Daniel Horn

fix bug in resolution of joints in controllers
  • Loading branch information...
1 parent 1cfd6a0 commit 0a93c79c728770f3abba242a1c874909c24be37b @opencollada-sebastian opencollada-sebastian committed Sep 24, 2009
@@ -220,7 +220,15 @@ namespace COLLADABU
void URI::copyFrom(const URI& copyFrom)
{
- set(copyFrom.originalStr());
+// set(copyFrom.originalStr());
+ mUriString = copyFrom.mUriString;
+ mOriginalURIString = copyFrom.mOriginalURIString;
+ mScheme = copyFrom.mScheme;
+ mAuthority = copyFrom.mScheme;
+ mPath = copyFrom.mPath;
+ mQuery = copyFrom.mQuery;
+ mFragment = copyFrom.mFragment;
+ mIsValid = copyFrom.mIsValid;
}
URI& URI::operator=(const URI& other) {
@@ -53,9 +53,9 @@ namespace COLLADAFW
/** Clones the values in @a valuesArray and appends the pointers.*/
void appendValues( const PointerArray<T>& valuesArray )
{
- size_t newCount = mCount + valuesArray.getCount();
+ size_t newCount = ArrayPrimitiveType<T*>::mCount + valuesArray.getCount();
ArrayPrimitiveType<T*>::reallocMemory(newCount);
- for ( size_t i = mCount, j = 0; i < newCount; ++i, ++j)
+ for ( size_t i = ArrayPrimitiveType<T*>::mCount, j = 0; i < newCount; ++i, ++j)
{
(*this)[i] = valuesArray[j]->clone();
}
@@ -169,8 +169,28 @@ namespace COLLADAFW
// Get the normal indices of the current primitive.
const UIntValuesArray& normalIndices = meshPrimitive->getNormalIndices ();
- // Add the normals to the sum of normals
- numNormals += normalIndices.getCount ();
+ switch ( meshPrimitive->getPrimitiveType () )
+ {
+ case COLLADAFW::MeshPrimitive::TRIANGLE_FANS:
+ case COLLADAFW::MeshPrimitive::TRIANGLE_STRIPS:
+ {
+ COLLADAFW::MeshPrimitiveWithFaceVertexCount<unsigned int>* trifans = (COLLADAFW::MeshPrimitiveWithFaceVertexCount<unsigned int>*) meshPrimitive;
+ COLLADAFW::MeshPrimitiveWithFaceVertexCount<unsigned int>::VertexCountArray& vertexCountArray = trifans->getGroupedVerticesVertexCountArray ();
+ size_t groupedVtxCount = vertexCountArray.getCount ();
+ for ( size_t groupedVtxIndex=0; groupedVtxIndex<groupedVtxCount; ++groupedVtxIndex )
+ {
+ // Iterate over the indices and write their normal values into the maya file.
+ size_t indexCount = vertexCountArray[groupedVtxIndex]; //normalIndices.getCount();
+ numNormals += (indexCount - 2) * 3;
+ }
+ }
+ break;
+ default:
+ {
+ // Add the normals to the sum of normals
+ numNormals += normalIndices.getCount ();
+ }
+ }
}
return numNormals;
@@ -61,14 +61,6 @@ namespace COLLADASaxFWL
/** List of UniqueIdSidAddressPairs.*/
typedef std::vector< AnimationSidAddressBinding > AnimationSidAddressBindingList;
- /** Maps unique ids of skin data to the sids of the joints of this skin controller.*/
- typedef std::map< COLLADAFW::UniqueId, StringList> SkinDataJointSidsMap;
-
- /** Maps unique ids of skin data to the source uri string.*/
- typedef std::map< COLLADAFW::UniqueId/*skin controller data*/, COLLADABU::URI/*source uri string*/> SkinDataSkinSourceMap;
-
- /** Set of SkinControllers.*/
- typedef std::set< COLLADAFW::SkinController, bool(*)(const COLLADAFW::SkinController& lhs, const COLLADAFW::SkinController& rhs)> SkinControllerSet;
protected:
@@ -129,17 +121,17 @@ namespace COLLADASaxFWL
int& mParsedObjectFlags;
/** Maps unique ids of skin data to the sids of the joints of this skin controller.*/
- SkinDataJointSidsMap mSkinDataJointSidsMap;
+ Loader::SkinDataJointSidsMap& mSkinDataJointSidsMap;
/** Maps the Unique generated from the id of the COLLADA controller element to the
InstanceControllerDataList containing all instance controllers that reference the same controller.*/
- InstanceControllerDataListMap mInstanceControllerDataListMap;
+ Loader::InstanceControllerDataListMap& mInstanceControllerDataListMap;
/** Maps unique ids of skin data to the source uri string.*/
- SkinDataSkinSourceMap mSkinDataSkinSourceMap;
+ Loader::SkinDataSkinSourceMap& mSkinDataSkinSourceMap;
/** Set of all SkinController already created and written.*/
- SkinControllerSet mSkinControllerSet;
+ Loader::SkinControllerSet& mSkinControllerSet;
/** Error handler to be used. */
SaxParserErrorHandler* mSaxParserErrorHandler;
@@ -271,26 +263,26 @@ namespace COLLADASaxFWL
/** Returns the mapping of the Unique generated from the id of the COLLADA controller element to the
InstanceControllerDataList containing all instance controllers that reference the same controller.*/
- const InstanceControllerDataListMap& getInstanceControllerDataListMap() const { return mInstanceControllerDataListMap;}
+ const Loader::InstanceControllerDataListMap& getInstanceControllerDataListMap() const { return mInstanceControllerDataListMap;}
/** Returns the InstanceControllerDataList of the controller with Unique @a controllerUniqueId.*/
- const InstanceControllerDataList& getInstanceControllerDataListByControllerUniqueId(const COLLADAFW::UniqueId& controllerUniqueId)const;
+ const Loader::InstanceControllerDataList& getInstanceControllerDataListByControllerUniqueId(const COLLADAFW::UniqueId& controllerUniqueId)const;
/** Returns the InstanceControllerDataList of the controller with Unique @a controllerUniqueId.*/
- InstanceControllerDataList& getInstanceControllerDataListByControllerUniqueId(const COLLADAFW::UniqueId& controllerUniqueId);
+ Loader::InstanceControllerDataList& getInstanceControllerDataListByControllerUniqueId(const COLLADAFW::UniqueId& controllerUniqueId);
/** Returns the intermediate data to build up the kinematics after the COLLADA file has been parsed.*/
const KinematicsIntermediateData& getKinematicsIntermediateData() const { return mKinematicsIntermediateData; }
/** Creates a controller which instantiation is described by @a InstanceControllerData and that uses
the controller with id @a controllerDataUniqueId.*/
- bool createAndWriteSkinController( const InstanceControllerData& instanceControllerData,
+ bool createAndWriteSkinController( const Loader::InstanceControllerData& instanceControllerData,
const COLLADAFW::UniqueId& controllerDataUniqueId,
const COLLADAFW::UniqueId& sourceUniqueId);
/** Creates a controller which instantiation is described by @a InstanceControllerData and that uses
the controller with id @a controllerDataUniqueId. The sids used to resolve joints are @a sids.*/
- bool createAndWriteSkinController( const InstanceControllerData& instanceControllerData,
+ bool createAndWriteSkinController( const Loader::InstanceControllerData& instanceControllerData,
const COLLADAFW::UniqueId& controllerDataUniqueId,
const COLLADAFW::UniqueId& sourceUniqueId,
const StringList& sids);
@@ -317,11 +309,6 @@ namespace COLLADASaxFWL
/** Disable default assignment operator. */
const DocumentProcessor& operator= ( const DocumentProcessor& pre );
- /** Compares to SkinControllers. The comparison is suitable for using SkinController as key in stl
- containers but has no deeper meaning. The unique id of the SkinControllers themselves is not
- taken into account. Is basically compares if two SkinControllers describe exactly the same skin controller
- i.e. have the same source, joints and SkinControllerData.*/
- static bool compare( const COLLADAFW::SkinController& lhs, const COLLADAFW::SkinController& rhs);
/** The version of the collada document.*/
void setCOLLADAVersion(COLLADAVersion cOLLADAVersion);
@@ -15,6 +15,7 @@
#include "COLLADASaxFWLTypes.h"
#include "COLLADASaxFWLSaxFWLError.h"
#include "COLLADASaxFWLXmlTypes.h"
+#include "COLLADASaxFWLLoader.h"
#include "COLLADAFWUniqueId.h"
#include "COLLADAFWExtraData.h"
@@ -50,7 +51,7 @@ namespace COLLADABU
namespace COLLADASaxFWL
{
- class Loader;
+// class Loader;
class FileLoader;
class GeometryMaterialIdInfo;
class SidTreeNode;
@@ -67,26 +68,7 @@ namespace COLLADASaxFWL
friend class RootParser14;
friend class RootParser15;
- /** Data that needs to be store, intermediately, to assign controllers. One struct for each
- instance controller.*/
- struct InstanceControllerData
- {
- /** List of URIs of the skeleton roots, ie the uris in the COLLADA skeleton element.*/
- URIList skeletonRoots;
-
- /** The instance controller that instantiates the controller.*/
- COLLADAFW::InstanceController* instanceController;
- };
-
- /** List of all instance controllers that reference the same controller, ie share the same skin
- data for skin controllers.*/
- typedef std::list<InstanceControllerData> InstanceControllerDataList;
-
- /** Maps each controller data unique id to the list of nodes instantiating it.*/
- typedef std::map<COLLADAFW::UniqueId,InstanceControllerDataList> InstanceControllerDataListMap;
- public:
- const static InstanceControllerDataList EMPTY_INSTANCE_CONTROLLER_DATALIST;
private:
@@ -175,8 +157,10 @@ namespace COLLADASaxFWL
been passed to this method before, the same COLLADAFW::UniqueId will be returned, if not, an
invalid unique id will be returned.
@param uriString The uriString of the element to get the COLLADAFW::UniqueId for
+ @param isAbsolute If true, the url is assumed to be absolute, otherwise it will be made absolute
+ using the current file urie.
@return The elements COLLADAFW::UniqueId or COLLADAFW::UniqueId::INVALID*/
- const COLLADAFW::UniqueId& getUniqueIdFromUrl( const COLLADABU::URI& url );
+ const COLLADAFW::UniqueId& getUniqueIdFromUrl( const COLLADABU::URI& url, bool isAbsolute = false );
/** Returns the COLLADAFW::UniqueId of an element with no uri. At each call a new
COLLADAFW::UniqueId will be created and returned. Use this member for collada elements that
@@ -258,13 +242,13 @@ namespace COLLADASaxFWL
/** Returns the mapping of the Unique generated from the id of the COLLADA controller element to the
InstanceControllerDataList containing all instance controllers that reference the same controller.*/
- const InstanceControllerDataListMap& getInstanceControllerDataListMap() const ;
+ const Loader::InstanceControllerDataListMap& getInstanceControllerDataListMap() const ;
/** Returns the InstanceControllerDataList of the controller with Unique @a controllerUniqueId.*/
- const InstanceControllerDataList& getInstanceControllerDataListByControllerUniqueId(const COLLADAFW::UniqueId& controllerUniqueId)const;
+ const Loader::InstanceControllerDataList& getInstanceControllerDataListByControllerUniqueId(const COLLADAFW::UniqueId& controllerUniqueId)const;
/** Returns the InstanceControllerDataList of the controller with Unique @a controllerUniqueId.*/
- InstanceControllerDataList& getInstanceControllerDataListByControllerUniqueId(const COLLADAFW::UniqueId& controllerUniqueId);
+ Loader::InstanceControllerDataList& getInstanceControllerDataListByControllerUniqueId(const COLLADAFW::UniqueId& controllerUniqueId);
/** After this functions, the next sax callback should be caught by this the file part loader.*/
@@ -15,6 +15,7 @@
#include "COLLADASaxFWLGeometryMaterialIdInfo.h"
#include "COLLADASaxFWLSidTreeNode.h"
#include "COLLADASaxFWLKinematicsIntermediateData.h"
+#include "COLLADASaxFWLTypes.h"
#include "COLLADAFWILoader.h"
#include "COLLADAFWLoaderUtils.h"
@@ -81,7 +82,7 @@ namespace COLLADASaxFWL
ALL_OBJECTS_MASK = (1<<16) - 1,
};
- private:
+ public:
typedef COLLADABU::HashMap<COLLADABU::URI, COLLADAFW::UniqueId, unsigned long, COLLADABU::calculateHash> URIUniqueIdMap;
typedef COLLADABU::HashMap<COLLADABU::URI, COLLADAFW::FileId, unsigned long, COLLADABU::calculateHash> URIFileIdMap;
@@ -113,9 +114,40 @@ namespace COLLADASaxFWL
/** List of morph controller.*/
typedef std::vector<COLLADAFW::MorphController*> MorphControllerList;
+ /** Maps unique ids of skin data to the sids of the joints of this skin controller.*/
+ typedef std::map< COLLADAFW::UniqueId, StringList> SkinDataJointSidsMap;
+
+ /** Maps unique ids of skin data to the source uri string.*/
+ typedef std::map< COLLADAFW::UniqueId/*skin controller data*/, COLLADABU::URI/*source uri string*/> SkinDataSkinSourceMap;
+
+ /** Set of SkinControllers.*/
+ typedef std::set< COLLADAFW::SkinController, bool(*)(const COLLADAFW::SkinController& lhs, const COLLADAFW::SkinController& rhs)> SkinControllerSet;
+
+ /** Data that needs to be store, intermediately, to assign controllers. One struct for each
+ instance controller.*/
+ struct InstanceControllerData
+ {
+ /** List of URIs of the skeleton roots, ie the uris in the COLLADA skeleton element.*/
+ URIList skeletonRoots;
+
+ /** The instance controller that instantiates the controller.*/
+ COLLADAFW::InstanceController* instanceController;
+ };
+
+ /** List of all instance controllers that reference the same controller, ie share the same skin
+ data for skin controllers.*/
+ typedef std::list<InstanceControllerData> InstanceControllerDataList;
+
+ /** Maps each controller data unique id to the list of nodes instantiating it.*/
+ typedef std::map<COLLADAFW::UniqueId,InstanceControllerDataList> InstanceControllerDataListMap;
+
+
/** List of formulas.*/
typedef std::vector<COLLADAFW::Formula*> FormulaList;
+ public:
+ const static InstanceControllerDataList EMPTY_INSTANCE_CONTROLLER_DATALIST;
+
private:
/** The version of the collada document.*/
COLLADAVersion mCOLLADAVersion;
@@ -190,6 +222,20 @@ namespace COLLADASaxFWL
completely been parsed. This is required to assign animations of the morph weights.*/
MorphControllerList mMorphControllerList;
+ /** Maps unique ids of skin data to the sids of the joints of this skin controller.*/
+ SkinDataJointSidsMap mSkinDataJointSidsMap;
+
+ /** Maps the Unique generated from the id of the COLLADA controller element to the
+ InstanceControllerDataList containing all instance controllers that reference the same controller.*/
+ InstanceControllerDataListMap mInstanceControllerDataListMap;
+
+ /** Maps unique ids of skin data to the source uri string.*/
+ SkinDataSkinSourceMap mSkinDataSkinSourceMap;
+
+ /** Set of all SkinController already created and written.*/
+ SkinControllerSet mSkinControllerSet;
+
+
/** Maps unique ids of animation list to the corresponding animation list. All animation list in this map
will be deleted by the FileLoader.*/
UniqueIdAnimationListMap mUniqueIdAnimationListMap;
@@ -319,6 +365,27 @@ namespace COLLADASaxFWL
completely been parsed. This is required to assign animations of the morph weights.*/
MorphControllerList& getMorphControllerList() { return mMorphControllerList; }
+ /** Maps unique ids of skin data to the sids of the joints of this skin controller.*/
+ SkinDataJointSidsMap& getSkinDataJointSidsMap() { return mSkinDataJointSidsMap; }
+
+ /** Maps the Unique generated from the id of the COLLADA controller element to the
+ InstanceControllerDataList containing all instance controllers that reference the same controller.*/
+ InstanceControllerDataListMap& getInstanceControllerDataListMap() { return mInstanceControllerDataListMap; }
+
+ /** Maps unique ids of skin data to the source uri string.*/
+ SkinDataSkinSourceMap& getSkinDataSkinSourceMap() {
+ return mSkinDataSkinSourceMap;
+ }
+
+ /** Set of all SkinController already created and written.*/
+ SkinControllerSet& getSkinControllerSet() { return mSkinControllerSet; }
+
+ /** Compares to SkinControllers. The comparison is suitable for using SkinController as key in stl
+ containers but has no deeper meaning. The unique id of the SkinControllers themselves is not
+ taken into account. Is basically compares if two SkinControllers describe exactly the same skin controller
+ i.e. have the same source, joints and SkinControllerData.*/
+ static bool compare( const COLLADAFW::SkinController& lhs, const COLLADAFW::SkinController& rhs);
+
/** Returns the writer the data will be written to.*/
COLLADAFW::IWriter* writer(){ return mWriter; }
@@ -71,7 +71,7 @@ namespace COLLADASaxFWL
GeometryMaterialIdInfo* mCurrentMaterialInfo;
/** The InstanceControllerData of the current instance controller.*/
- FileLoader::InstanceControllerData *mCurrentInstanceControllerData;
+ Loader::InstanceControllerData *mCurrentInstanceControllerData;
public:
Oops, something went wrong.

0 comments on commit 0a93c79

Please sign in to comment.