doxygen: prevent GPL license block from being parsed as doxygen comment.
[blender.git] / source / gameengine / Ketsji / KX_LightIpoSGController.cpp
1 /*
2  * $Id$
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Contributor(s): none yet.
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include "KX_LightIpoSGController.h"
30 #include "KX_ScalarInterpolator.h"
31 #include "KX_Light.h"
32 #include "RAS_LightObject.h"
33
34 #if defined(_WIN64)
35 typedef unsigned __int64 uint_ptr;
36 #else
37 typedef unsigned long uint_ptr;
38 #endif
39
40 bool KX_LightIpoSGController::Update(double currentTime)
41 {
42         if (m_modified)
43         {
44                 T_InterpolatorList::iterator i;
45                 for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
46                         (*i)->Execute(m_ipotime);//currentTime);
47                 }
48                 
49                 RAS_LightObject *lightobj;
50
51                 SG_Spatial* ob = (SG_Spatial*)m_pObject;
52                 KX_LightObject* kxlight = (KX_LightObject*) ob->GetSGClientObject();
53                 lightobj = kxlight->GetLightData();
54                 //lightobj = (KX_Light*) 
55
56                 if (m_modify_energy) {
57                         lightobj->m_energy = m_energy;
58                 }
59
60                 if (m_modify_color) {
61                         lightobj->m_red   = m_col_rgb[0];
62                         lightobj->m_green = m_col_rgb[1];
63                         lightobj->m_blue  = m_col_rgb[2];
64                 }
65
66                 if (m_modify_dist) {
67                         lightobj->m_distance = m_dist;
68                 }
69
70                 m_modified=false;
71         }
72         return false;
73 }
74
75
76 void KX_LightIpoSGController::AddInterpolator(KX_IInterpolator* interp)
77 {
78         this->m_interpolators.push_back(interp);
79 }
80
81 SG_Controller*  KX_LightIpoSGController::GetReplica(class SG_Node* destnode)
82 {
83         KX_LightIpoSGController* iporeplica = new KX_LightIpoSGController(*this);
84         // clear object that ipo acts on
85         iporeplica->ClearObject();
86
87         // dirty hack, ask Gino for a better solution in the ipo implementation
88         // hacken en zagen, in what we call datahiding, not written for replication :(
89
90         T_InterpolatorList oldlist = m_interpolators;
91         iporeplica->m_interpolators.clear();
92
93         T_InterpolatorList::iterator i;
94         for (i = oldlist.begin(); !(i == oldlist.end()); ++i) {
95                 KX_ScalarInterpolator* copyipo = new KX_ScalarInterpolator(*((KX_ScalarInterpolator*)*i));
96                 iporeplica->AddInterpolator(copyipo);
97
98                 MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
99                 uint_ptr orgbase = (uint_ptr)this;
100                 uint_ptr orgloc = (uint_ptr)scaal;
101                 uint_ptr offset = orgloc-orgbase;
102                 uint_ptr newaddrbase = (uint_ptr)iporeplica + offset;
103                 MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
104                 copyipo->SetNewTarget((MT_Scalar*)blaptr);
105         }
106         
107         return iporeplica;
108 }
109
110 KX_LightIpoSGController::~KX_LightIpoSGController()
111 {
112
113         T_InterpolatorList::iterator i;
114         for (i = m_interpolators.begin(); !(i == m_interpolators.end()); ++i) {
115                 delete (*i);
116         }
117         
118 }