~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Lukas Fittl
  • Date: 2006-09-20 01:57:27 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060920015727-gmoqlxwstx9wwqs3
Tags: 2.42a-1ubuntu1
* Merge from Debian unstable (Closes: Malone #55903). Remaining changes:
  - debian/genpot: Add python scripts from Lee June <blender@eyou.com> to
    generate a reasonable PO template from the sources. Since gettext is used
    in a highly nonstandard way, xgettext does not work for this job.
  - debian/rules: Call the scripts, generate po/blender.pot, and clean it up
    in the clean target.
  - Add a proper header to the generated PO template.
* debian/control: Build depend on libavformat-dev >= 3:0.cvs20060823-3.1,
  otherwise this package will FTBFS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: KX_PyConstraintBinding.cpp,v 1.11 2006/01/15 11:34:54 erwin Exp $
 
2
 * $Id: KX_PyConstraintBinding.cpp,v 1.14 2006/07/03 05:58:23 erwin Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
32
32
#include "KX_PyConstraintBinding.h"
33
33
#include "PHY_IPhysicsEnvironment.h"
34
34
#include "KX_ConstraintWrapper.h"
 
35
#include "KX_VehicleWrapper.h"
35
36
#include "KX_PhysicsObjectWrapper.h"
36
37
#include "PHY_IPhysicsController.h"
 
38
#include "PHY_IVehicle.h"
37
39
 
38
40
#ifdef HAVE_CONFIG_H
39
41
#include <config.h>
51
53
static char gPySetDebugMode__doc__[] = "setDebugMode(int mode)";
52
54
 
53
55
static char gPySetNumIterations__doc__[] = "setNumIterations(int numiter) This sets the number of iterations for an iterative constraint solver";
 
56
static char gPySetNumTimeSubSteps__doc__[] = "setNumTimeSubSteps(int numsubstep) This sets the number of substeps for each physics proceed. Tradeoff quality for performance.";
 
57
 
 
58
 
54
59
static char gPySetDeactivationTime__doc__[] = "setDeactivationTime(float time) This sets the time after which a resting rigidbody gets deactived";
55
60
static char gPySetDeactivationLinearTreshold__doc__[] = "setDeactivationLinearTreshold(float linearTreshold)";
56
61
static char gPySetDeactivationAngularTreshold__doc__[] = "setDeactivationAngularTreshold(float angularTreshold)";
66
71
 
67
72
 
68
73
static char gPyCreateConstraint__doc__[] = "createConstraint(ob1,ob2,float restLength,float restitution,float damping)";
69
 
static char gPyRemoveConstraint__doc__[] = "removeConstraint(constraint id)";
 
74
static char gPyGetVehicleConstraint__doc__[] = "getVehicleConstraint(int constraintId)";
 
75
static char gPyRemoveConstraint__doc__[] = "removeConstraint(int constraintId)";
 
76
static char gPyGetAppliedImpulse__doc__[] = "getAppliedImpulse(int constraintId)";
 
77
 
70
78
 
71
79
 
72
80
 
103
111
        Py_INCREF(Py_None); return Py_None;
104
112
}
105
113
 
 
114
 
 
115
 
 
116
static PyObject* gPySetNumTimeSubSteps(PyObject* self,
 
117
                                                                                 PyObject* args, 
 
118
                                                                                 PyObject* kwds)
 
119
{
 
120
        int substep;
 
121
        if (PyArg_ParseTuple(args,"i",&substep))
 
122
        {
 
123
                if (PHY_GetActiveEnvironment())
 
124
                {
 
125
                        PHY_GetActiveEnvironment()->setNumTimeSubSteps(substep);
 
126
                }
 
127
        }
 
128
        Py_INCREF(Py_None); return Py_None;
 
129
}
 
130
 
 
131
 
106
132
static PyObject* gPySetNumIterations(PyObject* self,
107
133
                                                                                 PyObject* args, 
108
134
                                                                                 PyObject* kwds)
291
317
 
