From 7bddce476ee770e5c46d46629a24f7b7e1b5f98d Mon Sep 17 00:00:00 2001 From: Tazpn <tazpn@users.sourceforge.net> Date: Mon, 24 Sep 2007 04:16:53 +0000 Subject: [PATCH] Add helper method to ControllerSequence which allows for adding item by name and not with target attached. --- include/obj/NiControllerSequence.h | 7 +++++++ src/obj/NiControllerSequence.cpp | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/obj/NiControllerSequence.h b/include/obj/NiControllerSequence.h index 95763e18..c1aac068 100644 --- a/include/obj/NiControllerSequence.h +++ b/include/obj/NiControllerSequence.h @@ -98,6 +98,13 @@ public: */ NIFLIB_API void AddController( NiTimeController * obj ); + /*! + * Attaches a controler to this KF file for a KF file of version 10.2.0.0 or below. Versions above this use interpolators. + * \param[in] obj A reference to the new NiTimeController to attach. + * \sa NiControllerSequence::ClearChildren, NiControllersequence::AddInterpolator + */ + NIFLIB_API void AddController( string const & targetName, NiTimeController * obj ); + /*! * Attatches an interpolator to this KF file for a KF file of version greater than 10.2.0.0. Versions below this use controllers. * \param[in] obj A reference to the new controller which has an interpolator to attach. diff --git a/src/obj/NiControllerSequence.cpp b/src/obj/NiControllerSequence.cpp index 6feaabee..72ba41ed 100644 --- a/src/obj/NiControllerSequence.cpp +++ b/src/obj/NiControllerSequence.cpp @@ -222,7 +222,6 @@ void NiControllerSequence::AddController( NiTimeController * obj ) { if ( target == NULL ) { throw runtime_error("Controller must have a target to be added to a NiControllerSequence."); } - //Make a new ControllerLink and fill out necessary data ControllerLink cl; cl.controller = obj; @@ -240,6 +239,24 @@ void NiControllerSequence::AddController( NiTimeController * obj ) { controlledBlocks.push_back( cl ); } +void NiControllerSequence::AddController( string const & targetName, NiTimeController * obj ) { + //Make sure the link isn't null + if ( obj == NULL ) { + throw runtime_error("Attempted to add a null controller to NiControllerSequence."); + } + + //Make a new ControllerLink and fill out necessary data + ControllerLink cl; + cl.controller = obj; + cl.targetName = targetName; + cl.nodeName = targetName; + + cl.controllerType = obj->GetType().GetTypeName(); + + //Add finished ControllerLink to list + controlledBlocks.push_back( cl ); +} + void NiControllerSequence::AddInterpolator( NiSingleInterpController * obj, byte priority ) { //Make sure the link isn't null if ( obj == NULL ) { -- GitLab