|
Blender
V2.59
|
00001 /* 00002 * $Id: KX_BlenderScalarInterpolator.cpp 35167 2011-02-25 13:30:41Z jesterking $ 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00020 * All rights reserved. 00021 * 00022 * The Original Code is: all of this file. 00023 * 00024 * Contributor(s): none yet. 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00034 #include "KX_BlenderScalarInterpolator.h" 00035 00036 #include <cstring> 00037 00038 extern "C" { 00039 #include "DNA_ipo_types.h" 00040 #include "DNA_action_types.h" 00041 #include "DNA_anim_types.h" 00042 #include "BKE_fcurve.h" 00043 } 00044 00045 float BL_ScalarInterpolator::GetValue(float currentTime) const { 00046 // XXX 2.4x IPO_GetFloatValue(m_blender_adt, m_channel, currentTime); 00047 return evaluate_fcurve(m_fcu, currentTime); 00048 } 00049 00050 BL_InterpolatorList::BL_InterpolatorList(struct AnimData *adt) { 00051 if(adt->action==NULL) 00052 return; 00053 00054 for(FCurve *fcu= (FCurve *)adt->action->curves.first; fcu; fcu= (FCurve *)fcu->next) { 00055 if(fcu->rna_path) { 00056 BL_ScalarInterpolator *new_ipo = new BL_ScalarInterpolator(fcu); 00057 //assert(new_ipo); 00058 push_back(new_ipo); 00059 } 00060 } 00061 } 00062 00063 BL_InterpolatorList::~BL_InterpolatorList() { 00064 BL_InterpolatorList::iterator i; 00065 for (i = begin(); !(i == end()); ++i) { 00066 delete *i; 00067 } 00068 } 00069 00070 KX_IScalarInterpolator *BL_InterpolatorList::GetScalarInterpolator(const char *rna_path, int array_index) { 00071 for(BL_InterpolatorList::iterator i = begin(); (i != end()) ; i++ ) 00072 { 00073 FCurve *fcu= (static_cast<BL_ScalarInterpolator *>(*i))->GetFCurve(); 00074 if(array_index==fcu->array_index && strcmp(rna_path, fcu->rna_path)==0) 00075 return *i; 00076 } 00077 return NULL; 00078 } 00079