292
318
 
293
319
 
 
320
static PyObject* gPyGetVehicleConstraint(PyObject* self,
 
321
                                                                                 PyObject* args, 
 
322
                                                                                 PyObject* kwds)
 
323
{
 
324
#if defined(_WIN64)
 
325
        __int64 constraintid;
 
326
        if (PyArg_ParseTuple(args,"L",&constraintid))
 
327
#else
 
328
        long constraintid;
 
329
        if (PyArg_ParseTuple(args,"l",&constraintid))
 
330
#endif
 
331
        {
 
332
                if (PHY_GetActiveEnvironment())
 
333
                {
 
334
                        
 
335
                        PHY_IVehicle* vehicle = PHY_GetActiveEnvironment()->getVehicleConstraint(constraintid);
 
336
                        if (vehicle)
 
337
                        {
 
338
                                KX_VehicleWrapper* pyWrapper = new KX_VehicleWrapper(vehicle,PHY_GetActiveEnvironment());
 
339
                                return pyWrapper;
 
340
                        }
 
341
 
 
342
                }
 
343
        }
 
344
 
 
345
        Py_INCREF(Py_None); return Py_None;
 
346
}
 
347
 
 
348
 
294
349
 
295
350
 
296
351
 
348
403
}
349
404
 
350
405
 
 
406
 
 
407
 
 
408
static PyObject* gPyGetAppliedImpulse(PyObject* self,
 
409
                                                                                 PyObject* args, 
 
410
                                                                                 PyObject* kwds)
 
411
{
 
412
        float   appliedImpulse = 0.f;
 
413
 
 
414
#if defined(_WIN64)
 
415
        __int64 constraintid;
 
416
        if (PyArg_ParseTuple(args,"L",&constraintid))
 
417
#else
 
418
        long constraintid;
 
419
        if (PyArg_ParseTuple(args,"l",&constraintid))
 
420
#endif
 
421
        {
 
422
                if (PHY_GetActiveEnvironment())
 
423
                {
 
424
                        appliedImpulse = PHY_GetActiveEnvironment()->getAppliedImpulse(constraintid);
 
425
                }
 
426
        }
 
427
 
 
428
        return PyFloat_FromDouble(appliedImpulse);
 
429
}
 
430
 
 
431
 
351
432
static PyObject* gPyRemoveConstraint(PyObject* self,
352
433
                                                                                 PyObject* args, 
353
434
                                                                                 PyObject* kwds)
379
460
  {"setNumIterations",(PyCFunction) gPySetNumIterations,
380
461
   METH_VARARGS, gPySetNumIterations__doc__},
381
462
 
 
463
   {"setNumTimeSubSteps",(PyCFunction) gPySetNumTimeSubSteps,
 
464
   METH_VARARGS, gPySetNumTimeSubSteps__doc__},
 
465
 
382
466
  {"setDeactivationTime",(PyCFunction) gPySetDeactivationTime,
383
467
   METH_VARARGS, gPySetDeactivationTime__doc__},
384
468
 
407
491
   METH_VARARGS, gPySetSolverType__doc__},
408
492
 
409
493
 
410
 
 
411
494
  {"createConstraint",(PyCFunction) gPyCreateConstraint,
412
495
   METH_VARARGS, gPyCreateConstraint__doc__},
 
496
     {"getVehicleConstraint",(PyCFunction) gPyGetVehicleConstraint,
 
497
   METH_VARARGS, gPyGetVehicleConstraint__doc__},
 
498
 
413
499
  {"removeConstraint",(PyCFunction) gPyRemoveConstraint,
414
500
   METH_VARARGS, gPyRemoveConstraint__doc__},
 
501
        {"getAppliedImpulse",(PyCFunction) gPyGetAppliedImpulse,
 
502
   METH_VARARGS, gPyGetAppliedImpulse__doc__},
 
503
 
415
504
 
416
505
   //sentinel
417
506
  { NULL, (PyCFunction) NULL, 0, NULL }