bugfix 8183, Ray sensor with material/property filter always triggers when hitting...
[blender.git] / source / gameengine / GameLogic / SCA_2DFilterActuator.cpp
1 #include "SCA_IActuator.h"
2
3 #include "SCA_2DFilterActuator.h"
4
5 #ifdef HAVE_CONFIG_H
6 #include <config.h>
7 #endif
8 #include <iostream>
9
10
11 SCA_2DFilterActuator::~SCA_2DFilterActuator()
12 {
13 }
14
15 SCA_2DFilterActuator::SCA_2DFilterActuator(
16         SCA_IObject *gameobj, 
17         RAS_2DFilterManager::RAS_2DFILTER_MODE type,
18                 short flag,
19                 float float_arg,
20                 int int_arg,
21                 RAS_IRasterizer* rasterizer,
22                 RAS_IRenderTools* rendertools,
23         PyTypeObject* T)
24     : SCA_IActuator(gameobj, T),
25      m_type(type),
26          m_flag(flag),
27          m_int_arg(int_arg),
28          m_float_arg(float_arg),
29          m_rasterizer(rasterizer),
30          m_rendertools(rendertools)
31 {
32 }
33
34 void SCA_2DFilterActuator::SetShaderText(STR_String text)
35 {
36         m_shaderText = text;
37 }
38
39
40
41 CValue* SCA_2DFilterActuator::GetReplica()
42 {
43     SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this);
44     replica->ProcessReplica();
45     CValue::AddDataToReplica(replica);
46
47     return replica;
48 }
49
50
51 bool SCA_2DFilterActuator::Update()
52 {
53         bool result = false;
54
55         bool bNegativeEvent = IsNegativeEvent();
56         RemoveAllEvents();
57
58
59         if (bNegativeEvent)
60                 return false; // do nothing on negative events
61
62         if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR )
63         {
64                 if(!m_flag)
65                 {
66                         m_rasterizer->EnableMotionBlur(m_float_arg);
67                 }
68                 else
69                 {
70                         m_rasterizer->DisableMotionBlur();
71                 }
72         }
73         else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS)
74         {
75                 m_rendertools->Update2DFilter(m_type, m_int_arg, m_shaderText);
76         }
77     return true;
78 }
79
80
81 PyTypeObject SCA_2DFilterActuator::Type = {
82         PyObject_HEAD_INIT(&PyType_Type)
83         0,
84         "SCA_2DFilterActuator",
85         sizeof(SCA_2DFilterActuator),
86         0,
87         PyDestructor,
88         0,
89         __getattr,
90         __setattr,
91         0, 
92          __repr,
93         0,
94         0,
95         0,
96         0,
97         0
98 };
99
100
101 PyParentObject SCA_2DFilterActuator::Parents[] = {
102         &SCA_2DFilterActuator::Type,
103         &SCA_IActuator::Type,
104         &SCA_ILogicBrick::Type,
105         &CValue::Type,
106         NULL
107 };
108
109
110 PyMethodDef SCA_2DFilterActuator::Methods[] = {
111     /* add python functions to deal with m_msg... */
112     {NULL,NULL}
113 };
114
115
116 PyObject* SCA_2DFilterActuator::_getattr(const STR_String& attr) {
117     _getattr_up(SCA_IActuator);
118 }