svn merge -r 37306:39975 https://svn.blender.org/svnroot/bf-blender/trunk/blender
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
extern "C" {
|
||||
#include "bpy_internal_import.h" /* from the blender python api, but we want to import text too! */
|
||||
#include "py_capi_utils.h"
|
||||
#include "mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use.
|
||||
#include "mathutils.h" // 'mathutils' module copied here so the blenderlayer can use.
|
||||
#include "bgl.h"
|
||||
#include "blf_py_api.h"
|
||||
|
||||
@@ -115,6 +115,7 @@ extern "C" {
|
||||
#include "NG_NetworkScene.h" //Needed for sendMessage()
|
||||
|
||||
#include "BL_Shader.h"
|
||||
#include "BL_Action.h"
|
||||
|
||||
#include "KX_PyMath.h"
|
||||
|
||||
@@ -336,7 +337,7 @@ static PyObject* gPyLoadGlobalDict(PyObject*)
|
||||
{
|
||||
char marshal_path[512];
|
||||
char *marshal_buffer = NULL;
|
||||
unsigned int marshal_length;
|
||||
size_t marshal_length;
|
||||
FILE *fp = NULL;
|
||||
int result;
|
||||
|
||||
@@ -347,7 +348,7 @@ static PyObject* gPyLoadGlobalDict(PyObject*)
|
||||
if (fp) {
|
||||
// obtain file size:
|
||||
fseek (fp, 0, SEEK_END);
|
||||
marshal_length = ftell(fp);
|
||||
marshal_length = (size_t)ftell(fp);
|
||||
rewind(fp);
|
||||
|
||||
marshal_buffer = (char*)malloc (sizeof(char)*marshal_length);
|
||||
@@ -397,10 +398,10 @@ static PyObject* gPyGetSpectrum(PyObject*)
|
||||
{
|
||||
PyObject* resultlist = PyList_New(512);
|
||||
|
||||
for (int index = 0; index < 512; index++)
|
||||
{
|
||||
PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0));
|
||||
}
|
||||
for (int index = 0; index < 512; index++)
|
||||
{
|
||||
PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0));
|
||||
}
|
||||
|
||||
return resultlist;
|
||||
}
|
||||
@@ -487,13 +488,13 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args)
|
||||
char cpath[sizeof(gp_GamePythonPath)];
|
||||
char *searchpath = NULL;
|
||||
PyObject* list, *value;
|
||||
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
|
||||
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|s:getBlendFileList", &searchpath))
|
||||
return NULL;
|
||||
|
||||
|
||||
list = PyList_New(0);
|
||||
|
||||
if (searchpath) {
|
||||
@@ -503,23 +504,23 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args)
|
||||
/* Get the dir only */
|
||||
BLI_split_dirfile(gp_GamePythonPath, cpath, NULL);
|
||||
}
|
||||
|
||||
if((dp = opendir(cpath)) == NULL) {
|
||||
|
||||
if((dp = opendir(cpath)) == NULL) {
|
||||
/* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */
|
||||
fprintf(stderr, "Could not read directoty (%s) failed, code %d (%s)\n", cpath, errno, strerror(errno));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
while ((dirp = readdir(dp)) != NULL) {
|
||||
while ((dirp = readdir(dp)) != NULL) {
|
||||
if (BLI_testextensie(dirp->d_name, ".blend")) {
|
||||
value= PyUnicode_DecodeFSDefault(dirp->d_name);
|
||||
PyList_Append(list, value);
|
||||
Py_DECREF(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dp);
|
||||
return list;
|
||||
closedir(dp);
|
||||
return list;
|
||||
}
|
||||
|
||||
static char gPyAddScene_doc[] =
|
||||
@@ -1216,6 +1217,28 @@ static PyObject* gPyGetMaterialType(PyObject*)
|
||||
return PyLong_FromSsize_t(flag);
|
||||
}
|
||||
|
||||
static PyObject* gPySetAnisotropicFiltering(PyObject*, PyObject* args)
|
||||
{
|
||||
short level;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "h:setAnisotropicFiltering", &level))
|
||||
return NULL;
|
||||
|
||||
if (level != 1 && level != 2 && level != 4 && level != 8 && level != 16) {
|
||||
PyErr_SetString(PyExc_ValueError, "Rasterizer.setAnisotropicFiltering(level): Expected value of 1, 2, 4, 8, or 16 for value");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gp_Rasterizer->SetAnisotropicFiltering(level);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* gPyGetAnisotropicFiltering(PyObject*, PyObject* args)
|
||||
{
|
||||
return PyLong_FromLong(gp_Rasterizer->GetAnisotropicFiltering());
|
||||
}
|
||||
|
||||
static PyObject* gPyDrawLine(PyObject*, PyObject* args)
|
||||
{
|
||||
PyObject* ob_from;
|
||||
@@ -1280,6 +1303,10 @@ static struct PyMethodDef rasterizer_methods[] = {
|
||||
METH_VARARGS, "set the state of a GLSL material setting"},
|
||||
{"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting,
|
||||
METH_VARARGS, "get the state of a GLSL material setting"},
|
||||
{"setAnisotropicFiltering", (PyCFunction) gPySetAnisotropicFiltering,
|
||||
METH_VARARGS, "set the anisotropic filtering level (must be one of 1, 2, 4, 8, 16)"},
|
||||
{"getAnisotropicFiltering", (PyCFunction) gPyGetAnisotropicFiltering,
|
||||
METH_VARARGS, "get the anisotropic filtering level"},
|
||||
{"drawLine", (PyCFunction) gPyDrawLine,
|
||||
METH_VARARGS, "draw a line on the screen"},
|
||||
{ NULL, (PyCFunction) NULL, 0, NULL }
|
||||
@@ -1647,11 +1674,16 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack
|
||||
KX_MACRO_addTypesToDict(d, RM_POLYS, KX_NavMeshObject::RM_POLYS);
|
||||
KX_MACRO_addTypesToDict(d, RM_TRIS, KX_NavMeshObject::RM_TRIS);
|
||||
|
||||
/* BL_Action play modes */
|
||||
KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_PLAY, BL_Action::ACT_MODE_PLAY);
|
||||
KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_LOOP, BL_Action::ACT_MODE_LOOP);
|
||||
KX_MACRO_addTypesToDict(d, KX_ACTION_MODE_PING_PONG, BL_Action::ACT_MODE_PING_PONG);
|
||||
|
||||
// Check for errors
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
{
|
||||
Py_FatalError("can't initialize module bge.logic");
|
||||
}
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
@@ -1768,7 +1800,7 @@ static void restorePySysObjects(void)
|
||||
|
||||
// Copied from bpy_interface.c
|
||||
static struct _inittab bge_internal_modules[]= {
|
||||
{(char *)"mathutils", BPyInit_mathutils},
|
||||
{(char *)"mathutils", PyInit_mathutils},
|
||||
{(char *)"bgl", BPyInit_bgl},
|
||||
{(char *)"blf", BPyInit_blf},
|
||||
{(char *)"aud", AUD_initPython},
|
||||
@@ -1941,12 +1973,12 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
|
||||
gp_Rasterizer = rasty;
|
||||
|
||||
|
||||
PyObject* m;
|
||||
PyObject* d;
|
||||
PyObject* item;
|
||||
PyObject* m;
|
||||
PyObject* d;
|
||||
PyObject* item;
|
||||
|
||||
/* Use existing module where possible
|
||||
* be careful not to init any runtime vars after this */
|
||||
* be careful not to init any runtime vars after this */
|
||||
m = PyImport_ImportModule( "Rasterizer" );
|
||||
if(m) {
|
||||
Py_DECREF(m);
|
||||
@@ -1954,32 +1986,32 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
|
||||
}
|
||||
else {
|
||||
PyErr_Clear();
|
||||
|
||||
|
||||
// Create the module and add the functions
|
||||
m = PyModule_Create(&Rasterizer_module_def);
|
||||
PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_module_def.m_name, m);
|
||||
}
|
||||
|
||||
// Add some symbolic constants to the module
|
||||
d = PyModule_GetDict(m);
|
||||
ErrorObject = PyUnicode_FromString("Rasterizer.error");
|
||||
PyDict_SetItemString(d, "error", ErrorObject);
|
||||
Py_DECREF(ErrorObject);
|
||||
// Add some symbolic constants to the module
|
||||
d = PyModule_GetDict(m);
|
||||
ErrorObject = PyUnicode_FromString("Rasterizer.error");
|
||||
PyDict_SetItemString(d, "error", ErrorObject);
|
||||
Py_DECREF(ErrorObject);
|
||||
|
||||
/* needed for get/setMaterialType */
|
||||
KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL);
|
||||
KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL);
|
||||
KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL);
|
||||
/* needed for get/setMaterialType */
|
||||
KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL);
|
||||
KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL);
|
||||
KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL);
|
||||
|
||||
// XXXX Add constants here
|
||||
// XXXX Add constants here
|
||||
|
||||
// Check for errors
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
Py_FatalError("can't initialize module Rasterizer");
|
||||
}
|
||||
// Check for errors
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
Py_FatalError("can't initialize module Rasterizer");
|
||||
}
|
||||
|
||||
return d;
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
@@ -2218,9 +2250,9 @@ PyObject* initGameKeys()
|
||||
|
||||
// Check for errors
|
||||
if (PyErr_Occurred())
|
||||
{
|
||||
{
|
||||
Py_FatalError("can't initialize module GameKeys");
|
||||
}
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user