From c7b077dea8ff0329273866c9c027961db4572aff Mon Sep 17 00:00:00 2001 From: Shon Ferguson <shonferg@users.sourceforge.net> Date: Tue, 27 Jun 2006 04:58:52 +0000 Subject: [PATCH] Fixes for the MergeNifTree function for NiControllerSequence rooted KF files. --- niflib.cpp | 31 +++++++++++++++++++++++++++++-- obj/NiControllerSequence.cpp | 4 ++++ obj/NiControllerSequence.h | 2 ++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/niflib.cpp b/niflib.cpp index fcdd2448..b491043e 100644 --- a/niflib.cpp +++ b/niflib.cpp @@ -24,6 +24,7 @@ All rights reserved. Please see niflib.h for licence. */ #include "obj/NiKeyframeController.h" #include "obj/NiKeyframeData.h" #include "obj/NiStringExtraData.h" +#include "obj/NiExtraData.h" #include "gen/header.h" #include "gen/footer.h" @@ -754,6 +755,22 @@ void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiControllerSequence> map<string,NiNodeRef> name_map; MapNodeNames( name_map, target ); + //TODO: Allow this to merge a KF sequence into a file that already has + //sequences in it by appending all the keyframe data to the end of + //existing controllers + + //Get the NiTextKeyExtraData, clone it, and attach it to the target node + NiTextKeyExtraDataRef txt_key = right->GetTextKeyExtraData(); + if ( txt_key != NULL ) { + NiObjectRef tx_clone = txt_key->Clone( version, user_version ); + NiExtraDataRef ext_dat = DynamicCast<NiExtraData>(tx_clone); + if ( ext_dat != NULL ) { + target->AddExtraData( ext_dat ); + } + } + + //Atach it to + //Get the controller data vector<ControllerLink> data = right->GetControllerData(); @@ -776,7 +793,7 @@ void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiControllerSequence> if ( data[i].controller != NULL ) { //Clone the controller and attached data and //add it to the named node - NiObjectRef clone = CloneNifTree( StaticCast<NiObject>(data[i].controller) ); + NiObjectRef clone = CloneNifTree( StaticCast<NiObject>(data[i].controller), version, user_version ); NiTimeControllerRef ctlr = DynamicCast<NiTimeController>(clone); if ( ctlr != NULL ) { name_map[node_name]->AddController( ctlr ); @@ -794,7 +811,7 @@ void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiControllerSequence> //Clone the interpolator and attached data and //add it to controller of matching type that was //found - NiObjectRef clone = CloneNifTree( StaticCast<NiObject>(data[i].interpolator) ); + NiObjectRef clone = CloneNifTree( StaticCast<NiObject>(data[i].interpolator), version, user_version ); NiInterpolatorRef interp = DynamicCast<NiInterpolator>(clone); if ( interp != NULL ) { ctlr->SetInterpolator( interp ); @@ -808,6 +825,16 @@ void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiControllerSequence> } } +//Version for merging KF Trees rooted by a NiSequenceStreamHelper +void MergeNifTrees( const Ref<NiNode> & target, const Ref<NiSequenceStreamHelper> & right, unsigned int version, unsigned int user_version ) { + //Map the node names + map<string,NiNodeRef> name_map; + MapNodeNames( name_map, target ); + + //TODO: Implement this + +} + bool IsVersionSupported(unsigned int ver) { switch (ver) diff --git a/obj/NiControllerSequence.cpp b/obj/NiControllerSequence.cpp index 97810102..af01e0b7 100644 --- a/obj/NiControllerSequence.cpp +++ b/obj/NiControllerSequence.cpp @@ -142,3 +142,7 @@ vector<ControllerLink> NiControllerSequence::GetControllerData() const { return controlledBlocks; } +Ref<NiTextKeyExtraData> NiControllerSequence::GetTextKeyExtraData() const { + return textKeys; +} + diff --git a/obj/NiControllerSequence.h b/obj/NiControllerSequence.h index e9bd23a0..dfd1ce77 100644 --- a/obj/NiControllerSequence.h +++ b/obj/NiControllerSequence.h @@ -74,6 +74,8 @@ public: */ vector<ControllerLink> GetControllerData() const; + Ref<NiTextKeyExtraData> GetTextKeyExtraData() const; + protected: NiControllerManager * NiControllerSequence::Parent() const; NI_CONTROLLER_SEQUENCE_MEMBERS -- GitLab