style cleanup
This commit is contained in:
@@ -756,7 +756,7 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
*
|
||||
* TODO, loop over children before parents if multiple bones
|
||||
* at once are to be predictable*/
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
float delta_mat[4][4];
|
||||
|
||||
@@ -923,7 +923,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
pose = ob->pose;
|
||||
ob->mode &= ~OB_MODE_POSE;
|
||||
|
||||
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
|
||||
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
|
||||
{
|
||||
if ((base->object->type == OB_ARMATURE) && (base->object != ob)) {
|
||||
bArmature *curarm = base->object->data;
|
||||
@@ -1195,7 +1195,7 @@ static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* 1) only edit-base selected */
|
||||
// TODO: use context iterators for this?
|
||||
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
|
||||
CTX_DATA_BEGIN(C, Base *, base, visible_bases)
|
||||
{
|
||||
if (base->object == obedit) base->flag |= 1;
|
||||
else base->flag &= ~1;
|
||||
@@ -2848,7 +2848,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* loop over all bones, and only consider if visible */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
|
||||
{
|
||||
if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL))
|
||||
fill_add_joint(ebone, 0, &points);
|
||||
@@ -3562,7 +3562,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* loop over all editable bones */
|
||||
// XXX the old code did this in reverse order though!
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
for (i = numcuts + 1; i > 1; i--) {
|
||||
/* compute cut ratio first */
|
||||
@@ -3851,7 +3851,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
|
||||
*/
|
||||
|
||||
/* parent selected bones to the active one */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
if (ELEM(ebone, actbone, actmirb) == 0) {
|
||||
if (ebone->flag & BONE_SELECTED)
|
||||
@@ -3877,7 +3877,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEve
|
||||
uiLayout *layout = uiPupMenuLayout(pup);
|
||||
int allchildbones = 0;
|
||||
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
if (ebone != actbone) {
|
||||
if (ebone->parent != actbone) allchildbones = 1;
|
||||
@@ -3937,7 +3937,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
int val = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
editbone_clear_parent(ebone, val);
|
||||
}
|
||||
@@ -3974,7 +3974,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
|
||||
static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
/* Set the flags */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
|
||||
{
|
||||
/* ignore bone if selection can't change */
|
||||
if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
@@ -4017,7 +4017,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* Set the flags */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, visible_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
|
||||
{
|
||||
/* ignore bone if selection can't change */
|
||||
if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
@@ -4437,7 +4437,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
|
||||
*/
|
||||
|
||||
/* align selected bones to the active one */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
if (ELEM(ebone, actbone, actmirb) == 0) {
|
||||
if (ebone->flag & BONE_SELECTED)
|
||||
@@ -4523,7 +4523,9 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
|
||||
* note, special exception for armature mode so we can do multi-select
|
||||
* we could check for multi-select explicitly but think its fine to
|
||||
* always give predictable behavior in weight paint mode - campbell */
|
||||
if ((!extend && !deselect && !toggle)|| ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) {
|
||||
if ((!extend && !deselect && !toggle) ||
|
||||
((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0)))
|
||||
{
|
||||
ED_pose_deselectall(ob, 0);
|
||||
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
arm->act_bone = nearBone;
|
||||
@@ -5134,7 +5136,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
|
||||
}
|
||||
|
||||
/* only clear relevant transforms for selected bones */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
/* run provided clearing function */
|
||||
clear_func(pchan);
|
||||
@@ -5278,7 +5280,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* Set the flags */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
/* select pchan only if selectable, but deselect works always */
|
||||
switch (action) {
|
||||
@@ -5674,7 +5676,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
arm = ob->data;
|
||||
|
||||
/* loop through selected bones, auto-naming them */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
flip_side_name(newname, ebone->name, TRUE); // 1 = do strip off number extensions
|
||||
ED_armature_bone_rename(arm, ebone->name, newname);
|
||||
@@ -5719,7 +5721,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op)
|
||||
arm = ob->data;
|
||||
|
||||
/* loop through selected bones, auto-naming them */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
BLI_strncpy(newname, ebone->name, sizeof(newname));
|
||||
if (bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis]))
|
||||
@@ -5742,7 +5744,8 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
|
||||
{0, "XAXIS", 0, "X-Axis", "Left/Right"},
|
||||
{1, "YAXIS", 0, "Y-Axis", "Front/Back"},
|
||||
{2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "AutoName by Axis";
|
||||
|
||||
@@ -141,14 +141,14 @@ void ED_operatormacros_curve(void)
|
||||
wmOperatorTypeMacro *otmacro;
|
||||
|
||||
ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", "Duplicate curve and move",
|
||||
OPTYPE_UNDO|OPTYPE_REGISTER);
|
||||
OPTYPE_UNDO | OPTYPE_REGISTER);
|
||||
WM_operatortype_macro_define(ot, "CURVE_OT_duplicate");
|
||||
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
|
||||
RNA_enum_set(otmacro->ptr, "proportional", 0);
|
||||
RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
|
||||
|
||||
ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move",
|
||||
"Extrude curve and move result", OPTYPE_UNDO|OPTYPE_REGISTER);
|
||||
"Extrude curve and move result", OPTYPE_UNDO | OPTYPE_REGISTER);
|
||||
WM_operatortype_macro_define(ot, "CURVE_OT_extrude");
|
||||
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
|
||||
RNA_enum_set(otmacro->ptr, "proportional", 0);
|
||||
@@ -189,8 +189,8 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", ENDKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", LINE_END);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_CHAR);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_CHAR);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "type", PREV_WORD);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0)->ptr, "type", NEXT_WORD);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "type", PREV_WORD);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "type", NEXT_WORD);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_LINE);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", NEXT_LINE);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_move_select", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", PREV_PAGE);
|
||||
@@ -224,9 +224,9 @@ void ED_keymap_curve(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", LEFTMOUSE, KM_CLICK, KM_CTRL, 0);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
|
||||
kmi = WM_keymap_add_item(keymap, "CURVE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
|
||||
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_select_row", RKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "CURVE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
@@ -3530,7 +3530,8 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot)
|
||||
// {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
|
||||
// {CU_BSPLINE, "B_SPLINE", 0, "B-Spline", ""},
|
||||
{CU_NURBS, "NURBS", 0, "NURBS", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Set Spline Type";
|
||||
@@ -3573,7 +3574,8 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot)
|
||||
{5, "ALIGNED", 0, "Aligned", ""},
|
||||
{6, "FREE_ALIGN", 0, "Free", ""},
|
||||
{3, "TOGGLE_FREE_ALIGN", 0, "Toggle Free/Align", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Set Handle Type";
|
||||
@@ -4886,7 +4888,8 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot)
|
||||
static EnumPropertyItem direction_items[] = {
|
||||
{0, "CYCLIC_U", 0, "Cyclic U", ""},
|
||||
{1, "CYCLIC_V", 0, "Cyclic V", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Toggle Cyclic";
|
||||
@@ -6007,7 +6010,8 @@ void CURVE_OT_delete(wmOperatorType *ot)
|
||||
{0, "SELECTED", 0, "Select", ""},
|
||||
{1, "SEGMENT", 0, "Segment", ""},
|
||||
{2, "ALL", 0, "All", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Delete";
|
||||
@@ -6101,7 +6105,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* trasnform all selected curves inverse in obact */
|
||||
invert_m4_m4(imat, ob->obmat);
|
||||
|
||||
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
|
||||
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
|
||||
{
|
||||
if (base->object->type == ob->type) {
|
||||
if (base->object != ob) {
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include "curve_intern.h"
|
||||
|
||||
const char ED_lorem[]= {
|
||||
const char ED_lorem[] = {
|
||||
76, 111, 114, 101, 109, 32, 105, 112, 115, 117, 109, 32, 100, 111, 108, 111, 114, 32, 115, 105, 116, 32, 97, 109, 101, 116, 44, 32, 99,
|
||||
111, 110, 115, 101, 99, 116, 101, 116, 117, 101, 114, 32, 97, 100, 105, 112, 105, 115, 99, 105, 110, 103, 32, 101, 108, 105, 116, 46, 32, 65, 108, 105,
|
||||
113, 117, 97, 109, 32, 116, 114, 105, 115, 116, 105, 113, 117, 101, 32, 105, 110, 116, 101, 114, 100, 117, 109, 32, 115, 101, 109, 46, 32, 78, 117, 108,
|
||||
|
||||
@@ -167,9 +167,9 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa)
|
||||
static void panels_collapse_all(ScrArea *sa, ARegion *ar)
|
||||
{
|
||||
Panel *pa;
|
||||
int flag = ((panel_aligned(sa, ar)==BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY);
|
||||
int flag = ((panel_aligned(sa, ar) == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY);
|
||||
|
||||
for (pa= ar->panels.first; pa; pa= pa->next) {
|
||||
for (pa = ar->panels.first; pa; pa = pa->next) {
|
||||
if (pa->type && !(pa->type->flag & PNL_NO_HEADER)) {
|
||||
pa->flag = flag;
|
||||
}
|
||||
|
||||
@@ -162,9 +162,10 @@ static unsigned int scroll_circle_face[14][3] = {
|
||||
};
|
||||
|
||||
|
||||
static float menu_tria_vert[6][2]= {
|
||||
{-0.33, 0.16}, {0.33, 0.16}, {0, 0.82},
|
||||
{0, -0.82}, {-0.33, -0.16}, {0.33, -0.16}};
|
||||
static float menu_tria_vert[6][2] = {
|
||||
{-0.33, 0.16}, {0.33, 0.16}, {0, 0.82},
|
||||
{0, -0.82}, {-0.33, -0.16}, {0.33, -0.16}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1168,7 +1169,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
|
||||
|
||||
#if 0
|
||||
ui_rasterpos_safe(x, y, but->aspect);
|
||||
if (but->type == IDPOIN) transopts = 0; // no translation, of course!
|
||||
if (but->type == IDPOIN) transopts = 0; // no translation, of course!
|
||||
else transopts = ui_translate_buttons();
|
||||
#endif
|
||||
|
||||
@@ -3133,7 +3134,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
|
||||
if (but->drawflag & UI_BUT_DRAW_ENUM_ARROWS)
|
||||
wt = widget_type(UI_WTYPE_MENU_RADIO); /* with arrows */
|
||||
else
|
||||
wt = widget_type(UI_WTYPE_MENU_ICON_RADIO); /* no arrows */
|
||||
wt = widget_type(UI_WTYPE_MENU_ICON_RADIO); /* no arrows */
|
||||
}
|
||||
/* with menu arrows */
|
||||
else
|
||||
|
||||
@@ -783,8 +783,8 @@ void ui_theme_init_default(void)
|
||||
/* space nla */
|
||||
btheme->tnla = btheme->tact;
|
||||
|
||||
rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */
|
||||
rgba_char_args_set(btheme->tnla.anim_non_active,153, 135, 97, 77);
|
||||
rgba_char_args_set(btheme->tnla.anim_active, 204, 112, 26, 102); /* same as for dopesheet; duplicate here for easier reference */
|
||||
rgba_char_args_set(btheme->tnla.anim_non_active, 153, 135, 97, 77);
|
||||
|
||||
rgba_char_args_set(btheme->tnla.nla_tweaking, 77, 243, 26, 77);
|
||||
rgba_char_args_set(btheme->tnla.nla_tweakdupli, 217, 0, 0, 255);
|
||||
|
||||
@@ -4830,13 +4830,11 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
mdiff[1] = opdata->mcenter[1] - event->mval[1];
|
||||
|
||||
if (opdata->modify_depth) {
|
||||
amount = opdata->old_depth + (len_v2(mdiff)
|
||||
- opdata->initial_length) / opdata->initial_length;
|
||||
amount = opdata->old_depth + (len_v2(mdiff) - opdata->initial_length) / opdata->initial_length;
|
||||
RNA_float_set(op->ptr, "depth", amount);
|
||||
}
|
||||
else {
|
||||
amount = opdata->old_thickness - (len_v2(mdiff)
|
||||
- opdata->initial_length) / opdata->initial_length;
|
||||
amount = opdata->old_thickness - (len_v2(mdiff) - opdata->initial_length) / opdata->initial_length;
|
||||
amount = MAX2(amount, 0.0f);
|
||||
|
||||
RNA_float_set(op->ptr, "thickness", amount);
|
||||
|
||||
@@ -180,7 +180,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
|
||||
short changed = 0;
|
||||
const int unselected = RNA_boolean_get(op->ptr, "unselected");
|
||||
|
||||
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
|
||||
CTX_DATA_BEGIN(C, Base *, base, visible_bases)
|
||||
{
|
||||
if (!unselected) {
|
||||
if (base->flag & SELECT) {
|
||||
@@ -240,7 +240,7 @@ static int object_hide_render_clear_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
short changed = 0;
|
||||
|
||||
/* XXX need a context loop to handle such cases */
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
|
||||
{
|
||||
if (ob->restrictflag & OB_RESTRICT_RENDER) {
|
||||
ob->restrictflag &= ~OB_RESTRICT_RENDER;
|
||||
@@ -275,7 +275,7 @@ static int object_hide_render_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const int unselected = RNA_boolean_get(op->ptr, "unselected");
|
||||
|
||||
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
|
||||
CTX_DATA_BEGIN(C, Base *, base, visible_bases)
|
||||
{
|
||||
if (!unselected) {
|
||||
if (base->flag & SELECT) {
|
||||
@@ -1114,7 +1114,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene)
|
||||
ListBase targets = {NULL, NULL};
|
||||
|
||||
/* loop over objects in scene */
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
|
||||
{
|
||||
/* set flag to force recalc, then grab path(s) from object */
|
||||
ob->avs.recalc |= ANIMVIZ_RECALC_PATHS;
|
||||
@@ -1157,7 +1157,7 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op)
|
||||
int end = RNA_int_get(op->ptr, "end_frame");
|
||||
|
||||
/* set up path data for bones being calculated */
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
|
||||
{
|
||||
bAnimVizSettings *avs = &ob->avs;
|
||||
|
||||
@@ -1196,9 +1196,9 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot)
|
||||
|
||||
/* properties */
|
||||
RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
|
||||
"First frame to calculate object paths on", MINFRAME, MAXFRAME/2.0);
|
||||
"First frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
|
||||
RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
|
||||
"Last frame to calculate object paths on", MINFRAME, MAXFRAME/2.0);
|
||||
"Last frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0);
|
||||
}
|
||||
|
||||
/* --------- */
|
||||
@@ -1231,7 +1231,7 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_object_active_editable; /* TODO: this should probably check for existing paths */
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* --------- */
|
||||
@@ -1240,7 +1240,7 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
|
||||
void ED_objects_clear_paths(bContext *C)
|
||||
{
|
||||
/* loop over objects in scene */
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
|
||||
{
|
||||
if (ob->mpath) {
|
||||
animviz_free_motionpath(ob->mpath);
|
||||
@@ -1288,7 +1288,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
|
||||
int clear = (strcmp(op->idname, "OBJECT_OT_shade_flat") == 0);
|
||||
int done = FALSE;
|
||||
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects)
|
||||
{
|
||||
|
||||
if (ob->type == OB_MESH) {
|
||||
@@ -1666,10 +1666,12 @@ static EnumPropertyItem game_properties_copy_operations[] = {
|
||||
{COPY_PROPERTIES_REPLACE, "REPLACE", 0, "Replace Properties", ""},
|
||||
{COPY_PROPERTIES_MERGE, "MERGE", 0, "Merge Properties", ""},
|
||||
{COPY_PROPERTIES_COPY, "COPY", 0, "Copy a Property", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem gameprops_items[]= {
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
static EnumPropertyItem gameprops_items[] = {
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
|
||||
{
|
||||
@@ -1706,7 +1708,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
|
||||
prop = BLI_findlink(&ob->prop, propid - 1);
|
||||
|
||||
if (prop) {
|
||||
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
|
||||
{
|
||||
if (ob != ob_iter)
|
||||
set_ob_property(ob_iter, prop);
|
||||
@@ -1715,7 +1717,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
else {
|
||||
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
|
||||
{
|
||||
if (ob != ob_iter) {
|
||||
if (type == COPY_PROPERTIES_REPLACE)
|
||||
@@ -1756,7 +1758,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot)
|
||||
|
||||
static int game_property_clear_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
|
||||
{
|
||||
free_properties(&ob_iter->prop);
|
||||
}
|
||||
@@ -1786,7 +1788,7 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob = ED_object_active_context(C);
|
||||
|
||||
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
|
||||
{
|
||||
if (ob != ob_iter) {
|
||||
/* first: free all logic */
|
||||
@@ -1843,7 +1845,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob = ED_object_active_context(C);
|
||||
|
||||
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects)
|
||||
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects)
|
||||
{
|
||||
if (ob != ob_iter) {
|
||||
ob_iter->gameflag = ob->gameflag;
|
||||
|
||||
@@ -344,18 +344,17 @@ int mouse_lattice(bContext *C, const int mval[2], int extend, int deselect, int
|
||||
bp = findnearestLattvert(&vc, mval, 1);
|
||||
|
||||
if (bp) {
|
||||
if (extend) {
|
||||
bp->f1 |= SELECT;
|
||||
}
|
||||
else if (deselect) {
|
||||
bp->f1 &= ~SELECT;
|
||||
}
|
||||
if (extend) {
|
||||
bp->f1 |= SELECT;
|
||||
}
|
||||
else if (deselect) {
|
||||
bp->f1 &= ~SELECT;
|
||||
}
|
||||
else if (toggle) {
|
||||
bp->f1 ^= SELECT; /* swap */
|
||||
}
|
||||
else
|
||||
{
|
||||
ED_setflagsLatt(vc.obedit, 0);
|
||||
else {
|
||||
ED_setflagsLatt(vc.obedit, 0);
|
||||
bp->f1 |= SELECT;
|
||||
}
|
||||
|
||||
|
||||
@@ -577,7 +577,6 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
|
||||
SpaceClipDrawContext *context = sc->draw_context;
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
int need_rebind = 0;
|
||||
short custom_start_frame = FALSE;
|
||||
|
||||
context->last_texture = glaGetOneInteger(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
@@ -1047,7 +1047,7 @@ static void clip_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
|
||||
|
||||
/* own keymap */
|
||||
keymap= WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0);
|
||||
keymap = WM_keymap_find(wm->defaultconf, "Mask Editing", 0, 0);
|
||||
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
|
||||
|
||||
keymap = WM_keymap_find(wm->defaultconf, "Clip", SPACE_CLIP, 0);
|
||||
|
||||
@@ -2099,7 +2099,7 @@ static struct PyMethodDef bpy_bmesh_methods[] = {
|
||||
{"select_flush_mode", (PyCFunction)bpy_bmesh_select_flush_mode, METH_NOARGS, bpy_bmesh_select_flush_mode_doc},
|
||||
{"select_flush", (PyCFunction)bpy_bmesh_select_flush, METH_O, bpy_bmesh_select_flush_doc},
|
||||
{"normal_update", (PyCFunction)bpy_bmesh_normal_update, METH_VARARGS, bpy_bmesh_normal_update_doc},
|
||||
{"transform", (PyCFunction)bpy_bmesh_transform, METH_VARARGS|METH_KEYWORDS, bpy_bmesh_transform_doc},
|
||||
{"transform", (PyCFunction)bpy_bmesh_transform, METH_VARARGS | METH_KEYWORDS, bpy_bmesh_transform_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -2141,7 +2141,7 @@ static struct PyMethodDef bpy_bmface_methods[] = {
|
||||
{"copy_from", (PyCFunction)bpy_bm_elem_copy_from, METH_O, bpy_bm_elem_copy_from_doc},
|
||||
{"copy_from_face_interp", (PyCFunction)bpy_bmface_copy_from_face_interp, METH_O, bpy_bmface_copy_from_face_interp_doc},
|
||||
|
||||
{"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS|METH_KEYWORDS, bpy_bmface_copy_doc},
|
||||
{"copy", (PyCFunction)bpy_bmface_copy, METH_VARARGS | METH_KEYWORDS, bpy_bmface_copy_doc},
|
||||
|
||||
{"calc_area", (PyCFunction)bpy_bmface_calc_area, METH_NOARGS, bpy_bmface_calc_area_doc},
|
||||
{"calc_perimeter", (PyCFunction)bpy_bmface_calc_perimeter, METH_NOARGS, bpy_bmface_calc_perimeter_doc},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -74,49 +74,49 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf)
|
||||
|
||||
/* after lock we test cube[1], if set the other thread has done it fine */
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
if (env->cube[1]==NULL) {
|
||||
if (env->cube[1] == NULL) {
|
||||
|
||||
BKE_free_envmapdata(env);
|
||||
|
||||
dx= ibuf->y;
|
||||
dx/= 2;
|
||||
if (3*dx == ibuf->x) {
|
||||
dx = ibuf->y;
|
||||
dx /= 2;
|
||||
if (3 * dx == ibuf->x) {
|
||||
env->type = ENV_CUBE;
|
||||
env->ok= ENV_OSA;
|
||||
env->ok = ENV_OSA;
|
||||
}
|
||||
else if (ibuf->x == ibuf->y) {
|
||||
env->type = ENV_PLANE;
|
||||
env->ok= ENV_OSA;
|
||||
env->ok = ENV_OSA;
|
||||
}
|
||||
else {
|
||||
printf("Incorrect envmap size\n");
|
||||
env->ok= 0;
|
||||
env->ima->ok= 0;
|
||||
env->ok = 0;
|
||||
env->ima->ok = 0;
|
||||
}
|
||||
|
||||
if (env->ok) {
|
||||
if (env->type == ENV_CUBE) {
|
||||
for (part=0; part<6; part++) {
|
||||
env->cube[part]= IMB_allocImBuf(dx, dx, 24, IB_rect|IB_rectfloat);
|
||||
for (part = 0; part < 6; part++) {
|
||||
env->cube[part] = IMB_allocImBuf(dx, dx, 24, IB_rect | IB_rectfloat);
|
||||
}
|
||||
IMB_float_from_rect(ibuf);
|
||||
|
||||
IMB_rectcpy(env->cube[0], ibuf,
|
||||
0, 0, 0, 0, dx, dx);
|
||||
0, 0, 0, 0, dx, dx);
|
||||
IMB_rectcpy(env->cube[1], ibuf,
|
||||
0, 0, dx, 0, dx, dx);
|
||||
0, 0, dx, 0, dx, dx);
|
||||
IMB_rectcpy(env->cube[2], ibuf,
|
||||
0, 0, 2*dx, 0, dx, dx);
|
||||
0, 0, 2 * dx, 0, dx, dx);
|
||||
IMB_rectcpy(env->cube[3], ibuf,
|
||||
0, 0, 0, dx, dx, dx);
|
||||
0, 0, 0, dx, dx, dx);
|
||||
IMB_rectcpy(env->cube[4], ibuf,
|
||||
0, 0, dx, dx, dx, dx);
|
||||
0, 0, dx, dx, dx, dx);
|
||||
IMB_rectcpy(env->cube[5], ibuf,
|
||||
0, 0, 2*dx, dx, dx, dx);
|
||||
0, 0, 2 * dx, dx, dx, dx);
|
||||
|
||||
}
|
||||
else { /* ENV_PLANE */
|
||||
env->cube[1]= IMB_dupImBuf(ibuf);
|
||||
env->cube[1] = IMB_dupImBuf(ibuf);
|
||||
IMB_float_from_rect(env->cube[1]);
|
||||
}
|
||||
}
|
||||
@@ -134,53 +134,53 @@ static Render *envmap_render_copy(Render *re, EnvMap *env)
|
||||
float viewscale;
|
||||
int cuberes;
|
||||
|
||||
envre= RE_NewRender("Envmap");
|
||||
envre = RE_NewRender("Envmap");
|
||||
|
||||
env->lastsize= re->r.size;
|
||||
env->lastsize = re->r.size;
|
||||
cuberes = (env->cuberes * re->r.size) / 100;
|
||||
cuberes &= 0xFFFC;
|
||||
|
||||
/* this flag has R_ZTRA in it for example */
|
||||
envre->flag= re->flag;
|
||||
envre->flag = re->flag;
|
||||
|
||||
/* set up renderdata */
|
||||
envre->r= re->r;
|
||||
envre->r = re->r;
|
||||
envre->r.mode &= ~(R_BORDER | R_PANORAMA | R_ORTHO | R_MBLUR);
|
||||
envre->r.layers.first= envre->r.layers.last= NULL;
|
||||
envre->r.filtertype= 0;
|
||||
envre->r.xparts= envre->r.yparts= 2;
|
||||
envre->r.size= 100;
|
||||
envre->r.yasp= envre->r.xasp= 1;
|
||||
envre->r.layers.first = envre->r.layers.last = NULL;
|
||||
envre->r.filtertype = 0;
|
||||
envre->r.xparts = envre->r.yparts = 2;
|
||||
envre->r.size = 100;
|
||||
envre->r.yasp = envre->r.xasp = 1;
|
||||
|
||||
RE_InitState(envre, NULL, &envre->r, NULL, cuberes, cuberes, NULL);
|
||||
envre->scene= re->scene; /* unsure about this... */
|
||||
envre->lay= re->lay;
|
||||
envre->scene = re->scene; /* unsure about this... */
|
||||
envre->lay = re->lay;
|
||||
|
||||
/* view stuff in env render */
|
||||
viewscale= (env->type == ENV_PLANE)? env->viewscale: 1.0f;
|
||||
viewscale = (env->type == ENV_PLANE) ? env->viewscale : 1.0f;
|
||||
RE_SetEnvmapCamera(envre, env->object, viewscale, env->clipsta, env->clipend);
|
||||
|
||||
/* callbacks */
|
||||
envre->display_draw= re->display_draw;
|
||||
envre->ddh= re->ddh;
|
||||
envre->test_break= re->test_break;
|
||||
envre->tbh= re->tbh;
|
||||
envre->display_draw = re->display_draw;
|
||||
envre->ddh = re->ddh;
|
||||
envre->test_break = re->test_break;
|
||||
envre->tbh = re->tbh;
|
||||
|
||||
/* and for the evil stuff; copy the database... */
|
||||
envre->totvlak= re->totvlak;
|
||||
envre->totvert= re->totvert;
|
||||
envre->tothalo= re->tothalo;
|
||||
envre->totstrand= re->totstrand;
|
||||
envre->totlamp= re->totlamp;
|
||||
envre->sortedhalos= re->sortedhalos;
|
||||
envre->lights= re->lights;
|
||||
envre->objecttable= re->objecttable;
|
||||
envre->customdata_names= re->customdata_names;
|
||||
envre->raytree= re->raytree;
|
||||
envre->totinstance= re->totinstance;
|
||||
envre->instancetable= re->instancetable;
|
||||
envre->objectinstance= re->objectinstance;
|
||||
envre->qmcsamplers= re->qmcsamplers;
|
||||
envre->totvlak = re->totvlak;
|
||||
envre->totvert = re->totvert;
|
||||
envre->tothalo = re->tothalo;
|
||||
envre->totstrand = re->totstrand;
|
||||
envre->totlamp = re->totlamp;
|
||||
envre->sortedhalos = re->sortedhalos;
|
||||
envre->lights = re->lights;
|
||||
envre->objecttable = re->objecttable;
|
||||
envre->customdata_names = re->customdata_names;
|
||||
envre->raytree = re->raytree;
|
||||
envre->totinstance = re->totinstance;
|
||||
envre->instancetable = re->instancetable;
|
||||
envre->objectinstance = re->objectinstance;
|
||||
envre->qmcsamplers = re->qmcsamplers;
|
||||
|
||||
return envre;
|
||||
}
|
||||
@@ -188,20 +188,20 @@ static Render *envmap_render_copy(Render *re, EnvMap *env)
|
||||
static void envmap_free_render_copy(Render *envre)
|
||||
{
|
||||
|
||||
envre->totvlak= 0;
|
||||
envre->totvert= 0;
|
||||
envre->tothalo= 0;
|
||||
envre->totstrand= 0;
|
||||
envre->totlamp= 0;
|
||||
envre->totinstance= 0;
|
||||
envre->sortedhalos= NULL;
|
||||
envre->lights.first= envre->lights.last= NULL;
|
||||
envre->objecttable.first= envre->objecttable.last= NULL;
|
||||
envre->customdata_names.first= envre->customdata_names.last= NULL;
|
||||
envre->raytree= NULL;
|
||||
envre->instancetable.first= envre->instancetable.last= NULL;
|
||||
envre->objectinstance= NULL;
|
||||
envre->qmcsamplers= NULL;
|
||||
envre->totvlak = 0;
|
||||
envre->totvert = 0;
|
||||
envre->tothalo = 0;
|
||||
envre->totstrand = 0;
|
||||
envre->totlamp = 0;
|
||||
envre->totinstance = 0;
|
||||
envre->sortedhalos = NULL;
|
||||
envre->lights.first = envre->lights.last = NULL;
|
||||
envre->objecttable.first = envre->objecttable.last = NULL;
|
||||
envre->customdata_names.first = envre->customdata_names.last = NULL;
|
||||
envre->raytree = NULL;
|
||||
envre->instancetable.first = envre->instancetable.last = NULL;
|
||||
envre->objectinstance = NULL;
|
||||
envre->qmcsamplers = NULL;
|
||||
|
||||
RE_FreeRender(envre);
|
||||
}
|
||||
@@ -212,28 +212,28 @@ static void envmap_transmatrix(float mat[][4], int part)
|
||||
{
|
||||
float tmat[4][4], eul[3], rotmat[4][4];
|
||||
|
||||
eul[0]= eul[1]= eul[2]= 0.0;
|
||||
eul[0] = eul[1] = eul[2] = 0.0;
|
||||
|
||||
if (part==0) { /* neg z */
|
||||
if (part == 0) { /* neg z */
|
||||
;
|
||||
}
|
||||
else if (part==1) { /* pos z */
|
||||
eul[0]= M_PI;
|
||||
else if (part == 1) { /* pos z */
|
||||
eul[0] = M_PI;
|
||||
}
|
||||
else if (part==2) { /* pos y */
|
||||
eul[0]= M_PI/2.0;
|
||||
else if (part == 2) { /* pos y */
|
||||
eul[0] = M_PI / 2.0;
|
||||
}
|
||||
else if (part==3) { /* neg x */
|
||||
eul[0]= M_PI/2.0;
|
||||
eul[2]= M_PI/2.0;
|
||||
else if (part == 3) { /* neg x */
|
||||
eul[0] = M_PI / 2.0;
|
||||
eul[2] = M_PI / 2.0;
|
||||
}
|
||||
else if (part==4) { /* neg y */
|
||||
eul[0]= M_PI/2.0;
|
||||
eul[2]= M_PI;
|
||||
else if (part == 4) { /* neg y */
|
||||
eul[0] = M_PI / 2.0;
|
||||
eul[2] = M_PI;
|
||||
}
|
||||
else { /* pos x */
|
||||
eul[0]= M_PI/2.0;
|
||||
eul[2]= -M_PI/2.0;
|
||||
else { /* pos x */
|
||||
eul[0] = M_PI / 2.0;
|
||||
eul[2] = -M_PI / 2.0;
|
||||
}
|
||||
|
||||
copy_m4_m4(tmat, mat);
|
||||
@@ -255,7 +255,7 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
|
||||
float imat[3][3], pmat[4][4], smat[4][4], tmat[4][4], cmat[3][3], tmpmat[4][4];
|
||||
int a;
|
||||
|
||||
if (mode==0) {
|
||||
if (mode == 0) {
|
||||
invert_m4_m4(tmat, mat);
|
||||
copy_m3_m4(imat, tmat);
|
||||
}
|
||||
@@ -264,13 +264,13 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
|
||||
copy_m3_m4(imat, mat);
|
||||
}
|
||||
|
||||
for (obi=re->instancetable.first; obi; obi=obi->next) {
|
||||
for (obi = re->instancetable.first; obi; obi = obi->next) {
|
||||
/* append or set matrix depending on dupli */
|
||||
if (obi->flag & R_DUPLI_TRANSFORMED) {
|
||||
copy_m4_m4(tmpmat, obi->mat);
|
||||
mult_m4_m4m4(obi->mat, tmat, tmpmat);
|
||||
}
|
||||
else if (mode==1)
|
||||
else if (mode == 1)
|
||||
copy_m4_m4(obi->mat, tmat);
|
||||
else
|
||||
unit_m4(obi->mat);
|
||||
@@ -280,24 +280,24 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
|
||||
transpose_m3(obi->nmat);
|
||||
|
||||
/* indicate the renderer has to use transform matrices */
|
||||
if (mode==0)
|
||||
if (mode == 0)
|
||||
obi->flag &= ~R_ENV_TRANSFORMED;
|
||||
else
|
||||
obi->flag |= R_ENV_TRANSFORMED;
|
||||
}
|
||||
|
||||
|
||||
for (obr=re->objecttable.first; obr; obr=obr->next) {
|
||||
for (a=0; a<obr->tothalo; a++) {
|
||||
if ((a & 255)==0) har= obr->bloha[a>>8];
|
||||
for (obr = re->objecttable.first; obr; obr = obr->next) {
|
||||
for (a = 0; a < obr->tothalo; a++) {
|
||||
if ((a & 255) == 0) har = obr->bloha[a >> 8];
|
||||
else har++;
|
||||
|
||||
mul_m4_v3(tmat, har->co);
|
||||
}
|
||||
}
|
||||
|
||||
for (go=re->lights.first; go; go= go->next) {
|
||||
lar= go->lampren;
|
||||
for (go = re->lights.first; go; go = go->next) {
|
||||
lar = go->lampren;
|
||||
|
||||
/* removed here some horrible code of someone in NaN who tried to fix
|
||||
* prototypes... just solved by introducing a correct cmat[3][3] instead
|
||||
@@ -308,14 +308,14 @@ static void env_rotate_scene(Render *re, float mat[][4], int mode)
|
||||
mul_m3_v3(imat, lar->vec);
|
||||
mul_m4_v3(tmat, lar->co);
|
||||
|
||||
lar->sh_invcampos[0]= -lar->co[0];
|
||||
lar->sh_invcampos[1]= -lar->co[1];
|
||||
lar->sh_invcampos[2]= -lar->co[2];
|
||||
lar->sh_invcampos[0] = -lar->co[0];
|
||||
lar->sh_invcampos[1] = -lar->co[1];
|
||||
lar->sh_invcampos[2] = -lar->co[2];
|
||||
mul_m3_v3(lar->imat, lar->sh_invcampos);
|
||||
lar->sh_invcampos[2]*= lar->sh_zfac;
|
||||
lar->sh_invcampos[2] *= lar->sh_zfac;
|
||||
|
||||
if (lar->shb) {
|
||||
if (mode==1) {
|
||||
if (mode == 1) {
|
||||
invert_m4_m4(pmat, mat);
|
||||
mult_m4_m4m4(smat, lar->shb->viewmat, pmat);
|
||||
mult_m4_m4m4(lar->shb->persmat, lar->shb->winmat, smat);
|
||||
@@ -342,12 +342,12 @@ static void env_layerflags(Render *re, unsigned int notlay)
|
||||
* now (face & ~not) is true
|
||||
*/
|
||||
|
||||
notlay= ~notlay;
|
||||
notlay = ~notlay;
|
||||
|
||||
for (obr=re->objecttable.first; obr; obr=obr->next) {
|
||||
if ((obr->lay & notlay)==0) {
|
||||
for (a=0; a<obr->totvlak; a++) {
|
||||
if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
|
||||
for (obr = re->objecttable.first; obr; obr = obr->next) {
|
||||
if ((obr->lay & notlay) == 0) {
|
||||
for (a = 0; a < obr->totvlak; a++) {
|
||||
if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak;
|
||||
else vlr++;
|
||||
|
||||
vlr->flag |= R_HIDDEN;
|
||||
@@ -362,9 +362,9 @@ static void env_hideobject(Render *re, Object *ob)
|
||||
VlakRen *vlr = NULL;
|
||||
int a;
|
||||
|
||||
for (obr=re->objecttable.first; obr; obr=obr->next) {
|
||||
for (a=0; a<obr->totvlak; a++) {
|
||||
if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
|
||||
for (obr = re->objecttable.first; obr; obr = obr->next) {
|
||||
for (a = 0; a < obr->totvlak; a++) {
|
||||
if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak;
|
||||
else vlr++;
|
||||
|
||||
if (obr->ob == ob)
|
||||
@@ -379,9 +379,9 @@ static void env_showobjects(Render *re)
|
||||
VlakRen *vlr = NULL;
|
||||
int a;
|
||||
|
||||
for (obr=re->objecttable.first; obr; obr=obr->next) {
|
||||
for (a=0; a<obr->totvlak; a++) {
|
||||
if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
|
||||
for (obr = re->objecttable.first; obr; obr = obr->next) {
|
||||
for (a = 0; a < obr->totvlak; a++) {
|
||||
if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak;
|
||||
else vlr++;
|
||||
|
||||
vlr->flag &= ~R_HIDDEN;
|
||||
@@ -396,12 +396,12 @@ static void env_set_imats(Render *re)
|
||||
Base *base;
|
||||
float mat[4][4];
|
||||
|
||||
base= re->scene->base.first;
|
||||
base = re->scene->base.first;
|
||||
while (base) {
|
||||
mult_m4_m4m4(mat, re->viewmat, base->object->obmat);
|
||||
invert_m4_m4(base->object->imat, mat);
|
||||
|
||||
base= base->next;
|
||||
base = base->next;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -420,7 +420,7 @@ static void render_envmap(Render *re, EnvMap *env)
|
||||
/* need a recalc: ortho-render has no correct viewinv */
|
||||
invert_m4_m4(oldviewinv, re->viewmat);
|
||||
|
||||
envre= envmap_render_copy(re, env);
|
||||
envre = envmap_render_copy(re, env);
|
||||
|
||||
/* precalc orthmat for object */
|
||||
copy_m4_m4(orthmat, env->object->obmat);
|
||||
@@ -431,8 +431,8 @@ static void render_envmap(Render *re, EnvMap *env)
|
||||
invert_m4_m4(tmat, mat);
|
||||
copy_m3_m4(env->obimat, tmat);
|
||||
|
||||
for (part=0; part<6; part++) {
|
||||
if (env->type==ENV_PLANE && part!=1)
|
||||
for (part = 0; part < 6; part++) {
|
||||
if (env->type == ENV_PLANE && part != 1)
|
||||
continue;
|
||||
|
||||
re->display_clear(re->dch, envre->result);
|
||||
@@ -456,7 +456,7 @@ static void render_envmap(Render *re, EnvMap *env)
|
||||
env_hideobject(envre, env->object);
|
||||
env_set_imats(envre);
|
||||
|
||||
if (re->test_break(re->tbh)==0) {
|
||||
if (re->test_break(re->tbh) == 0) {
|
||||
RE_TileProcessor(envre);
|
||||
}
|
||||
|
||||
@@ -464,23 +464,23 @@ static void render_envmap(Render *re, EnvMap *env)
|
||||
env_showobjects(envre);
|
||||
env_rotate_scene(envre, tmat, 0);
|
||||
|
||||
if (re->test_break(re->tbh)==0) {
|
||||
RenderLayer *rl= envre->result->layers.first;
|
||||
if (re->test_break(re->tbh) == 0) {
|
||||
RenderLayer *rl = envre->result->layers.first;
|
||||
int y;
|
||||
float *alpha;
|
||||
|
||||
ibuf= IMB_allocImBuf(envre->rectx, envre->recty, 24, IB_rect|IB_rectfloat);
|
||||
ibuf = IMB_allocImBuf(envre->rectx, envre->recty, 24, IB_rect | IB_rectfloat);
|
||||
memcpy(ibuf->rect_float, rl->rectf, ibuf->channels * ibuf->x * ibuf->y * sizeof(float));
|
||||
|
||||
if (re->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)
|
||||
ibuf->profile = IB_PROFILE_LINEAR_RGB;
|
||||
|
||||
/* envmap renders without alpha */
|
||||
alpha= ((float *)ibuf->rect_float)+3;
|
||||
for (y= ibuf->x*ibuf->y - 1; y>=0; y--, alpha+=4)
|
||||
*alpha= 1.0;
|
||||
alpha = ((float *)ibuf->rect_float) + 3;
|
||||
for (y = ibuf->x * ibuf->y - 1; y >= 0; y--, alpha += 4)
|
||||
*alpha = 1.0;
|
||||
|
||||
env->cube[part]= ibuf;
|
||||
env->cube[part] = ibuf;
|
||||
}
|
||||
|
||||
if (re->test_break(re->tbh)) break;
|
||||
@@ -489,9 +489,9 @@ static void render_envmap(Render *re, EnvMap *env)
|
||||
|
||||
if (re->test_break(re->tbh)) BKE_free_envmapdata(env);
|
||||
else {
|
||||
if (envre->r.mode & R_OSA) env->ok= ENV_OSA;
|
||||
else env->ok= ENV_NORMAL;
|
||||
env->lastframe= re->scene->r.cfra;
|
||||
if (envre->r.mode & R_OSA) env->ok = ENV_OSA;
|
||||
else env->ok = ENV_NORMAL;
|
||||
env->lastframe = re->scene->r.cfra;
|
||||
}
|
||||
|
||||
/* restore */
|
||||
@@ -505,27 +505,27 @@ static void render_envmap(Render *re, EnvMap *env)
|
||||
void make_envmaps(Render *re)
|
||||
{
|
||||
Tex *tex;
|
||||
int do_init = FALSE, depth= 0, trace;
|
||||
int do_init = FALSE, depth = 0, trace;
|
||||
|
||||
if (!(re->r.mode & R_ENVMAP)) return;
|
||||
|
||||
/* we don't raytrace, disabling the flag will cause ray_transp render solid */
|
||||
trace= (re->r.mode & R_RAYTRACE);
|
||||
trace = (re->r.mode & R_RAYTRACE);
|
||||
re->r.mode &= ~R_RAYTRACE;
|
||||
|
||||
re->i.infostr= "Creating Environment maps";
|
||||
re->i.infostr = "Creating Environment maps";
|
||||
re->stats_draw(re->sdh, &re->i);
|
||||
|
||||
/* 5 = hardcoded max recursion level */
|
||||
while (depth<5) {
|
||||
tex= re->main->tex.first;
|
||||
while (depth < 5) {
|
||||
tex = re->main->tex.first;
|
||||
while (tex) {
|
||||
if (tex->id.us && tex->type==TEX_ENVMAP) {
|
||||
if (tex->id.us && tex->type == TEX_ENVMAP) {
|
||||
if (tex->env && tex->env->object) {
|
||||
EnvMap *env= tex->env;
|
||||
EnvMap *env = tex->env;
|
||||
|
||||
if (env->object->lay & re->lay) {
|
||||
if (env->stype==ENV_LOAD) {
|
||||
if (env->stype == ENV_LOAD) {
|
||||
float orthmat[4][4], mat[4][4], tmat[4][4];
|
||||
|
||||
/* precalc orthmat for object */
|
||||
@@ -545,31 +545,31 @@ void make_envmaps(Render *re)
|
||||
/* set 'recalc' to make sure it does an entire loop of recalcs */
|
||||
|
||||
if (env->ok) {
|
||||
/* free when OSA, and old one isn't OSA */
|
||||
if ((re->r.mode & R_OSA) && env->ok==ENV_NORMAL)
|
||||
/* free when OSA, and old one isn't OSA */
|
||||
if ((re->r.mode & R_OSA) && env->ok == ENV_NORMAL)
|
||||
BKE_free_envmapdata(env);
|
||||
/* free when size larger */
|
||||
/* free when size larger */
|
||||
else if (env->lastsize < re->r.size)
|
||||
BKE_free_envmapdata(env);
|
||||
/* free when env is in recalcmode */
|
||||
/* free when env is in recalcmode */
|
||||
else if (env->recalc)
|
||||
BKE_free_envmapdata(env);
|
||||
}
|
||||
|
||||
if (env->ok==0 && depth==0) env->recalc= 1;
|
||||
if (env->ok == 0 && depth == 0) env->recalc = 1;
|
||||
|
||||
if (env->ok==0) {
|
||||
if (env->ok == 0) {
|
||||
do_init = TRUE;
|
||||
render_envmap(re, env);
|
||||
|
||||
if (depth==env->depth) env->recalc= 0;
|
||||
if (depth == env->depth) env->recalc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tex= tex->id.next;
|
||||
tex = tex->id.next;
|
||||
}
|
||||
depth++;
|
||||
}
|
||||
@@ -591,55 +591,55 @@ static int envcube_isect(EnvMap *env, const float vec[3], float answ[2])
|
||||
float labda;
|
||||
int face;
|
||||
|
||||
if (env->type==ENV_PLANE) {
|
||||
face= 1;
|
||||
if (env->type == ENV_PLANE) {
|
||||
face = 1;
|
||||
|
||||
labda= 1.0f/vec[2];
|
||||
answ[0]= env->viewscale*labda*vec[0];
|
||||
answ[1]= -env->viewscale*labda*vec[1];
|
||||
labda = 1.0f / vec[2];
|
||||
answ[0] = env->viewscale * labda * vec[0];
|
||||
answ[1] = -env->viewscale * labda * vec[1];
|
||||
}
|
||||
else {
|
||||
/* which face */
|
||||
if ( vec[2] <= -fabsf(vec[0]) && vec[2] <= -fabsf(vec[1]) ) {
|
||||
face= 0;
|
||||
labda= -1.0f/vec[2];
|
||||
answ[0]= labda*vec[0];
|
||||
answ[1]= labda*vec[1];
|
||||
if (vec[2] <= -fabsf(vec[0]) && vec[2] <= -fabsf(vec[1]) ) {
|
||||
face = 0;
|
||||
labda = -1.0f / vec[2];
|
||||
answ[0] = labda * vec[0];
|
||||
answ[1] = labda * vec[1];
|
||||
}
|
||||
else if (vec[2] >= fabsf(vec[0]) && vec[2] >= fabsf(vec[1])) {
|
||||
face= 1;
|
||||
labda= 1.0f/vec[2];
|
||||
answ[0]= labda*vec[0];
|
||||
answ[1]= -labda*vec[1];
|
||||
face = 1;
|
||||
labda = 1.0f / vec[2];
|
||||
answ[0] = labda * vec[0];
|
||||
answ[1] = -labda * vec[1];
|
||||
}
|
||||
else if (vec[1] >= fabsf(vec[0])) {
|
||||
face= 2;
|
||||
labda= 1.0f/vec[1];
|
||||
answ[0]= labda*vec[0];
|
||||
answ[1]= labda*vec[2];
|
||||
face = 2;
|
||||
labda = 1.0f / vec[1];
|
||||
answ[0] = labda * vec[0];
|
||||
answ[1] = labda * vec[2];
|
||||
}
|
||||
else if (vec[0] <= -fabsf(vec[1])) {
|
||||
face= 3;
|
||||
labda= -1.0f/vec[0];
|
||||
answ[0]= labda*vec[1];
|
||||
answ[1]= labda*vec[2];
|
||||
face = 3;
|
||||
labda = -1.0f / vec[0];
|
||||
answ[0] = labda * vec[1];
|
||||
answ[1] = labda * vec[2];
|
||||
}
|
||||
else if (vec[1] <= -fabsf(vec[0])) {
|
||||
face= 4;
|
||||
labda= -1.0f/vec[1];
|
||||
answ[0]= -labda*vec[0];
|
||||
answ[1]= labda*vec[2];
|
||||
face = 4;
|
||||
labda = -1.0f / vec[1];
|
||||
answ[0] = -labda * vec[0];
|
||||
answ[1] = labda * vec[2];
|
||||
}
|
||||
else {
|
||||
face= 5;
|
||||
labda= 1.0f/vec[0];
|
||||
answ[0]= -labda*vec[1];
|
||||
answ[1]= labda*vec[2];
|
||||
face = 5;
|
||||
labda = 1.0f / vec[0];
|
||||
answ[0] = -labda * vec[1];
|
||||
answ[1] = labda * vec[2];
|
||||
}
|
||||
}
|
||||
|
||||
answ[0]= 0.5f+0.5f*answ[0];
|
||||
answ[1]= 0.5f+0.5f*answ[1];
|
||||
answ[0] = 0.5f + 0.5f * answ[0];
|
||||
answ[1] = 0.5f + 0.5f * answ[1];
|
||||
return face;
|
||||
}
|
||||
|
||||
@@ -647,23 +647,23 @@ static int envcube_isect(EnvMap *env, const float vec[3], float answ[2])
|
||||
|
||||
static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int face)
|
||||
{
|
||||
if (face==2 || face==4) {
|
||||
dxts[0]= dxt[0];
|
||||
dyts[0]= dyt[0];
|
||||
dxts[1]= dxt[2];
|
||||
dyts[1]= dyt[2];
|
||||
if (face == 2 || face == 4) {
|
||||
dxts[0] = dxt[0];
|
||||
dyts[0] = dyt[0];
|
||||
dxts[1] = dxt[2];
|
||||
dyts[1] = dyt[2];
|
||||
}
|
||||
else if (face==3 || face==5) {
|
||||
dxts[0]= dxt[1];
|
||||
dxts[1]= dxt[2];
|
||||
dyts[0]= dyt[1];
|
||||
dyts[1]= dyt[2];
|
||||
else if (face == 3 || face == 5) {
|
||||
dxts[0] = dxt[1];
|
||||
dxts[1] = dxt[2];
|
||||
dyts[0] = dyt[1];
|
||||
dyts[1] = dyt[2];
|
||||
}
|
||||
else {
|
||||
dxts[0]= dxt[0];
|
||||
dyts[0]= dyt[0];
|
||||
dxts[1]= dxt[1];
|
||||
dyts[1]= dyt[1];
|
||||
dxts[0] = dxt[0];
|
||||
dyts[0] = dyt[0];
|
||||
dxts[1] = dxt[1];
|
||||
dyts[1] = dyt[1];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,34 +671,34 @@ static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int fac
|
||||
|
||||
int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres)
|
||||
{
|
||||
extern Render R; /* only in this call */
|
||||
extern Render R; /* only in this call */
|
||||
/* texvec should be the already reflected normal */
|
||||
EnvMap *env;
|
||||
ImBuf *ibuf;
|
||||
float fac, vec[3], sco[3], dxts[3], dyts[3];
|
||||
int face, face1;
|
||||
|
||||
env= tex->env;
|
||||
if (env==NULL || (env->stype!=ENV_LOAD && env->object==NULL)) {
|
||||
texres->tin= 0.0;
|
||||
env = tex->env;
|
||||
if (env == NULL || (env->stype != ENV_LOAD && env->object == NULL)) {
|
||||
texres->tin = 0.0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (env->stype==ENV_LOAD) {
|
||||
env->ima= tex->ima;
|
||||
if (env->stype == ENV_LOAD) {
|
||||
env->ima = tex->ima;
|
||||
if (env->ima && env->ima->ok) {
|
||||
if (env->cube[1]==NULL) {
|
||||
ImBuf *ibuf_ima= BKE_image_get_ibuf(env->ima, NULL);
|
||||
if (env->cube[1] == NULL) {
|
||||
ImBuf *ibuf_ima = BKE_image_get_ibuf(env->ima, NULL);
|
||||
if (ibuf_ima)
|
||||
envmap_split_ima(env, ibuf_ima);
|
||||
else
|
||||
env->ok= 0;
|
||||
env->ok = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (env->ok==0) {
|
||||
texres->tin= 0.0;
|
||||
if (env->ok == 0) {
|
||||
texres->tin = 0.0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -707,8 +707,8 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe
|
||||
if (env->object) mul_m3_v3(env->obimat, vec);
|
||||
else mul_mat3_m4_v3(R.viewinv, vec);
|
||||
|
||||
face= envcube_isect(env, vec, sco);
|
||||
ibuf= env->cube[face];
|
||||
face = envcube_isect(env, vec, sco);
|
||||
ibuf = env->cube[face];
|
||||
|
||||
if (osatex) {
|
||||
if (env->object) {
|
||||
@@ -724,45 +724,45 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe
|
||||
|
||||
/* edges? */
|
||||
|
||||
if (texres->ta<1.0f) {
|
||||
if (texres->ta < 1.0f) {
|
||||
TexResult texr1, texr2;
|
||||
|
||||
texr1.nor= texr2.nor= NULL;
|
||||
texr1.talpha= texr2.talpha= texres->talpha; /* boxclip expects this initialized */
|
||||
texr1.nor = texr2.nor = NULL;
|
||||
texr1.talpha = texr2.talpha = texres->talpha; /* boxclip expects this initialized */
|
||||
|
||||
add_v3_v3(vec, dxt);
|
||||
face1= envcube_isect(env, vec, sco);
|
||||
face1 = envcube_isect(env, vec, sco);
|
||||
sub_v3_v3(vec, dxt);
|
||||
|
||||
if (face!=face1) {
|
||||
ibuf= env->cube[face1];
|
||||
if (face != face1) {
|
||||
ibuf = env->cube[face1];
|
||||
set_dxtdyt(dxts, dyts, dxt, dyt, face1);
|
||||
imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, &texr1);
|
||||
}
|
||||
else texr1.tr= texr1.tg= texr1.tb= texr1.ta= 0.0;
|
||||
else texr1.tr = texr1.tg = texr1.tb = texr1.ta = 0.0;
|
||||
|
||||
/* here was the nasty bug! results were not zero-ed. FPE! */
|
||||
|
||||
add_v3_v3(vec, dyt);
|
||||
face1= envcube_isect(env, vec, sco);
|
||||
face1 = envcube_isect(env, vec, sco);
|
||||
sub_v3_v3(vec, dyt);
|
||||
|
||||
if (face!=face1) {
|
||||
ibuf= env->cube[face1];
|
||||
if (face != face1) {
|
||||
ibuf = env->cube[face1];
|
||||
set_dxtdyt(dxts, dyts, dxt, dyt, face1);
|
||||
imagewraposa(tex, NULL, ibuf, sco, dxts, dyts, &texr2);
|
||||
}
|
||||
else texr2.tr= texr2.tg= texr2.tb= texr2.ta= 0.0;
|
||||
else texr2.tr = texr2.tg = texr2.tb = texr2.ta = 0.0;
|
||||
|
||||
fac= (texres->ta+texr1.ta+texr2.ta);
|
||||
if (fac!=0.0f) {
|
||||
fac= 1.0f/fac;
|
||||
fac = (texres->ta + texr1.ta + texr2.ta);
|
||||
if (fac != 0.0f) {
|
||||
fac = 1.0f / fac;
|
||||
|
||||
texres->tr= fac*(texres->ta*texres->tr + texr1.ta*texr1.tr + texr2.ta*texr2.tr );
|
||||
texres->tg= fac*(texres->ta*texres->tg + texr1.ta*texr1.tg + texr2.ta*texr2.tg );
|
||||
texres->tb= fac*(texres->ta*texres->tb + texr1.ta*texr1.tb + texr2.ta*texr2.tb );
|
||||
texres->tr = fac * (texres->ta * texres->tr + texr1.ta * texr1.tr + texr2.ta * texr2.tr);
|
||||
texres->tg = fac * (texres->ta * texres->tg + texr1.ta * texr1.tg + texr2.ta * texr2.tg);
|
||||
texres->tb = fac * (texres->ta * texres->tb + texr1.ta * texr1.tb + texr2.ta * texr2.tb);
|
||||
}
|
||||
texres->ta= 1.0;
|
||||
texres->ta = 1.0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -771,7 +771,3 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* eof */
|
||||
|
||||
@@ -71,7 +71,7 @@ extern struct Render R;
|
||||
/* luminance rec. 709 */
|
||||
BLI_INLINE float luminance(const float col[3])
|
||||
{
|
||||
return (0.212671f*col[0] + 0.71516f*col[1] + 0.072169f*col[2]);
|
||||
return (0.212671f * col[0] + 0.71516f * col[1] + 0.072169f * col[2]);
|
||||
}
|
||||
|
||||
/* tracing */
|
||||
@@ -80,7 +80,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3])
|
||||
float visibility = 1.f;
|
||||
|
||||
if (lar->shb) {
|
||||
float dxco[3]={0.f, 0.f, 0.f}, dyco[3]={0.f, 0.f, 0.f};
|
||||
float dxco[3] = {0.f, 0.f, 0.f}, dyco[3] = {0.f, 0.f, 0.f};
|
||||
|
||||
visibility = testshadowbuf(&R, lar->shb, co, dxco, dyco, 1.0, 0.0);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3])
|
||||
Isect is;
|
||||
|
||||
copy_v3_v3(is.start, co);
|
||||
if (lar->type==LA_SUN || lar->type==LA_HEMI) {
|
||||
if (lar->type == LA_SUN || lar->type == LA_HEMI) {
|
||||
is.dir[0] = -lar->vec[0];
|
||||
is.dir[1] = -lar->vec[1];
|
||||
is.dir[2] = -lar->vec[2];
|
||||
@@ -97,17 +97,17 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3])
|
||||
}
|
||||
else {
|
||||
sub_v3_v3v3(is.dir, lar->co, is.start);
|
||||
is.dist = normalize_v3(is.dir );
|
||||
is.dist = normalize_v3(is.dir);
|
||||
}
|
||||
|
||||
is.mode = RE_RAY_MIRROR;
|
||||
is.check = RE_CHECK_VLR_NON_SOLID_MATERIAL;
|
||||
is.skip = 0;
|
||||
|
||||
if (lar->mode & (LA_LAYER|LA_LAYER_SHADOW))
|
||||
is.lay= lar->lay;
|
||||
if (lar->mode & (LA_LAYER | LA_LAYER_SHADOW))
|
||||
is.lay = lar->lay;
|
||||
else
|
||||
is.lay= -1;
|
||||
is.lay = -1;
|
||||
|
||||
is.orig.ob = NULL;
|
||||
is.orig.face = NULL;
|
||||
@@ -117,7 +117,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3])
|
||||
visibility = 0.f;
|
||||
}
|
||||
|
||||
lar->last_hit[shi->thread]= is.last_hit;
|
||||
lar->last_hit[shi->thread] = is.last_hit;
|
||||
}
|
||||
return visibility;
|
||||
}
|
||||
@@ -128,26 +128,26 @@ static int vol_get_bounds(ShadeInput *shi, const float co[3], const float vec[3]
|
||||
copy_v3_v3(isect->start, co);
|
||||
copy_v3_v3(isect->dir, vec);
|
||||
isect->dist = FLT_MAX;
|
||||
isect->mode= RE_RAY_MIRROR;
|
||||
isect->mode = RE_RAY_MIRROR;
|
||||
isect->last_hit = NULL;
|
||||
isect->lay= -1;
|
||||
isect->check= RE_CHECK_VLR_NONE;
|
||||
isect->lay = -1;
|
||||
isect->check = RE_CHECK_VLR_NONE;
|
||||
|
||||
if (intersect_type == VOL_BOUNDS_DEPTH) {
|
||||
isect->skip = RE_SKIP_VLR_NEIGHBOUR;
|
||||
isect->orig.face = (void*)shi->vlr;
|
||||
isect->orig.ob = (void*)shi->obi;
|
||||
isect->orig.face = (void *)shi->vlr;
|
||||
isect->orig.ob = (void *)shi->obi;
|
||||
}
|
||||
else { // if (intersect_type == VOL_BOUNDS_SS) {
|
||||
isect->skip= 0;
|
||||
isect->orig.face= NULL;
|
||||
isect->skip = 0;
|
||||
isect->orig.face = NULL;
|
||||
isect->orig.ob = NULL;
|
||||
}
|
||||
|
||||
if (RE_rayobject_raycast(R.raytree, isect)) {
|
||||
hitco[0] = isect->start[0] + isect->dist*isect->dir[0];
|
||||
hitco[1] = isect->start[1] + isect->dist*isect->dir[1];
|
||||
hitco[2] = isect->start[2] + isect->dist*isect->dir[2];
|
||||
hitco[0] = isect->start[0] + isect->dist * isect->dir[0];
|
||||
hitco[1] = isect->start[1] + isect->dist * isect->dir[1];
|
||||
hitco[2] = isect->start[2] + isect->dist * isect->dir[2];
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
@@ -162,18 +162,18 @@ static void shade_intersection(ShadeInput *shi, float col_r[4], Isect *is)
|
||||
|
||||
memset(&shi_new, 0, sizeof(ShadeInput));
|
||||
|
||||
shi_new.mask= shi->mask;
|
||||
shi_new.osatex= shi->osatex;
|
||||
shi_new.thread= shi->thread;
|
||||
shi_new.mask = shi->mask;
|
||||
shi_new.osatex = shi->osatex;
|
||||
shi_new.thread = shi->thread;
|
||||
shi_new.depth = shi->depth + 1;
|
||||
shi_new.volume_depth= shi->volume_depth + 1;
|
||||
shi_new.xs= shi->xs;
|
||||
shi_new.ys= shi->ys;
|
||||
shi_new.lay= shi->lay;
|
||||
shi_new.passflag= SCE_PASS_COMBINED; /* result of tracing needs no pass info */
|
||||
shi_new.combinedflag= 0xFFFFFF; /* ray trace does all options */
|
||||
shi_new.light_override= shi->light_override;
|
||||
shi_new.mat_override= shi->mat_override;
|
||||
shi_new.volume_depth = shi->volume_depth + 1;
|
||||
shi_new.xs = shi->xs;
|
||||
shi_new.ys = shi->ys;
|
||||
shi_new.lay = shi->lay;
|
||||
shi_new.passflag = SCE_PASS_COMBINED; /* result of tracing needs no pass info */
|
||||
shi_new.combinedflag = 0xFFFFFF; /* ray trace does all options */
|
||||
shi_new.light_override = shi->light_override;
|
||||
shi_new.mat_override = shi->mat_override;
|
||||
|
||||
copy_v3_v3(shi_new.camera_co, is->start);
|
||||
|
||||
@@ -196,13 +196,13 @@ static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], f
|
||||
copy_v3_v3(isect.dir, shi->view);
|
||||
isect.dist = FLT_MAX;
|
||||
|
||||
isect.mode= RE_RAY_MIRROR;
|
||||
isect.mode = RE_RAY_MIRROR;
|
||||
isect.check = RE_CHECK_VLR_NONE;
|
||||
isect.skip = RE_SKIP_VLR_NEIGHBOUR;
|
||||
isect.orig.ob = (void*) shi->obi;
|
||||
isect.orig.face = (void*)vlr;
|
||||
isect.orig.ob = (void *) shi->obi;
|
||||
isect.orig.face = (void *)vlr;
|
||||
isect.last_hit = NULL;
|
||||
isect.lay= -1;
|
||||
isect.lay = -1;
|
||||
|
||||
/* check to see if there's anything behind the volume, otherwise shade the sky */
|
||||
if (RE_rayobject_raycast(R.raytree, &isect)) {
|
||||
@@ -241,11 +241,11 @@ static void vol_get_precached_scattering(Render *re, ShadeInput *shi, float scat
|
||||
|
||||
/* Meta object density, brute force for now
|
||||
* (might be good enough anyway, don't need huge number of metaobs to model volumetric objects */
|
||||
static float metadensity(Object* ob, const float co[3])
|
||||
static float metadensity(Object *ob, const float co[3])
|
||||
{
|
||||
float mat[4][4], imat[4][4], dens = 0.f;
|
||||
MetaBall* mb = (MetaBall*)ob->data;
|
||||
MetaElem* ml;
|
||||
MetaBall *mb = (MetaBall *)ob->data;
|
||||
MetaElem *ml;
|
||||
|
||||
/* transform co to meta-element */
|
||||
float tco[3] = {co[0], co[1], co[2]};
|
||||
@@ -253,13 +253,13 @@ static float metadensity(Object* ob, const float co[3])
|
||||
invert_m4_m4(imat, mat);
|
||||
mul_m4_v3(imat, tco);
|
||||
|
||||
for (ml = mb->elems.first; ml; ml=ml->next) {
|
||||
for (ml = mb->elems.first; ml; ml = ml->next) {
|
||||
float bmat[3][3], dist2;
|
||||
|
||||
/* element rotation transform */
|
||||
float tp[3] = {ml->x - tco[0], ml->y - tco[1], ml->z - tco[2]};
|
||||
quat_to_mat3(bmat, ml->quat);
|
||||
transpose_m3(bmat); // rot.only, so inverse == transpose
|
||||
transpose_m3(bmat); // rot.only, so inverse == transpose
|
||||
mul_m3_v3(bmat, tp);
|
||||
|
||||
/* MB_BALL default */
|
||||
@@ -269,10 +269,10 @@ static float metadensity(Object* ob, const float co[3])
|
||||
break;
|
||||
case MB_CUBE:
|
||||
tp[2] = (tp[2] > ml->expz) ? (tp[2] - ml->expz) : ((tp[2] < -ml->expz) ? (tp[2] + ml->expz) : 0.f);
|
||||
// no break, xy as plane
|
||||
// no break, xy as plane
|
||||
case MB_PLANE:
|
||||
tp[1] = (tp[1] > ml->expy) ? (tp[1] - ml->expy) : ((tp[1] < -ml->expy) ? (tp[1] + ml->expy) : 0.f);
|
||||
// no break, x as tube
|
||||
// no break, x as tube
|
||||
case MB_TUBE:
|
||||
tp[0] = (tp[0] > ml->expx) ? (tp[0] - ml->expx) : ((tp[0] < -ml->expx) ? (tp[0] + ml->expx) : 0.f);
|
||||
}
|
||||
@@ -280,7 +280,7 @@ static float metadensity(Object* ob, const float co[3])
|
||||
/* ml->rad2 is not set */
|
||||
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;
|
||||
dens += (ml->flag & MB_NEGATIVE) ? -ml->s * dist2 * dist2 * dist2 : ml->s * dist2 * dist2 * dist2;
|
||||
}
|
||||
|
||||
dens -= mb->thresh;
|
||||
@@ -299,7 +299,7 @@ float vol_get_density(struct ShadeInput *shi, const float co[3])
|
||||
if (shi->obi->obr->ob->type == OB_MBALL) {
|
||||
const float md = metadensity(shi->obi->obr->ob, co);
|
||||
if (md < 1.f) density *= md;
|
||||
}
|
||||
}
|
||||
|
||||
return density * density_scale;
|
||||
}
|
||||
@@ -311,11 +311,11 @@ float vol_get_density(struct ShadeInput *shi, const float co[3])
|
||||
static void vol_get_reflection_color(ShadeInput *shi, float ref_col[3], const float co[3])
|
||||
{
|
||||
float scatter = shi->mat->vol.scattering;
|
||||
float reflection= shi->mat->vol.reflection;
|
||||
float reflection = shi->mat->vol.reflection;
|
||||
copy_v3_v3(ref_col, shi->mat->vol.reflection_col);
|
||||
|
||||
if (shi->mat->mapto_textured & (MAP_SCATTERING+MAP_REFLECTION_COL))
|
||||
do_volume_tex(shi, co, MAP_SCATTERING+MAP_REFLECTION_COL, ref_col, &scatter, &R);
|
||||
if (shi->mat->mapto_textured & (MAP_SCATTERING + MAP_REFLECTION_COL))
|
||||
do_volume_tex(shi, co, MAP_SCATTERING + MAP_REFLECTION_COL, ref_col, &scatter, &R);
|
||||
|
||||
/* only one single float parameter at a time... :s */
|
||||
if (shi->mat->mapto_textured & (MAP_REFLECTION))
|
||||
@@ -333,8 +333,8 @@ static void vol_get_emission(ShadeInput *shi, float emission_col[3], const float
|
||||
float emission = shi->mat->vol.emission;
|
||||
copy_v3_v3(emission_col, shi->mat->vol.emission_col);
|
||||
|
||||
if (shi->mat->mapto_textured & (MAP_EMISSION+MAP_EMISSION_COL))
|
||||
do_volume_tex(shi, co, MAP_EMISSION+MAP_EMISSION_COL, emission_col, &emission, &R);
|
||||
if (shi->mat->mapto_textured & (MAP_EMISSION + MAP_EMISSION_COL))
|
||||
do_volume_tex(shi, co, MAP_EMISSION + MAP_EMISSION_COL, emission_col, &emission, &R);
|
||||
|
||||
emission_col[0] = emission_col[0] * emission;
|
||||
emission_col[1] = emission_col[1] * emission;
|
||||
@@ -353,8 +353,8 @@ static void vol_get_sigma_t(ShadeInput *shi, float sigma_t[3], const float co[3]
|
||||
float transmission_col[3] = {shi->mat->vol.transmission_col[0], shi->mat->vol.transmission_col[1], shi->mat->vol.transmission_col[2]};
|
||||
float scattering = shi->mat->vol.scattering;
|
||||
|
||||
if (shi->mat->mapto_textured & (MAP_SCATTERING+MAP_TRANSMISSION_COL))
|
||||
do_volume_tex(shi, co, MAP_SCATTERING+MAP_TRANSMISSION_COL, transmission_col, &scattering, &R);
|
||||
if (shi->mat->mapto_textured & (MAP_SCATTERING + MAP_TRANSMISSION_COL))
|
||||
do_volume_tex(shi, co, MAP_SCATTERING + MAP_TRANSMISSION_COL, transmission_col, &scattering, &R);
|
||||
|
||||
sigma_t[0] = (1.0f - transmission_col[0]) + scattering;
|
||||
sigma_t[1] = (1.0f - transmission_col[1]) + scattering;
|
||||
@@ -378,13 +378,13 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3
|
||||
* until Blender's shading system supports this better. --matt
|
||||
*/
|
||||
|
||||
if (g == 0.f) { /* isotropic */
|
||||
if (g == 0.f) { /* isotropic */
|
||||
return normalize * 1.f;
|
||||
}
|
||||
else { /* schlick */
|
||||
else { /* schlick */
|
||||
const float k = 1.55f * g - .55f * g * g * g;
|
||||
const float kcostheta = k * dot_v3v3(w, wp);
|
||||
return normalize * (1.f - k*k) / ((1.f - kcostheta) * (1.f - kcostheta));
|
||||
return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta));
|
||||
}
|
||||
|
||||
/* not used, but here for reference: */
|
||||
@@ -395,14 +395,14 @@ static float vol_get_phasefunc(ShadeInput *UNUSED(shi), float g, const float w[3
|
||||
case MA_VOL_PH_MIEMURKY:
|
||||
return normalize * (0.5f + 16.5f * powf(0.5 * (1.f + costheta), 32.f));
|
||||
case MA_VOL_PH_RAYLEIGH:
|
||||
return normalize * 3.f/4.f * (1 + costheta * costheta);
|
||||
return normalize * 3.f / 4.f * (1 + costheta * costheta);
|
||||
case MA_VOL_PH_HG:
|
||||
return normalize * (1.f - g * g) / powf(1.f + g * g - 2.f * g * costheta, 1.5f);
|
||||
case MA_VOL_PH_SCHLICK:
|
||||
{
|
||||
const float k = 1.55f * g - .55f * g * g * g;
|
||||
const float kcostheta = k * costheta;
|
||||
return normalize * (1.f - k*k) / ((1.f - kcostheta) * (1.f - kcostheta));
|
||||
return normalize * (1.f - k * k) / ((1.f - kcostheta) * (1.f - kcostheta));
|
||||
}
|
||||
case MA_VOL_PH_ISOTROPIC:
|
||||
default:
|
||||
@@ -471,20 +471,20 @@ static void vol_get_transmittance(ShadeInput *shi, float tr[3], const float co[3
|
||||
static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const float view[3], LampRen *lar, float lacol[3])
|
||||
{
|
||||
float visifac, lv[3], lampdist;
|
||||
float tr[3]={1.0, 1.0, 1.0};
|
||||
float tr[3] = {1.0, 1.0, 1.0};
|
||||
float hitco[3], *atten_co;
|
||||
float p, ref_col[3];
|
||||
|
||||
if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay)==0) return;
|
||||
if ((lar->lay & shi->lay)==0) return;
|
||||
if (lar->mode & LA_LAYER) if ((lar->lay & shi->obi->lay) == 0) return;
|
||||
if ((lar->lay & shi->lay) == 0) return;
|
||||
if (lar->energy == 0.0f) return;
|
||||
|
||||
if ((visifac= lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return;
|
||||
if ((visifac = lamp_get_visibility(lar, co, lv, &lampdist)) == 0.f) return;
|
||||
|
||||
copy_v3_v3(lacol, &lar->r);
|
||||
|
||||
if (lar->mode & LA_TEXTURE) {
|
||||
shi->osatex= 0;
|
||||
shi->osatex = 0;
|
||||
do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE);
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ static void vol_shade_one_lamp(struct ShadeInput *shi, const float co[3], const
|
||||
if (ELEM(lar->type, LA_SUN, LA_HEMI))
|
||||
/* infinite lights, can never be inside volume */
|
||||
atten_co = hitco;
|
||||
else if ( lampdist < dist ) {
|
||||
else if (lampdist < dist) {
|
||||
atten_co = lar->co;
|
||||
}
|
||||
else
|
||||
@@ -558,10 +558,10 @@ void vol_get_scattering(ShadeInput *shi, float scatter_col[3], const float co[3]
|
||||
|
||||
zero_v3(scatter_col);
|
||||
|
||||
lights= get_lights(shi);
|
||||
for (go=lights->first; go; go= go->next) {
|
||||
lights = get_lights(shi);
|
||||
for (go = lights->first; go; go = go->next) {
|
||||
float lacol[3] = {0.f, 0.f, 0.f};
|
||||
lar= go->lampren;
|
||||
lar = go->lampren;
|
||||
|
||||
if (lar) {
|
||||
vol_shade_one_lamp(shi, co, view, lar, lacol);
|
||||
@@ -598,7 +598,7 @@ static void volumeintegrate(struct ShadeInput *shi, float col[4], const float co
|
||||
|
||||
float t0 = 0.f;
|
||||
float pt0 = t0;
|
||||
float t1 = normalize_v3(step_vec); /* returns vector length */
|
||||
float t1 = normalize_v3(step_vec); /* returns vector length */
|
||||
|
||||
t0 += stepsize * ((shi->mat->vol.stepsize_type == MA_VOL_STEP_CONSTANT) ? 0.5f : BLI_thread_frand(shi->thread));
|
||||
p[0] += t0 * step_vec[0];
|
||||
@@ -656,7 +656,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in
|
||||
float hitco[3], col[4] = {0.f, 0.f, 0.f, 0.f};
|
||||
float *startco, *endco;
|
||||
int trace_behind = 1;
|
||||
const int ztransp= ((shi->depth==0) && (shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_ZTRANSP));
|
||||
const int ztransp = ((shi->depth == 0) && (shi->mat->mode & MA_TRANSP) && (shi->mat->mode & MA_ZTRANSP));
|
||||
Isect is;
|
||||
|
||||
/* check for shading an internal face a volume object directly */
|
||||
@@ -669,7 +669,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in
|
||||
|
||||
if (ztransp && inside_volume == VOL_SHADE_INSIDE) {
|
||||
MatInside *mi;
|
||||
int render_this=0;
|
||||
int render_this = 0;
|
||||
|
||||
/* don't render the backfaces of ztransp volume materials.
|
||||
*
|
||||
@@ -683,9 +683,9 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in
|
||||
* which would otherwise render the volume in between the camera and the backface
|
||||
* --matt */
|
||||
|
||||
for (mi=R.render_volumes_inside.first; mi; mi=mi->next) {
|
||||
for (mi = R.render_volumes_inside.first; mi; mi = mi->next) {
|
||||
/* weak... */
|
||||
if (mi->ma == shi->mat) render_this=1;
|
||||
if (mi->ma == shi->mat) render_this = 1;
|
||||
}
|
||||
if (!render_this) return;
|
||||
}
|
||||
@@ -733,7 +733,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in
|
||||
}
|
||||
|
||||
if (ztransp)
|
||||
col[3] = col[3]>1.f?1.f:col[3];
|
||||
col[3] = col[3] > 1.f ? 1.f : col[3];
|
||||
else
|
||||
col[3] = 1.f;
|
||||
|
||||
@@ -749,7 +749,7 @@ void shade_volume_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct
|
||||
{
|
||||
float hitco[3];
|
||||
float tr[3] = {1.0, 1.0, 1.0};
|
||||
Isect is= {{0}};
|
||||
Isect is = {{0}};
|
||||
float *startco, *endco;
|
||||
|
||||
memset(shr, 0, sizeof(ShadeResult));
|
||||
@@ -825,5 +825,3 @@ void shade_volume_inside(ShadeInput *shi, ShadeResult *shr)
|
||||
shi->obi = obi_backup;
|
||||
shi->obr = obi_backup->obr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@
|
||||
static int is_vd_res_ok(VoxelData *vd)
|
||||
{
|
||||
/* arbitrary large value so corrupt headers don't break */
|
||||
const int min= 1, max= 100000;
|
||||
return (vd->resol[0] >= min && vd->resol[0] <= max) &&
|
||||
(vd->resol[1] >= min && vd->resol[1] <= max) &&
|
||||
(vd->resol[2] >= min && vd->resol[2] <= max);
|
||||
const int min = 1, max = 100000;
|
||||
return (vd->resol[0] >= min && vd->resol[0] <= max) &&
|
||||
(vd->resol[1] >= min && vd->resol[1] <= max) &&
|
||||
(vd->resol[2] >= min && vd->resol[2] <= max);
|
||||
}
|
||||
|
||||
/* use size_t because the result may exceed INT_MAX */
|
||||
@@ -86,10 +86,10 @@ static int load_frame_blendervoxel(VoxelData *vd, FILE *fp, int frame)
|
||||
if (is_vd_res_ok(vd) == FALSE)
|
||||
return 0;
|
||||
|
||||
vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset");
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset");
|
||||
if (vd->dataset == NULL) return 0;
|
||||
|
||||
if (fseek(fp, frame*size*sizeof(float)+offset, 0) == -1)
|
||||
if (fseek(fp, frame * size * sizeof(float) + offset, 0) == -1)
|
||||
return 0;
|
||||
if (fread(vd->dataset, sizeof(float), size, fp) != size)
|
||||
return 0;
|
||||
@@ -108,29 +108,29 @@ static int load_frame_raw8(VoxelData *vd, FILE *fp, int frame)
|
||||
if (is_vd_res_ok(vd) == FALSE)
|
||||
return 0;
|
||||
|
||||
vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset");
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * size, "voxel dataset");
|
||||
if (vd->dataset == NULL) return 0;
|
||||
data_c = (char *)MEM_mallocN(sizeof(char)*size, "temporary voxel file reading storage");
|
||||
data_c = (char *)MEM_mallocN(sizeof(char) * size, "temporary voxel file reading storage");
|
||||
if (data_c == NULL) {
|
||||
MEM_freeN(vd->dataset);
|
||||
vd->dataset= NULL;
|
||||
vd->dataset = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fseek(fp, (frame-1)*size*sizeof(char), 0) == -1) {
|
||||
if (fseek(fp, (frame - 1) * size * sizeof(char), 0) == -1) {
|
||||
MEM_freeN(data_c);
|
||||
MEM_freeN(vd->dataset);
|
||||
vd->dataset= NULL;
|
||||
vd->dataset = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (fread(data_c, sizeof(char), size, fp) != size) {
|
||||
MEM_freeN(data_c);
|
||||
MEM_freeN(vd->dataset);
|
||||
vd->dataset= NULL;
|
||||
vd->dataset = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i=0; i<size; i++) {
|
||||
for (i = 0; i < size; i++) {
|
||||
vd->dataset[i] = (float)data_c[i] / 255.f;
|
||||
}
|
||||
MEM_freeN(data_c);
|
||||
@@ -146,7 +146,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex)
|
||||
Image *ima = tex->ima;
|
||||
ImageUser *tiuser = &tex->iuser;
|
||||
ImageUser iuser = *(tiuser);
|
||||
int x=0, y=0, z=0;
|
||||
int x = 0, y = 0, z = 0;
|
||||
float *rf;
|
||||
|
||||
if (!ima || !tiuser) return;
|
||||
@@ -157,10 +157,10 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex)
|
||||
|
||||
/* find the first valid ibuf and use it to initialize the resolution of the data set */
|
||||
/* need to do this in advance so we know how much memory to allocate */
|
||||
ibuf= BKE_image_get_ibuf(ima, &iuser);
|
||||
ibuf = BKE_image_get_ibuf(ima, &iuser);
|
||||
while (!ibuf && (iuser.framenr < iuser.frames)) {
|
||||
iuser.framenr++;
|
||||
ibuf= BKE_image_get_ibuf(ima, &iuser);
|
||||
ibuf = BKE_image_get_ibuf(ima, &iuser);
|
||||
}
|
||||
if (!ibuf) return;
|
||||
if (!ibuf->rect_float) IMB_float_from_rect(ibuf);
|
||||
@@ -169,23 +169,23 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex)
|
||||
vd->resol[0] = ibuf->x;
|
||||
vd->resol[1] = ibuf->y;
|
||||
vd->resol[2] = iuser.frames;
|
||||
vd->dataset = MEM_mapallocN(sizeof(float)*vd_resol_size(vd), "voxel dataset");
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * vd_resol_size(vd), "voxel dataset");
|
||||
|
||||
for (z=0; z < iuser.frames; z++) {
|
||||
for (z = 0; z < iuser.frames; z++) {
|
||||
/* get a new ibuf for each frame */
|
||||
if (z > 0) {
|
||||
iuser.framenr++;
|
||||
ibuf= BKE_image_get_ibuf(ima, &iuser);
|
||||
ibuf = BKE_image_get_ibuf(ima, &iuser);
|
||||
if (!ibuf) break;
|
||||
if (!ibuf->rect_float) IMB_float_from_rect(ibuf);
|
||||
}
|
||||
rf = ibuf->rect_float;
|
||||
|
||||
for (y=0; y < ibuf->y; y++) {
|
||||
for (x=0; x < ibuf->x; x++) {
|
||||
for (y = 0; y < ibuf->y; y++) {
|
||||
for (x = 0; x < ibuf->x; x++) {
|
||||
/* currently averaged to monchrome */
|
||||
vd->dataset[ BLI_VOXEL_INDEX(x, y, z, vd->resol) ] = (rf[0] + rf[1] + rf[2]) * 0.333f;
|
||||
rf +=4;
|
||||
vd->dataset[BLI_VOXEL_INDEX(x, y, z, vd->resol)] = (rf[0] + rf[1] + rf[2]) * 0.333f;
|
||||
rf += 4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex)
|
||||
|
||||
static int read_voxeldata_header(FILE *fp, struct VoxelData *vd)
|
||||
{
|
||||
VoxelDataHeader *h=(VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header");
|
||||
VoxelDataHeader *h = (VoxelDataHeader *)MEM_mallocN(sizeof(VoxelDataHeader), "voxel data header");
|
||||
|
||||
rewind(fp);
|
||||
if (fread(h, sizeof(VoxelDataHeader), 1, fp) != 1) {
|
||||
@@ -206,9 +206,9 @@ static int read_voxeldata_header(FILE *fp, struct VoxelData *vd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
vd->resol[0]=h->resolX;
|
||||
vd->resol[1]=h->resolY;
|
||||
vd->resol[2]=h->resolZ;
|
||||
vd->resol[0] = h->resolX;
|
||||
vd->resol[1] = h->resolY;
|
||||
vd->resol[2] = h->resolZ;
|
||||
|
||||
MEM_freeN(h);
|
||||
return 1;
|
||||
@@ -221,8 +221,8 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
ModifierData *md;
|
||||
|
||||
vd->dataset = NULL;
|
||||
if (vd->object == NULL) return;
|
||||
ob= vd->object;
|
||||
if (vd->object == NULL) return;
|
||||
ob = vd->object;
|
||||
|
||||
/* draw code for smoke */
|
||||
if ((md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke))) {
|
||||
@@ -231,23 +231,23 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
|
||||
if (smd->domain && smd->domain->fluid) {
|
||||
if (cfra < smd->domain->point_cache[0]->startframe)
|
||||
; /* don't show smoke before simulation starts, this could be made an option in the future */
|
||||
; /* don't show smoke before simulation starts, this could be made an option in the future */
|
||||
else if (vd->smoked_type == TEX_VD_SMOKEHEAT) {
|
||||
size_t totRes;
|
||||
size_t i;
|
||||
float *heat;
|
||||
|
||||
copy_v3_v3_int(vd->resol, smd->domain->res);
|
||||
totRes= vd_resol_size(vd);
|
||||
totRes = vd_resol_size(vd);
|
||||
|
||||
// scaling heat values from -2.0-2.0 to 0.0-1.0
|
||||
vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
|
||||
|
||||
|
||||
heat = smoke_get_heat(smd->domain->fluid);
|
||||
|
||||
for (i=0; i<totRes; i++) {
|
||||
vd->dataset[i] = (heat[i]+2.0f)/4.0f;
|
||||
for (i = 0; i < totRes; i++) {
|
||||
vd->dataset[i] = (heat[i] + 2.0f) / 4.0f;
|
||||
}
|
||||
|
||||
//vd->dataset = smoke_get_heat(smd->domain->fluid);
|
||||
@@ -258,17 +258,17 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
float *xvel, *yvel, *zvel;
|
||||
|
||||
copy_v3_v3_int(vd->resol, smd->domain->res);
|
||||
totRes= vd_resol_size(vd);
|
||||
totRes = vd_resol_size(vd);
|
||||
|
||||
// scaling heat values from -2.0-2.0 to 0.0-1.0
|
||||
vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
|
||||
|
||||
xvel = smoke_get_velocity_x(smd->domain->fluid);
|
||||
yvel = smoke_get_velocity_y(smd->domain->fluid);
|
||||
zvel = smoke_get_velocity_z(smd->domain->fluid);
|
||||
|
||||
for (i=0; i<totRes; i++) {
|
||||
vd->dataset[i] = sqrt(xvel[i]*xvel[i] + yvel[i]*yvel[i] + zvel[i]*zvel[i])*3.0f;
|
||||
for (i = 0; i < totRes; i++) {
|
||||
vd->dataset[i] = sqrt(xvel[i] * xvel[i] + yvel[i] * yvel[i] + zvel[i] * zvel[i]) * 3.0f;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -286,10 +286,10 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
}
|
||||
|
||||
/* TODO: is_vd_res_ok(rvd) doesnt check this resolution */
|
||||
totRes= vd_resol_size(vd);
|
||||
totRes = vd_resol_size(vd);
|
||||
/* always store copy, as smoke internal data can change */
|
||||
vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
|
||||
memcpy(vd->dataset, density, sizeof(float)*totRes);
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
|
||||
memcpy(vd->dataset, density, sizeof(float) * totRes);
|
||||
} // end of fluid condition
|
||||
}
|
||||
}
|
||||
@@ -300,7 +300,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
(void)vd;
|
||||
(void)cfra;
|
||||
|
||||
vd->dataset= NULL;
|
||||
vd->dataset = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ void cache_voxeldata(Tex *tex, int scene_frame)
|
||||
if (!fp) return;
|
||||
|
||||
if (read_voxeldata_header(fp, vd))
|
||||
load_frame_blendervoxel(vd, fp, curframe-1);
|
||||
load_frame_blendervoxel(vd, fp, curframe - 1);
|
||||
|
||||
fclose(fp);
|
||||
return;
|
||||
@@ -362,17 +362,17 @@ void make_voxeldata(struct Render *re)
|
||||
{
|
||||
Tex *tex;
|
||||
|
||||
re->i.infostr= "Loading voxel datasets";
|
||||
re->i.infostr = "Loading voxel datasets";
|
||||
re->stats_draw(re->sdh, &re->i);
|
||||
|
||||
/* XXX: should be doing only textures used in this render */
|
||||
for (tex= re->main->tex.first; tex; tex= tex->id.next) {
|
||||
if (tex->id.us && tex->type==TEX_VOXELDATA) {
|
||||
for (tex = re->main->tex.first; tex; tex = tex->id.next) {
|
||||
if (tex->id.us && tex->type == TEX_VOXELDATA) {
|
||||
cache_voxeldata(tex, re->r.cfra);
|
||||
}
|
||||
}
|
||||
|
||||
re->i.infostr= NULL;
|
||||
re->i.infostr = NULL;
|
||||
re->stats_draw(re->sdh, &re->i);
|
||||
|
||||
}
|
||||
@@ -383,7 +383,7 @@ int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texre
|
||||
VoxelData *vd = tex->vd;
|
||||
float co[3], offset[3] = {0.5, 0.5, 0.5};
|
||||
|
||||
if (vd->dataset==NULL) {
|
||||
if (vd->dataset == NULL) {
|
||||
texres->tin = 0.0f;
|
||||
return 0;
|
||||
}
|
||||
@@ -448,5 +448,3 @@ int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texre
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user