~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
2
// Replace the mesh for this actuator's parent
3
3
//
4
 
// $Id: KX_SCA_ReplaceMeshActuator.cpp 14444 2008-04-16 22:40:48Z hos $
 
4
// $Id: KX_SCA_ReplaceMeshActuator.cpp 16873 2008-10-02 00:22:28Z campbellbarton $
5
5
//
6
6
// ***** BEGIN GPL LICENSE BLOCK *****
7
7
//
37
37
 
38
38
#include "KX_SCA_ReplaceMeshActuator.h"
39
39
 
 
40
#include "PyObjectPlus.h" 
 
41
 
40
42
#ifdef HAVE_CONFIG_H
41
43
#include <config.h>
42
44
#endif
80
82
 
81
83
 
82
84
PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = {
83
 
        {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_VARARGS, SetMesh_doc},
 
85
        {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, (PY_METHODCHAR)SetMesh_doc},
84
86
        
85
87
        KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh),
86
88
        KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh),
97
99
 
98
100
 
99
101
/* 1. setMesh */
100
 
char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] = 
 
102
const char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] = 
101
103
        "setMesh(name)\n"
102
 
        "\t- name: string\n"
 
104
        "\t- name: string or None\n"
103
105
        "\tSet the mesh that will be substituted for the current one.\n";
104
106
 
105
 
PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* self,
106
 
                                                                          PyObject* args, 
107
 
                                                                          PyObject* kwds)
 
107
PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* self, PyObject* value)
108
108
{
109
 
        char* meshname;
110
 
        
111
 
        if (!PyArg_ParseTuple(args, "s", &meshname))
112
 
        {
113
 
                return NULL;    
114
 
        }
115
 
 
116
 
        void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname));
117
 
        
118
 
        if (mesh) {
 
109
        if (value == Py_None) {
 
110
                m_mesh = NULL;
 
111
        } else {
 
112
                char* meshname = PyString_AsString(value);
 
113
                if (!meshname) {
 
114
                        PyErr_SetString(PyExc_ValueError, "Expected the name of a mesh or None");
 
115
                        return NULL;
 
116
                }
 
117
                void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname));
 
118
                
 
119
                if (mesh==NULL) {
 
120
                        PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist");
 
121
                        return NULL;
 
122
                }
119
123
                m_mesh= (class RAS_MeshObject*)mesh;
120
 
                Py_Return;
121
124
        }
122
125
        
123
 
        return NULL;
 
126
        Py_RETURN_NONE;
124
127
}
125
128
 
126
129
KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh,
129
132
)
130
133
{
131
134
        if (!m_mesh)
132
 
                Py_Return;
 
135
                Py_RETURN_NONE;
133
136
 
134
137
        return PyString_FromString(const_cast<char *>(m_mesh->GetName().ReadPtr()));
135
138
}
139
142
"instantReplaceMesh() : immediately replace mesh without delay\n")
140
143
{
141
144
        InstantReplaceMesh();
142
 
        Py_Return;
 
145
        Py_RETURN_NONE;
143
146
}
144
147
 
145
148
/* ------------------------------------------------------------------------- */