blender/source/gameengine/Ketsji/KX_VehicleWrapper.h
Campbell Barton fd2b115678 Python BGE API
- Initialize python types with PyType_Ready, which adds methods to the type dictionary.
- use Pythons get/setattro (uses a python string for the attribute rather then char*). Using basic C strings seems nice but internally python converts them to python strings and discards them for most functions that accept char arrays.
- Method lookups use the PyTypes dictionary (should be faster then Py_FindMethod)
- Renamed __getattr -> py_base_getattro, _getattr -> py_getattro, __repr -> py_base_repr, py_delattro, py_getattro_self etc.

From here is possible to put all the parent classes methods into each python types dictionary to avoid nested lookups (api has 4 levels of lookups in some places), tested this but its not ready yet.

Simple tests for getting a method within a loop show this to be between 0.5 and 3.2x faster then using Py_FindMethod()
2009-04-03 14:51:06 +00:00

59 lines
1.5 KiB
C++

#ifndef KX_VEHICLE_WRAPPER
#define KX_VEHICLE_WRAPPER
#include "Value.h"
#include "PHY_DynamicTypes.h"
class PHY_IVehicle;
class PHY_IMotionState;
#include <vector>
///Python interface to physics vehicles (primarily 4-wheel cars and 2wheel bikes)
class KX_VehicleWrapper : public PyObjectPlus
{
Py_Header;
virtual PyObject* py_getattro(PyObject *attr);
virtual int py_setattro(PyObject *attr, PyObject *value);
std::vector<PHY_IMotionState*> m_motionStates;
public:
KX_VehicleWrapper(PHY_IVehicle* vehicle,class PHY_IPhysicsEnvironment* physenv,PyTypeObject *T = &Type);
virtual ~KX_VehicleWrapper ();
int getConstraintId();
KX_PYMETHOD(KX_VehicleWrapper,AddWheel);
KX_PYMETHOD(KX_VehicleWrapper,GetNumWheels);
KX_PYMETHOD(KX_VehicleWrapper,GetWheelOrientationQuaternion);
KX_PYMETHOD(KX_VehicleWrapper,GetWheelRotation);
KX_PYMETHOD(KX_VehicleWrapper,GetWheelPosition);
KX_PYMETHOD(KX_VehicleWrapper,GetConstraintId);
KX_PYMETHOD(KX_VehicleWrapper,GetConstraintType);
KX_PYMETHOD(KX_VehicleWrapper,SetSteeringValue);
KX_PYMETHOD(KX_VehicleWrapper,ApplyEngineForce);
KX_PYMETHOD(KX_VehicleWrapper,ApplyBraking);
KX_PYMETHOD(KX_VehicleWrapper,SetTyreFriction);
KX_PYMETHOD(KX_VehicleWrapper,SetSuspensionStiffness);
KX_PYMETHOD(KX_VehicleWrapper,SetSuspensionDamping);
KX_PYMETHOD(KX_VehicleWrapper,SetSuspensionCompression);
KX_PYMETHOD(KX_VehicleWrapper,SetRollInfluence);
private:
PHY_IVehicle* m_vehicle;
PHY_IPhysicsEnvironment* m_physenv;
};
#endif //KX_VEHICLE_WRAPPER