~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kevin Roy
  • Date: 2011-02-08 22:20:54 UTC
  • mfrom: (1.4.2 upstream)
  • mto: (14.2.6 sid) (1.5.1)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: james.westby@ubuntu.com-20110208222054-kk0gwa4bu8h5lyq4
Tags: upstream-2.56.1-beta-svn34076
ImportĀ upstreamĀ versionĀ 2.56.1-beta-svn34076

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
// Adjust dynamics settins for this object
3
3
//
4
 
// $Id: KX_SCA_DynamicActuator.cpp 20210 2009-05-15 03:26:53Z campbellbarton $
 
4
// $Id: KX_SCA_DynamicActuator.cpp 32788 2010-10-31 04:11:39Z campbellbarton $
5
5
//
6
6
// ***** BEGIN GPL LICENSE BLOCK *****
7
7
//
17
17
//
18
18
// You should have received a copy of the GNU General Public License
19
19
// along with this program; if not, write to the Free Software Foundation,
20
 
// Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
20
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
21
//
22
22
// The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23
23
// All rights reserved.
36
36
// Please look here for revision history.
37
37
 
38
38
#include "KX_SCA_DynamicActuator.h"
39
 
#include "blendef.h"
40
39
 
41
 
#ifdef HAVE_CONFIG_H
42
 
#include <config.h>
43
 
#endif
 
40
#ifdef WITH_PYTHON
44
41
 
45
42
/* ------------------------------------------------------------------------- */
46
43
/* Python functions                                                          */
48
45
 
49
46
/* Integration hooks ------------------------------------------------------- */
50
47
 
51
 
        PyTypeObject 
52
 
 
53
 
KX_SCA_DynamicActuator::Type = {
54
 
#if (PY_VERSION_HEX >= 0x02060000)
 
48
PyTypeObject KX_SCA_DynamicActuator::Type = {
55
49
        PyVarObject_HEAD_INIT(NULL, 0)
56
 
#else
57
 
        /* python 2.5 and below */
58
 
        PyObject_HEAD_INIT( NULL )  /* required py macro */
59
 
        0,                          /* ob_size */
60
 
#endif
61
50
        "KX_SCA_DynamicActuator",
62
51
        sizeof(PyObjectPlus_Proxy),
63
52
        0,
67
56
        0,
68
57
        0,
69
58
        py_base_repr,
70
 
        0,0,0,0,0,0,
71
 
        py_base_getattro,
72
 
        py_base_setattro,
73
59
        0,0,0,0,0,0,0,0,0,
74
 
        Methods
75
 
};
76
 
 
77
 
PyParentObject KX_SCA_DynamicActuator::Parents[] = {
78
 
        &KX_SCA_DynamicActuator::Type,
 
60
        Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
 
61
        0,0,0,0,0,0,0,
 
62
        Methods,
 
63
        0,
 
64
        0,
79
65
        &SCA_IActuator::Type,
80
 
        &SCA_ILogicBrick::Type,
81
 
        &CValue::Type,
82
 
        NULL
 
66
        0,0,0,0,0,0,
 
67
        py_base_new
83
68
};
84
69
 
85
 
 
86
70
PyMethodDef KX_SCA_DynamicActuator::Methods[] = {
87
 
        // ---> deprecated
88
 
        KX_PYMETHODTABLE(KX_SCA_DynamicActuator, setOperation),
89
 
        KX_PYMETHODTABLE(KX_SCA_DynamicActuator, getOperation),
90
71
        {NULL,NULL} //Sentinel
91
72
};
92
73
 
93
74
PyAttributeDef KX_SCA_DynamicActuator::Attributes[] = {
94
75
        KX_PYATTRIBUTE_SHORT_RW("mode",0,4,false,KX_SCA_DynamicActuator,m_dyn_operation),
95
 
        KX_PYATTRIBUTE_FLOAT_RW("mass",0.0,MAXFLOAT,KX_SCA_DynamicActuator,m_setmass),
 
76
        KX_PYATTRIBUTE_FLOAT_RW("mass",0.0,FLT_MAX,KX_SCA_DynamicActuator,m_setmass),
96
77
        { NULL }        //Sentinel
97
78
};
98
79
 
99
 
 
100
 
PyObject* KX_SCA_DynamicActuator::py_getattro(PyObject *attr)
101
 
{
102
 
        py_getattro_up(SCA_IActuator);
103
 
}
104
 
 
105
 
PyObject* KX_SCA_DynamicActuator::py_getattro_dict() {
106
 
        py_getattro_dict_up(SCA_IActuator);
107
 
}
108
 
 
109
 
int KX_SCA_DynamicActuator::py_setattro(PyObject *attr, PyObject* value)
110
 
{
111
 
        py_setattro_up(SCA_IActuator);
112
 
}
113
 
 
114
 
 
115
 
/* 1. setOperation */
116
 
KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, setOperation,
117
 
"setOperation(operation?)\n"
118
 
"\t - operation? : type of dynamic operation\n"
119
 
"\t                0 = restore dynamics\n"
120
 
"\t                1 = disable dynamics\n"
121
 
"\t                2 = enable rigid body\n"
122
 
"\t                3 = disable rigid body\n"
123
 
"Change the dynamic status of the parent object.\n")
124
 
{
125
 
        ShowDeprecationWarning("setOperation()", "the mode property");
126
 
        int dyn_operation;
127
 
        
128
 
        if (!PyArg_ParseTuple(args, "i:setOperation", &dyn_operation))
129
 
        {
130
 
                return NULL;    
131
 
        }
132
 
        if (dyn_operation <0 || dyn_operation>3) {
133
 
                PyErr_SetString(PyExc_IndexError, "Dynamic Actuator's setOperation() range must be between 0 and 3");
134
 
                return NULL;
135
 
        }
136
 
        m_dyn_operation= dyn_operation;
137
 
        Py_RETURN_NONE;
138
 
}
139
 
 
140
 
KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, getOperation,
141
 
"getOperation() -> integer\n"
142
 
"Returns the operation type of this actuator.\n"
143
 
)
144
 
{
145
 
        ShowDeprecationWarning("getOperation()", "the mode property");
146
 
        return PyInt_FromLong((long)m_dyn_operation);
147
 
}
148
 
 
 
80
#endif // WITH_PYTHON
149
81
 
150
82
/* ------------------------------------------------------------------------- */
151
83
/* Native functions                                                          */
153
85
 
154
86
KX_SCA_DynamicActuator::KX_SCA_DynamicActuator(SCA_IObject *gameobj,
155
87
                                                                                                           short dyn_operation,
156
 
                                                                                                           float setmass,
157
 
                                                                                                           PyTypeObject* T) : 
 
88
                                                                                                           float setmass) :
158
89
 
159
 
        SCA_IActuator(gameobj, T),
 
90
        SCA_IActuator(gameobj, KX_ACT_DYNAMIC),
160
91
        m_dyn_operation(dyn_operation),
161
92
        m_setmass(setmass)
162
93
{