if k not in B.arguments:
env[k] = v
+# detect presence of 3D_CONNEXION_CLIENT_LIBRARY for OSX
+if env['OURPLATFORM']=='darwin':
+ envi = Environment()
+ conf = Configure(envi)
+ if not conf.CheckCHeader('ConnexionClientAPI.h'): # CheckCXXHeader if it is c++ !
+ print "3D_CONNEXION_CLIENT_LIBRARY not found, disabling WITH_BF_3DMOUSE" # avoid build errors !
+ env['WITH_BF_3DMOUSE'] = 0
+ envi = conf.Finish()
+
if env['WITH_BF_OPENMP'] == 1:
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
Physics Constraints (bge.constraints)
=====================================
+.. module:: bge.constraints
+
+.. literalinclude:: ../examples/bge.constraints.py
+
.. function:: createConstraint(physicsid, physicsid2, constrainttype, [pivotX, pivotY, pivotZ, [axisX, axisY, axisZ, [flag]]]])
Creates a constraint.
.. module:: bge.texture
+.. literalinclude:: ../examples/bge.texture.py
+
+.. literalinclude:: ../examples/bge.texture.1.py
+
.. class:: VideoFFmpeg(file [, capture=-1, rate=25.0, width=0, height=0])
FFmpeg video source
The "red book": "I{OpenGL Programming Guide: The Official Guide to Learning
OpenGL}" and the online NeHe tutorials are two of the best resources.
-..note::
+.. note::
You can use the :class:`Image` type to load and set textures.
See :class:`Image.gl_load` and :class:`Image.gl_load`,
for example.
bgl.glGetFloatv(bgl.GL_MODELVIEW_MATRIX, view_matrix)
f = 1.0 / view_matrix[0]
- # Instead of the usual glRasterPos2i(xval, yval)
+ # Instead of the usual glRasterPos2i(xval, yval)
bgl.glRasterPos2f(xval * f, yval * f)
.. code-block:: python
import bgl
+
myByteBuffer = bgl.Buffer(bgl.GL_BYTE, [32, 32])
bgl.glGetPolygonStipple(myByteBuffer)
+
print(myByteBuffer.dimensions)
print(myByteBuffer.to_list())
+
sliceBuffer = myByteBuffer[0:16]
print(sliceBuffer)
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+#ifdef WITH_INPUT_NDOF // use contents of this file
+
#include "GHOST_NDOFManagerWin32.h"
// always available since RawInput is built into Windows
return true;
}
+
+#endif // WITH_INPUT_NDOF
*
* ***** END GPL LICENSE BLOCK *****
*/
-
+
+
#ifndef _GHOST_NDOFMANAGERWIN32_H_
#define _GHOST_NDOFMANAGERWIN32_H_
+#ifdef WITH_INPUT_NDOF
+
#include "GHOST_NDOFManager.h"
};
-#endif
+#endif // WITH_INPUT_NDOF
+#endif // #include guard
#endif
#endif
-#include "GHOST_Debug.h"
#include "GHOST_DisplayManagerWin32.h"
#include "GHOST_EventButton.h"
#include "GHOST_EventCursor.h"
#include "GHOST_TimerManager.h"
#include "GHOST_WindowManager.h"
#include "GHOST_WindowWin32.h"
+
+#ifdef WITH_INPUT_NDOF
#include "GHOST_NDOFManagerWin32.h"
+#endif
// Key code values not found in winuser.h
#ifndef VK_MINUS
static void initRawInput()
{
- RAWINPUTDEVICE devices[2];
- memset(devices, 0, 2 * sizeof(RAWINPUTDEVICE));
+#ifdef WITH_INPUT_NDOF
+#define DEVICE_COUNT 2
+#else
+#define DEVICE_COUNT 1
+#endif
- // multi-axis mouse (SpaceNavigator, etc.)
- devices[0].usUsagePage = 0x01;
- devices[0].usUsage = 0x08;
+ RAWINPUTDEVICE devices[DEVICE_COUNT];
+ memset(devices, 0, DEVICE_COUNT * sizeof(RAWINPUTDEVICE));
// Initiates WM_INPUT messages from keyboard
// That way GHOST can retrieve true keys
+ devices[0].usUsagePage = 0x01;
+ devices[0].usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
+
+#ifdef WITH_INPUT_NDOF
+ // multi-axis mouse (SpaceNavigator, etc.)
devices[1].usUsagePage = 0x01;
- devices[1].usUsage = 0x06; /* http://msdn.microsoft.com/en-us/windows/hardware/gg487473.aspx */
+ devices[1].usUsage = 0x08;
+#endif
- if (RegisterRawInputDevices(devices, 2, sizeof(RAWINPUTDEVICE)))
- puts("registered for RawInput (spacenav & keyboard)");
+ if (RegisterRawInputDevices(devices, DEVICE_COUNT, sizeof(RAWINPUTDEVICE)))
+ ; // yay!
else
printf("could not register for RawInput: %d\n", (int)GetLastError());
+
+#undef DEVICE_COUNT
}
GHOST_SystemWin32::GHOST_SystemWin32()
case 1: // translation
{
short* axis = (short*)(data + 1);
+ // massage into blender view coords (same goes for rotation)
short t[3] = {axis[0], -axis[2], axis[1]};
m_ndofManager->updateTranslation(t, now);
}
case 3: // buttons
{
-#if 0
- // I'm getting garbage bits -- examine whole report:
- printf("ndof: HID report for buttons [");
- for (int i = 0; i < raw.data.hid.dwSizeHid; ++i)
- printf(" %02X", data[i]);
- printf(" ]\n");
-#endif
-
int button_bits;
memcpy(&button_bits, data + 1, sizeof(button_bits));
m_ndofManager->updateButtons(button_bits, now);
GHOST_PRINT(" key ignored\n")
}
break;
- case RIM_TYPEHID:
#ifdef WITH_INPUT_NDOF
+ case RIM_TYPEHID:
if (system->processNDOF(raw))
eventHandled = true;
-#endif
break;
+#endif
}
break;
}
col = layout.column(align=True)
col.label(text="Shading:")
- col.operator("object.shade_smooth", text="Smooth")
- col.operator("object.shade_flat", text="Flat")
+ row = col.row(align=True)
+ row.operator("object.shade_smooth", text="Smooth")
+ row.operator("object.shade_flat", text="Flat")
draw_keyframing_tools(context, layout)
col = layout.column(align=True)
col.label(text="Shading:")
- col.operator("mesh.faces_shade_smooth", text="Smooth")
- col.operator("mesh.faces_shade_flat", text="Flat")
+ row = col.row(align=True)
+ row.operator("mesh.faces_shade_smooth", text="Smooth")
+ row.operator("mesh.faces_shade_flat", text="Flat")
draw_repeat_tools(context, layout)
*/
int BLO_is_a_library(const char *path, char *dir, char *group);
-struct Main* BLO_library_append_begin(const struct bContext *C, BlendHandle** bh, const char *filepath);
+
+/**
+ * Initialize the BlendHandle for appending or linking library data.
+ *
+ * @param mainvar The current main database eg G.main or CTX_data_main(C).
+ * @param bh A blender file handle as returned by BLO_blendhandle_from_file or BLO_blendhandle_from_memory.
+ * @param filepath Used for relative linking, copied to the lib->name
+ * @return the library Main, to be passed to BLO_library_append_named_part as mainl.
+ */
+struct Main* BLO_library_append_begin(struct Main *mainvar, BlendHandle** bh, const char *filepath);
/**
void *BLO_library_read_struct(struct FileData *fd, struct BHead *bh, const char *blockname);
-/* deprecated */
-#if 1
-void BLO_script_library_append(BlendHandle **bh, char *dir, char *name, int idcode, short flag, struct Main *mainvar, struct Scene *scene, struct ReportList *reports);
-#endif
-
BlendFileData* blo_read_blendafterruntime(int file, char *name, int actualsize, struct ReportList *reports);
#ifdef __cplusplus
/* common routine to append/link something from a library */
-static Main* library_append_begin(const bContext *C, FileData **fd, const char *filepath)
+static Main* library_append_begin(Main *mainvar, FileData **fd, const char *filepath)
{
- Main *mainvar= CTX_data_main(C);
Main *mainl;
/* make mains */
return mainl;
}
-Main* BLO_library_append_begin(const bContext *C, BlendHandle** bh, const char *filepath)
+Main* BLO_library_append_begin(Main *mainvar, BlendHandle** bh, const char *filepath)
{
FileData *fd= (FileData*)(*bh);
- return library_append_begin(C, &fd, filepath);
+ return library_append_begin(mainvar, &fd, filepath);
}
-static void append_do_cursor(Scene *scene, Library *curlib, short flag)
-{
- Base *centerbase;
- Object *ob;
- float *curs, centerloc[3], vec[3], min[3], max[3];
- int count= 0;
-
- /* when not linking (appending)... */
- if(flag & FILE_LINK)
- return;
-
- /* we're not appending at cursor */
- if((flag & FILE_ATCURSOR) == 0)
- return;
-
- /* find the center of everything appended */
- INIT_MINMAX(min, max);
- centerbase= (scene->base.first);
- while(centerbase) {
- if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
- VECCOPY(vec, centerbase->object->loc);
- DO_MINMAX(vec, min, max);
- count++;
- }
- centerbase= centerbase->next;
- }
- /* we haven't found any objects to move to cursor */
- if(!count)
- return;
-
- /* move from the center of the appended objects to cursor */
- mid_v3_v3v3(centerloc, min, max);
- curs = scene->cursor;
- VECSUB(centerloc,curs,centerloc);
-
- /* now translate the center of the objects */
- centerbase= (scene->base.first);
- while(centerbase) {
- if(centerbase->object->id.lib==curlib && centerbase->object->parent==NULL) {
- ob= centerbase->object;
- ob->loc[0] += centerloc[0];
- ob->loc[1] += centerloc[1];
- ob->loc[2] += centerloc[2];
- }
- centerbase= centerbase->next;
- }
-}
+/* Context == NULL signifies not to do any scene manipulation */
static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
{
Main *mainvar;
- Scene *scene= CTX_data_scene(C);
Library *curlib;
/* make main consistent */
lib_verify_nodetree(mainvar, FALSE);
fix_relpaths_library(G.main->name, mainvar); /* make all relative paths, relative to the open blend file */
- /* give a base to loose objects. If group append, do it for objects too */
- if(scene) {
- const short is_link= (flag & FILE_LINK) != 0;
- if(idcode==ID_SCE) {
- /* dont instance anything when linking in scenes, assume the scene its self instances the data */
- }
- else {
- give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
+ if(C) {
+ Scene *scene= CTX_data_scene(C);
- if (flag & FILE_GROUP_INSTANCE) {
- give_base_to_groups(mainvar, scene);
+ /* give a base to loose objects. If group append, do it for objects too */
+ if(scene) {
+ const short is_link= (flag & FILE_LINK) != 0;
+ if(idcode==ID_SCE) {
+ /* dont instance anything when linking in scenes, assume the scene its self instances the data */
+ }
+ else {
+ give_base_to_objects(mainvar, scene, curlib, idcode, is_link);
+
+ if (flag & FILE_GROUP_INSTANCE) {
+ give_base_to_groups(mainvar, scene);
+ }
}
}
- }
- else {
- printf("library_append_end, scene is NULL (objects wont get bases)\n");
+ else {
+ printf("library_append_end, scene is NULL (objects wont get bases)\n");
+ }
}
/* has been removed... erm, why? s..ton) */
/* 20040907: looks like they are give base already in append_named_part(); -Nathan L */
blo_freefiledata( *fd );
*fd = NULL;
}
-
- append_do_cursor(scene, curlib, flag);
}
void BLO_library_append_end(const bContext *C, struct Main *mainl, BlendHandle** bh, int idcode, short flag)
VFont *font;
PropertyPointerRNA *pprop;
PointerRNA idptr;
- char str[FILE_MAX];
- RNA_string_get(op->ptr, "filepath", str);
+ char filepath[FILE_MAX];
+ RNA_string_get(op->ptr, "filepath", filepath);
- font = load_vfont(str);
+ font= load_vfont(filepath);
if(!font) {
if(op->customdata) MEM_freeN(op->customdata);
TH_DRAWEXTRA_EDGELEN,
TH_DRAWEXTRA_FACEAREA,
- TH_DRAWEXTRA_FACEANG
+ TH_DRAWEXTRA_FACEANG,
+
+ TH_NODE_CURVING
};
/* XXX WARNING: previous is saved in file, so do not change order! */
cp= ts->syntaxv; break;
case TH_NODE_GROUP:
cp= ts->syntaxc; break;
-
+ case TH_NODE_CURVING:
+ cp= &ts->noodle_curving; break;
+
case TH_SEQ_MOVIE:
cp= ts->movie; break;
case TH_SEQ_IMAGE:
SETCOL(btheme->tnode.syntaxb, 108, 105, 111, 255); /* operator */
SETCOL(btheme->tnode.syntaxv, 104, 106, 117, 255); /* generator */
SETCOL(btheme->tnode.syntaxc, 105, 117, 110, 255); /* group */
+ btheme->tnode.noodle_curving = 5;
/* space logic */
btheme->tlogic= btheme->tv3d;
/* clear "AUTOKEY_FLAG_ONLYKEYINGSET" flag from userprefs, so that it doesn't linger around from old configs like a ghost */
U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET;
}
-
+
+ if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) {
+ bTheme *btheme;
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ btheme->tnode.noodle_curving = 5;
+ }
+ }
+
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {
U.texcollectrate = 60;
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+#include <ctype.h>
/* for events */
#define NOTACTIVEFILE 0
}
#ifdef WIN32
- if (sfile->params->dir[0] == '\0')
+ if (sfile->params->dir[0] == '\0') {
get_default_root(sfile->params->dir);
+ }
+ /* change "C:" --> "C:\", [#28102] */
+ else if ( (isalpha(sfile->params->dir[0]) &&
+ (sfile->params->dir[1] == ':')) &&
+ (sfile->params->dir[2] == '\0')
+
+ ) {
+ sfile->params->dir[2]= '\\';
+ sfile->params->dir[3]= '\0';
+ }
#endif
}
}
vec[3][0]= snode->mx;
vec[3][1]= snode->my;
}
-
- dist= 0.5f*ABS(vec[0][0] - vec[3][0]);
+
+ dist= UI_GetThemeValue(TH_NODE_CURVING)*0.10f*ABS(vec[0][0] - vec[3][0]);
/* check direction later, for top sockets */
vec[1][0]= vec[0][0]+dist;
se = give_stripelem(seq, cfra);
seq_new= seq_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME);
- BLI_addtail(&ed->seqbase, seq_new);
+ BLI_addtail(ed->seqbasep, seq_new);
seq_new->start= start_ofs;
seq_new->type= SEQ_IMAGE;
ot->description="On image sequences strips, it return a strip for each image";
/* api callbacks */
- ot->invoke= WM_operator_props_popup;
ot->exec= sequencer_separate_images_exec;
ot->poll= sequencer_edit_poll;
#define FILE_HIDE_DOT (1<<3)
#define FILE_AUTOSELECT (1<<4)
#define FILE_ACTIVELAY (1<<5)
-#define FILE_ATCURSOR (1<<6)
+/* #define FILE_ATCURSOR (1<<6) */ /* deprecated */
#define FILE_DIRSEL_ONLY (1<<7)
#define FILE_FILTER (1<<8)
#define FILE_BOOKMARKS (1<<9)
char console_cursor[4];
char vertex_size, outline_width, facedot_size;
- char bpad;
+ char noodle_curving;
char syntaxl[4], syntaxn[4], syntaxb[4]; // syntax for textwindow and nodes
char syntaxv[4], syntaxc[4];
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
- if(prop)
+ if(prop) {
RNA_property_string_get(ptr, prop, value);
- else
+ }
+ else {
printf("RNA_string_get: %s.%s not found.\n", ptr->type->identifier, name);
+ value[0]= '\0';
+ }
}
char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen)
// #include "ED_mesh.h"
-#include "BLI_math.h"
#ifdef RNA_RUNTIME
+#include "BLI_math.h"
#include "BKE_main.h"
#include "BKE_global.h"
/* location of point for test and max distance */
parm= RNA_def_float_vector(func, "point", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
RNA_def_property_flag(parm, PROP_REQUIRED);
- RNA_def_float(func, "max_dist", sqrt(FLT_MAX), 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
+ /* default is sqrt(FLT_MAX) */
+ RNA_def_float(func, "max_dist", 1.844674352395373e+19, 0.0, FLT_MAX, "", "", 0.0, FLT_MAX);
/* return location and normal */
parm= RNA_def_float_vector(func, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "The location on the object closest to the point", -1e4, 1e4);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Group Node", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+ prop= RNA_def_property(srna, "noodle_curving", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "noodle_curving");
+ RNA_def_property_int_default(prop, 5);
+ RNA_def_property_range(prop, 0, 10);
+ RNA_def_property_ui_text(prop, "Noodle curving", "Curving of the noodle");
+ RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_space_logic(BlenderRNA *brna)
#include "bpy_driver.h"
-#include "../generic/py_capi_utils.h"
-
/* for pydrivers (drivers using one-line Python expressions to express relationships between targets) */
PyObject *bpy_pydriver_Dict= NULL;
void BPY_driver_reset(void)
{
PyGILState_STATE gilstate;
- int use_gil= !PYC_INTERPRETER_ACTIVE;
+ int use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
if(use_gil)
gilstate= PyGILState_Ensure();
/* This evals py driver expressions, 'expr' is a Python expression that
* should evaluate to a float number, which is returned.
*
- * note: PyGILState_Ensure() isnt always called because python can call the
- * bake operator which intern starts a thread which calls scene update which
- * does a driver update. to avoid a deadlock check PYC_INTERPRETER_ACTIVE if PyGILState_Ensure() is needed.
+ * (old)note: PyGILState_Ensure() isnt always called because python can call
+ * the bake operator which intern starts a thread which calls scene update
+ * which does a driver update. to avoid a deadlock check PYC_INTERPRETER_ACTIVE
+ * if PyGILState_Ensure() is needed - see [#27683]
+ *
+ * (new)note: checking if python is running is not threadsafe [#28114]
+ * now release the GIL on python operator execution instead, using
+ * PyEval_SaveThread() / PyEval_RestoreThread() so we dont lock up blender.
*/
float BPY_driver_exec(ChannelDriver *driver)
{
return 0.0f;
}
- use_gil= !PYC_INTERPRETER_ACTIVE;
+ use_gil= 1; /* !PYC_INTERPRETER_ACTIVE; */
if(use_gil)
gilstate= PyGILState_Ensure();
#include "BKE_library.h"
#include "BKE_idcode.h"
#include "BKE_report.h"
+#include "BKE_context.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
/* here appending/linking starts */
- mainl= BLO_library_append_begin(BPy_GetContext(), &(self->blo_handle), self->relpath);
+ mainl= BLO_library_append_begin(CTX_data_main(BPy_GetContext()), &(self->blo_handle), self->relpath);
{
int i= 0, code;
#include "BKE_report.h"
#include "BKE_context.h"
+/* so operators called can spawn threads which aquire the GIL */
+#define BPY_RELEASE_GIL
+
+
static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
{
wmOperatorType *ot;
reports= MEM_mallocN(sizeof(ReportList), "wmOperatorReportList");
BKE_reports_init(reports, RPT_STORE | RPT_OP_HOLD); /* own so these dont move into global reports */
- operator_ret= WM_operator_call_py(C, ot, context, &ptr, reports);
+#ifdef BPY_RELEASE_GIL
+ /* release GIL, since a thread could be started from an operator
+ * that updates a driver */
+ /* note: I havve not seen any examples of code that does this
+ * so it may not be officially supported but seems to work ok. */
+ {
+ PyThreadState *ts= PyEval_SaveThread();
+#endif
+
+ operator_ret= WM_operator_call_py(C, ot, context, &ptr, reports);
+
+#ifdef BPY_RELEASE_GIL
+ /* regain GIL */
+ PyEval_RestoreThread(ts);
+ }
+#endif
error_val= BPy_reports_to_error(reports, PyExc_RuntimeError, FALSE);
int idcode, totfiles=0;
short flag;
- name[0] = '\0';
RNA_string_get(op->ptr, "filename", name);
RNA_string_get(op->ptr, "directory", dir);
flag_all_listbases_ids(LIB_PRE_EXISTING, 1);
/* here appending/linking starts */
- mainl = BLO_library_append_begin(C, &bh, libname);
+ mainl = BLO_library_append_begin(bmain, &bh, libname);
if(totfiles == 0) {
BLO_library_append_named_part_ex(C, mainl, &bh, name, idcode, flag);
}
bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const char *path, char *group, KX_Scene *scene_merge, char **err_str, short options)
{
- bContext *C;
Main *main_newlib; /* stored as a dynamic 'main' until we free it */
Main *main_tmp= NULL; /* created only for linking, then freed */
LinkNode *names = NULL;
}
main_newlib= (Main *)MEM_callocN( sizeof(Main), "BgeMain");
- C= CTX_create();
- CTX_data_main_set(C, main_newlib);
BKE_reports_init(&reports, RPT_STORE);
/* here appending/linking starts */
- main_tmp = BLO_library_append_begin(C, &bpy_openlib, (char *)path);
+ main_tmp = BLO_library_append_begin(main_newlib, &bpy_openlib, (char *)path);
int totnames_dummy;
names = BLO_blendhandle_get_datablock_names( bpy_openlib, idcode, &totnames_dummy);
}
BLI_linklist_free(names, free); /* free linklist *and* each node's data */
- BLO_library_append_end(C, main_tmp, &bpy_openlib, idcode, flag);
+ BLO_library_append_end(NULL, main_tmp, &bpy_openlib, idcode, flag);
/* now do another round of linking for Scenes so all actions are properly loaded */
if (idcode==ID_SCE && options & LIB_LOAD_LOAD_ACTIONS) {
- main_tmp = BLO_library_append_begin(C, &bpy_openlib, (char *)path);
+ main_tmp = BLO_library_append_begin(main_newlib, &bpy_openlib, (char *)path);
int totnames_dummy;
names = BLO_blendhandle_get_datablock_names( bpy_openlib, ID_AC, &totnames_dummy);
}
BLI_linklist_free(names, free); /* free linklist *and* each node's data */
- BLO_library_append_end(C, main_tmp, &bpy_openlib, ID_AC, flag);
+ BLO_library_append_end(NULL, main_tmp, &bpy_openlib, ID_AC, flag);
}
BLO_blendhandle_close(bpy_openlib);
-
- CTX_free(C);
+
BKE_reports_clear(&reports);
/* done linking */