rename and negate DISABLE_PYTHON --> WITH_PYTHON
[blender.git] / source / gameengine / Ketsji / KX_VisibilityActuator.cpp
1 /*
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  * Actuator to toggle visibility/invisibility of objects
29  */
30
31 #include "KX_VisibilityActuator.h"
32 #include "KX_GameObject.h"
33
34 KX_VisibilityActuator::KX_VisibilityActuator(
35         SCA_IObject* gameobj,
36         bool visible,
37         bool occlusion,
38         bool recursive
39         ) 
40         : SCA_IActuator(gameobj, KX_ACT_VISIBILITY),
41           m_visible(visible),
42           m_occlusion(occlusion),
43           m_recursive(recursive)
44 {
45         // intentionally empty
46 }
47
48 KX_VisibilityActuator::~KX_VisibilityActuator(
49         void
50         )
51 {
52         // intentionally empty
53 }
54
55 CValue*
56 KX_VisibilityActuator::GetReplica(
57         void
58         )
59 {
60         KX_VisibilityActuator* replica = new KX_VisibilityActuator(*this);
61         replica->ProcessReplica();
62         return replica;
63 }
64
65 bool
66 KX_VisibilityActuator::Update()
67 {
68         bool bNegativeEvent = IsNegativeEvent();
69         
70         RemoveAllEvents();
71         if (bNegativeEvent) return false;
72
73         KX_GameObject *obj = (KX_GameObject*) GetParent();
74         
75         obj->SetVisible(m_visible, m_recursive);
76         obj->SetOccluder(m_occlusion, m_recursive);
77         obj->UpdateBuckets(m_recursive);
78
79         return false;
80 }
81
82 #ifdef WITH_PYTHON
83
84 /* ------------------------------------------------------------------------- */
85 /* Python functions                                                          */
86 /* ------------------------------------------------------------------------- */
87
88
89
90 /* Integration hooks ------------------------------------------------------- */
91 PyTypeObject KX_VisibilityActuator::Type = {
92         PyVarObject_HEAD_INIT(NULL, 0)
93         "KX_VisibilityActuator",
94         sizeof(PyObjectPlus_Proxy),
95         0,
96         py_base_dealloc,
97         0,
98         0,
99         0,
100         0,
101         py_base_repr,
102         0,0,0,0,0,0,0,0,0,
103         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
104         0,0,0,0,0,0,0,
105         Methods,
106         0,
107         0,
108         &SCA_IActuator::Type,
109         0,0,0,0,0,0,
110         py_base_new
111 };
112
113 PyMethodDef KX_VisibilityActuator::Methods[] = {
114         {NULL,NULL} //Sentinel
115 };
116
117 PyAttributeDef KX_VisibilityActuator::Attributes[] = {
118         KX_PYATTRIBUTE_BOOL_RW("visibility", KX_VisibilityActuator, m_visible),
119         KX_PYATTRIBUTE_BOOL_RW("useOcclusion", KX_VisibilityActuator, m_occlusion),
120         KX_PYATTRIBUTE_BOOL_RW("useRecursion", KX_VisibilityActuator, m_recursive),
121         { NULL }        //Sentinel
122 };
123
124 #endif // WITH_PYTHON