From 83b1f21cf9454cbbe49411b8973d57b5c9f76642 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 21 Jan 2012 22:42:09 +0000 Subject: [PATCH 001/105] fix for memory leak displaying shortcuts to buttons which use allocated string, also de-duplocate this code which had this error in 2 places. noticed while testing 1023 length paths. --- source/blender/editors/interface/interface.c | 50 +++++++++++++------ .../editors/interface/interface_handlers.c | 22 ++------ .../editors/interface/interface_intern.h | 1 + 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index c112918833e..3a1bab9987e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -800,11 +800,43 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) } } +/* XXX, this code will shorten any allocated string to 'UI_MAX_NAME_STR' + * since this is really long its unlikely to be an issue, + * but this could be supported */ +void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const short do_strip) +{ + + if (do_strip) { + char *cpoin= strchr(but->str, '|'); + if(cpoin) { + *cpoin= '\0'; + } + } + + /* without this, just allow stripping of the shortcut */ + if (shortcut_str) { + char *butstr_orig; + + if (but->str != but->strdata) { + butstr_orig = but->str; /* free after using as source buffer */ + } + else { + butstr_orig = BLI_strdup(but->str); + } + BLI_snprintf(but->strdata, + sizeof(but->strdata), + "%s|%s", + butstr_orig, shortcut_str); + MEM_freeN(butstr_orig); + but->str = but->strdata; + ui_check_but(but); + } +} static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) { uiBut *but; - char buf[512]; + char buf[128]; /* for menu's */ MenuType *mt; @@ -815,18 +847,6 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if(block->minx != block->maxx) return; - -#define UI_MENU_KEY_STR_CAT \ - char *butstr_orig= BLI_strdup(but->str); \ - BLI_snprintf(but->strdata, \ - sizeof(but->strdata), \ - "%s|%s", \ - butstr_orig, buf); \ - MEM_freeN(butstr_orig); \ - but->str= but->strdata; \ - ui_check_but(but); \ - - for(but=block->buttons.first; but; but=but->next) { if(but->optype) { IDProperty *prop= (but->opptr)? but->opptr->data: NULL; @@ -834,7 +854,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) { - UI_MENU_KEY_STR_CAT + ui_but_add_shortcut(but, buf, FALSE); } } else if ((mt= uiButGetMenuType(but))) { @@ -851,7 +871,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, buf, sizeof(buf))) { - UI_MENU_KEY_STR_CAT + ui_but_add_shortcut(but, buf, FALSE); } } } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 311f0f87b50..93d8f9c0c8a 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4382,31 +4382,19 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) uiBut *but = (uiBut *)arg1; if (but->optype) { - char buf[512], *cpoin; + char shortcut_str[128]; IDProperty *prop= (but->opptr)? but->opptr->data: NULL; /* complex code to change name of button */ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, - buf, sizeof(buf))) + shortcut_str, sizeof(shortcut_str))) { - char *butstr_orig; - - // XXX but->str changed... should not, remove the hotkey from it - cpoin= strchr(but->str, '|'); - if(cpoin) *cpoin= 0; - - butstr_orig= BLI_strdup(but->str); - BLI_snprintf(but->strdata, sizeof(but->strdata), "%s|%s", butstr_orig, buf); - MEM_freeN(butstr_orig); - but->str= but->strdata; - - ui_check_but(but); + ui_but_add_shortcut(but, shortcut_str, TRUE); } else { - /* shortcut was removed */ - cpoin= strchr(but->str, '|'); - if(cpoin) *cpoin= 0; + /* simply strip the shortcut */ + ui_but_add_shortcut(but, NULL, TRUE); } } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 2980b28d522..2d8de475c4b 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -498,6 +498,7 @@ void ui_resources_free(void); void ui_layout_add_but(uiLayout *layout, uiBut *but); int ui_but_can_align(uiBut *but); void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop); +void ui_but_add_shortcut(uiBut *but, const char *key_str, const short do_strip); /* interface_anim.c */ void ui_but_anim_flag(uiBut *but, float cfra); From 2139c7080eb6bc05111b09f93ad1836930434dad Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sat, 21 Jan 2012 23:57:28 +0000 Subject: [PATCH 002/105] patch: 'set the right Action Actuator when duplicating an object' by Daniel Macedo bug and patch not in tracker. little fix by me (replace while loop by for(...;act;...). Thanks Daniel ;) --- source/blender/editors/object/object_add.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 64bbf604f67..6ac2ee820db 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -46,6 +46,7 @@ #include "DNA_scene_types.h" #include "DNA_speaker_types.h" #include "DNA_vfont_types.h" +#include "DNA_actuator_types.h" #include "BLI_ghash.h" #include "BLI_listbase.h" @@ -1789,10 +1790,22 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base /* check if obdata is copied */ if(didit) { Key *key = ob_get_key(obn); + bActuator *act; if(dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action((ID *)obn->data); if(key) BKE_copy_animdata_id_action((ID*)key); + + /* Update the duplicated action in the action actuators */ + for (act= obn->actuators.first; act; act= act->next) { + if(act->type == ACT_ACTION) { + bActionActuator* actact = (bActionActuator*) act->data; + if(actact->act == ob->adt->action) { + actact->act = obn->adt->action; + } + } + act= act->next; + } } if(dupflag & USER_DUP_MAT) { From f45a8105eedc93ba8c4284f85e7e29f3eaeeb510 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Jan 2012 00:53:53 +0000 Subject: [PATCH 003/105] fix for 'next' being set twice in the for loop from r43588 --- source/blender/editors/object/object_add.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 6ac2ee820db..dce2179db24 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1790,21 +1790,23 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base /* check if obdata is copied */ if(didit) { Key *key = ob_get_key(obn); - bActuator *act; if(dupflag & USER_DUP_ACT) { + bActuator *act; + BKE_copy_animdata_id_action((ID *)obn->data); - if(key) BKE_copy_animdata_id_action((ID*)key); - + if(key) { + BKE_copy_animdata_id_action((ID*)key); + } + /* Update the duplicated action in the action actuators */ - for (act= obn->actuators.first; act; act= act->next) { + for (act = obn->actuators.first; act; act = act->next) { if(act->type == ACT_ACTION) { bActionActuator* actact = (bActionActuator*) act->data; if(actact->act == ob->adt->action) { actact->act = obn->adt->action; } } - act= act->next; } } From 6964b5a6c48f2fab19b4ce5a52ba23525a5f05eb Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 22 Jan 2012 03:21:28 +0000 Subject: [PATCH 004/105] cucumber merge: world scaling + video texture constants revisions: 38166,38167,38177,38179,38180,38187,38242 To be implemented after merge: 1) add pydocs(rst) for the video texture new defines 2) see if a NodeSetLocalMatrix would fit well #43439 by kupoman Changing the worldTransform and localTransform python attributes to use BLI_math to simplify the code #38242 by kupoman Adding the constants SOURCE_ERROR, SOURCE_EMPTY, SOURCE_READY, SOURCE_PLAYING, SOURCE_STOPPED to the video texture module. Updates to the documentation will follow after a merge with trunk #38187 by kupoman Updates to the documentation to reflect that worldScale is now writable, and added localTransform and worldTransform to KX_GameObject. #38180 by kupoman The Transform attribute of KX_GameObject was based on world space data. I converted that one to worldTransform, and added a localTransform for local space transform information. #38179 by kupoman Fixed the transform attribute of KX_GameObject's set method to properly deal with negative scaling. #38177 by kupoman Updated the transform property on KX_GameObject so that it is now read/write, and added the corresponding set method. Also simplified the get method by calling GetOpenGLMatrix instead of making the matrix myself. #38167 by kupoman Adding a read only transform attribute to KX_GameObject that returns a 4x4 matrix representing the object's transformations. #38166 by kupoman Adding a worldScale attribute to KX_GameObject. This attribute scales the object independently of its parent's scale. --- doc/python_api/rst/bge.types.rst | 14 +- source/gameengine/Ketsji/KX_GameObject.cpp | 125 +++++++++++++++++- source/gameengine/Ketsji/KX_GameObject.h | 6 + .../gameengine/VideoTexture/blendVideoTex.cpp | 6 + 4 files changed, 149 insertions(+), 2 deletions(-) diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index f97c95babc9..bb3ac004d51 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -980,7 +980,7 @@ Game Types (bge.types) .. attribute:: worldScale - The object's world scaling factor. Read-only. [sx, sy, sz] + The object's world scaling factor. [sx, sy, sz] :type: :class:`mathutils.Vector` @@ -995,6 +995,18 @@ Game Types (bge.types) The object's world position. [x, y, z] :type: :class:`mathutils.Vector` + + .. attribute:: localTransform + + The object's local space transform matrix. 4x4 Matrix. + + :type: :class:`mathutils.Matrix` + + .. attribute:: worldTransform + + The object's world space transform matrix. 4x4 Matrix. + + :type: :class:`mathutils.Matrix` .. attribute:: localLinearVelocity diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 18b8c0d533d..023c3dcbfc9 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -1153,6 +1153,36 @@ void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale) } } +void KX_GameObject::NodeSetWorldScale(const MT_Vector3& scale) +{ + if (!GetSGNode()) + return; + SG_Node* parent = GetSGNode()->GetSGParent(); + if (parent != NULL) + { + // Make sure the objects have some scale + MT_Vector3 p_scale = parent->GetWorldScaling(); + if (fabs(p_scale[0]) < FLT_EPSILON || + fabs(p_scale[1]) < FLT_EPSILON || + fabs(p_scale[2]) < FLT_EPSILON) + { + return; + } + + MT_Vector3 *local = new MT_Vector3(scale); + + p_scale[0] = 1/p_scale[0]; + p_scale[1] = 1/p_scale[1]; + p_scale[2] = 1/p_scale[2]; + + NodeSetLocalScale(scale * p_scale); + } + else + { + NodeSetLocalScale(scale); + } +} + void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans) { if (!GetSGNode()) @@ -1620,7 +1650,9 @@ PyAttributeDef KX_GameObject::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("localPosition", KX_GameObject, pyattr_get_localPosition, pyattr_set_localPosition), KX_PYATTRIBUTE_RW_FUNCTION("worldPosition", KX_GameObject, pyattr_get_worldPosition, pyattr_set_worldPosition), KX_PYATTRIBUTE_RW_FUNCTION("localScale", KX_GameObject, pyattr_get_localScaling, pyattr_set_localScaling), - KX_PYATTRIBUTE_RO_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling), + KX_PYATTRIBUTE_RW_FUNCTION("worldScale", KX_GameObject, pyattr_get_worldScaling, pyattr_set_worldScaling), + KX_PYATTRIBUTE_RW_FUNCTION("localTransform", KX_GameObject, pyattr_get_localTransform, pyattr_set_localTransform), + KX_PYATTRIBUTE_RW_FUNCTION("worldTransform", KX_GameObject, pyattr_get_worldTransform, pyattr_set_worldTransform), KX_PYATTRIBUTE_RW_FUNCTION("linearVelocity", KX_GameObject, pyattr_get_localLinearVelocity, pyattr_set_worldLinearVelocity), KX_PYATTRIBUTE_RW_FUNCTION("localLinearVelocity", KX_GameObject, pyattr_get_localLinearVelocity, pyattr_set_localLinearVelocity), KX_PYATTRIBUTE_RW_FUNCTION("worldLinearVelocity", KX_GameObject, pyattr_get_worldLinearVelocity, pyattr_set_worldLinearVelocity), @@ -2112,6 +2144,18 @@ PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIB #endif } +int KX_GameObject::pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_GameObject* self= static_cast(self_v); + MT_Vector3 scale; + if (!PyVecTo(value, scale)) + return PY_SET_ATTR_FAIL; + + self->NodeSetWorldScale(scale); + self->NodeUpdateGS(0.f); + return PY_SET_ATTR_SUCCESS; +} + PyObject* KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { #ifdef USE_MATHUTILS @@ -2134,6 +2178,85 @@ int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DE return PY_SET_ATTR_SUCCESS; } +PyObject* KX_GameObject::pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_GameObject* self = static_cast(self_v); + + double *mat = MT_CmMatrix4x4().getPointer(); + + MT_Transform trans; + + trans.setOrigin(self->GetSGNode()->GetLocalPosition()); + trans.setBasis(self->GetSGNode()->GetLocalOrientation()); + + MT_Vector3 scaling = self->GetSGNode()->GetLocalScale(); + trans.scale(scaling[0], scaling[1], scaling[2]); + + trans.getValue(mat); + + return PyObjectFrom(MT_Matrix4x4(mat)); +} + +int KX_GameObject::pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_GameObject* self = static_cast(self_v); + MT_Matrix4x4 temp; + if (!PyMatTo(value, temp)) + return PY_SET_ATTR_FAIL; + + float transform[4][4]; + float loc[3], size[3]; + float rot[3][3]; + MT_Matrix3x3 orientation; + + temp.getValue(*transform); + mat4_to_loc_rot_size(loc, rot, size, transform); + + self->NodeSetLocalPosition(MT_Point3(loc)); + + //MT_Matrix3x3's constructor expects a 4x4 matrix + orientation = MT_Matrix3x3(); + orientation.setValue3x3(*rot); + self->NodeSetLocalOrientation(orientation); + + self->NodeSetLocalScale(MT_Vector3(size)); + + return PY_SET_ATTR_SUCCESS; +} + +PyObject* KX_GameObject::pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_GameObject* self = static_cast(self_v); + + return PyObjectFrom(MT_Matrix4x4(self->GetOpenGLMatrix())); +} + +int KX_GameObject::pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_GameObject* self = static_cast(self_v); + MT_Matrix4x4 temp; + if (!PyMatTo(value, temp)) + return PY_SET_ATTR_FAIL; + + float transform[4][4]; + float loc[3], size[3]; + float rot[3][3]; + MT_Matrix3x3 orientation; + + temp.getValue(*transform); + mat4_to_loc_rot_size(loc, rot, size, transform); + + self->NodeSetWorldPosition(MT_Point3(loc)); + + //MT_Matrix3x3's constructor expects a 4x4 matrix + orientation = MT_Matrix3x3(); + orientation.setValue3x3(*rot); + self->NodeSetGlobalOrientation(orientation); + + self->NodeSetWorldScale(MT_Vector3(size)); + + return PY_SET_ATTR_SUCCESS; +} PyObject* KX_GameObject::pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index cc078e96e64..a35e6f1b2cd 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -475,6 +475,7 @@ public: void NodeSetGlobalOrientation(const MT_Matrix3x3& rot ); void NodeSetLocalScale( const MT_Vector3& scale ); + void NodeSetWorldScale( const MT_Vector3& scale ); void NodeSetRelativeScale( const MT_Vector3& scale ); @@ -968,8 +969,13 @@ public: static PyObject* pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static PyObject* pyattr_get_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_localTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); + static PyObject* pyattr_get_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_worldTransform(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static PyObject* pyattr_get_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index abfd0ed49b7..8410e9350d0 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -38,6 +38,7 @@ http://www.gnu.org/copyleft/lesser.txt. //#include "TexPlayerGL.h" #include "ImageBase.h" +#include "VideoBase.h" #include "FilterBase.h" #include "Texture.h" @@ -208,6 +209,11 @@ PyObject* initVideoTexture(void) Py_INCREF(&TextureType); PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType); + PyModule_AddIntConstant(m, (char*)"SOURCE_ERROR", SourceError); + PyModule_AddIntConstant(m, (char*)"SOURCE_EMPTY", SourceEmpty); + PyModule_AddIntConstant(m, (char*)"SOURCE_READY", SourceReady); + PyModule_AddIntConstant(m, (char*)"SOURCE_PLAYING", SourcePlaying); + PyModule_AddIntConstant(m, (char*)"SOURCE_STOPPED", SourceStopped); // init last error description Exception::m_lastError = ""; From b1667911ef88e067817cb1702695a0d1e350dd78 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Jan 2012 03:30:07 +0000 Subject: [PATCH 005/105] reduce operator lookups in the UI (could do 4 hash lookups per button). --- source/blender/editors/armature/poselib.c | 10 +- source/blender/editors/curve/editcurve.c | 4 +- source/blender/editors/include/UI_interface.h | 7 + source/blender/editors/interface/interface.c | 44 ++-- .../editors/interface/interface_layout.c | 202 +++++++++++------- .../blender/editors/object/object_relations.c | 2 +- .../blender/editors/space_graph/graph_edit.c | 3 +- source/blender/editors/space_node/drawnode.c | 9 +- source/blender/editors/space_text/text_ops.c | 16 +- source/blender/editors/util/ed_util.c | 34 +-- .../windowmanager/intern/wm_operators.c | 2 +- 11 files changed, 212 insertions(+), 121 deletions(-) diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index dcddde207f0..eb49f16584b 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -376,6 +376,10 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, bAction *act= ob->poselib; /* never NULL */ TimeMarker *marker; + wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1); + + BLI_assert(ot != NULL); + /* set the operator execution context correctly */ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); @@ -383,9 +387,9 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, for (marker= act->markers.first; marker; marker= marker->next) { PointerRNA props_ptr; - props_ptr = uiItemFullO(layout, "POSELIB_OT_pose_add", - marker->name, ICON_ARMATURE_DATA, NULL, - WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr = uiItemFullO_ptr(layout, ot, + marker->name, ICON_ARMATURE_DATA, NULL, + WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_int_set(&props_ptr, "frame", marker->frame); RNA_string_set(&props_ptr, "name", marker->name); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index a20fbad874e..8c20d9be4f8 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5876,8 +5876,8 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) if(obedit->type==OB_SURF) { pup= uiPupMenuBegin(C, "Delete", ICON_NONE); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, op->type->idname, NULL, 0, "type", 0); - uiItemEnumO(layout, op->type->idname, NULL, 0, "type", 2); + uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 0); + uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 2); uiPupMenuEnd(C, pup); } else { diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d1f11d60999..3f907004931 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -62,6 +62,7 @@ struct ColorBand; struct CurveMapping; struct Image; struct ImageUser; +struct wmOperatorType; struct uiWidgetColors; struct Tex; struct MTex; @@ -446,6 +447,7 @@ uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *s uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconBut(uiBlock *block, @@ -466,6 +468,7 @@ uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, @@ -485,6 +488,7 @@ uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int i uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); /* for passing inputs to ButO buttons */ struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but); @@ -773,6 +777,7 @@ void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const cha /* items */ void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname); +void uiItemEnumO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, const char *propname, int value); void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value); void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value); @@ -781,6 +786,8 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value); void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value); + +PointerRNA uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag); PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag); void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3a1bab9987e..8bb9ceb121c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2806,16 +2806,12 @@ static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, cons return but; } -static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - wmOperatorType *ot; - - ot= WM_operatortype_find(opname, 0); if(!str) { - if(ot) str= ot->name; - else str= opname; + if(ot) str = ot->name; } if ((!tip || tip[0]=='\0') && ot && ot->description) { @@ -2837,6 +2833,12 @@ static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, return but; } +static uiBut *UNUSED_FUNCTION(ui_def_but_operator)(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); + if (str == NULL && ot == NULL) str = opname; + return ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); +} static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { @@ -3043,13 +3045,20 @@ uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int ui_check_but(but); return but; } -uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) + +uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip); + but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); ui_check_but(but); return but; } +uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); + if (str == NULL && ot == NULL) str = opname; + return uiDefButO_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); +} uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { @@ -3121,13 +3130,19 @@ uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1 ui_check_but_and_iconize(but, icon); return but; } -uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) + +uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, "", x1, y1, x2, y2, tip); + but= ui_def_but_operator_ptr(block, type, ot, opcontext, "", x1, y1, x2, y2, tip); ui_check_but_and_iconize(but, icon); return but; } +uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); + return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x1, y1, x2, y2, tip); +} /* Button containing both string label and icon */ uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) @@ -3195,14 +3210,19 @@ uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, co but->flag|= UI_ICON_LEFT; return but; } -uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip); + but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); ui_check_but_and_iconize(but, icon); but->flag|= UI_ICON_LEFT; return but; } +uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); + return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x1, y1, x2, y2, tip); +} /* END Button containing both string label and icon */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index eb55cf912d6..20b5bc54661 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -622,19 +622,12 @@ static void ui_item_disabled(uiLayout *layout, const char *name) } /* operator items */ -PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag) +PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag) { uiBlock *block= layout->root->block; - wmOperatorType *ot= WM_operatortype_find(opname, 1); uiBut *but; int w; - if(!ot) { - ui_item_disabled(layout, opname); - RNA_warning("unknown operator '%s'", opname); - return PointerRNA_NULL; - } - if(!name) { name= IFACE_(ot->name); } @@ -650,12 +643,18 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i if (flag & UI_ITEM_R_NO_BG) uiBlockSetEmboss(block, UI_EMBOSSN); - if(icon && name[0]) - but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL); - else if(icon) - but= uiDefIconButO(block, BUT, ot->idname, context, icon, 0, 0, w, UI_UNIT_Y, NULL); - else - but= uiDefButO(block, BUT, ot->idname, context, name, 0, 0, w, UI_UNIT_Y, NULL); + /* create the button */ + if(icon) { + if (name[0]) { + but = uiDefIconTextButO_ptr(block, BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL); + } + else { + but = uiDefIconButO_ptr(block, BUT, ot, context, icon, 0, 0, w, UI_UNIT_Y, NULL); + } + } + else { + but= uiDefButO_ptr(block, BUT, ot, context, name, 0, 0, w, UI_UNIT_Y, NULL); + } assert(but->optype != NULL); @@ -687,55 +686,90 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i return PointerRNA_NULL; } -static const char *ui_menu_enumpropname(uiLayout *layout, const char *opname, const char *propname, int retval) +PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag) { - wmOperatorType *ot= WM_operatortype_find(opname, 0); - PointerRNA ptr; - PropertyRNA *prop; + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ - if(!ot || !ot->srna) - return ""; + if(ot) { + return uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag); + } + else { + ui_item_disabled(layout, opname); + RNA_warning("unknown operator '%s'", opname); + return PointerRNA_NULL; + } +} - RNA_pointer_create(NULL, ot->srna, NULL, &ptr); - prop= RNA_struct_find_property(&ptr, propname); +static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int retval) +{ + EnumPropertyItem *item; + int totitem, free; + const char *name; - if(prop) { - EnumPropertyItem *item; - int totitem, free; - const char *name; + RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item, &totitem, &free); + if (RNA_enum_name(item, retval, &name) == 0) { + name = ""; + } - RNA_property_enum_items_gettexted(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free); - if(RNA_enum_name(item, retval, &name)) { - if (free) { - MEM_freeN(item); - } - return name; - } - - if (free) { - MEM_freeN(item); - } + if (free) { + MEM_freeN(item); } return ""; } -void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value) +/* same as below but 'prop' is already known */ +static void uiItemEnumO_ptr__internal(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, PropertyRNA *prop, int value) { PointerRNA ptr; - - WM_operator_properties_create(&ptr, opname); - RNA_enum_set(&ptr, propname, value); + WM_operator_properties_create_ptr(&ptr, ot); + RNA_property_enum_set(&ptr, prop, value); if(!name) - name= ui_menu_enumpropname(layout, opname, propname, value); + name = ui_menu_enumpropname(layout, &ptr, prop, value); + + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); +} +void uiItemEnumO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, const char *propname, int value) +{ + PointerRNA ptr; + PropertyRNA *prop; + + WM_operator_properties_create_ptr(&ptr, ot); + + if ((prop = RNA_struct_find_property(&ptr, propname))) { + /* pass */ + } + else { + RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname); + return; + } + + RNA_property_enum_set(&ptr, prop, value); + + if(!name) + name = ui_menu_enumpropname(layout, &ptr, prop, value); + + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); +} +void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ + + if(ot) { + uiItemEnumO_ptr(layout, ot, name, icon, propname, value); + } + else { + ui_item_disabled(layout, opname); + RNA_warning("unknown operator '%s'", opname); + } - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, IDProperty *properties, int context, int flag) { - wmOperatorType *ot= WM_operatortype_find(opname, 1); + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ + PointerRNA ptr; PropertyRNA *prop; uiBut *bt; @@ -748,7 +782,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname } RNA_pointer_create(NULL, ot->srna, NULL, &ptr); - prop= RNA_struct_find_property(&ptr, propname); + prop = RNA_struct_find_property(&ptr, propname); /* don't let bad properties slip through */ BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM)); @@ -772,12 +806,13 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname MEM_freeN(tptr.data); } tptr.data= IDP_CopyProperty(properties); - RNA_enum_set(&tptr, propname, item[i].value); + RNA_property_enum_set(&tptr, prop, item[i].value); - uiItemFullO(column, opname, item[i].name, item[i].icon, tptr.data, context, flag); + uiItemFullO_ptr(column, ot, item[i].name, item[i].icon, tptr.data, context, flag); + } + else { + uiItemEnumO_ptr__internal(column, ot, item[i].name, item[i].icon, prop, item[i].value); } - else - uiItemEnumO(column, opname, item[i].name, item[i].icon, propname, item[i].value); } else { if(item[i].name) { @@ -807,18 +842,26 @@ void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0); } +#define UI_OPERATOR_ERROR_RET(_ot, _opname) \ + if (ot == NULL) { \ + ui_item_disabled(layout, _opname); \ + RNA_warning("'%s' unknown operator", _opname); \ + return; \ + } (void)0 + /* for use in cases where we have */ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - - /* for getting the enum */ PropertyRNA *prop; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); /* enum lookup */ - if((prop= RNA_struct_find_property(&ptr, propname))) { + if ((prop = RNA_struct_find_property(&ptr, propname))) { /* pass */ } else { @@ -830,21 +873,23 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char /* same as uiItemEnumO */ if(!name) - name= ui_menu_enumpropname(layout, opname, propname, value); + name = ui_menu_enumpropname(layout, &ptr, prop, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value_str) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - - /* for getting the enum */ PropertyRNA *prop; + EnumPropertyItem *item; int value, free; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); /* enum lookup */ if((prop= RNA_struct_find_property(&ptr, propname))) { @@ -870,49 +915,61 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char /* same as uiItemEnumO */ if(!name) - name= ui_menu_enumpropname(layout, opname, propname, value); + name = ui_menu_enumpropname(layout, &ptr, prop, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); RNA_boolean_set(&ptr, propname, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); RNA_int_set(&ptr, propname, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); RNA_float_set(&ptr, propname, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); RNA_string_set(&ptr, propname, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname) @@ -1548,14 +1605,11 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon) { - wmOperatorType *ot= WM_operatortype_find(opname, 1); + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ MenuItemLevel *lvl; - if(!ot) { - ui_item_disabled(layout, opname); - RNA_warning("unknown operator '%s'", opname); - return; - } + UI_OPERATOR_ERROR_RET(ot, opname); + if(!ot->srna) { ui_item_disabled(layout, opname); RNA_warning("operator missing srna '%s'", opname); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index a0bddda0413..b1c8f8012a5 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -300,7 +300,7 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) uiLayout *layout= uiPupMenuLayout(pup); /* create operator menu item with relevant properties filled in */ - uiItemFullO(layout, op->idname, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + uiItemFullO_ptr(layout, op->type, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); /* present the menu and be done... */ uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 24b2dc9e41c..9df43a85614 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -2069,6 +2069,7 @@ void GRAPH_OT_smooth (wmOperatorType *ot) /* present a special customised popup menu for this, with some filtering */ static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { + wmOperatorType *ot = WM_operatortype_find("GRAPH_OT_fmodifier_add", 1); uiPopupMenu *pup; uiLayout *layout; int i; @@ -2086,7 +2087,7 @@ static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNU continue; /* create operator menu item with relevant properties filled in */ - props_ptr= uiItemFullO(layout, "GRAPH_OT_fmodifier_add", fmi->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO_ptr(layout, ot, fmi->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); /* the only thing that gets set from the menu is the type of F-Modifier to add */ RNA_enum_set(&props_ptr, "type", i); /* the following properties are just repeats of existing ones... */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 7d475973c09..143173da5bc 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1233,7 +1233,10 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point PropertyRNA *prop; const char *layer_name; char scene_name[MAX_ID_NAME-2]; - + wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1); + + BLI_assert(ot != 0); + uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL); if(!node->id) return; @@ -1249,10 +1252,10 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point scn_ptr = RNA_pointer_get(ptr, "scene"); RNA_string_get(&scn_ptr, "name", scene_name); - WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); + WM_operator_properties_create_ptr(&op_ptr, ot); RNA_string_set(&op_ptr, "layer", layer_name); RNA_string_set(&op_ptr, "scene", scene_name); - uiItemFullO(row, "RENDER_OT_render", "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); + uiItemFullO_ptr(row, ot, "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index eab06474546..29583a9356e 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3187,25 +3187,25 @@ static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, wmEvent *UN /* modified locally and externally, ahhh. offer more possibilites. */ pup= uiPupMenuBegin(C, "File Modified Outside and Inside Blender", ICON_NONE); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, op->type->idname, "Reload from disk (ignore local changes)", 0, "resolution", RESOLVE_RELOAD); - uiItemEnumO(layout, op->type->idname, "Save to disk (ignore outside changes)", 0, "resolution", RESOLVE_SAVE); - uiItemEnumO(layout, op->type->idname, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL); + uiItemEnumO_ptr(layout, op->type, "Reload from disk (ignore local changes)", 0, "resolution", RESOLVE_RELOAD); + uiItemEnumO_ptr(layout, op->type, "Save to disk (ignore outside changes)", 0, "resolution", RESOLVE_SAVE); + uiItemEnumO_ptr(layout, op->type, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL); uiPupMenuEnd(C, pup); } else { pup= uiPupMenuBegin(C, "File Modified Outside Blender", ICON_NONE); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, op->type->idname, "Reload from disk", 0, "resolution", RESOLVE_RELOAD); - uiItemEnumO(layout, op->type->idname, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL); - uiItemEnumO(layout, op->type->idname, "Ignore", 0, "resolution", RESOLVE_IGNORE); + uiItemEnumO_ptr(layout, op->type, "Reload from disk", 0, "resolution", RESOLVE_RELOAD); + uiItemEnumO_ptr(layout, op->type, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL); + uiItemEnumO_ptr(layout, op->type, "Ignore", 0, "resolution", RESOLVE_IGNORE); uiPupMenuEnd(C, pup); } break; case 2: pup= uiPupMenuBegin(C, "File Deleted Outside Blender", ICON_NONE); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, op->type->idname, "Make text internal", 0, "resolution", RESOLVE_MAKE_INTERNAL); - uiItemEnumO(layout, op->type->idname, "Recreate file", 0, "resolution", RESOLVE_SAVE); + uiItemEnumO_ptr(layout, op->type, "Make text internal", 0, "resolution", RESOLVE_MAKE_INTERNAL); + uiItemEnumO_ptr(layout, op->type, "Recreate file", 0, "resolution", RESOLVE_SAVE); uiPupMenuEnd(C, pup); break; } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 73322a8292d..a40c6cfa42f 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -58,6 +58,7 @@ #include "UI_resources.h" #include "WM_types.h" +#include "WM_api.h" #include "RNA_access.h" @@ -165,12 +166,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha uiPopupMenu *pup; uiLayout *layout; char line[FILE_MAX + 100]; + wmOperatorType *ot = WM_operatortype_find(opname, 1); pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE); layout= uiPupMenuLayout(pup); strcpy(line, "Remove Pack"); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_REMOVE); RNA_string_set(&props_ptr, "id", id_name); @@ -184,29 +186,29 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha switch(checkPackedFile(local_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), "Create %s", local_name); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_EQUAL: BLI_snprintf(line, sizeof(line), "Use %s (identical)", local_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_DIFFERS: BLI_snprintf(line, sizeof(line), "Use %s (differs)", local_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); BLI_snprintf(line, sizeof(line), "Overwrite %s", local_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; @@ -217,28 +219,28 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha switch(checkPackedFile(abs_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), "Create %s", abs_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_EQUAL: BLI_snprintf(line, sizeof(line), "Use %s (identical)", abs_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_DIFFERS: BLI_snprintf(line, sizeof(line), "Use %s (differs)", abs_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); BLI_snprintf(line, sizeof(line), "Overwrite %s", abs_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 3a3be292f07..7dd2bf7fc51 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -806,7 +806,7 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message pup= uiPupMenuBegin(C, IFACE_("OK?"), ICON_QUESTION); layout= uiPupMenuLayout(pup); - uiItemFullO(layout, op->type->idname, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); + uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); return OPERATOR_CANCELLED; From cfab40b65235a4cf55f74af1da45a9bc4511a3fd Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 22 Jan 2012 03:42:49 +0000 Subject: [PATCH 006/105] Fluidsim - Restoring simulation speed control (ZanQdo request) This commit restores support for freezing or speeding up physics sims. Animate the "Speed" parameter under Domain->Time, which controls a multiplier factor for the rate at which the sim proceeds (i.e. the old "Fac-Tim" setting). Notes: * Subversion bumped to 4 to patch up defaults for new value so that old sim files will still run correctly * Names/descriptions could do with some tweaking * Porting this across was not that obvious since quite a bit of stuff had changed (as in, been cleaned up). However, from tests so far, it seems to work well. --- .../startup/bl_ui/properties_physics_fluid.py | 5 ++ source/blender/blenkernel/BKE_blender.h | 2 +- source/blender/blenloader/intern/readfile.c | 17 +++++ .../blender/editors/physics/physics_fluid.c | 72 +++++++++---------- source/blender/makesdna/DNA_object_fluidsim.h | 4 +- source/blender/makesrna/intern/rna_fluidsim.c | 5 ++ .../modifiers/intern/MOD_fluidsim_util.c | 1 + 7 files changed, 63 insertions(+), 43 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_physics_fluid.py b/release/scripts/startup/bl_ui/properties_physics_fluid.py index 8717a9b9114..114d74f1060 100644 --- a/release/scripts/startup/bl_ui/properties_physics_fluid.py +++ b/release/scripts/startup/bl_ui/properties_physics_fluid.py @@ -79,6 +79,7 @@ class PHYSICS_PT_fluid(PhysicButtonsPanel, Panel): sub = col.column(align=True) sub.prop(fluid, "start_time", text="Start") sub.prop(fluid, "end_time", text="End") + col.prop(fluid, "simulation_rate", text="Speed") col = split.column() col.label() @@ -230,6 +231,10 @@ class PHYSICS_PT_domain_gravity(PhysicButtonsPanel, Panel): if fluid.viscosity_preset == 'MANUAL': sub.prop(fluid, "viscosity_base", text="Base") sub.prop(fluid, "viscosity_exponent", text="Exponent", slider=True) + else: + # just for padding to prevent jumping around + sub.separator() + sub.separator() col.label(text="Optimization:") col.prop(fluid, "grid_levels", slider=True) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index f24687e0fc9..42d9ae73b9a 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 261 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 4 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index fb49f3974b4..28f00f355de 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -13019,6 +13019,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 4)) + { + { + /* set fluidsim rate */ + Object *ob; + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Fluidsim) { + FluidsimSettings *fss = (FluidsimSettings *)md; + fss->animRate = 1.0f; + } + } + } + } + } + /* put compatibility code here until next subversion bump */ { } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index d652d2c0e5c..dbc153de108 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -113,6 +113,18 @@ static float get_fluid_viscosity(FluidsimSettings *settings) } } +static float get_fluid_rate(FluidsimSettings *settings) +{ + float rate = 1.0f; /* default rate if not animated... */ + + rate = settings->animRate; + + if (rate < 0.0f) + rate = 0.0f; + + return rate; +} + static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fss) { if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { @@ -243,7 +255,7 @@ static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *chann channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1 - for(i=2; i<=channels->length; i++) { + for (i=2; i <= channels->length; i++) { channels->timeAtFrame[i] = channels->timeAtFrame[i-1] + channels->aniFrameTime; } } @@ -305,6 +317,8 @@ static void free_domain_channels(FluidAnimChannels *channels) channels->DomainGravity = NULL; MEM_freeN(channels->DomainViscosity); channels->DomainViscosity = NULL; + MEM_freeN(channels->DomainTime); + channels->DomainTime = NULL; } static void free_all_fluidobject_channels(ListBase *fobjects) @@ -351,14 +365,13 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid int length = channels->length; float eval_time; - /* XXX: first init time channel - temporary for now */ - /* init time values (should be done after evaluating animated time curve) */ + /* init time values (assuming that time moves at a constant speed; may be overridden later) */ init_time(domainSettings, channels); /* allocate domain animation channels */ channels->DomainGravity = MEM_callocN( length * (CHANNEL_VEC+1) * sizeof(float), "channel DomainGravity"); channels->DomainViscosity = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainViscosity"); - //channels->DomainTime = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime"); + channels->DomainTime = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime"); /* allocate fluid objects */ for (base=scene->base.first; base; base= base->next) { @@ -406,10 +419,9 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid for (i=0; ilength; i++) { FluidObject *fobj; float viscosity, gravity[3]; - float timeAtFrame; + float timeAtFrame, time; eval_time = domainSettings->bakeStart + i; - timeAtFrame = channels->timeAtFrame[i+1]; /* XXX: This can't be used due to an anim sys optimisation that ignores recalc object animation, * leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ ) @@ -425,12 +437,24 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid /* now scene data should be current according to animation system, so we fill the channels */ - /* Domain properties - gravity/viscosity/time */ + /* Domain time */ + // TODO: have option for not running sim, time mangling, in which case second case comes in handy + if (channels->DomainTime) { + time = get_fluid_rate(domainSettings) * channels->aniFrameTime; + timeAtFrame = channels->timeAtFrame[i] + time; + + channels->timeAtFrame[i+1] = timeAtFrame; + set_channel(channels->DomainTime, i, &time, i, CHANNEL_FLOAT); + } + else { + timeAtFrame = channels->timeAtFrame[i+1]; + } + + /* Domain properties - gravity/viscosity */ get_fluid_gravity(gravity, scene, domainSettings); set_channel(channels->DomainGravity, timeAtFrame, gravity, i, CHANNEL_VEC); viscosity = get_fluid_viscosity(domainSettings); set_channel(channels->DomainViscosity, timeAtFrame, &viscosity, i, CHANNEL_FLOAT); - // XXX : set_channel(channels->DomainTime, timeAtFrame, &time, i, CHANNEL_VEC); /* object movement */ for (fobj=fobjects->first; fobj; fobj=fobj->next) { @@ -957,38 +981,6 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* reset to original current frame */ scene->r.cfra = origFrame; ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1); - - - /* ---- XXX: No Time animation curve for now, leaving this code here for reference - - { int timeIcu[1] = { FLUIDSIM_TIME }; - float timeDef[1] = { 1. }; - - // time channel is a bit special, init by hand... - timeAtIndex = MEM_callocN( (allchannelSize+1)*1*sizeof(float), "fluidsiminit_timeatindex"); - for(i=0; i<=scene->r.efra; i++) { - timeAtIndex[i] = (float)(i-startFrame); - } - fluidsimInitChannel(scene, &channelDomainTime, allchannelSize, timeAtIndex, timeIcu,timeDef, domainSettings->ipo, CHANNEL_FLOAT ); // NDEB - // time channel is a multiplicator for - if(channelDomainTime) { - for(i=0; ianimStart; // start at index 1 - if(channelDomainTime) { - for(i=2; i<=allchannelSize; i++) { - timeAtFrame[i] = timeAtFrame[i-1]+channelDomainTime[(i-1)*2+0]; - } - fsset->} else { - for(i=2; i<=allchannelSize; i++) { timeAtFrame[i] = timeAtFrame[i-1]+aniFrameTime; } - } - - } // domain channel init - */ /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h index 3f87f8a3e9c..90e6e97bc15 100644 --- a/source/blender/makesdna/DNA_object_fluidsim.h +++ b/source/blender/makesdna/DNA_object_fluidsim.h @@ -140,8 +140,8 @@ typedef struct FluidsimSettings { int lastgoodframe; - int pad; - + /* Simulation/flow rate control (i.e. old "Fac-Time") */ + float animRate; } FluidsimSettings; /* ob->fluidsimSettings defines */ diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index f853e7b8dd9..99a84fc8b39 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -340,6 +340,11 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_range(prop, 0.001, 10); RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in metres"); + prop= RNA_def_property(srna, "simulation_rate", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "animRate"); + RNA_def_property_range(prop, 0.0, 100.0); + RNA_def_property_ui_text(prop, "Simulation Speed", "Fluid motion rate (0 = stationary, 1 = normal speed)"); + prop= RNA_def_property(srna, "viscosity_preset", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "viscosityMode"); RNA_def_property_enum_items(prop, viscosity_items); diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 0452c6a4e73..b62a497a10c 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -95,6 +95,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->animStart = 0.0; fss->animEnd = 4.0; + fss->animRate = 1.0; fss->gstar = 0.005; // used as normgstar fss->maxRefine = -1; // maxRefine is set according to resolutionxyz during bake From 85f2256bea549113b352f167137fdc7f4f5300e0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 22 Jan 2012 04:12:30 +0000 Subject: [PATCH 007/105] Bugfix [#29822] Driver's target field doesn't update on Bone rename This only affected non-object drivers, since the renaming was only getting called on object-animdata. --- source/blender/editors/armature/editarmature.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 5df4d42ad96..e8c9a2cf4da 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -5356,7 +5356,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } } } - + /* See if an object is parented to this armature */ if (ob->parent && (ob->parent->data == arm)) { if (ob->partype==PARBONE) { @@ -5385,17 +5385,15 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } } } - - /* Fix animation data attached to this object */ - // TODO: should we be using the database wide version instead (since drivers may break) - if (ob->adt) { - /* posechannels only... */ - BKE_animdata_fix_paths_rename(&ob->id, ob->adt, "pose.bones", oldname, newname, 0, 0, 1); - } } - + + /* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since + * other ID-blocks may have drivers referring to this bone [#29822] + */ + BKE_all_animdata_fix_paths_rename("pose.bones", oldname, newname); + + /* correct view locking */ { - /* correct view locking */ bScreen *screen; for(screen= G.main->screen.first; screen; screen= screen->id.next) { ScrArea *sa; From af9ac97b2ed1a678ff59e221152a712140e2bd08 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Jan 2012 04:30:11 +0000 Subject: [PATCH 008/105] fix for own error in recent paint refactor, subtract mode was broken. --- .../editors/sculpt_paint/paint_vertex.c | 76 +++++++++++-------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index c9a60236d07..941e885c143 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -497,7 +497,7 @@ void vpaint_dogamma(Scene *scene) } */ -static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int mfac; @@ -520,7 +520,7 @@ static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int temp; @@ -543,7 +543,7 @@ static unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int temp; @@ -566,7 +566,7 @@ static unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int mfac; @@ -590,7 +590,7 @@ static unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int mfac; @@ -618,7 +618,7 @@ static unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int mfac; @@ -651,18 +651,12 @@ static unsigned int vpaint_blend_tool(const int tool, const unsigned int col, { switch (tool) { case PAINT_BLEND_MIX: - case PAINT_BLEND_BLUR: - return mcol_blend(col, paintcol, alpha_i); - case PAINT_BLEND_ADD: - return mcol_add(col, paintcol, alpha_i); - case PAINT_BLEND_SUB: - return mcol_sub(col, paintcol, alpha_i); - case PAINT_BLEND_MUL: - return mcol_mul(col, paintcol, alpha_i); - case PAINT_BLEND_LIGHTEN: - return mcol_lighten(col, paintcol, alpha_i); - case PAINT_BLEND_DARKEN: - return mcol_darken(col, paintcol, alpha_i); + case PAINT_BLEND_BLUR: return mcol_blend(col, paintcol, alpha_i); + case PAINT_BLEND_ADD: return mcol_add(col, paintcol, alpha_i); + case PAINT_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i); + case PAINT_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i); + case PAINT_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i); + case PAINT_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i); default: BLI_assert(0); return 0; @@ -797,6 +791,33 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, return 0.0f; } + +BM_INLINE float wval_blend(const float weight, const float paintval, const float alpha) +{ + return (paintval * alpha) + (weight * (1.0f - alpha)); +} +BM_INLINE float wval_add(const float weight, const float paintval, const float alpha) +{ + return weight + (paintval * alpha); +} +BM_INLINE float wval_sub(const float weight, const float paintval, const float alpha) +{ + return weight - (paintval * alpha); +} +BM_INLINE float wval_mul(const float weight, const float paintval, const float alpha) +{ /* first mul, then blend the fac */ + return ((1.0f - alpha) + (alpha * paintval)) * weight; +} +BM_INLINE float wval_lighten(const float weight, const float paintval, const float alpha) +{ + return (weight < paintval) ? wval_blend(weight, paintval, alpha) : weight; +} +BM_INLINE float wval_darken(const float weight, const float paintval, const float alpha) +{ + return (weight > paintval) ? wval_blend(weight, paintval, alpha) : weight; +} + + /* vpaint has 'vpaint_blend_tool' */ /* result is not clamped from [0-1] */ static float wpaint_blend_tool(const int tool, @@ -806,19 +827,12 @@ static float wpaint_blend_tool(const int tool, { switch (tool) { case PAINT_BLEND_MIX: - case PAINT_BLEND_BLUR: - return (paintval * alpha) + (weight * (1.0f - alpha)); - case PAINT_BLEND_ADD: - return (paintval * alpha) + weight; - case PAINT_BLEND_SUB: - return (paintval * alpha) - weight; - case PAINT_BLEND_MUL: - /* first mul, then blend the fac */ - return ((1.0f - alpha) + alpha * paintval) * weight; - case PAINT_BLEND_LIGHTEN: - return (weight < paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight; - case PAINT_BLEND_DARKEN: - return (weight > paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight; + case PAINT_BLEND_BLUR: return wval_blend(weight, paintval, alpha); + case PAINT_BLEND_ADD: return wval_add(weight, paintval, alpha); + case PAINT_BLEND_SUB: return wval_sub(weight, paintval, alpha); + case PAINT_BLEND_MUL: return wval_mul(weight, paintval, alpha); + case PAINT_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha); + case PAINT_BLEND_DARKEN: return wval_darken(weight, paintval, alpha); default: BLI_assert(0); return 0.0f; From 7d13619990dc1fff12a32bee11a9856688948bf4 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 22 Jan 2012 04:30:52 +0000 Subject: [PATCH 009/105] Bugfix [#28468] Cannot enter "Tweak mode" on mutiple objects at the same time, though it initially works Problem was that in the past it was possible to have multiple strips/tracks tagged as "active", but now after getting a correct implementation, we can no longer have that, and thus entering Tweak Mode only works on the last selected strip. However this is problematic in cases when you want to tweak the keyframes of several objects (which may only have a single strip each) in order to get them to line up with each other. This hack caters for this case (selecting multiple strips from the same AnimData block is still impossible and insane/illogical and is not allowed). This may have implications for some future tools which make assumptions about certain aspects of NLA state. However, it shouldn't cause too many problems (hopefully ;) --- source/blender/blenkernel/intern/nla.c | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index fd184b9def4..147f39b6728 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1542,6 +1542,34 @@ short BKE_nla_tweakmode_enter (AnimData *adt) break; } } + + /* There are situations where we may have multiple strips selected and we want to enter tweakmode on all + * of those at once. Usually in those cases, it will usually just be a single strip per AnimData. + * In such cases, compromise and take the last selected track and/or last selected strip [#28468] + */ + if (activeTrack == NULL) { + /* try last selected track for active strip */ + for (nlt = adt->nla_tracks.last; nlt; nlt = nlt->prev) { + if (nlt->flag & NLATRACK_SELECTED) { + /* assume this is the active track */ + activeTrack= nlt; + + /* try to find active strip */ + activeStrip= BKE_nlastrip_find_active(nlt); + break; + } + } + } + if ((activeTrack) && (activeStrip == NULL)) { + /* no active strip in active or last selected track; compromise for first selected (assuming only single)... */ + for (strip = activeTrack->strips.first; strip; strip= strip->next) { + if (strip->flag & (NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE)) { + activeStrip = strip; + break; + } + } + } + if ELEM3(NULL, activeTrack, activeStrip, activeStrip->act) { if (G.f & G_DEBUG) { printf("NLA tweakmode enter - neither active requirement found \n"); From 4ec5a9a42c00d65898e8a4aef5b73409a5e1785f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 22 Jan 2012 04:39:33 +0000 Subject: [PATCH 010/105] Bugfix [#29869] NLA editor keeps resetting my extrapolation mode every time I edit a strip in the timeline Tweaked the behaviour of the overwritting of extrapolation mode so that it is less destructive when the problems it sets out to fix aren't likely to occur (namely a top strip blocking everything below it due to extend backwards). --- source/blender/blenkernel/intern/nla.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 147f39b6728..12f403d028f 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1448,9 +1448,17 @@ void BKE_nla_validate_state (AnimData *adt) */ // TODO: 1 solution is to tie this in with auto-blending... if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) { + /* 1) First strip must be set to extend hold, otherwise, stuff before acts dodgy + * 2) Only overwrite extend mode if *not* changing it will most probably result in + * occlusion problems, which will occur iff + * - blendmode = REPLACE + * - all channels the same (this is fiddly to test, so is currently assumed) + * + * Should fix problems such as [#29869] + */ if (strip == fstrip) strip->extendmode= NLASTRIP_EXTEND_HOLD; - else + else if (strip->blendmode == NLASTRIP_MODE_REPLACE) strip->extendmode= NLASTRIP_EXTEND_HOLD_FORWARD; } } From 57d48d4493a78d2886f83a28fe66c2654bed4f6c Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 22 Jan 2012 05:45:56 +0000 Subject: [PATCH 011/105] Committing patch "[#29763] Adding an active_events property to SCA_PythonKeyboard and SCA_PythonMouse" Here is the description: As the summary says, this patch adds a new event to both SCA_PythonKeyboard and SCA_PythonMouse. This property is similar to the events property that both have, but it only returns events which are not KX_NO_INPUTSTATUS. This moves the "no input" check from Python to C, which gave my input handling code a 2x speed up. Python sucks (performance-wise) with iterating lists and SCA_PythonKeyboard has close to 200 events (I think something like 177, but I don't know for sure). --- doc/python_api/rst/bge.types.rst | 12 ++++++++++++ .../GameLogic/SCA_PythonKeyboard.cpp | 18 ++++++++++++++++++ .../gameengine/GameLogic/SCA_PythonKeyboard.h | 1 + .../gameengine/GameLogic/SCA_PythonMouse.cpp | 17 +++++++++++++++++ source/gameengine/GameLogic/SCA_PythonMouse.h | 1 + 5 files changed, 49 insertions(+) diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index bb3ac004d51..6988f90cc1e 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -66,6 +66,12 @@ Game Types (bge.types) :type: dictionary {:ref:`keycode`::ref:`status`, ...} + .. attribute:: active_events + + A dictionary containing the status of only the active keyboard events or keys. (read-only). + + :type: dictionary {:ref:`keycode`::ref:`status`, ...} + .. class:: SCA_PythonMouse(PyObjectPlus) The current mouse. @@ -75,6 +81,12 @@ Game Types (bge.types) a dictionary containing the status of each mouse event. (read-only). :type: dictionary {:ref:`keycode`::ref:`status`, ...} + + .. attribute:: active_events + + a dictionary containing the status of only the active mouse events. (read-only). + + :type: dictionary {:ref:`keycode`::ref:`status`, ...} .. attribute:: position diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp index 9c7f3831567..46c43b5e339 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp @@ -84,6 +84,7 @@ PyMethodDef SCA_PythonKeyboard::Methods[] = { PyAttributeDef SCA_PythonKeyboard::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_PythonKeyboard, pyattr_get_events), + KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonKeyboard, pyattr_get_active_events), { NULL } //Sentinel }; @@ -101,4 +102,21 @@ PyObject* SCA_PythonKeyboard::pyattr_get_events(void *self_v, const KX_PYATTRIBU return self->m_event_dict; } +PyObject* SCA_PythonKeyboard::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + SCA_PythonKeyboard* self = static_cast(self_v); + + PyDict_Clear(self->m_event_dict); + + for (int i=SCA_IInputDevice::KX_BEGINKEY; i<=SCA_IInputDevice::KX_ENDKEY; i++) + { + const SCA_InputEvent & inevent = self->m_keyboard->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i); + + if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS) + PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status)); + } + Py_INCREF(self->m_event_dict); + return self->m_event_dict; +} + #endif diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.h b/source/gameengine/GameLogic/SCA_PythonKeyboard.h index 7ecf76d1581..f44bb40e13c 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.h +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.h @@ -43,6 +43,7 @@ public: #ifdef WITH_PYTHON static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); #endif }; diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.cpp b/source/gameengine/GameLogic/SCA_PythonMouse.cpp index 4f06445a79f..cdbeaba2235 100644 --- a/source/gameengine/GameLogic/SCA_PythonMouse.cpp +++ b/source/gameengine/GameLogic/SCA_PythonMouse.cpp @@ -86,6 +86,7 @@ PyMethodDef SCA_PythonMouse::Methods[] = { PyAttributeDef SCA_PythonMouse::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("events", SCA_PythonMouse, pyattr_get_events), + KX_PYATTRIBUTE_RO_FUNCTION("active_events", SCA_PythonMouse, pyattr_get_active_events), KX_PYATTRIBUTE_RW_FUNCTION("position", SCA_PythonMouse, pyattr_get_position, pyattr_set_position), KX_PYATTRIBUTE_RW_FUNCTION("visible", SCA_PythonMouse, pyattr_get_visible, pyattr_set_visible), { NULL } //Sentinel @@ -105,6 +106,22 @@ PyObject* SCA_PythonMouse::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_ return self->m_event_dict; } +PyObject* SCA_PythonMouse::pyattr_get_active_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + SCA_PythonMouse* self = static_cast(self_v); + + PyDict_Clear(self->m_event_dict); + + for (int i=SCA_IInputDevice::KX_BEGINMOUSE; i<=SCA_IInputDevice::KX_ENDMOUSE; i++) + { + const SCA_InputEvent & inevent = self->m_mouse->GetEventValue((SCA_IInputDevice::KX_EnumInputs)i); + + if (inevent.m_status != SCA_InputEvent::KX_NO_INPUTSTATUS) + PyDict_SetItem(self->m_event_dict, PyLong_FromSsize_t(i), PyLong_FromSsize_t(inevent.m_status)); + } + Py_INCREF(self->m_event_dict); + return self->m_event_dict; +} PyObject* SCA_PythonMouse::pyattr_get_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { diff --git a/source/gameengine/GameLogic/SCA_PythonMouse.h b/source/gameengine/GameLogic/SCA_PythonMouse.h index 4ad655dce8f..41d286a8048 100644 --- a/source/gameengine/GameLogic/SCA_PythonMouse.h +++ b/source/gameengine/GameLogic/SCA_PythonMouse.h @@ -48,6 +48,7 @@ public: KX_PYMETHOD_DOC(SCA_PythonMouse, show); static PyObject* pyattr_get_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static PyObject* pyattr_get_active_events(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_position(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value); static PyObject* pyattr_get_visible(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef); From d8d2dc552a47d521b1d8c93ce13d5216b31c72f0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 22 Jan 2012 06:10:21 +0000 Subject: [PATCH 012/105] Patch [#28608] Add search match colour to theme settings Submitted by Shane Ambler (sambler) From patch description: As a follow on from #23443 - committed in r40066 I have added the outliner filter match highlight colour to the theme settings. Default colour is a light green matching what was originally hard coded. --- source/blender/editors/include/UI_resources.h | 4 ++- source/blender/editors/interface/resources.c | 25 +++++++++++++++---- .../editors/space_outliner/outliner_draw.c | 10 +++++--- source/blender/makesdna/DNA_userdef_types.h | 3 +++ source/blender/makesrna/intern/rna_userdef.c | 11 ++++++++ 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 6e921a0ca8c..d755b17bc98 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -193,8 +193,10 @@ enum { TH_STITCH_PREVIEW_VERT, TH_STITCH_PREVIEW_STITCHABLE, TH_STITCH_PREVIEW_UNSTITCHABLE, - TH_STITCH_PREVIEW_ACTIVE + TH_STITCH_PREVIEW_ACTIVE, + TH_MATCH, /* highlight color for search matches */ + TH_SELECT_HIGHLIGHT /* highlight color for selected outliner item */ }; /* XXX WARNING: previous is saved in file, so do not change order! */ diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index ad20ff0b6dd..7cc9febc603 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -452,6 +452,14 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp= ts->camera_path; break; case TH_LOCK_MARKER: cp= ts->lock_marker; break; + + case TH_MATCH: + cp= ts->match; + break; + + case TH_SELECT_HIGHLIGHT: + cp= ts->selected_highlight; + break; } } } @@ -792,6 +800,9 @@ void ui_theme_init_default(void) btheme->toops= btheme->tv3d; SETCOLF(btheme->toops.back, 0.45, 0.45, 0.45, 1.0); + SETCOLF(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); /* highlighting search match - soft green*/ + SETCOLF(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3); + /* space info */ btheme->tinfo= btheme->tv3d; SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); @@ -1696,17 +1707,17 @@ void init_userdef_do_versions(void) BLI_addtail(&U.addons, baddon); } } - + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) { bTheme *btheme; - + for(btheme= U.themes.first; btheme; btheme= btheme->next) { SETCOL(btheme->tui.panel.header, 0, 0, 0, 25); btheme->tui.icon_alpha= 1.0; } } - - if (bmain->versionfile < 262){ + + if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 4)) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { SETCOLF(btheme->tima.preview_stitch_face, 0.071, 0.259, 0.694, 0.150); @@ -1715,10 +1726,14 @@ void init_userdef_do_versions(void) SETCOLF(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0); SETCOLF(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0); SETCOLF(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140); + + SETCOLF(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); + SETCOLF(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3); } + U.use_16bit_textures = 0; } - + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index f8abfb6f4c3..0264cf5ad05 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1258,8 +1258,10 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis==SO_DATABLOCKS && soops->search_string[0]!=0)) && (tselem->flag & TSE_SEARCHMATCH)) { - /* TODO - add search highlight color to theme? */ - glColor4f(0.2f, 0.5f, 0.2f, 0.3f); + char col[4]; + UI_GetThemeColorType4ubv(TH_MATCH, SPACE_OUTLINER, col); + col[3]=100; + glColor4ubv((GLubyte *)col); glRecti(startx, *starty+1, ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); } @@ -1513,8 +1515,8 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio } /* always draw selection fill before hierarchy */ - UI_GetThemeColor3fv(TH_BACK, col); - glColor3f(col[0]+0.06f, col[1]+0.08f, col[2]+0.10f); + UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col); + glColor3fv(col); starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 83b8bdcf282..405e1e33720 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -258,6 +258,9 @@ typedef struct ThemeSpace { char preview_stitch_stitchable[4]; char preview_stitch_unstitchable[4]; char preview_stitch_active[4]; + + char match[4]; /* outliner - filter match */ + char selected_highlight[4]; /* outliner - selected item */ } ThemeSpace; diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 24486c227b7..dc4f3449c1b 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1312,6 +1312,7 @@ static void rna_def_userdef_theme_space_file(BlenderRNA *brna) static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; /* space_outliner */ @@ -1321,6 +1322,16 @@ static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Theme Outliner", "Theme settings for the Outliner"); rna_def_userdef_theme_spaces_main(srna); + + prop= RNA_def_property(srna, "match", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Filter Match", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop= RNA_def_property(srna, "selected_highlight", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Selected Highlight", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_theme_space_userpref(BlenderRNA *brna) From c8cff5e1c4a8a5b61f11ee708460c994903f14e7 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 22 Jan 2012 10:14:01 +0000 Subject: [PATCH 013/105] Fix a crasher in WeightVG modifiers. Problem was, if no vertices were ever added to one of the obect's vgroups, there is no CD_DEFORMVERT layer, even though there might be several valid vgroup indices... Odd no one noticed that earlier. Many thanks to miikah for finding that bug! --- source/blender/modifiers/intern/MOD_weightvgedit.c | 11 +++++++++++ source/blender/modifiers/intern/MOD_weightvgmix.c | 11 +++++++++++ .../blender/modifiers/intern/MOD_weightvgproximity.c | 4 ++++ 3 files changed, 26 insertions(+) diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index bdd7ab7486b..e090ad78e59 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -204,6 +204,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der return dm; dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); + /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ + if(!dvert) + /* If this modifier is not allowed to add vertices, just return. */ + if(!do_add) + return dm; + /* Else, add a valid data layer! */ + dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC, + NULL, numVerts, wmd->defgrp_name); + /* Ultimate security check. */ + if(!dvert) + return dm; /* Get org weights, assuming 0.0 for vertices not in given vgroup. */ org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w"); diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 17316d891da..28f9f503966 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -251,6 +251,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der } dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); + /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ + if(!dvert) + /* If not affecting all vertices, just return. */ + if(wmd->mix_set != MOD_WVG_SET_ALL) + return dm; + /* Else, add a valid data layer! */ + dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC, + NULL, numVerts, wmd->defgrp_name_a); + /* Ultimate security check. */ + if(!dvert) + return dm; /* Find out which vertices to work on. */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx"); diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 8e0949f2a22..55b625f7865 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -378,6 +378,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der return dm; dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); + /* If no vertices were ever added to an object's vgroup, dvert might be NULL. + * As this modifier never add vertices to vgroup, just return. */ + if(!dvert) + return dm; /* Find out which vertices to work on (all vertices in vgroup), and get their relevant weight. */ From 98fd7c294881d0452b0c9eeb3e8b3a6b604567d9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 22 Jan 2012 10:20:30 +0000 Subject: [PATCH 014/105] Patch [#27790] Drag and drop parenting in outliner Submitted by Perry Parks (scuey) From the patch: This patch enables drag and drop parenting for objects in the outliner. Drag and drop is supported for a selection of multiple objects as well. Also, all of the "special" parenting tasks (armature, curve, lattice) are possible through the usual parenting context menus. For example, drag a mesh object onto an armature and you are prompted for using bone envelopes, automatic weights, etc. Demonstration on Vimeo: http://vimeo.com/25698606 --- source/blender/editors/include/ED_object.h | 24 ++ .../blender/editors/object/object_relations.c | 117 ++++---- .../editors/space_outliner/outliner_edit.c | 275 ++++++++++++++++++ .../editors/space_outliner/outliner_intern.h | 6 + .../editors/space_outliner/outliner_ops.c | 3 + .../editors/space_outliner/space_outliner.c | 86 ++++++ 6 files changed, 454 insertions(+), 57 deletions(-) diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 51d3c3f021b..f3e780d715e 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -40,6 +40,7 @@ struct bConstraint; struct bContext; struct bPoseChannel; struct Curve; +struct EnumPropertyItem; struct KeyBlock; struct Lattice; struct Main; @@ -64,6 +65,29 @@ void ED_operatortypes_object(void); void ED_operatormacros_object(void); void ED_keymap_object(struct wmKeyConfig *keyconf); +/* object_relations.c */ +typedef enum eParentType { + PAR_OBJECT, + PAR_ARMATURE, + PAR_ARMATURE_NAME, + PAR_ARMATURE_ENVELOPE, + PAR_ARMATURE_AUTO, + PAR_BONE, + PAR_CURVE, + PAR_FOLLOW, + PAR_PATH_CONST, + PAR_LATTICE, + PAR_VERTEX, + PAR_TRIA +} eParentType; + +extern struct EnumPropertyItem prop_clear_parent_types[]; +extern struct EnumPropertyItem prop_make_parent_types[]; + +int ED_object_parent_set(struct bContext *C, struct wmOperator *op, struct Object *par, int partype); +void ED_object_parent_clear(struct bContext *C, int type); + + /* generic editmode keys like pet * do_pet * 0: No diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index b1c8f8012a5..37461377506 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -421,43 +421,47 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot) /********************** Clear Parent Operator ******************* */ -static EnumPropertyItem prop_clear_parent_types[] = { +EnumPropertyItem prop_clear_parent_types[] = { {0, "CLEAR", 0, "Clear Parent", ""}, {1, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation", ""}, {2, "CLEAR_INVERSE", 0, "Clear Parent Inverse", ""}, {0, NULL, 0, NULL, NULL} }; -/* note, poll should check for editable scene */ -static int parent_clear_exec(bContext *C, wmOperator *op) +void ED_object_parent_clear(bContext *C, int type) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - int type= RNA_enum_get(op->ptr, "type"); - - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { if(ob->parent == NULL) continue; if(type == 0) { ob->parent= NULL; - } + } else if(type == 1) { ob->parent= NULL; object_apply_mat4(ob, ob->obmat, TRUE, FALSE); } else if(type == 2) unit_m4(ob->parentinv); - + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } CTX_DATA_END; - + DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); +} + +/* note, poll should check for editable scene */ +static int parent_clear_exec(bContext *C, wmOperator *op) +{ + ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type")); return OPERATOR_FINISHED; } @@ -483,35 +487,6 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) /* ******************** Make Parent Operator *********************** */ -#define PAR_OBJECT 0 -#define PAR_ARMATURE 1 -#define PAR_ARMATURE_NAME 2 -#define PAR_ARMATURE_ENVELOPE 3 -#define PAR_ARMATURE_AUTO 4 -#define PAR_BONE 5 -#define PAR_CURVE 6 -#define PAR_FOLLOW 7 -#define PAR_PATH_CONST 8 -#define PAR_LATTICE 9 -#define PAR_VERTEX 10 -#define PAR_TRIA 11 - -static EnumPropertyItem prop_make_parent_types[] = { - {PAR_OBJECT, "OBJECT", 0, "Object", ""}, - {PAR_ARMATURE, "ARMATURE", 0, "Armature Deform", ""}, - {PAR_ARMATURE_NAME, "ARMATURE_NAME", 0, " With Empty Groups", ""}, - {PAR_ARMATURE_AUTO, "ARMATURE_AUTO", 0, " With Automatic Weights", ""}, - {PAR_ARMATURE_ENVELOPE, "ARMATURE_ENVELOPE", 0, " With Envelope Weights", ""}, - {PAR_BONE, "BONE", 0, "Bone", ""}, - {PAR_CURVE, "CURVE", 0, "Curve Deform", ""}, - {PAR_FOLLOW, "FOLLOW", 0, "Follow Path", ""}, - {PAR_PATH_CONST, "PATH_CONST", 0, "Path Constraint", ""}, - {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""}, - {PAR_VERTEX, "VERTEX", 0, "Vertex", ""}, - {PAR_TRIA, "TRIA", 0, "Triangle", ""}, - {0, NULL, 0, NULL, NULL} -}; - void ED_object_parent(Object *ob, Object *par, int type, const char *substr) { if (!par || BKE_object_parent_loop_check(par, ob)) { @@ -529,13 +504,28 @@ void ED_object_parent(Object *ob, Object *par, int type, const char *substr) BLI_strncpy(ob->parsubstr, substr, sizeof(ob->parsubstr)); } -static int parent_set_exec(bContext *C, wmOperator *op) +/* Operator Property */ +EnumPropertyItem prop_make_parent_types[] = { + {PAR_OBJECT, "OBJECT", 0, "Object", ""}, + {PAR_ARMATURE, "ARMATURE", 0, "Armature Deform", ""}, + {PAR_ARMATURE_NAME, "ARMATURE_NAME", 0, " With Empty Groups", ""}, + {PAR_ARMATURE_AUTO, "ARMATURE_AUTO", 0, " With Automatic Weights", ""}, + {PAR_ARMATURE_ENVELOPE, "ARMATURE_ENVELOPE", 0, " With Envelope Weights", ""}, + {PAR_BONE, "BONE", 0, "Bone", ""}, + {PAR_CURVE, "CURVE", 0, "Curve Deform", ""}, + {PAR_FOLLOW, "FOLLOW", 0, "Follow Path", ""}, + {PAR_PATH_CONST, "PATH_CONST", 0, "Path Constraint", ""}, + {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""}, + {PAR_VERTEX, "VERTEX", 0, "Vertex", ""}, + {PAR_TRIA, "TRIA", 0, "Triangle", ""}, + {0, NULL, 0, NULL, NULL} +}; + +int ED_object_parent_set(bContext *C, wmOperator *op, Object *par, int partype) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - Object *par= ED_object_active_context(C); bPoseChannel *pchan= NULL; - int partype= RNA_enum_get(op->ptr, "type"); int pararm= ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); par->recalc |= OB_RECALC_OB; @@ -543,7 +533,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) /* preconditions */ if(partype==PAR_FOLLOW || partype==PAR_PATH_CONST) { if(par->type!=OB_CURVE) - return OPERATOR_CANCELLED; + return 0; else { Curve *cu= par->data; @@ -574,15 +564,14 @@ static int parent_set_exec(bContext *C, wmOperator *op) if(pchan==NULL) { BKE_report(op->reports, RPT_ERROR, "No active Bone"); - return OPERATOR_CANCELLED; + return 0; } } /* context iterator */ - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - - if(ob!=par) { - + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { + if (ob!=par) { if (BKE_object_parent_loop_check(par, ob)) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); } @@ -591,10 +580,11 @@ static int parent_set_exec(bContext *C, wmOperator *op) /* apply transformation of previous parenting */ /* object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ - + /* set the parent (except for follow-path constraint option) */ - if(partype != PAR_PATH_CONST) + if (partype != PAR_PATH_CONST) { ob->parent= par; + } /* handle types */ if (pchan) @@ -602,9 +592,10 @@ static int parent_set_exec(bContext *C, wmOperator *op) else ob->parsubstr[0]= 0; - if(partype == PAR_PATH_CONST) - ; /* don't do anything here, since this is not technically "parenting" */ - else if( ELEM(partype, PAR_CURVE, PAR_LATTICE) || pararm ) + if (partype == PAR_PATH_CONST) { + /* don't do anything here, since this is not technically "parenting" */ + } + else if (ELEM(partype, PAR_CURVE, PAR_LATTICE) || (pararm)) { /* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers @@ -614,10 +605,10 @@ static int parent_set_exec(bContext *C, wmOperator *op) /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */ // XXX currently this should only happen for meshes, curves, surfaces, and lattices - this stuff isn't available for metas yet - if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) + if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { ModifierData *md; - + switch (partype) { case PAR_CURVE: /* curve deform */ md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Curve); @@ -684,15 +675,27 @@ static int parent_set_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); - - return OPERATOR_FINISHED; + + return 1; } +static int parent_set_exec(bContext *C, wmOperator *op) +{ + Object *par= ED_object_active_context(C); + int partype= RNA_enum_get(op->ptr, "type"); + + if(ED_object_parent_set(C, op, par, partype)) + return OPERATOR_FINISHED; + else + return OPERATOR_CANCELLED; +} + + static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { Object *ob= ED_object_active_context(C); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 0ccbf9127c6..12f4af3637e 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1429,3 +1429,278 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } + +/* ******************** Parent Drop Operator *********************** */ + +static int parent_drop_exec(bContext *C, wmOperator *op) +{ + Object *par = NULL; + int partype = -1; + char parname[32]; + + partype= RNA_enum_get(op->ptr, "type"); + RNA_string_get(op->ptr, "parent", parname); + par= (Object *)find_id("OB", parname); + + ED_object_parent_set(C, op, par, partype); + + return OPERATOR_FINISHED; +} + +/* Used for drag and drop parenting */ +TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement *te, float *fmval) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeStoreElem *tselem= TREESTORE(te); + + if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { + /* name and first icon */ + if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { + /* always makes active object */ + if (te->idcode == ID_OB) { + return te; + } + else { + return NULL; + } + } + } + + /* Not it. Let's look at its children. */ + if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + for (te = te->subtree.first; te; te = te->next) { + TreeElement *te_valid; + te_valid= outliner_dropzone_parent(C, event, te, fmval); + if (te_valid) return te_valid; + } + } + return NULL; +} + +static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Object *par= NULL; + Object *ob= NULL; + SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar= CTX_wm_region(C); + Scene *scene= CTX_data_scene(C); + TreeElement *te= NULL; + TreeElement *te_found= NULL; + char childname[MAX_ID_NAME]; + char parname[MAX_ID_NAME]; + int partype= 0; + float fmval[2]; + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + /* Find object hovered over */ + for (te= soops->tree.first; te; te= te->next) { + te_found= outliner_dropzone_parent(C, event, te, fmval); + if (te_found) break; + } + + if(te_found) { + RNA_string_set(op->ptr, "parent", te_found->name); + /* Identify parent and child */ + RNA_string_get(op->ptr, "child", childname); + ob= (Object *)find_id("OB", childname); + RNA_string_get(op->ptr, "parent", parname); + par= (Object *)find_id("OB", parname); + + if (ELEM(NULL, ob, par)) { + if (par == NULL) printf("par==NULL\n"); + return OPERATOR_CANCELLED; + } + if (ob == par) { + return OPERATOR_CANCELLED; + } + + /* check dragged object (child) is active */ + if (ob != CTX_data_active_object(C)) + ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + + if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { + ED_object_parent_set(C, op, par, partype); + } + else { + /* Menu creation */ + uiPopupMenu *pup= uiPupMenuBegin(C, "Set Parent To", ICON_NONE); + uiLayout *layout= uiPupMenuLayout(pup); + + PointerRNA ptr; + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_OBJECT); + /* Cannot use uiItemEnumO()... have multiple properties to set. */ + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Object", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + /* par becomes parent, make the associated menus */ + if (par->type==OB_ARMATURE) { + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_ARMATURE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Armature Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_ARMATURE_NAME); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Empty Groups", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_ARMATURE_ENVELOPE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Envelope Weights", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_ARMATURE_AUTO); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Automatic Weights", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_BONE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Bone", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + } + else if (par->type==OB_CURVE) { + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_CURVE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Curve Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_FOLLOW); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Follow Path", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_PATH_CONST); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Path Constraint", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + } + else if (par->type == OB_LATTICE) { + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_LATTICE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Lattice Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + } + + uiPupMenuEnd(C, pup); + + return OPERATOR_CANCELLED; + } + } + else { + return OPERATOR_CANCELLED; + } + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_parent_drop(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Drop to Set Parent"; + ot->description = "Drag to parent in Outliner"; + ot->idname= "OUTLINER_OT_parent_drop"; + + /* api callbacks */ + ot->invoke= parent_drop_invoke; + ot->exec= parent_drop_exec; + + ot->poll= ED_operator_outliner_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "child", "Object", MAX_ID_NAME, "Child", "Child Object"); + RNA_def_string(ot->srna, "parent", "Object", MAX_ID_NAME, "Parent", "Parent Object"); + RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", ""); +} + +int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, float *fmval) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeStoreElem *tselem= TREESTORE(te); + + /* Check for row */ + if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { + /* Ignore drop on scene tree elements */ + if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { + if ((te->idcode == ID_SCE) && + !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) + { + return 0; + } + // Other codes to ignore? + } + + /* Left or right of: (+), first icon, and name */ + if ((fmval[0] < (te->xs + UI_UNIT_X)) || (fmval[0] > te->xend)) { + return 1; + } + else if (te->idcode != ID_OB) { + return 1; + } + + return 0; // ID_OB, but mouse in undefined dropzone. + } + + /* Not this row. Let's look at its children. */ + if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + for (te = te->subtree.first; te; te = te->next) { + if (outliner_dropzone_parent_clear(C, event, te, fmval)) + return 1; + } + } + return 0; +} + +static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= NULL; + char obname[MAX_ID_NAME]; + + RNA_string_get(op->ptr, "dragged_obj", obname); + ob= (Object *)find_id("OB", obname); + + /* check dragged object (child) is active */ + if (ob != CTX_data_active_object(C)) + ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + + ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type")); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_parent_clear(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Drop to Clear Parent"; + ot->description = "Drag to clear parent in outliner"; + ot->idname= "OUTLINER_OT_parent_clear"; + + /* api callbacks */ + ot->invoke= parent_clear_invoke; + + ot->poll= ED_operator_outliner_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "dragged_obj", "Object", MAX_ID_NAME, "Child", "Child Object"); + RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", ""); +} diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 3b6b4334880..be33fc2e37a 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -188,6 +188,9 @@ void group_toggle_renderability_cb(struct bContext *C, struct Scene *scene, Tree void item_rename_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); +TreeElement *outliner_dropzone_parent(struct bContext *C, struct wmEvent *event, struct TreeElement *te, float *fmval); +int outliner_dropzone_parent_clear(struct bContext *C, struct wmEvent *event, struct TreeElement *te, float *fmval); + /* ...................................................... */ void OUTLINER_OT_item_activate(struct wmOperatorType *ot); @@ -215,6 +218,9 @@ void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot); void OUTLINER_OT_drivers_add_selected(struct wmOperatorType *ot); void OUTLINER_OT_drivers_delete_selected(struct wmOperatorType *ot); +void OUTLINER_OT_parent_drop(struct wmOperatorType *ot); +void OUTLINER_OT_parent_clear(struct wmOperatorType *ot); + /* outliner_tools.c ---------------------------------------------- */ void OUTLINER_OT_operation(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 0de26cece93..17434d0f6c9 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -77,6 +77,9 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_drivers_add_selected); WM_operatortype_append(OUTLINER_OT_drivers_delete_selected); + + WM_operatortype_append(OUTLINER_OT_parent_drop); + WM_operatortype_append(OUTLINER_OT_parent_clear); } void outliner_keymap(wmKeyConfig *keyconf) diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 673ddaebc5f..5b20c170362 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -50,6 +50,8 @@ #include "BIF_gl.h" +#include "RNA_access.h" + #include "UI_resources.h" #include "UI_view2d.h" @@ -58,6 +60,7 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) { + ListBase *lb; wmKeyMap *keymap; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); @@ -66,6 +69,88 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) keymap= WM_keymap_find(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0); /* don't pass on view2d mask, it's always set with scrollbar space, hide fails */ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, &ar->winrct); + + /* Add dropboxes */ + lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW); + WM_event_add_dropbox_handler(&ar->handlers, lb); +} + +static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeElement *te= NULL; + float fmval[2]; + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + if(drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if( GS(id->name) == ID_OB ) { + /* Ensure item under cursor is valid drop target */ + /* Find object hovered over */ + for(te= soops->tree.first; te; te= te->next) { + TreeElement *te_valid; + te_valid= outliner_dropzone_parent(C, event, te, fmval); + if(te_valid) return 1; + } + } + } + return 0; +} + +static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id = (ID *)drag->poin; + + RNA_string_set(drop->ptr, "child", id->name+2); +} + +static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeElement *te= NULL; + float fmval[2]; + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + if(drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if( GS(id->name) == ID_OB ) { + //TODO: Check if no parent? + /* Ensure location under cursor is valid dropzone */ + for(te= soops->tree.first; te; te= te->next) { + if(outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; + } + /* Check if mouse cursor is below the tree */ + te= soops->tree.last; + while(((te->flag & TE_LAZY_CLOSED)==0) && (te->subtree.last)) { + te= te->subtree.last; + } + if(fmval[1] < te->ys) return 1; + } + } + return 0; +} + +static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id = (ID *)drag->poin; + RNA_string_set(drop->ptr, "dragged_obj", id->name+2); + + /* Set to simple parent clear type. Avoid menus for drag and drop if possible. + If desired, user can toggle the different "Clear Parent" types in the operator + menu on tool shelf. */ + RNA_string_set(drop->ptr, "type", 0); +} + +/* region dropbox definition */ +static void outliner_dropboxes(void) +{ + ListBase *lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW); + + WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", outliner_parent_drop_poll, outliner_parent_drop_copy); + WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", outliner_parent_clear_poll, outliner_parent_clear_copy); } static void outliner_main_area_draw(const bContext *C, ARegion *ar) @@ -302,6 +387,7 @@ void ED_spacetype_outliner(void) st->duplicate= outliner_duplicate; st->operatortypes= outliner_operatortypes; st->keymap= outliner_keymap; + st->dropboxes= outliner_dropboxes; /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); From 6e5c763e9b2730327e737593a63081f49255aff5 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 22 Jan 2012 11:59:30 +0000 Subject: [PATCH 015/105] Bugfix for r.43592 A typo (?) meant that enum menus, such as the Set Parent (Ctrl P) menu would get shown with empty string labels. --- source/blender/editors/interface/interface_layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 20b5bc54661..b40c618c301 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -715,7 +715,7 @@ static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, Prope MEM_freeN(item); } - return ""; + return name; } /* same as below but 'prop' is already known */ From 3fa4b6ea7d932d5be9abbf306bbaf342d20c519f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 22 Jan 2012 13:26:59 +0000 Subject: [PATCH 016/105] Fix missing shadows with cycles world sample as lamp option, my mistake in tweaking patch. --- intern/cycles/render/light.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index eea5cfb0137..777e764558f 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -431,7 +431,7 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce shader_id &= ~SHADER_AREA_LIGHT; light_data[i*LIGHT_SIZE + 0] = make_float4(__int_as_float(light->type), 0.0f, 0.0f, 0.0f); - light_data[i*LIGHT_SIZE + 1] = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + light_data[i*LIGHT_SIZE + 1] = make_float4(__int_as_float(shader_id), 0.0f, 0.0f, 0.0f); light_data[i*LIGHT_SIZE + 2] = make_float4(0.0f, 0.0f, 0.0f, 0.0f); light_data[i*LIGHT_SIZE + 3] = make_float4(0.0f, 0.0f, 0.0f, 0.0f); } From 27e94f7cbe21c43899d9f889c1e1078ca1df7d8c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 22 Jan 2012 13:56:39 +0000 Subject: [PATCH 017/105] Fix #29935: missing cycles update/crash when removing world datablock form scene. --- intern/cycles/blender/blender_object.cpp | 32 +++++++++++---------- source/blender/makesrna/intern/rna_scene.c | 2 +- source/blender/quicktime/quicktime_export.h | 3 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index bc7868e0192..c805bd03063 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -159,24 +159,26 @@ void BlenderSync::sync_background_light() { BL::World b_world = b_scene.world(); - PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles"); - bool sample_as_light = get_boolean(cworld, "sample_as_light"); + if(b_world) { + PointerRNA cworld = RNA_pointer_get(&b_world.ptr, "cycles"); + bool sample_as_light = get_boolean(cworld, "sample_as_light"); - if(sample_as_light) { - /* test if we need to sync */ - Light *light; - ObjectKey key(b_world, 0, b_world); + if(sample_as_light) { + /* test if we need to sync */ + Light *light; + ObjectKey key(b_world, 0, b_world); - if(light_map.sync(&light, b_world, b_world, key) || - world_recalc || - b_world.ptr.data != world_map) - { - light->type = LIGHT_BACKGROUND; - light->map_resolution = get_int(cworld, "sample_map_resolution"); - light->shader = scene->default_background; + if(light_map.sync(&light, b_world, b_world, key) || + world_recalc || + b_world.ptr.data != world_map) + { + light->type = LIGHT_BACKGROUND; + light->map_resolution = get_int(cworld, "sample_map_resolution"); + light->shader = scene->default_background; - light->tag_update(scene); - light_map.set_recalc(b_world); + light->tag_update(scene); + light_map.set_recalc(b_world); + } } } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 7f01a9387b5..83c82cdeb5b 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3957,7 +3957,7 @@ void RNA_def_scene(BlenderRNA *brna) prop= RNA_def_property(srna, "world", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "World", "World used for rendering the scene"); - RNA_def_property_update(prop, NC_SCENE|ND_WORLD, NULL); + RNA_def_property_update(prop, NC_SCENE|ND_WORLD, "rna_Scene_glsl_update"); prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH); RNA_def_property_float_sdna(prop, NULL, "cursor"); diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h index f64521bda35..71827b1e202 100644 --- a/source/blender/quicktime/quicktime_export.h +++ b/source/blender/quicktime/quicktime_export.h @@ -50,10 +50,11 @@ typedef struct QuicktimeCodecTypeDesc { } QuicktimeCodecTypeDesc ; // quicktime movie output functions +struct ImageFormatData; struct RenderData; +struct ReportList; struct Scene; struct wmOperatorType; -struct ReportList; int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); //for movie handle (BKE writeavi.c now) int append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int recty, struct ReportList *reports); From 39aaf4f2f0af3e0663a19381d65081a9090fc10e Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 22 Jan 2012 16:29:10 +0000 Subject: [PATCH 018/105] Fix for the Sculpt UI (revert part of 43535 by nicholasbishop) * Such labels like for "use_space_atten" should not be in the UI, thats too overkill. Toolbar is meant to be small in size. --- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index ff482e7cb74..aa7cec0c01a 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -526,9 +526,9 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): if brush.use_space and tool != 'SMOOTH': if brush.use_space_atten: - row.prop(brush, "use_space_atten", toggle=True, icon='LOCKED') + row.prop(brush, "use_space_atten", toggle=True, text="", icon='LOCKED') else: - row.prop(brush, "use_space_atten", toggle=True, icon='UNLOCKED') + row.prop(brush, "use_space_atten", toggle=True, text="", icon='UNLOCKED') self.prop_unified_strength(row, context, brush, "strength", text="Strength") self.prop_unified_strength(row, context, brush, "use_pressure_strength") From cd4123e1db8a40836fa04813ef7dc440ef7feeb0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Jan 2012 17:20:37 +0000 Subject: [PATCH 019/105] use inline BLI_math functions for dot product and length calculation. --- source/blender/blenkernel/BKE_armature.h | 2 +- source/blender/blenkernel/intern/armature.c | 18 +++++------ source/blender/blenlib/intern/BLI_kdtree.c | 9 +++--- source/blender/blenlib/intern/math_geom.c | 3 +- source/blender/blenlib/intern/noise.c | 4 --- source/blender/editors/object/object_vgroup.c | 4 +-- .../editors/space_view3d/view3d_edit.c | 2 +- .../render/intern/source/convertblender.c | 30 +++++++++---------- .../blender/render/intern/source/occlusion.c | 2 +- .../render/intern/source/pixelshading.c | 6 ++-- .../blender/render/intern/source/rayshade.c | 14 ++++----- source/blender/render/intern/source/shadbuf.c | 4 +-- .../blender/render/intern/source/shadeinput.c | 4 +-- .../blender/render/intern/source/volumetric.c | 2 +- 14 files changed, 50 insertions(+), 54 deletions(-) diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index a89bfbd50b1..11ab981822e 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -86,7 +86,7 @@ int bone_autoside_name (char name[64], int strip_number, short axis, float head, struct Bone *get_named_bone (struct bArmature *arm, const char *name); -float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist); +float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist); void where_is_armature (struct bArmature *arm); void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 4f83bcf7e7f..64ea862477f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -665,7 +665,7 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float *co, Dua } /* using vec with dist to bone b1 - b2 */ -float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist) +float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist) { float dist=0.0f; float bdelta[3]; @@ -677,18 +677,18 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl sub_v3_v3v3(pdelta, vec, b1); - a = bdelta[0]*pdelta[0] + bdelta[1]*pdelta[1] + bdelta[2]*pdelta[2]; - hsqr = ((pdelta[0]*pdelta[0]) + (pdelta[1]*pdelta[1]) + (pdelta[2]*pdelta[2])); + a = dot_v3v3(bdelta, pdelta); + hsqr = dot_v3v3(pdelta, pdelta); - if (a < 0.0F){ + if (a < 0.0f) { /* If we're past the end of the bone, do a spherical field attenuation thing */ - dist= ((b1[0]-vec[0])*(b1[0]-vec[0]) +(b1[1]-vec[1])*(b1[1]-vec[1]) +(b1[2]-vec[2])*(b1[2]-vec[2])) ; + dist = len_squared_v3v3(b1, vec); rad= rad1; } - else if (a > l){ + else if (a > l) { /* If we're past the end of the bone, do a spherical field attenuation thing */ - dist= ((b2[0]-vec[0])*(b2[0]-vec[0]) +(b2[1]-vec[1])*(b2[1]-vec[1]) +(b2[2]-vec[2])*(b2[2]-vec[2])) ; - rad= rad2; + dist = len_squared_v3v3(b2, vec); + rad = rad2; } else { dist= (hsqr - (a*a)); @@ -709,7 +709,7 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl if(rdist==0.0f || dist >= l) return 0.0f; else { - a= (float)sqrt(dist)-rad; + a = sqrtf(dist)-rad; return 1.0f-( a*a )/( rdist*rdist ); } } diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 3543b847f19..d5f66c0e75f 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -132,19 +132,18 @@ void BLI_kdtree_balance(KDTree *tree) tree->root= kdtree_balance(tree->nodes, tree->totnode, 0); } -static float squared_distance(float *v2, float *v1, float *n1, float *n2) +static float squared_distance(float *v2, float *v1, float *UNUSED(n1), float *n2) { float d[3], dist; - (void)n1; /* unused */ d[0]= v2[0]-v1[0]; d[1]= v2[1]-v1[1]; d[2]= v2[2]-v1[2]; - dist= d[0]*d[0] + d[1]*d[1] + d[2]*d[2]; + dist = dot_v3v3(d, d); - //if(n1 && n2 && n1[0]*n2[0] + n1[1]*n2[1] + n1[2]*n2[2] < 0.0f) - if(n2 && d[0]*n2[0] + d[1]*n2[1] + d[2]*n2[2] < 0.0f) + //if(n1 && n2 && (dot_v3v3(n1, n2) < 0.0f)) + if(n2 && (dot_v3v3(d, n2) < 0.0f)) dist *= 10.0f; return dist; diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d7880e40626..500e27064d7 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2485,8 +2485,9 @@ void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], flo cross_v3_v3v3(ct, tang, tangv); /* check flip */ - if ((ct[0]*n[0] + ct[1]*n[1] + ct[2]*n[2]) < 0.0f) + if (dot_v3v3(ct, n) < 0.0f) { negate_v3(tang); + } } else { tang[0]= tang[1]= tang[2]= 0.0; diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index e1a08de0dd8..b3cb2856383 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -919,10 +919,6 @@ static float g[512+2][3]= { {-0.944031, -0.326599, -0.045624}, }; - - -#define DOT(a,b) (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]) - #define setup(i,b0,b1,r0,r1) \ t = vec[i] + 10000.0f; \ b0 = ((int)t) & 255; \ diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index f91740f4b47..7fe98a604ec 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -870,7 +870,7 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f closest_to_plane_v3(projB, coord, norm, end); // (vertical and horizontal refer to the plane's y and xz respectively) // vertical distance - dists[index] = norm[0]*end[0] + norm[1]*end[1] + norm[2]*end[2] + d; + dists[index] = dot_v3v3(norm, end) + d; // vertical change changes[index][0] = dists[index] - distToStart; //printf("vc %f %f\n", distance(end, projB, 3)-distance(start, projA, 3), changes[index][0]); @@ -1111,7 +1111,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, mag= normalize_v3(norm); if(mag) { /* zeros fix */ d = -dot_v3v3(norm, coord); - /* dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d); */ /* UNUSED */ + /* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */ moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp); } } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 2620fe4ac71..f617f673397 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -634,7 +634,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) sub_v3_v3v3(dvec, newvec, vod->trackvec); - si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]); + si = len_v3(dvec); si /= (float)(2.0 * TRACKBALLSIZE); cross_v3_v3v3(q1+1, vod->trackvec, newvec); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 1ec400138a7..fa8540b352d 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -671,7 +671,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen float *tav= RE_vertren_get_tangent(obr, ver, 0); if (tav) { /* orthonorm. */ - float tdn = tav[0]*ver->n[0] + tav[1]*ver->n[1] + tav[2]*ver->n[2]; + const float tdn = dot_v3v3(tav, ver->n); tav[0] -= ver->n[0]*tdn; tav[1] -= ver->n[1]*tdn; tav[2] -= ver->n[2]*tdn; @@ -767,7 +767,7 @@ static int as_testvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, float while(asf) { for(a=0; a<4; a++) { if(asf->vlr[a] && asf->vlr[a]!=vlr) { - inp= fabs( vlr->n[0]*asf->vlr[a]->n[0] + vlr->n[1]*asf->vlr[a]->n[1] + vlr->n[2]*asf->vlr[a]->n[2] ); + inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); if(inp < thresh) return 1; } } @@ -790,7 +790,7 @@ static VertRen *as_findvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, f if(asf->vlr[a] && asf->vlr[a]!=vlr) { /* this face already made a copy for this vertex! */ if(asf->nver[a]) { - inp= fabs( vlr->n[0]*asf->vlr[a]->n[0] + vlr->n[1]*asf->vlr[a]->n[1] + vlr->n[2]*asf->vlr[a]->n[2] ); + inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); if(inp >= thresh) { return asf->nver[a]; } @@ -2158,7 +2158,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int copy_v3_v3(view, vec); normalize_v3(view); - zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2]; + zn = dot_v3v3(nor, view); if(zn>=0.0f) hasize= 0.0f; else hasize*= zn*zn*zn*zn; } @@ -2240,9 +2240,9 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve mul_m4_v3(mat, shi->co); if(imat) { - shi->vn[0]= imat[0][0]*vr->n[0]+imat[0][1]*vr->n[1]+imat[0][2]*vr->n[2]; - shi->vn[1]= imat[1][0]*vr->n[0]+imat[1][1]*vr->n[1]+imat[1][2]*vr->n[2]; - shi->vn[2]= imat[2][0]*vr->n[0]+imat[2][1]*vr->n[1]+imat[2][2]*vr->n[2]; + shi->vn[0] = dot_v3v3(imat[0], vr->n); + shi->vn[1] = dot_v3v3(imat[1], vr->n); + shi->vn[2] = dot_v3v3(imat[2], vr->n); } if (texco & TEXCO_UV) { @@ -4241,7 +4241,7 @@ static void check_non_flat_quads(ObjectRen *obr) flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co); if(flen==0.0f) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co); - xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2]; + xn = dot_v3v3(nor, vlr->n); if(ABS(xn) < 0.999995f ) { // checked on noisy fractal grid @@ -4252,11 +4252,11 @@ static void check_non_flat_quads(ObjectRen *obr) /* split direction based on vnorms */ normal_tri_v3( nor,vlr->v1->co, vlr->v2->co, vlr->v3->co); - d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2]; + d1 = dot_v3v3(nor, vlr->v1->n); normal_tri_v3( nor,vlr->v2->co, vlr->v3->co, vlr->v4->co); - d2= nor[0]*vlr->v2->n[0] + nor[1]*vlr->v2->n[1] + nor[2]*vlr->v2->n[2]; - + d2 = dot_v3v3(nor, vlr->v2->n); + if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; else vlr->flag &= ~R_DIVIDE_24; @@ -5267,7 +5267,7 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con if(vec[0]<0.0f) ang= -ang; zco[0]= ang/pixelphix + zmulx; - ang= 0.5f*(float)M_PI - saacos(vec[1]/sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])); + ang= 0.5f*(float)M_PI - saacos(vec[1] / len_v3(vec)); zco[1]= ang/pixelphiy + zmuly; } @@ -5487,9 +5487,9 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * } // transform (=rotate) to cam space - camco[0]= imat[0][0]*fsvec[0] + imat[0][1]*fsvec[1] + imat[0][2]*fsvec[2]; - camco[1]= imat[1][0]*fsvec[0] + imat[1][1]*fsvec[1] + imat[1][2]*fsvec[2]; - camco[2]= imat[2][0]*fsvec[0] + imat[2][1]*fsvec[1] + imat[2][2]*fsvec[2]; + camco[0] = dot_v3v3(imat[0], fsvec); + camco[1] = dot_v3v3(imat[1], fsvec); + camco[2] = dot_v3v3(imat[2], fsvec); // get homogenous coordinates projectvert(camco, winmat, hoco); diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index e20fd85d0f0..782e0b59388 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -1413,7 +1413,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f if(env) { /* sky shading using bent normal */ if(ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { - fac= 0.5f*(1.0f+bn[0]*re->grvec[0]+ bn[1]*re->grvec[1]+ bn[2]*re->grvec[2]); + fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); env[0]= (1.0f-fac)*re->wrld.horr + fac*re->wrld.zenr; env[1]= (1.0f-fac)*re->wrld.horg + fac*re->wrld.zeng; env[2]= (1.0f-fac)*re->wrld.horb + fac*re->wrld.zenb; diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index f261ec41746..24683ec57f7 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -104,7 +104,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) lv[0]= rco[0]-lar->co[0]; lv[1]= rco[1]-lar->co[1]; lv[2]= rco[2]-lar->co[2]; - ld= sqrt(lv[0]*lv[0]+lv[1]*lv[1]+lv[2]*lv[2]); + ld = len_v3(lv); lv[0]/= ld; lv[1]/= ld; lv[2]/= ld; @@ -210,7 +210,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) /* dot product and reflectivity*/ - inp= 1.0-fabs(vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2]); + inp = 1.0 - fabs(dot_v3v3(vn, lv)); /* inp= cos(0.5*M_PI-acos(inp)); */ @@ -511,7 +511,7 @@ void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const /* Some view vector stuff. */ if(R.wrld.skytype & WO_SKYREAL) { - blend= view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]; + blend = dot_v3v3(view, R.grvec); if(blend<0.0f) skyflag= 0; diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index f9ffc2532eb..6c0386cc8b1 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -471,7 +471,7 @@ void makeraytree(Render *re) sub[i] = max[i]-min[i]; } - re->maxdist= sub[0]*sub[0] + sub[1]*sub[1] + sub[2]*sub[2]; + re->maxdist = dot_v3v3(sub, sub); if(re->maxdist > 0.0f) re->maxdist= sqrt(re->maxdist); re->i.infostr= "Raytree finished"; @@ -598,7 +598,7 @@ static int refraction(float refract[3], const float n[3], const float view[3], f copy_v3_v3(refract, view); - dot= view[0]*n[0] + view[1]*n[1] + view[2]*n[2]; + dot = dot_v3v3(view, n); if(dot>0.0f) { index = 1.0f/index; @@ -1708,7 +1708,7 @@ static int UNUSED_FUNCTION(ray_trace_shadow_rad)(ShadeInput *ship, ShadeResult * counter+=3; counter %= 768; copy_v3_v3(vec, hashvectf+counter); - if(ship->vn[0]*vec[0]+ship->vn[1]*vec[1]+ship->vn[2]*vec[2]>0.0f) { + if (dot_v3v3(ship->vn, vec) > 0.0f) { vec[0]-= vec[0]; vec[1]-= vec[1]; vec[2]-= vec[2]; @@ -1771,7 +1771,7 @@ static void DS_energy(float *sphere, int tot, float vec[3]) for(a=0, fp=sphere; a bias) { + if (dot_v3v3(vec, nrm) > bias) { /* only ao samples for mask */ if(R.r.mode & R_OSA) { j++; @@ -2135,7 +2135,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) normalize_v3(view); if(envcolor==WO_AOSKYCOL) { - const float fac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); + const float fac = 0.5f * (1.0f + dot_v3v3(view, R.grvec)); env[0]+= (1.0f-fac)*R.wrld.horr + fac*R.wrld.zenr; env[1]+= (1.0f-fac)*R.wrld.horg + fac*R.wrld.zeng; env[2]+= (1.0f-fac)*R.wrld.horb + fac*R.wrld.zenb; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index c14a768d1ce..88d86d5bd43 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -2068,7 +2068,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v mul_m4_v3(obi->mat, v1); /* from shadepixel() */ - dface= v1[0]*nor[0] + v1[1]*nor[1] + v1[2]*nor[2]; + dface = dot_v3v3(v1, nor); hoco[3]= 1.0f; /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ @@ -2091,7 +2091,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v calc_view_vector(view, x, y); - div= nor[0]*view[0] + nor[1]*view[1] + nor[2]*view[2]; + div = dot_v3v3(nor, view); if (div==0.0f) return 0; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 580a09d5050..e0b5da817cb 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -608,7 +608,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v if(shi->obi->flag & R_TRANSFORMED) mul_m4_v3(shi->obi->mat, v1); - dface= v1[0]*shi->facenor[0]+v1[1]*shi->facenor[1]+v1[2]*shi->facenor[2]; + dface = dot_v3v3(v1, shi->facenor); /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ if(R.r.mode & R_ORTHO) { @@ -650,7 +650,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v else { float div; - div= shi->facenor[0]*view[0] + shi->facenor[1]*view[1] + shi->facenor[2]*view[2]; + div = dot_v3v3(shi->facenor, view); if (div!=0.0f) fac= dface/div; else fac= 0.0f; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 3637c2de1fb..66cbb18bc57 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -274,7 +274,7 @@ static float metadensity(Object* ob, const float co[3]) } /* ml->rad2 is not set */ - dist2 = 1.f - ((tp[0]*tp[0] + tp[1]*tp[1] + tp[2]*tp[2]) / (ml->rad*ml->rad)); + dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad)); if (dist2 > 0.f) dens += (ml->flag & MB_NEGATIVE) ? -ml->s*dist2*dist2*dist2 : ml->s*dist2*dist2*dist2; } From df51fd74cf826c42a90212082abb27e99484257a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Jan 2012 17:26:56 +0000 Subject: [PATCH 020/105] Quiet warnings in text editor --- source/blender/blenkernel/intern/text.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 8e5cc8c48e3..ba48db588c4 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -808,13 +808,14 @@ static int txt_utf8_len(const char *src) void txt_move_up(Text *text, short sel) { TextLine **linep; - int *charp, old; + int *charp; + /* int old; */ /* UNUSED */ if (!text) return; if(sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - old= *charp; + /* old= *charp; */ /* UNUSED */ if((*linep)->prev) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); @@ -834,13 +835,14 @@ void txt_move_up(Text *text, short sel) void txt_move_down(Text *text, short sel) { TextLine **linep; - int *charp, old; + int *charp; + /* int old; */ /* UNUSED */ if (!text) return; if(sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - old= *charp; + /* old= *charp; */ /* UNUSED */ if((*linep)->next) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); @@ -1897,6 +1899,10 @@ static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, s break; case 4: /* 32-bit unicode symbol */ unicode= txt_undo_read_uint32(undo_buf, undo_pos); + default: + /* should never happen */ + BLI_assert(0); + unicode= 0; } return unicode; From 1a93d8834319b890ff0cbc70231b14635603ae95 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 22 Jan 2012 17:54:23 +0000 Subject: [PATCH 021/105] Add weight preview to WeightVG modifiers, and first, simple/basic refactor of how modifiers can generate preview. User side: * Preview for DynamicPaint should keep the same behavior (for now). Weight preview should be somawhat quicker, though. * Preview for WeightVG modifiers is only active in WeightPaint mode, and if the affected vgroup is the active one. * Last active preview modifier in stack wins! Note: that modifier preview topic is yet to be further refined, quite raw/incomplete for now. Dev side: * In draw code, renamed DRAW_DYNAMIC_PAINT_PREVIEW flag to DRAW_MODIFIERS_PREVIEW * Removed use of MOD_DPAINT_PREVIEW_READY in DynamicPaint code (seems unecessary, and if it was, should be of more general scope). * Added eModifierTypeFlag_UsesPreview to ModifierTypeFlag, for modifiers that can generate some preview data. * Added three new modifier funcs, to handle preview modifiers in draw code / mod stack. * For weights preview: added the generic DM_update_weight_mcol func, which can update WEIGHT_MCOL layer with either a given array of weights (currently used by DynamicPaint only), or from current active vgroup(s). So now, draw code is fully generic (i.e. no more modifier-type checking in it). Mod stack code is generic to some extent, but will need more work. --- source/blender/blenkernel/BKE_DerivedMesh.h | 9 + source/blender/blenkernel/BKE_modifier.h | 10 +- .../blender/blenkernel/intern/DerivedMesh.c | 164 +++++++++++++----- .../blender/blenkernel/intern/dynamicpaint.c | 26 +-- source/blender/blenkernel/intern/modifier.c | 42 +++++ .../blender/editors/space_view3d/drawmesh.c | 4 +- .../blender/editors/space_view3d/drawobject.c | 24 +-- .../editors/space_view3d/view3d_intern.h | 2 +- .../blender/makesdna/DNA_dynamicpaint_types.h | 3 + .../modifiers/intern/MOD_dynamicpaint.c | 6 +- .../modifiers/intern/MOD_weightvgedit.c | 21 ++- .../modifiers/intern/MOD_weightvgmix.c | 17 +- .../modifiers/intern/MOD_weightvgproximity.c | 17 +- 13 files changed, 245 insertions(+), 100 deletions(-) diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 0c47c833cb3..a887412bbf4 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -538,6 +538,15 @@ int sculpt_get_deform_matrices(struct Scene *scene, struct Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]); void weight_to_rgb(float r_rgb[3], const float weight); +/* Update the weight MCOL preview layer. + * If weights are NULL, use object's active vgroup(s). + * Else, weights must be an array of weight float values. + * If indices is NULL, it must be of numVerts length. + * Else, it must be of num length, as indices, which contains vertices' idx to apply weights to. + * (other vertices are assumed zero weight). + */ +void DM_update_weight_mcol(struct Object *ob, struct DerivedMesh *dm, int const draw_flag, + float *weights, int num, const int *indices); /* convert layers requested by a GLSL material to actually available layers in * the DerivedMesh, with both a pointer for arrays and an offset for editmesh */ diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 23073a2d8eb..f72bc5b93ec 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -99,7 +99,10 @@ typedef enum { eModifierTypeFlag_Single = (1<<7), /* Some modifier can't be added manually by user */ - eModifierTypeFlag_NoUserAdd = (1<<8) + eModifierTypeFlag_NoUserAdd = (1<<8), + + /* For modifiers that use CD_WEIGHT_MCOL for preview. */ + eModifierTypeFlag_UsesPreview = (1<<9) } ModifierTypeFlag; typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object **obpoin); @@ -323,6 +326,7 @@ void modifier_setError(struct ModifierData *md, const char *format, ... __attribute__ ((format (printf, 2, 3))) #endif ; +int modifier_isPreview(struct ModifierData *md); void modifiers_foreachObjectLink(struct Object *ob, ObjectWalkFunc walk, @@ -349,6 +353,7 @@ struct Object *modifiers_isDeformedByLattice(struct Object *ob); int modifiers_usesArmature(struct Object *ob, struct bArmature *arm); int modifiers_isCorrectableDeformed(struct Object *ob); void modifier_freeTemporaryData(struct ModifierData *md); +int modifiers_isPreview(struct Object *ob); int modifiers_indexInObject(struct Object *ob, struct ModifierData *md); @@ -362,6 +367,9 @@ struct LinkNode *modifiers_calcDataMasks(struct Scene *scene, struct ModifierData *md, CustomDataMask dataMask, int required_mode); +struct ModifierData *modifiers_getLastPreview(struct Scene *scene, + struct ModifierData *md, + int required_mode); struct ModifierData *modifiers_getVirtualModifierList(struct Object *ob); /* ensure modifier correctness when changing ob->data */ diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index b670a360a6a..27aeeb95903 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -722,24 +722,23 @@ void vDM_ColorBand_store(ColorBand *coba) * note that we could save some memory and allocate RGB only but then we'd need to * re-arrange the colors when copying to the face since MCol has odd ordering, * so leave this as is - campbell */ -static unsigned char *calc_weightpaint_vert_array(Object *ob, int const draw_flag, ColorBand *coba) +static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, int const draw_flag, ColorBand *coba) { - Mesh *me = ob->data; - unsigned char *wtcol_v = MEM_mallocN (sizeof(unsigned char) * me->totvert * 4, "weightmap_v"); + MDeformVert *dv = DM_get_vert_data_layer(dm, CD_MDEFORMVERT); + int numVerts = dm->getNumVerts(dm); + unsigned char *wtcol_v = MEM_mallocN (sizeof(unsigned char) * numVerts * 4, "weightmap_v"); - if (me->dvert) { + if (dv) { unsigned char *wc = wtcol_v; - MDeformVert *dv= me->dvert; unsigned int i; - /* varisbles for multipaint */ + /* variables for multipaint */ const int defbase_tot = BLI_countlist(&ob->defbase); const int defbase_act = ob->actdef-1; char *dg_flags = MEM_mallocN(defbase_tot * sizeof(char), __func__); const int selected = get_selected_defgroups(ob, dg_flags, defbase_tot); - /* const int unselected = defbase_tot - selected; */ /* UNUSED */ - for (i = me->totvert; i != 0; i--, wc += 4, dv++) { + for (i = numVerts; i != 0; i--, wc += 4, dv++) { calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, dg_flags, selected, draw_flag); } @@ -748,48 +747,94 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, int const draw_fla else { int col_i; weightpaint_color((unsigned char *)&col_i, coba, 0.0f); - fill_vn_i((int *)wtcol_v, me->totvert, col_i); + fill_vn_i((int *)wtcol_v, numVerts, col_i); } return wtcol_v; } -static void add_weight_mcol_dm(Object *ob, DerivedMesh *dm, int const draw_flag) +/* return an array of vertex weight colors from given weights, caller must free. + * + * note that we could save some memory and allocate RGB only but then we'd need to + * re-arrange the colors when copying to the face since MCol has odd ordering, + * so leave this as is - campbell */ +static unsigned char *calc_colors_from_weights_array(const int num, float *weights) +{ + unsigned char *wtcol_v = MEM_mallocN(sizeof(unsigned char) * num * 4, "weightmap_v"); + unsigned char *wc = wtcol_v; + int i; + + for (i = 0; i < num; i++, wc += 4, weights++) + weightpaint_color((unsigned char *) wc, NULL, *weights); + + return wtcol_v; +} + +void DM_update_weight_mcol(Object *ob, DerivedMesh *dm, int const draw_flag, + float *weights, int num, const int *indices) { ColorBand *coba= stored_cb; /* warning, not a local var */ - Mesh *me = ob->data; - unsigned char *wtcol_v = calc_weightpaint_vert_array(ob, draw_flag, coba); - unsigned char *wtcol_f = MEM_mallocN (sizeof(unsigned char) * me->totface*4*4, "weightmap_f"); - unsigned char *wtcol_f_step = wtcol_f; - - MFace *mf = me->mface; + MFace *mf = dm->getFaceArray(dm); + int numFaces = dm->getNumFaces(dm); + int numVerts = dm->getNumVerts(dm); + unsigned char *wtcol_v; + unsigned char *wtcol_f = dm->getFaceDataArray(dm, CD_WEIGHT_MCOL); int i; - for (i=0; itotface; i++, mf++, wtcol_f_step += (4 * 4)) { + /* If no CD_WEIGHT_MCOL existed yet, add a new one! */ + if (!wtcol_f) + wtcol_f = CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numFaces); + + if (wtcol_f) { + unsigned char *wtcol_f_step = wtcol_f; + + /* Weights are given by caller. */ + if (weights) { + float *w = weights; + /* If indices is not NULL, it means we do not have weights for all vertices, + * so we must create them (and set them to zero)... */ + if(indices) { + w = MEM_callocN(sizeof(float)*numVerts, "Temp weight array DM_update_weight_mcol"); + i = num; + while(i--) + w[indices[i]] = weights[i]; + } + + /* Convert float weights to colors. */ + wtcol_v = calc_colors_from_weights_array(numVerts, w); + + if(indices) + MEM_freeN(w); + } + + /* No weights given, take them from active vgroup(s). */ + else + wtcol_v = calc_weightpaint_vert_array(ob, dm, draw_flag, coba); + + /* Now copy colors in all face verts. */ + for (i = 0; i < numFaces; i++, mf++, wtcol_f_step += (4 * 4)) { #if 0 - unsigned int fidx= mf->v4 ? 3:2; + unsigned int fidx= mf->v4 ? 3:2; #else /* better zero out triangles 4th component. else valgrind complains when the buffer's copied */ - unsigned int fidx; - if (mf->v4) { - fidx = 3; - } - else { - fidx = 2; - *(int *)(&wtcol_f_step[3 * 4]) = 0; - } + unsigned int fidx; + if (mf->v4) { + fidx = 3; + } + else { + fidx = 2; + *(int *)(&wtcol_f_step[3 * 4]) = 0; + } #endif - do { - copy_v4_v4_char((char *)&wtcol_f_step[fidx * 4], - (char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]); - } while (fidx--); + do { + copy_v4_v4_char((char *)&wtcol_f_step[fidx * 4], + (char *)&wtcol_v[4 * (*(&mf->v1 + fidx))]); + } while (fidx--); + } + MEM_freeN(wtcol_v); } - - MEM_freeN(wtcol_v); - - CustomData_add_layer(&dm->faceData, CD_WEIGHT_MCOL, CD_ASSIGN, wtcol_f, dm->numFaceData); } /* new value for useDeform -1 (hack for the gameengine): @@ -803,7 +848,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos int needMapping, CustomDataMask dataMask, int index, int useCache) { Mesh *me = ob->data; - ModifierData *firstmd, *md; + ModifierData *firstmd, *md, *previewmd = NULL; LinkNode *datamasks, *curr; CustomDataMask mask, nextmask, append_mask = 0; float (*deformedVerts)[3] = NULL; @@ -816,8 +861,17 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos int has_multires = mmd != NULL, multires_applied = 0; int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt; - int draw_flag= ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) | - (scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0)); + const int draw_flag= ((scene->toolsettings->multipaint ? CALC_WP_MULTIPAINT : 0) | + (scene->toolsettings->auto_normalize ? CALC_WP_AUTO_NORMALIZE : 0)); + /* Generic preview only in object mode! */ + const int do_mod_mcol = (ob->mode == OB_MODE_OBJECT); +#if 0 /* XXX Will re-enable this when we have global mod stack options. */ + const int do_final_wmcol = (scene->toolsettings->weights_preview == WP_WPREVIEW_FINAL) && do_wmcol; +#endif + const int do_final_wmcol = FALSE; + int do_init_wmcol = ((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && !do_final_wmcol); + /* XXX Same as above... For now, only weights preview in WPaint mode. */ + const int do_mod_wmcol = do_init_wmcol; if(mmd && !mmd->sculptlvl) has_multires = 0; @@ -842,6 +896,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode); curr = datamasks; + if(do_mod_wmcol || do_mod_mcol) { + /* Find the last active modifier generating a preview, or NULL if none. */ + /* XXX Currently, DPaint modifier just ignores this. + * Needs a stupid hack... + * The whole "modifier preview" thing has to be (re?)designed, anyway! */ + previewmd = modifiers_getLastPreview(scene, md, required_mode); + } + if(deform_r) *deform_r = NULL; *final_r = NULL; @@ -997,8 +1059,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos CDDM_calc_normals(dm); } - if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT)) - add_weight_mcol_dm(ob, dm, draw_flag); + if(do_init_wmcol) + DM_update_weight_mcol(ob, dm, draw_flag, NULL, 0, NULL); /* Constructive modifiers need to have an origindex * otherwise they wont have anywhere to copy the data from. @@ -1085,8 +1147,14 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } /* in case of dynamic paint, make sure preview mask remains for following modifiers */ + /* XXX Temp and hackish solution! */ if (md->type == eModifierType_DynamicPaint) append_mask |= CD_MASK_WEIGHT_MCOL; + /* In case of active preview modifier, make sure preview mask remains for following modifiers. */ + else if ((md == previewmd) && (do_mod_wmcol)) { + DM_update_weight_mcol(ob, dm, draw_flag, NULL, 0, NULL); + append_mask |= CD_MASK_WEIGHT_MCOL; + } } isPrevDeform= (mti->type == eModifierTypeType_OnlyDeform); @@ -1114,10 +1182,19 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos CDDM_apply_vert_coords(finaldm, deformedVerts); CDDM_calc_normals(finaldm); - if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT)) - add_weight_mcol_dm(ob, finaldm, draw_flag); +#if 0 /* For later nice mod preview! */ + /* In case we need modified weights in CD_WEIGHT_MCOL, we have to re-compute it. */ + if(do_final_wmcol) + DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL); +#endif } else if(dm) { finaldm = dm; + +#if 0 /* For later nice mod preview! */ + /* In case we need modified weights in CD_WEIGHT_MCOL, we have to re-compute it. */ + if(do_final_wmcol) + DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL); +#endif } else { finaldm = CDDM_from_mesh(me, ob); @@ -1126,8 +1203,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos CDDM_calc_normals(finaldm); } - if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT)) - add_weight_mcol_dm(ob, finaldm, draw_flag); + /* In this case, we should never have weight-modifying modifiers in stack... */ + if(do_init_wmcol) + DM_update_weight_mcol(ob, finaldm, draw_flag, NULL, 0, NULL); } /* add an orco layer if needed */ diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 6a2207d455c..18c8d0f0106 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -1574,7 +1574,6 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData DynamicPaintSurface *surface = pmd->canvas->surfaces.first; int update_normals = 0; - pmd->canvas->flags &= ~MOD_DPAINT_PREVIEW_READY; /* loop through surfaces */ for (; surface; surface=surface->next) { @@ -1651,7 +1650,6 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData } } } - pmd->canvas->flags |= MOD_DPAINT_PREVIEW_READY; } } @@ -1711,29 +1709,7 @@ static struct DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData if (surface->flags & MOD_DPAINT_PREVIEW) { /* Save preview results to weight layer, to be * able to share same drawing methods */ - MFace *mface = result->getFaceArray(result); - int numOfFaces = result->getNumFaces(result); - int i; - MCol *col = result->getFaceDataArray(result, CD_WEIGHT_MCOL); - if (!col) col = CustomData_add_layer(&result->faceData, CD_WEIGHT_MCOL, CD_CALLOC, NULL, numOfFaces); - - if (col) { - #pragma omp parallel for schedule(static) - for (i=0; icanvas->flags |= MOD_DPAINT_PREVIEW_READY; - } + DM_update_weight_mcol(ob, result, 0, weight, 0, NULL); } /* apply weights into a vertex group, if doesnt exists add a new layer */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 5a389019519..911d303b4cf 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -142,6 +142,19 @@ int modifier_supportsMapping(ModifierData *md) (mti->flags & eModifierTypeFlag_SupportsMapping)); } +int modifier_isPreview(ModifierData *md) +{ + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + + if (!(mti->flags & eModifierTypeFlag_UsesPreview)) + return FALSE; + + if (md->mode & eModifierMode_Realtime) + return TRUE; + + return FALSE; +} + ModifierData *modifiers_findByType(Object *ob, ModifierType type) { ModifierData *md = ob->modifiers.first; @@ -385,6 +398,21 @@ LinkNode *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierData return dataMasks; } +ModifierData *modifiers_getLastPreview(struct Scene *scene, ModifierData *md, int required_mode) +{ + ModifierData *tmp_md = NULL; + + if (required_mode != eModifierMode_Realtime) + return tmp_md; + + /* Find the latest modifier in stack generating preview. */ + for(; md; md = md->next) { + if(modifier_isEnabled(scene, md, required_mode) && modifier_isPreview(md)) + tmp_md = md; + } + return tmp_md; +} + ModifierData *modifiers_getVirtualModifierList(Object *ob) { /* Kinda hacky, but should be fine since we are never @@ -545,6 +573,20 @@ int modifiers_isCorrectableDeformed(Object *ob) return 0; } +/* Check whether the given object has a modifier in its stack that uses WEIGHT_MCOL CD layer + * to preview something... Used by DynamicPaint and WeightVG currently. */ +int modifiers_isPreview(Object *ob) +{ + ModifierData *md = ob->modifiers.first; + + for (; md; md = md->next) { + if (modifier_isPreview(md)) + return TRUE; + } + + return FALSE; +} + int modifiers_indexInObject(Object *ob, ModifierData *md_seek) { int i= 0; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 5f521cc3dd1..62c12500aa8 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -713,7 +713,7 @@ void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec } else { if(GPU_buffer_legacy(dm)) { - if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) + if (draw_flags & DRAW_MODIFIERS_PREVIEW) dm->drawFacesTex(dm, draw_mcol__set_draw_legacy, NULL, NULL); else dm->drawFacesTex(dm, draw_tface__set_draw_legacy, NULL, NULL); @@ -849,7 +849,7 @@ static int tex_mat_set_face_editmesh_cb(void *UNUSED(userData), int index) void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) { - if((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) { + if((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags); return; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index f7f67bd4e73..1482340632e 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -36,7 +36,6 @@ #include "DNA_camera_types.h" #include "DNA_curve_types.h" #include "DNA_constraint_types.h" // for drawing constraint -#include "DNA_dynamicpaint_types.h" #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" @@ -3081,27 +3080,16 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D eWireDrawMode draw_wire= OBDRAW_WIRE_OFF; int /* totvert,*/ totedge, totface; DerivedMesh *dm= mesh_get_derived_final(scene, ob, scene->customdata_mask); - ModifierData *md = NULL; const short is_obact= (ob == OBACT); int draw_flags = (is_obact && paint_facesel_test(ob)) ? DRAW_FACE_SELECT : 0; if(!dm) return; - /* check to draw dynamic paint colors */ - if ((md = modifiers_findByType(ob, eModifierType_DynamicPaint))) - { - /* check if target has an active dpaint modifier */ - if(md && (md->mode & eModifierMode_Realtime)) - { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; - /* if canvas is ready to preview vertex colors */ - if (pmd->canvas && pmd->canvas->flags & MOD_DPAINT_PREVIEW_READY && - DM_get_face_data_layer(dm, CD_WEIGHT_MCOL)) { - draw_flags |= DRAW_DYNAMIC_PAINT_PREVIEW; - } - } - } + /* Check to draw dynamic paint colors (or weights from WeightVG modifiers). + * Note: Last "preview-active" modifier in stack will win! */ + if(DM_get_face_data_layer(dm, CD_WEIGHT_MCOL) && modifiers_isPreview(ob)) + draw_flags |= DRAW_MODIFIERS_PREVIEW; /* Unwanted combination */ if (draw_flags & DRAW_FACE_SELECT) { @@ -3142,7 +3130,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D draw_mesh_object_outline(v3d, ob, dm); } - if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW)) { + if(draw_glsl_material(scene, ob, v3d, dt) && !(draw_flags & DRAW_MODIFIERS_PREVIEW)) { glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); dm->drawFacesGLSL(dm, GPU_enable_material); @@ -3193,7 +3181,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* since we already draw wire as wp guide, dont draw over the top */ draw_wire= OBDRAW_WIRE_OFF; } - else if (draw_flags & DRAW_DYNAMIC_PAINT_PREVIEW) { + else if (draw_flags & DRAW_MODIFIERS_PREVIEW) { /* for object selection draws no shade */ if (flag & (DRAW_PICKING|DRAW_CONSTCOLOR)) { dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index f6c82b0ba9d..07754c0883c 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -59,7 +59,7 @@ struct wmNDOFMotionData; #define DRAW_SCENESET 4 /* draw_mesh_fancy/draw_mesh_textured draw_flags */ -#define DRAW_DYNAMIC_PAINT_PREVIEW 1 +#define DRAW_MODIFIERS_PREVIEW 1 #define DRAW_FACE_SELECT 2 /* view3d_header.c */ diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h index aff4607da51..2345b8dd1c0 100644 --- a/source/blender/makesdna/DNA_dynamicpaint_types.h +++ b/source/blender/makesdna/DNA_dynamicpaint_types.h @@ -135,7 +135,10 @@ typedef struct DynamicPaintSurface { } DynamicPaintSurface; /* canvas flags */ +#if 0 /* This should not be needed, having a valid WEIGHT_MCOL layer should be enough. + * And if not, should be a general flag. But seems unecessary for now... */ #define MOD_DPAINT_PREVIEW_READY (1<<0) /* if viewport preview is ready */ +#endif #define MOD_DPAINT_BAKING (1<<1) /* surface is already baking, so it wont get updated (loop) */ /* Canvas settings */ diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 773e93a22ad..c7b4d41e646 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -170,8 +170,10 @@ ModifierTypeInfo modifierType_DynamicPaint = { /* structSize */ sizeof(DynamicPaintModifierData), /* type */ eModifierTypeType_Constructive, /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache - | eModifierTypeFlag_Single, +/* |eModifierTypeFlag_SupportsMapping*/ + |eModifierTypeFlag_UsesPointCache + |eModifierTypeFlag_Single + |eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index e090ad78e59..e4d1d7d0eb0 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -114,6 +114,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV) dataMask |= CD_MASK_MTFACE; + /* No need to ask for CD_WEIGHT_MCOL... */ + return dataMask; } @@ -186,8 +188,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der int defgrp_idx; int i; /* Flags. */ - int do_add = (wmd->edit_flags & MOD_WVG_EDIT_ADD2VG) != 0; - int do_rem = (wmd->edit_flags & MOD_WVG_EDIT_REMFVG) != 0; + int do_add = (wmd->edit_flags & MOD_WVG_EDIT_ADD2VG) != 0; + int do_rem = (wmd->edit_flags & MOD_WVG_EDIT_REMFVG) != 0; + /* Only do weight-preview in Object, Sculpt and Pose modes! */ +#if 0 + int do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview); +#endif /* Get number of verts. */ numVerts = dm->getNumVerts(dm); @@ -244,6 +250,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der weightvg_update_vg(dvert, defgrp_idx, dw, numVerts, NULL, org_w, do_add, wmd->add_threshold, do_rem, wmd->rem_threshold); + /* If weight preview enabled... */ +#if 0 /* XXX Currently done in mod stack :/ */ + if(do_prev) + DM_update_weight_mcol(ob, dm, 0, org_w, 0, NULL); +#endif + /* Freeing stuff. */ MEM_freeN(org_w); MEM_freeN(new_w); @@ -267,8 +279,9 @@ ModifierTypeInfo modifierType_WeightVGEdit = { /* structSize */ sizeof(WeightVGEditModifierData), /* type */ eModifierTypeType_NonGeometrical, /* flags */ eModifierTypeFlag_AcceptsMesh -/* |eModifierTypeFlag_SupportsMapping*/ - |eModifierTypeFlag_SupportsEditmode, + |eModifierTypeFlag_SupportsMapping + |eModifierTypeFlag_SupportsEditmode + |eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 28f9f503966..38de944cf45 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -156,6 +156,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV) dataMask |= CD_MASK_MTFACE; + /* No need to ask for CD_WEIGHT_MCOL... */ + return dataMask; } @@ -229,6 +231,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der int *tidx, *indices = NULL; int numIdx = 0; int i; + /* Flags. */ +#if 0 + int do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview); +#endif /* Get number of verts. */ numVerts = dm->getNumVerts(dm); @@ -372,6 +378,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der */ weightvg_update_vg(dvert, defgrp_idx, dw1, numIdx, indices, org_w, TRUE, -FLT_MAX, FALSE, 0.0f); + /* If weight preview enabled... */ +#if 0 /* XXX Currently done in mod stack :/ */ + if(do_prev) + DM_update_weight_mcol(ob, dm, 0, org_w, numIdx, indices); +#endif + /* Freeing stuff. */ MEM_freeN(org_w); MEM_freeN(new_w); @@ -399,8 +411,9 @@ ModifierTypeInfo modifierType_WeightVGMix = { /* structSize */ sizeof(WeightVGMixModifierData), /* type */ eModifierTypeType_NonGeometrical, /* flags */ eModifierTypeFlag_AcceptsMesh -/* |eModifierTypeFlag_SupportsMapping*/ - |eModifierTypeFlag_SupportsEditmode, + |eModifierTypeFlag_SupportsMapping + |eModifierTypeFlag_SupportsEditmode + |eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 55b625f7865..c1aa68d1544 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -268,6 +268,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) if(wmd->mask_tex_mapping == MOD_DISP_MAP_UV) dataMask |= CD_MASK_MTFACE; + /* No need to ask for CD_WEIGHT_MCOL... */ + return dataMask; } @@ -353,6 +355,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der int *tidx, *indices = NULL; int numIdx = 0; int i; + /* Flags. */ +#if 0 + int do_prev = (wmd->modifier.mode & eModifierMode_DoWeightPreview); +#endif #if DO_PROFILE TIMEIT_START(perf) @@ -505,6 +511,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Update vgroup. Note we never add nor remove vertices from vgroup here. */ weightvg_update_vg(dvert, defgrp_idx, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f); + /* If weight preview enabled... */ +#if 0 /* XXX Currently done in mod stack :/ */ + if(do_prev) + DM_update_weight_mcol(ob, dm, 0, org_w, numIdx, indices); +#endif + /* Freeing stuff. */ MEM_freeN(org_w); MEM_freeN(new_w); @@ -535,8 +547,9 @@ ModifierTypeInfo modifierType_WeightVGProximity = { /* structSize */ sizeof(WeightVGProximityModifierData), /* type */ eModifierTypeType_NonGeometrical, /* flags */ eModifierTypeFlag_AcceptsMesh -/* |eModifierTypeFlag_SupportsMapping*/ - |eModifierTypeFlag_SupportsEditmode, + |eModifierTypeFlag_SupportsMapping + |eModifierTypeFlag_SupportsEditmode + |eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, From ab1600bee50cf2546938dca8837e4c7ba86d78f7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Jan 2012 18:59:06 +0000 Subject: [PATCH 022/105] error in outliner parent patch - was using set string on an enum property. --- source/blender/editors/space_outliner/space_outliner.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 5b20c170362..a040c63b2ab 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -139,9 +139,9 @@ static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop) RNA_string_set(drop->ptr, "dragged_obj", id->name+2); /* Set to simple parent clear type. Avoid menus for drag and drop if possible. - If desired, user can toggle the different "Clear Parent" types in the operator - menu on tool shelf. */ - RNA_string_set(drop->ptr, "type", 0); + * If desired, user can toggle the different "Clear Parent" types in the operator + * menu on tool shelf. */ + RNA_enum_set(drop->ptr, "type", 0); } /* region dropbox definition */ From 008b0e90dd87490763f685d822ffe37d40ede7c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Jan 2012 19:52:41 +0000 Subject: [PATCH 023/105] minor edit for operator error macro so it can return different values. --- .../editors/interface/interface_layout.c | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b40c618c301..429cd658dea 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -66,6 +66,14 @@ #define EM_SEPR_X 6 #define EM_SEPR_Y 6 +#define UI_OPERATOR_ERROR_RET(_ot, _opname, return_statement) \ + if (ot == NULL) { \ + ui_item_disabled(layout, _opname); \ + RNA_warning("'%s' unknown operator", _opname); \ + return_statement; \ + } (void)0 \ + + /* uiLayoutRoot */ typedef struct uiLayoutRoot { @@ -690,14 +698,9 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i { wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ - if(ot) { - return uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag); - } - else { - ui_item_disabled(layout, opname); - RNA_warning("unknown operator '%s'", opname); - return PointerRNA_NULL; - } + UI_OPERATOR_ERROR_RET(ot, opname, return PointerRNA_NULL); + + return uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag); } static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int retval) @@ -842,13 +845,6 @@ void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0); } -#define UI_OPERATOR_ERROR_RET(_ot, _opname) \ - if (ot == NULL) { \ - ui_item_disabled(layout, _opname); \ - RNA_warning("'%s' unknown operator", _opname); \ - return; \ - } (void)0 - /* for use in cases where we have */ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) { @@ -856,7 +852,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char PointerRNA ptr; PropertyRNA *prop; - UI_OPERATOR_ERROR_RET(ot, opname); + UI_OPERATOR_ERROR_RET(ot, opname, return); WM_operator_properties_create_ptr(&ptr, ot); @@ -887,7 +883,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char EnumPropertyItem *item; int value, free; - UI_OPERATOR_ERROR_RET(ot, opname); + UI_OPERATOR_ERROR_RET(ot, opname, return); WM_operator_properties_create_ptr(&ptr, ot); @@ -925,7 +921,7 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname); + UI_OPERATOR_ERROR_RET(ot, opname, return); WM_operator_properties_create_ptr(&ptr, ot); RNA_boolean_set(&ptr, propname, value); @@ -938,7 +934,7 @@ void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname); + UI_OPERATOR_ERROR_RET(ot, opname, return); WM_operator_properties_create_ptr(&ptr, ot); RNA_int_set(&ptr, propname, value); @@ -951,7 +947,7 @@ void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opna wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname); + UI_OPERATOR_ERROR_RET(ot, opname, return); WM_operator_properties_create_ptr(&ptr, ot); RNA_float_set(&ptr, propname, value); @@ -964,7 +960,7 @@ void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opn wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname); + UI_OPERATOR_ERROR_RET(ot, opname, return); WM_operator_properties_create_ptr(&ptr, ot); RNA_string_set(&ptr, propname, value); @@ -1608,7 +1604,7 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ MenuItemLevel *lvl; - UI_OPERATOR_ERROR_RET(ot, opname); + UI_OPERATOR_ERROR_RET(ot, opname, return); if(!ot->srna) { ui_item_disabled(layout, opname); From 359e961a12e5c2f6432b8d65a543d2d6e389ba17 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Sun, 22 Jan 2012 20:01:33 +0000 Subject: [PATCH 024/105] restrict stitching of same island uvs to only midpoint, without snapping case --- source/blender/editors/uvedit/uvedit_smart_stitch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 3731d348522..e99a90f34c5 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -290,7 +290,8 @@ static int stitch_check_uvs_stitchable(UvElement *element, UvElement *element_it static int stitch_check_uvs_state_stitchable(UvElement *element, UvElement *element_iter, StitchState *state){ - if(state->snap_islands && element->island == element_iter->island) + if((state->snap_islands && element->island == element_iter->island) || + (!state->midpoints && element->island == element_iter->island)) return 0; return stitch_check_uvs_stitchable(element, element_iter, state); @@ -543,9 +544,8 @@ static void stitch_validate_stichability(UvElement *element, StitchState *state, if(element_iter->separate){ if(element_iter == element) continue; - if(stitch_check_uvs_stitchable(element, element_iter, state)){ - if(((element_iter->island == state->static_island) || (element->island == state->static_island)) && - !((element_iter->island == element->island) && state->snap_islands)){ + if(stitch_check_uvs_state_stitchable(element, element_iter, state)){ + if((element_iter->island == state->static_island) || (element->island == state->static_island)){ element->flag |= STITCH_STITCHABLE; preview->num_stitchable++; stitch_setup_face_preview_for_uv_group(element, state, island_stitch_data); From 686ce92fe88d166f0fa1658363c4de8c1b5009b2 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 22 Jan 2012 20:25:25 +0000 Subject: [PATCH 025/105] Committing patch "[#27676] Change window size/resolution in realtime" by me. Description: This patch allows the user to change the size of the window (or the resolution in fullscreen mode) using the new bge.render.setWindowSize() method. This only works in the Blenderplayer since it doesn't make a whole lot of sense for the embedded player. --- doc/python_api/rst/bge.render.rst | 8 ++++++++ intern/ghost/GHOST_ISystem.h | 9 +++++++++ intern/ghost/intern/GHOST_System.cpp | 13 ++++++++++++ intern/ghost/intern/GHOST_System.h | 9 +++++++++ .../BlenderRoutines/KX_BlenderCanvas.cpp | 5 +++++ .../BlenderRoutines/KX_BlenderCanvas.h | 2 +- .../gameengine/GamePlayer/common/GPC_Canvas.h | 1 + .../GamePlayer/ghost/GPG_Canvas.cpp | 20 +++++++++++++++++++ .../gameengine/GamePlayer/ghost/GPG_Canvas.h | 2 ++ source/gameengine/Ketsji/KX_PythonInit.cpp | 11 ++++++++++ source/gameengine/Rasterizer/RAS_ICanvas.h | 9 +++++++++ 11 files changed, 88 insertions(+), 1 deletion(-) diff --git a/doc/python_api/rst/bge.render.rst b/doc/python_api/rst/bge.render.rst index eeb50a833ff..ddc05ac1d8c 100644 --- a/doc/python_api/rst/bge.render.rst +++ b/doc/python_api/rst/bge.render.rst @@ -77,6 +77,14 @@ Functions :rtype: integer +.. function:: setWindowSize(width, height) + + Set the width and height of the window (in pixels). This also works for fullscreen applications. + + :type width: integer + :type height: integer + + .. function:: makeScreenshot(filename) Writes a screenshot to the given filename. diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h index 3ec8d3d2fbf..ee67694760b 100644 --- a/intern/ghost/GHOST_ISystem.h +++ b/intern/ghost/GHOST_ISystem.h @@ -271,6 +271,15 @@ public: */ virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0) = 0; + + /** + * Updates the resolution while in fullscreen mode. + * @param setting The new setting of the display. + * @param window Window displayed in full screen. + * + * @return Indication of success. + */ + virtual GHOST_TSuccess updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window) = 0; /** * Ends full screen mode. diff --git a/intern/ghost/intern/GHOST_System.cpp b/intern/ghost/intern/GHOST_System.cpp index 4efdcbc6519..944ade3f22b 100644 --- a/intern/ghost/intern/GHOST_System.cpp +++ b/intern/ghost/intern/GHOST_System.cpp @@ -168,6 +168,19 @@ GHOST_TSuccess GHOST_System::beginFullScreen(const GHOST_DisplaySetting& setting } +GHOST_TSuccess GHOST_System::updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window) +{ + GHOST_TSuccess success = GHOST_kFailure; + GHOST_ASSERT(m_windowManager, "GHOST_System::updateFullScreen(): invalid window manager"); + if(m_displayManager) { + if (m_windowManager->getFullScreen()) { + success = m_displayManager->setCurrentDisplaySetting(GHOST_DisplayManager::kMainDisplay, setting); + } + } + + return success; +} + GHOST_TSuccess GHOST_System::endFullScreen(void) { GHOST_TSuccess success = GHOST_kFailure; diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h index 6286121719d..0bb0387a287 100644 --- a/intern/ghost/intern/GHOST_System.h +++ b/intern/ghost/intern/GHOST_System.h @@ -145,6 +145,15 @@ public: */ virtual GHOST_TSuccess beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, const bool stereoVisual, const GHOST_TUns16 numOfAASamples=0); + + /** + * Updates the resolution while in fullscreen mode. + * @param setting The new setting of the display. + * @param window Window displayed in full screen. + * + * @return Indication of success. + */ + virtual GHOST_TSuccess updateFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window); /** * Ends full screen mode. diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 2a21b531b6b..7e7b3d2e3d4 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -59,6 +59,11 @@ void KX_BlenderCanvas::SwapBuffers() BL_SwapBuffers(m_win); } +void KX_BlenderCanvas::ResizeWindow(int width, int height) +{ + // Not implemented for the embedded player +} + void KX_BlenderCanvas::BeginFrame() { glEnable(GL_DEPTH_TEST); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h index 1f38cf9766d..44dffb5bc54 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h @@ -78,7 +78,7 @@ public: SwapBuffers( ); void - Resize( + ResizeWindow( int width, int height ); diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h index 6ac1323783b..a9d7ab1b93f 100644 --- a/source/gameengine/GamePlayer/common/GPC_Canvas.h +++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h @@ -103,6 +103,7 @@ public: void Resize(int width, int height); + virtual void ResizeWindow(int width, int height){}; /** * @section Methods inherited from abstract base class RAS_ICanvas. diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp index 4b5d2bbf96a..9b01cb5786f 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.cpp @@ -108,6 +108,26 @@ void GPG_Canvas::SwapBuffers() } } +void GPG_Canvas::ResizeWindow(int width, int height) +{ + if (m_window->getState() == GHOST_kWindowStateFullScreen) + { + GHOST_ISystem* system = GHOST_ISystem::getSystem(); + GHOST_DisplaySetting setting; + setting.xPixels = width; + setting.yPixels = height; + //XXX allow these to be changed or kept from previous state + setting.bpp = 32; + setting.frequency = 60; + + system->updateFullScreen(setting, &m_window); + } + + m_window->setClientSize(width, height); + + Resize(width, height); +} + float GPG_Canvas::GetMouseNormalizedX(int x) { return float(x)/this->GetWidth(); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h index c1ebb09251c..217cfc5eb88 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Canvas.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Canvas.h @@ -60,6 +60,8 @@ public: virtual float GetMouseNormalizedX(int x); virtual float GetMouseNormalizedY(int y); + virtual void ResizeWindow(int width, int height); + bool BeginDraw() { return true;}; void EndDraw() {}; }; diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 114ca735265..32106b1fdd8 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1288,6 +1288,16 @@ static PyObject* gPyDrawLine(PyObject*, PyObject* args) Py_RETURN_NONE; } +static PyObject* gPySetWindowSize(PyObject*, PyObject* args) +{ + int width, height; + if (!PyArg_ParseTuple(args, "ii:resize", &width, &height)) + return NULL; + + gp_Canvas->ResizeWindow(width, height); + Py_RETURN_NONE; +} + static struct PyMethodDef rasterizer_methods[] = { {"getWindowWidth",(PyCFunction) gPyGetWindowWidth, METH_VARARGS, "getWindowWidth doc"}, @@ -1329,6 +1339,7 @@ static struct PyMethodDef rasterizer_methods[] = { METH_VARARGS, "get the anisotropic filtering level"}, {"drawLine", (PyCFunction) gPyDrawLine, METH_VARARGS, "draw a line on the screen"}, + {"setWindowSize", (PyCFunction) gPySetWindowSize, METH_VARARGS, ""}, { NULL, (PyCFunction) NULL, 0, NULL } }; diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h index d7e2f237bb0..2c2f62c946e 100644 --- a/source/gameengine/Rasterizer/RAS_ICanvas.h +++ b/source/gameengine/Rasterizer/RAS_ICanvas.h @@ -205,6 +205,15 @@ public: MakeScreenShot( const char* filename )=0; + + virtual + void + ResizeWindow( + int width, + int height + )=0; + + protected: RAS_MouseState m_mousestate; From c499f5120bc16f100ec6d38a661de0ae12c7a0d5 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 22 Jan 2012 22:30:45 +0000 Subject: [PATCH 026/105] Ocean Modifier UI fixes: * Modifier Icon was missing in the outliner * Fluid icon was used in the rna struct, fixed Note: Ocean uses the Wave modifier icon atm, if we find a better one, this can be changed. --- source/blender/editors/space_outliner/outliner_draw.c | 2 ++ source/blender/makesrna/intern/rna_modifier.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 0264cf5ad05..eaa04a1e09e 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1022,6 +1022,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto UI_icon_draw(x, y, ICON_MOD_VERTEX_WEIGHT); break; case eModifierType_DynamicPaint: UI_icon_draw(x, y, ICON_MOD_DYNAMICPAINT); break; + case eModifierType_Ocean: + UI_icon_draw(x, y, ICON_MOD_WAVE); break; default: UI_icon_draw(x, y, ICON_DOT); break; } diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 3f3ac6ce906..50eb3d394df 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2901,7 +2901,7 @@ static void rna_def_modifier_ocean(BlenderRNA *brna) srna= RNA_def_struct(brna, "OceanModifier", "Modifier"); RNA_def_struct_ui_text(srna, "Ocean Modifier", "Simulate an ocean surface"); RNA_def_struct_sdna(srna, "OceanModifierData"); - RNA_def_struct_ui_icon(srna, ICON_MOD_FLUIDSIM); + RNA_def_struct_ui_icon(srna, ICON_MOD_WAVE); /* General check if blender was built with OceanSim modifier support */ prop= RNA_def_property(srna, "is_build_enabled", PROP_BOOLEAN, PROP_NONE); From b3d5224390a2e9072ed2d7971e153880c4bb73cc Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 22 Jan 2012 22:43:21 +0000 Subject: [PATCH 027/105] Cycles UI: * Use full width for the world sample as lamp properties --- intern/cycles/blender/addon/ui.py | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 67ff79a2037..94918345db9 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -337,16 +337,13 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel): ob = context.object visibility = ob.cycles_visibility - split = layout.split() - - col = split.column() - col.prop(visibility, "camera") - col.prop(visibility, "diffuse") - col.prop(visibility, "glossy") - - col = split.column() - col.prop(visibility, "transmission") - col.prop(visibility, "shadow") + flow = layout.column_flow() + + flow.prop(visibility, "camera") + flow.prop(visibility, "diffuse") + flow.prop(visibility, "glossy") + flow.prop(visibility, "transmission") + flow.prop(visibility, "shadow") def find_node(material, nodetype): @@ -473,17 +470,13 @@ class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel): world = context.world cworld = world.cycles - split = layout.split() - col = split.column() + col = layout.column() col.prop(cworld, "sample_as_light") row = col.row() row.active = cworld.sample_as_light row.prop(cworld, "sample_map_resolution") - col = split.column() - col.label() - class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel): bl_label = "Volume" From 9dac61c74d4a56f6a7a579ee521abe07b6d09fd9 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 22 Jan 2012 22:59:21 +0000 Subject: [PATCH 028/105] Cycles Textures: * Remove the "Use nodes" button, the TextureOutput node was never ported to trunk from the cycles branch. --- intern/cycles/blender/addon/ui.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 94918345db9..f44c04e36f8 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -610,14 +610,9 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel): col.template_ID(user, "texture", new="texture.new") if tex: - row = split.row() - row.prop(tex, "use_nodes", icon="NODETREE", text="") - row.label() - - if not tex.use_nodes: - split = layout.split(percentage=0.2) - split.label(text="Type:") - split.prop(tex, "type", text="") + split = layout.split(percentage=0.2) + split.label(text="Type:") + split.prop(tex, "type", text="") class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel): From a004257e4787930f8a67a31e5c442abfa1a333dd Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 22 Jan 2012 23:13:24 +0000 Subject: [PATCH 029/105] Cycles UI: * Add World ID Block to World Shader Nodes. --- release/scripts/startup/bl_ui/space_node.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index edbcf3ecf5b..e1a599dca2e 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -58,6 +58,9 @@ class NODE_HT_header(Header): # Don't show "Use Nodes" Button when Engine is BI for Lamps if snode_id and not (scene.render.use_shading_nodes == 0 and ob.type == 'LAMP'): layout.prop(snode_id, "use_nodes") + + if snode.shader_type == 'WORLD': + layout.template_ID(scene, "world", new="world.new") elif snode.tree_type == 'TEXTURE': layout.prop(snode, "texture_type", text="", expand=True) From 62963525ced6a6a286d44eac9cca952aead2ac3f Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 22 Jan 2012 23:15:35 +0000 Subject: [PATCH 030/105] Fix for "[#29911] Crash on reading BL_ActionActuator.channelNames" The crash occurred when an action actuator was attached to a non-armature object because objects that aren't armatures do not have pose data. A NotImplementedError is now raised if someone tries to access any of the following with an action actuator attached to a non-armature object: BL_ActionActuator.channelNames BL_ActionActuator.getChannel() BL_ActionActuator.setChannel() --- .../gameengine/Converter/BL_ActionActuator.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index c63b32830b0..1d4edb45242 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -350,6 +350,12 @@ bool BL_ActionActuator::Update(double curtime, bool frame) PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) { const char *string= _PyUnicode_AsString(value); + + if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE) + { + PyErr_SetString(PyExc_NotImplementedError, "actuator.getChannel(): Only armatures support channels"); + return NULL; + } if (!string) { PyErr_SetString(PyExc_TypeError, "expected a single string"); @@ -414,6 +420,12 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, PyObject *pymat= NULL; PyObject *pyloc= NULL, *pysize= NULL, *pyquat= NULL; bPoseChannel *pchan; + + if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE) + { + PyErr_SetString(PyExc_NotImplementedError, "actuator.setChannel(): Only armatures support channels"); + return NULL; + } if(PyTuple_Size(args)==2) { if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix @@ -574,6 +586,12 @@ PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA PyObject *ret= PyList_New(0); PyObject *item; + if (self->GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE) + { + PyErr_SetString(PyExc_NotImplementedError, "actuator.channelNames: Only armatures support channels"); + return NULL; + } + bPose *pose= ((BL_ArmatureObject*)self->GetParent())->GetOrigPose(); if(pose) { From 37e128504257db0c37e31f26a626b2f92b2d10db Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Mon, 23 Jan 2012 01:35:14 +0000 Subject: [PATCH 031/105] Cloth: Add "velocity damping" to damping options. This will help with the "cloth wobbling" problem which accurs quite often when having animated characters with cloth. --- .../startup/bl_ui/properties_physics_cloth.py | 1 + source/blender/blenkernel/intern/cloth.c | 1 + source/blender/blenkernel/intern/implicit.c | 3 +++ source/blender/blenloader/intern/readfile.c | 14 ++++++++++++++ source/blender/makesdna/DNA_cloth_types.h | 3 ++- source/blender/makesdna/DNA_object_force.h | 2 ++ source/blender/makesrna/intern/rna_cloth.c | 6 ++++++ 7 files changed, 29 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py index 32b94504525..dc64aacf043 100644 --- a/release/scripts/startup/bl_ui/properties_physics_cloth.py +++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py @@ -87,6 +87,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel): col.label(text="Damping:") col.prop(cloth, "spring_damping", text="Spring") col.prop(cloth, "air_damping", text="Air") + col.prop(cloth, "vel_damping", text="Velocity") col.prop(cloth, "use_pin_cloth", text="Pinning") sub = col.column() diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 73428c889dc..33adc2af284 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -130,6 +130,7 @@ void cloth_init ( ClothModifierData *clmd ) clmd->sim_parms->presets = 2; /* cotton as start setting */ clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */ clmd->sim_parms->reset = 0; + clmd->sim_parms->vel_damping = 1.0f; /* 1.0 = no damping, 0.0 = fully dampened */ clmd->coll_parms->self_friction = 5.0; clmd->coll_parms->friction = 5.0; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 00a2de369a3..757d3ddf9ac 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1852,6 +1852,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase while(step < tf) { + // damping velocity for artistic reasons + mul_lfvectorS(id->V, id->V, clmd->sim_parms->vel_damping, numverts); + // calculate forces cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step, id->M); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 28f00f355de..0a92d2ca544 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -13038,6 +13038,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* put compatibility code here until next subversion bump */ { + { + Object *ob; + for(ob=main->object.first; ob; ob= ob->id.next) { + ModifierData *md; + + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type==eModifierType_Cloth) { + ClothModifierData *clmd = (ClothModifierData*) md; + if(clmd->sim_parms) + clmd->sim_parms->vel_damping = 1.0f; + } + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index 5c333c3fc1f..1079f1db835 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -70,6 +70,7 @@ typedef struct ClothSimSettings float goalfrict; float velocity_smooth; /* smoothing of velocities for hair */ float collider_friction; /* friction with colliders */ + float vel_damping; /* damp the velocity to speed up getting to the resting position */ int stepsPerFrame; /* Number of time steps per frame. */ int flags; /* flags, see CSIMSETT_FLAGS enum above. */ @@ -82,7 +83,7 @@ typedef struct ClothSimSettings short shapekey_rest; /* vertex group for scaling structural stiffness */ short presets; /* used for presets on GUI */ short reset; - short pad[3]; + short pad; struct EffectorWeights *effector_weights; } ClothSimSettings; diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 1707c0d3929..70aeaaacd44 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -186,6 +186,8 @@ typedef struct PointCache { int endframe; /* simulation end frame */ int editframe; /* frame being edited (runtime only) */ int last_exact; /* last exact frame that's cached */ + int last_valid; /* used for editing cache - what is the last baked frame */ + int pad; /* for external cache files */ int totpoint; /* number of cached points */ diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index db6cb28bd98..839c67f6297 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -289,6 +289,12 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Air Damping", "Air has normally some thickness which slows falling things down"); RNA_def_property_update(prop, 0, "rna_cloth_update"); + prop= RNA_def_property(srna, "vel_damping", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "vel_damping"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Velocity Damping", "Damp velocity to help cloth reach the resting position faster. [1.0 = no damping, 0.0 = fully dampened]"); + RNA_def_property_update(prop, 0, "rna_cloth_update"); + prop= RNA_def_property(srna, "use_pin_cloth", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_GOAL); RNA_def_property_ui_text(prop, "Pin Cloth", "Enable pinning of cloth vertices to other objects/positions"); From be69b8b4fd6432694ff9b3faeefe281344b77081 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Mon, 23 Jan 2012 03:13:55 +0000 Subject: [PATCH 032/105] modifier Apply as Shape is now Apply as Shape Key. Was confusing some users --- source/blender/editors/interface/interface_templates.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 1e5309fa603..2b0a406a421 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -850,7 +850,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply"), 0, "apply_as", MODIFIER_APPLY_DATA); if (modifier_sameTopology(md) && !modifier_nonGeometrical(md)) - uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply as Shape"), 0, "apply_as", MODIFIER_APPLY_SHAPE); + uiItemEnumO(row, "OBJECT_OT_modifier_apply", IFACE_("Apply as Shape Key"), 0, "apply_as", MODIFIER_APPLY_SHAPE); } uiBlockClearButLock(block); From d2f8be9aa24551e585fa39a82c56a3ffe85b825b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 23 Jan 2012 08:48:52 +0000 Subject: [PATCH 033/105] Fix for compilation error when using scons and carve is disabled --- intern/boolop/SConscript | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/boolop/SConscript b/intern/boolop/SConscript index 0efed532cb9..1c8c912614d 100644 --- a/intern/boolop/SConscript +++ b/intern/boolop/SConscript @@ -8,6 +8,7 @@ incs += ' ../../source/blender/blenlib' defs = [] if not env['WITH_BF_CARVE']: + import os sources = env.Glob('intern/*.cpp') sources.remove('intern' + os.sep + 'BOP_CarveInterface.cpp') else: From 74b4fd26d2d1dde537a46f9237839c057cd03aaf Mon Sep 17 00:00:00 2001 From: Andrew Hale Date: Mon, 23 Jan 2012 13:29:29 +0000 Subject: [PATCH 034/105] In order to maintain consistency with other uses of .remove(), these functions will be removed and reimplemented after the BMesh merge. The main issue in an implementation of these functions is the need to constantly edit the vertex array and subsequently update the face and edge arrays. --- source/blender/makesrna/intern/rna_mesh.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 689b19b9371..2ada09f2df1 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1699,10 +1699,11 @@ static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "add", "ED_mesh_vertices_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add", 0, INT_MAX); - +#if 0 // Remove until BMesh merge func= RNA_def_function(srna, "remove", "ED_mesh_vertices_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to remove", 0, INT_MAX); +#endif } /* mesh.edges */ @@ -1722,10 +1723,11 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "add", "ED_mesh_edges_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to add", 0, INT_MAX); - +#if 0 // Remove until BMesh merge func= RNA_def_function(srna, "remove", "ED_mesh_edges_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to remove", 0, INT_MAX); +#endif } /* mesh.faces */ @@ -1755,10 +1757,11 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "add", "ED_mesh_faces_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to add", 0, INT_MAX); - +#if 0 // Remove until BMesh merge func= RNA_def_function(srna, "remove", "ED_mesh_faces_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to remove", 0, INT_MAX); +#endif } /* mesh.vertex_colors */ From 690c77dd7de19783adb228be51b099ed19c22d5a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 23 Jan 2012 17:43:41 +0000 Subject: [PATCH 035/105] Fix #29934: New Carve library can't execute boolean operations in some cases Issue was caused by left boolean operand consist of several intersecting manifolds which make Carve triangulator confused and which can't be resolved in general case. Added mesh pre-processing before actual applying boolean operator on it. This preprocessing applies union operation on intersecting manifolds of the same object so intersection edge loop with second object wouldn't confuse tesselator and correct result would be returned. Detecting of intersecting manifolds is based on AABB intersection check which leads to some extra union operation called, but it's possible to speed things up from Carve side so union operation of two not intersecting meshes would work faster. Additional condition for running union for manifold is this manifolds intersects AABB of second operand, so mesh topology wouldn't be changed at all in areas where there's definitely no intersection between operands. It might be improved so only manifolds which actually intersects second operand would be joined together, but it'll slow things down a bit and prefer to do it only if it'll be really a problem. Additional change is fixed memory leak when boolean operation fails to run - it was missed "delete" call if exception happens in Carve library. From side effects of this change might be named boolean operation between suzanne and another object: suzanne is consist of three intersecting open manifolds, so this new meshes preprocessing leads to missed eyes in result because of failure of merging two open manifolds. Don't think making suzanne work for all setups should really be a goal, it's a bit crappy mesh for CSG algorithms. --- intern/boolop/intern/BOP_CarveInterface.cpp | 173 +++++++++++++++++- .../modifiers/intern/MOD_boolean_util.c | 2 +- 2 files changed, 172 insertions(+), 3 deletions(-) diff --git a/intern/boolop/intern/BOP_CarveInterface.cpp b/intern/boolop/intern/BOP_CarveInterface.cpp index 4db4fdd819d..e69287e34f4 100644 --- a/intern/boolop/intern/BOP_CarveInterface.cpp +++ b/intern/boolop/intern/BOP_CarveInterface.cpp @@ -36,6 +36,8 @@ #include #include +#include + typedef unsigned int uint; #define MAX(x,y) ((x)>(y)?(x):(y)) @@ -61,10 +63,159 @@ static int isFacePlanar(CSG_IFace &face, std::vector &ver return 1; } +static carve::mesh::MeshSet<3> *Carve_meshSetFromMeshes(std::vector::mesh_t*> &meshes) +{ + std::vector::mesh_t*> new_meshes; + + std::vector::mesh_t*>::iterator it = meshes.begin(); + for(; it!=meshes.end(); it++) { + carve::mesh::MeshSet<3>::mesh_t *mesh = *it; + carve::mesh::MeshSet<3>::mesh_t *new_mesh = new carve::mesh::MeshSet<3>::mesh_t(mesh->faces); + + new_meshes.push_back(new_mesh); + } + + return new carve::mesh::MeshSet<3>(new_meshes); +} + +static void Carve_getIntersectedOperandMeshes(std::vector::mesh_t*> &meshes, + std::vector::aabb_t> &precomputedAABB, + carve::mesh::MeshSet<3>::aabb_t &otherAABB, + std::vector::mesh_t*> &operandMeshes) +{ + std::vector::mesh_t*>::iterator it = meshes.begin(); + std::vector::aabb_t>::iterator aabb_it = precomputedAABB.begin(); + std::vector::aabb_t> usedAABB; + + while(it != meshes.end()) { + carve::mesh::MeshSet<3>::mesh_t *mesh = *it; + carve::mesh::MeshSet<3>::aabb_t aabb = mesh->getAABB(); + bool isIntersect = false; + + std::vector::aabb_t>::iterator used_it = usedAABB.begin(); + for(; used_it!=usedAABB.end(); used_it++) { + carve::mesh::MeshSet<3>::aabb_t usedAABB = *used_it; + + if(usedAABB.intersects(aabb) && usedAABB.intersects(otherAABB)) { + isIntersect = true; + break; + } + } + + if(!isIntersect) { + operandMeshes.push_back(mesh); + usedAABB.push_back(aabb); + + it = meshes.erase(it); + aabb_it = precomputedAABB.erase(aabb_it); + } + else { + it++; + aabb_it++; + } + } +} + +static carve::mesh::MeshSet<3> *Carve_getIntersectedOperand(std::vector::mesh_t*> &meshes, + std::vector::aabb_t> &precomputedAABB, + carve::mesh::MeshSet<3>::aabb_t &otherAABB) +{ + std::vector::mesh_t*> operandMeshes; + Carve_getIntersectedOperandMeshes(meshes, precomputedAABB, otherAABB, operandMeshes); + + return Carve_meshSetFromMeshes(operandMeshes); +} + +static carve::mesh::MeshSet<3> *Carve_unionIntersectingMeshes(carve::mesh::MeshSet<3> *poly, + std::vector::aabb_t> &precomputedAABB, + carve::mesh::MeshSet<3>::aabb_t &otherAABB, + carve::interpolate::FaceAttr &oface_num) +{ + if(poly->meshes.size()<=1) + return poly; + + carve::csg::CSG csg; + + oface_num.installHooks(csg); + csg.hooks.registerHook(new carve::csg::CarveTriangulator, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT); + + std::vector::mesh_t*> orig_meshes = std::vector::mesh_t*>(poly->meshes.begin(), poly->meshes.end()); + + carve::mesh::MeshSet<3> *left = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB); + + while(orig_meshes.size()) { + carve::mesh::MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB); + + try { + carve::mesh::MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE); + delete left; + delete right; + + left = result; + } + catch(carve::exception e) { + std::cerr << "CSG failed, exception " << e.str() << std::endl; + + delete right; + } + catch(...) { + delete left; + delete right; + + throw "Unknown error in Carve library"; + } + } + + return left; +} + +static carve::mesh::MeshSet<3>::aabb_t Carve_computeAABB(carve::mesh::MeshSet<3> *poly, + std::vector::aabb_t> &precomputedAABB) +{ + carve::mesh::MeshSet<3>::aabb_t overallAABB; + std::vector::mesh_t*>::iterator it = poly->meshes.begin(); + + for(; it!=poly->meshes.end(); it++) { + carve::mesh::MeshSet<3>::aabb_t aabb; + carve::mesh::MeshSet<3>::mesh_t *mesh = *it; + + aabb = mesh->getAABB(); + precomputedAABB.push_back(aabb); + + overallAABB.unionAABB(aabb); + } + + return overallAABB; +} + +static void Carve_prepareOperands(carve::mesh::MeshSet<3> **left_r, carve::mesh::MeshSet<3> **right_r, + carve::interpolate::FaceAttr &oface_num) +{ + carve::mesh::MeshSet<3> *left, *right; + + std::vector::aabb_t> left_precomputedAABB; + std::vector::aabb_t> right_precomputedAABB; + + carve::mesh::MeshSet<3>::aabb_t leftAABB = Carve_computeAABB(*left_r, left_precomputedAABB); + carve::mesh::MeshSet<3>::aabb_t rightAABB = Carve_computeAABB(*right_r, right_precomputedAABB); + + left = Carve_unionIntersectingMeshes(*left_r, left_precomputedAABB, rightAABB, oface_num); + right = Carve_unionIntersectingMeshes(*right_r, right_precomputedAABB, leftAABB, oface_num); + + if(left != *left_r) + delete *left_r; + + if(right != *right_r) + delete *right_r; + + *left_r = left; + *right_r = right; +} + static carve::mesh::MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor& face_it, CSG_VertexIteratorDescriptor& vertex_it, carve::interpolate::FaceAttr &oface_num, - uint &num_origfaces ) + uint &num_origfaces) { CSG_IVertex vertex; std::vector vertices; @@ -360,6 +511,8 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType, left = Carve_addMesh(obAFaces, obAVertices, oface_num, num_origfaces ); right = Carve_addMesh(obBFaces, obBVertices, oface_num, num_origfaces ); + Carve_prepareOperands(&left, &right, oface_num); + min.x = max.x = left->vertex_storage[0].v.x; min.y = max.y = left->vertex_storage[0].v.y; min.z = max.z = left->vertex_storage[0].v.z; @@ -390,10 +543,26 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType, csg.hooks.registerHook(new carve::csg::CarveTriangulator, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT); oface_num.installHooks(csg); - output = csg.compute( left, right, op, NULL, carve::csg::CSG::CLASSIFY_EDGE); + + try { + output = csg.compute( left, right, op, NULL, carve::csg::CSG::CLASSIFY_EDGE); + } + catch(carve::exception e) { + std::cerr << "CSG failed, exception " << e.str() << std::endl; + } + catch(...) { + delete left; + delete right; + + throw "Unknown error in Carve library"; + } + delete left; delete right; + if(!output) + return BOP_ERROR; + output->transform(rev_r); *outputMesh = Carve_exportMesh( output, oface_num, num_origfaces); diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index afd16b41131..fa829bcd44b 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -522,7 +522,7 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( CSG_FreeFaceDescriptor(&fd_o); } else - printf("Unknown internal error in boolean"); + printf("Unknown internal error in boolean\n"); CSG_FreeBooleanOperation(bool_op); From 7d22a41a3dd7ec26c2a3ad480d193d8b6a747d4b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 23 Jan 2012 17:44:05 +0000 Subject: [PATCH 036/105] Carve booleans: code and style cleanup --- intern/boolop/intern/BOP_CarveInterface.cpp | 139 ++++++++++---------- 1 file changed, 71 insertions(+), 68 deletions(-) diff --git a/intern/boolop/intern/BOP_CarveInterface.cpp b/intern/boolop/intern/BOP_CarveInterface.cpp index e69287e34f4..b8482a25b61 100644 --- a/intern/boolop/intern/BOP_CarveInterface.cpp +++ b/intern/boolop/intern/BOP_CarveInterface.cpp @@ -38,6 +38,7 @@ #include +using namespace carve::mesh; typedef unsigned int uint; #define MAX(x,y) ((x)>(y)?(x):(y)) @@ -63,38 +64,38 @@ static int isFacePlanar(CSG_IFace &face, std::vector &ver return 1; } -static carve::mesh::MeshSet<3> *Carve_meshSetFromMeshes(std::vector::mesh_t*> &meshes) +static MeshSet<3> *Carve_meshSetFromMeshes(std::vector::mesh_t*> &meshes) { - std::vector::mesh_t*> new_meshes; + std::vector::mesh_t*> new_meshes; - std::vector::mesh_t*>::iterator it = meshes.begin(); + std::vector::mesh_t*>::iterator it = meshes.begin(); for(; it!=meshes.end(); it++) { - carve::mesh::MeshSet<3>::mesh_t *mesh = *it; - carve::mesh::MeshSet<3>::mesh_t *new_mesh = new carve::mesh::MeshSet<3>::mesh_t(mesh->faces); + MeshSet<3>::mesh_t *mesh = *it; + MeshSet<3>::mesh_t *new_mesh = new MeshSet<3>::mesh_t(mesh->faces); new_meshes.push_back(new_mesh); } - return new carve::mesh::MeshSet<3>(new_meshes); + return new MeshSet<3>(new_meshes); } -static void Carve_getIntersectedOperandMeshes(std::vector::mesh_t*> &meshes, - std::vector::aabb_t> &precomputedAABB, - carve::mesh::MeshSet<3>::aabb_t &otherAABB, - std::vector::mesh_t*> &operandMeshes) +static void Carve_getIntersectedOperandMeshes(std::vector::mesh_t*> &meshes, + std::vector::aabb_t> &precomputedAABB, + MeshSet<3>::aabb_t &otherAABB, + std::vector::mesh_t*> &operandMeshes) { - std::vector::mesh_t*>::iterator it = meshes.begin(); - std::vector::aabb_t>::iterator aabb_it = precomputedAABB.begin(); - std::vector::aabb_t> usedAABB; + std::vector::mesh_t*>::iterator it = meshes.begin(); + std::vector::aabb_t>::iterator aabb_it = precomputedAABB.begin(); + std::vector::aabb_t> usedAABB; while(it != meshes.end()) { - carve::mesh::MeshSet<3>::mesh_t *mesh = *it; - carve::mesh::MeshSet<3>::aabb_t aabb = mesh->getAABB(); + MeshSet<3>::mesh_t *mesh = *it; + MeshSet<3>::aabb_t aabb = mesh->getAABB(); bool isIntersect = false; - std::vector::aabb_t>::iterator used_it = usedAABB.begin(); + std::vector::aabb_t>::iterator used_it = usedAABB.begin(); for(; used_it!=usedAABB.end(); used_it++) { - carve::mesh::MeshSet<3>::aabb_t usedAABB = *used_it; + MeshSet<3>::aabb_t usedAABB = *used_it; if(usedAABB.intersects(aabb) && usedAABB.intersects(otherAABB)) { isIntersect = true; @@ -116,20 +117,20 @@ static void Carve_getIntersectedOperandMeshes(std::vector *Carve_getIntersectedOperand(std::vector::mesh_t*> &meshes, - std::vector::aabb_t> &precomputedAABB, - carve::mesh::MeshSet<3>::aabb_t &otherAABB) +static MeshSet<3> *Carve_getIntersectedOperand(std::vector::mesh_t*> &meshes, + std::vector::aabb_t> &precomputedAABB, + MeshSet<3>::aabb_t &otherAABB) { - std::vector::mesh_t*> operandMeshes; + std::vector::mesh_t*> operandMeshes; Carve_getIntersectedOperandMeshes(meshes, precomputedAABB, otherAABB, operandMeshes); return Carve_meshSetFromMeshes(operandMeshes); } -static carve::mesh::MeshSet<3> *Carve_unionIntersectingMeshes(carve::mesh::MeshSet<3> *poly, - std::vector::aabb_t> &precomputedAABB, - carve::mesh::MeshSet<3>::aabb_t &otherAABB, - carve::interpolate::FaceAttr &oface_num) +static MeshSet<3> *Carve_unionIntersectingMeshes(MeshSet<3> *poly, + std::vector::aabb_t> &precomputedAABB, + MeshSet<3>::aabb_t &otherAABB, + carve::interpolate::FaceAttr &oface_num) { if(poly->meshes.size()<=1) return poly; @@ -139,15 +140,17 @@ static carve::mesh::MeshSet<3> *Carve_unionIntersectingMeshes(carve::mesh::MeshS oface_num.installHooks(csg); csg.hooks.registerHook(new carve::csg::CarveTriangulator, carve::csg::CSG::Hooks::PROCESS_OUTPUT_FACE_BIT); - std::vector::mesh_t*> orig_meshes = std::vector::mesh_t*>(poly->meshes.begin(), poly->meshes.end()); + std::vector::mesh_t*> orig_meshes = + std::vector::mesh_t*>(poly->meshes.begin(), poly->meshes.end()); - carve::mesh::MeshSet<3> *left = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB); + MeshSet<3> *left = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB); while(orig_meshes.size()) { - carve::mesh::MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB); + MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB); try { - carve::mesh::MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE); + MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE); + delete left; delete right; @@ -169,15 +172,15 @@ static carve::mesh::MeshSet<3> *Carve_unionIntersectingMeshes(carve::mesh::MeshS return left; } -static carve::mesh::MeshSet<3>::aabb_t Carve_computeAABB(carve::mesh::MeshSet<3> *poly, - std::vector::aabb_t> &precomputedAABB) +static MeshSet<3>::aabb_t Carve_computeAABB(MeshSet<3> *poly, + std::vector::aabb_t> &precomputedAABB) { - carve::mesh::MeshSet<3>::aabb_t overallAABB; - std::vector::mesh_t*>::iterator it = poly->meshes.begin(); + MeshSet<3>::aabb_t overallAABB; + std::vector::mesh_t*>::iterator it = poly->meshes.begin(); for(; it!=poly->meshes.end(); it++) { - carve::mesh::MeshSet<3>::aabb_t aabb; - carve::mesh::MeshSet<3>::mesh_t *mesh = *it; + MeshSet<3>::aabb_t aabb; + MeshSet<3>::mesh_t *mesh = *it; aabb = mesh->getAABB(); precomputedAABB.push_back(aabb); @@ -188,16 +191,16 @@ static carve::mesh::MeshSet<3>::aabb_t Carve_computeAABB(carve::mesh::MeshSet<3> return overallAABB; } -static void Carve_prepareOperands(carve::mesh::MeshSet<3> **left_r, carve::mesh::MeshSet<3> **right_r, +static void Carve_prepareOperands(MeshSet<3> **left_r, MeshSet<3> **right_r, carve::interpolate::FaceAttr &oface_num) { - carve::mesh::MeshSet<3> *left, *right; + MeshSet<3> *left, *right; - std::vector::aabb_t> left_precomputedAABB; - std::vector::aabb_t> right_precomputedAABB; + std::vector::aabb_t> left_precomputedAABB; + std::vector::aabb_t> right_precomputedAABB; - carve::mesh::MeshSet<3>::aabb_t leftAABB = Carve_computeAABB(*left_r, left_precomputedAABB); - carve::mesh::MeshSet<3>::aabb_t rightAABB = Carve_computeAABB(*right_r, right_precomputedAABB); + MeshSet<3>::aabb_t leftAABB = Carve_computeAABB(*left_r, left_precomputedAABB); + MeshSet<3>::aabb_t rightAABB = Carve_computeAABB(*right_r, right_precomputedAABB); left = Carve_unionIntersectingMeshes(*left_r, left_precomputedAABB, rightAABB, oface_num); right = Carve_unionIntersectingMeshes(*right_r, right_precomputedAABB, leftAABB, oface_num); @@ -212,10 +215,10 @@ static void Carve_prepareOperands(carve::mesh::MeshSet<3> **left_r, carve::mesh: *right_r = right; } -static carve::mesh::MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor& face_it, - CSG_VertexIteratorDescriptor& vertex_it, - carve::interpolate::FaceAttr &oface_num, - uint &num_origfaces) +static MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor &face_it, + CSG_VertexIteratorDescriptor &vertex_it, + carve::interpolate::FaceAttr &oface_num, + uint &num_origfaces) { CSG_IVertex vertex; std::vector vertices; @@ -277,12 +280,12 @@ static carve::mesh::MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor& face_i } } - carve::mesh::MeshSet<3> *poly = new carve::mesh::MeshSet<3> (vertices, numfaces, f); + MeshSet<3> *poly = new MeshSet<3> (vertices, numfaces, f); uint i; - carve::mesh::MeshSet<3>::face_iter face_iter = poly->faceBegin(); + MeshSet<3>::face_iter face_iter = poly->faceBegin(); for (i = 0; face_iter != poly->faceEnd(); ++face_iter, ++i) { - carve::mesh::MeshSet<3>::face_t *face = *face_iter; + MeshSet<3>::face_t *face = *face_iter; oface_num.setAttribute(face, forig[i]); } @@ -290,8 +293,8 @@ static carve::mesh::MeshSet<3> *Carve_addMesh(CSG_FaceIteratorDescriptor& face_i } // check whether two faces share an edge, and if so merge them -static uint quadMerge(std::map::vertex_t*, uint> *vertexToIndex_map, - carve::mesh::MeshSet<3>::face_t *f1, carve::mesh::MeshSet<3>::face_t *f2, +static uint quadMerge(std::map::vertex_t*, uint> *vertexToIndex_map, + MeshSet<3>::face_t *f1, MeshSet<3>::face_t *f2, uint v, uint quad[4]) { uint current, n1, p1, n2, p2; @@ -339,23 +342,23 @@ static uint quadMerge(std::map::vertex_t*, uint> *vertex return 0; } -static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::interpolate::FaceAttr &oface_num, +static BSP_CSGMesh *Carve_exportMesh(MeshSet<3>* &poly, carve::interpolate::FaceAttr &oface_num, uint num_origfaces) { uint i; - BSP_CSGMesh* outputMesh = BSP_CSGMesh::New(); + BSP_CSGMesh *outputMesh = BSP_CSGMesh::New(); if (outputMesh == NULL) return NULL; - std::vector* vertices = new std::vector; + std::vector *vertices = new std::vector; outputMesh->SetVertices(vertices); - std::map::vertex_t*, uint> vertexToIndex_map; - std::vector::vertex_t>::iterator it = poly->vertex_storage.begin(); + std::map::vertex_t*, uint> vertexToIndex_map; + std::vector::vertex_t>::iterator it = poly->vertex_storage.begin(); for (i = 0; it != poly->vertex_storage.end(); ++i, ++it) { - carve::mesh::MeshSet<3>::vertex_t *vertex = &(*it); + MeshSet<3>::vertex_t *vertex = &(*it); vertexToIndex_map[vertex] = i; } @@ -368,13 +371,13 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte } // build vectors of faces for each original face and each vertex - std::vector< std::vector > vi(poly->vertex_storage.size()); - std::vector< std::vector > ofaces(num_origfaces); - carve::mesh::MeshSet<3>::face_iter face_iter = poly->faceBegin(); + std::vector> vi(poly->vertex_storage.size()); + std::vector> ofaces(num_origfaces); + MeshSet<3>::face_iter face_iter = poly->faceBegin(); for (i = 0; face_iter != poly->faceEnd(); ++face_iter, ++i) { - carve::mesh::MeshSet<3>::face_t *f = *face_iter; + MeshSet<3>::face_t *f = *face_iter; ofaces[oface_num.getAttribute(f)].push_back(i); - carve::mesh::MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin(); + MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin(); for (; edge_iter != f->end(); ++edge_iter) { int index = vertexToIndex_map[edge_iter->vert]; vi[index].push_back(i); @@ -393,7 +396,7 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte uint findex = fl.back(); fl.pop_back(); - carve::mesh::MeshSet<3>::face_t *f = *(poly->faceBegin() + findex); + MeshSet<3>::face_t *f = *(poly->faceBegin() + findex); // add all information except vertices to the output mesh outputMesh->FaceSet().push_back(BSP_MFace()); @@ -407,7 +410,7 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte // the original face uint result = 0; - carve::mesh::MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin(); + MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin(); for (; edge_iter != f->end(); ++edge_iter) { int v = vertexToIndex_map[edge_iter->vert]; for (uint pos2=0; !result && pos2 < vi[v].size();pos2++) { @@ -417,7 +420,7 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte if (findex == otherf) continue; - carve::mesh::MeshSet<3>::face_t *f2 = *(poly->faceBegin() + otherf); + MeshSet<3>::face_t *f2 = *(poly->faceBegin() + otherf); // if other face doesn't have the same original face, // ignore it also @@ -453,7 +456,7 @@ static BSP_CSGMesh* Carve_exportMesh(carve::mesh::MeshSet<3>* &poly, carve::inte outFace.m_verts.push_back(quadverts[2]); outFace.m_verts.push_back(quadverts[3]); } else { - carve::mesh::MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin(); + MeshSet<3>::face_t::edge_iter_t edge_iter = f->begin(); for (; edge_iter != f->end(); ++edge_iter) { //int index = ofacevert_num.getAttribute(f, edge_iter.idx()); int index = vertexToIndex_map[edge_iter->vert]; @@ -488,7 +491,7 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType, CSG_VertexIteratorDescriptor obBVertices) { carve::csg::CSG::OP op; - carve::mesh::MeshSet<3> *left, *right, *output; + MeshSet<3> *left, *right, *output; carve::csg::CSG csg; carve::geom3d::Vector min, max; carve::interpolate::FaceAttr oface_num; @@ -545,7 +548,7 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType, oface_num.installHooks(csg); try { - output = csg.compute( left, right, op, NULL, carve::csg::CSG::CLASSIFY_EDGE); + output = csg.compute(left, right, op, NULL, carve::csg::CSG::CLASSIFY_EDGE); } catch(carve::exception e) { std::cerr << "CSG failed, exception " << e.str() << std::endl; @@ -565,7 +568,7 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType, output->transform(rev_r); - *outputMesh = Carve_exportMesh( output, oface_num, num_origfaces); + *outputMesh = Carve_exportMesh(output, oface_num, num_origfaces); delete output; return BOP_OK; From e079bf8184df076f9ee48ca4f7fdd08d09bc9de1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 23 Jan 2012 17:44:19 +0000 Subject: [PATCH 037/105] Carve booleans: corrected copyright header --- intern/boolop/intern/BOP_CarveInterface.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/intern/boolop/intern/BOP_CarveInterface.cpp b/intern/boolop/intern/BOP_CarveInterface.cpp index b8482a25b61..20e3790b3fe 100644 --- a/intern/boolop/intern/BOP_CarveInterface.cpp +++ b/intern/boolop/intern/BOP_CarveInterface.cpp @@ -15,12 +15,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * The Original Code is Copyright (C) 2010 by the Blender Foundation. * All rights reserved. * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Ken Hughes, + * Sergey Sharybin. * * ***** END GPL LICENSE BLOCK ***** */ From 69b7a3a72af3cea7783775ab7e9b800b81fbcced Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 23 Jan 2012 17:49:56 +0000 Subject: [PATCH 038/105] Fix compilation error caused by code cleanup --- intern/boolop/intern/BOP_CarveInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/boolop/intern/BOP_CarveInterface.cpp b/intern/boolop/intern/BOP_CarveInterface.cpp index 20e3790b3fe..274d9cac0cf 100644 --- a/intern/boolop/intern/BOP_CarveInterface.cpp +++ b/intern/boolop/intern/BOP_CarveInterface.cpp @@ -372,8 +372,8 @@ static BSP_CSGMesh *Carve_exportMesh(MeshSet<3>* &poly, carve::interpolate::Face } // build vectors of faces for each original face and each vertex - std::vector> vi(poly->vertex_storage.size()); - std::vector> ofaces(num_origfaces); + std::vector > vi(poly->vertex_storage.size()); + std::vector > ofaces(num_origfaces); MeshSet<3>::face_iter face_iter = poly->faceBegin(); for (i = 0; face_iter != poly->faceEnd(); ++face_iter, ++i) { MeshSet<3>::face_t *f = *face_iter; From be0be0b1a9a8520f73cfdead9e1ae00c674b6233 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 23 Jan 2012 19:32:00 +0000 Subject: [PATCH 039/105] Fix #29970: Crash trying to track disabled marker --- source/blender/editors/space_clip/tracking_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 6cf8a988571..7fcd761fc49 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1208,7 +1208,7 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip) track= tracksbase->first; while(track) { if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { - MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, framenr); + MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr); if (!marker || (marker->flag&MARKER_DISABLED) == 0) tot++; From 99dc4ec69170a9a68e8ab20eede64bb88cba006f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Jan 2012 19:42:22 +0000 Subject: [PATCH 040/105] BLI_array_reserve from bmesh. --- source/blender/blenlib/BLI_array.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index bd14793e0f9..a5453f1537b 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -140,6 +140,10 @@ (&arr[_##arr##_count - 1]) \ ) +#define BLI_array_reserve(arr, num) \ + BLI_array_growitems(arr, num), (void)(_##arr##_count -= num) + + #define BLI_array_free(arr) \ if (arr && (char *)arr != _##arr##_static) { \ BLI_array_fake_user(arr); \ From 5585b3e9084a96f54c5b75479a492b504252351b Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 23 Jan 2012 19:53:23 +0000 Subject: [PATCH 041/105] rst bge touch ups: making the title of the examples slightly more noticeable - it's still not correct, comparing to the other examples, but at least it looks okish. - fixed some small typos --- doc/python_api/examples/bge.constraints.py | 2 +- doc/python_api/examples/bge.texture.1.py | 4 ++-- doc/python_api/examples/bge.texture.py | 2 +- doc/python_api/rst/bge.constraints.rst | 5 +++++ doc/python_api/rst/bge.texture.rst | 10 ++++++++++ doc/python_api/rst/bge.types.rst | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/python_api/examples/bge.constraints.py b/doc/python_api/examples/bge.constraints.py index de2f7e0a39d..e76fc3dd13b 100644 --- a/doc/python_api/examples/bge.constraints.py +++ b/doc/python_api/examples/bge.constraints.py @@ -1,6 +1,6 @@ """ Basic Physics Constraint -++++++++++++++++++++++ +++++++++++++++++++++++++ Example of how to create a hinge Physics Constraint between two objects. """ from bge import logic diff --git a/doc/python_api/examples/bge.texture.1.py b/doc/python_api/examples/bge.texture.1.py index 918ffc9772d..fba369739f7 100644 --- a/doc/python_api/examples/bge.texture.1.py +++ b/doc/python_api/examples/bge.texture.1.py @@ -1,6 +1,6 @@ """ -Texture replacement -++++++++++++++++++++++ +Texture Replacement ++++++++++++++++++++ Example of how to replace a texture in game with an external image. createTexture() and removeTexture() are to be called from a module Python Controller. diff --git a/doc/python_api/examples/bge.texture.py b/doc/python_api/examples/bge.texture.py index 70e4d6d9377..1ba0b99fc27 100644 --- a/doc/python_api/examples/bge.texture.py +++ b/doc/python_api/examples/bge.texture.py @@ -1,6 +1,6 @@ """ Basic Video Playback -++++++++++++++++++++++ +++++++++++++++++++++ Example of how to replace a texture in game with a video. It needs to run everyframe """ import bge diff --git a/doc/python_api/rst/bge.constraints.rst b/doc/python_api/rst/bge.constraints.rst index da0a358dfed..83f2a6b4950 100644 --- a/doc/python_api/rst/bge.constraints.rst +++ b/doc/python_api/rst/bge.constraints.rst @@ -5,6 +5,11 @@ Physics Constraints (bge.constraints) .. module:: bge.constraints .. literalinclude:: ../examples/bge.constraints.py + :language: rest + :lines: 2-4 + +.. literalinclude:: ../examples/bge.constraints.py + :lines: 6- .. function:: createConstraint(physicsid, physicsid2, constrainttype, [pivotX, pivotY, pivotZ, [axisX, axisY, axisZ, [flag]]]]) diff --git a/doc/python_api/rst/bge.texture.rst b/doc/python_api/rst/bge.texture.rst index 0abefcbea82..07d83f66bd4 100644 --- a/doc/python_api/rst/bge.texture.rst +++ b/doc/python_api/rst/bge.texture.rst @@ -37,8 +37,18 @@ When the texture object is deleted, the new texture is deleted and the old textu .. module:: bge.texture .. literalinclude:: ../examples/bge.texture.py + :language: rest + :lines: 2-4 + +.. literalinclude:: ../examples/bge.texture.py + :lines: 6- .. literalinclude:: ../examples/bge.texture.1.py + :language: rest + :lines: 2-6 + +.. literalinclude:: ../examples/bge.texture.1.py + :lines: 8- .. class:: VideoFFmpeg(file [, capture=-1, rate=25.0, width=0, height=0]) diff --git a/doc/python_api/rst/bge.types.rst b/doc/python_api/rst/bge.types.rst index 6988f90cc1e..735ad037175 100644 --- a/doc/python_api/rst/bge.types.rst +++ b/doc/python_api/rst/bge.types.rst @@ -954,7 +954,7 @@ Game Types (bge.types) .. deprecated:: use :data:`localPosition` and :data:`worldPosition`. - :type: :class:`mathurils.Vector` + :type: :class:`mathutils.Vector` .. attribute:: orientation From ebe01d06bcb3ed42d8466fdf133fe8810c5ecd2d Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 23 Jan 2012 22:57:46 +0000 Subject: [PATCH 042/105] Misc picky edits to UI messages. --- release/scripts/startup/bl_ui/properties_particle.py | 2 +- source/blender/editors/sculpt_paint/paint_ops.c | 2 +- .../blender/editors/space_outliner/outliner_edit.c | 2 +- source/blender/editors/uvedit/uvedit_smart_stitch.c | 12 ++++++++---- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 6 ++++-- source/blender/makesrna/intern/rna_cloth.c | 4 +++- source/blender/makesrna/intern/rna_scene.c | 8 ++++---- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index 5e68351d9e6..4e511f18cd4 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -911,7 +911,7 @@ class PARTICLE_PT_render(ParticleButtonsPanel, Panel): col.prop_search(psys, "billboard_time_index_uv", ob.data, "uv_textures") split = layout.split(percentage=0.33) - split.label(text="Split uv's:") + split.label(text="Split UVs:") split.prop(part, "billboard_uv_split", text="Number of splits") if psys: diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index c2026b30ab2..757f501d296 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -359,7 +359,7 @@ static void BRUSH_OT_uv_sculpt_tool_set(wmOperatorType *ot) extern EnumPropertyItem uv_sculpt_tool_items[]; /* identifiers */ ot->name = "UV Sculpt Tool Set"; - ot->description = "Set the uv sculpt tool"; + ot->description = "Set the UV sculpt tool"; ot->idname = "BRUSH_OT_uv_sculpt_tool_set"; /* api callbacks */ diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 12f4af3637e..562cbf45e86 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1689,7 +1689,7 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot) { /* identifiers */ ot->name= "Drop to Clear Parent"; - ot->description = "Drag to clear parent in outliner"; + ot->description = "Drag to clear parent in Outliner"; ot->idname= "OUTLINER_OT_parent_clear"; /* api callbacks */ diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index e99a90f34c5..b2a9b6bb572 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1454,11 +1454,15 @@ void UV_OT_stitch(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "use_limit", 0, "Use Limit", "Stitch UVs within a specified limit distance"); - RNA_def_boolean(ot->srna, "snap_islands", 1, "Snap Islands", "Snap islands together. On edge stitch mode, rotates the islands too"); + RNA_def_boolean(ot->srna, "snap_islands", 1, "Snap Islands", + "Snap islands together (on edge stitch mode, rotates the islands too)"); - RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, FLT_MAX, "Limit", "Limit distance in normalized coordinates", 0.0, FLT_MAX); - RNA_def_int(ot->srna, "static_island", 0, 0, INT_MAX, "Static Island", "Island that stays in place when stitching islands", 0, INT_MAX); - RNA_def_boolean(ot->srna, "midpoint_snap", 0, "Snap At Midpoint", "Uv's are stitched at midpoint instead of at static island"); + RNA_def_float(ot->srna, "limit", 0.01f, 0.0f, FLT_MAX, "Limit", + "Limit distance in normalized coordinates", 0.0, FLT_MAX); + RNA_def_int(ot->srna, "static_island", 0, 0, INT_MAX, "Static Island", + "Island that stays in place when stitching islands", 0, INT_MAX); + RNA_def_boolean(ot->srna, "midpoint_snap", 0, "Snap At Midpoint", + "UVs are stitched at midpoint instead of at static island"); prop = RNA_def_collection_runtime(ot->srna, "selection", &RNA_SelectedUvElement, "Selection", ""); /* Selection should not be editable or viewed in toolbar */ RNA_def_property_flag(prop, PROP_HIDDEN); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 3ed4df66778..5eadb0a71c5 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1204,8 +1204,10 @@ void UV_OT_unwrap(wmOperatorType *ot) "Virtual fill holes in mesh before unwrapping, to better avoid overlaps and preserve symmetry"); RNA_def_boolean(ot->srna, "correct_aspect", 1, "Correct Aspect", "Map UVs taking image aspect ratio into account"); - RNA_def_boolean(ot->srna, "use_subsurf_data", 0, "Use Subsurf Data", "Map UV's taking vertex position after subsurf into account"); - RNA_def_int(ot->srna, "uv_subsurf_level", 1, 1, 6, "SubSurf Target", "Number of times to subdivide before calculating UV's", 1, 6); + RNA_def_boolean(ot->srna, "use_subsurf_data", 0, "Use Subsurf Data", + "Map UVs taking vertex position after subsurf into account"); + RNA_def_int(ot->srna, "uv_subsurf_level", 1, 1, 6, "SubSurf Target", + "Number of times to subdivide before calculating UVs", 1, 6); } /**************** Project From View operator **************/ diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 839c67f6297..1327a205c19 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -292,7 +292,9 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "vel_damping", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "vel_damping"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Velocity Damping", "Damp velocity to help cloth reach the resting position faster. [1.0 = no damping, 0.0 = fully dampened]"); + RNA_def_property_ui_text(prop, "Velocity Damping", + "Damp velocity to help cloth reach the resting position faster " + "(1.0 = no damping, 0.0 = fully dampened)"); RNA_def_property_update(prop, 0, "rna_cloth_update"); prop= RNA_def_property(srna, "use_pin_cloth", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 83c82cdeb5b..d3d808390da 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1457,13 +1457,13 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "use_uv_sculpt", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_uv_sculpt", 1); - RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for uv sculpting"); + RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for UV sculpting"); RNA_def_property_ui_icon(prop, ICON_TPAINT_HLT, 0); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_SpaceImageEditor_uv_sculpt_update"); prop= RNA_def_property(srna, "uv_sculpt_lock_borders", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_LOCK_BORDERS); - RNA_def_property_ui_text(prop, "Lock Borders", "Disables editing of boundary edges"); + RNA_def_property_ui_text(prop, "Lock Borders", "Disable editing of boundary edges"); prop= RNA_def_property(srna, "uv_sculpt_all_islands", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_ALL_ISLANDS); @@ -3722,7 +3722,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "use_simplify_triangulate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE); - RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disables non-planer quads being triangulated"); + RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planer quads being triangulated"); /* Scene API */ RNA_api_scene_render(srna); @@ -3896,7 +3896,7 @@ static void rna_def_selected_uv_element(BlenderRNA *brna) PropertyRNA *prop; srna= RNA_def_struct(brna, "SelectedUvElement", "PropertyGroup"); - RNA_def_struct_ui_text(srna, "Selected Uv Element", ""); + RNA_def_struct_ui_text(srna, "Selected UV Element", ""); /* store the index to the UV element selected */ prop= RNA_def_property(srna, "element_index", PROP_INT, PROP_UNSIGNED); From d7e30369f8799d31a81a5b0e87122263d164ec16 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Jan 2012 01:21:43 +0000 Subject: [PATCH 043/105] commented smoke collision derived mesh, was storing its own copy of the collision mesh but never using it. --- source/blender/blenkernel/intern/smoke.c | 14 +++++++++++++- source/blender/makesdna/DNA_smoke_types.h | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 60941ef78a3..424f97f57ed 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -77,6 +77,9 @@ #include "BKE_smoke.h" +/* UNUSED so far, may be enabled later */ +/* #define USE_SMOKE_COLLISION_DM */ + #ifdef WITH_SMOKE #ifdef _WIN32 @@ -617,9 +620,11 @@ static void smokeModifier_freeCollision(SmokeModifierData *smd) smd->coll->bvhtree = NULL; } +#ifdef USE_SMOKE_COLLISION_DM if(smd->coll->dm) smd->coll->dm->release(smd->coll->dm); smd->coll->dm = NULL; +#endif MEM_freeN(smd->coll); smd->coll = NULL; @@ -682,9 +687,11 @@ void smokeModifier_reset(struct SmokeModifierData *smd) smd->coll->bvhtree = NULL; } +#ifdef USE_SMOKE_COLLISION_DM if(smd->coll->dm) smd->coll->dm->release(smd->coll->dm); smd->coll->dm = NULL; +#endif } } @@ -772,7 +779,10 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->coll->points = NULL; smd->coll->numpoints = 0; smd->coll->bvhtree = NULL; + +#ifdef USE_SMOKE_COLLISION_DM smd->coll->dm = NULL; +#endif } } } @@ -1339,11 +1349,13 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { // XXX TODO smd->time = scene->r.cfra; - + +#ifdef USE_SMOKE_COLLISION_DM if(smd->coll->dm) smd->coll->dm->release(smd->coll->dm); smd->coll->dm = CDDM_copy(dm); +#endif // rigid movement support copy_m4_m4(smd->coll->mat_old, smd->coll->mat); diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h index ed764c4f644..753f1374774 100644 --- a/source/blender/makesdna/DNA_smoke_types.h +++ b/source/blender/makesdna/DNA_smoke_types.h @@ -138,7 +138,8 @@ typedef struct SmokeFlowSettings { typedef struct SmokeCollSettings { struct SmokeModifierData *smd; /* for fast RNA access */ struct BVHTree *bvhtree; /* bounding volume hierarchy for this cloth object */ - struct DerivedMesh *dm; + +// struct DerivedMesh *dm; // UNUSED, ifdef'd in code for now. float *points; float *points_old; float *vel; From e634cb26074ca3950fe00c1266e87d7d7689be09 Mon Sep 17 00:00:00 2001 From: Andrew Hale Date: Tue, 24 Jan 2012 01:56:44 +0000 Subject: [PATCH 044/105] Add the .Identity() classmethod to mathutils matrices. This allows the user to create an identity matrix of a specific size without having to specify all the values in the matrix and then use the .identity() method. --- .../python/mathutils/mathutils_Matrix.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 7fe4b5ba5dd..efd73bf8c04 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -411,6 +411,34 @@ static void matrix_3x3_as_4x4(float mat[16]) /*-----------------------CLASS-METHODS----------------------------*/ //mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. +PyDoc_STRVAR(C_Matrix_Identity_doc, +".. classmethod:: Identity(size)\n" +"\n" +" Create an identity matrix.\n" +"\n" +" :arg size: The size of the identity matrix to construct [2, 4].\n" +" :type size: int\n" +" :return: A new identity matrix.\n" +" :rtype: :class:`Matrix`\n" +); +static PyObject *C_Matrix_Identity(PyObject *cls, PyObject *args) +{ + int matSize; + + if (!PyArg_ParseTuple(args, "i:Matrix.Identity", &matSize)) { + return NULL; + } + + if (matSize < 2 || matSize > 4) { + PyErr_SetString(PyExc_RuntimeError, + "Matrix.Identity(): " + "size must be between 2 and 4"); + return NULL; + } + + return Matrix_CreatePyObject(NULL, matSize, matSize, Py_NEW, (PyTypeObject *)cls); +} + PyDoc_STRVAR(C_Matrix_Rotation_doc, ".. classmethod:: Rotation(angle, size, axis)\n" "\n" @@ -2246,6 +2274,7 @@ static struct PyMethodDef Matrix_methods[] = { {"__copy__", (PyCFunction) Matrix_copy, METH_NOARGS, Matrix_copy_doc}, /* class methods */ + {"Identity", (PyCFunction) C_Matrix_Identity, METH_VARARGS | METH_CLASS, C_Matrix_Identity_doc}, {"Rotation", (PyCFunction) C_Matrix_Rotation, METH_VARARGS | METH_CLASS, C_Matrix_Rotation_doc}, {"Scale", (PyCFunction) C_Matrix_Scale, METH_VARARGS | METH_CLASS, C_Matrix_Scale_doc}, {"Shear", (PyCFunction) C_Matrix_Shear, METH_VARARGS | METH_CLASS, C_Matrix_Shear_doc}, From 9998d1235bd587690f27675a0e148af23f32efb5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 24 Jan 2012 08:43:17 +0000 Subject: [PATCH 045/105] Fix #29965: Crash: Memory psys node array: end corrupt Original indices from right operand were used in boolean result derived mesh which lead to crash if right operand has got more entities (faces/edges/vertices) than left operand. --- source/blender/modifiers/intern/MOD_boolean_util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index fa829bcd44b..f6a2e4451b2 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -350,7 +350,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( GHash *material_hash = NULL; Mesh *me1= (Mesh*)ob1->data; Mesh *me2= (Mesh*)ob2->data; - int i; + int i, *origindex_layer; // create a new DerivedMesh result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements); @@ -379,6 +379,8 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( *totmat = 0; } + origindex_layer = result->getFaceDataArray(result, CD_ORIGINDEX); + // step through the face iterators for(i = 0; !face_it->Done(face_it->it); i++) { Mesh *orig_me; @@ -427,6 +429,9 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( (orig_me == me2)? mapmat: NULL); test_index_face(mface, &result->faceData, i, csgface.vertex_number); + + if(origindex_layer && orig_ob == ob2) + origindex_layer[i] = ORIGINDEX_NONE; } if (material_hash) From b8fe464b62098d0fbdca2f4b629c0c3042224507 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 24 Jan 2012 08:43:39 +0000 Subject: [PATCH 046/105] Bugfix: Circle-select in Pose Mode disregarded layer visibility, selecting invisible bones too --- source/blender/editors/space_view3d/view3d_select.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 1b153d03e45..be838c36ba9 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -2452,6 +2452,7 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int static void pose_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + bArmature *arm = vc->obact->data; bPose *pose = vc->obact->pose; bPoseChannel *pchan; int change= FALSE; @@ -2470,6 +2471,10 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f short sco1[2], sco2[2], didpoint=0; float vec[3]; + /* skip invisible bones */ + if (PBONE_VISIBLE(arm, pchan->bone) == 0) + continue; + /* project head location to screenspace */ mul_v3_m4v3(vec, vc->obact->obmat, pchan->pose_head); project_short(vc->ar, vec, sco1); From 1c33126cf50f43f0abf14706ab211a998868c669 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 24 Jan 2012 12:25:03 +0000 Subject: [PATCH 047/105] Fix #29975: Track Preview color channels not filtering correctly Typo in checking bitflags --- source/blender/blenkernel/intern/tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 73170612ff7..0c3c43bebc3 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1062,7 +1062,7 @@ void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disab static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int grayscale) { BKE_tracking_disable_imbuf_channels(ibuf, track->flag&TRACK_DISABLE_RED, - track->flag&TRACK_DISABLE_GREEN, track->flag&TRACK_DISABLE_RED, grayscale); + track->flag&TRACK_DISABLE_GREEN, track->flag&TRACK_DISABLE_BLUE, grayscale); } static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, From 925234f1e07fd445d67dd0ca3fb66a11e4a5c164 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 24 Jan 2012 13:17:32 +0000 Subject: [PATCH 048/105] New fix for [#29940] Stretch To constraint breaks scaling in Transform constraint, previous one caused bug [#29962] linked objects not correct on r4361, should be fixed now. Org code was working with isotropic scaling, but when scaling only one axis, it was broken. First fix just disabled completly scale handling. This version only takes into account scaling along local Y axis, as this is the only one affecting that constraint! Sorry for the mistake, hope this time it will be ok. --- source/blender/blenkernel/intern/constraint.c | 11 +++++++---- source/blender/makesrna/intern/rna_scene.c | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 2bda3066af0..8118cf64429 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2775,8 +2775,7 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* store Z orientation before destroying obmat */ normalize_v3_v3(zz, cob->matrix[2]); - dist = len_v3v3(cob->matrix[3], ct->matrix[3]); - /* XXX What was all that for??? Makes the constraint buggy with scaled objects, see #29940. */ + /* XXX That makes the constraint buggy with asymmetrically scaled objects, see #29940. */ /* sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);*/ /* vec[0] /= size[0];*/ /* vec[1] /= size[1];*/ @@ -2784,10 +2783,14 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* dist = normalize_v3(vec);*/ + dist = len_v3v3(cob->matrix[3], ct->matrix[3]); + /* Only Y constrained object axis scale should be used, to keep same length when scaling it. */ + dist /= size[1]; + /* data->orglength==0 occurs on first run, and after 'R' button is clicked */ - if (data->orglength == 0) + if (data->orglength == 0) data->orglength = dist; - if (data->bulge == 0) + if (data->bulge == 0) data->bulge = 1.0; scale[1] = dist/data->orglength; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d3d808390da..cd033b1f329 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3722,7 +3722,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "use_simplify_triangulate", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "simplify_flag", R_SIMPLE_NO_TRIANGULATE); - RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planer quads being triangulated"); + RNA_def_property_ui_text(prop, "Skip Quad to Triangles", "Disable non-planar quads being triangulated"); /* Scene API */ RNA_api_scene_render(srna); From 58c51bb551fbc573f3e570b9365ac309568973be Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Jan 2012 15:37:50 +0000 Subject: [PATCH 049/105] quiet some warnings & (possible/unlikely error) --- source/blender/editors/space_text/text_ops.c | 10 ++++++---- source/blender/editors/space_time/space_time.c | 4 ++++ source/blender/editors/uvedit/uvedit_smart_stitch.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 29583a9356e..5517f428678 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2412,7 +2412,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in { Text *text = st->text; int max = wrap_width(st, ar); /* view */ - int charp; /* mem */ + int charp = -1; /* mem */ int loop = 1, found = 0; /* flags */ char ch; @@ -2513,9 +2513,11 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in y--; } - - if(sel) { text->sell = linep; text->selc = charp; } - else { text->curl = linep; text->curc = charp; } + + if (linep && charp != -1) { + if(sel) { text->sell = linep; text->selc = charp; } + else { text->curl = linep; text->curc = charp; } + } } static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, int sel) diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 65ef3273e30..bf1b1ddc18a 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -193,6 +193,10 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; + default: + BLI_assert(0); + col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; + col[3] = 0.1; } glColor4fv(col); diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index b2a9b6bb572..c012a23c175 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -565,7 +565,7 @@ static void stitch_validate_stichability(UvElement *element, StitchState *state, static int stitch_process_data(StitchState *state, Scene *scene, int final) { int i; - StitchPreviewer *preview = uv_get_stitch_previewer(); + StitchPreviewer *preview; IslandStitchData *island_stitch_data = NULL; int previous_island = state->static_island; EditFace *efa; From 1f9e25ac1a7851ab2503b88564c0d480b9e125cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Jan 2012 15:51:44 +0000 Subject: [PATCH 050/105] comment unused assignment. --- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 5eadb0a71c5..f3569639454 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -306,7 +306,6 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi MFace *face; MEdge *edge; EditVert *editVert; - MTFace *texface; EditFace *editFace, **editFaceTmp; EditEdge *editEdge, **editEdgeTmp; int i; @@ -321,7 +320,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi MVert *subsurfedVerts; MEdge *subsurfedEdges; MFace *subsurfedFaces; - MTFace *subsurfedTexfaces; + /* MTFace *subsurfedTexfaces; */ /* UNUSED */ /* number of vertices and faces for subsurfed mesh*/ int numOfEdges, numOfFaces; @@ -340,7 +339,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi if(eface) { float aspx, aspy; - texface= CustomData_em_get(&editMesh->fdata, eface->data, CD_MTFACE); + MTFace *texface= CustomData_em_get(&editMesh->fdata, eface->data, CD_MTFACE); ED_image_uv_aspect(texface->tpage, &aspx, &aspy); @@ -368,7 +367,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi origEdgeIndices = derivedMesh->getEdgeDataArray(derivedMesh, CD_ORIGINDEX); origFaceIndices = derivedMesh->getFaceDataArray(derivedMesh, CD_ORIGINDEX); - subsurfedTexfaces = derivedMesh->getFaceDataArray(derivedMesh, CD_MTFACE); + /* subsurfedTexfaces = derivedMesh->getFaceDataArray(derivedMesh, CD_MTFACE); */ /* UNUSED */ numOfEdges = derivedMesh->getNumEdges(derivedMesh); numOfFaces = derivedMesh->getNumFaces(derivedMesh); @@ -427,7 +426,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, EditMesh *edi } /* Now we feed the rest of the data from the subsurfed faces */ - texface= subsurfedTexfaces+i; + /* texface= subsurfedTexfaces+i; */ /* UNUSED */ /* We will not check for v4 here. Subsurfed mfaces always have 4 vertices. */ key = (ParamKey)face; From 335ffb0ff3df6ee52f525448d09ae6448b75e158 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 24 Jan 2012 16:32:31 +0000 Subject: [PATCH 051/105] Brightness/Contrast Node for Cycles Contrast helps to adjust IBL (HDR images used for background lighting). Note: In the UI we are caling it Bright instead of Brightness. This copy what Blender composite is doing. Note2: the algorithm we are using produces pure black when contrast is 100. I'm not a fan of that, but it's a division by zero. I would like to look at other algorithms (what gimp does for example). But that would be only after 2.62. --- intern/cycles/app/cycles_xml.cpp | 3 + intern/cycles/blender/blender_shader.cpp | 4 ++ intern/cycles/kernel/CMakeLists.txt | 1 + intern/cycles/kernel/osl/nodes/CMakeLists.txt | 1 + .../kernel/osl/nodes/node_brightness.osl | 50 ++++++++++++++++ intern/cycles/kernel/svm/svm.h | 4 ++ intern/cycles/kernel/svm/svm_brightness.h | 57 ++++++++++++++++++ intern/cycles/kernel/svm/svm_types.h | 3 +- intern/cycles/render/nodes.cpp | 32 ++++++++++ intern/cycles/render/nodes.h | 5 ++ source/blender/blenkernel/BKE_node.h | 1 + source/blender/blenkernel/intern/node.c | 1 + .../makesrna/intern/rna_nodetree_types.h | 1 + source/blender/nodes/CMakeLists.txt | 1 + source/blender/nodes/NOD_shader.h | 1 + .../shader/nodes/node_shader_brightness.c | 60 +++++++++++++++++++ .../nodes/shader/nodes/node_shader_gamma.c | 5 -- 17 files changed, 224 insertions(+), 6 deletions(-) create mode 100644 intern/cycles/kernel/osl/nodes/node_brightness.osl create mode 100644 intern/cycles/kernel/svm/svm_brightness.h create mode 100644 source/blender/nodes/shader/nodes/node_shader_brightness.c diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index af52520d87c..5e4b3da071d 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -462,6 +462,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug else if(string_iequals(node.name(), "gamma")) { snode = new GammaNode(); } + else if(string_iequals(node.name(), "brightness")) { + snode = new BrightContrastNode(); + } else if(string_iequals(node.name(), "combine_rgb")) { snode = new CombineRGBNode(); } diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 1ce134f3094..f7b750e6dab 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -142,6 +142,10 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Shader node = new GammaNode(); break; } + case BL::ShaderNode::type_BRIGHTCONTRAST: { + node = new BrightContrastNode(); + break; + } case BL::ShaderNode::type_MIX_RGB: { BL::ShaderNodeMixRGB b_mix_node(b_node); MixNode *mix = new MixNode(); diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index a4e0c0ddb56..b6e749f3fcb 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -61,6 +61,7 @@ set(SRC_SVM_HEADERS svm/svm_displace.h svm/svm_fresnel.h svm/svm_gamma.h + svm/svm_brightness.h svm/svm_geometry.h svm/svm_gradient.h svm/svm_hsv.h diff --git a/intern/cycles/kernel/osl/nodes/CMakeLists.txt b/intern/cycles/kernel/osl/nodes/CMakeLists.txt index 1a207d6c139..d3a1cf59a37 100644 --- a/intern/cycles/kernel/osl/nodes/CMakeLists.txt +++ b/intern/cycles/kernel/osl/nodes/CMakeLists.txt @@ -20,6 +20,7 @@ set(SRC_OSL node_environment_texture.osl node_fresnel.osl node_gamma.osl + node_brightness.osl node_geometry.osl node_glass_bsdf.osl node_glossy_bsdf.osl diff --git a/intern/cycles/kernel/osl/nodes/node_brightness.osl b/intern/cycles/kernel/osl/nodes/node_brightness.osl new file mode 100644 index 00000000000..a93ff06d443 --- /dev/null +++ b/intern/cycles/kernel/osl/nodes/node_brightness.osl @@ -0,0 +1,50 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "stdosl.h" + +shader node_brightness( + color ColorIn = color(0.8, 0.8, 0.8), + float Bright = 0.0, + float Contrast = 0.0, + output ColorOut = color(0.8, 0.8, 0.8) +{ + float delta = Contrast * (1.0/200.0); + float a = 1.0 - delta * 2.0; + float b; + + Bright *= 1.0/100.0; + + /* + * The algorithm is by Werner D. Streidt + * (http://visca.com/ffactory/archives/5-99/msg00021.html) + * Extracted of OpenCV demhist.c + */ + + if (Contrast > 0.0) { + a = (a < 0.0 ? 1.0/a : 0.0); + b = a * (Brightness - delta); + } + else { + delta *= -1.0; + b = a * (Brightness + delta); + } + + ColorOut = a * ColorIn + b; +} + diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index d22c9181a84..f1bae9c8d9f 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -131,6 +131,7 @@ CCL_NAMESPACE_END #include "svm_hsv.h" #include "svm_image.h" #include "svm_gamma.h" +#include "svm_brightness.h" #include "svm_invert.h" #include "svm_light_path.h" #include "svm_magic.h" @@ -270,6 +271,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT case NODE_GAMMA: svm_node_gamma(sd, stack, node.y, node.z, node.w); break; + case NODE_BRIGHTCONTRAST: + svm_node_brightness(sd, stack, node.y, node.z, node.w); + break; case NODE_MIX: svm_node_mix(kg, sd, stack, node.y, node.z, node.w, &offset); break; diff --git a/intern/cycles/kernel/svm/svm_brightness.h b/intern/cycles/kernel/svm/svm_brightness.h new file mode 100644 index 00000000000..698899ffd60 --- /dev/null +++ b/intern/cycles/kernel/svm/svm_brightness.h @@ -0,0 +1,57 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +CCL_NAMESPACE_BEGIN + +__device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, uint out_color, uint node) +{ + uint bright_offset, contrast_offset; + float3 color = stack_load_float3(stack, in_color); + + decode_node_uchar4(node, &bright_offset, &contrast_offset, NULL, NULL); + float brightness = stack_load_float(stack, bright_offset); + float contrast = stack_load_float(stack, contrast_offset); + + brightness *= 1.0f/100.0f; + float delta = contrast * (1.0f/200.0f); + float a = 1.0f - delta * 2.0f; + float b; + + /* + * The algorithm is by Werner D. Streidt + * (http://visca.com/ffactory/archives/5-99/msg00021.html) + * Extracted of OpenCV demhist.c + */ + if (contrast > 0.0f) { + a = (a > 0.0f? (1.0f / a): 0.0f); + b = a * (brightness - delta); + } + else { + delta *= -1.0f; + b = a * (brightness + delta); + } + + color.x = a*color.x + b; + color.y = a*color.y + b; + color.z = a*color.z + b; + + if (stack_valid(out_color)) + stack_store_float3(stack, out_color, color); +} + +CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index 8203ed4c15e..ff6e9b94a0f 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -87,7 +87,8 @@ typedef enum NodeType { NODE_INVERT = 5400, NODE_NORMAL = 5500, NODE_GAMMA = 5600, - NODE_TEX_CHECKER = 5700 + NODE_TEX_CHECKER = 5700, + NODE_BRIGHTCONTRAST = 5800 } NodeType; typedef enum NodeAttributeType { diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 7397c9c09af..982521b31f2 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1820,6 +1820,38 @@ void GammaNode::compile(OSLCompiler& compiler) compiler.add(this, "node_gamma"); } +/* Bright Contrast */ +BrightContrastNode::BrightContrastNode() +: ShaderNode("brightness") +{ + add_input("Color", SHADER_SOCKET_COLOR); + add_input("Bright", SHADER_SOCKET_FLOAT); + add_input("Contrast", SHADER_SOCKET_FLOAT); + add_output("Color", SHADER_SOCKET_COLOR); +} + +void BrightContrastNode::compile(SVMCompiler& compiler) +{ + ShaderInput *color_in = input("Color"); + ShaderInput *bright_in = input("Bright"); + ShaderInput *contrast_in = input("Contrast"); + ShaderOutput *color_out = output("Color"); + + compiler.stack_assign(color_in); + compiler.stack_assign(bright_in); + compiler.stack_assign(contrast_in); + compiler.stack_assign(color_out); + + compiler.add_node(NODE_BRIGHTCONTRAST, + color_in->stack_offset, color_out->stack_offset, + compiler.encode_uchar4(bright_in->stack_offset, contrast_in->stack_offset)); +} + +void BrightContrastNode::compile(OSLCompiler& compiler) +{ + compiler.add(this, "node_brightness"); +} + /* Separate RGB */ SeparateRGBNode::SeparateRGBNode() : ShaderNode("separate_rgb") diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index c2f9ead5924..338af4ef48a 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -320,6 +320,11 @@ public: SHADER_NODE_CLASS(GammaNode) }; +class BrightContrastNode : public ShaderNode { +public: + SHADER_NODE_CLASS(BrightContrastNode) +}; + class SeparateRGBNode : public ShaderNode { public: SHADER_NODE_CLASS(SeparateRGBNode) diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 67de699c7c4..2fa587e168a 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -523,6 +523,7 @@ struct ShadeResult; #define SH_NODE_VOLUME_ISOTROPIC 162 #define SH_NODE_GAMMA 163 #define SH_NODE_TEX_CHECKER 164 +#define SH_NODE_BRIGHTCONTRAST 165 /* custom defines options for Material node */ #define SH_NODE_MAT_DIFF 1 diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 96ee2bd0349..b72abcd79f4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1881,6 +1881,7 @@ static void registerShaderNodes(bNodeTreeType *ttype) register_node_type_sh_material(ttype); register_node_type_sh_camera(ttype); register_node_type_sh_gamma(ttype); + register_node_type_sh_brightcontrast(ttype); register_node_type_sh_value(ttype); register_node_type_sh_rgb(ttype); register_node_type_sh_mix_rgb(ttype); diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 5ab907c87dc..2284b09e941 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -41,6 +41,7 @@ DefNode( ShaderNode, SH_NODE_RGBTOBW, 0, "RGBTO DefNode( ShaderNode, SH_NODE_TEXTURE, def_texture, "TEXTURE", Texture, "Texture", "" ) DefNode( ShaderNode, SH_NODE_NORMAL, 0, "NORMAL", Normal, "Normal", "" ) DefNode( ShaderNode, SH_NODE_GAMMA, 0, "GAMMA", Gamma, "Gamma", "" ) +DefNode( ShaderNode, SH_NODE_BRIGHTCONTRAST, 0, "BRIGHTCONTRAST", BrightContrast, "Bright Contrast", "" ) DefNode( ShaderNode, SH_NODE_GEOMETRY, def_sh_geometry, "GEOMETRY", Geometry, "Geometry", "" ) DefNode( ShaderNode, SH_NODE_MAPPING, def_sh_mapping, "MAPPING", Mapping, "Mapping", "" ) DefNode( ShaderNode, SH_NODE_CURVE_VEC, def_vector_curve, "CURVE_VEC", VectorCurve, "Vector Curve", "" ) diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 6d5c282d308..b458ae3a77d 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -115,6 +115,7 @@ set(SRC shader/nodes/node_shader_curves.c shader/nodes/node_shader_dynamic.c shader/nodes/node_shader_gamma.c + shader/nodes/node_shader_brightness.c shader/nodes/node_shader_geom.c shader/nodes/node_shader_hueSatVal.c shader/nodes/node_shader_invert.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index 907efd76786..63fc0f4232c 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -55,6 +55,7 @@ void register_node_type_sh_rgbtobw(struct bNodeTreeType *ttype); void register_node_type_sh_texture(struct bNodeTreeType *ttype); void register_node_type_sh_normal(struct bNodeTreeType *ttype); void register_node_type_sh_gamma(struct bNodeTreeType *ttype); +void register_node_type_sh_brightcontrast(struct bNodeTreeType *ttype); void register_node_type_sh_geom(struct bNodeTreeType *ttype); void register_node_type_sh_mapping(struct bNodeTreeType *ttype); void register_node_type_sh_curve_vec(struct bNodeTreeType *ttype); diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c new file mode 100644 index 00000000000..7448a0b3bab --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c @@ -0,0 +1,60 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2006 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + +*/ + +#include "node_shader_util.h" + + +/* **************** Brigh and contrsast ******************** */ + +static bNodeSocketTemplate sh_node_brightcontrast_in[]= { + { SOCK_RGBA, 1, "Color", 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_FLOAT, 1, "Bright", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, + { SOCK_FLOAT, 1, "Contrast", 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, + { -1, 0, "" } +}; + +static bNodeSocketTemplate sh_node_brightcontrast_out[]= { + { SOCK_RGBA, 0, "Color"}, + { -1, 0, "" } +}; + +void register_node_type_sh_brightcontrast(bNodeTreeType *ttype) +{ + static bNodeType ntype; + + node_type_base(ttype, &ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, NODE_OPTIONS); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out); + node_type_size(&ntype, 140, 100, 320); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + node_type_exec(&ntype, NULL); + node_type_gpu(&ntype, NULL); + + nodeRegisterType(ttype, &ntype); +} diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c index 1d525d71698..e2907f5ba91 100644 --- a/source/blender/nodes/shader/nodes/node_shader_gamma.c +++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c @@ -26,11 +26,6 @@ */ -/** \file blender/nodes/composite/nodes/node_composite_gamma.c - * \ingroup cmpnodes - */ - - #include "node_shader_util.h" /* **************** Gamma Tools ******************** */ From 8f7762c356b8a1d39fd8222b72d5c35ef66d8061 Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Tue, 24 Jan 2012 17:28:50 +0000 Subject: [PATCH 052/105] Dynamic Paint: * Fix: Substep update failed if brush was parented to a canvas vertex. Now substeps are ignored in such case. * Fix: Wave "open borders" option didn't work for image sequence format. * Fixed a possible crash after changing surface format to image sequence. * Some code cleanup. --- .../blender/blenkernel/intern/dynamicpaint.c | 131 ++++++++++-------- 1 file changed, 70 insertions(+), 61 deletions(-) diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 18c8d0f0106..501b97bd9be 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -97,6 +97,10 @@ static int neighY[8] = {0,1,1, 1, 0,-1,-1,-1}; /* brush mesh raycast status */ #define HIT_VOLUME 1 #define HIT_PROXIMITY 2 +/* dynamicPaint_findNeighbourPixel() return codes */ +#define NOT_FOUND -1 +#define ON_MESH_EDGE -2 +#define OUT_OF_TEXTURE -3 /* paint effect default movement per frame in global units */ #define EFF_MOVEMENT_PER_FRAME 0.05f /* initial wave time factor */ @@ -134,10 +138,10 @@ typedef struct Vec3f { float v[3]; } Vec3f; -typedef struct BakeNeighPoint { +typedef struct BakeAdjPoint { float dir[3]; /* vector pointing towards this neighbour */ float dist; /* distance to */ -} BakeNeighPoint; +} BakeAdjPoint; /* Surface data used while processing a frame */ typedef struct PaintBakeNormal { @@ -156,7 +160,7 @@ typedef struct PaintBakeData { Bounds3D mesh_bounds; /* adjacency info */ - BakeNeighPoint *bNeighs; /* current global neighbour distances and directions, if required */ + BakeAdjPoint *bNeighs; /* current global neighbour distances and directions, if required */ double average_dist; /* space partitioning */ VolumeGrid *grid; /* space partitioning grid to optimize brush checks */ @@ -188,13 +192,6 @@ typedef struct ImgSeqFormatData { Vec3f *barycentricWeights; /* b-weights for all pixel samples */ } ImgSeqFormatData; -#if 0 /* UNUSED */ -typedef struct EffVelPoint { - float previous_pos[3]; - float previous_vel[3]; -} EffVelPoint; -#endif - /* adjacency data flags */ #define ADJ_ON_MESH_EDGE (1<<0) @@ -470,19 +467,25 @@ static void object_cacheIgnoreClear(Object *ob, int state) BLI_freelistN(&pidlist); } -static void subframe_updateObject(Scene *scene, Object *ob, int flags, float frame) +static int subframe_updateObject(Scene *scene, Object *ob, int flags, float frame) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); bConstraint *con; /* if other is dynamic paint canvas, dont update */ if (pmd && pmd->canvas) - return; + return 1; /* if object has parents, update them too */ if (flags & UPDATE_PARENTS) { - if (ob->parent) subframe_updateObject(scene, ob->parent, 0, frame); - if (ob->track) subframe_updateObject(scene, ob->track, 0, frame); + int is_canvas = 0; + if (ob->parent) is_canvas += subframe_updateObject(scene, ob->parent, 0, frame); + if (ob->track) is_canvas += subframe_updateObject(scene, ob->track, 0, frame); + + /* skip subframe if object is parented + * to vertex of a dynamic paint canvas */ + if (is_canvas && (ob->partype == PARVERT1 || ob->partype == PARVERT3)) + return 0; /* also update constraint targets */ for (con = ob->constraints.first; con; con=con->next) { @@ -519,6 +522,8 @@ static void subframe_updateObject(Scene *scene, Object *ob, int flags, float fra } else where_is_object_time(scene, ob, frame); + + return 0; } static void scene_setSubframe(Scene *scene, float subframe) @@ -1222,7 +1227,7 @@ static int surface_usesAdjData(DynamicPaintSurface *surface) static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int force_init) { PaintSurfaceData *sData = surface->data; - PaintAdjData *ed; + PaintAdjData *ad; int *temp_data; int neigh_points = 0; @@ -1238,17 +1243,17 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for if (!neigh_points) return; /* allocate memory */ - ed = sData->adj_data = MEM_callocN(sizeof(PaintAdjData), "Surface Adj Data"); - if (!ed) return; - ed->n_index = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Index"); - ed->n_num = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Counts"); + ad = sData->adj_data = MEM_callocN(sizeof(PaintAdjData), "Surface Adj Data"); + if (!ad) return; + ad->n_index = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Index"); + ad->n_num = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Counts"); temp_data = MEM_callocN(sizeof(int)*sData->total_points, "Temp Adj Data"); - ed->n_target = MEM_callocN(sizeof(int)*neigh_points, "Surface Adj Targets"); - ed->flags = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Flags"); - ed->total_targets = neigh_points; + ad->n_target = MEM_callocN(sizeof(int)*neigh_points, "Surface Adj Targets"); + ad->flags = MEM_callocN(sizeof(int)*sData->total_points, "Surface Adj Flags"); + ad->total_targets = neigh_points; /* in case of allocation error, free memory */ - if (!ed->n_index || !ed->n_num || !ed->n_target || !temp_data) { + if (!ad->n_index || !ad->n_num || !ad->n_target || !temp_data) { dynamicPaint_freeAdjData(sData); if (temp_data) MEM_freeN(temp_data); setError(surface->canvas, "Not enough free memory."); @@ -1267,14 +1272,15 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for /* count number of edges per vertex */ for (i=0; in_num[edge[i].v1]++; - ed->n_num[edge[i].v2]++; + ad->n_num[edge[i].v1]++; + ad->n_num[edge[i].v2]++; temp_data[edge[i].v1]++; temp_data[edge[i].v2]++; } - /* to locate points on "mesh edge" */ + /* also add number of vertices to temp_data + * to locate points on "mesh edge" */ for (i=0; itotal_points; i++) { if ((temp_data[i]%2) || temp_data[i] < 4) - ed->flags[i] |= ADJ_ON_MESH_EDGE; + ad->flags[i] |= ADJ_ON_MESH_EDGE; /* reset temp data */ temp_data[i] = 0; @@ -1297,22 +1303,22 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for /* order n_index array */ n_pos = 0; for (i=0; itotal_points; i++) { - ed->n_index[i] = n_pos; - n_pos += ed->n_num[i]; + ad->n_index[i] = n_pos; + n_pos += ad->n_num[i]; } /* and now add neighbour data using that info */ for (i=0; in_index[index]+temp_data[index]; - ed->n_target[n_pos] = edge[i].v2; + n_pos = ad->n_index[index]+temp_data[index]; + ad->n_target[n_pos] = edge[i].v2; temp_data[index]++; /* second vertex */ index = edge[i].v2; - n_pos = ed->n_index[index]+temp_data[index]; - ed->n_target[n_pos] = edge[i].v1; + n_pos = ad->n_index[index]+temp_data[index]; + ad->n_target[n_pos] = edge[i].v1; temp_data[index]++; } } @@ -1500,10 +1506,11 @@ void dynamicPaint_clearSurface(DynamicPaintSurface *surface) int dynamicPaint_resetSurface(DynamicPaintSurface *surface) { int numOfPoints = dynamicPaint_surfaceNumOfPoints(surface); - /* dont touch image sequence types. they get handled only on bake */ - if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 1; - + /* free existing data */ if (surface->data) dynamicPaint_freeSurfaceData(surface); + + /* dont reallocate for image sequence types. they get handled only on bake */ + if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) return 1; if (numOfPoints < 1) return 0; /* allocate memory */ @@ -1899,8 +1906,8 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh x = px + neighX[n_index]; y = py + neighY[n_index]; - if (x<0 || x>=w) return -1; - if (y<0 || y>=h) return -1; + if (x<0 || x>=w) return OUT_OF_TEXTURE; + if (y<0 || y>=h) return OUT_OF_TEXTURE; tPoint = &tempPoints[x+w*y]; /* UV neighbour */ cPoint = &tempPoints[px+w*py]; /* Origin point */ @@ -2013,8 +2020,8 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh } } - /* If none found return -1 */ - if (target_face == -1) return -1; + /* If none found pixel is on mesh edge */ + if (target_face == -1) return ON_MESH_EDGE; /* * If target face is connected in UV space as well, just use original index @@ -2052,15 +2059,15 @@ static int dynamicPaint_findNeighbourPixel(PaintUVPoint *tempPoints, DerivedMesh final_pixel[1] = (int)floor(pixel[1]); /* If current pixel uv is outside of texture */ - if (final_pixel[0] < 0 || final_pixel[0] >= w) return -1; - if (final_pixel[1] < 0 || final_pixel[1] >= h) return -1; + if (final_pixel[0] < 0 || final_pixel[0] >= w) return OUT_OF_TEXTURE; + if (final_pixel[1] < 0 || final_pixel[1] >= h) return OUT_OF_TEXTURE; final_index = final_pixel[0] + w * final_pixel[1]; /* If we ended up to our origin point ( mesh has smaller than pixel sized faces) */ - if (final_index == (px+w*py)) return -1; + if (final_index == (px+w*py)) return NOT_FOUND; /* If found pixel still lies on wrong face ( mesh has smaller than pixel sized faces) */ - if (tempPoints[final_index].face_index != target_face) return -1; + if (tempPoints[final_index].face_index != target_face) return NOT_FOUND; /* * If final point is an "edge pixel", use it's "real" neighbour instead @@ -2442,11 +2449,14 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) * If not found, -1 is returned */ int n_target = dynamicPaint_findNeighbourPixel(tempPoints, dm, uvname, w, h, tx, ty, i); - if (n_target != -1) { + if (n_target >= 0) { ed->n_target[n_pos] = final_index[n_target]; ed->n_num[final_index[index]]++; n_pos++; } + else if (n_target == ON_MESH_EDGE || n_target == OUT_OF_TEXTURE) { + ed->flags[final_index[index]] |= ADJ_ON_MESH_EDGE; + } } } } @@ -3147,8 +3157,8 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, mul_m4_v3(brushOb->obmat, mvert[ii].co); boundInsert(&mesh_bb, mvert[ii].co); - /* for project brush calculate average normal */ - if (brush->flags & MOD_DPAINT_PROX_PROJECT) { + /* for proximity project calculate average normal */ + if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) { float nor[3]; normal_short_to_float_v3(nor, mvert[ii].no); mul_mat3_m4_v3(brushOb->obmat, nor); @@ -3158,7 +3168,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, } } - if (brush->flags & MOD_DPAINT_PROX_PROJECT) { + if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) { mul_v3_fl(avg_brushNor, 1.0f/(float)numOfVerts); /* instead of null vector use positive z */ if (!(MIN3(avg_brushNor[0],avg_brushNor[1],avg_brushNor[2]))) @@ -3855,14 +3865,13 @@ static int dynamicPaint_paintSinglePoint(DynamicPaintSurface *surface, float *po /***************************** Dynamic Paint Step / Baking ******************************/ /* -* Calculate current frame neighbouring point distances -* and direction vectors +* Calculate current frame distances and directions for adjacency data */ -static void dynamicPaint_prepareNeighbourData(DynamicPaintSurface *surface, int force_init) +static void dynamicPaint_prepareAdjacencyData(DynamicPaintSurface *surface, int force_init) { PaintSurfaceData *sData = surface->data; PaintBakeData *bData = sData->bData; - BakeNeighPoint *bNeighs; + BakeAdjPoint *bNeighs; PaintAdjData *adj_data = sData->adj_data; Vec3f *realCoord = bData->realCoord; int index; @@ -3870,7 +3879,7 @@ static void dynamicPaint_prepareNeighbourData(DynamicPaintSurface *surface, int if ((!surface_usesAdjDistance(surface) && !force_init) || !sData->adj_data) return; if (bData->bNeighs) MEM_freeN(bData->bNeighs); - bNeighs = bData->bNeighs = MEM_mallocN(sData->adj_data->total_targets*sizeof(struct BakeNeighPoint),"PaintEffectBake"); + bNeighs = bData->bNeighs = MEM_mallocN(sData->adj_data->total_targets*sizeof(struct BakeAdjPoint),"PaintEffectBake"); if (!bNeighs) return; #pragma omp parallel for schedule(static) @@ -3909,7 +3918,7 @@ static void dynamicPaint_prepareNeighbourData(DynamicPaintSurface *surface, int /* find two adjacency points (closest_id) and influence (closest_d) to move paint towards when affected by a force */ void surface_determineForceTargetPoints(PaintSurfaceData *sData, int index, float force[3], float closest_d[2], int closest_id[2]) { - BakeNeighPoint *bNeighs = sData->bData->bNeighs; + BakeAdjPoint *bNeighs = sData->bData->bNeighs; int numOfNeighs = sData->adj_data->n_num[index]; int i; @@ -3978,7 +3987,7 @@ static void dynamicPaint_doSmudge(DynamicPaintSurface *surface, DynamicPaintBrus { PaintSurfaceData *sData = surface->data; PaintBakeData *bData = sData->bData; - BakeNeighPoint *bNeighs = sData->bData->bNeighs; + BakeAdjPoint *bNeighs = sData->bData->bNeighs; int index, steps, step; float eff_scale, max_velocity = 0.0f; @@ -4137,7 +4146,7 @@ static int dynamicPaint_prepareEffectStep(DynamicPaintSurface *surface, Scene *s static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force, PaintPoint *prevPoint, float timescale, float steps) { PaintSurfaceData *sData = surface->data; - BakeNeighPoint *bNeighs = sData->bData->bNeighs; + BakeAdjPoint *bNeighs = sData->bData->bNeighs; float distance_scale = getSurfaceDimension(sData)/CANVAS_REL_SIZE; int index; timescale /= steps; @@ -4166,7 +4175,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force /* Loop through neighbouring points */ for (i=0; iadj_data->n_index[index]+i; - float w_factor /* , p_alpha = pPoint->e_alpha */ /* UNUSED */; + float w_factor; PaintPoint *ePoint = &prevPoint[sData->adj_data->n_target[n_index]]; float speed_scale = (bNeighs[n_index].distwetness, pPoint->wetness, 1.0f))*0.25f*surface->color_spread_speed; @@ -4303,7 +4312,7 @@ static void dynamicPaint_doEffectStep(DynamicPaintSurface *surface, float *force void dynamicPaint_doWaveStep(DynamicPaintSurface *surface, float timescale) { PaintSurfaceData *sData = surface->data; - BakeNeighPoint *bNeighs = sData->bData->bNeighs; + BakeAdjPoint *bNeighs = sData->bData->bNeighs; int index; int steps, ss; float dt, min_dist, damp_factor; @@ -4736,8 +4745,8 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc /* generate surface space partitioning grid */ surfaceGenerateGrid(surface); - /* calculate current frame neighbouring point distances and global dirs */ - dynamicPaint_prepareNeighbourData(surface, 0); + /* calculate current frame adjacency point distances and global dirs */ + dynamicPaint_prepareAdjacencyData(surface, 0); /* Copy current frame vertices to check against in next frame */ copy_m4_m4(bData->prev_obmat, ob->obmat); @@ -4820,7 +4829,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su if (!sData->adj_data) dynamicPaint_initAdjacencyData(surface, 1); if (!bData->bNeighs) - dynamicPaint_prepareNeighbourData(surface, 1); + dynamicPaint_prepareAdjacencyData(surface, 1); } /* update object data on this subframe */ From 44850d69469342b9b11105dc87bdb47ab4234cff Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 24 Jan 2012 18:18:51 +0000 Subject: [PATCH 053/105] Fix #29946: Recover Auto Save defaults to "Short List" View -- Cannot determine dates Added option display_type to WM_operator_properties_filesel which defines which file display type (short/list/icons/default) should be used for file browser. All current operators are using FILE_DEFAULTDISPLAY display type which means display type will still be calculated based on type of opening file and user preferences settings. Recover Auto Save operator is now using long display type so file date can easily be checked now. Reviewed by Andrea, thanks! --- source/blender/editors/curve/editfont.c | 4 ++-- .../blender/editors/object/object_modifier.c | 2 +- .../blender/editors/render/render_shading.c | 2 +- source/blender/editors/screen/screendump.c | 2 +- source/blender/editors/sound/sound_ops.c | 6 ++--- .../editors/space_buttons/buttons_ops.c | 4 ++-- source/blender/editors/space_clip/clip_ops.c | 2 +- source/blender/editors/space_file/filesel.c | 19 ++++++++++------ .../blender/editors/space_graph/graph_edit.c | 2 +- .../blender/editors/space_image/image_ops.c | 6 ++--- source/blender/editors/space_info/info_ops.c | 2 +- source/blender/editors/space_node/node_edit.c | 2 +- .../editors/space_sequencer/sequencer_add.c | 8 +++---- .../editors/space_sequencer/sequencer_edit.c | 2 +- source/blender/editors/space_text/text_ops.c | 4 ++-- source/blender/makesdna/DNA_space_types.h | 3 ++- source/blender/windowmanager/WM_api.h | 2 +- .../windowmanager/intern/wm_operators.c | 22 ++++++++++++++----- 18 files changed, 55 insertions(+), 39 deletions(-) diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index a2cbe6f7def..493fc6e277b 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -422,7 +422,7 @@ void FONT_OT_file_paste(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); } /******************* text to object operator ********************/ @@ -1697,7 +1697,7 @@ void FONT_OT_open(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************* delete operator *********************/ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 93f4a31f1ff..2797c08e72b 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1236,7 +1236,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|BTXFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); edit_modifier_properties(ot); } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 13818ee13e4..87b77912978 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -749,7 +749,7 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot) prop= RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] (use -1 to skip a face)", 0.0f, 0.0f); RNA_def_property_flag(prop, PROP_HIDDEN); - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); } static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index e32277e3789..deeb3061ad5 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -228,7 +228,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) ot->flag= 0; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); } diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 50c436d88f5..3f3369ac6cb 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -186,7 +186,7 @@ static void SOUND_OT_open(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory"); RNA_def_boolean(ot->srna, "mono", FALSE, "Mono", "Mixdown the sound to mono"); } @@ -207,7 +207,7 @@ static void SOUND_OT_open_mono(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory"); RNA_def_boolean(ot->srna, "mono", TRUE, "Mono", "Mixdown the sound to mono"); } @@ -587,7 +587,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); #ifdef WITH_AUDASPACE RNA_def_int(ot->srna, "accuracy", 1024, 1, 16777216, "Accuracy", "Sample accuracy, important for animation data (the lower the value, the more accurate)", 1, 16777216); RNA_def_enum(ot->srna, "container", container_items, AUD_CONTAINER_FLAC, "Container", "File format"); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index df05521fa8d..b1a25d093d2 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -224,7 +224,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) ot->cancel= file_browse_cancel; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */ @@ -241,5 +241,5 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot) ot->cancel= file_browse_cancel; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 06dd96603ef..5053379d376 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -213,7 +213,7 @@ void CLIP_OT_open(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************* reload clip operator *********************/ diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index bf31775a349..5b4e133e283 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -215,14 +215,19 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->flag |= RNA_boolean_get(op->ptr, "autoselect") ? FILE_AUTOSELECT : 0; params->flag |= RNA_boolean_get(op->ptr, "active_layer") ? FILE_ACTIVELAY : 0; } - - if (U.uiflag & USER_SHOW_THUMBNAILS) { - if(params->filter & (IMAGEFILE|MOVIEFILE)) - params->display= FILE_IMGDISPLAY; - else + + if(RNA_struct_find_property(op->ptr, "display_type")) + params->display= RNA_enum_get(op->ptr, "display_type"); + + if(params->display==FILE_DEFAULTDISPLAY) { + if (U.uiflag & USER_SHOW_THUMBNAILS) { + if(params->filter & (IMAGEFILE|MOVIEFILE)) + params->display= FILE_IMGDISPLAY; + else + params->display= FILE_SHORTDISPLAY; + } else { params->display= FILE_SHORTDISPLAY; - } else { - params->display= FILE_SHORTDISPLAY; + } } if (is_relative_path) { diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 9df43a85614..fbcb9546a1b 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1188,7 +1188,7 @@ void GRAPH_OT_sound_bake (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", "", 0.1, 1000.00); RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", "", 0.1, 1000.00); RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", "", 0.01, 0.1); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 1ac5ba56145..ea58b4aa737 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -868,7 +868,7 @@ void IMAGE_OT_open(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************** replace image operator ********************/ @@ -928,7 +928,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************** save image as operator ********************/ @@ -1278,7 +1278,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) /* properties */ RNA_def_boolean(ot->srna, "copy", 0, "Copy", "Create a new image file without modifying the current image in blender"); - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************** save image operator ********************/ diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 87f9a5d65aa..54e8b1b490d 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -309,7 +309,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); } /********************* report box operator *********************/ diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 3301f89ab7a..71f0917a4f3 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -3519,7 +3519,7 @@ void NODE_OT_add_file(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Datablock name to assign"); } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index f1d3d65559d..66aefc72f33 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -402,7 +402,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "sound", TRUE, "Sound", "Load sound with the movie"); } @@ -454,7 +454,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory"); } @@ -558,7 +558,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME); } @@ -734,7 +734,7 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME|SEQPROP_ENDFRAME); RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_CROSS, "Type", "Sequencer effect type"); RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", "Initialize the strip with this color (only used when type='COLOR')", 0.0f, 1.0f); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index c46a1eebc2e..e88664ac817 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -3060,5 +3060,5 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILEPATH|WM_FILESEL_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH|WM_FILESEL_FILEPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY); } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 5517f428678..db8c1b230ba 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -303,7 +303,7 @@ void TEXT_OT_open(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path + WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path RNA_def_boolean(ot->srna, "internal", 0, "Make internal", "Make text file internal after loading"); } @@ -563,7 +563,7 @@ void TEXT_OT_save_as(wmOperatorType *ot) ot->poll= text_edit_poll; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); //XXX TODO, relative_path + WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE|PYSCRIPTFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); //XXX TODO, relative_path } /******************* run script operator *********************/ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 8f986a5f7cc..d57da31793e 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -608,7 +608,8 @@ typedef struct SpaceClip { /* FileSelectParams.display */ enum FileDisplayTypeE { - FILE_SHORTDISPLAY = 1, + FILE_DEFAULTDISPLAY = 0, + FILE_SHORTDISPLAY, FILE_LONGDISPLAY, FILE_IMGDISPLAY }; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 11ac56090a3..132b57696e1 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -203,7 +203,7 @@ void WM_operator_properties_reset(struct wmOperator *op); void WM_operator_properties_create(struct PointerRNA *ptr, const char *opstring); void WM_operator_properties_create_ptr(struct PointerRNA *ptr, struct wmOperatorType *ot); void WM_operator_properties_free(struct PointerRNA *ptr); -void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type, short action, short flag); +void WM_operator_properties_filesel(struct wmOperatorType *ot, int filter, short type, short action, short flag, short display); void WM_operator_properties_gesture_border(struct wmOperatorType *ot, int extend); void WM_operator_properties_gesture_straightline(struct wmOperatorType *ot, int cursor); void WM_operator_properties_select_all(struct wmOperatorType *ot); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 7dd2bf7fc51..4cf36de7f5f 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -831,10 +831,17 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) } /* default properties for fileselect */ -void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag) +void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display) { PropertyRNA *prop; + static EnumPropertyItem file_display_items[] = { + {FILE_DEFAULTDISPLAY, "FILE_DEFAULTDISPLAY", 0, "Default", "Automatically determine display type for files"}, + {FILE_SHORTDISPLAY, "FILE_SHORTDISPLAY", ICON_SHORTDISPLAY, "Short List", "Display files as short list"}, + {FILE_LONGDISPLAY, "FILE_LONGDISPLAY", ICON_LONGDISPLAY, "Long List", "Display files as a detailed list"}, + {FILE_IMGDISPLAY, "FILE_IMGDISPLAY", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"}, + {0, NULL, 0, NULL, NULL}}; + if(flag & WM_FILESEL_FILEPATH) RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file"); @@ -881,6 +888,9 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, if(flag & WM_FILESEL_RELPATH) RNA_def_boolean(ot->srna, "relative_path", TRUE, "Relative Path", "Select the file relative to the blend file"); + + prop= RNA_def_enum(ot->srna, "display_type", file_display_items, display, "Display Type", ""); + RNA_def_property_flag(prop, PROP_HIDDEN); } void WM_operator_properties_select_all(wmOperatorType *ot) @@ -1650,7 +1660,7 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) ot->exec= wm_open_mainfile_exec; /* ommit window poll so this can work in background mode */ - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "load_ui", 1, "Load UI", "Load user interface setup in the .blend file"); RNA_def_boolean(ot->srna, "use_scripts", 1, "Trusted Source", "Allow blend file execute scripts automatically, default available from system preferences"); @@ -1840,7 +1850,7 @@ static void WM_OT_link_append(wmOperatorType *ot) ot->flag |= OPTYPE_UNDO; - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH|WM_FILESEL_FILES); + WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_LOADLIB, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_DIRECTORY|WM_FILESEL_FILENAME| WM_FILESEL_RELPATH|WM_FILESEL_FILES, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "link", 1, "Link", "Link the objects or datablocks rather than appending"); RNA_def_boolean(ot->srna, "autoselect", 1, "Select", "Select the linked objects"); @@ -1921,7 +1931,7 @@ static void WM_OT_recover_auto_save(wmOperatorType *ot) ot->invoke= wm_recover_auto_save_invoke; ot->poll= WM_operator_winactive; - WM_operator_properties_filesel(ot, BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, BLENDERFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_LONGDISPLAY); } /* *************** save file as **************** */ @@ -2035,7 +2045,7 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) ot->check= blend_save_check; /* ommit window poll so this can work in background mode */ - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); RNA_def_boolean(ot->srna, "relative_remap", 1, "Remap Relative", "Remap relative paths when saving in a different directory"); RNA_def_boolean(ot->srna, "copy", 0, "Save Copy", "Save a copy of the actual working state but does not make saved file active"); @@ -2102,7 +2112,7 @@ static void WM_OT_save_mainfile(wmOperatorType *ot) ot->check= blend_save_check; /* ommit window poll so this can work in background mode */ - WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|BLENDERFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "compress", 0, "Compress", "Write compressed .blend file"); RNA_def_boolean(ot->srna, "relative_remap", 0, "Remap Relative", "Remap relative paths when saving in a different directory"); } From 7a628a3967b08f8a099791572112a9e68c4144c6 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 24 Jan 2012 19:54:18 +0000 Subject: [PATCH 054/105] Enable 16 bit format for float textures by default after discussion with Morten and Sergey on irc. Rationale is that for most cases when people create a float texture they will expect the extra precision in the 3D view. This shouldn't be a problem on any graphics card since internally a very old texture format (GL 1.1) is used. In the case of any unlikely screams, a revert of this commit can be done. --- source/blender/editors/interface/resources.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 7cc9febc603..a70db7ad235 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1731,7 +1731,7 @@ void init_userdef_do_versions(void) SETCOLF(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3); } - U.use_16bit_textures = 0; + U.use_16bit_textures = 1; } /* GL Texture Garbage Collection (variable abused above!) */ From 439e9a39a8dd16076648d8e3eaa6a721ce349a57 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Jan 2012 19:57:34 +0000 Subject: [PATCH 055/105] use a struct to pass normals to normal draw derived mesh callbacks (no functional changes) --- .../blender/editors/space_view3d/drawobject.c | 42 ++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 1482340632e..2766ddab15b 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -154,6 +154,10 @@ typedef struct drawDMFacesSel_userData { int *orig_index; } drawDMFacesSel_userData; +typedef struct drawDMNormal_userData { + float normalsize; +} drawDMNormal_userData; + typedef struct bbsObmodeMeshVerts_userData { void *offset; MVert *mvert; @@ -2212,20 +2216,24 @@ void nurbs_foreachScreenVert( static void draw_dm_face_normals__mapFunc(void *userData, int index, float *cent, float *no) { - ToolSettings *ts= ((Scene *)userData)->toolsettings; + drawDMNormal_userData *data = userData; EditFace *efa = EM_get_face_for_index(index); if (efa->h==0 && efa->fgonf!=EM_FGON) { glVertex3fv(cent); - glVertex3f( cent[0] + no[0]*ts->normalsize, - cent[1] + no[1]*ts->normalsize, - cent[2] + no[2]*ts->normalsize); + glVertex3f(cent[0] + no[0] * data->normalsize, + cent[1] + no[1] * data->normalsize, + cent[2] + no[2] * data->normalsize); } } static void draw_dm_face_normals(Scene *scene, DerivedMesh *dm) { + drawDMNormal_userData data; + + data.normalsize = scene->toolsettings->normalsize; + glBegin(GL_LINES); - dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, scene); + dm->foreachMappedFaceCenter(dm, draw_dm_face_normals__mapFunc, &data); glEnd(); } @@ -2247,28 +2255,32 @@ static void draw_dm_face_centers(DerivedMesh *dm, int sel) static void draw_dm_vert_normals__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s) { - Scene *scene= (Scene *)userData; - ToolSettings *ts= scene->toolsettings; + drawDMNormal_userData *data = userData; EditVert *eve = EM_get_vert_for_index(index); if (eve->h==0) { glVertex3fv(co); if (no_f) { - glVertex3f( co[0] + no_f[0]*ts->normalsize, - co[1] + no_f[1]*ts->normalsize, - co[2] + no_f[2]*ts->normalsize); - } else { - glVertex3f( co[0] + no_s[0]*ts->normalsize/32767.0f, - co[1] + no_s[1]*ts->normalsize/32767.0f, - co[2] + no_s[2]*ts->normalsize/32767.0f); + glVertex3f(co[0] + no_f[0] * data->normalsize, + co[1] + no_f[1] * data->normalsize, + co[2] + no_f[2] * data->normalsize); + } + else { + glVertex3f(co[0] + no_s[0] * (data->normalsize / 32767.0f), + co[1] + no_s[1] * (data->normalsize / 32767.0f), + co[2] + no_s[2] * (data->normalsize / 32767.0f)); } } } static void draw_dm_vert_normals(Scene *scene, DerivedMesh *dm) { + drawDMNormal_userData data; + + data.normalsize = scene->toolsettings->normalsize; + glBegin(GL_LINES); - dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, scene); + dm->foreachMappedVert(dm, draw_dm_vert_normals__mapFunc, &data); glEnd(); } From c905415f6bf498ebf0351aae040ea52983a5b36e Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 24 Jan 2012 20:10:37 +0000 Subject: [PATCH 056/105] Cycles Node Editor: * Add Use Nodes button for World shader type * UI was not redrawing the Node area, when enabling "Use nodes", added check for it to the listener. --- intern/cycles/blender/addon/ui.py | 2 +- release/scripts/startup/bl_ui/space_node.py | 1 + source/blender/editors/space_node/space_node.c | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index f44c04e36f8..763cff0bd7d 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -241,7 +241,7 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel): class Cycles_PT_context_material(CyclesButtonsPanel, Panel): - bl_label = "Surface" + bl_label = "" bl_context = "material" bl_options = {'HIDE_HEADER'} diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index e1a599dca2e..f875fab415f 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -61,6 +61,7 @@ class NODE_HT_header(Header): if snode.shader_type == 'WORLD': layout.template_ID(scene, "world", new="world.new") + layout.prop(snode_id, "use_nodes") elif snode.tree_type == 'TEXTURE': layout.prop(snode, "texture_type", text="", expand=True) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 9d4c5705bd1..a00b1d1d2dc 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -214,6 +214,11 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_refresh(sa); } break; + case NC_WORLD: + if(type==NTREE_SHADER) { + ED_area_tag_refresh(sa); + } + break; case NC_OBJECT: if(type==NTREE_SHADER) { if(wmn->data==ND_OB_SHADING) From d888b19d9080c5d977105ffe4035c6280ab1d9af Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 24 Jan 2012 20:13:44 +0000 Subject: [PATCH 057/105] Fix compilation error caused by recent changes in file browser stuff --- source/blender/windowmanager/intern/wm_operators.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 4cf36de7f5f..faf2d3fd352 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2166,7 +2166,7 @@ static void WM_OT_collada_export(wmOperatorType *ot) ot->exec= wm_collada_export_exec; ot->poll= WM_operator_winactive; - WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_boolean(ot->srna, "selected", 0, "Export only selected", "Export only selected elements"); } @@ -2198,7 +2198,7 @@ static void WM_OT_collada_import(wmOperatorType *ot) ot->exec= wm_collada_import_exec; ot->poll= WM_operator_winactive; - WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH); + WM_operator_properties_filesel(ot, FOLDERFILE|COLLADAFILE, FILE_BLENDER, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); } #endif From 8169ad0219c54edca8b9209b1320be44462e9ce9 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 24 Jan 2012 20:19:26 +0000 Subject: [PATCH 058/105] Improvement for last commit, only do redraw when actually needed (in world shader type) --- source/blender/editors/space_node/space_node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index a00b1d1d2dc..493fb854585 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -169,6 +169,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) /* note, ED_area_tag_refresh will re-execute compositor */ SpaceNode *snode= sa->spacedata.first; int type= snode->treetype; + short shader_type = snode->shaderfrom; /* preview renders */ switch(wmn->category) { @@ -215,7 +216,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_WORLD: - if(type==NTREE_SHADER) { + if(type==NTREE_SHADER && shader_type==SNODE_SHADER_WORLD) { ED_area_tag_refresh(sa); } break; From 5cf9f8ab908ac4dab9b22e55ec760a8c574b51d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Jan 2012 20:33:26 +0000 Subject: [PATCH 059/105] fix for memory leak when particles have 0 elements. --- source/blender/blenkernel/intern/particle_system.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 4afe9412786..5bb0ffbb76a 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1126,6 +1126,9 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D fprintf(stderr,"Particle distribution error: Nothing to emit from!\n"); if(dm != finaldm) dm->release(dm); + + BLI_kdtree_free(tree); + return 0; } From fb1fba1454765f746df93cffc2ec6e3e2d9ff3bc Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 24 Jan 2012 20:56:19 +0000 Subject: [PATCH 060/105] Node UI: * Make sure to check on snode_id, raised errors if no world datablock was active. --- release/scripts/startup/bl_ui/space_node.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index f875fab415f..d29dff49132 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -61,7 +61,8 @@ class NODE_HT_header(Header): if snode.shader_type == 'WORLD': layout.template_ID(scene, "world", new="world.new") - layout.prop(snode_id, "use_nodes") + if snode_id: + layout.prop(snode_id, "use_nodes") elif snode.tree_type == 'TEXTURE': layout.prop(snode, "texture_type", text="", expand=True) From 1aadbdedc748c1bc63b1ffa25793858a06c4ba21 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Jan 2012 22:15:25 +0000 Subject: [PATCH 061/105] found a bug by accident. - bugfix for setting string defaults in rna functions (incorrect pointer use and would copy past string length). - Object.dm_info was setting a default when it didnt need to. --- source/blender/makesrna/intern/rna_access.c | 2 +- source/blender/makesrna/intern/rna_object_api.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 4eebfc52920..7d366afd3ca 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4746,7 +4746,7 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *UNUSE case PROP_STRING: { const char *defvalue= ((StringPropertyRNA*)parm)->defaultvalue; if(defvalue && defvalue[0]) - memcpy(data, &defvalue, size); + BLI_strncpy(data, defvalue, size); break; } case PROP_POINTER: diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 0246e22d928..188ccccbfc4 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -643,7 +643,7 @@ void RNA_api_object(StructRNA *srna) parm= RNA_def_enum(func, "type", mesh_dm_info_items, 0, "", "Modifier settings to apply"); RNA_def_property_flag(parm, PROP_REQUIRED); /* weak!, no way to return dynamic string type */ - parm= RNA_def_string(func, "result", "result", 16384, "result", ""); + parm= RNA_def_string(func, "result", "", 16384, "result", ""); RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */ RNA_def_function_output(func, parm); #endif /* NDEBUG */ From 345703fbef36649c6738afe226bb25b65ab9fd17 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 25 Jan 2012 01:39:38 +0000 Subject: [PATCH 062/105] Cucumber left over: new scene needs a default ESC key --- source/blender/blenkernel/intern/scene.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 281631168cd..c8ec71d512f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -531,6 +531,8 @@ Scene *add_scene(const char *name) sce->gm.recastData.detailsampledist = 6.0f; sce->gm.recastData.detailsamplemaxerror = 1.0f; + sce->gm.exitkey = 218; // Blender key code for ESC + sound_create_scene(sce); return sce; From 128741a02e4c7fb9d0c6872fe1ae690c9de7c63d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 25 Jan 2012 09:27:18 +0000 Subject: [PATCH 063/105] Fix typo in camera reconstruction context creation. Thanks to Lockal to pointing out! --- source/blender/blenkernel/intern/tracking.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 0c3c43bebc3..370463b650c 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1838,7 +1838,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking * context->k1= camera->k1; context->k2= camera->k2; - context->k2= camera->k2; + context->k3= camera->k3; return context; } From b8586f4ec347430b2bf00494ab885bd787f26869 Mon Sep 17 00:00:00 2001 From: "Sv. Lockal" Date: Wed, 25 Jan 2012 10:10:15 +0000 Subject: [PATCH 064/105] Fix typo for sharpen graph post-processing so fac1+fac2+fac3 always equals 1.0 --- source/blender/editors/armature/reeb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index fe9eb6dcd01..bcdda8e9eb1 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -1174,7 +1174,7 @@ void postprocessGraph(ReebGraph *rg, char mode) fac2 = 0.5f; break; case SKGEN_SHARPEN: - fac1 = fac2 = -0.25f; + fac1 = fac3 = -0.25f; fac2 = 1.5f; break; default: From bce89860f52b150ea7da7bbeefd2cdd62b75ae33 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 25 Jan 2012 13:37:11 +0000 Subject: [PATCH 065/105] Various fixes for camera tracking stuff - Fixed tooltip displaying for track sequence forwards in clip editor - Corrected detection of 8 tracks so it wouldn't count tracks disabled on keyframes. - Scale track preview to actual track widget size instead of scaling the whole preview image with given zoom ratio, so no extra memory needed to store zoomed margin would be used. - Track's statistics text will fit pattern position instead of search if marker is disabled on current frame. - Fixed toggle selection operator if selected track is hidden due to "Hide Disabled" policy. --- release/scripts/startup/bl_ui/space_clip.py | 1 + source/blender/blenkernel/BKE_tracking.h | 1 + source/blender/blenkernel/intern/tracking.c | 13 ++++-- .../editors/interface/interface_draw.c | 42 ++++++++++--------- source/blender/editors/space_clip/clip_draw.c | 4 +- .../blender/editors/space_clip/tracking_ops.c | 13 ++++-- 6 files changed, 47 insertions(+), 27 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 55c10a56015..c8582e532bb 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -172,6 +172,7 @@ class CLIP_PT_tools_tracking(Panel): props.backwards = True props.sequence = True props = row.operator("clip.track_markers", text="", icon='PLAY') + props.backwards = False props.sequence = True row.operator("clip.track_markers", text="", icon='FRAME_NEXT') diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index d3f297ece86..f720050f59c 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -61,6 +61,7 @@ struct MovieTrackingMarker *BKE_tracking_get_marker(struct MovieTrackingTrack *t struct MovieTrackingMarker *BKE_tracking_ensure_marker(struct MovieTrackingTrack *track, int framenr); struct MovieTrackingMarker *BKE_tracking_exact_marker(struct MovieTrackingTrack *track, int framenr); int BKE_tracking_has_marker(struct MovieTrackingTrack *track, int framenr); +int BKE_tracking_has_enabled_marker(struct MovieTrackingTrack *track, int framenr); void BKE_tracking_free_track(struct MovieTrackingTrack *track); diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 370463b650c..ea3f076523f 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -395,6 +395,13 @@ int BKE_tracking_has_marker(MovieTrackingTrack *track, int framenr) return BKE_tracking_exact_marker(track, framenr) != 0; } +int BKE_tracking_has_enabled_marker(MovieTrackingTrack *track, int framenr) +{ + MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr); + + return marker && (marker->flag & MARKER_DISABLED) == 0; +} + void BKE_tracking_free_track(MovieTrackingTrack *track) { if(track->markers) MEM_freeN(track->markers); @@ -1741,8 +1748,8 @@ static int count_tracks_on_both_keyframes(MovieTracking *tracking, ListBase *tra track= tracksbase->first; while(track) { - if(BKE_tracking_has_marker(track, frame1)) - if(BKE_tracking_has_marker(track, frame2)) + if(BKE_tracking_has_enabled_marker(track, frame1)) + if(BKE_tracking_has_enabled_marker(track, frame2)) tot++; track= track->next; @@ -1758,7 +1765,7 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object); if(count_tracks_on_both_keyframes(tracking, tracksbase)<8) { - BLI_strncpy(error_msg, "At least 8 tracks on both of keyframes are needed for reconstruction", error_size); + BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size); return 0; } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 56f7fd04080..d79bc7d2974 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1461,19 +1461,21 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } -static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float zoomx, float zoomy) +static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float track_pos[2], int width, float height, int margin) { ImBuf *scaleibuf; - int x, y, w= ibuf->x*zoomx, h= ibuf->y*zoomy; - const float scalex= 1.0f/zoomx; - const float scaley= 1.0f/zoomy; + const float scalex= ((float)ibuf->x-2*margin) / width; + const float scaley= ((float)ibuf->y-2*margin) / height; + float off_x= (int)track_pos[0]-track_pos[0]+0.5f; + float off_y= (int)track_pos[1]-track_pos[1]+0.5f; + int x, y; - scaleibuf= IMB_allocImBuf(w, h, 32, IB_rect); + scaleibuf= IMB_allocImBuf(width, height, 32, IB_rect); - for(y= 0; ytrack_disabled) { glColor4f(0.7f, 0.3f, 0.3f, 0.3f); uiSetRoundBox(15); - uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f); ok= 1; } @@ -1512,8 +1514,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc /* additional margin around image */ /* NOTE: should be kept in sync with value from BKE_movieclip_update_scopes */ const int margin= 3; - float zoomx, zoomy, track_pos[2], off_x, off_y, x0, y0; - int a; + float zoomx, zoomy, track_pos[2], off_x, off_y; + int a, width, height; ImBuf *drawibuf; glPushMatrix(); @@ -1524,16 +1526,18 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc /* draw content of pattern area */ glScissor(ar->winrct.xmin+rect.xmin, ar->winrct.ymin+rect.ymin, scissor[2], scissor[3]); - zoomx= (rect.xmax-rect.xmin) / (scopes->track_preview->x-2*margin); - zoomy= (rect.ymax-rect.ymin) / (scopes->track_preview->y-2*margin); + width= rect.xmax-rect.xmin+1; + height = rect.ymax-rect.ymin; + + zoomx= (float)width / (scopes->track_preview->x-2*margin); + zoomy= (float)height / (scopes->track_preview->y-2*margin); off_x= ((int)track_pos[0]-track_pos[0]+0.5)*zoomx; off_y= ((int)track_pos[1]-track_pos[1]+0.5)*zoomy; - x0= (int)(off_x+rect.xmin-zoomx*(margin-0.5f))+1; - y0= (int)(off_y+rect.ymin-zoomy*(margin-0.5f))+1; - drawibuf= scale_trackpreview_ibuf(scopes->track_preview, zoomx, zoomy); - glaDrawPixelsSafe(x0, y0, rect.xmax-x0+1, rect.ymax-y0+1, + drawibuf= scale_trackpreview_ibuf(scopes->track_preview, track_pos, width, height, margin); + + glaDrawPixelsSafe(rect.xmin, rect.ymin+1, drawibuf->x, drawibuf->y, drawibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, drawibuf->rect); IMB_freeImBuf(drawibuf); @@ -1568,7 +1572,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc if(!ok) { glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(15); - uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); + uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f); } /* outline, scale gripper */ diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index eb8f30b6739..a331703690b 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -777,7 +777,9 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra else UI_ThemeColor(TH_SEL_MARKER); } - if(sc->flag&SC_SHOW_MARKER_SEARCH) { + if((sc->flag&SC_SHOW_MARKER_SEARCH) && + ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0)) + { dx= track->search_min[0]; dy= track->search_min[1]; } else if(sc->flag&SC_SHOW_MARKER_PATTERN) { diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 7fcd761fc49..f21b50ec592 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1014,6 +1014,7 @@ static int select_all_exec(bContext *C, wmOperator *op) SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); MovieTrackingTrack *track= NULL; /* selected track */ + MovieTrackingMarker *marker; ListBase *tracksbase= BKE_tracking_get_tracks(&clip->tracking); int action= RNA_enum_get(op->ptr, "action"); int framenr= sc->user.framenr; @@ -1024,8 +1025,12 @@ static int select_all_exec(bContext *C, wmOperator *op) track= tracksbase->first; while(track) { if(TRACK_VIEW_SELECTED(sc, track)) { - action= SEL_DESELECT; - break; + marker= BKE_tracking_get_marker(track, framenr); + + if(MARKER_VISIBLE(sc, marker)) { + action= SEL_DESELECT; + break; + } } track= track->next; @@ -1035,9 +1040,9 @@ static int select_all_exec(bContext *C, wmOperator *op) track= tracksbase->first; while(track) { if((track->flag&TRACK_HIDDEN)==0) { - MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr); + marker= BKE_tracking_get_marker(track, framenr); - if(marker && MARKER_VISIBLE(sc, marker)) { + if(MARKER_VISIBLE(sc, marker)) { switch (action) { case SEL_SELECT: track->flag|= SELECT; From 14f475fccad7158098ddecc285c617f990b2f8b5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 25 Jan 2012 16:14:24 +0000 Subject: [PATCH 066/105] Fix #29892: Properties of objects in nested custom collections stop being animatable once an object get added to an unrelated custom collection. Issue was caused by attempting to find rna path in all property collections which lead to overwritting already found path. --- source/blender/makesrna/intern/rna_access.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 7d366afd3ca..3dc0e7c37e4 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3979,6 +3979,8 @@ static char *rna_idp_path(PointerRNA *ptr, IDProperty *haystack, IDProperty *nee } } } + if(path) + break; } } } From f99343d3b8676543e2bd6acd6ee2274c21b1b388 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 25 Jan 2012 17:23:52 +0000 Subject: [PATCH 067/105] Cycles: Render Passes Currently supported passes: * Combined, Z, Normal, Object Index, Material Index, Emission, Environment, Diffuse/Glossy/Transmission x Direct/Indirect/Color Not supported yet: * UV, Vector, Mist Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow, also for environment importance sampling. Documentation: http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes --- intern/cycles/blender/addon/ui.py | 32 ++ intern/cycles/blender/blender_object.cpp | 1 + intern/cycles/blender/blender_session.cpp | 113 ++++++- intern/cycles/blender/blender_shader.cpp | 1 + intern/cycles/device/device_cpu.cpp | 8 +- intern/cycles/kernel/CMakeLists.txt | 2 + intern/cycles/kernel/kernel.cl | 4 +- intern/cycles/kernel/kernel.cpp | 4 +- intern/cycles/kernel/kernel.cu | 4 +- intern/cycles/kernel/kernel.h | 8 +- intern/cycles/kernel/kernel_accumulate.h | 283 ++++++++++++++++++ intern/cycles/kernel/kernel_emission.h | 23 +- intern/cycles/kernel/kernel_film.h | 13 +- intern/cycles/kernel/kernel_object.h | 10 + intern/cycles/kernel/kernel_optimized.cpp | 4 +- intern/cycles/kernel/kernel_passes.h | 146 +++++++++ intern/cycles/kernel/kernel_path.h | 109 +++---- intern/cycles/kernel/kernel_random.h | 44 ++- intern/cycles/kernel/kernel_shader.h | 108 +++++-- intern/cycles/kernel/kernel_types.h | 99 +++++- intern/cycles/kernel/svm/svm_types.h | 25 +- intern/cycles/render/buffers.cpp | 120 +++++++- intern/cycles/render/buffers.h | 42 +-- intern/cycles/render/film.cpp | 179 ++++++++++- intern/cycles/render/film.h | 15 + intern/cycles/render/object.cpp | 4 +- intern/cycles/render/object.h | 1 + intern/cycles/render/shader.cpp | 5 +- intern/cycles/render/shader.h | 1 + source/blender/blenkernel/BKE_node.h | 47 +-- source/blender/makesdna/DNA_scene_types.h | 47 +-- source/blender/makesrna/intern/rna_render.c | 9 + source/blender/makesrna/intern/rna_scene.c | 54 ++++ .../nodes/composite/node_composite_tree.c | 23 +- .../composite/nodes/node_composite_image.c | 83 +++-- .../render/intern/source/render_result.c | 100 +++++++ 36 files changed, 1528 insertions(+), 243 deletions(-) create mode 100644 intern/cycles/kernel/kernel_accumulate.h create mode 100644 intern/cycles/kernel/kernel_passes.h diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 763cff0bd7d..6353bf37a15 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -183,6 +183,38 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel): layout.separator() + split = layout.split() + + col = split.column() + col.label(text="Passes:") + col.prop(rl, "use_pass_combined") + col.prop(rl, "use_pass_z") + col.prop(rl, "use_pass_normal") + col.prop(rl, "use_pass_object_index") + col.prop(rl, "use_pass_material_index") + col.prop(rl, "use_pass_emit") + col.prop(rl, "use_pass_environment") + + col = split.column() + col.label() + col.label(text="Diffuse:") + row = col.row(align=True) + row.prop(rl, "use_pass_diffuse_direct", text="Direct", toggle=True) + row.prop(rl, "use_pass_diffuse_indirect", text="Indirect", toggle=True) + row.prop(rl, "use_pass_diffuse_color", text="Color", toggle=True) + col.label(text="Glossy:") + row = col.row(align=True) + row.prop(rl, "use_pass_glossy_direct", text="Direct", toggle=True) + row.prop(rl, "use_pass_glossy_indirect", text="Indirect", toggle=True) + row.prop(rl, "use_pass_glossy_color", text="Color", toggle=True) + col.label(text="Transmission:") + row = col.row(align=True) + row.prop(rl, "use_pass_transmission_direct", text="Direct", toggle=True) + row.prop(rl, "use_pass_transmission_indirect", text="Indirect", toggle=True) + row.prop(rl, "use_pass_transmission_color", text="Color", toggle=True) + + layout.separator() + rl = rd.layers[0] layout.prop(rl, "material_override", text="Material") diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index c805bd03063..afcfcd95063 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -214,6 +214,7 @@ void BlenderSync::sync_object(BL::Object b_parent, int b_index, BL::Object b_ob, /* object sync */ if(object_updated || (object->mesh && object->mesh->need_update)) { object->name = b_ob.name().c_str(); + object->pass_id = b_ob.pass_index(); object->tfm = tfm; /* visibility flags for both parent */ diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index b052fb3e195..ff1c32831bb 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -116,9 +116,68 @@ void BlenderSession::free_session() delete session; } +static PassType get_pass_type(BL::RenderPass b_pass) +{ + switch(b_pass.type()) { + case BL::RenderPass::type_COMBINED: + return PASS_COMBINED; + + case BL::RenderPass::type_Z: + return PASS_DEPTH; + case BL::RenderPass::type_NORMAL: + return PASS_NORMAL; + case BL::RenderPass::type_OBJECT_INDEX: + return PASS_OBJECT_ID; + case BL::RenderPass::type_UV: + return PASS_UV; + case BL::RenderPass::type_MATERIAL_INDEX: + return PASS_MATERIAL_ID; + + case BL::RenderPass::type_DIFFUSE_DIRECT: + return PASS_DIFFUSE_DIRECT; + case BL::RenderPass::type_GLOSSY_DIRECT: + return PASS_GLOSSY_DIRECT; + case BL::RenderPass::type_TRANSMISSION_DIRECT: + return PASS_TRANSMISSION_DIRECT; + + case BL::RenderPass::type_DIFFUSE_INDIRECT: + return PASS_DIFFUSE_INDIRECT; + case BL::RenderPass::type_GLOSSY_INDIRECT: + return PASS_GLOSSY_INDIRECT; + case BL::RenderPass::type_TRANSMISSION_INDIRECT: + return PASS_TRANSMISSION_INDIRECT; + + case BL::RenderPass::type_DIFFUSE_COLOR: + return PASS_DIFFUSE_COLOR; + case BL::RenderPass::type_GLOSSY_COLOR: + return PASS_GLOSSY_COLOR; + case BL::RenderPass::type_TRANSMISSION_COLOR: + return PASS_TRANSMISSION_COLOR; + + case BL::RenderPass::type_EMIT: + return PASS_EMISSION; + case BL::RenderPass::type_ENVIRONMENT: + return PASS_BACKGROUND; + + case BL::RenderPass::type_DIFFUSE: + case BL::RenderPass::type_SHADOW: + case BL::RenderPass::type_AO: + case BL::RenderPass::type_COLOR: + case BL::RenderPass::type_REFRACTION: + case BL::RenderPass::type_SPECULAR: + case BL::RenderPass::type_REFLECTION: + case BL::RenderPass::type_VECTOR: + case BL::RenderPass::type_MIST: + return PASS_NONE; + } + + return PASS_NONE; +} + void BlenderSession::render() { /* get buffer parameters */ + SessionParams session_params = BlenderSync::get_session_params(b_userpref, b_scene, background); BufferParams buffer_params = BlenderSync::get_buffer_params(b_scene, b_rv3d, width, height); int w = buffer_params.width, h = buffer_params.height; @@ -143,6 +202,25 @@ void BlenderSession::render() /* set layer */ b_rlay = *b_iter; + /* add passes */ + if(session_params.device.type == DEVICE_CPU) { /* todo */ + BL::RenderLayer::passes_iterator b_pass_iter; + + for(b_rlay.passes.begin(b_pass_iter); b_pass_iter != b_rlay.passes.end(); ++b_pass_iter) { + BL::RenderPass b_pass(*b_pass_iter); + PassType pass_type = get_pass_type(b_pass); + + if(pass_type != PASS_NONE) + Pass::add(pass_type, buffer_params.passes); + } + } + + scene->film->passes = buffer_params.passes; + scene->film->need_update = true; + + /* update session */ + session->reset(buffer_params, session_params.samples); + /* update scene */ sync->sync_data(b_v3d, active); @@ -165,22 +243,41 @@ void BlenderSession::write_render_result() { /* get state */ RenderBuffers *buffers = session->buffers; + + /* copy data from device */ + if(!buffers->copy_from_device()) + return; + + BufferParams& params = buffers->params; float exposure = scene->film->exposure; double total_time, sample_time; int sample; + session->progress.get_sample(sample, total_time, sample_time); - /* get pixels */ - float4 *pixels = buffers->copy_from_device(exposure, sample); + vector pixels(params.width*params.height*4); - if(!pixels) - return; + /* copy each pass */ + BL::RenderLayer::passes_iterator b_iter; + + for(b_rlay.passes.begin(b_iter); b_iter != b_rlay.passes.end(); ++b_iter) { + BL::RenderPass b_pass(*b_iter); - /* write pixels */ - rna_RenderLayer_rect_set(&b_rlay.ptr, (float*)pixels); + /* find matching pass type */ + PassType pass_type = get_pass_type(b_pass); + int components = b_pass.channels(); + + /* copy pixels */ + if(buffers->get_pass(pass_type, exposure, sample, components, &pixels[0])) + rna_RenderPass_rect_set(&b_pass.ptr, &pixels[0]); + } + + /* copy combined pass */ + if(buffers->get_pass(PASS_COMBINED, exposure, sample, 4, &pixels[0])) + rna_RenderLayer_rect_set(&b_rlay.ptr, &pixels[0]); + + /* tag result as updated */ RE_engine_update_result((RenderEngine*)b_engine.ptr.data, (RenderResult*)b_rr.ptr.data); - - delete [] pixels; } void BlenderSession::synchronize() diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index f7b750e6dab..5310e35dc25 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -636,6 +636,7 @@ void BlenderSync::sync_materials() ShaderGraph *graph = new ShaderGraph(); shader->name = b_mat->name().c_str(); + shader->pass_id = b_mat->pass_index(); /* create nodes */ if(b_mat->use_nodes() && b_mat->node_tree()) { diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 25da978edd8..2ca599f6c67 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -162,7 +162,7 @@ public: if(system_cpu_support_optimized()) { for(int y = task.y; y < task.y + task.h; y++) { for(int x = task.x; x < task.x + task.w; x++) - kernel_cpu_optimized_path_trace(kg, (float4*)task.buffer, (unsigned int*)task.rng_state, + kernel_cpu_optimized_path_trace(kg, (float*)task.buffer, (unsigned int*)task.rng_state, task.sample, x, y, task.offset, task.stride); if(tasks.worker_cancel()) @@ -174,7 +174,7 @@ public: { for(int y = task.y; y < task.y + task.h; y++) { for(int x = task.x; x < task.x + task.w; x++) - kernel_cpu_path_trace(kg, (float4*)task.buffer, (unsigned int*)task.rng_state, + kernel_cpu_path_trace(kg, (float*)task.buffer, (unsigned int*)task.rng_state, task.sample, x, y, task.offset, task.stride); if(tasks.worker_cancel()) @@ -194,7 +194,7 @@ public: if(system_cpu_support_optimized()) { for(int y = task.y; y < task.y + task.h; y++) for(int x = task.x; x < task.x + task.w; x++) - kernel_cpu_optimized_tonemap(kg, (uchar4*)task.rgba, (float4*)task.buffer, + kernel_cpu_optimized_tonemap(kg, (uchar4*)task.rgba, (float*)task.buffer, task.sample, task.resolution, x, y, task.offset, task.stride); } else @@ -202,7 +202,7 @@ public: { for(int y = task.y; y < task.y + task.h; y++) for(int x = task.x; x < task.x + task.w; x++) - kernel_cpu_tonemap(kg, (uchar4*)task.rgba, (float4*)task.buffer, + kernel_cpu_tonemap(kg, (uchar4*)task.rgba, (float*)task.buffer, task.sample, task.resolution, x, y, task.offset, task.stride); } } diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index b6e749f3fcb..59fe9709e61 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -15,6 +15,7 @@ set(SRC set(SRC_HEADERS kernel.h + kernel_accumulate.h kernel_bvh.h kernel_camera.h kernel_compat_cpu.h @@ -30,6 +31,7 @@ set(SRC_HEADERS kernel_mbvh.h kernel_montecarlo.h kernel_object.h + kernel_passes.h kernel_path.h kernel_qbvh.h kernel_random.h diff --git a/intern/cycles/kernel/kernel.cl b/intern/cycles/kernel/kernel.cl index 305d81339c2..f98414d4f02 100644 --- a/intern/cycles/kernel/kernel.cl +++ b/intern/cycles/kernel/kernel.cl @@ -28,7 +28,7 @@ __kernel void kernel_ocl_path_trace( __constant KernelData *data, - __global float4 *buffer, + __global float *buffer, __global uint *rng_state, #define KERNEL_TEX(type, ttype, name) \ @@ -56,7 +56,7 @@ __kernel void kernel_ocl_path_trace( __kernel void kernel_ocl_tonemap( __constant KernelData *data, __global uchar4 *rgba, - __global float4 *buffer, + __global float *buffer, #define KERNEL_TEX(type, ttype, name) \ __global type *name, diff --git a/intern/cycles/kernel/kernel.cpp b/intern/cycles/kernel/kernel.cpp index 9e0d252772b..a93f6172d28 100644 --- a/intern/cycles/kernel/kernel.cpp +++ b/intern/cycles/kernel/kernel.cpp @@ -204,14 +204,14 @@ void kernel_tex_copy(KernelGlobals *kg, const char *name, device_ptr mem, size_t /* Path Tracing */ -void kernel_cpu_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride) +void kernel_cpu_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride) { kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride); } /* Tonemapping */ -void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, int sample, int resolution, int x, int y, int offset, int stride) +void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float *buffer, int sample, int resolution, int x, int y, int offset, int stride) { kernel_film_tonemap(kg, rgba, buffer, sample, resolution, x, y, offset, stride); } diff --git a/intern/cycles/kernel/kernel.cu b/intern/cycles/kernel/kernel.cu index 4e585fd563d..fc7992c87f0 100644 --- a/intern/cycles/kernel/kernel.cu +++ b/intern/cycles/kernel/kernel.cu @@ -26,7 +26,7 @@ #include "kernel_path.h" #include "kernel_displace.h" -extern "C" __global__ void kernel_cuda_path_trace(float4 *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride) +extern "C" __global__ void kernel_cuda_path_trace(float *buffer, uint *rng_state, int sample, int sx, int sy, int sw, int sh, int offset, int stride) { int x = sx + blockDim.x*blockIdx.x + threadIdx.x; int y = sy + blockDim.y*blockIdx.y + threadIdx.y; @@ -35,7 +35,7 @@ extern "C" __global__ void kernel_cuda_path_trace(float4 *buffer, uint *rng_stat kernel_path_trace(NULL, buffer, rng_state, sample, x, y, offset, stride); } -extern "C" __global__ void kernel_cuda_tonemap(uchar4 *rgba, float4 *buffer, int sample, int resolution, int sx, int sy, int sw, int sh, int offset, int stride) +extern "C" __global__ void kernel_cuda_tonemap(uchar4 *rgba, float *buffer, int sample, int resolution, int sx, int sy, int sw, int sh, int offset, int stride) { int x = sx + blockDim.x*blockIdx.x + threadIdx.x; int y = sy + blockDim.y*blockIdx.y + threadIdx.y; diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h index df6b5ee92da..26c0bcd6d1a 100644 --- a/intern/cycles/kernel/kernel.h +++ b/intern/cycles/kernel/kernel.h @@ -36,17 +36,17 @@ bool kernel_osl_use(KernelGlobals *kg); void kernel_const_copy(KernelGlobals *kg, const char *name, void *host, size_t size); void kernel_tex_copy(KernelGlobals *kg, const char *name, device_ptr mem, size_t width, size_t height); -void kernel_cpu_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state, +void kernel_cpu_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride); -void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, +void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float *buffer, int sample, int resolution, int x, int y, int offset, int stride); void kernel_cpu_shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int i); #ifdef WITH_OPTIMIZED_KERNEL -void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state, +void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride); -void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, +void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float *buffer, int sample, int resolution, int x, int y, int offset, int stride); void kernel_cpu_optimized_shader(KernelGlobals *kg, uint4 *input, float4 *output, int type, int i); diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h new file mode 100644 index 00000000000..e71fad58c96 --- /dev/null +++ b/intern/cycles/kernel/kernel_accumulate.h @@ -0,0 +1,283 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +CCL_NAMESPACE_BEGIN + +/* BSDF Eval + * + * BSDF evaluation result, split per BSDF type. This is used to accumulate + * render passes separately. */ + +__device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass) +{ +#ifdef __PASSES__ + eval->use_light_pass = use_light_pass; + + if(eval->use_light_pass) { + eval->diffuse = make_float3(0.0f, 0.0f, 0.0f); + eval->glossy = make_float3(0.0f, 0.0f, 0.0f); + eval->transmission = make_float3(0.0f, 0.0f, 0.0f); + eval->transparent = make_float3(0.0f, 0.0f, 0.0f); + + if(type == CLOSURE_BSDF_TRANSPARENT_ID) + eval->transparent = value; + else if(CLOSURE_IS_BSDF_DIFFUSE(type)) + eval->diffuse = value; + else if(CLOSURE_IS_BSDF_GLOSSY(type)) + eval->glossy = value; + else + eval->transmission = value; + } + else + eval->diffuse = value; +#else + *eval = value; +#endif +} + +__device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value) +{ +#ifdef __PASSES__ + if(eval->use_light_pass) { + if(CLOSURE_IS_BSDF_DIFFUSE(type)) + eval->diffuse += value; + else if(CLOSURE_IS_BSDF_GLOSSY(type)) + eval->glossy += value; + else + eval->transmission += value; + + /* skipping transparent, this function is used by for eval(), will be zero then */ + } + else + eval->diffuse += value; +#else + *eval += value; +#endif +} + +__device_inline bool bsdf_eval_is_zero(BsdfEval *eval) +{ +#ifdef __PASSES__ + if(eval->use_light_pass) { + return is_zero(eval->diffuse) + && is_zero(eval->glossy) + && is_zero(eval->transmission) + && is_zero(eval->transparent); + } + else + return is_zero(eval->diffuse); +#else + return is_zero(*eval); +#endif +} + +__device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value) +{ +#ifdef __PASSES__ + if(eval->use_light_pass) { + eval->diffuse *= value; + eval->glossy *= value; + eval->transmission *= value; + + /* skipping transparent, this function is used by for eval(), will be zero then */ + } + else + eval->diffuse *= value; +#else + *eval *= value; +#endif +} + +/* Path Radiance + * + * We accumulate different render passes separately. After summing at the end + * to get the combined result, it should be identical. We definte directly + * visible as the first non-transparent hit, while indirectly visible are the + * bounces after that. */ + +__device_inline void path_radiance_init(PathRadiance *L, int use_light_pass) +{ + /* clear all */ +#ifdef __PASSES__ + L->use_light_pass = use_light_pass; + + if(use_light_pass) { + L->indirect = make_float3(0.0f, 0.0f, 0.0f); + L->direct_throughput = make_float3(0.0f, 0.0f, 0.0f); + L->direct_emission = make_float3(0.0f, 0.0f, 0.0f); + + L->color_diffuse = make_float3(0.0f, 0.0f, 0.0f); + L->color_glossy = make_float3(0.0f, 0.0f, 0.0f); + L->color_transmission = make_float3(0.0f, 0.0f, 0.0f); + + L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f); + L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f); + L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f); + + L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f); + L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f); + L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f); + + L->emission = make_float3(0.0f, 0.0f, 0.0f); + L->background = make_float3(0.0f, 0.0f, 0.0f); + } + else + L->emission = make_float3(0.0f, 0.0f, 0.0f); +#else + *L = make_float3(0.0f, 0.0f, 0.0f); +#endif +} + +__device_inline void path_radiance_bsdf_bounce(PathRadiance *L, float3 *throughput, + BsdfEval *bsdf_eval, float bsdf_pdf, int bounce, int bsdf_label) +{ + float inverse_pdf = 1.0f/bsdf_pdf; + +#ifdef __PASSES__ + if(L->use_light_pass) { + if(bounce == 0) { + if(bsdf_label & LABEL_TRANSPARENT) { + /* transparent bounce before first hit */ + *throughput *= bsdf_eval->transparent*inverse_pdf; + } + else { + /* first on directly visible surface */ + float3 value = *throughput*inverse_pdf; + + L->indirect_diffuse = bsdf_eval->diffuse*value; + L->indirect_glossy = bsdf_eval->glossy*value; + L->indirect_transmission = bsdf_eval->transmission*value; + + *throughput = L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission; + + L->direct_throughput = *throughput; + } + } + else { + /* indirectly visible through BSDF */ + float3 sum = (bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->transparent)*inverse_pdf; + *throughput *= sum; + } + } + else + *throughput *= bsdf_eval->diffuse*inverse_pdf; +#else + *throughput *= *bsdf_eval*inverse_pdf; +#endif +} + +__device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce) +{ +#ifdef __PASSES__ + if(L->use_light_pass) { + if(bounce == 0) + L->emission += throughput*value; + else if(bounce == 1) + L->direct_emission += throughput*value; + else + L->indirect += throughput*value; + } + else + L->emission += throughput*value; +#else + *L += throughput*value; +#endif +} + +__device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, int bounce) +{ +#ifdef __PASSES__ + if(L->use_light_pass) { + if(bounce == 0) { + /* directly visible lighting */ + L->direct_diffuse += throughput*bsdf_eval->diffuse; + L->direct_glossy += throughput*bsdf_eval->glossy; + L->direct_transmission += throughput*bsdf_eval->transmission; + } + else { + /* indirectly visible lighting after BSDF bounce */ + float3 sum = bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission; + L->indirect += throughput*sum; + } + } + else + L->emission += throughput*bsdf_eval->diffuse; +#else + *L += throughput*(*bsdf_eval); +#endif +} + +__device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce) +{ +#ifdef __PASSES__ + if(L->use_light_pass) { + if(bounce == 0) + L->background += throughput*value; + else if(bounce == 1) + L->direct_emission += throughput*value; + else + L->indirect += throughput*value; + } + else + L->emission += throughput*value; +#else + *L += throughput*value; +#endif +} + +__device_inline float3 safe_divide_color(float3 a, float3 b) +{ + float x, y, z; + + x = (b.x != 0.0f)? a.x/b.x: 0.0f; + y = (b.y != 0.0f)? a.y/b.y: 0.0f; + z = (b.z != 0.0f)? a.z/b.z: 0.0f; + + return make_float3(x, y, z); +} + +__device_inline float3 path_radiance_sum(PathRadiance *L) +{ +#ifdef __PASSES__ + if(L->use_light_pass) { + /* this division is a bit ugly, but means we only have to keep track of + only a single throughput further along the path, here we recover just + the indirect parth that is not influenced by any particular BSDF type */ + L->direct_emission = safe_divide_color(L->direct_emission, L->direct_throughput); + L->direct_diffuse += L->indirect_diffuse*L->direct_emission; + L->direct_glossy += L->indirect_glossy*L->direct_emission; + L->direct_transmission += L->indirect_transmission*L->direct_emission; + + L->indirect = safe_divide_color(L->indirect, L->direct_throughput); + L->indirect_diffuse *= L->indirect; + L->indirect_glossy *= L->indirect; + L->indirect_transmission *= L->indirect; + + return L->emission + L->background + + L->direct_diffuse + L->direct_glossy + L->direct_transmission + + L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission; + } + else + return L->emission; +#else + return *L; +#endif +} + +CCL_NAMESPACE_END + diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 51698f3a9bd..b3a5b2bfcb4 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -57,7 +57,7 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando, } __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex, - float randt, float rando, float randu, float randv, Ray *ray, float3 *eval) + float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval) { LightSample ls; @@ -83,32 +83,33 @@ __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex, return false; /* evaluate closure */ - *eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D); + float3 light_eval = direct_emissive_eval(kg, rando, &ls, randu, randv, -ls.D); - if(is_zero(*eval)) + if(is_zero(light_eval)) return false; /* todo: use visbility flag to skip lights */ /* evaluate BSDF at shading point */ float bsdf_pdf; - float3 bsdf_eval = shader_bsdf_eval(kg, sd, ls.D, &bsdf_pdf); - *eval *= bsdf_eval/pdf; - - if(is_zero(*eval)) - return false; + shader_bsdf_eval(kg, sd, ls.D, eval, &bsdf_pdf); if(ls.prim != ~0 || ls.type == LIGHT_BACKGROUND) { /* multiple importance sampling */ float mis_weight = power_heuristic(pdf, bsdf_pdf); - *eval *= mis_weight; + light_eval *= mis_weight; } /* todo: clean up these weights */ else if(ls.shader & SHADER_AREA_LIGHT) - *eval *= 0.25f; /* area lamp */ + light_eval *= 0.25f; /* area lamp */ else if(ls.t != FLT_MAX) - *eval *= 0.25f*M_1_PI_F; /* point lamp */ + light_eval *= 0.25f*M_1_PI_F; /* point lamp */ + + bsdf_eval_mul(eval, light_eval/pdf); + + if(bsdf_eval_is_zero(eval)) + return false; if(ls.shader & SHADER_CAST_SHADOW) { /* setup ray */ diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h index cd8acc9647a..d0fb5402291 100644 --- a/intern/cycles/kernel/kernel_film.h +++ b/intern/cycles/kernel/kernel_film.h @@ -48,15 +48,22 @@ __device uchar4 film_float_to_byte(float4 color) return result; } -__device void kernel_film_tonemap(KernelGlobals *kg, __global uchar4 *rgba, __global float4 *buffer, int sample, int resolution, int x, int y, int offset, int stride) +__device void kernel_film_tonemap(KernelGlobals *kg, + __global uchar4 *rgba, __global float *buffer, + int sample, int resolution, int x, int y, int offset, int stride) { + /* buffer offset */ int index = offset + x + y*stride; - float4 irradiance = buffer[index]; + rgba += index; + buffer += index*kernel_data.film.pass_stride; + + /* map colors */ + float4 irradiance = *(float4*)buffer; float4 float_result = film_map(kg, irradiance, sample); uchar4 byte_result = film_float_to_byte(float_result); - rgba[index] = byte_result; + *rgba = byte_result; } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h index b4c42d3bacc..318a6fea489 100644 --- a/intern/cycles/kernel/kernel_object.h +++ b/intern/cycles/kernel/kernel_object.h @@ -64,5 +64,15 @@ __device_inline float object_surface_area(KernelGlobals *kg, int object) return f.x; } +__device_inline float object_pass_id(KernelGlobals *kg, int object) +{ + if(object == ~0) + return 0.0f; + + int offset = object*OBJECT_SIZE + OBJECT_PROPERTIES; + float4 f = kernel_tex_fetch(__objects, offset); + return f.y; +} + CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_optimized.cpp b/intern/cycles/kernel/kernel_optimized.cpp index 50341021d9d..393686bb203 100644 --- a/intern/cycles/kernel/kernel_optimized.cpp +++ b/intern/cycles/kernel/kernel_optimized.cpp @@ -35,14 +35,14 @@ CCL_NAMESPACE_BEGIN /* Path Tracing */ -void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride) +void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride) { kernel_path_trace(kg, buffer, rng_state, sample, x, y, offset, stride); } /* Tonemapping */ -void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, int sample, int resolution, int x, int y, int offset, int stride) +void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float *buffer, int sample, int resolution, int x, int y, int offset, int stride) { kernel_film_tonemap(kg, rgba, buffer, sample, resolution, x, y, offset, stride); } diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h new file mode 100644 index 00000000000..0e775812eda --- /dev/null +++ b/intern/cycles/kernel/kernel_passes.h @@ -0,0 +1,146 @@ +/* + * Copyright 2011, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +CCL_NAMESPACE_BEGIN + +__device_inline void kernel_write_pass_float(__global float *buffer, int sample, float value) +{ + float *buf = buffer; + *buf = (sample == 0)? value: *buf + value; +} + +__device_inline void kernel_write_pass_float3(__global float *buffer, int sample, float3 value) +{ + float3 *buf = (float3*)buffer; + *buf = (sample == 0)? value: *buf + value; +} + +__device_inline void kernel_write_pass_float4(__global float *buffer, int sample, float4 value) +{ + float4 *buf = (float4*)buffer; + *buf = (sample == 0)? value: *buf + value; +} + +__device_inline void kernel_clear_passes(__global float *buffer, int sample, int pass_stride) +{ +#ifdef __PASSES__ + if(sample == 0 && pass_stride != 4) + for(int i = 4; i < pass_stride; i++) + buffer[i] = 0.0f; +#endif +} + +__device void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, + ShaderData *sd, int sample, int path_flag, float3 throughput) +{ +#ifdef __PASSES__ + if(!(path_flag & PATH_RAY_CAMERA)) + return; + + int flag = kernel_data.film.pass_flag; + + if(!(flag & PASS_ALL)) + return; + + /* todo: add alpha treshold */ + if(!(path_flag & PATH_RAY_TRANSPARENT)) { + if(sample == 0) { + if(flag & PASS_DEPTH) { + Transform tfm = kernel_data.cam.worldtocamera; + float depth = len(transform(&tfm, sd->P)); + + kernel_write_pass_float(buffer + kernel_data.film.pass_depth, sample, depth); + } + if(flag & PASS_OBJECT_ID) { + float id = object_pass_id(kg, sd->object); + kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, sample, id); + } + if(flag & PASS_MATERIAL_ID) { + float id = shader_pass_id(kg, sd); + kernel_write_pass_float(buffer + kernel_data.film.pass_material_id, sample, id); + } + } + + if(flag & PASS_NORMAL) { + float3 normal = sd->N; + kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal); + } + if(flag & PASS_UV) { + float3 uv = make_float3(0.0f, 0.0f, 0.0f); /* todo: request and lookup */ + kernel_write_pass_float3(buffer + kernel_data.film.pass_uv, sample, uv); + } + } + + if(flag & (PASS_DIFFUSE_INDIRECT|PASS_DIFFUSE_COLOR|PASS_DIFFUSE_DIRECT)) + L->color_diffuse += shader_bsdf_diffuse(kg, sd)*throughput; + if(flag & (PASS_GLOSSY_INDIRECT|PASS_GLOSSY_COLOR|PASS_GLOSSY_DIRECT)) + L->color_glossy += shader_bsdf_glossy(kg, sd)*throughput; + if(flag & (PASS_TRANSMISSION_INDIRECT|PASS_TRANSMISSION_COLOR|PASS_TRANSMISSION_DIRECT)) + L->color_transmission += shader_bsdf_transmission(kg, sd)*throughput; +#endif +} + +__device void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample) +{ +#ifdef __PASSES__ + int flag = kernel_data.film.pass_flag; + + if(!kernel_data.film.use_light_pass) + return; + + if(flag & PASS_DIFFUSE_INDIRECT) { + float3 color = safe_divide_color(L->indirect_diffuse, L->color_diffuse); + kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_indirect, sample, color); + } + if(flag & PASS_GLOSSY_INDIRECT) { + float3 color = safe_divide_color(L->indirect_glossy, L->color_glossy); + kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_indirect, sample, color); + } + if(flag & PASS_TRANSMISSION_INDIRECT) { + float3 color = safe_divide_color(L->indirect_transmission, L->color_transmission); + kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_indirect, sample, color); + } + if(flag & PASS_DIFFUSE_DIRECT) { + float3 color = safe_divide_color(L->direct_diffuse, L->color_diffuse); + kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_direct, sample, color); + } + if(flag & PASS_GLOSSY_DIRECT) { + float3 color = safe_divide_color(L->direct_glossy, L->color_glossy); + kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_direct, sample, color); + } + if(flag & PASS_TRANSMISSION_DIRECT) { + float3 color = safe_divide_color(L->direct_transmission, L->color_transmission); + kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_direct, sample, color); + } + + if(flag & PASS_EMISSION) + kernel_write_pass_float3(buffer + kernel_data.film.pass_emission, sample, L->emission); + if(flag & PASS_BACKGROUND) + kernel_write_pass_float3(buffer + kernel_data.film.pass_background, sample, L->background); + + if(flag & PASS_DIFFUSE_COLOR) + kernel_write_pass_float3(buffer + kernel_data.film.pass_diffuse_color, sample, L->color_diffuse); + if(flag & PASS_GLOSSY_COLOR) + kernel_write_pass_float3(buffer + kernel_data.film.pass_glossy_color, sample, L->color_glossy); + if(flag & PASS_TRANSMISSION_COLOR) + kernel_write_pass_float3(buffer + kernel_data.film.pass_transmission_color, sample, L->color_transmission); +#endif +} + +CCL_NAMESPACE_END + diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index c80d2068506..c0bfa320405 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -25,39 +25,16 @@ #else #include "kernel_bvh.h" #endif +#include "kernel_accumulate.h" #include "kernel_camera.h" #include "kernel_shader.h" #include "kernel_light.h" #include "kernel_emission.h" #include "kernel_random.h" +#include "kernel_passes.h" CCL_NAMESPACE_BEGIN -#ifdef __MODIFY_TP__ -__device float3 path_terminate_modified_throughput(KernelGlobals *kg, __global float3 *buffer, int x, int y, int offset, int stride, int sample) -{ - /* modify throughput to influence path termination probability, to avoid - darker regions receiving fewer samples than lighter regions. also RGB - are weighted differently. proper validation still remains to be done. */ - const float3 weights = make_float3(1.0f, 1.33f, 0.66f); - const float3 one = make_float3(1.0f, 1.0f, 1.0f); - const int minsample = 5; - const float minL = 0.1f; - - if(sample >= minsample) { - float3 L = buffer[offset + x + y*stride]; - float3 Lmin = make_float3(minL, minL, minL); - float correct = (float)(sample+1)/(float)sample; - - L = film_map(L*correct, sample); - - return weights/clamp(L, Lmin, one); - } - - return weights; -} -#endif - typedef struct PathState { uint flag; int bounce; @@ -168,7 +145,7 @@ __device_inline float path_state_terminate_probability(KernelGlobals *kg, PathSt return average(throughput); } -__device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, Intersection *isect, float3 *light_L) +__device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, Intersection *isect, BsdfEval *L_light) { if(ray->t == 0.0f) return false; @@ -208,7 +185,7 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra } if(!scene_intersect(kg, ray, PATH_RAY_SHADOW_TRANSPARENT, isect)) { - *light_L *= throughput; + bsdf_eval_mul(L_light, throughput); return false; } @@ -234,11 +211,14 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra return result; } -__device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, float3 throughput) +__device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, __global float *buffer) { /* initialize */ - float3 L = make_float3(0.0f, 0.0f, 0.0f); - float Ltransparent = 0.0f; + PathRadiance L; + float3 throughput = make_float3(1.0f, 1.0f, 1.0f); + float L_transparent = 0.0f; + + path_radiance_init(&L, kernel_data.film.use_light_pass); #ifdef __EMISSION__ float ray_pdf = 0.0f; @@ -257,12 +237,12 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R if(!scene_intersect(kg, &ray, visibility, &isect)) { /* eval background shader if nothing hit */ if(kernel_data.background.transparent && (state.flag & PATH_RAY_CAMERA)) { - Ltransparent += average(throughput); + L_transparent += average(throughput); } else { /* sample background shader */ - float3 background_L = indirect_background(kg, &ray, state.flag, ray_pdf); - L += throughput*background_L; + float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf); + path_radiance_accum_background(&L, throughput, L_background, state.bounce); } break; @@ -274,19 +254,24 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R float rbsdf = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF); shader_eval_surface(kg, &sd, rbsdf, state.flag); + kernel_write_data_passes(kg, buffer, &L, &sd, sample, state.flag, throughput); + #ifdef __HOLDOUT__ if((sd.flag & SD_HOLDOUT) && (state.flag & PATH_RAY_CAMERA)) { float3 holdout_weight = shader_holdout_eval(kg, &sd); if(kernel_data.background.transparent) - Ltransparent += average(holdout_weight*throughput); + /* any throughput is ok, should all be identical here */ + L_transparent += average(holdout_weight*throughput); } #endif #ifdef __EMISSION__ /* emission */ - if(sd.flag & SD_EMISSION) - L += throughput*indirect_emission(kg, &sd, isect.t, state.flag, ray_pdf); + if(sd.flag & SD_EMISSION) { + float3 emission = indirect_emission(kg, &sd, isect.t, state.flag, ray_pdf); + path_radiance_accum_emission(&L, throughput, emission, state.bounce); + } #endif /* path termination. this is a strange place to put the termination, it's @@ -310,7 +295,7 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R float light_v = path_rng(kg, rng, sample, rng_offset + PRNG_LIGHT_V); Ray light_ray; - float3 light_L; + BsdfEval L_light; #ifdef __MULTI_LIGHT__ /* index -1 means randomly sample from distribution */ @@ -320,10 +305,10 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R #else const int i = -1; #endif - if(direct_emission(kg, &sd, i, light_t, light_o, light_u, light_v, &light_ray, &light_L)) { + if(direct_emission(kg, &sd, i, light_t, light_o, light_u, light_v, &light_ray, &L_light)) { /* trace shadow ray */ - if(!shadow_blocked(kg, &state, &light_ray, &isect, &light_L)) - L += throughput*light_L; + if(!shadow_blocked(kg, &state, &light_ray, &isect, &L_light)) + path_radiance_accum_light(&L, throughput, &L_light, state.bounce); } #ifdef __MULTI_LIGHT__ } @@ -338,7 +323,7 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R /* sample BSDF */ float bsdf_pdf; - float3 bsdf_eval; + BsdfEval bsdf_eval; float3 bsdf_omega_in; differential3 bsdf_domega_in; float bsdf_u = path_rng(kg, rng, sample, rng_offset + PRNG_BSDF_U); @@ -350,11 +335,11 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R shader_release(kg, &sd); - if(bsdf_pdf == 0.0f || is_zero(bsdf_eval)) + if(bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval)) break; /* modify throughput */ - throughput *= bsdf_eval/bsdf_pdf; + path_radiance_bsdf_bounce(&L, &throughput, &bsdf_eval, bsdf_pdf, state.bounce, label); /* set labels */ #if defined(__EMISSION__) || defined(__BACKGROUND__) @@ -374,18 +359,33 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R #endif } - return make_float4(L.x, L.y, L.z, 1.0f - Ltransparent); + float3 L_sum = path_radiance_sum(&L); + + kernel_write_light_passes(kg, buffer, &L, sample); + + return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent); } -__device void kernel_path_trace(KernelGlobals *kg, __global float4 *buffer, __global uint *rng_state, int sample, int x, int y, int offset, int stride) +__device void kernel_path_trace(KernelGlobals *kg, + __global float *buffer, __global uint *rng_state, + int sample, int x, int y, int offset, int stride) { + /* buffer offset */ + int index = offset + x + y*stride; + int pass_stride = kernel_data.film.pass_stride; + + rng_state += index; + buffer += index*pass_stride; + + kernel_clear_passes(buffer, sample, pass_stride); + /* initialize random numbers */ RNG rng; float filter_u; float filter_v; - path_rng_init(kg, rng_state, sample, &rng, x, y, offset, stride, &filter_u, &filter_v); + path_rng_init(kg, rng_state, sample, &rng, x, y, &filter_u, &filter_v); /* sample camera ray */ Ray ray; @@ -396,23 +396,12 @@ __device void kernel_path_trace(KernelGlobals *kg, __global float4 *buffer, __gl camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, &ray); /* integrate */ -#ifdef __MODIFY_TP__ - float3 throughput = path_terminate_modified_throughput(kg, buffer, x, y, offset, stride, sample); - float4 L = kernel_path_integrate(kg, &rng, sample, ray, throughput)/throughput; -#else - float3 throughput = make_float3(1.0f, 1.0f, 1.0f); - float4 L = kernel_path_integrate(kg, &rng, sample, ray, throughput); -#endif + float4 L = kernel_path_integrate(kg, &rng, sample, ray, buffer); /* accumulate result in output buffer */ - int index = offset + x + y*stride; + kernel_write_pass_float4(buffer, sample, L); - if(sample == 0) - buffer[index] = L; - else - buffer[index] += L; - - path_rng_end(kg, rng_state, rng, x, y, offset, stride); + path_rng_end(kg, rng_state, rng); } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h index 41301ebd3dc..6d15100f8a3 100644 --- a/intern/cycles/kernel/kernel_random.h +++ b/intern/cycles/kernel/kernel_random.h @@ -123,7 +123,7 @@ __device_inline float path_rng(KernelGlobals *kg, RNG *rng, int sample, int dime #endif } -__device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, RNG *rng, int x, int y, int offset, int stride, float *fx, float *fy) +__device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, RNG *rng, int x, int y, float *fx, float *fy) { #ifdef __SOBOL_FULL_SCREEN__ uint px, py; @@ -135,19 +135,31 @@ __device_inline void path_rng_init(KernelGlobals *kg, __global uint *rng_state, *rng ^= kernel_data.integrator.seed; - *fx = size * (float)px * (1.0f/(float)0xFFFFFFFF) - x; - *fy = size * (float)py * (1.0f/(float)0xFFFFFFFF) - y; + if(sample == 0) { + *fx = 0.5f; + *fy = 0.5f; + } + else { + *fx = size * (float)px * (1.0f/(float)0xFFFFFFFF) - x; + *fy = size * (float)py * (1.0f/(float)0xFFFFFFFF) - y; + } #else - *rng = rng_state[offset + x + y*stride]; + *rng = *rng_state; *rng ^= kernel_data.integrator.seed; - *fx = path_rng(kg, rng, sample, PRNG_FILTER_U); - *fy = path_rng(kg, rng, sample, PRNG_FILTER_V); + if(sample == 0) { + *fx = 0.5f; + *fy = 0.5f; + } + else { + *fx = path_rng(kg, rng, sample, PRNG_FILTER_U); + *fy = path_rng(kg, rng, sample, PRNG_FILTER_V); + } #endif } -__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng, int x, int y, int offset, int stride) +__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng) { /* nothing to do */ } @@ -163,21 +175,27 @@ __device float path_rng(KernelGlobals *kg, RNG *rng, int sample, int dimension) return (float)*rng * (1.0f/(float)0xFFFFFFFF); } -__device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, RNG *rng, int x, int y, int offset, int stride, float *fx, float *fy) +__device void path_rng_init(KernelGlobals *kg, __global uint *rng_state, int sample, RNG *rng, int x, int y, float *fx, float *fy) { /* load state */ - *rng = rng_state[offset + x + y*stride]; + *rng = *rng_state; *rng ^= kernel_data.integrator.seed; - *fx = path_rng(kg, rng, sample, PRNG_FILTER_U); - *fy = path_rng(kg, rng, sample, PRNG_FILTER_V); + if(sample == 0) { + *fx = 0.5f; + *fy = 0.5f; + } + else { + *fx = path_rng(kg, rng, sample, PRNG_FILTER_U); + *fy = path_rng(kg, rng, sample, PRNG_FILTER_V); + } } -__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng, int x, int y, int offset, int stride) +__device void path_rng_end(KernelGlobals *kg, __global uint *rng_state, RNG rng) { /* store state for next sample */ - rng_state[offset + x + y*stride] = rng; + *rng_state = rng; } #endif diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 9c59e1566a9..1d2cf46aa56 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -75,7 +75,7 @@ __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, if(sd->shader & SHADER_SMOOTH_NORMAL) sd->N = triangle_smooth_normal(kg, sd->prim, sd->u, sd->v); - sd->flag = kernel_tex_fetch(__shader_flag, sd->shader & SHADER_MASK); + sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2); #ifdef __DPDU__ /* dPdu/dPdv */ @@ -166,7 +166,7 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, #endif } - sd->flag = kernel_tex_fetch(__shader_flag, sd->shader & SHADER_MASK); + sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2); #ifdef __DPDU__ /* dPdu/dPdv */ @@ -243,7 +243,7 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData sd->Ng = -sd->P; sd->I = -sd->P; sd->shader = kernel_data.background.shader; - sd->flag = kernel_tex_fetch(__shader_flag, sd->shader & SHADER_MASK); + sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2); #ifdef __INSTANCING__ sd->object = ~0; @@ -275,8 +275,8 @@ __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData #ifdef __MULTI_CLOSURE__ -__device_inline float3 _shader_bsdf_multi_eval(const ShaderData *sd, const float3 omega_in, float *pdf, - int skip_bsdf, float3 sum_eval, float sum_pdf, float sum_sample_weight) +__device_inline void _shader_bsdf_multi_eval(const ShaderData *sd, const float3 omega_in, float *pdf, + int skip_bsdf, BsdfEval *bsdf_eval, float sum_pdf, float sum_sample_weight) { for(int i = 0; i< sd->num_closure; i++) { if(i == skip_bsdf) @@ -293,7 +293,7 @@ __device_inline float3 _shader_bsdf_multi_eval(const ShaderData *sd, const float #endif if(bsdf_pdf != 0.0f) { - sum_eval += eval*sc->weight; + bsdf_eval_accum(bsdf_eval, sc->type, eval*sc->weight); sum_pdf += bsdf_pdf*sc->sample_weight; } @@ -302,25 +302,27 @@ __device_inline float3 _shader_bsdf_multi_eval(const ShaderData *sd, const float } *pdf = sum_pdf/sum_sample_weight; - return sum_eval; } #endif -__device float3 shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd, - const float3 omega_in, float *pdf) +__device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd, + const float3 omega_in, BsdfEval *eval, float *pdf) { #ifdef __MULTI_CLOSURE__ - return _shader_bsdf_multi_eval(sd, omega_in, pdf, -1, make_float3(0.0f, 0.0f, 0.0f), 0.0f, 0.0f); + bsdf_eval_init(eval, NBUILTIN_CLOSURES, make_float3(0.0f, 0.0f, 0.0f), kernel_data.film.use_light_pass); + + return _shader_bsdf_multi_eval(sd, omega_in, pdf, -1, eval, 0.0f, 0.0f); #else const ShaderClosure *sc = &sd->closure; + *pdf = 0.0f; - return svm_bsdf_eval(sd, sc, omega_in, pdf)*sc->weight; + *eval = svm_bsdf_eval(sd, sc, omega_in, pdf)*sc->weight; #endif } __device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd, - float randu, float randv, float3 *eval, + float randu, float randv, BsdfEval *bsdf_eval, float3 *omega_in, differential3 *domega_in, float *pdf) { #ifdef __MULTI_CLOSURE__ @@ -359,27 +361,28 @@ __device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd, const ShaderClosure *sc = &sd->closure[sampled]; int label; + float3 eval; *pdf = 0.0f; #ifdef __OSL__ - label = OSLShader::bsdf_sample(sd, sc, randu, randv, *eval, *omega_in, *domega_in, *pdf); + label = OSLShader::bsdf_sample(sd, sc, randu, randv, eval, *omega_in, *domega_in, *pdf); #else - label = svm_bsdf_sample(sd, sc, randu, randv, eval, omega_in, domega_in, pdf); + label = svm_bsdf_sample(sd, sc, randu, randv, &eval, omega_in, domega_in, pdf); #endif - *eval *= sc->weight; + bsdf_eval_init(bsdf_eval, sc->type, eval*sc->weight, kernel_data.film.use_light_pass); if(sd->num_closure > 1 && *pdf != 0.0f) { float sweight = sc->sample_weight; - *eval = _shader_bsdf_multi_eval(sd, *omega_in, pdf, sampled, *eval, *pdf*sweight, sweight); + _shader_bsdf_multi_eval(sd, *omega_in, pdf, sampled, bsdf_eval, *pdf*sweight, sweight); } return label; #else /* sample the single closure that we picked */ *pdf = 0.0f; - int label = svm_bsdf_sample(sd, &sd->closure, randu, randv, eval, omega_in, domega_in, pdf); - *eval *= sd->closure.weight; + int label = svm_bsdf_sample(sd, &sd->closure, randu, randv, bsdf_eval, omega_in, domega_in, pdf); + *bsdf_eval *= sd->closure.weight; return label; #endif } @@ -421,6 +424,68 @@ __device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd) #endif } +__device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd) +{ +#ifdef __MULTI_CLOSURE__ + float3 eval = make_float3(0.0f, 0.0f, 0.0f); + + for(int i = 0; i< sd->num_closure; i++) { + ShaderClosure *sc = &sd->closure[i]; + + if(CLOSURE_IS_BSDF_DIFFUSE(sc->type)) + eval += sc->weight; + } + + return eval; +#else + if(CLOSURE_IS_BSDF_DIFFUSE(sd->closure.type)) + return sd->closure.weight; + else + return make_float3(0.0f, 0.0f, 0.0f); +#endif +} + +__device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd) +{ +#ifdef __MULTI_CLOSURE__ + float3 eval = make_float3(0.0f, 0.0f, 0.0f); + + for(int i = 0; i< sd->num_closure; i++) { + ShaderClosure *sc = &sd->closure[i]; + + if(CLOSURE_IS_BSDF_GLOSSY(sc->type)) + eval += sc->weight; + } + + return eval; +#else + if(CLOSURE_IS_BSDF_GLOSSY(sd->closure.type)) + return sd->closure.weight; + else + return make_float3(0.0f, 0.0f, 0.0f); +#endif +} + +__device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd) +{ +#ifdef __MULTI_CLOSURE__ + float3 eval = make_float3(0.0f, 0.0f, 0.0f); + + for(int i = 0; i< sd->num_closure; i++) { + ShaderClosure *sc = &sd->closure[i]; + + if(CLOSURE_IS_BSDF_TRANSMISSION(sc->type)) + eval += sc->weight; + } + + return eval; +#else + if(CLOSURE_IS_BSDF_TRANSMISSION(sd->closure.type)) + return sd->closure.weight; + else + return make_float3(0.0f, 0.0f, 0.0f); +#endif +} /* Emission */ @@ -588,12 +653,17 @@ __device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect) int prim = kernel_tex_fetch(__prim_index, isect->prim); float4 Ns = kernel_tex_fetch(__tri_normal, prim); int shader = __float_as_int(Ns.w); - int flag = kernel_tex_fetch(__shader_flag, shader & SHADER_MASK); + int flag = kernel_tex_fetch(__shader_flag, (shader & SHADER_MASK)*2); return (flag & SD_HAS_SURFACE_TRANSPARENT) != 0; } #endif +__device int shader_pass_id(KernelGlobals *kg, ShaderData *sd) +{ + return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1); +} + /* Free ShaderData */ __device void shader_release(KernelGlobals *kg, ShaderData *sd) diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 008ec0bdf28..b4b1da83162 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -70,6 +70,9 @@ CCL_NAMESPACE_BEGIN #ifdef __KERNEL_ADV_SHADING__ #define __MULTI_CLOSURE__ #define __TRANSPARENT_SHADOWS__ +#ifdef __KERNEL_CPU__ +#define __PASSES__ +#endif #endif //#define __MULTI_LIGHT__ @@ -150,6 +153,75 @@ typedef enum ClosureLabel { LABEL_STOP = 2048 } ClosureLabel; +/* Render Passes */ + +typedef enum PassType { + PASS_NONE = 0, + PASS_COMBINED = 1, + PASS_DEPTH = 2, + PASS_NORMAL = 8, + PASS_UV = 16, + PASS_OBJECT_ID = 32, + PASS_MATERIAL_ID = 64, + PASS_DIFFUSE_COLOR = 128, + PASS_GLOSSY_COLOR = 256, + PASS_TRANSMISSION_COLOR = 512, + PASS_DIFFUSE_INDIRECT = 1024, + PASS_GLOSSY_INDIRECT = 2048, + PASS_TRANSMISSION_INDIRECT = 4096, + PASS_DIFFUSE_DIRECT = 8192, + PASS_GLOSSY_DIRECT = 16384, + PASS_TRANSMISSION_DIRECT = 32768, + PASS_EMISSION = 65536, + PASS_BACKGROUND = 131072 +} PassType; + +#define PASS_ALL (~0) + +#ifdef __PASSES__ + +typedef float3 PathThroughput; + +struct PathRadiance { + int use_light_pass; + + float3 indirect; + float3 direct_throughput; + float3 direct_emission; + + float3 color_diffuse; + float3 color_glossy; + float3 color_transmission; + + float3 direct_diffuse; + float3 direct_glossy; + float3 direct_transmission; + + float3 indirect_diffuse; + float3 indirect_glossy; + float3 indirect_transmission; + + float3 emission; + float3 background; +}; + +struct BsdfEval { + int use_light_pass; + + float3 diffuse; + float3 glossy; + float3 transmission; + float3 transparent; +}; + +#else + +typedef float3 PathThroughput; +typedef float3 PathRadiance; +typedef float3 BsdfEval; + +#endif + /* Shader Flag */ typedef enum ShaderFlag { @@ -353,7 +425,32 @@ typedef struct KernelCamera { typedef struct KernelFilm { float exposure; - int pad1, pad2, pad3; + int pass_flag; + int pass_stride; + int use_light_pass; + + int pass_combined; + int pass_depth; + int pass_normal; + int pass_pad; + + int pass_uv; + int pass_object_id; + int pass_material_id; + int pass_diffuse_color; + + int pass_glossy_color; + int pass_transmission_color; + int pass_diffuse_indirect; + int pass_glossy_indirect; + + int pass_transmission_indirect; + int pass_diffuse_direct; + int pass_glossy_direct; + int pass_transmission_direct; + + int pass_emission; + int pass_background; } KernelFilm; typedef struct KernelBackground { diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index ff6e9b94a0f..533a2944557 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -266,22 +266,26 @@ typedef enum ShaderType { typedef enum ClosureType { CLOSURE_BSDF_ID, + CLOSURE_BSDF_DIFFUSE_ID, CLOSURE_BSDF_OREN_NAYAR_ID, - CLOSURE_BSDF_TRANSLUCENT_ID, + CLOSURE_BSDF_REFLECTION_ID, - CLOSURE_BSDF_REFRACTION_ID, - CLOSURE_BSDF_GLASS_ID, - CLOSURE_BSDF_TRANSPARENT_ID, CLOSURE_BSDF_MICROFACET_GGX_ID, - CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, CLOSURE_BSDF_MICROFACET_BECKMANN_ID, - CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, CLOSURE_BSDF_WARD_ID, - CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, - CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, CLOSURE_BSDF_WESTIN_SHEEN_ID, + CLOSURE_BSDF_TRANSLUCENT_ID, + CLOSURE_BSDF_REFRACTION_ID, + CLOSURE_BSDF_WESTIN_BACKSCATTER_ID, + CLOSURE_BSDF_ASHIKHMIN_VELVET_ID, + CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID, + CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID, + CLOSURE_BSDF_GLASS_ID, + + CLOSURE_BSDF_TRANSPARENT_ID, + CLOSURE_BSSRDF_CUBIC_ID, CLOSURE_EMISSION_ID, CLOSURE_DEBUG_ID, @@ -297,7 +301,10 @@ typedef enum ClosureType { } ClosureType; /* watch this, being lazy with memory usage */ -#define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_WESTIN_SHEEN_ID) +#define CLOSURE_IS_BSDF(type) (type <= CLOSURE_BSDF_TRANSPARENT_ID) +#define CLOSURE_IS_BSDF_DIFFUSE(type) (type >= CLOSURE_BSDF_DIFFUSE_ID && type <= CLOSURE_BSDF_OREN_NAYAR_ID) +#define CLOSURE_IS_BSDF_GLOSSY(type) (type >= CLOSURE_BSDF_REFLECTION_ID && type <= CLOSURE_BSDF_WESTIN_SHEEN_ID) +#define CLOSURE_IS_BSDF_TRANSMISSION(type) (type >= CLOSURE_BSDF_TRANSLUCENT_ID && type <= CLOSURE_BSDF_GLASS_ID) #define CLOSURE_IS_VOLUME(type) (type >= CLOSURE_VOLUME_ID && type <= CLOSURE_VOLUME_ISOTROPIC_ID) #define CLOSURE_IS_EMISSION(type) (type == CLOSURE_EMISSION_ID) #define CLOSURE_IS_HOLDOUT(type) (type == CLOSURE_HOLDOUT_ID) diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index a6bbbc91901..08dda944111 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -22,6 +22,7 @@ #include "device.h" #include "util_debug.h" +#include "util_foreach.h" #include "util_hash.h" #include "util_image.h" #include "util_math.h" @@ -31,6 +32,48 @@ CCL_NAMESPACE_BEGIN +/* Buffer Params */ + +BufferParams::BufferParams() +{ + width = 0; + height = 0; + + full_x = 0; + full_y = 0; + full_width = 0; + full_height = 0; + + Pass::add(PASS_COMBINED, passes); +} + +void BufferParams::get_offset_stride(int& offset, int& stride) +{ + offset = -(full_x + full_y*width); + stride = width; +} + +bool BufferParams::modified(const BufferParams& params) +{ + return !(full_x == params.full_x + && full_y == params.full_y + && width == params.width + && height == params.height + && full_width == params.full_width + && full_height == params.full_height + && Pass::equals(passes, params.passes)); +} + +int BufferParams::get_passes_size() +{ + int size = 0; + + foreach(Pass& pass, passes) + size += pass.components; + + return size; +} + /* Render Buffers */ RenderBuffers::RenderBuffers(Device *device_) @@ -64,7 +107,7 @@ void RenderBuffers::reset(Device *device, BufferParams& params_) device_free(); /* allocate buffer */ - buffer.resize(params.width, params.height); + buffer.resize(params.width*params.height*params.get_passes_size()); device->mem_alloc(buffer, MEM_READ_WRITE); device->mem_zero(buffer); @@ -82,31 +125,76 @@ void RenderBuffers::reset(Device *device, BufferParams& params_) device->mem_copy_to(rng_state); } -float4 *RenderBuffers::copy_from_device(float exposure, int sample) +bool RenderBuffers::copy_from_device() { if(!buffer.device_pointer) - return NULL; + return false; device->mem_copy_from(buffer, 0, params.width, params.height, sizeof(float4)); - float4 *out = new float4[params.width*params.height]; - float4 *in = (float4*)buffer.data_pointer; - float scale = 1.0f/(float)sample; - - for(int i = params.width*params.height - 1; i >= 0; i--) { - float4 rgba = in[i]*scale; + return true; +} - rgba.x = rgba.x*exposure; - rgba.y = rgba.y*exposure; - rgba.z = rgba.z*exposure; +bool RenderBuffers::get_pass(PassType type, float exposure, int sample, int components, float *pixels) +{ + int pass_offset = 0; - /* clamp since alpha might be > 1.0 due to russian roulette */ - rgba.w = clamp(rgba.w, 0.0f, 1.0f); + foreach(Pass& pass, params.passes) { + if(pass.type != type) { + pass_offset += pass.components; + continue; + } - out[i] = rgba; + float *in = (float*)buffer.data_pointer + pass_offset; + int pass_stride = params.get_passes_size(); + + float scale = (pass.filter)? 1.0f/(float)sample: 1.0f; + float scale_exposure = (pass.exposure)? scale*exposure: scale; + + int size = params.width*params.height; + + if(components == 1) { + assert(pass.components == components); + + /* scalar */ + for(int i = 0; i < size; i++, in += pass_stride, pixels++) { + float f = *in; + + pixels[0] = f*scale_exposure; + } + } + else if(components == 3) { + assert(pass.components == 4); + + /* RGB/vector */ + for(int i = 0; i < size; i++, in += pass_stride, pixels += 3) { + float3 f = make_float3(in[0], in[1], in[2]); + + pixels[0] = f.x*scale_exposure; + pixels[1] = f.y*scale_exposure; + pixels[2] = f.z*scale_exposure; + } + } + else if(components == 4) { + assert(pass.components == components); + + /* RGBA */ + for(int i = 0; i < size; i++, in += pass_stride, pixels += 4) { + float4 f = make_float4(in[0], in[1], in[2], in[3]); + + pixels[0] = f.x*scale_exposure; + pixels[1] = f.y*scale_exposure; + pixels[2] = f.z*scale_exposure; + + /* clamp since alpha might be > 1.0 due to russian roulette */ + pixels[3] = clamp(f.w*scale, 0.0f, 1.0f); + } + } + + return true; } - return out; + return false; } /* Display Buffer */ diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h index f4a9b37c09b..3062e5ae3e4 100644 --- a/intern/cycles/render/buffers.h +++ b/intern/cycles/render/buffers.h @@ -21,6 +21,10 @@ #include "device_memory.h" +#include "film.h" + +#include "kernel_types.h" + #include "util_string.h" #include "util_thread.h" #include "util_types.h" @@ -45,32 +49,16 @@ public: int full_width; int full_height; - BufferParams() - { - width = 0; - height = 0; + /* passes */ + vector passes; - full_x = 0; - full_y = 0; - full_width = 0; - full_height = 0; - } + /* functions */ + BufferParams(); - void get_offset_stride(int& offset, int& stride) - { - offset = -(full_x + full_y*width); - stride = width; - } - - bool modified(const BufferParams& params) - { - return !(full_x == params.full_x - && full_y == params.full_y - && width == params.width - && height == params.height - && full_width == params.full_width - && full_height == params.full_height); - } + void get_offset_stride(int& offset, int& stride); + bool modified(const BufferParams& params); + void add_pass(PassType type); + int get_passes_size(); }; /* Render Buffers */ @@ -80,7 +68,7 @@ public: /* buffer parameters */ BufferParams params; /* float buffer */ - device_vector buffer; + device_vector buffer; /* random number generator state */ device_vector rng_state; /* mutex, must be locked manually by callers */ @@ -90,7 +78,9 @@ public: ~RenderBuffers(); void reset(Device *device, BufferParams& params); - float4 *copy_from_device(float exposure, int sample); + + bool copy_from_device(); + bool get_pass(PassType type, float exposure, int sample, int components, float *pixels); protected: void device_free(); diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index 0ae2866f182..bc51384b873 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -21,11 +21,111 @@ #include "film.h" #include "scene.h" +#include "util_foreach.h" + CCL_NAMESPACE_BEGIN +/* Pass */ + +void Pass::add(PassType type, vector& passes) +{ + Pass pass; + + pass.type = type; + pass.filter = true; + pass.exposure = false; + + switch(type) { + case PASS_NONE: + pass.components = 0; + break; + case PASS_COMBINED: + pass.components = 4; + pass.exposure = true; + break; + case PASS_DEPTH: + pass.components = 1; + pass.filter = false; + break; + case PASS_NORMAL: + pass.components = 4; + break; + case PASS_UV: + pass.components = 4; + break; + case PASS_OBJECT_ID: + pass.components = 1; + pass.filter = false; + break; + case PASS_MATERIAL_ID: + pass.components = 1; + pass.filter = false; + break; + case PASS_DIFFUSE_COLOR: + pass.components = 4; + break; + case PASS_GLOSSY_COLOR: + pass.components = 4; + break; + case PASS_TRANSMISSION_COLOR: + pass.components = 4; + break; + case PASS_DIFFUSE_INDIRECT: + pass.components = 4; + pass.exposure = true; + break; + case PASS_GLOSSY_INDIRECT: + pass.components = 4; + pass.exposure = true; + break; + case PASS_TRANSMISSION_INDIRECT: + pass.components = 4; + pass.exposure = true; + break; + case PASS_DIFFUSE_DIRECT: + pass.components = 4; + pass.exposure = true; + break; + case PASS_GLOSSY_DIRECT: + pass.components = 4; + pass.exposure = true; + break; + case PASS_TRANSMISSION_DIRECT: + pass.components = 4; + pass.exposure = true; + break; + + case PASS_EMISSION: + pass.components = 4; + pass.exposure = true; + break; + case PASS_BACKGROUND: + pass.components = 4; + pass.exposure = true; + break; + } + + passes.push_back(pass); +} + +bool Pass::equals(const vector& A, const vector& B) +{ + if(A.size() != B.size()) + return false; + + for(int i = 0; i < A.size(); i++) + if(A[i].type != B[i].type) + return false; + + return true; +} + +/* Film */ + Film::Film() { exposure = 0.8f; + Pass::add(PASS_COMBINED, passes); need_update = true; } @@ -42,6 +142,82 @@ void Film::device_update(Device *device, DeviceScene *dscene) /* update __data */ kfilm->exposure = exposure; + kfilm->pass_flag = 0; + kfilm->pass_stride = 0; + kfilm->use_light_pass = 0; + + foreach(Pass& pass, passes) { + kfilm->pass_flag |= pass.type; + + switch(pass.type) { + case PASS_COMBINED: + kfilm->pass_combined = kfilm->pass_stride; + break; + case PASS_DEPTH: + kfilm->pass_depth = kfilm->pass_stride; + break; + case PASS_NORMAL: + kfilm->pass_normal = kfilm->pass_stride; + break; + case PASS_UV: + kfilm->pass_uv = kfilm->pass_stride; + break; + case PASS_OBJECT_ID: + kfilm->pass_object_id = kfilm->pass_stride; + break; + case PASS_MATERIAL_ID: + kfilm->pass_material_id = kfilm->pass_stride; + break; + case PASS_DIFFUSE_COLOR: + kfilm->pass_diffuse_color = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_GLOSSY_COLOR: + kfilm->pass_glossy_color = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_TRANSMISSION_COLOR: + kfilm->pass_transmission_color = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_DIFFUSE_INDIRECT: + kfilm->pass_diffuse_indirect = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_GLOSSY_INDIRECT: + kfilm->pass_glossy_indirect = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_TRANSMISSION_INDIRECT: + kfilm->pass_transmission_indirect = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_DIFFUSE_DIRECT: + kfilm->pass_diffuse_direct = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_GLOSSY_DIRECT: + kfilm->pass_glossy_direct = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_TRANSMISSION_DIRECT: + kfilm->pass_transmission_direct = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + + case PASS_EMISSION: + kfilm->pass_emission = kfilm->pass_stride; + kfilm->use_light_pass = 1; + break; + case PASS_BACKGROUND: + kfilm->pass_background = kfilm->pass_stride; + kfilm->use_light_pass = 1; + case PASS_NONE: + break; + } + + kfilm->pass_stride += pass.components; + } need_update = false; } @@ -52,7 +228,8 @@ void Film::device_free(Device *device, DeviceScene *dscene) bool Film::modified(const Film& film) { - return !(exposure == film.exposure); + return !(exposure == film.exposure + && Pass::equals(passes, film.passes)); } void Film::tag_update(Scene *scene) diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h index df24fad3725..511ad316460 100644 --- a/intern/cycles/render/film.h +++ b/intern/cycles/render/film.h @@ -20,6 +20,9 @@ #define __FILM_H__ #include "util_string.h" +#include "util_vector.h" + +#include "kernel_types.h" CCL_NAMESPACE_BEGIN @@ -27,9 +30,21 @@ class Device; class DeviceScene; class Scene; +class Pass { +public: + PassType type; + int components; + bool filter; + bool exposure; + + static void add(PassType type, vector& passes); + static bool equals(const vector& A, const vector& B); +}; + class Film { public: float exposure; + vector passes; bool need_update; Film(); diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 3a9f0add735..f83c85c632d 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -36,6 +36,7 @@ Object::Object() mesh = NULL; tfm = transform_identity(); visibility = ~0; + pass_id = 0; } Object::~Object() @@ -135,6 +136,7 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene /* todo: correct for displacement, and move to a better place */ float uniform_scale; float surface_area = 0.0f; + float pass_id = ob->pass_id; if(transform_uniform_scale(tfm, uniform_scale)) { map::iterator it = surface_area_map.find(mesh); @@ -171,7 +173,7 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene memcpy(&objects[offset], &tfm, sizeof(float4)*4); memcpy(&objects[offset+4], &itfm, sizeof(float4)*4); memcpy(&objects[offset+8], &ntfm, sizeof(float4)*4); - objects[offset+12] = make_float4(surface_area, 0.0f, 0.0f, 0.0f); + objects[offset+12] = make_float4(surface_area, pass_id, 0.0f, 0.0f); i++; diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h index 7fe83cf7d91..14da2cfb35d 100644 --- a/intern/cycles/render/object.h +++ b/intern/cycles/render/object.h @@ -41,6 +41,7 @@ public: Transform tfm; BoundBox bounds; ustring name; + int pass_id; vector attributes; uint visibility; diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 6e827ec94bb..12968a79ab2 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -35,6 +35,7 @@ CCL_NAMESPACE_BEGIN Shader::Shader() { name = ""; + pass_id = 0; graph = NULL; graph_bump = NULL; @@ -167,7 +168,7 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc if(scene->shaders.size() == 0) return; - uint shader_flag_size = scene->shaders.size()*2; + uint shader_flag_size = scene->shaders.size()*4; uint *shader_flag = dscene->shader_flag.resize(shader_flag_size); uint i = 0; @@ -184,7 +185,9 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc flag |= SD_HOMOGENEOUS_VOLUME; shader_flag[i++] = flag; + shader_flag[i++] = shader->pass_id; shader_flag[i++] = flag; + shader_flag[i++] = shader->pass_id; } device->tex_alloc("__shader_flag", dscene->shader_flag); diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index 45efa123ef6..35f3cfe27f5 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -47,6 +47,7 @@ class Shader { public: /* name */ string name; + int pass_id; /* shader graph */ ShaderGraph *graph; diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 2fa587e168a..0cccd8a366b 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -557,25 +557,34 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat); /* ************** COMPOSITE NODES *************** */ /* output socket defines */ -#define RRES_OUT_IMAGE 0 -#define RRES_OUT_ALPHA 1 -#define RRES_OUT_Z 2 -#define RRES_OUT_NORMAL 3 -#define RRES_OUT_UV 4 -#define RRES_OUT_VEC 5 -#define RRES_OUT_RGBA 6 -#define RRES_OUT_DIFF 7 -#define RRES_OUT_SPEC 8 -#define RRES_OUT_SHADOW 9 -#define RRES_OUT_AO 10 -#define RRES_OUT_REFLECT 11 -#define RRES_OUT_REFRACT 12 -#define RRES_OUT_INDIRECT 13 -#define RRES_OUT_INDEXOB 14 -#define RRES_OUT_INDEXMA 15 -#define RRES_OUT_MIST 16 -#define RRES_OUT_EMIT 17 -#define RRES_OUT_ENV 18 +#define RRES_OUT_IMAGE 0 +#define RRES_OUT_ALPHA 1 +#define RRES_OUT_Z 2 +#define RRES_OUT_NORMAL 3 +#define RRES_OUT_UV 4 +#define RRES_OUT_VEC 5 +#define RRES_OUT_RGBA 6 +#define RRES_OUT_DIFF 7 +#define RRES_OUT_SPEC 8 +#define RRES_OUT_SHADOW 9 +#define RRES_OUT_AO 10 +#define RRES_OUT_REFLECT 11 +#define RRES_OUT_REFRACT 12 +#define RRES_OUT_INDIRECT 13 +#define RRES_OUT_INDEXOB 14 +#define RRES_OUT_INDEXMA 15 +#define RRES_OUT_MIST 16 +#define RRES_OUT_EMIT 17 +#define RRES_OUT_ENV 18 +#define RRES_OUT_DIFF_DIRECT 19 +#define RRES_OUT_DIFF_INDIRECT 20 +#define RRES_OUT_DIFF_COLOR 21 +#define RRES_OUT_GLOSSY_DIRECT 22 +#define RRES_OUT_GLOSSY_INDIRECT 23 +#define RRES_OUT_GLOSSY_COLOR 24 +#define RRES_OUT_TRANSM_DIRECT 25 +#define RRES_OUT_TRANSM_INDIRECT 26 +#define RRES_OUT_TRANSM_COLOR 27 /* note: types are needed to restore callbacks, don't change values */ #define CMP_NODE_VIEWER 201 diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 6b13951348a..1f42118dbc0 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -202,25 +202,34 @@ typedef struct SceneRenderLayer { #define SCE_LAY_NEG_ZMASK 0x80000 /* srl->passflag */ -#define SCE_PASS_COMBINED (1<<0) -#define SCE_PASS_Z (1<<1) -#define SCE_PASS_RGBA (1<<2) -#define SCE_PASS_DIFFUSE (1<<3) -#define SCE_PASS_SPEC (1<<4) -#define SCE_PASS_SHADOW (1<<5) -#define SCE_PASS_AO (1<<6) -#define SCE_PASS_REFLECT (1<<7) -#define SCE_PASS_NORMAL (1<<8) -#define SCE_PASS_VECTOR (1<<9) -#define SCE_PASS_REFRACT (1<<10) -#define SCE_PASS_INDEXOB (1<<11) -#define SCE_PASS_UV (1<<12) -#define SCE_PASS_INDIRECT (1<<13) -#define SCE_PASS_MIST (1<<14) -#define SCE_PASS_RAYHITS (1<<15) -#define SCE_PASS_EMIT (1<<16) -#define SCE_PASS_ENVIRONMENT (1<<17) -#define SCE_PASS_INDEXMA (1<<18) +#define SCE_PASS_COMBINED (1<<0) +#define SCE_PASS_Z (1<<1) +#define SCE_PASS_RGBA (1<<2) +#define SCE_PASS_DIFFUSE (1<<3) +#define SCE_PASS_SPEC (1<<4) +#define SCE_PASS_SHADOW (1<<5) +#define SCE_PASS_AO (1<<6) +#define SCE_PASS_REFLECT (1<<7) +#define SCE_PASS_NORMAL (1<<8) +#define SCE_PASS_VECTOR (1<<9) +#define SCE_PASS_REFRACT (1<<10) +#define SCE_PASS_INDEXOB (1<<11) +#define SCE_PASS_UV (1<<12) +#define SCE_PASS_INDIRECT (1<<13) +#define SCE_PASS_MIST (1<<14) +#define SCE_PASS_RAYHITS (1<<15) +#define SCE_PASS_EMIT (1<<16) +#define SCE_PASS_ENVIRONMENT (1<<17) +#define SCE_PASS_INDEXMA (1<<18) +#define SCE_PASS_DIFFUSE_DIRECT (1<<19) +#define SCE_PASS_DIFFUSE_INDIRECT (1<<20) +#define SCE_PASS_DIFFUSE_COLOR (1<<21) +#define SCE_PASS_GLOSSY_DIRECT (1<<22) +#define SCE_PASS_GLOSSY_INDIRECT (1<<23) +#define SCE_PASS_GLOSSY_COLOR (1<<24) +#define SCE_PASS_TRANSM_DIRECT (1<<25) +#define SCE_PASS_TRANSM_INDIRECT (1<<26) +#define SCE_PASS_TRANSM_COLOR (1<<27) /* note, srl->passflag is treestore element 'nr' in outliner, short still... */ diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index f00b97994d5..b88e452588e 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -472,6 +472,15 @@ static void rna_def_render_pass(BlenderRNA *brna) {SCE_PASS_EMIT, "EMIT", 0, "Emit", ""}, {SCE_PASS_ENVIRONMENT, "ENVIRONMENT", 0, "Environment", ""}, {SCE_PASS_INDEXMA, "MATERIAL_INDEX", 0, "Material Index", ""}, + {SCE_PASS_DIFFUSE_DIRECT, "DIFFUSE_DIRECT", 0, "Diffuse Direct", ""}, + {SCE_PASS_DIFFUSE_INDIRECT, "DIFFUSE_INDIRECT", 0, "Diffuse Indirect", ""}, + {SCE_PASS_DIFFUSE_COLOR, "DIFFUSE_COLOR", 0, "Diffuse Color", ""}, + {SCE_PASS_GLOSSY_DIRECT, "GLOSSY_DIRECT", 0, "Glossy Direct", ""}, + {SCE_PASS_GLOSSY_INDIRECT, "GLOSSY_INDIRECT", 0, "Glossy Indirect", ""}, + {SCE_PASS_GLOSSY_COLOR, "GLOSSY_COLOR", 0, "Glossy Color", ""}, + {SCE_PASS_TRANSM_DIRECT, "TRANSMISSION_DIRECT", 0, "Transmission Direct", ""}, + {SCE_PASS_TRANSM_INDIRECT, "TRANSMISSION_INDIRECT", 0, "Transmission Indirect", ""}, + {SCE_PASS_TRANSM_COLOR, "TRANSMISSION_COLOR", 0, "Transmission Color", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "RenderPass", NULL); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index cd033b1f329..c1df493eea5 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2065,6 +2065,60 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_diffuse_direct", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_DIRECT); + RNA_def_property_ui_text(prop, "Diffuse Direct", "Deliver diffuse direct pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_diffuse_indirect", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_INDIRECT); + RNA_def_property_ui_text(prop, "Diffuse Indirect", "Deliver diffuse indirect pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_diffuse_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_COLOR); + RNA_def_property_ui_text(prop, "Diffuse Color", "Deliver diffuse color pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_glossy_direct", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_DIRECT); + RNA_def_property_ui_text(prop, "Glossy Direct", "Deliver glossy direct pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_glossy_indirect", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_INDIRECT); + RNA_def_property_ui_text(prop, "Glossy Indirect", "Deliver glossy indirect pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_glossy_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_COLOR); + RNA_def_property_ui_text(prop, "Glossy Color", "Deliver glossy color pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_transmission_direct", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_DIRECT); + RNA_def_property_ui_text(prop, "Transmission Direct", "Deliver transmission direct pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_transmission_indirect", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_INDIRECT); + RNA_def_property_ui_text(prop, "Transmission Indirect", "Deliver transmission indirect pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop= RNA_def_property(srna, "use_pass_transmission_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_COLOR); + RNA_def_property_ui_text(prop, "Transmission Color", "Deliver transmission color pass"); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); } static void rna_def_scene_game_recast_data(BlenderRNA *brna) diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 93456d39c9c..dfc0bcb3f75 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -694,7 +694,28 @@ static void force_hidden_passes(bNode *node, int passflag) if(!(passflag & SCE_PASS_EMIT)) sock->flag |= SOCK_UNAVAIL; sock= BLI_findlink(&node->outputs, RRES_OUT_ENV); if(!(passflag & SCE_PASS_ENVIRONMENT)) sock->flag |= SOCK_UNAVAIL; - + + sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_DIRECT); + if(!(passflag & SCE_PASS_DIFFUSE_DIRECT)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_INDIRECT); + if(!(passflag & SCE_PASS_DIFFUSE_INDIRECT)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_DIFF_COLOR); + if(!(passflag & SCE_PASS_DIFFUSE_COLOR)) sock->flag |= SOCK_UNAVAIL; + + sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_DIRECT); + if(!(passflag & SCE_PASS_GLOSSY_DIRECT)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_INDIRECT); + if(!(passflag & SCE_PASS_GLOSSY_INDIRECT)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_GLOSSY_COLOR); + if(!(passflag & SCE_PASS_GLOSSY_COLOR)) sock->flag |= SOCK_UNAVAIL; + + sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_DIRECT); + if(!(passflag & SCE_PASS_TRANSM_DIRECT)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_INDIRECT); + if(!(passflag & SCE_PASS_TRANSM_INDIRECT)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_COLOR); + if(!(passflag & SCE_PASS_TRANSM_COLOR)) sock->flag |= SOCK_UNAVAIL; + sock= BLI_findlink(&node->outputs, RRES_OUT_TRANSM_COLOR); } /* based on rules, force sockets hidden always */ diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 57b5cec4256..997bd72d5c4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -36,25 +36,34 @@ /* **************** IMAGE (and RenderResult, multilayer image) ******************** */ static bNodeSocketTemplate cmp_node_rlayers_out[]= { - { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_FLOAT, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_FLOAT, 0, "Z", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_VECTOR, 0, "UV", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_VECTOR, 0, "Speed", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Diffuse", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Specular", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Shadow", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "AO", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Reflect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Refract", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_FLOAT, 0, "IndexOB", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_FLOAT, 0, "IndexMA", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_FLOAT, 0, "Mist", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Emit", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, - { SOCK_RGBA, 0, "Environment",0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Image", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Z", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_VECTOR, 0, "UV", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_VECTOR, 0, "Speed", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Diffuse", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Specular", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Shadow", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "AO", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Reflect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Refract", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "IndexOB", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "IndexMA", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Mist", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Emit", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Environment", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Diffuse Direct", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Diffuse Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Diffuse Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Glossy Direct", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Glossy Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Glossy Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Transmission Direct", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Transmission Indirect", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_RGBA, 0, "Transmission Color", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; @@ -238,6 +247,24 @@ static void outputs_multilayer_get(RenderData *rd, RenderLayer *rl, bNodeStack * out[RRES_OUT_EMIT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_EMIT); if(out[RRES_OUT_ENV]->hasoutput) out[RRES_OUT_ENV]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_ENVIRONMENT); + if(out[RRES_OUT_DIFF_DIRECT]->hasoutput) + out[RRES_OUT_DIFF_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_DIRECT); + if(out[RRES_OUT_DIFF_INDIRECT]->hasoutput) + out[RRES_OUT_DIFF_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_INDIRECT); + if(out[RRES_OUT_DIFF_COLOR]->hasoutput) + out[RRES_OUT_DIFF_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_DIFFUSE_COLOR); + if(out[RRES_OUT_GLOSSY_DIRECT]->hasoutput) + out[RRES_OUT_GLOSSY_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_DIRECT); + if(out[RRES_OUT_GLOSSY_INDIRECT]->hasoutput) + out[RRES_OUT_GLOSSY_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_INDIRECT); + if(out[RRES_OUT_GLOSSY_COLOR]->hasoutput) + out[RRES_OUT_GLOSSY_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_GLOSSY_COLOR); + if(out[RRES_OUT_TRANSM_DIRECT]->hasoutput) + out[RRES_OUT_TRANSM_DIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_DIRECT); + if(out[RRES_OUT_TRANSM_INDIRECT]->hasoutput) + out[RRES_OUT_TRANSM_INDIRECT]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_INDIRECT); + if(out[RRES_OUT_TRANSM_COLOR]->hasoutput) + out[RRES_OUT_TRANSM_COLOR]->data= compbuf_multilayer_get(rd, rl, ima, iuser, SCE_PASS_TRANSM_COLOR); } @@ -402,6 +429,24 @@ static void node_composit_rlayers_out(RenderData *rd, RenderLayer *rl, bNodeStac out[RRES_OUT_EMIT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_EMIT); if(out[RRES_OUT_ENV]->hasoutput) out[RRES_OUT_ENV]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_ENVIRONMENT); + if(out[RRES_OUT_DIFF_DIRECT]->hasoutput) + out[RRES_OUT_DIFF_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_DIRECT); + if(out[RRES_OUT_DIFF_INDIRECT]->hasoutput) + out[RRES_OUT_DIFF_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_INDIRECT); + if(out[RRES_OUT_DIFF_COLOR]->hasoutput) + out[RRES_OUT_DIFF_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_DIFFUSE_COLOR); + if(out[RRES_OUT_GLOSSY_DIRECT]->hasoutput) + out[RRES_OUT_GLOSSY_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_DIRECT); + if(out[RRES_OUT_GLOSSY_INDIRECT]->hasoutput) + out[RRES_OUT_GLOSSY_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_INDIRECT); + if(out[RRES_OUT_GLOSSY_COLOR]->hasoutput) + out[RRES_OUT_GLOSSY_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_GLOSSY_COLOR); + if(out[RRES_OUT_TRANSM_DIRECT]->hasoutput) + out[RRES_OUT_TRANSM_DIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_DIRECT); + if(out[RRES_OUT_TRANSM_INDIRECT]->hasoutput) + out[RRES_OUT_TRANSM_INDIRECT]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_INDIRECT); + if(out[RRES_OUT_TRANSM_COLOR]->hasoutput) + out[RRES_OUT_TRANSM_COLOR]->data= compbuf_from_pass(rd, rl, rectx, recty, SCE_PASS_TRANSM_COLOR); } static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index e825c9d842e..30853e8e1f6 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -224,6 +224,60 @@ static const char *get_pass_name(int passtype, int channel) if(channel==1) return "Rayhits.G"; return "Rayhits.B"; } + if(passtype == SCE_PASS_DIFFUSE_DIRECT) { + if(channel==-1) return "DiffDir"; + if(channel==0) return "DiffDir.R"; + if(channel==1) return "DiffDir.G"; + return "DiffDir.B"; + } + if(passtype == SCE_PASS_DIFFUSE_INDIRECT) { + if(channel==-1) return "DiffInd"; + if(channel==0) return "DiffInd.R"; + if(channel==1) return "DiffInd.G"; + return "DiffInd.B"; + } + if(passtype == SCE_PASS_DIFFUSE_COLOR) { + if(channel==-1) return "DiffCol"; + if(channel==0) return "DiffCol.R"; + if(channel==1) return "DiffCol.G"; + return "DiffCol.B"; + } + if(passtype == SCE_PASS_GLOSSY_DIRECT) { + if(channel==-1) return "GlossDir"; + if(channel==0) return "GlossDir.R"; + if(channel==1) return "GlossDir.G"; + return "GlossDir.B"; + } + if(passtype == SCE_PASS_GLOSSY_INDIRECT) { + if(channel==-1) return "GlossInd"; + if(channel==0) return "GlossInd.R"; + if(channel==1) return "GlossInd.G"; + return "GlossInd.B"; + } + if(passtype == SCE_PASS_GLOSSY_COLOR) { + if(channel==-1) return "GlossCol"; + if(channel==0) return "GlossCol.R"; + if(channel==1) return "GlossCol.G"; + return "GlossCol.B"; + } + if(passtype == SCE_PASS_TRANSM_DIRECT) { + if(channel==-1) return "TransDir"; + if(channel==0) return "TransDir.R"; + if(channel==1) return "TransDir.G"; + return "TransDir.B"; + } + if(passtype == SCE_PASS_TRANSM_INDIRECT) { + if(channel==-1) return "TransInd"; + if(channel==0) return "TransInd.R"; + if(channel==1) return "TransInd.G"; + return "TransInd.B"; + } + if(passtype == SCE_PASS_TRANSM_COLOR) { + if(channel==-1) return "TransCol"; + if(channel==0) return "TransCol.R"; + if(channel==1) return "TransCol.G"; + return "TransCol.B"; + } return "Unknown"; } @@ -286,6 +340,34 @@ static int passtype_from_name(const char *str) if(strcmp(str, "RayHits")==0) return SCE_PASS_RAYHITS; + + if(strcmp(str, "DiffDir")==0) + return SCE_PASS_DIFFUSE_DIRECT; + + if(strcmp(str, "DiffInd")==0) + return SCE_PASS_DIFFUSE_INDIRECT; + + if(strcmp(str, "DiffCol")==0) + return SCE_PASS_DIFFUSE_COLOR; + + if(strcmp(str, "GlossDir")==0) + return SCE_PASS_GLOSSY_DIRECT; + + if(strcmp(str, "GlossInd")==0) + return SCE_PASS_GLOSSY_INDIRECT; + + if(strcmp(str, "GlossCol")==0) + return SCE_PASS_GLOSSY_COLOR; + + if(strcmp(str, "TransDir")==0) + return SCE_PASS_TRANSM_DIRECT; + + if(strcmp(str, "TransInd")==0) + return SCE_PASS_TRANSM_INDIRECT; + + if(strcmp(str, "TransCol")==0) + return SCE_PASS_TRANSM_COLOR; + return 0; } @@ -430,6 +512,24 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf render_layer_add_pass(rr, rl, 1, SCE_PASS_MIST); if(rl->passflag & SCE_PASS_RAYHITS) render_layer_add_pass(rr, rl, 4, SCE_PASS_RAYHITS); + if(srl->passflag & SCE_PASS_DIFFUSE_DIRECT) + render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_DIRECT); + if(srl->passflag & SCE_PASS_DIFFUSE_INDIRECT) + render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_INDIRECT); + if(srl->passflag & SCE_PASS_DIFFUSE_COLOR) + render_layer_add_pass(rr, rl, 3, SCE_PASS_DIFFUSE_COLOR); + if(srl->passflag & SCE_PASS_GLOSSY_DIRECT) + render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_DIRECT); + if(srl->passflag & SCE_PASS_GLOSSY_INDIRECT) + render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_INDIRECT); + if(srl->passflag & SCE_PASS_GLOSSY_COLOR) + render_layer_add_pass(rr, rl, 3, SCE_PASS_GLOSSY_COLOR); + if(srl->passflag & SCE_PASS_TRANSM_DIRECT) + render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_DIRECT); + if(srl->passflag & SCE_PASS_TRANSM_INDIRECT) + render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_INDIRECT); + if(srl->passflag & SCE_PASS_TRANSM_COLOR) + render_layer_add_pass(rr, rl, 3, SCE_PASS_TRANSM_COLOR); } /* sss, previewrender and envmap don't do layers, so we make a default one */ From 6b567963b378acb1a2e64c80e5675ebf73184883 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 25 Jan 2012 21:23:34 +0000 Subject: [PATCH 068/105] Fix #29989: Ctrl + T to show seconds in timeline, python error Issue seems to be caused by refactoring from rev43376. --- source/blender/makesrna/intern/rna_space.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d7f1c375a21..ebe698eb5d5 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2375,6 +2375,11 @@ static void rna_def_space_time(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Frame Number Indicator", "Show frame number beside the current frame indicator line"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); + prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", TIME_DRAWFRAMES); + RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); + /* displaying cache status */ prop= RNA_def_property(srna, "show_cache", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "cache_display", TIME_CACHE_DISPLAY); From 337302b56f27ccbcdaac44fffd2a69a8e19b736f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Jan 2012 22:06:53 +0000 Subject: [PATCH 069/105] hrmf, fix for fix [#29988] Segfault when unwrap default cube with smart project / follow active quads I think that we need a check here for thick wrapped strings but for now we dont have any thick wrapped strings with default values so comment it. --- source/blender/makesrna/intern/rna_access.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 3dc0e7c37e4..5339ee58acf 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4747,8 +4747,15 @@ ParameterList *RNA_parameter_list_create(ParameterList *parms, PointerRNA *UNUSE break; case PROP_STRING: { const char *defvalue= ((StringPropertyRNA*)parm)->defaultvalue; - if(defvalue && defvalue[0]) + if(defvalue && defvalue[0]) { + /* causes bug [#29988], possibly this is only correct for thick wrapped + * need to look further into it - campbell */ +#if 0 BLI_strncpy(data, defvalue, size); +#else + memcpy(data, &defvalue, size); +#endif + } break; } case PROP_POINTER: From c3fe3b1bafe9e2c29e2c6787c51c221cfa780c98 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Jan 2012 22:13:08 +0000 Subject: [PATCH 070/105] fix [#29987] scene.frame_set method doesn't take in account camera change done via markers --- source/blender/makesrna/intern/rna_scene_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 14e518da4b5..153317fb687 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -57,6 +57,7 @@ static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME); scene_update_for_newframe(G.main, scene, (1<<20) - 1); + scene_camera_switch_update(scene); /* cant use NC_SCENE|ND_FRAME because this casues wm_event_do_notifiers to call * scene_update_for_newframe which will loose any un-keyed changes [#24690] */ From 201890d4bbef61080e14a414fc74bb462595141f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Jan 2012 01:46:16 +0000 Subject: [PATCH 071/105] disable toggle option for BGE boolean property, not sure why this was set. --- release/scripts/startup/bl_ui/space_logic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_logic.py b/release/scripts/startup/bl_ui/space_logic.py index 1593f2c71ec..da6d1f72123 100644 --- a/release/scripts/startup/bl_ui/space_logic.py +++ b/release/scripts/startup/bl_ui/space_logic.py @@ -68,7 +68,7 @@ class LOGIC_PT_properties(Panel): row = box.row() row.prop(prop, "name", text="") row.prop(prop, "type", text="") - row.prop(prop, "value", text="", toggle=True) # we don't care about the type. rna will display correctly + row.prop(prop, "value", text="") row.prop(prop, "show_debug", text="", toggle=True, icon='INFO') row.operator("object.game_property_remove", text="", icon='X', emboss=False).index = i From 7e4558d163af72566213529c0a60a97bcbb6897d Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Thu, 26 Jan 2012 03:27:10 +0000 Subject: [PATCH 072/105] added support for USB Spaceball5000, also a partial attempt to accept button presses from unidentified 3D mice (for ancient serial devices) --- intern/ghost/intern/GHOST_NDOFManager.cpp | 50 +++++++++++++++++++++-- intern/ghost/intern/GHOST_NDOFManager.h | 10 ++++- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp index db4ed306dbe..0f5149de037 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.cpp +++ b/intern/ghost/intern/GHOST_NDOFManager.cpp @@ -77,6 +77,12 @@ static const char* ndof_button_names[] = { "NDOF_BUTTON_8", "NDOF_BUTTON_9", "NDOF_BUTTON_10", + // more general-purpose buttons + "NDOF_BUTTON_A", + "NDOF_BUTTON_B", + "NDOF_BUTTON_C", + // the end + "NDOF_BUTTON_LAST" }; #endif @@ -169,7 +175,7 @@ static const NDOF_ButtonT SpaceMousePro_HID_map[] = { }; /* this is the older SpacePilot (sans Pro) - * thanks to polosson for the info in this table */ + * thanks to polosson for info about this device */ static const NDOF_ButtonT SpacePilot_HID_map[] = { NDOF_BUTTON_1, NDOF_BUTTON_2, @@ -194,6 +200,23 @@ static const NDOF_ButtonT SpacePilot_HID_map[] = { NDOF_BUTTON_NONE // the CONFIG button -- what does it do? }; +/* this is the older Spaceball 5000 USB + * thanks to Tehrasha Darkon for info about this device */ +static const NDOF_ButtonT Spaceball5000_HID_map[] = { + NDOF_BUTTON_1, + NDOF_BUTTON_2, + NDOF_BUTTON_3, + NDOF_BUTTON_4, + NDOF_BUTTON_5, + NDOF_BUTTON_6, + NDOF_BUTTON_7, + NDOF_BUTTON_8, + NDOF_BUTTON_9, + NDOF_BUTTON_A, + NDOF_BUTTON_B, + NDOF_BUTTON_C +}; + GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System& sys) : m_system(sys) , m_deviceType(NDOF_UnknownDevice) // each platform has its own device detection code @@ -237,12 +260,12 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ m_buttonCount = 15; break; case 0xC629: - puts("ndof: using SpacePilotPro"); + puts("ndof: using SpacePilot Pro"); m_deviceType = NDOF_SpacePilotPro; m_buttonCount = 31; break; case 0xC62B: - puts("ndof: using SpaceMousePro"); + puts("ndof: using SpaceMouse Pro"); m_deviceType = NDOF_SpaceMousePro; m_buttonCount = 27; // ^^ actually has 15 buttons, but their HID codes range from 0 to 26 @@ -255,6 +278,12 @@ bool GHOST_NDOFManager::setDevice(unsigned short vendor_id, unsigned short produ m_buttonCount = 21; break; + case 0xC621: + puts("ndof: using Spaceball 5000"); + m_deviceType = NDOF_Spaceball5000; + m_buttonCount = 12; + break; + case 0xC623: puts("ndof: SpaceTraveler not supported, please file a bug report"); m_buttonCount = 8; @@ -385,8 +414,21 @@ void GHOST_NDOFManager::updateButton(int button_number, bool press, GHOST_TUns64 default: sendButtonEvent(SpacePilot_HID_map[button_number], press, time, window); } break; + case NDOF_Spaceball5000: + // has no special 'keyboard' buttons + sendButtonEvent(Spaceball5000_HID_map[button_number], press, time, window); + break; case NDOF_UnknownDevice: - printf("ndof: button %d on unknown device (ignoring)\n", button_number); + printf("ndof: button %d on unknown device (", button_number); + // map to the 'general purpose' buttons + // this is mainly for old serial devices + if (button_number < NDOF_BUTTON_LAST - NDOF_BUTTON_1) { + printf("sending)\n"); + sendButtonEvent((NDOF_ButtonT)(NDOF_BUTTON_1 + button_number), press, time, window); + } + else { + printf("discarding)\n"); + } } int mask = 1 << button_number; diff --git a/intern/ghost/intern/GHOST_NDOFManager.h b/intern/ghost/intern/GHOST_NDOFManager.h index 701f458ccf1..c4e980bb895 100644 --- a/intern/ghost/intern/GHOST_NDOFManager.h +++ b/intern/ghost/intern/GHOST_NDOFManager.h @@ -40,7 +40,8 @@ typedef enum { NDOF_SpaceMousePro, // older devices - NDOF_SpacePilot + NDOF_SpacePilot, + NDOF_Spaceball5000 } NDOF_DeviceT; @@ -87,7 +88,12 @@ typedef enum { NDOF_BUTTON_8, NDOF_BUTTON_9, NDOF_BUTTON_10, - + // more general-purpose buttons + NDOF_BUTTON_A, + NDOF_BUTTON_B, + NDOF_BUTTON_C, + // the end + NDOF_BUTTON_LAST } NDOF_ButtonT; class GHOST_NDOFManager From 18147117fefa5260018b0fd0fe5edf43a4226ed5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 07:18:26 +0000 Subject: [PATCH 073/105] Fix #29991: Broken Hotkeys for rotation in custom Maya-Navigation. >rev43375 Issue was caused by incorrect operator property set in revision 43376. --- release/scripts/presets/keyconfig/maya.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/presets/keyconfig/maya.py b/release/scripts/presets/keyconfig/maya.py index 4a9b6b0e96e..5e1e5d0d778 100644 --- a/release/scripts/presets/keyconfig/maya.py +++ b/release/scripts/presets/keyconfig/maya.py @@ -219,7 +219,8 @@ kmi.properties.value_1 = 'DISABLED' kmi.properties.value_2 = 'ENABLED' kmi = km.keymap_items.new('view3d.game_start', 'P', 'PRESS') kmi = km.keymap_items.new('object.select_all', 'A', 'PRESS') -kmi = km.keymap_items.new('object.select_all', 'I', 'PRESS', ctrl=True).action = 'INVERT' +kmi = km.keymap_items.new('object.select_all', 'I', 'PRESS', ctrl=True) +kmi.properties.action = 'INVERT' kmi = km.keymap_items.new('object.select_linked', 'L', 'PRESS', shift=True) kmi = km.keymap_items.new('object.select_grouped', 'G', 'PRESS', shift=True) kmi = km.keymap_items.new('object.select_mirror', 'M', 'PRESS', shift=True, ctrl=True) From 2a3d8a171b3eb01502e2a31eccefb6b5b9ad4c13 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 07:33:14 +0000 Subject: [PATCH 074/105] Fix for layer toggling always sticking to extend policy. Reported by Dalai in IRC, thanks for pointing to issue. --- source/blender/editors/space_view3d/view3d_header.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 00bb8d16943..e9b339c0baf 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -231,6 +231,8 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, wmEvent *event) if(event->shift) RNA_boolean_set(op->ptr, "extend", TRUE); + else + RNA_boolean_set(op->ptr, "extend", FALSE); if(event->alt) { int nr= RNA_int_get(op->ptr, "nr") + 10; From 1f996cb95ad3b6e97dba7e4392fe81f84e0263c6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 08:12:12 +0000 Subject: [PATCH 075/105] Replace hard-coded structures in selection callbacks in view3d_select with typedef-ed structures. Should be no functional changes, but this discovered inconsistency in structures used for armature circle selection, not sure how harmful this were, but it's not nice to have such inconsistencies. Anyway, it's resolved now. --- .../editors/space_view3d/view3d_select.c | 86 +++++++++++-------- 1 file changed, 52 insertions(+), 34 deletions(-) diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index be838c36ba9..f98149d2485 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -240,6 +240,12 @@ static void EM_backbuf_checkAndSelectTFaces(Mesh *me, int select) /* *********************** GESTURE AND LASSO ******************* */ +typedef struct LassoSelectUserData { + ViewContext *vc; + rcti *rect; + int (*mcords)[2], moves, select, pass, done; +} LassoSelectUserData; + static int view3d_selectable_data(bContext *C) { Object *ob = CTX_data_active_object(C); @@ -456,7 +462,7 @@ static void lasso_select_boundbox(rcti *rect, int mcords[][2], short moves) static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; + LassoSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { eve->f = data->select?(eve->f|1):(eve->f&~1); @@ -464,7 +470,7 @@ static void do_lasso_select_mesh__doSelectVert(void *userData, EditVert *eve, in } static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index) { - struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; + LassoSelectUserData *data = userData; if (EM_check_backbuf(em_solidoffs+index)) { if (data->pass==0) { @@ -483,16 +489,16 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, EditEdge *eed, in } static void do_lasso_select_mesh__doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } *data = userData; + LassoSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { - EM_select_face_fgon(data->vc.em, efa, data->select); + EM_select_face_fgon(data->vc->em, efa, data->select); } } static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { ViewContext vc; rcti *rect; int (*mcords)[2], moves, select, pass, done; } data; + LassoSelectUserData data; ToolSettings *ts= vc->scene->toolsettings; rcti rect; int bbsel; @@ -502,7 +508,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, /* set editmesh */ vc->em= ((Mesh *)vc->obedit->data)->edit_mesh; - data.vc= *vc; + data.vc= vc; data.rect = ▭ data.mcords = mcords; data.moves = moves; @@ -610,7 +616,7 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } *data = userData; + LassoSelectUserData *data = userData; Object *obedit= data->vc->obedit; Curve *cu= (Curve*)obedit->data; @@ -639,7 +645,7 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { ViewContext *vc; int (*mcords)[2]; short moves; short select; } data; + LassoSelectUserData data; /* set vc->editnurb */ data.vc = vc; @@ -656,7 +662,7 @@ static void do_lasso_select_curve(ViewContext *vc, int mcords[][2], short moves, static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, int y) { - struct { int (*mcords)[2]; short moves; short select; } *data = userData; + LassoSelectUserData *data = userData; if (lasso_inside(data->mcords, data->moves, x, y)) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); @@ -664,7 +670,7 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, } static void do_lasso_select_lattice(ViewContext *vc, int mcords[][2], short moves, short extend, short select) { - struct { int (*mcords)[2]; short moves; short select; } data; + LassoSelectUserData data; /* set editdata in vc */ data.mcords = mcords; @@ -1624,6 +1630,11 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* ******************** border and circle ************************************** */ +typedef struct BoxSelectUserData { + ViewContext *vc; + rcti *rect; + int select, pass, done; +} BoxSelectUserData; int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2) { @@ -1649,7 +1660,7 @@ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct { ViewContext *vc; rcti *rect; int select; } *data = userData; + BoxSelectUserData *data = userData; Object *obedit= data->vc->obedit; Curve *cu= (Curve*)obedit->data; @@ -1677,7 +1688,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi } static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int extend) { - struct { ViewContext *vc; rcti *rect; int select; } data; + BoxSelectUserData data; data.vc = vc; data.rect = rect; @@ -1694,7 +1705,7 @@ static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int exte static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, int y) { - struct { ViewContext vc; rcti *rect; int select; } *data = userData; + BoxSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y)) { bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); @@ -1702,9 +1713,9 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i } static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int extend) { - struct { ViewContext vc; rcti *rect; int select, pass, done; } data; + BoxSelectUserData data; - data.vc= *vc; + data.vc= vc; data.rect = rect; data.select = select; @@ -1719,7 +1730,7 @@ static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int ex static void do_mesh_box_select__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData; + BoxSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y)) { eve->f = data->select?(eve->f|1):(eve->f&~1); @@ -1727,7 +1738,7 @@ static void do_mesh_box_select__doSelectVert(void *userData, EditVert *eve, int } static void do_mesh_box_select__doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index) { - struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData; + BoxSelectUserData *data = userData; if(EM_check_backbuf(em_solidoffs+index)) { if (data->pass==0) { @@ -1744,19 +1755,19 @@ static void do_mesh_box_select__doSelectEdge(void *userData, EditEdge *eed, int } static void do_mesh_box_select__doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct { ViewContext vc; rcti *rect; short select, pass, done; } *data = userData; + BoxSelectUserData *data = userData; if (BLI_in_rcti(data->rect, x, y)) { - EM_select_face_fgon(data->vc.em, efa, data->select); + EM_select_face_fgon(data->vc->em, efa, data->select); } } static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int extend) { - struct { ViewContext vc; rcti *rect; short select, pass, done; } data; + BoxSelectUserData data; ToolSettings *ts= vc->scene->toolsettings; int bbsel; - data.vc= *vc; + data.vc= vc; data.rect = rect; data.select = select; data.pass = 0; @@ -2251,9 +2262,16 @@ void VIEW3D_OT_select(wmOperatorType *ot) /* -------------------- circle select --------------------------------------------- */ +typedef struct CircleSelectUserData { + ViewContext *vc; + short select; + int mval[2]; + float radius; +} CircleSelectUserData; + static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index)) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2263,7 +2281,7 @@ static void mesh_circle_doSelectVert(void *userData, EditVert *eve, int x, int y } static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int UNUSED(index)) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; if (edge_inside_circle(data->mval[0], data->mval[1], (short) data->radius, x0, y0, x1, y1)) { EM_select_edge(eed, data->select); @@ -2271,7 +2289,7 @@ static void mesh_circle_doSelectEdge(void *userData, EditEdge *eed, int x0, int } static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y, int UNUSED(index)) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2284,7 +2302,7 @@ static void mesh_circle_select(ViewContext *vc, int select, const int mval[2], f { ToolSettings *ts= vc->scene->toolsettings; int bbsel; - struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + CircleSelectUserData data; bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0f)); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -2346,7 +2364,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m Object *ob= vc->obact; Mesh *me = ob?ob->data:NULL; /* int bbsel; */ /* UNUSED */ - /* struct {ViewContext *vc; short select; int mval[2]; float radius; } data = {NULL}; */ /* UNUSED */ + /* CircleSelectUserData data = {NULL}; */ /* UNUSED */ if (me) { em_vertoffs= me->totvert+1; /* max index array */ @@ -2361,7 +2379,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint *bp, BezTriple *bezt, int beztindex, int x, int y) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); Object *obedit= data->vc->obedit; @@ -2392,7 +2410,7 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint } static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + CircleSelectUserData data; /* set vc-> edit data */ @@ -2409,7 +2427,7 @@ static void nurbscurve_circle_select(ViewContext *vc, int select, const int mval static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int y) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2419,7 +2437,7 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int } static void lattice_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + CircleSelectUserData data; /* set vc-> edit data */ @@ -2436,7 +2454,7 @@ static void lattice_circle_select(ViewContext *vc, int select, const int mval[2] // NOTE: pose-bone case is copied from editbone case... static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2451,7 +2469,7 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int } static void pose_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } data; + CircleSelectUserData data; bArmature *arm = vc->obact->data; bPose *pose = vc->obact->pose; bPoseChannel *pchan; @@ -2501,7 +2519,7 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int x, int y, short head) { - struct {ViewContext *vc; short select; int mval[2]; float radius; } *data = userData; + CircleSelectUserData *data = userData; int mx = x - data->mval[0], my = y - data->mval[1]; float r = sqrt(mx*mx + my*my); @@ -2524,7 +2542,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int } static void armature_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { - struct {ViewContext *vc; short select, mval[2]; float radius; } data; + CircleSelectUserData data; bArmature *arm= vc->obedit->data; EditBone *ebone; int change= FALSE; From dc4e37c7642da007ebc73f7528426e921b3f96fa Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 09:29:49 +0000 Subject: [PATCH 076/105] Tracks curves fixes and improvements: - Use proper poll functions for tracks curve operators. - Darken frames outside of scene frame range in curves view. - Implemented view all operator. - Implemented jump to current frame operator. --- .../editors/space_clip/clip_graph_draw.c | 24 ++++ .../editors/space_clip/clip_graph_ops.c | 116 +++++++++++++++++- .../blender/editors/space_clip/clip_intern.h | 2 + .../blender/editors/space_clip/space_clip.c | 8 +- 4 files changed, 147 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index e913ae77f05..6fabe802ff0 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -47,6 +47,7 @@ #include "ED_clip.h" #include "BIF_gl.h" +#include "BIF_glutil.h" #include "WM_types.h" @@ -120,6 +121,26 @@ static void draw_graph_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) glScalef(xscale, 1.0, 1.0); } +static void draw_graph_sfra_efra(Scene *scene, View2D *v2d) +{ + UI_view2d_view_ortho(v2d); + + /* currently clip editor supposes that editing clip length is equal to scene frame range */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glColor4f(0.0f, 0.0f, 0.0f, 0.4f); + + glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); + glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + glDisable(GL_BLEND); + + UI_ThemeColorShade(TH_BACK, -60); + + /* thin lines where the actual frames are */ + fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); + fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax); +} + static void tracking_segment_point_cb(void *UNUSED(userdata), MovieTrackingTrack *UNUSED(track), MovieTrackingMarker *marker, int UNUSED(coord), float val) { @@ -255,6 +276,9 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) draw_frame_curves(sc); } + /* frame range */ + draw_graph_sfra_efra(scene, v2d); + /* current frame */ draw_graph_cfra(sc, ar, scene); } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 8be5e520b1f..7652e59a9a8 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -30,6 +30,7 @@ */ #include "DNA_object_types.h" /* SELECT */ +#include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -58,6 +59,19 @@ /******************** common graph-editing utilities ********************/ +static int ED_space_clip_graph_poll(bContext *C) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + + if(sc && sc->clip) { + ARegion *ar = CTX_wm_region(C); + + return ar->regiontype == RGN_TYPE_PREVIEW; + } + + return 0; +} + typedef struct { int action; } SelectUserData; @@ -278,7 +292,7 @@ void CLIP_OT_graph_select(wmOperatorType *ot) /* api callbacks */ ot->exec= select_exec; ot->invoke= select_invoke; - ot->poll= ED_space_clip_poll; + ot->poll= ED_space_clip_graph_poll; /* flags */ ot->flag= OPTYPE_UNDO; @@ -357,8 +371,106 @@ void CLIP_OT_graph_delete_knot(wmOperatorType *ot) /* api callbacks */ ot->exec= delete_knot_exec; - ot->poll= ED_space_clip_poll; + ot->poll= ED_space_clip_graph_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } + +/******************** view all operator ********************/ + +typedef struct { + float min, max; +} ViewAllUserData; + +static void view_all_cb(void *userdata, MovieTrackingTrack *UNUSED(track), MovieTrackingMarker *UNUSED(marker), + int UNUSED(coord), float val) +{ + ViewAllUserData *data = (ViewAllUserData *)userdata; + + if(val < data->min) data->min = val; + if(val > data->max) data->max = val; +} + +static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + SpaceClip *sc = CTX_wm_space_clip(C); + View2D *v2d = &ar->v2d; + ViewAllUserData userdata; + float extra; + + userdata.max = -FLT_MAX; + userdata.min = FLT_MAX; + + clip_graph_tracking_values_iterate(sc, &userdata, view_all_cb, NULL, NULL); + + /* set extents of view to start/end frames */ + v2d->cur.xmin = (float)SFRA; + v2d->cur.xmax = (float)EFRA; + + if (userdata.min < userdata.max) { + v2d->cur.ymin = userdata.min; + v2d->cur.ymax = userdata.max; + } + else { + v2d->cur.ymin = -10; + v2d->cur.ymax = 10; + } + + /* we need an extra "buffer" factor on either side so that the endpoints are visible */ + extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin); + v2d->cur.xmin -= extra; + v2d->cur.xmax += extra; + + extra= 0.01f * (v2d->cur.ymax - v2d->cur.ymin); + v2d->cur.ymin -= extra; + v2d->cur.ymax += extra; + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void CLIP_OT_graph_view_all(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "View All"; + ot->description = "View all curves in editor"; + ot->idname = "CLIP_OT_graph_view_all"; + + /* api callbacks */ + ot->exec = view_all_exec; + ot->poll = ED_space_clip_graph_poll; +} + +/******************** jump to current frame operator ********************/ + +static int jump_to_current_frame_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; + float extra = (v2d->cur.xmax - v2d->cur.xmin) / 2.0; + + /* set extents of view to start/end frames */ + v2d->cur.xmin = (float)CFRA - extra; + v2d->cur.xmax = (float)CFRA + extra; + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void CLIP_OT_graph_jump_to_current_frame(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Jump to current frame"; + ot->description = "Jump to current frame"; + ot->idname = "CLIP_OT_graph_jump_to_current_frame"; + + /* api callbacks */ + ot->exec = jump_to_current_frame_exec; + ot->poll = ED_space_clip_graph_poll; +} diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 3f7456e90dc..3f273b5cd90 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -58,6 +58,8 @@ void clip_draw_graph(struct SpaceClip *sc, struct ARegion *ar, struct Scene *sce void CLIP_OT_graph_select(struct wmOperatorType *ot); void CLIP_OT_graph_delete_curve(struct wmOperatorType *ot); void CLIP_OT_graph_delete_knot(struct wmOperatorType *ot); +void CLIP_OT_graph_view_all(struct wmOperatorType *ot); +void CLIP_OT_graph_jump_to_current_frame(struct wmOperatorType *ot); /* clip_ops.c */ void CLIP_OT_open(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 04871156412..25617c3cf5d 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -78,7 +78,7 @@ static void init_preview_region(const bContext *C, ARegion *ar) ar->flag|= RGN_FLAG_HIDDEN; ar->v2d.tot.xmin= 0.0f; - ar->v2d.tot.ymin= (float)scene->r.sfra - 10.0f; + ar->v2d.tot.ymin= -10.0f; ar->v2d.tot.xmax= (float)scene->r.efra; ar->v2d.tot.ymax= 10.0f; @@ -373,6 +373,8 @@ static void clip_operatortypes(void) WM_operatortype_append(CLIP_OT_graph_select); WM_operatortype_append(CLIP_OT_graph_delete_curve); WM_operatortype_append(CLIP_OT_graph_delete_knot); + WM_operatortype_append(CLIP_OT_graph_view_all); + WM_operatortype_append(CLIP_OT_graph_jump_to_current_frame); /* object tracking */ WM_operatortype_append(CLIP_OT_tracking_object_new); @@ -546,6 +548,10 @@ static void clip_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", DELKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "CLIP_OT_graph_delete_knot", XKEY, KM_PRESS, KM_SHIFT, 0); + /* view */ + WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", HOMEKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CLIP_OT_graph_jump_to_current_frame", PADPERIOD, KM_PRESS, 0, 0); + transform_keymap_for_space(keyconf, keymap, SPACE_CLIP); } From 969c87b5afc19094fc77537f74f2b0b86d5448d3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 09:53:58 +0000 Subject: [PATCH 077/105] Movie clip editor: graph view now can be toggled using Z key --- source/blender/editors/space_clip/space_clip.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 25617c3cf5d..c9b8c7971e5 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -420,6 +420,11 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "mode", SC_MODE_DISTORTION); RNA_boolean_set(kmi->ptr, "toggle", TRUE); + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "space_data.view"); + RNA_string_set(kmi->ptr, "value_1", "CLIP"); + RNA_string_set(kmi->ptr, "value_2", "GRAPH"); + /* ******** Hotkeys avalaible for main region only ******** */ keymap= WM_keymap_find(keyconf, "Clip Editor", SPACE_CLIP, 0); From dbe432f73fd1628900d699431801209614e2e174 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 10:36:36 +0000 Subject: [PATCH 078/105] Fix build on debian ports that differs from generic i386/x86_64 like kFreeBSD Patch by Kevin Roy, thanks! --- extern/libmv/third_party/glog/src/config.h | 10 +++++----- extern/libmv/third_party/glog/src/config_linux.h | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/extern/libmv/third_party/glog/src/config.h b/extern/libmv/third_party/glog/src/config.h index 49c0d8905b0..102bf9e4034 100644 --- a/extern/libmv/third_party/glog/src/config.h +++ b/extern/libmv/third_party/glog/src/config.h @@ -2,14 +2,14 @@ /* src/config.h.in. Generated from configure.ac by autoheader. */ /* Namespace for Google classes */ -#ifdef __APPLE__ +#if defined(__APPLE__) #include "config_mac.h" -#elif __FreeBSD__ +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include "config_freebsd.h" -#elif __MINGW32__ +#elif defined(__MINGW32__) #include "windows/config.h" -#elif __GNUC__ +#elif defined(__linux__) #include "config_linux.h" -#elif _MSC_VER +#elif defined(_MSC_VER) #include "windows/config.h" #endif diff --git a/extern/libmv/third_party/glog/src/config_linux.h b/extern/libmv/third_party/glog/src/config_linux.h index ffd4e778de6..faf032949bb 100644 --- a/extern/libmv/third_party/glog/src/config_linux.h +++ b/extern/libmv/third_party/glog/src/config_linux.h @@ -133,8 +133,10 @@ /* How to access the PC from a struct ucontext */ #if defined(_M_X64) || defined(__amd64__) || defined(__x86_64__) #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_RIP] -#else +#elif defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) #define PC_FROM_UCONTEXT uc_mcontext.gregs[REG_EIP] +#else + #undef PC_FROM_UCONTEXT #endif /* Define to necessary symbol if this constant uses a non-standard name on From 371d5815a7088c74c8228783834474fb71316c62 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 10:59:31 +0000 Subject: [PATCH 079/105] Fix implicit declaration of guardedalloc functions in avi's endian.c. Discovered by debian building system. --- source/blender/avi/intern/endian.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c index 29b3047eca4..adcc7e8750a 100644 --- a/source/blender/avi/intern/endian.c +++ b/source/blender/avi/intern/endian.c @@ -42,6 +42,10 @@ #include "endian.h" #include "avi_intern.h" +#ifdef __BIG_ENDIAN__ +#include "MEM_guardedalloc.h" +#endif + #ifdef __BIG_ENDIAN__ static void invert (int *num) { From e19d78178de0eeb8cdadcbbe7b7d78d950d85007 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 11:16:49 +0000 Subject: [PATCH 080/105] Possible fix for implicit declaration of av_rescale_q on some platforms. --- intern/ffmpeg/ffmpeg_compat.h | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index dfdad22e176..582086d130b 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -35,6 +35,7 @@ #include #include +#include #if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) #define FFMPEG_HAVE_PARSE_UTILS 1 From db57cbac20bb513ba688c5cfb2655d8753a89aab Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 11:49:38 +0000 Subject: [PATCH 081/105] More curves view improvements for clip editor: - Renamed graph_jump_to_current_frame to graph_center_current_frame which makes more sense. - Curve view now can be locked to time cursor (Lock to Time Cursor in Display panel or L button in curve view). Not sure if offset from locked position will make much sense here. - Added hotkey for solving -- Shift-S. --- release/scripts/startup/bl_ui/space_clip.py | 3 +++ .../editors/space_clip/clip_graph_ops.c | 22 ++++++++++++------- .../blender/editors/space_clip/clip_intern.h | 4 +++- .../blender/editors/space_clip/space_clip.c | 12 ++++++++-- source/blender/makesdna/DNA_space_types.h | 3 ++- source/blender/makesrna/intern/rna_space.c | 6 +++++ 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index c8582e532bb..c179342bc44 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -559,6 +559,9 @@ class CLIP_PT_display(Panel): col.prop(sc, "lock_selection") + if sc.view == 'GRAPH': + col.prop(sc, "lock_time_cursor") + clip = sc.clip if clip: col.label(text="Display Aspect Ratio:") diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 7652e59a9a8..6a56de26689 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -447,30 +447,36 @@ void CLIP_OT_graph_view_all(wmOperatorType *ot) /******************** jump to current frame operator ********************/ -static int jump_to_current_frame_exec(bContext *C, wmOperator *UNUSED(op)) +void ED_clip_graph_center_current_frame(Scene *scene, ARegion *ar) { - Scene *scene = CTX_data_scene(C); - ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; float extra = (v2d->cur.xmax - v2d->cur.xmin) / 2.0; /* set extents of view to start/end frames */ v2d->cur.xmin = (float)CFRA - extra; v2d->cur.xmax = (float)CFRA + extra; +} + +static int center_current_frame_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + + ED_clip_graph_center_current_frame(scene, ar); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } -void CLIP_OT_graph_jump_to_current_frame(wmOperatorType *ot) +void CLIP_OT_graph_center_current_frame(wmOperatorType *ot) { /* identifiers */ - ot->name = "Jump to current frame"; - ot->description = "Jump to current frame"; - ot->idname = "CLIP_OT_graph_jump_to_current_frame"; + ot->name = "Center Current Frame"; + ot->description = "Scroll view so current frame would be centered"; + ot->idname = "CLIP_OT_graph_center_current_frame"; /* api callbacks */ - ot->exec = jump_to_current_frame_exec; + ot->exec = center_current_frame_exec; ot->poll = ED_space_clip_graph_poll; } diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index 3f273b5cd90..9ff58a73ca2 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -55,11 +55,13 @@ void clip_draw_curfra_label(struct SpaceClip *sc, float x, float y); void clip_draw_graph(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); /* clip_graph_ops.c */ +void ED_clip_graph_center_current_frame(struct Scene *scene, struct ARegion *ar); + void CLIP_OT_graph_select(struct wmOperatorType *ot); void CLIP_OT_graph_delete_curve(struct wmOperatorType *ot); void CLIP_OT_graph_delete_knot(struct wmOperatorType *ot); void CLIP_OT_graph_view_all(struct wmOperatorType *ot); -void CLIP_OT_graph_jump_to_current_frame(struct wmOperatorType *ot); +void CLIP_OT_graph_center_current_frame(struct wmOperatorType *ot); /* clip_ops.c */ void CLIP_OT_open(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index c9b8c7971e5..9eff602fe6b 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -374,7 +374,7 @@ static void clip_operatortypes(void) WM_operatortype_append(CLIP_OT_graph_delete_curve); WM_operatortype_append(CLIP_OT_graph_delete_knot); WM_operatortype_append(CLIP_OT_graph_view_all); - WM_operatortype_append(CLIP_OT_graph_jump_to_current_frame); + WM_operatortype_append(CLIP_OT_graph_center_current_frame); /* object tracking */ WM_operatortype_append(CLIP_OT_tracking_object_new); @@ -425,6 +425,8 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "value_1", "CLIP"); RNA_string_set(kmi->ptr, "value_2", "GRAPH"); + WM_keymap_add_item(keymap, "CLIP_OT_solve_camera", SKEY, KM_PRESS, KM_SHIFT, 0); + /* ******** Hotkeys avalaible for main region only ******** */ keymap= WM_keymap_find(keyconf, "Clip Editor", SPACE_CLIP, 0); @@ -555,7 +557,10 @@ static void clip_keymap(struct wmKeyConfig *keyconf) /* view */ WM_keymap_add_item(keymap, "CLIP_OT_graph_view_all", HOMEKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "CLIP_OT_graph_jump_to_current_frame", PADPERIOD, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "CLIP_OT_graph_center_current_frame", PADPERIOD, KM_PRESS, 0, 0); + + kmi= WM_keymap_add_item(keymap, "WM_OT_context_toggle", LKEY, KM_PRESS, 0, 0); + RNA_string_set(kmi->ptr, "data_path", "space_data.lock_time_cursor"); transform_keymap_for_space(keyconf, keymap, SPACE_CLIP); } @@ -778,6 +783,9 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar) Scene *scene= CTX_data_scene(C); short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES; + if(sc->flag & SC_LOCK_TIMECURSOR) + ED_clip_graph_center_current_frame(scene, ar); + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index d57da31793e..06138bc0757 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -900,7 +900,8 @@ enum { #define SC_SHOW_FILTERS (1<<13) #define SC_SHOW_GRAPH_FRAMES (1<<14) #define SC_SHOW_GRAPH_TRACKS (1<<15) -#define SC_SHOW_PYRAMID_LEVELS (1<<16) +#define SC_SHOW_PYRAMID_LEVELS (1<<16) +#define SC_LOCK_TIMECURSOR (1<<17) /* SpaceClip->mode */ #define SC_MODE_TRACKING 0 diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index ebe698eb5d5..571fe05238d 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2900,6 +2900,12 @@ static void rna_def_space_clip(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_LOCK_SELECTION); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, "rna_SpaceClipEditor_lock_selection_update"); + /* lock to time cursor */ + prop= RNA_def_property(srna, "lock_time_cursor", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_text(prop, "Lock to Time Cursor", "Lock curves view to time cursos during playback and tracking"); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_LOCK_TIMECURSOR); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); + /* show markers pathes */ prop= RNA_def_property(srna, "show_track_path", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_TRACK_PATH); From 83a6b331a75580f9eab24f4fe0b3fd6a1db9fab9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 12:44:31 +0000 Subject: [PATCH 082/105] Fix #29895 Fast Alt-Mousewheel toggling of Mapping Modes scrubs timeline Issue was caused by changing button state to EXIT, so there's no active button just after applying Alt-Wheel event. Setting this state is needed to prevent button trigger cancel callback when mouse is leaving hovered menu button. Using the same "post activate" trick used by Tab button allows to make prevent canceling button and makes this button active again after applying all handlers. There's still issues with Alt-Scroll if changing active element in menu leads to interface changes (like file format in render buttons) -- in this case button simple doesn't receive wheel events and it's actually not connected to this issue. --- .../editors/interface/interface_handlers.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 93d8f9c0c8a..849d3ecc758 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3030,12 +3030,28 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm data->value= ui_step_name_menu(but, -1); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, 1); + + /* button's state need to be changed to EXIT so moving mouse away from this mouse wouldn't lead + * to cancel changes made to this button, but shanging state to EXIT also makes no button active for + * a while which leads to triggering operator when doing fast scrolling mouse wheel. + * using post activate stuff from button allows to make button be active again after checking for all + * all that mouse leave and cancel stuff, so wuick scrool wouldnt't be an issue anumore. + * same goes for scrolling wheel in another direction below (sergey) + */ + data->postbut= but; + data->posttype= BUTTON_ACTIVATE_OVER; + return WM_UI_HANDLER_BREAK; } else if(event->type == WHEELUPMOUSE && event->alt) { data->value= ui_step_name_menu(but, 1); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, 1); + + /* why this is needed described above */ + data->postbut= but; + data->posttype= BUTTON_ACTIVATE_OVER; + return WM_UI_HANDLER_BREAK; } } From 4ae93a48d83a8340493aef0049c43f6180033807 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 12:48:36 +0000 Subject: [PATCH 083/105] Fix #29958: Search Menu keeps hiding first character(s) after long input - ui_check_but() in ui_textedit_move() is necessary because this function clips but->drawstring to fit text entry widget and it confuses cursor movement stuff. ui_check_but copies editstring to drawstring, so displaystring would be clipped again in correct way. - If the whole drawstring fits widget, no need to set button's offset. --- source/blender/editors/interface/interface_handlers.c | 2 ++ source/blender/editors/interface/interface_widgets.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 849d3ecc758..cfb375c2558 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1527,6 +1527,8 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, int direction const int pos_prev= but->pos; const int has_sel= (but->selend - but->selsta) > 0; + ui_check_but(but); + /* special case, quit selection and set cursor */ if (has_sel && !select) { if (jump == BUTTON_EDIT_JUMP_ALL) { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 19acfaccaa3..cd0844a38a3 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -952,6 +952,9 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) if(but->editstr && but->pos >= 0) { if(but->ofs > but->pos) but->ofs= but->pos; + + if(BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth) + but->ofs = 0; } else but->ofs= 0; From 331c235d93ef77bce3c5d5b668d433bfbb75ca88 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 13:13:48 +0000 Subject: [PATCH 084/105] Movie clip editor: curves view shouldn't jump back to top when click on it Also it should now re-store position after toggling it. --- source/blender/editors/space_clip/space_clip.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 9eff602fe6b..0d34cc2cfbf 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -604,10 +604,6 @@ static void clip_refresh(const bContext *C, ScrArea *sa) ar_main->alignment= RGN_ALIGN_NONE; view_changed= 1; } - if (ar_preview && ar_preview->alignment != RGN_ALIGN_NONE) { - ar_preview->alignment= RGN_ALIGN_NONE; - view_changed= 1; - } break; case SC_VIEW_GRAPH: if (ar_preview && (ar_preview->flag & RGN_FLAG_HIDDEN)) { @@ -620,7 +616,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa) ar_main->alignment= RGN_ALIGN_NONE; view_changed= 1; } - if (ar_preview && ar_preview->alignment != RGN_ALIGN_TOP) { + if (ar_preview && !ELEM(ar_preview->alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { ar_preview->alignment= RGN_ALIGN_TOP; view_changed= 1; } From f8bddbd347e7ded7a14187ca96b69dfec70c20cd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 Jan 2012 14:55:25 +0000 Subject: [PATCH 085/105] Cycles: fix issues rendering second render layer passes, and avoid unnecessary clear of buffer. --- intern/cycles/blender/blender_session.cpp | 10 +++++++--- intern/cycles/kernel/kernel_passes.h | 9 --------- intern/cycles/kernel/kernel_path.h | 2 -- intern/cycles/render/buffers.cpp | 15 +++++++++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index ff1c32831bb..5e3102fd7c7 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -203,6 +203,9 @@ void BlenderSession::render() b_rlay = *b_iter; /* add passes */ + vector passes; + Pass::add(PASS_COMBINED, passes); + if(session_params.device.type == DEVICE_CPU) { /* todo */ BL::RenderLayer::passes_iterator b_pass_iter; @@ -211,12 +214,13 @@ void BlenderSession::render() PassType pass_type = get_pass_type(b_pass); if(pass_type != PASS_NONE) - Pass::add(pass_type, buffer_params.passes); + Pass::add(pass_type, passes); } } - scene->film->passes = buffer_params.passes; - scene->film->need_update = true; + buffer_params.passes = passes; + scene->film->passes = passes; + scene->film->tag_update(scene); /* update session */ session->reset(buffer_params, session_params.samples); diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index 0e775812eda..9a568229b17 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -36,15 +36,6 @@ __device_inline void kernel_write_pass_float4(__global float *buffer, int sample *buf = (sample == 0)? value: *buf + value; } -__device_inline void kernel_clear_passes(__global float *buffer, int sample, int pass_stride) -{ -#ifdef __PASSES__ - if(sample == 0 && pass_stride != 4) - for(int i = 4; i < pass_stride; i++) - buffer[i] = 0.0f; -#endif -} - __device void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, ShaderData *sd, int sample, int path_flag, float3 throughput) { diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index c0bfa320405..aad7050ed1b 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -377,8 +377,6 @@ __device void kernel_path_trace(KernelGlobals *kg, rng_state += index; buffer += index*pass_stride; - kernel_clear_passes(buffer, sample, pass_stride); - /* initialize random numbers */ RNG rng; diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 08dda944111..56219482ef0 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -157,10 +157,17 @@ bool RenderBuffers::get_pass(PassType type, float exposure, int sample, int comp assert(pass.components == components); /* scalar */ - for(int i = 0; i < size; i++, in += pass_stride, pixels++) { - float f = *in; - - pixels[0] = f*scale_exposure; + if(type == PASS_DEPTH) { + for(int i = 0; i < size; i++, in += pass_stride, pixels++) { + float f = *in; + pixels[0] = (f == 0.0f)? 1e10f: f*scale_exposure; + } + } + else { + for(int i = 0; i < size; i++, in += pass_stride, pixels++) { + float f = *in; + pixels[0] = f*scale_exposure; + } } } else if(components == 3) { From 7e86c8fcdc3037a8ced688a81210e5953ec91d8d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 Jan 2012 14:55:39 +0000 Subject: [PATCH 086/105] Fix #29966: cycles elapsed time not resetting in viewport after changes. --- intern/cycles/util/util_progress.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h index acb00b03507..2cc2995bcfe 100644 --- a/intern/cycles/util/util_progress.h +++ b/intern/cycles/util/util_progress.h @@ -96,7 +96,7 @@ public: { thread_scoped_lock lock(progress_mutex); - start_time = start_time; + start_time = start_time_; } void set_sample(int sample_, double sample_time_) From 2e9ae40aafd26da9376983cc73e17b4f1274b0ad Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 Jan 2012 14:55:46 +0000 Subject: [PATCH 087/105] Fix #29960: fields option should not be used for external engine rendering. --- source/blender/render/intern/source/pipeline.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index f585912c18c..604ba189dcf 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1894,6 +1894,7 @@ static void validate_render_settings(Render *re) if(RE_engine_is_external(re)) { /* not supported yet */ re->r.scemode &= ~(R_EXR_TILE_FILE|R_FULL_SAMPLE); + re->r.mode &= ~R_FIELDS; } } From 6eb3d5cb50b3ca542b4705a41dbecd47d53d64f9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 15:04:25 +0000 Subject: [PATCH 088/105] Movie clip editor: default tracking settings can be copied from active track now --- release/scripts/startup/bl_operators/clip.py | 51 ++++++++++++++++++++ release/scripts/startup/bl_ui/space_clip.py | 3 ++ 2 files changed, 54 insertions(+) diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index ac82ffbf48f..c5ea8176691 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -90,6 +90,31 @@ def CLIP_track_view_selected(sc, track): return False +def CLIP_default_settings_from_track(clip, track): + settings = clip.tracking.settings + + width = clip.size[0] + height = clip.size[1] + + pattern = track.pattern_max - track.pattern_min + search = track.search_max - track.search_min + + pattern[0] = pattern[0] * clip.size[0] + pattern[1] = pattern[1] * clip.size[1] + + search[0] = search[0] * clip.size[0] + search[1] = search[1] * clip.size[1] + + settings.default_tracker = track.tracker + settings.default_pyramid_levels = track.pyramid_levels + settings.default_correlation_min = track.correlation_min + settings.default_pattern_size = max(pattern[0], pattern[1]) + settings.default_search_size = max(search[0], search[1]) + settings.default_frames_limit = track.frames_limit + settings.default_pattern_match = track.pattern_match + settings.default_margin = track.margin + + class CLIP_OT_track_to_empty(Operator): """Create an Empty object which will be copying movement of active track""" @@ -805,3 +830,29 @@ class CLIP_OT_setup_tracking_scene(Operator): self._setupObjects(context) return {'FINISHED'} + +class CLIP_OT_track_settings_as_default(Operator): + """Copy trackign settings from active track to default settings""" + + bl_idname = "clip.track_settings_as_default" + bl_label = "Track Settings As Default" + bl_options = {'UNDO', 'REGISTER'} + + @classmethod + def poll(cls, context): + sc = context.space_data + + if sc.type != 'CLIP_EDITOR': + return False + + clip = sc.clip + + return clip and clip.tracking.tracks.active + + def execute(self, context): + sc = context.space_data + clip = sc.clip + + CLIP_default_settings_from_track(clip, clip.tracking.tracks.active) + + return {'FINISHED'} diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index c179342bc44..7c2e1a2007c 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -147,6 +147,9 @@ class CLIP_PT_tools_marker(Panel): col.label(text="Match:") col.prop(settings, "default_pattern_match", text="") + col.separator() + col.operator('clip.track_settings_as_default', text="Copy From Active Track") + class CLIP_PT_tools_tracking(Panel): bl_space_type = 'CLIP_EDITOR' From bcbe9ca5fc09caf617a355c52a6368f9c889adbc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 15:33:16 +0000 Subject: [PATCH 089/105] Color channels used for tracking is now a part of default tracking settings and also a part of presets. --- .../tracking_settings/blurry_footage.py | 3 +++ .../presets/tracking_settings/default.py | 3 +++ .../presets/tracking_settings/fast_motion.py | 3 +++ release/scripts/startup/bl_operators/clip.py | 3 +++ .../scripts/startup/bl_operators/presets.py | 5 ++++- release/scripts/startup/bl_ui/space_clip.py | 7 +++++++ source/blender/blenkernel/intern/tracking.c | 1 + source/blender/makesdna/DNA_tracking_types.h | 7 ++++++- source/blender/makesrna/intern/rna_tracking.c | 20 +++++++++++++++++++ 9 files changed, 50 insertions(+), 2 deletions(-) diff --git a/release/scripts/presets/tracking_settings/blurry_footage.py b/release/scripts/presets/tracking_settings/blurry_footage.py index c805301df78..c06d4c3835b 100644 --- a/release/scripts/presets/tracking_settings/blurry_footage.py +++ b/release/scripts/presets/tracking_settings/blurry_footage.py @@ -9,3 +9,6 @@ settings.default_search_size = 100 settings.default_frames_limit = 0 settings.default_pattern_match = 'PREV_FRAME' settings.default_margin = 0 +settings.use_default_red_channel = True +settings.use_default_green_channel = True +settings.use_default_blue_channel = True diff --git a/release/scripts/presets/tracking_settings/default.py b/release/scripts/presets/tracking_settings/default.py index 3846f92d828..b9fd1928472 100644 --- a/release/scripts/presets/tracking_settings/default.py +++ b/release/scripts/presets/tracking_settings/default.py @@ -9,3 +9,6 @@ settings.default_search_size = 61 settings.default_frames_limit = 0 settings.default_pattern_match = 'KEYFRAME' settings.default_margin = 0 +settings.use_default_red_channel = True +settings.use_default_green_channel = True +settings.use_default_blue_channel = True diff --git a/release/scripts/presets/tracking_settings/fast_motion.py b/release/scripts/presets/tracking_settings/fast_motion.py index f99fd7f0c42..dce3304eddb 100644 --- a/release/scripts/presets/tracking_settings/fast_motion.py +++ b/release/scripts/presets/tracking_settings/fast_motion.py @@ -9,3 +9,6 @@ settings.default_search_size = 300 settings.default_frames_limit = 0 settings.default_pattern_match = 'PREV_FRAME' settings.default_margin = 5 +settings.use_default_red_channel = True +settings.use_default_green_channel = True +settings.use_default_blue_channel = True diff --git a/release/scripts/startup/bl_operators/clip.py b/release/scripts/startup/bl_operators/clip.py index c5ea8176691..787f3be4e76 100644 --- a/release/scripts/startup/bl_operators/clip.py +++ b/release/scripts/startup/bl_operators/clip.py @@ -113,6 +113,9 @@ def CLIP_default_settings_from_track(clip, track): settings.default_frames_limit = track.frames_limit settings.default_pattern_match = track.pattern_match settings.default_margin = track.margin + settings.use_default_red_channel = track.use_red_channel + settings.use_default_green_channel = track.use_green_channel + settings.use_default_blue_channel = track.use_blue_channel class CLIP_OT_track_to_empty(Operator): diff --git a/release/scripts/startup/bl_operators/presets.py b/release/scripts/startup/bl_operators/presets.py index 0ba19ad8109..1aecfbbaa77 100644 --- a/release/scripts/startup/bl_operators/presets.py +++ b/release/scripts/startup/bl_operators/presets.py @@ -409,7 +409,10 @@ class AddPresetTrackingSettings(AddPresetBase, Operator): "settings.default_search_size", "settings.default_frames_limit", "settings.default_pattern_match", - "settings.default_margin" + "settings.default_margin", + "settings.use_default_red_channel", + "settings.use_default_green_channel", + "settings.use_default_blue_channel" ] preset_subdir = "tracking_settings" diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py index 7c2e1a2007c..e7ccc1e624e 100644 --- a/release/scripts/startup/bl_ui/space_clip.py +++ b/release/scripts/startup/bl_ui/space_clip.py @@ -127,6 +127,13 @@ class CLIP_PT_tools_marker(Panel): col.separator() + row = col.row(align=True) + row.prop(settings, "use_default_red_channel", text="R", toggle=True) + row.prop(settings, "use_default_green_channel", text="G", toggle=True) + row.prop(settings, "use_default_blue_channel", text="B", toggle=True) + + col.separator() + sub = col.column(align=True) sub.prop(settings, "default_pattern_size") sub.prop(settings, "default_search_size") diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index ea3f076523f..9bff5e3003d 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -242,6 +242,7 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, ListBase *tr track->margin= settings->default_margin; track->pattern_match= settings->default_pattern_match; track->frames_limit= settings->default_frames_limit; + track->flag= settings->default_flag; memset(&marker, 0, sizeof(marker)); marker.pos[0]= x; diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h index 6ab8b5524ff..1b41131c07d 100644 --- a/source/blender/makesdna/DNA_tracking_types.h +++ b/source/blender/makesdna/DNA_tracking_types.h @@ -121,6 +121,9 @@ typedef struct MovieTrackingSettings { short default_frames_limit; /* number of frames to be tarcked during single tracking session (if TRACKING_FRAMES_LIMIT is set) */ short default_margin; /* margin from frame boundaries */ short default_pattern_match; /* re-adjust every N frames */ + short default_flag; /* default flags like color channels used by default */ + + short pod; /* ** common tracker settings ** */ short speed; /* speed of tracking */ @@ -129,7 +132,7 @@ typedef struct MovieTrackingSettings { int keyframe1, keyframe2; /* two keyframes for reconstrution initialization */ /* ** which camera intrinsics to refine. uses on the REFINE_* flags */ - short refine_camera_intrinsics, pad2; + short refine_camera_intrinsics, pad23; /* ** tool settings ** */ @@ -142,6 +145,8 @@ typedef struct MovieTrackingSettings { /* set object scale */ float object_distance; /* distance between two bundles used for object scaling */ + + int pad3; } MovieTrackingSettings; typedef struct MovieTrackingStabilization { diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index 5573ceccf8f..993c0ca0bde 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -639,6 +639,26 @@ static void rna_def_trackingSettings(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_tracking_defaultSettings_searchUpdate"); RNA_def_property_ui_text(prop, "Search Size", "Size of search area for newly created tracks"); + /* use_red_channel */ + prop= RNA_def_property(srna, "use_default_red_channel", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "default_flag", TRACK_DISABLE_RED); + RNA_def_property_ui_text(prop, "Use Red Channel", "Use red channel from footage for tracking"); + RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL); + + /* use_green_channel */ + prop= RNA_def_property(srna, "use_default_green_channel", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "default_flag", TRACK_DISABLE_GREEN); + RNA_def_property_ui_text(prop, "Use Green Channel", "Use green channel from footage for tracking"); + RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL); + + /* use_blue_channel */ + prop= RNA_def_property(srna, "use_default_blue_channel", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "default_flag", TRACK_DISABLE_BLUE); + RNA_def_property_ui_text(prop, "Use Blue Channel", "Use blue channel from footage for tracking"); + RNA_def_property_update(prop, NC_MOVIECLIP|ND_DISPLAY, NULL); + + /* ** object tracking ** */ + /* object distance */ prop= RNA_def_property(srna, "object_distance", PROP_FLOAT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); From de5d5ded7bf34f6f28027f173f781f058287f058 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 Jan 2012 15:37:33 +0000 Subject: [PATCH 090/105] Cycles: fixes for OpenCL build after pass changes, patch by Daniel Genrich. --- intern/cycles/kernel/kernel_film.h | 2 +- intern/cycles/kernel/kernel_passes.h | 6 +++--- intern/cycles/kernel/kernel_path.h | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/intern/cycles/kernel/kernel_film.h b/intern/cycles/kernel/kernel_film.h index d0fb5402291..232049fb6cb 100644 --- a/intern/cycles/kernel/kernel_film.h +++ b/intern/cycles/kernel/kernel_film.h @@ -59,7 +59,7 @@ __device void kernel_film_tonemap(KernelGlobals *kg, buffer += index*kernel_data.film.pass_stride; /* map colors */ - float4 irradiance = *(float4*)buffer; + float4 irradiance = *((__global float4*)buffer); float4 float_result = film_map(kg, irradiance, sample); uchar4 byte_result = film_float_to_byte(float_result); diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index 9a568229b17..cfd73c98bad 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -20,19 +20,19 @@ CCL_NAMESPACE_BEGIN __device_inline void kernel_write_pass_float(__global float *buffer, int sample, float value) { - float *buf = buffer; + __global float *buf = buffer; *buf = (sample == 0)? value: *buf + value; } __device_inline void kernel_write_pass_float3(__global float *buffer, int sample, float3 value) { - float3 *buf = (float3*)buffer; + __global float3 *buf = (__global float3*)buffer; *buf = (sample == 0)? value: *buf + value; } __device_inline void kernel_write_pass_float4(__global float *buffer, int sample, float4 value) { - float4 *buf = (float4*)buffer; + __global float4 *buf = (__global float4*)buffer; *buf = (sample == 0)? value: *buf + value; } diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index aad7050ed1b..1a42cf1ed7e 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -220,7 +220,7 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R path_radiance_init(&L, kernel_data.film.use_light_pass); -#ifdef __EMISSION__ +#if defined(__EMISSION__) || defined(__BACKGROUND__) float ray_pdf = 0.0f; #endif PathState state; @@ -239,11 +239,13 @@ __device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample, R if(kernel_data.background.transparent && (state.flag & PATH_RAY_CAMERA)) { L_transparent += average(throughput); } +#ifdef __BACKGROUND__ else { /* sample background shader */ float3 L_background = indirect_background(kg, &ray, state.flag, ray_pdf); path_radiance_accum_background(&L, throughput, L_background, state.bounce); } +#endif break; } From 5d49eff25a7e9425def74b175836ea6302113d90 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 26 Jan 2012 17:03:30 +0000 Subject: [PATCH 091/105] Fix #29957: Texture "Generate" mapping work as global with cloth modifier Make Cloth modifier deformation only so now it applies on orco dm properly. --- source/blender/blenkernel/BKE_cloth.h | 2 +- source/blender/blenkernel/intern/cloth.c | 52 +++++++------------ .../blenkernel/intern/particle_system.c | 11 +++- source/blender/modifiers/intern/MOD_cloth.c | 32 ++++++------ 4 files changed, 47 insertions(+), 50 deletions(-) diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 62c3df7c6f4..6d42b8dc80b 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -216,7 +216,7 @@ void clmdSetInterruptCallBack ( int ( *f ) ( void ) ); void cloth_free_modifier_extern ( struct ClothModifierData *clmd ); void cloth_free_modifier ( struct ClothModifierData *clmd ); void cloth_init ( struct ClothModifierData *clmd ); -struct DerivedMesh *clothModifier_do ( struct ClothModifierData *clmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm); +void clothModifier_do ( struct ClothModifierData *clmd, struct Scene *scene, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3]); void cloth_update_normals ( ClothVertex *verts, int nVerts, struct MFace *face, int totface ); int cloth_uses_vgroup(struct ClothModifierData *clmd); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 33adc2af284..d86fc5c9aef 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -90,7 +90,7 @@ static CM_SOLVER_DEF solvers [] = /* ********** cloth engine ******* */ /* Prototypes for internal functions. */ -static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *dm); +static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*vertexCos)[3]); static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ); static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float framenr, int first); static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ); @@ -429,9 +429,8 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul /************************************************ * clothModifier_do - main simulation function ************************************************/ -DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm) +void clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3]) { - DerivedMesh *result; PointCache *cache; PTCacheID pid; float timescale; @@ -441,20 +440,14 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, clmd->scene= scene; /* nice to pass on later :) */ framenr= (int)scene->r.cfra; cache= clmd->point_cache; - result = CDDM_copy(dm); BKE_ptcache_id_from_cloth(&pid, ob, clmd); BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale); clmd->sim_parms->timescale= timescale; - if(!result) { - BKE_ptcache_invalidate(cache); - return dm; - } - if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0) - || (clmd->clothObject && result->getNumVerts(result) != clmd->clothObject->numverts)) + || (clmd->clothObject && dm->getNumVerts(dm) != clmd->clothObject->numverts)) { clmd->sim_parms->reset = 0; cache->flag |= PTCACHE_OUTDATED; @@ -462,7 +455,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, BKE_ptcache_validate(cache, 0); cache->last_exact= 0; cache->flag &= ~PTCACHE_REDO_NEEDED; - return result; + return; } // unused in the moment, calculated separately in implicit.c @@ -474,20 +467,20 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, /* do simulation */ if(!do_init_cloth(ob, clmd, dm, framenr)) - return result; + return; do_step_cloth(ob, clmd, dm, framenr); - cloth_to_object(ob, clmd, result); + cloth_to_object(ob, clmd, vertexCos); clmd->clothObject->last_frame= framenr; - return result; + return; } /* simulation is only active during a specific period */ if(framenr < startframe) { BKE_ptcache_invalidate(cache); - return result; + return; } else if(framenr > endframe) { framenr= endframe; @@ -495,7 +488,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, /* initialize simulation data if it didn't exist already */ if(!do_init_cloth(ob, clmd, dm, framenr)) - return result; + return; if((framenr == startframe) && (clmd->sim_parms->preroll == 0)) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); @@ -503,7 +496,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, BKE_ptcache_validate(cache, framenr); cache->flag &= ~PTCACHE_REDO_NEEDED; clmd->clothObject->last_frame= framenr; - return result; + return; } /* try to read from cache */ @@ -511,7 +504,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { implicit_set_positions(clmd); - cloth_to_object (ob, clmd, result); + cloth_to_object (ob, clmd, vertexCos); BKE_ptcache_validate(cache, framenr); @@ -520,7 +513,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, clmd->clothObject->last_frame= framenr; - return result; + return; } else if(cache_result==PTCACHE_READ_OLD) { implicit_set_positions(clmd); @@ -528,11 +521,11 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, else if( /*ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED)) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */ /* if baked and nothing in cache, do nothing */ BKE_ptcache_invalidate(cache); - return result; + return; } if(framenr!=clmd->clothObject->last_frame+1) - return result; + return; /* if on second frame, write cache for first frame */ if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) @@ -549,10 +542,8 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, else BKE_ptcache_write(&pid, framenr); - cloth_to_object (ob, clmd, result); + cloth_to_object (ob, clmd, vertexCos); clmd->clothObject->last_frame= framenr; - - return result; } /* frees all */ @@ -707,24 +698,19 @@ void cloth_free_modifier_extern ( ClothModifierData *clmd ) * cloth_to_object - copies the deformed vertices to the object. * **/ -static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *dm) +static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*vertexCos)[3]) { unsigned int i = 0; - MVert *mvert = NULL; - unsigned int numverts; Cloth *cloth = clmd->clothObject; if (clmd->clothObject) { /* inverse matrix is not uptodate... */ invert_m4_m4(ob->imat, ob->obmat); - mvert = CDDM_get_verts(dm); - numverts = dm->getNumVerts(dm); - - for (i = 0; i < numverts; i++) + for (i = 0; i < cloth->numverts; i++) { - copy_v3_v3 (mvert[i].co, cloth->verts[i].x); - mul_m4_v3(ob->imat, mvert[i].co); /* cloth is in global coords */ + copy_v3_v3 (vertexCos[i], cloth->verts[i].x); + mul_m4_v3(ob->imat, vertexCos[i]); /* cloth is in global coords */ } } } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 5bb0ffbb76a..5a64da7354e 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3480,6 +3480,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) int totedge; int k; float hairmat[4][4]; + float (*deformedVerts)[3]; if(!psys->clmd) { psys->clmd = (ClothModifierData*)modifier_new(eModifierType_Cloth); @@ -3573,7 +3574,15 @@ static void do_hair_dynamics(ParticleSimulationData *sim) psys->clmd->point_cache = psys->pointcache; psys->clmd->sim_parms->effector_weights = psys->part->effector_weights; - psys->hair_out_dm = clothModifier_do(psys->clmd, sim->scene, sim->ob, dm); + deformedVerts = MEM_callocN(sizeof(*deformedVerts)*dm->getNumVerts(dm), "do_hair_dynamics vertexCos"); + psys->hair_out_dm = CDDM_copy(dm); + psys->hair_out_dm->getVertCos(psys->hair_out_dm, deformedVerts); + + clothModifier_do(psys->clmd, sim->scene, sim->ob, dm, deformedVerts); + + CDDM_apply_vert_coords(psys->hair_out_dm, deformedVerts); + + MEM_freeN(deformedVerts); psys->clmd->sim_parms->effector_weights = NULL; } diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 6c9bbd11e9c..7e46d3f0fe3 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -67,11 +67,10 @@ static void initData(ModifierData *md) cloth_init (clmd); } -static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) +static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], + int UNUSED(numVerts), int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { + DerivedMesh *dm; ClothModifierData *clmd = (ClothModifierData*) md; DerivedMesh *result=NULL; @@ -79,19 +78,22 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if(!clmd->sim_parms || !clmd->coll_parms) { initData(md); - + if(!clmd->sim_parms || !clmd->coll_parms) - return dm; + return; } - result = clothModifier_do(clmd, md->scene, ob, dm); + dm = get_dm(ob, NULL, derivedData, NULL, 0); - if(result) - { - CDDM_calc_normals(result); - return result; + clothModifier_do(clmd, md->scene, ob, dm, vertexCos); + + if(result) { + result->getVertCos(result, vertexCos); + result->release(result); } - return dm; + + if(dm != derivedData) + dm->release(dm); } static void updateDepgraph( @@ -206,17 +208,17 @@ ModifierTypeInfo modifierType_Cloth = { /* name */ "Cloth", /* structName */ "ClothModifierData", /* structSize */ sizeof(ClothModifierData), - /* type */ eModifierTypeType_Nonconstructive, + /* type */ eModifierTypeType_OnlyDeform, /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_UsesPointCache | eModifierTypeFlag_Single, /* copyData */ copyData, - /* deformVerts */ NULL, + /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, + /* applyModifier */ NULL, /* applyModifierEM */ NULL, /* initData */ initData, /* requiredDataMask */ requiredDataMask, From 4514a4455be89bc0a789d78355321abe6cfd5112 Mon Sep 17 00:00:00 2001 From: "Sv. Lockal" Date: Thu, 26 Jan 2012 17:11:43 +0000 Subject: [PATCH 092/105] Fix orthogonality check for mat3 and mat4 --- source/blender/blenlib/intern/math_matrix.c | 42 ++++++++++++--------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index cd54c944ba9..0c8c98988d1 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -778,32 +778,38 @@ void orthogonalize_m4(float mat[][4], int axis) mul_v3_fl(mat[2], size[2]); } -int is_orthogonal_m3(float mat[][3]) +int is_orthogonal_m3(float m[][3]) { - if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON) - return 0; + int i, j; - if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON) - return 0; + for (i = 0; i < 3; i++) { + for (j = 0; j < i; j++) { + if (fabsf(dot_v3v3(m[i], m[j])) > 1.5f * FLT_EPSILON) + return 0; + } - if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON) - return 0; - - return 1; + if (fabsf(dot_v3v3(m[i], m[i]) - 1) > 1.5f * FLT_EPSILON) + return 0; + } + + return 1; } -int is_orthogonal_m4(float mat[][4]) +int is_orthogonal_m4(float m[][4]) { - if (fabsf(dot_v3v3(mat[0], mat[1])) > 1.5f * FLT_EPSILON) - return 0; + int i, j; - if (fabsf(dot_v3v3(mat[1], mat[2])) > 1.5f * FLT_EPSILON) - return 0; + for (i = 0; i < 4; i++) { + for (j = 0; j < i; j++) { + if (fabsf(dot_vn_vn(m[i], m[j], 4)) > 1.5f * FLT_EPSILON) + return 0; + } - if (fabsf(dot_v3v3(mat[0], mat[2])) > 1.5f * FLT_EPSILON) - return 0; - - return 1; + if (fabsf(dot_vn_vn(m[i], m[i], 4) - 1) > 1.5f * FLT_EPSILON) + return 0; + } + + return 1; } void normalize_m3(float mat[][3]) From 803286dde8dd9594a6a8c9e1ed154863934da295 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 Jan 2012 19:07:01 +0000 Subject: [PATCH 093/105] Cycles: render passes for CUDA cards with compute model >= 2.x. --- intern/cycles/blender/blender_session.cpp | 2 +- intern/cycles/device/device.cpp | 3 ++ intern/cycles/device/device.h | 6 +-- intern/cycles/device/device_cpu.cpp | 8 +--- intern/cycles/device/device_cuda.cpp | 24 ++---------- intern/cycles/device/device_multi.cpp | 46 ++--------------------- intern/cycles/device/device_network.cpp | 18 --------- intern/cycles/device/device_opencl.cpp | 15 +------- intern/cycles/kernel/kernel_passes.h | 4 +- intern/cycles/kernel/kernel_types.h | 6 +-- intern/cycles/render/buffers.cpp | 2 +- intern/cycles/render/svm.cpp | 2 +- 12 files changed, 25 insertions(+), 111 deletions(-) diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 5e3102fd7c7..d9adc5480dc 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -206,7 +206,7 @@ void BlenderSession::render() vector passes; Pass::add(PASS_COMBINED, passes); - if(session_params.device.type == DEVICE_CPU) { /* todo */ + if(session_params.device.advanced_shading) { BL::RenderLayer::passes_iterator b_pass_iter; for(b_rlay.passes.begin(b_pass_iter); b_pass_iter != b_rlay.passes.end(); ++b_pass_iter) { diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index e4beb4d7d8c..cceec8b8e5c 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -183,6 +183,9 @@ Device *Device::create(DeviceInfo& info, bool background, int threads) return NULL; } + if(device) + device->info = info; + return device; } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index b8fea4c4c69..af2567498d9 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -51,6 +51,7 @@ public: string id; int num; bool display_device; + bool advanced_shading; vector multi_devices; DeviceInfo() @@ -59,6 +60,7 @@ public: id = "CPU"; num = 0; display_device = false; + advanced_shading = true; } }; @@ -101,10 +103,8 @@ protected: public: virtual ~Device() {} - virtual bool support_full_kernel() = 0; - /* info */ - virtual string description() = 0; + DeviceInfo info; virtual const string& error_message() { return error_msg; } /* regular memory */ diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 2ca599f6c67..da977ed8472 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -72,16 +72,11 @@ public: kernel_globals_free(kg); } - bool support_full_kernel() + bool support_advanced_shading() { return true; } - string description() - { - return system_cpu_brand_string(); - } - void mem_alloc(device_memory& mem, MemoryType type) { mem.device_pointer = mem.data_pointer; @@ -271,6 +266,7 @@ void device_cpu_info(vector& devices) info.description = system_cpu_brand_string(); info.id = "CPU"; info.num = 0; + info.advanced_shading = true; devices.insert(devices.begin(), info); } diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 55b467fc856..14bcaa94130 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -194,26 +194,6 @@ public: cuda_assert(cuCtxDetach(cuContext)) } - bool support_full_kernel() - { - int major, minor; - cuDeviceComputeCapability(&major, &minor, cuDevId); - - return (major >= 2); - } - - string description() - { - /* print device information */ - char deviceName[256]; - - cuda_push_context(); - cuDeviceGetName(deviceName, 256, cuDevId); - cuda_pop_context(); - - return string("CUDA ") + deviceName; - } - bool support_device(bool experimental) { if(!experimental) { @@ -881,6 +861,10 @@ void device_cuda_info(vector& devices) info.id = string_printf("CUDA_%d", num); info.num = num; + int major, minor; + cuDeviceComputeCapability(&major, &minor, num); + info.advanced_shading = (major >= 2); + /* if device has a kernel timeout, assume it is used for display */ if(cuDeviceGetAttribute(&attr, CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT, num) == CUDA_SUCCESS && attr == 1) { info.display_device = true; diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index 41d0e268526..375719133b8 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -76,16 +76,6 @@ public: delete sub.device; } - bool support_full_kernel() - { - foreach(SubDevice& sub, devices) { - if(!sub.device->support_full_kernel()) - return false; - } - - return true; - } - const string& error_message() { foreach(SubDevice& sub, devices) { @@ -99,38 +89,6 @@ public: return error_msg; } - string description() - { - /* create map to find duplicate descriptions */ - map dupli_map; - map::iterator dt; - - foreach(SubDevice& sub, devices) { - string key = sub.device->description(); - - if(dupli_map.find(key) == dupli_map.end()) - dupli_map[key] = 1; - else - dupli_map[key]++; - } - - /* generate string */ - stringstream desc; - bool first = true; - - for(dt = dupli_map.begin(); dt != dupli_map.end(); dt++) { - if(!first) desc << ", "; - first = false; - - if(dt->second > 1) - desc << dt->second << "x " << dt->first; - else - desc << dt->first; - } - - return desc.str(); - } - bool load_kernels(bool experimental) { foreach(SubDevice& sub, devices) @@ -344,6 +302,8 @@ static void device_multi_add(vector& devices, DeviceType type, bool map::iterator dt; int num_added = 0, num_display = 0; + info.advanced_shading = true; + foreach(DeviceInfo& subinfo, devices) { if(subinfo.type == type) { if(subinfo.display_device) { @@ -363,6 +323,8 @@ static void device_multi_add(vector& devices, DeviceType type, bool info.multi_devices.push_back(subinfo); if(subinfo.display_device) info.display_device = true; + if(!subinfo.advanced_shading) + info.advanced_shading = false; num_added++; } } diff --git a/intern/cycles/device/device_network.cpp b/intern/cycles/device/device_network.cpp index 14518b1507e..931890b5859 100644 --- a/intern/cycles/device/device_network.cpp +++ b/intern/cycles/device/device_network.cpp @@ -57,24 +57,6 @@ public: { } - bool support_full_kernel() - { - return false; - } - - string description() - { - RPCSend snd(socket, "description"); - snd.write(); - - RPCReceive rcv(socket); - string desc_string; - - *rcv.archive & desc_string; - - return desc_string + " (remote)"; - } - void mem_alloc(device_memory& mem, MemoryType type) { #if 0 diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index ccfd8544362..9a55f957895 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -453,20 +453,6 @@ public: clReleaseContext(cxContext); } - bool support_full_kernel() - { - return false; - } - - string description() - { - char name[1024]; - - clGetDeviceInfo(cdDevice, CL_DEVICE_NAME, sizeof(name), &name, NULL); - - return string("OpenCL ") + name; - } - void mem_alloc(device_memory& mem, MemoryType type) { size_t size = mem.memory_size(); @@ -750,6 +736,7 @@ void device_opencl_info(vector& devices) info.num = num; /* we don't know if it's used for display, but assume it is */ info.display_device = true; + info.advanced_shading = false; devices.push_back(info); } diff --git a/intern/cycles/kernel/kernel_passes.h b/intern/cycles/kernel/kernel_passes.h index cfd73c98bad..a1b3b0e9038 100644 --- a/intern/cycles/kernel/kernel_passes.h +++ b/intern/cycles/kernel/kernel_passes.h @@ -36,7 +36,7 @@ __device_inline void kernel_write_pass_float4(__global float *buffer, int sample *buf = (sample == 0)? value: *buf + value; } -__device void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, +__device_inline void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, ShaderData *sd, int sample, int path_flag, float3 throughput) { #ifdef __PASSES__ @@ -86,7 +86,7 @@ __device void kernel_write_data_passes(KernelGlobals *kg, __global float *buffer #endif } -__device void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample) +__device_inline void kernel_write_light_passes(KernelGlobals *kg, __global float *buffer, PathRadiance *L, int sample) { #ifdef __PASSES__ int flag = kernel_data.film.pass_flag; diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index b4b1da83162..9ebe4120e36 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -185,6 +185,9 @@ typedef float3 PathThroughput; struct PathRadiance { int use_light_pass; + float3 emission; + float3 background; + float3 indirect; float3 direct_throughput; float3 direct_emission; @@ -200,9 +203,6 @@ struct PathRadiance { float3 indirect_diffuse; float3 indirect_glossy; float3 indirect_transmission; - - float3 emission; - float3 background; }; struct BsdfEval { diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 56219482ef0..361ead3cd24 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -130,7 +130,7 @@ bool RenderBuffers::copy_from_device() if(!buffer.device_pointer) return false; - device->mem_copy_from(buffer, 0, params.width, params.height, sizeof(float4)); + device->mem_copy_from(buffer, 0, params.width, params.height, params.get_passes_size()*sizeof(float)); return true; } diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index f088a8143cc..ae666ddfe68 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -58,7 +58,7 @@ void SVMShaderManager::device_update(Device *device, DeviceScene *dscene, Scene } bool sunsky_done = false; - bool use_multi_closure = device->support_full_kernel(); + bool use_multi_closure = device->info.advanced_shading; for(i = 0; i < scene->shaders.size(); i++) { Shader *shader = scene->shaders[i]; From 4fe00cd4f9ca5b0521c60c70b55032472700b0c5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 26 Jan 2012 19:45:59 +0000 Subject: [PATCH 094/105] Cycles: disable environment importance sampling code for CUDA cards with compute model < 2.x, to avoid running out of memory in the compiler. --- intern/cycles/kernel/kernel_emission.h | 7 ++++++- intern/cycles/kernel/kernel_light.h | 2 ++ intern/cycles/kernel/kernel_shader.h | 1 - intern/cycles/kernel/kernel_types.h | 3 +-- intern/cycles/render/light.cpp | 10 ++++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index b3a5b2bfcb4..513a453b585 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -27,6 +27,7 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando, ShaderData sd; float3 eval; +#ifdef __BACKGROUND_MIS__ if(ls->type == LIGHT_BACKGROUND) { Ray ray; ray.D = ls->D; @@ -36,7 +37,9 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando, shader_setup_from_background(kg, &sd, &ray); eval = shader_eval_background(kg, &sd, 0); } - else { + else +#endif + { shader_setup_from_sample(kg, &sd, ls->P, ls->Ng, I, ls->shader, ls->object, ls->prim, u, v); ls->Ng = sd.Ng; @@ -164,6 +167,7 @@ __device float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float3 L = shader_eval_background(kg, &sd, path_flag); shader_release(kg, &sd); +#ifdef __BACKGROUND_MIS__ /* check if background light exists or if we should skip pdf */ int res = kernel_data.integrator.pdf_background_res; @@ -175,6 +179,7 @@ __device float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, return L*mis_weight; } +#endif return L; #else diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h index 4c2b69c2716..aa125180a94 100644 --- a/intern/cycles/kernel/kernel_light.h +++ b/intern/cycles/kernel/kernel_light.h @@ -192,6 +192,7 @@ __device void regular_light_sample(KernelGlobals *kg, int point, ls->D = -D; ls->t = FLT_MAX; } +#ifdef __BACKGROUND_MIS__ else if(type == LIGHT_BACKGROUND) { /* infinite area light (e.g. light dome or env light) */ float3 D = background_light_sample(kg, randu, randv, pdf); @@ -201,6 +202,7 @@ __device void regular_light_sample(KernelGlobals *kg, int point, ls->D = -D; ls->t = FLT_MAX; } +#endif else { ls->P = make_float3(data0.y, data0.z, data0.w); diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 1d2cf46aa56..0f04af1275d 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -26,7 +26,6 @@ * */ - #ifdef __OSL__ #include "osl_shader.h" diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 9ebe4120e36..477b08f2f87 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -70,9 +70,8 @@ CCL_NAMESPACE_BEGIN #ifdef __KERNEL_ADV_SHADING__ #define __MULTI_CLOSURE__ #define __TRANSPARENT_SHADOWS__ -#ifdef __KERNEL_CPU__ #define __PASSES__ -#endif +#define __BACKGROUND_MIS__ #endif //#define __MULTI_LIGHT__ diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 777e764558f..405aa800457 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -402,6 +402,16 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce float4 *light_data = dscene->light_data.resize(scene->lights.size()*LIGHT_SIZE); + if(!device->info.advanced_shading) { + /* remove unsupported light */ + foreach(Light *light, scene->lights) { + if(light->type == LIGHT_BACKGROUND) { + scene->lights.erase(std::remove(scene->lights.begin(), scene->lights.end(), light), scene->lights.end()); + break; + } + } + } + for(size_t i = 0; i < scene->lights.size(); i++) { Light *light = scene->lights[i]; float3 co = light->co; From 0c7a455c074304c7882ea6aca63dee22ef620dec Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 27 Jan 2012 01:30:58 +0000 Subject: [PATCH 095/105] Action Constraint GUI - Refinements and Clarification While looking at a bug report, I found that the current GUI for the Action Constraint actually didn't make sense, mixing up settings so that it wasn't clear which settings corresponded to which others. This commit cleans up the layout into a clearer two-column design to have a "from" -> "to" layout, making all the relationships between things clear. For more details see http://aligorith.blogspot.com/2012/01/action-constraint- gui-revised.html --- .../bl_ui/properties_object_constraint.py | 31 ++++++++++--------- .../blender/makesrna/intern/rna_constraint.c | 22 ++++++------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/release/scripts/startup/bl_ui/properties_object_constraint.py b/release/scripts/startup/bl_ui/properties_object_constraint.py index 57adfa1fa20..dff23e6238f 100644 --- a/release/scripts/startup/bl_ui/properties_object_constraint.py +++ b/release/scripts/startup/bl_ui/properties_object_constraint.py @@ -434,25 +434,28 @@ class ConstraintButtonsPanel(): def ACTION(self, context, layout, con): self.target_template(layout, con) - layout.prop(con, "action") - - layout.prop(con, "transform_channel") - split = layout.split() - - col = split.column(align=True) - col.label(text="Action Length:") - col.prop(con, "frame_start", text="Start") - col.prop(con, "frame_end", text="End") - + + col = split.column() + col.label(text="From Target:") + col.prop(con, "transform_channel", text="") + col.prop(con, "target_space", text="") + + col = split.column() + col.label(text="To Action:") + col.prop(con, "action", text="") + + split = layout.split() + col = split.column(align=True) col.label(text="Target Range:") col.prop(con, "min", text="Min") col.prop(con, "max", text="Max") - - row = layout.row() - row.label(text="Convert:") - row.prop(con, "target_space", text="") + + col = split.column(align=True) + col.label(text="Action Range:") + col.prop(con, "frame_start", text="Start") + col.prop(con, "frame_end", text="End") def LOCKED_TRACK(self, context, layout, con): self.target_template(layout, con) diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 3258b8c3dcb..e12f411f81f 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1026,15 +1026,15 @@ static void rna_def_constraint_action(BlenderRNA *brna) PropertyRNA *prop; static EnumPropertyItem transform_channel_items[] = { - {20, "LOCATION_X", 0, "Location X", ""}, - {21, "LOCATION_Y", 0, "Location Y", ""}, - {22, "LOCATION_Z", 0, "Location Z", ""}, - {00, "ROTATION_X", 0, "Rotation X", ""}, - {01, "ROTATION_Y", 0, "Rotation Y", ""}, - {02, "ROTATION_Z", 0, "Rotation Z", ""}, - {10, "SCALE_X", 0, "Scale X", ""}, - {11, "SCALE_Y", 0, "Scale Y", ""}, - {12, "SCALE_Z", 0, "Scale Z", ""}, + {20, "LOCATION_X", 0, "X Location", ""}, + {21, "LOCATION_Y", 0, "Y Location", ""}, + {22, "LOCATION_Z", 0, "Z Location", ""}, + {00, "ROTATION_X", 0, "X Rotation", ""}, + {01, "ROTATION_Y", 0, "Y Rotation", ""}, + {02, "ROTATION_Z", 0, "Z Rotation", ""}, + {10, "SCALE_X", 0, "Z Scale", ""}, + {11, "SCALE_Y", 0, "Y Scale", ""}, + {12, "SCALE_Z", 0, "Z Scale", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "ActionConstraint", "Constraint"); @@ -2011,12 +2011,12 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "chainlen"); RNA_def_property_range(prop, 1, 255); // TODO: this should really check the max length of the chain the constraint is attached to RNA_def_property_ui_text(prop, "Chain Length", "How many bones are included in the chain"); - RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); + RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update"); // XXX: this update goes wrong... needs extra flush? /* direct access to bindings */ // NOTE: only to be used by experienced users prop= RNA_def_property(srna, "joint_bindings", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_array(prop, 32); // XXX this is the maximum value allowed + RNA_def_property_array(prop, 32); // XXX this is the maximum value allowed - why? RNA_def_property_flag(prop, PROP_DYNAMIC); RNA_def_property_dynamic_array_funcs(prop, "rna_SplineIKConstraint_joint_bindings_get_length"); RNA_def_property_float_funcs(prop, "rna_SplineIKConstraint_joint_bindings_get", "rna_SplineIKConstraint_joint_bindings_set", NULL); From 959f2624ca58839ae8cc5ac6e13162759e5dc759 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Fri, 27 Jan 2012 07:35:57 +0000 Subject: [PATCH 096/105] Fix [#29884] Splash screen only displays "r43" Based on patch by perfection cat Removed the unnecessary char * juggling. --- .../blender/windowmanager/intern/wm_operators.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index faf2d3fd352..4052c221935 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1277,22 +1277,17 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar #ifdef WITH_BUILDINFO int ver_width, rev_width; - char *version_str = NULL; - char *revision_str = NULL; char version_buf[128]; char revision_buf[128]; extern char build_rev[]; - version_str = &version_buf[0]; - revision_str = &revision_buf[0]; - - BLI_snprintf(version_str, sizeof(version_str), + BLI_snprintf(version_buf, sizeof(version_buf), "%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); - BLI_snprintf(revision_str, sizeof(revision_str), "r%s", build_rev); + BLI_snprintf(revision_buf, sizeof(revision_buf), "r%s", build_rev); BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi); - ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_str) + 5; - rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_str) + 5; + ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 5; + rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 5; #endif //WITH_BUILDINFO block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); @@ -1303,8 +1298,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL); #ifdef WITH_BUILDINFO - uiDefBut(block, LABEL, 0, version_str, 494-ver_width, 282-24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); - uiDefBut(block, LABEL, 0, revision_str, 494-rev_width, 282-36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + uiDefBut(block, LABEL, 0, version_buf, 494-ver_width, 282-24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); + uiDefBut(block, LABEL, 0, revision_buf, 494-rev_width, 282-36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); #endif //WITH_BUILDINFO layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, 480, 110, style); From b35446c3fa84ec0b817be1aaf356c3e3a5071285 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Jan 2012 08:04:03 +0000 Subject: [PATCH 097/105] Fix #30000: Boolean modifier messing up multi material Issue was caused by resetting face's mat_nr to zero if there's no material map sent to ConvertCSGDescriptorsToDerivedMesh. In case of boolean modifier we can't use such map because we can't affect on materials present in object. So the only way which can give reasonable result is: - Dot change mat_nr for faces from left operand (they should be fine, because materials aren't deleting by modifier) - For faces from right operand check if needed material exists in left operand and if so, use it's index as new mat_nr. - If there are materials in right operand which doesn't exist in left operand, they'll be changed to first material from left operand. --- .../modifiers/intern/MOD_boolean_util.c | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index f6a2e4451b2..4b380efa95b 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -374,10 +374,10 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( } // a hash table to remap materials to indices - if (mat) { - material_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "CSG_mat gh"); + material_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "CSG_mat gh"); + + if (mat) *totmat = 0; - } origindex_layer = result->getFaceDataArray(result, CD_ORIGINDEX); @@ -422,6 +422,32 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( else mface->mat_nr = GET_INT_FROM_POINTER(BLI_ghash_lookup(material_hash, orig_mat)); } + else if(orig_mat) { + if(orig_ob == ob1) { + // No need to change materian index for faces from left operand + } + else { + // for faces from right operand checn if there's needed material in left operand and if it is, + // use index of that material, otherwise fallback to first material (material with index=0) + if (!BLI_ghash_haskey(material_hash, orig_mat)) { + int a; + + mat_nr = 0; + for(a = 0; a < ob1->totcol; a++) { + if(give_current_material(ob1, a+1) == orig_mat) { + mat_nr = a; + break; + } + } + + BLI_ghash_insert(material_hash, orig_mat, SET_INT_IN_POINTER(mat_nr)); + + mface->mat_nr = mat_nr; + } + else + mface->mat_nr = GET_INT_FROM_POINTER(BLI_ghash_lookup(material_hash, orig_mat)); + } + } else mface->mat_nr = 0; From 82300fabb9cc0d55c3044fc1cf039025bd39129a Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 27 Jan 2012 08:15:30 +0000 Subject: [PATCH 098/105] Minor fix for CD_TYPE_AS_MASK macro: shift operator uses the left operand's type for the result, so cast 1 to CustomDataMask. --- source/blender/blenkernel/BKE_customdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 1af2f014ef4..7ad25ac7e79 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -67,7 +67,7 @@ extern const CustomDataMask CD_MASK_FACECORNERS; #define CD_DUPLICATE 4 /* do a full copy of all layers, only allowed if source has same number of elements */ -#define CD_TYPE_AS_MASK(_type) (CustomDataMask)(1 << (CustomDataMask)(_type)) +#define CD_TYPE_AS_MASK(_type) (CustomDataMask)((CustomDataMask)1 << (CustomDataMask)(_type)) /* initialises a CustomData object with the same layer setup as source. * mask is a bitfield where (mask & (1 << (layer type))) indicates From 3062798de3a34d461578da4bd9d8d4f700f70ddb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Jan 2012 08:17:53 +0000 Subject: [PATCH 099/105] Fixed some possible issues and access non-initialized variable in Carve BOP interface. Discovered when was investigating some crashes caused by Carve's triangulator. --- intern/boolop/intern/BOP_CarveInterface.cpp | 28 +++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/intern/boolop/intern/BOP_CarveInterface.cpp b/intern/boolop/intern/BOP_CarveInterface.cpp index 274d9cac0cf..5a847ff26d4 100644 --- a/intern/boolop/intern/BOP_CarveInterface.cpp +++ b/intern/boolop/intern/BOP_CarveInterface.cpp @@ -150,12 +150,19 @@ static MeshSet<3> *Carve_unionIntersectingMeshes(MeshSet<3> *poly, MeshSet<3> *right = Carve_getIntersectedOperand(orig_meshes, precomputedAABB, otherAABB); try { - MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE); + if(left->meshes.size()==0) { + delete left; - delete left; - delete right; + left = right; + } + else { + MeshSet<3> *result = csg.compute(left, right, carve::csg::CSG::UNION, NULL, carve::csg::CSG::CLASSIFY_EDGE); - left = result; + delete left; + delete right; + + left = result; + } } catch(carve::exception e) { std::cerr << "CSG failed, exception " << e.str() << std::endl; @@ -492,7 +499,7 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType, CSG_VertexIteratorDescriptor obBVertices) { carve::csg::CSG::OP op; - MeshSet<3> *left, *right, *output; + MeshSet<3> *left, *right, *output = NULL; carve::csg::CSG csg; carve::geom3d::Vector min, max; carve::interpolate::FaceAttr oface_num; @@ -517,6 +524,17 @@ BoolOpState BOP_performBooleanOperation(BoolOpType opType, Carve_prepareOperands(&left, &right, oface_num); + if(left->meshes.size() == 0 || right->meshes.size()==0) { + // normally sohuldn't happen (zero-faces objects are handled by modifier itself), but + // unioning intersecting meshes which doesn't have consistent normals might lead to + // empty result which wouldn't work here + + delete left; + delete right; + + return BOP_ERROR; + } + min.x = max.x = left->vertex_storage[0].v.x; min.y = max.y = left->vertex_storage[0].v.y; min.z = max.z = left->vertex_storage[0].v.z; From b023665551d2059d34ffa45d4234abb3d1c92736 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 27 Jan 2012 13:58:32 +0000 Subject: [PATCH 100/105] Cycles: another fix for CUDA render passes, needed to align float4 passes. --- intern/cycles/device/device_cuda.cpp | 11 +++-------- intern/cycles/render/buffers.cpp | 2 +- intern/cycles/render/film.cpp | 14 ++++++++++++++ intern/cycles/util/util_types.h | 5 +++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 14bcaa94130..0c08baae3ff 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -106,11 +106,6 @@ public: } } - static int cuda_align_up(int& offset, int alignment) - { - return (offset + alignment - 1) & ~(alignment - 1); - } - #ifdef NDEBUG #define cuda_abort() #else @@ -485,7 +480,7 @@ public: offset += sizeof(d_rng_state); int sample = task.sample; - offset = cuda_align_up(offset, __alignof(sample)); + offset = align_up(offset, __alignof(sample)); cuda_assert(cuParamSeti(cuPathTrace, offset, task.sample)) offset += sizeof(task.sample); @@ -549,7 +544,7 @@ public: offset += sizeof(d_buffer); int sample = task.sample; - offset = cuda_align_up(offset, __alignof(sample)); + offset = align_up(offset, __alignof(sample)); cuda_assert(cuParamSeti(cuFilmConvert, offset, task.sample)) offset += sizeof(task.sample); @@ -618,7 +613,7 @@ public: offset += sizeof(d_offset); int shader_eval_type = task.shader_eval_type; - offset = cuda_align_up(offset, __alignof(shader_eval_type)); + offset = align_up(offset, __alignof(shader_eval_type)); cuda_assert(cuParamSeti(cuDisplace, offset, task.shader_eval_type)) offset += sizeof(task.shader_eval_type); diff --git a/intern/cycles/render/buffers.cpp b/intern/cycles/render/buffers.cpp index 361ead3cd24..dd0ebf7195c 100644 --- a/intern/cycles/render/buffers.cpp +++ b/intern/cycles/render/buffers.cpp @@ -71,7 +71,7 @@ int BufferParams::get_passes_size() foreach(Pass& pass, passes) size += pass.components; - return size; + return align_up(size, 4); } /* Render Buffers */ diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index bc51384b873..376e9d6d0ca 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -21,12 +21,20 @@ #include "film.h" #include "scene.h" +#include "util_algorithm.h" #include "util_foreach.h" CCL_NAMESPACE_BEGIN /* Pass */ +static bool compare_pass_order(const Pass& a, const Pass& b) +{ + if(a.components == b.components) + return (a.type < b.type); + return (a.components > b.components); +} + void Pass::add(PassType type, vector& passes) { Pass pass; @@ -106,6 +114,10 @@ void Pass::add(PassType type, vector& passes) } passes.push_back(pass); + + /* order from by components, to ensure alignment so passes with size 4 + come first and then passes with size 1 */ + sort(passes.begin(), passes.end(), compare_pass_order); } bool Pass::equals(const vector& A, const vector& B) @@ -219,6 +231,8 @@ void Film::device_update(Device *device, DeviceScene *dscene) kfilm->pass_stride += pass.components; } + kfilm->pass_stride = align_up(kfilm->pass_stride, 4); + need_update = false; } diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index 2c0ae13ad2a..efdda98571a 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -277,6 +277,11 @@ __device float4 make_float4(float x, float y, float z, float w) return a; } +__device int align_up(int offset, int alignment) +{ + return (offset + alignment - 1) & ~(alignment - 1); +} + #endif CCL_NAMESPACE_END From 6da44f9042afcdb13f0c2b4bb99139629fc40907 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Jan 2012 14:17:59 +0000 Subject: [PATCH 101/105] Always assume isFinalCals is truth when applying constructive modifiers on curves for viewport display. It saves plenty of memory when using subsurf modifier which result is getting converted from CCGDM to CDDM without any benefit. It also syncs behavior of modifiers with mesh. Need to keep an eye on constructive modifiers when in edit mode. Discovered this when was looking into #29973. --- source/blender/blenkernel/intern/displist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 17936a44a73..e0f76917368 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -833,6 +833,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba int editmode = (!forRender && cu->editnurb); DerivedMesh *dm= NULL, *ndm; float (*vertCos)[3] = NULL; + int useCache = !forRender; if(forRender) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; @@ -911,7 +912,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba vertCos= NULL; } - ndm = mti->applyModifier(md, ob, dm, forRender, editmode); + ndm = mti->applyModifier(md, ob, dm, forRender, useCache); if (ndm) { /* Modifier returned a new derived mesh */ From d7b9fdc2f6090696390e3f991090ba3ab60f2ce3 Mon Sep 17 00:00:00 2001 From: Miika Hamalainen Date: Fri, 27 Jan 2012 17:44:56 +0000 Subject: [PATCH 102/105] Dynamic Paint: * Fix: Brush didn't paint particles that were hidden by the display percentage setting. --- source/blender/blenkernel/intern/dynamicpaint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 501b97bd9be..cdfd5d3562b 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3552,7 +3552,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, /* Proceed only if particle is active */ if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0) continue; else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue; - else if(pa->flag & PARS_NO_DISP || pa->flag & PARS_UNEXIST) continue; + else if(pa->flag & PARS_UNEXIST) continue; /* for debug purposes check if any NAN particle proceeds * For some reason they get past activity check, this should rule most of them out */ From 8369706c153cf1fde48de795d519617382ed7e67 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 28 Jan 2012 08:45:51 +0000 Subject: [PATCH 103/105] Fixed typo in a tooltip --- source/blender/makesrna/intern/rna_space.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 571fe05238d..799366a5234 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2902,7 +2902,7 @@ static void rna_def_space_clip(BlenderRNA *brna) /* lock to time cursor */ prop= RNA_def_property(srna, "lock_time_cursor", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_ui_text(prop, "Lock to Time Cursor", "Lock curves view to time cursos during playback and tracking"); + RNA_def_property_ui_text(prop, "Lock to Time Cursor", "Lock curves view to time cursor during playback and tracking"); RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_LOCK_TIMECURSOR); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL); From b86c6f65a43a2ef1597b29467ba61bbed4ff6ec5 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sat, 28 Jan 2012 13:53:17 +0000 Subject: [PATCH 104/105] Release cycle: * Moving on to BCon3: Beta. --- source/blender/blenkernel/BKE_blender.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 42d9ae73b9a..50fef032b75 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -51,7 +51,7 @@ extern "C" { /* can be left blank, otherwise a,b,c... etc with no quotes */ #define BLENDER_VERSION_CHAR /* alpha/beta/rc/release, docs use this */ -#define BLENDER_VERSION_CYCLE alpha +#define BLENDER_VERSION_CYCLE beta extern char versionstr[]; /* from blender.c */ From d4584dfd23ab4880cc6e2f7f6d699ea3c9687d22 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Sun, 29 Jan 2012 10:21:28 +0000 Subject: [PATCH 105/105] Fix for [#30015] Keyframed Resolution Unpredictable * Disabled possibility to keyframe render resolution, percentage and border render properties. Animating them does not makes much sense. Discussed with Sergey in IRC. --- source/blender/makesrna/intern/rna_scene.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index c1df493eea5..68b9ce4e956 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3154,18 +3154,21 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "resolution_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "xsch"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 4, 10000); RNA_def_property_ui_text(prop, "Resolution X", "Number of horizontal pixels in the rendered image"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); prop= RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "ysch"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 4, 10000); RNA_def_property_ui_text(prop, "Resolution Y", "Number of vertical pixels in the rendered image"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); prop= RNA_def_property(srna, "resolution_percentage", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "size"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 100, 10, 1); RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution"); @@ -3185,12 +3188,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xasp"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1.0f, 200.0f); RNA_def_property_ui_text(prop, "Pixel Aspect X", "Horizontal aspect ratio - for anamorphic or non-square pixel output"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); prop= RNA_def_property(srna, "pixel_aspect_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yasp"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1.0f, 200.0f); RNA_def_property_ui_text(prop, "Pixel Aspect Y", "Vertical aspect ratio - for anamorphic or non-square pixel output"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); @@ -3404,6 +3409,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) /* border */ prop= RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_BORDER); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Border", "Render a user-defined border region, within the frame size " "(note that this disables save_buffers and full_sample)"); @@ -3435,6 +3441,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) prop= RNA_def_property(srna, "use_crop_to_border", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_CROP); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Crop to Border", "Crop the rendered frame to the defined border size"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);