svn merge ^/trunk/blender -r49118:49143
This commit is contained in:
@@ -172,7 +172,7 @@ General functions
|
||||
|
||||
Restarts the current game by reloading the .blend file (the last saved version, not what is currently running).
|
||||
|
||||
.. function:: LibLoad(blend, type, data, load_actions=False, verbose=False)
|
||||
.. function:: LibLoad(blend, type, data, load_actions=False, verbose=False, load_scripts=True)
|
||||
|
||||
Converts the all of the datablocks of the given type from the given blend.
|
||||
|
||||
@@ -186,6 +186,8 @@ General functions
|
||||
:type load_actions: bool
|
||||
:arg verbose: Whether or not to print debugging information (e.g., "SceneName: Scene")
|
||||
:type verbose: bool
|
||||
:arg load_scripts: Whether or not to load text datablocks as well (can be disabled for some extra security)
|
||||
:type load_scripts: bool
|
||||
|
||||
.. function:: LibNew(name, type, data)
|
||||
|
||||
|
||||
@@ -306,6 +306,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion)
|
||||
for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end(); ++b_ob) {
|
||||
bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render();
|
||||
uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), object_is_light(*b_ob));
|
||||
CYCLES_LOCAL_LAYER_HACK(render_layer.use_localview, ob_layer);
|
||||
hide = hide || !(ob_layer & scene_layer);
|
||||
|
||||
if(!hide) {
|
||||
|
||||
@@ -220,7 +220,9 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer)
|
||||
layer = layername.c_str();
|
||||
}
|
||||
else {
|
||||
render_layer.use_localview = (b_v3d.local_view() ? true : false);
|
||||
render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view());
|
||||
CYCLES_LOCAL_LAYER_HACK(render_layer.use_localview, render_layer.scene_layer);
|
||||
render_layer.layer = render_layer.scene_layer;
|
||||
render_layer.holdout_layer = 0;
|
||||
render_layer.material_override = PointerRNA_NULL;
|
||||
@@ -246,6 +248,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer)
|
||||
render_layer.material_override = b_rlay->material_override();
|
||||
render_layer.use_background = b_rlay->use_sky();
|
||||
render_layer.use_viewport_visibility = false;
|
||||
render_layer.use_localview = false;
|
||||
render_layer.samples = b_rlay->samples();
|
||||
}
|
||||
|
||||
|
||||
@@ -128,10 +128,25 @@ private:
|
||||
BL::Material material_override;
|
||||
bool use_background;
|
||||
bool use_viewport_visibility;
|
||||
bool use_localview;
|
||||
int samples;
|
||||
} render_layer;
|
||||
};
|
||||
|
||||
/* we don't have spare bits for localview (normally 20-28)
|
||||
* because PATH_RAY_LAYER_SHIFT uses 20-32.
|
||||
* So - check if we have localview and if so, shift local
|
||||
* view bits down to 1-8, since this is done for the view
|
||||
* port only - it should be OK and not conflict with
|
||||
* render layers. - Campbell.
|
||||
*
|
||||
* ... as an alternative we could use uint64_t
|
||||
*/
|
||||
#define CYCLES_LOCAL_LAYER_HACK(use_localview, layer) \
|
||||
if (use_localview) { \
|
||||
layer >>= 20; \
|
||||
} (void)0
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
#endif /* __BLENDER_SYNC_H__ */
|
||||
|
||||
@@ -172,6 +172,8 @@ enum PathRayFlag {
|
||||
|
||||
PATH_RAY_ALL = (1|2|4|8|16|32|64|128|256|512),
|
||||
|
||||
/* this gives collisions with localview bits
|
||||
* see: CYCLES_LOCAL_LAYER_HACK(), grr - Campbell */
|
||||
PATH_RAY_LAYER_SHIFT = (32-20)
|
||||
};
|
||||
|
||||
|
||||
@@ -319,7 +319,7 @@ int Armature::addConstraint(const std::string& segment_name, ConstraintCallback
|
||||
return iConstraint;
|
||||
}
|
||||
}
|
||||
if (m_finalized) {
|
||||
if (m_finalized) {
|
||||
if (_freeParam && _param)
|
||||
free(_param);
|
||||
return -1;
|
||||
|
||||
@@ -148,7 +148,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
|
||||
|
||||
col = row.column(align=True)
|
||||
col.operator("object.vertex_group_add", icon='ZOOMIN', text="")
|
||||
col.operator("object.vertex_group_remove", icon='ZOOMOUT', text="")
|
||||
col.operator("object.vertex_group_remove", icon='ZOOMOUT', text="").all = False
|
||||
col.menu("MESH_MT_vertex_group_specials", icon='DOWNARROW_HLT', text="")
|
||||
if group:
|
||||
col.separator()
|
||||
|
||||
@@ -82,7 +82,7 @@ static const char *locales[] = {
|
||||
"spanish", "es",
|
||||
"catalan", "ca_AD",
|
||||
"czech", "cs_CZ",
|
||||
"ptb", "pt",
|
||||
"portuguese", "pt",
|
||||
#if defined(_WIN32) && !defined(FREE_WINDOWS)
|
||||
"Chinese (Simplified)_China.1252", "zh_CN",
|
||||
"Chinese (Traditional)_China.1252", "zh_TW",
|
||||
|
||||
@@ -1458,12 +1458,18 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
|
||||
|
||||
/* particle rotation uses x-axis as the aligned axis, so pre-rotate the object accordingly */
|
||||
if ((part->draw & PART_DRAW_ROTATE_OB) == 0) {
|
||||
float xvec[3], q[4];
|
||||
float xvec[3], q[4], size_mat[4][4], original_size[3];
|
||||
|
||||
mat4_to_size(original_size, obmat);
|
||||
size_to_mat4(size_mat, original_size);
|
||||
|
||||
xvec[0] = -1.f;
|
||||
xvec[1] = xvec[2] = 0;
|
||||
vec_to_quat(q, xvec, ob->trackflag, ob->upflag);
|
||||
quat_to_mat4(obmat, q);
|
||||
obmat[3][3] = 1.0f;
|
||||
|
||||
mult_m4_m4m4(obmat, obmat, size_mat);
|
||||
}
|
||||
|
||||
/* Normal particles and cached hair live in global space so we need to
|
||||
|
||||
@@ -352,10 +352,9 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node
|
||||
static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma);
|
||||
|
||||
/* recursive handling for material nodetree drivers */
|
||||
static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *node, bNodeTree *ntree, Material *rootma)
|
||||
static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *node, bNodeTree *ntree)
|
||||
{
|
||||
bNode *n;
|
||||
Material *ma;
|
||||
|
||||
/* nodetree itself */
|
||||
if (ntree->adt) {
|
||||
@@ -364,14 +363,13 @@ static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *
|
||||
|
||||
/* nodetree's nodes... */
|
||||
for (n = ntree->nodes.first; n; n = n->next) {
|
||||
if (n->id && GS(n->id->name) == ID_MA) {
|
||||
ma = (Material *)n->id;
|
||||
if (ma != rootma) {
|
||||
dag_add_material_driver_relations(dag, node, ma);
|
||||
if (n->id) {
|
||||
if (GS(n->id->name) == ID_MA) {
|
||||
dag_add_material_driver_relations(dag, node, (Material *)n->id);
|
||||
}
|
||||
else if (n->type == NODE_GROUP) {
|
||||
dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id);
|
||||
}
|
||||
}
|
||||
else if (n->type == NODE_GROUP && n->id) {
|
||||
dag_add_material_nodetree_driver_relations(dag, node, (bNodeTree *)n->id, rootma);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -379,6 +377,15 @@ static void dag_add_material_nodetree_driver_relations(DagForest *dag, DagNode *
|
||||
/* recursive handling for material drivers */
|
||||
static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Material *ma)
|
||||
{
|
||||
/* Prevent infinite recursion by checking (and tagging the material) as having been visited
|
||||
* already (see build_dag()). This assumes ma->id.flag & LIB_DOIT isn't set by anything else
|
||||
* in the meantime... [#32017]
|
||||
*/
|
||||
if (ma->id.flag & LIB_DOIT)
|
||||
return;
|
||||
else
|
||||
ma->id.flag |= LIB_DOIT;
|
||||
|
||||
/* material itself */
|
||||
if (ma->adt) {
|
||||
dag_add_driver_relation(ma->adt, dag, node, 1);
|
||||
@@ -390,7 +397,7 @@ static void dag_add_material_driver_relations(DagForest *dag, DagNode *node, Mat
|
||||
|
||||
/* material's nodetree */
|
||||
if (ma->nodetree) {
|
||||
dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree, ma);
|
||||
dag_add_material_nodetree_driver_relations(dag, node, ma->nodetree);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -804,6 +811,9 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask)
|
||||
sce->theDag = dag;
|
||||
}
|
||||
|
||||
/* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later [#32017] */
|
||||
tag_main_idcode(bmain, ID_MA, FALSE);
|
||||
|
||||
/* add base node for scene. scene is always the first node in DAG */
|
||||
scenenode = dag_add_node(dag, sce);
|
||||
|
||||
|
||||
@@ -1056,28 +1056,24 @@ int material_in_material(Material *parmat, Material *mat)
|
||||
/* ****************** */
|
||||
|
||||
/* Update drivers for materials in a nodetree */
|
||||
static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime, Material *rootma)
|
||||
static void material_node_drivers_update(Scene *scene, bNodeTree *ntree, float ctime)
|
||||
{
|
||||
bNode *node;
|
||||
Material *ma;
|
||||
|
||||
/* nodetree itself */
|
||||
if (ntree->adt && ntree->adt->drivers.first) {
|
||||
BKE_animsys_evaluate_animdata(scene, &ntree->id, ntree->adt, ctime, ADT_RECALC_DRIVERS);
|
||||
}
|
||||
|
||||
/* nodes... */
|
||||
/* nodes */
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->id && GS(node->id->name) == ID_MA) {
|
||||
/* TODO: prevent infinite recursion here... */
|
||||
ma = (Material *)node->id;
|
||||
if (ma != rootma) {
|
||||
material_drivers_update(scene, ma, ctime);
|
||||
}
|
||||
}
|
||||
else if (node->type == NODE_GROUP && node->id) {
|
||||
material_node_drivers_update(scene, (bNodeTree *)node->id,
|
||||
ctime, rootma);
|
||||
if (node->id) {
|
||||
if (GS(node->id->name) == ID_MA) {
|
||||
material_drivers_update(scene, (Material *)node->id, ctime);
|
||||
}
|
||||
else if (node->type == NODE_GROUP) {
|
||||
material_node_drivers_update(scene, (bNodeTree *)node->id, ctime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1092,6 +1088,15 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
|
||||
//if (G.f & G_DEBUG)
|
||||
// printf("material_drivers_update(%s, %s)\n", scene->id.name, ma->id.name);
|
||||
|
||||
/* Prevent infinite recursion by checking (and tagging the material) as having been visited already
|
||||
* (see BKE_scene_update_tagged()). This assumes ma->id.flag & LIB_DOIT isn't set by anything else
|
||||
* in the meantime... [#32017]
|
||||
*/
|
||||
if (ma->id.flag & LIB_DOIT)
|
||||
return;
|
||||
else
|
||||
ma->id.flag |= LIB_DOIT;
|
||||
|
||||
/* material itself */
|
||||
if (ma->adt && ma->adt->drivers.first) {
|
||||
BKE_animsys_evaluate_animdata(scene, &ma->id, ma->adt, ctime, ADT_RECALC_DRIVERS);
|
||||
@@ -1099,7 +1104,7 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime)
|
||||
|
||||
/* nodes */
|
||||
if (ma->nodetree) {
|
||||
material_node_drivers_update(scene, ma->nodetree, ctime, ma);
|
||||
material_node_drivers_update(scene, ma->nodetree, ctime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1688,16 +1688,16 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4])
|
||||
|
||||
if (cu->flag & CU_FOLLOW) {
|
||||
#if 0
|
||||
float x1, q[4];
|
||||
float si, q[4];
|
||||
vec_to_quat(quat, dir, ob->trackflag, ob->upflag);
|
||||
|
||||
/* the tilt */
|
||||
normalize_v3(dir);
|
||||
q[0] = (float)cos(0.5 * vec[3]);
|
||||
x1 = (float)sin(0.5 * vec[3]);
|
||||
q[1] = -x1 * dir[0];
|
||||
q[2] = -x1 * dir[1];
|
||||
q[3] = -x1 * dir[2];
|
||||
si = (float)sin(0.5 * vec[3]);
|
||||
q[1] = -si * dir[0];
|
||||
q[2] = -si * dir[1];
|
||||
q[3] = -si * dir[2];
|
||||
mul_qt_qtqt(quat, q, quat);
|
||||
#else
|
||||
quat_apply_track(quat, ob->trackflag, ob->upflag);
|
||||
|
||||
@@ -1031,6 +1031,11 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene)
|
||||
DAG_ids_flush_tagged(bmain);
|
||||
|
||||
scene->physics_settings.quick_cache_step = 0;
|
||||
|
||||
/* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later
|
||||
* when trying to find materials with drivers that need evaluating [#32017]
|
||||
*/
|
||||
tag_main_idcode(bmain, ID_MA, FALSE);
|
||||
|
||||
/* update all objects: drivers, matrices, displists, etc. flags set
|
||||
* by depgraph or manual, no layer check here, gets correct flushed
|
||||
|
||||
@@ -92,7 +92,7 @@ void print_qt(const char *str, const float q[4]);
|
||||
/******************************** Axis Angle *********************************/
|
||||
|
||||
/* conversion */
|
||||
void axis_angle_to_quat(float r[4], const float axis[3], float angle);
|
||||
void axis_angle_to_quat(float r[4], const float axis[3], const float angle);
|
||||
void axis_angle_to_mat3(float R[3][3], const float axis[3], const float angle);
|
||||
void axis_angle_to_mat4(float R[4][4], const float axis[3], const float angle);
|
||||
|
||||
@@ -107,9 +107,7 @@ void single_axis_angle_to_mat3(float R[3][3], const char axis, const float angle
|
||||
/* TODO: the following calls should probably be depreceated sometime */
|
||||
|
||||
/* conversion */
|
||||
void vec_rot_to_quat(float quat[4], const float vec[3], const float phi);
|
||||
void vec_rot_to_mat3(float mat[3][3], const float vec[3], const float phi);
|
||||
void vec_rot_to_mat4(float mat[4][4], const float vec[3], const float phi);
|
||||
|
||||
/******************************** XYZ Eulers *********************************/
|
||||
|
||||
|
||||
@@ -2367,7 +2367,8 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const
|
||||
|
||||
/***************************** View & Projection *****************************/
|
||||
|
||||
void orthographic_m4(float matrix[][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
|
||||
void orthographic_m4(float matrix[][4], const float left, const float right, const float bottom, const float top,
|
||||
const float nearClip, const float farClip)
|
||||
{
|
||||
float Xdelta, Ydelta, Zdelta;
|
||||
|
||||
@@ -2386,7 +2387,8 @@ void orthographic_m4(float matrix[][4], const float left, const float right, con
|
||||
matrix[3][2] = -(farClip + nearClip) / Zdelta;
|
||||
}
|
||||
|
||||
void perspective_m4(float mat[4][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip)
|
||||
void perspective_m4(float mat[4][4], const float left, const float right, const float bottom, const float top,
|
||||
const float nearClip, const float farClip)
|
||||
{
|
||||
float Xdelta, Ydelta, Zdelta;
|
||||
|
||||
|
||||
@@ -166,10 +166,9 @@ void sub_qt_qtqt(float q[4], const float q1[4], const float q2[4])
|
||||
/* angular mult factor */
|
||||
void mul_fac_qt_fl(float q[4], const float fac)
|
||||
{
|
||||
float angle = fac * saacos(q[0]); /* quat[0] = cos(0.5 * angle), but now the 0.5 and 2.0 rule out */
|
||||
|
||||
float co = (float)cos(angle);
|
||||
float si = (float)sin(angle);
|
||||
const float angle = fac * saacos(q[0]); /* quat[0] = cos(0.5 * angle), but now the 0.5 and 2.0 rule out */
|
||||
const float co = cosf(angle);
|
||||
const float si = sinf(angle);
|
||||
q[0] = co;
|
||||
normalize_v3(q + 1);
|
||||
mul_v3_fl(q + 1, si);
|
||||
@@ -342,8 +341,8 @@ void mat3_to_quat_is_ok(float q[4], float wmat[3][3])
|
||||
co = mat[2][2];
|
||||
angle = 0.5f * saacos(co);
|
||||
|
||||
co = (float)cos(angle);
|
||||
si = (float)sin(angle);
|
||||
co = cosf(angle);
|
||||
si = sinf(angle);
|
||||
q1[0] = co;
|
||||
q1[1] = -nor[0] * si; /* negative here, but why? */
|
||||
q1[2] = -nor[1] * si;
|
||||
@@ -357,8 +356,8 @@ void mat3_to_quat_is_ok(float q[4], float wmat[3][3])
|
||||
/* and align x-axes */
|
||||
angle = (float)(0.5 * atan2(mat[0][1], mat[0][0]));
|
||||
|
||||
co = (float)cos(angle);
|
||||
si = (float)sin(angle);
|
||||
co = cosf(angle);
|
||||
si = sinf(angle);
|
||||
q2[0] = co;
|
||||
q2[1] = 0.0f;
|
||||
q2[2] = 0.0f;
|
||||
@@ -483,8 +482,8 @@ void vec_to_quat(float q[4], const float vec[3], short axis, const short upflag)
|
||||
normalize_v3(nor);
|
||||
|
||||
angle = 0.5f * saacos(co);
|
||||
si = (float)sin(angle);
|
||||
q[0] = (float)cos(angle);
|
||||
si = sinf(angle);
|
||||
q[0] = cosf(angle);
|
||||
q[1] = nor[0] * si;
|
||||
q[2] = nor[1] * si;
|
||||
q[3] = nor[2] * si;
|
||||
@@ -615,16 +614,18 @@ void tri_to_quat(float quat[4], const float v1[3], const float v2[3], const floa
|
||||
/* move z-axis to face-normal */
|
||||
normal_tri_v3(vec, v1, v2, v3);
|
||||
|
||||
n[0] = vec[1];
|
||||
n[0] = vec[1];
|
||||
n[1] = -vec[0];
|
||||
n[2] = 0.0f;
|
||||
n[2] = 0.0f;
|
||||
normalize_v3(n);
|
||||
|
||||
if (n[0] == 0.0f && n[1] == 0.0f) n[0] = 1.0f;
|
||||
if (n[0] == 0.0f && n[1] == 0.0f) {
|
||||
n[0] = 1.0f;
|
||||
}
|
||||
|
||||
angle = -0.5f * (float)saacos(vec[2]);
|
||||
co = (float)cos(angle);
|
||||
si = (float)sin(angle);
|
||||
co = cosf(angle);
|
||||
si = sinf(angle);
|
||||
q1[0] = co;
|
||||
q1[1] = n[0] * si;
|
||||
q1[2] = n[1] * si;
|
||||
@@ -641,8 +642,8 @@ void tri_to_quat(float quat[4], const float v1[3], const float v2[3], const floa
|
||||
normalize_v3(vec);
|
||||
|
||||
angle = (float)(0.5 * atan2(vec[1], vec[0]));
|
||||
co = (float)cos(angle);
|
||||
si = (float)sin(angle);
|
||||
co = cosf(angle);
|
||||
si = sinf(angle);
|
||||
q2[0] = co;
|
||||
q2[1] = 0.0f;
|
||||
q2[2] = 0.0f;
|
||||
@@ -659,22 +660,21 @@ void print_qt(const char *str, const float q[4])
|
||||
/******************************** Axis Angle *********************************/
|
||||
|
||||
/* Axis angle to Quaternions */
|
||||
void axis_angle_to_quat(float q[4], const float axis[3], float angle)
|
||||
void axis_angle_to_quat(float q[4], const float axis[3], const float angle)
|
||||
{
|
||||
float nor[3];
|
||||
float si;
|
||||
|
||||
if (normalize_v3_v3(nor, axis) == 0.0f) {
|
||||
unit_qt(q);
|
||||
return;
|
||||
if (LIKELY(normalize_v3_v3(q + 1, axis) != 0.0f)) {
|
||||
const float phi = angle / 2.0f;
|
||||
float si;
|
||||
si = sinf(phi);
|
||||
q[0] = cosf(phi);
|
||||
q[1] *= si;
|
||||
q[2] *= si;
|
||||
q[3] *= si;
|
||||
}
|
||||
else {
|
||||
unit_qt(q);
|
||||
}
|
||||
|
||||
angle /= 2;
|
||||
si = (float)sin(angle);
|
||||
q[0] = (float)cos(angle);
|
||||
q[1] = nor[0] * si;
|
||||
q[2] = nor[1] * si;
|
||||
q[3] = nor[2] * si;
|
||||
}
|
||||
|
||||
/* Quaternions to Axis Angle */
|
||||
@@ -689,8 +689,8 @@ void quat_to_axis_angle(float axis[3], float *angle, const float q[4])
|
||||
#endif
|
||||
|
||||
/* calculate angle/2, and sin(angle/2) */
|
||||
ha = (float)acos(q[0]);
|
||||
si = (float)sin(ha);
|
||||
ha = acosf(q[0]);
|
||||
si = sinf(ha);
|
||||
|
||||
/* from half-angle to angle */
|
||||
*angle = ha * 2;
|
||||
@@ -739,8 +739,8 @@ void axis_angle_to_mat3(float mat[3][3], const float axis[3], const float angle)
|
||||
}
|
||||
|
||||
/* now convert this to a 3x3 matrix */
|
||||
co = (float)cos(angle);
|
||||
si = (float)sin(angle);
|
||||
co = cosf(angle);
|
||||
si = sinf(angle);
|
||||
|
||||
ico = (1.0f - co);
|
||||
nsi[0] = nor[0] * si;
|
||||
@@ -837,7 +837,7 @@ void single_axis_angle_to_mat3(float mat[3][3], const char axis, const float ang
|
||||
/****************************** Vector/Rotation ******************************/
|
||||
/* TODO: the following calls should probably be depreceated sometime */
|
||||
|
||||
/* ODO, replace use of this function with axis_angle_to_mat3() */
|
||||
/* TODO, replace use of this function with axis_angle_to_mat3() */
|
||||
void vec_rot_to_mat3(float mat[][3], const float vec[3], const float phi)
|
||||
{
|
||||
/* rotation of phi radials around vec */
|
||||
@@ -849,8 +849,8 @@ void vec_rot_to_mat3(float mat[][3], const float vec[3], const float phi)
|
||||
vx2 = vx * vx;
|
||||
vy2 = vy * vy;
|
||||
vz2 = vz * vz;
|
||||
co = (float)cos(phi);
|
||||
si = (float)sin(phi);
|
||||
co = cosf(phi);
|
||||
si = sinf(phi);
|
||||
|
||||
mat[0][0] = vx2 + co * (1.0f - vx2);
|
||||
mat[0][1] = vx * vy * (1.0f - co) + vz * si;
|
||||
@@ -863,38 +863,6 @@ void vec_rot_to_mat3(float mat[][3], const float vec[3], const float phi)
|
||||
mat[2][2] = vz2 + co * (1.0f - vz2);
|
||||
}
|
||||
|
||||
/* axis angle to 4x4 matrix */
|
||||
void vec_rot_to_mat4(float mat[][4], const float vec[3], const float phi)
|
||||
{
|
||||
float tmat[3][3];
|
||||
|
||||
vec_rot_to_mat3(tmat, vec, phi);
|
||||
unit_m4(mat);
|
||||
copy_m4_m3(mat, tmat);
|
||||
}
|
||||
|
||||
/* axis angle to quaternion */
|
||||
void vec_rot_to_quat(float *quat, const float vec[3], const float phi)
|
||||
{
|
||||
/* rotation of phi radials around vec */
|
||||
float si;
|
||||
|
||||
quat[1] = vec[0];
|
||||
quat[2] = vec[1];
|
||||
quat[3] = vec[2];
|
||||
|
||||
if (normalize_v3(quat + 1) == 0.0f) {
|
||||
unit_qt(quat);
|
||||
}
|
||||
else {
|
||||
quat[0] = (float)cos((double)phi / 2.0);
|
||||
si = (float)sin((double)phi / 2.0);
|
||||
quat[1] *= si;
|
||||
quat[2] *= si;
|
||||
quat[3] *= si;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************** XYZ Eulers *********************************/
|
||||
|
||||
/* XYZ order */
|
||||
|
||||
@@ -1958,14 +1958,25 @@ static void direct_link_fcurves(FileData *fd, ListBase *list)
|
||||
/* group */
|
||||
fcu->grp = newdataadr(fd, fcu->grp);
|
||||
|
||||
/* clear disabled flag - allows disabled drivers to be tried again ([#32155]),
|
||||
* but also means that another method for "reviving disabled F-Curves" exists
|
||||
*/
|
||||
fcu->flag &= ~FCURVE_DISABLED;
|
||||
|
||||
/* driver */
|
||||
fcu->driver= newdataadr(fd, fcu->driver);
|
||||
if (fcu->driver) {
|
||||
ChannelDriver *driver= fcu->driver;
|
||||
DriverVar *dvar;
|
||||
|
||||
/* compiled expression data will need to be regenerated (old pointer may still be set here) */
|
||||
driver->expr_comp = NULL;
|
||||
|
||||
/* give the driver a fresh chance - the operating environment may be different now
|
||||
* (addons, etc. may be different) so the driver namespace may be sane now [#32155]
|
||||
*/
|
||||
driver->flag &= ~DRIVER_FLAG_INVALID;
|
||||
|
||||
/* relink variables, targets and their paths */
|
||||
link_list(fd, &driver->variables);
|
||||
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
|
||||
|
||||
@@ -87,12 +87,9 @@
|
||||
|
||||
#define ANIM_CHAN_NAME_SIZE 256
|
||||
|
||||
/* macros used for type defines */
|
||||
|
||||
/* get the pointer used for some flag and return */
|
||||
/* get the pointer used for some flag */
|
||||
#define GET_ACF_FLAG_PTR(ptr, type) ((*(type) = sizeof((ptr))), &(ptr))
|
||||
|
||||
|
||||
/* *********************************************** */
|
||||
/* Generic Functions (Type independent) */
|
||||
|
||||
@@ -119,7 +116,7 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa
|
||||
glColor3fv(color);
|
||||
|
||||
/* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */
|
||||
uiSetRoundBox(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
|
||||
uiSetRoundBox((expanded) ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT));
|
||||
uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_key_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
@@ -2231,6 +2232,8 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Mesh *me = obedit->data;
|
||||
Key *key = me->key;
|
||||
KeyBlock *kb = NULL;
|
||||
BMEditMesh *em = me->edit_btmesh;
|
||||
BMVert *eve;
|
||||
BMIter iter;
|
||||
@@ -2244,24 +2247,34 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
|
||||
totshape = CustomData_number_of_layers(&em->bm->vdata, CD_SHAPEKEY);
|
||||
if (totshape == 0 || shape < 0 || shape >= totshape)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
|
||||
/* get shape key - needed for finding reference shape (for add mode only) */
|
||||
if (key) {
|
||||
kb = BLI_findlink(&key->block, shape);
|
||||
}
|
||||
|
||||
/* perform blending on selected vertices*/
|
||||
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
|
||||
if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
|
||||
continue;
|
||||
|
||||
|
||||
/* get coordinates of shapekey we're blending from */
|
||||
sco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, shape);
|
||||
copy_v3_v3(co, sco);
|
||||
|
||||
|
||||
|
||||
if (add) {
|
||||
mul_v3_fl(co, blend);
|
||||
add_v3_v3v3(eve->co, eve->co, co);
|
||||
/* in add mode, we add relative shape key offset */
|
||||
if (kb) {
|
||||
float *rco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, kb->relative);
|
||||
sub_v3_v3v3(co, co, rco);
|
||||
}
|
||||
|
||||
madd_v3_v3fl(eve->co, co, blend);
|
||||
}
|
||||
else {
|
||||
/* in blend mode, we interpolate to the shape key */
|
||||
interp_v3_v3v3(eve->co, eve->co, co, blend);
|
||||
}
|
||||
|
||||
copy_v3_v3(sco, co);
|
||||
}
|
||||
|
||||
EDBM_update_generic(C, em, TRUE);
|
||||
|
||||
@@ -2873,7 +2873,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
|
||||
break;
|
||||
|
||||
case RV3D_VIEW_BACK:
|
||||
axis_set_view(C, v3d, ar, 0.0, 0.0, -cosf(M_PI / 4.0), -cosf(M_PI / 4.0),
|
||||
axis_set_view(C, v3d, ar, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2,
|
||||
viewnum, nextperspo, align_active);
|
||||
break;
|
||||
|
||||
@@ -2888,7 +2888,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
|
||||
break;
|
||||
|
||||
case RV3D_VIEW_FRONT:
|
||||
axis_set_view(C, v3d, ar, cosf(M_PI / 4.0), -sinf(M_PI / 4.0), 0.0, 0.0,
|
||||
axis_set_view(C, v3d, ar, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0,
|
||||
viewnum, nextperspo, align_active);
|
||||
break;
|
||||
|
||||
@@ -3008,7 +3008,6 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
|
||||
View3D *v3d;
|
||||
ARegion *ar;
|
||||
RegionView3D *rv3d;
|
||||
float phi, q1[4], new_quat[4];
|
||||
int orbitdir;
|
||||
|
||||
/* no NULL check is needed, poll checks */
|
||||
@@ -3019,36 +3018,40 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if (rv3d->viewlock == 0) {
|
||||
if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
|
||||
if (orbitdir == V3D_VIEW_STEPLEFT || orbitdir == V3D_VIEW_STEPRIGHT) {
|
||||
float si;
|
||||
float angle = DEG2RADF((float)U.pad_rot_angle);
|
||||
float quat_mul[4];
|
||||
float quat_new[4];
|
||||
|
||||
if (ELEM(orbitdir, V3D_VIEW_STEPLEFT, V3D_VIEW_STEPRIGHT)) {
|
||||
const float zvec[3] = {0.0f, 0.0f, 1.0f};
|
||||
|
||||
if (orbitdir == V3D_VIEW_STEPRIGHT) {
|
||||
angle = -angle;
|
||||
}
|
||||
|
||||
/* z-axis */
|
||||
phi = (float)(M_PI / 360.0) * U.pad_rot_angle;
|
||||
if (orbitdir == V3D_VIEW_STEPRIGHT) phi = -phi;
|
||||
si = (float)sin(phi);
|
||||
q1[0] = (float)cos(phi);
|
||||
q1[1] = q1[2] = 0.0;
|
||||
q1[3] = si;
|
||||
mul_qt_qtqt(new_quat, rv3d->viewquat, q1);
|
||||
rv3d->view = RV3D_VIEW_USER;
|
||||
axis_angle_to_quat(quat_mul, zvec, angle);
|
||||
}
|
||||
else if (orbitdir == V3D_VIEW_STEPDOWN || orbitdir == V3D_VIEW_STEPUP) {
|
||||
else {
|
||||
|
||||
if (orbitdir == V3D_VIEW_STEPDOWN) {
|
||||
angle = -angle;
|
||||
}
|
||||
|
||||
/* horizontal axis */
|
||||
copy_v3_v3(q1 + 1, rv3d->viewinv[0]);
|
||||
|
||||
normalize_v3(q1 + 1);
|
||||
phi = (float)(M_PI / 360.0) * U.pad_rot_angle;
|
||||
if (orbitdir == V3D_VIEW_STEPDOWN) phi = -phi;
|
||||
q1[0] = (float)cos(phi);
|
||||
mul_v3_fl(q1 + 1, sin(phi));
|
||||
mul_qt_qtqt(new_quat, rv3d->viewquat, q1);
|
||||
rv3d->view = RV3D_VIEW_USER;
|
||||
axis_angle_to_quat(quat_mul, rv3d->viewinv[0], angle);
|
||||
}
|
||||
|
||||
smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, new_quat, NULL, NULL);
|
||||
mul_qt_qtqt(quat_new, rv3d->viewquat, quat_mul);
|
||||
rv3d->view = RV3D_VIEW_USER;
|
||||
|
||||
smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, quat_new, NULL, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
void VIEW3D_OT_view_orbit(wmOperatorType *ot)
|
||||
|
||||
@@ -1125,7 +1125,7 @@ int ED_view3d_lock(RegionView3D *rv3d)
|
||||
break;
|
||||
|
||||
case RV3D_VIEW_BACK:
|
||||
QUATSET(rv3d->viewquat, 0.0, 0.0, -cosf(M_PI / 4.0), -cosf(M_PI / 4.0));
|
||||
QUATSET(rv3d->viewquat, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2);
|
||||
break;
|
||||
|
||||
case RV3D_VIEW_LEFT:
|
||||
@@ -1137,7 +1137,7 @@ int ED_view3d_lock(RegionView3D *rv3d)
|
||||
break;
|
||||
|
||||
case RV3D_VIEW_FRONT:
|
||||
QUATSET(rv3d->viewquat, (float)cos(M_PI / 4.0), -sinf(M_PI / 4.0), 0.0, 0.0);
|
||||
QUATSET(rv3d->viewquat, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0);
|
||||
break;
|
||||
|
||||
case RV3D_VIEW_RIGHT:
|
||||
|
||||
@@ -2981,6 +2981,7 @@ static void rna_def_userdef_system(BlenderRNA *brna)
|
||||
{ 8, "FRENCH", 0, "French (Français)", "fr_FR"},
|
||||
{ 4, "ITALIAN", 0, "Italian (Italiano)", "it_IT"},
|
||||
{ 2, "JAPANESE", 0, "Japanese (日本語)", "ja_JP"},
|
||||
{12, "PORTUGUESE", 0, "Portuguese (Português)", "pt"},
|
||||
{15, "RUSSIAN", 0, "Russian (Русский)", "ru_RU"},
|
||||
{13, "SIMPLIFIED_CHINESE", 0, "Simplified Chinese (简体中文)", "zh_CN"},
|
||||
{ 9, "SPANISH", 0, "Spanish (Español)", "es"},
|
||||
@@ -3004,7 +3005,6 @@ static void rna_def_userdef_system(BlenderRNA *brna)
|
||||
/* using the utf8 flipped form of Persian (فارسی) */
|
||||
{26, "PERSIAN", 0, "Persian (ﯽﺳﺭﺎﻓ)", "fa_IR"},
|
||||
{19, "POLISH", 0, "Polish (Polski)", "pl_PL"},
|
||||
{12, "BRAZILIAN_PORTUGUESE", 0, "Portuguese (Português)", "pt"},
|
||||
/* {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, */ /* XXX No po's yet. */
|
||||
{17, "SERBIAN", 0, "Serbian (Српски)", "sr_RS"},
|
||||
{28, "SERBIAN_LATIN", 0, "Serbian latin (Srpski latinica)", "sr_RS@latin"},
|
||||
|
||||
@@ -2083,6 +2083,199 @@ static PyObject *bpy_bmelemseq_index_update(BPy_BMElemSeq *self)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bpy_bmelemseq_sort_doc,
|
||||
".. method:: sort(key=None, reverse=False)\n"
|
||||
"\n"
|
||||
" Sort the elements of this sequence, using an optional custom sort key.\n"
|
||||
" Indices of elements are not changed, BMElemeSeq.index_update() can be used for that.\n"
|
||||
"\n"
|
||||
" :arg key: The key that sets the ordering of the elements.\n"
|
||||
" :type key: :function: returning a number\n"
|
||||
" :arg reverse: Reverse the order of the elements\n"
|
||||
" :type reverse: :boolean:\n"
|
||||
"\n"
|
||||
" .. note::\n"
|
||||
"\n"
|
||||
" When the 'key' argument is not provided, the elements are reordered following their current index value.\n"
|
||||
" In particular this can be used by setting indices manually before calling this method.\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
/* Use a static variable here because there is the need to sort some array
|
||||
* doing comparisons on elements of another array, qsort_r would have been
|
||||
* wonderful to use here, but unfortunately it is not standard and it's not
|
||||
* portable across different platforms.
|
||||
*
|
||||
* If a portable alternative to qsort_r becomes available, remove this static
|
||||
* var hack!
|
||||
*
|
||||
* Note: the functions below assumes the keys array has been allocated and it
|
||||
* has enough elements to complete the task.
|
||||
*/
|
||||
static double *keys = NULL;
|
||||
|
||||
static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const void *index1_v, const void *index2_v)
|
||||
{
|
||||
const int *index1 = (int *)index1_v;
|
||||
const int *index2 = (int *)index2_v;
|
||||
|
||||
if (keys[*index1] < keys[*index2]) return -1;
|
||||
else if (keys[*index1] > keys[*index2]) return 1;
|
||||
else return 0;
|
||||
}
|
||||
|
||||
static int bpy_bmelemseq_sort_cmp_by_keys_descending(const void *index1_v, const void *index2_v)
|
||||
{
|
||||
return -bpy_bmelemseq_sort_cmp_by_keys_ascending(index1_v, index2_v);
|
||||
}
|
||||
|
||||
static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, PyObject *kw)
|
||||
{
|
||||
static const char *kwlist[] = {"key", "reverse", NULL};
|
||||
PyObject *keyfunc = NULL; /* optional */
|
||||
int reverse = FALSE; /* optional */
|
||||
|
||||
const char htype = bm_iter_itype_htype_map[self->itype];
|
||||
int n_elem;
|
||||
|
||||
BMIter iter;
|
||||
BMElem *ele;
|
||||
|
||||
int *elem_idx;
|
||||
int *elem_map_idx;
|
||||
int (*elem_idx_compare_by_keys)(const void *, const void *);
|
||||
|
||||
int *vert_idx = NULL;
|
||||
int *edge_idx = NULL;
|
||||
int *face_idx = NULL;
|
||||
int i;
|
||||
|
||||
BMesh *bm = self->bm;
|
||||
|
||||
BPY_BM_CHECK_OBJ(self);
|
||||
|
||||
if (args != NULL) {
|
||||
if(!PyArg_ParseTupleAndKeywords(args, kw,
|
||||
"|Oi:BMElemSeq.sort",
|
||||
(char **)kwlist,
|
||||
&keyfunc, &reverse))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (keyfunc != NULL && !PyCallable_Check(keyfunc)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"the 'key' argument is not a callable object");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
n_elem = BM_mesh_elem_count(bm, htype);
|
||||
if (n_elem <= 1) {
|
||||
/* 0 or 1 elements: sorted already */
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
keys = PyMem_MALLOC(sizeof(*keys) * n_elem);
|
||||
if (keys == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
BM_ITER_BPY_BM_SEQ (ele, &iter, self) {
|
||||
if (keyfunc != NULL) {
|
||||
PyObject *py_elem;
|
||||
PyObject *index;
|
||||
|
||||
py_elem = BPy_BMElem_CreatePyObject(self->bm, (BMHeader *)ele);
|
||||
index = PyObject_CallFunctionObjArgs(keyfunc, py_elem, NULL);
|
||||
Py_DECREF(py_elem);
|
||||
if (index == NULL) {
|
||||
/* No need to set the exception here,
|
||||
* PyObject_CallFunctionObjArgs() does that */
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((keys[i] = PyFloat_AsDouble(index)) == -1 && PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
"the value returned by the 'key' function is not a number");
|
||||
Py_DECREF(index);
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Py_DECREF(index);
|
||||
}
|
||||
else {
|
||||
/* If the 'key' function is not provided we sort
|
||||
* according to the current index values */
|
||||
keys[i] = ele->head.index;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
elem_idx = PyMem_MALLOC(sizeof(*elem_idx) * n_elem);
|
||||
if (elem_idx == NULL) {
|
||||
PyErr_NoMemory();
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize the element index array */
|
||||
range_vn_i(elem_idx, n_elem, 0);
|
||||
|
||||
/* Sort the index array according to the order of the 'keys' array */
|
||||
if (reverse)
|
||||
elem_idx_compare_by_keys = bpy_bmelemseq_sort_cmp_by_keys_descending;
|
||||
else
|
||||
elem_idx_compare_by_keys = bpy_bmelemseq_sort_cmp_by_keys_ascending;
|
||||
|
||||
qsort(elem_idx, n_elem, sizeof(*elem_idx), elem_idx_compare_by_keys);
|
||||
|
||||
elem_map_idx = PyMem_MALLOC(sizeof(*elem_map_idx) * n_elem);
|
||||
if (elem_map_idx == NULL) {
|
||||
PyErr_NoMemory();
|
||||
PyMem_FREE(elem_idx);
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Initialize the map array
|
||||
*
|
||||
* We need to know the index such that if used as the new_index in
|
||||
* BM_mesh_remap() will give the order of the sorted keys like in
|
||||
* elem_idx */
|
||||
for (i = 0; i < n_elem; i++) {
|
||||
elem_map_idx[elem_idx[i]] = i;
|
||||
}
|
||||
|
||||
switch ((BMIterType)self->itype) {
|
||||
case BM_VERTS_OF_MESH:
|
||||
vert_idx = elem_map_idx;
|
||||
break;
|
||||
case BM_EDGES_OF_MESH:
|
||||
edge_idx = elem_map_idx;
|
||||
break;
|
||||
case BM_FACES_OF_MESH:
|
||||
face_idx = elem_map_idx;
|
||||
break;
|
||||
default:
|
||||
PyErr_Format(PyExc_TypeError, "element type %d not supported", self->itype);
|
||||
PyMem_FREE(elem_map_idx);
|
||||
PyMem_FREE(elem_idx);
|
||||
PyMem_FREE(keys);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BM_mesh_remap(bm, vert_idx, edge_idx, face_idx);
|
||||
|
||||
PyMem_FREE(elem_map_idx);
|
||||
PyMem_FREE(elem_idx);
|
||||
PyMem_FREE(keys);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static struct PyMethodDef bpy_bmesh_methods[] = {
|
||||
/* utility */
|
||||
@@ -2175,6 +2368,7 @@ static struct PyMethodDef bpy_bmvertseq_methods[] = {
|
||||
|
||||
/* odd function, initializes index values */
|
||||
{"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
|
||||
{"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -2186,6 +2380,7 @@ static struct PyMethodDef bpy_bmedgeseq_methods[] = {
|
||||
|
||||
/* odd function, initializes index values */
|
||||
{"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
|
||||
{"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -2197,12 +2392,14 @@ static struct PyMethodDef bpy_bmfaceseq_methods[] = {
|
||||
|
||||
/* odd function, initializes index values */
|
||||
{"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc},
|
||||
{"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
static struct PyMethodDef bpy_bmloopseq_methods[] = {
|
||||
/* odd function, initializes index values */
|
||||
/* no: index_update() function since we cant iterate over loops */
|
||||
/* no: sort() function since we cant iterate over loops */
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
|
||||
@@ -157,7 +157,8 @@ PyObject *bpy_text_import_name(const char *name, int *found)
|
||||
}
|
||||
|
||||
/* we know this cant be importable, the name is too long for blender! */
|
||||
if (namelen >= (MAX_ID_NAME - 2) - 3) return NULL;
|
||||
if (namelen >= (MAX_ID_NAME - 2) - 3)
|
||||
return NULL;
|
||||
|
||||
memcpy(txtname, name, namelen);
|
||||
memcpy(&txtname[namelen], ".py", 4);
|
||||
|
||||
@@ -988,8 +988,7 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha
|
||||
|
||||
load_datablocks(main_newlib, bpy_openlib, path, idcode);
|
||||
|
||||
if (idcode==ID_SCE) {
|
||||
/* assume we want text blocks too */
|
||||
if (idcode==ID_SCE && options & LIB_LOAD_LOAD_SCRIPTS) {
|
||||
load_datablocks(main_newlib, bpy_openlib, path, ID_TXT);
|
||||
}
|
||||
|
||||
@@ -1045,8 +1044,8 @@ bool KX_BlenderSceneConverter::LinkBlendFile(BlendHandle *bpy_openlib, const cha
|
||||
}
|
||||
|
||||
/* Handle any text datablocks */
|
||||
|
||||
addImportMain(main_newlib);
|
||||
if (options & LIB_LOAD_LOAD_SCRIPTS)
|
||||
addImportMain(main_newlib);
|
||||
|
||||
/* Now handle all the actions */
|
||||
if (options & LIB_LOAD_LOAD_ACTIONS) {
|
||||
|
||||
@@ -182,6 +182,7 @@ public:
|
||||
{
|
||||
LIB_LOAD_LOAD_ACTIONS = 1,
|
||||
LIB_LOAD_VERBOSE = 2,
|
||||
LIB_LOAD_LOAD_SCRIPTS = 4,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "PyObjectPlus.h"
|
||||
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Native functions */
|
||||
@@ -113,34 +114,7 @@ void KX_CameraActuator::Relink(CTR_Map<CTR_HashedPtr, void*> *obj_map)
|
||||
}
|
||||
}
|
||||
|
||||
/* three functions copied from blender arith... don't know if there's an equivalent */
|
||||
|
||||
static float Kx_Normalize(float *n)
|
||||
{
|
||||
float d;
|
||||
|
||||
d= n[0]*n[0]+n[1]*n[1]+n[2]*n[2];
|
||||
/* FLT_EPSILON is too large! A larger value causes normalize errors in a scaled down utah teapot */
|
||||
if (d>0.0000000000001) {
|
||||
d= sqrt(d);
|
||||
|
||||
n[0]/=d;
|
||||
n[1]/=d;
|
||||
n[2]/=d;
|
||||
} else {
|
||||
n[0]=n[1]=n[2]= 0.0;
|
||||
d= 0.0;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
static void Kx_Crossf(float *c, float *a, float *b)
|
||||
{
|
||||
c[0] = a[1] * b[2] - a[2] * b[1];
|
||||
c[1] = a[2] * b[0] - a[0] * b[2];
|
||||
c[2] = a[0] * b[1] - a[1] * b[0];
|
||||
}
|
||||
|
||||
/* copied from blender BLI_math ... don't know if there's an equivalent */
|
||||
|
||||
static void Kx_VecUpMat3(float vec[3], float mat[][3], short axis)
|
||||
{
|
||||
@@ -184,7 +158,7 @@ static void Kx_VecUpMat3(float vec[3], float mat[][3], short axis)
|
||||
mat[coz][0]= vec[0];
|
||||
mat[coz][1]= vec[1];
|
||||
mat[coz][2]= vec[2];
|
||||
if (Kx_Normalize((float *)mat[coz]) == 0.f) {
|
||||
if (normalize_v3((float *)mat[coz]) == 0.f) {
|
||||
/* this is a very abnormal situation: the camera has reach the object center exactly
|
||||
* We will choose a completely arbitrary direction */
|
||||
mat[coz][0] = 1.0f;
|
||||
@@ -197,15 +171,14 @@ static void Kx_VecUpMat3(float vec[3], float mat[][3], short axis)
|
||||
mat[coy][1] = - inp * mat[coz][1];
|
||||
mat[coy][2] = 1.0f - inp * mat[coz][2];
|
||||
|
||||
if (Kx_Normalize((float *)mat[coy]) == 0.f) {
|
||||
if (normalize_v3((float *)mat[coy]) == 0.f) {
|
||||
/* the camera is vertical, chose the y axis arbitrary */
|
||||
mat[coy][0] = 0.f;
|
||||
mat[coy][1] = 1.f;
|
||||
mat[coy][2] = 0.f;
|
||||
}
|
||||
|
||||
Kx_Crossf(mat[cox], mat[coy], mat[coz]);
|
||||
|
||||
cross_v3_v3v3(mat[cox], mat[coy], mat[coz]);
|
||||
}
|
||||
|
||||
bool KX_CameraActuator::Update(double curtime, bool frame)
|
||||
|
||||
@@ -503,6 +503,8 @@ bool KX_KetsjiEngine::BeginFrame()
|
||||
|
||||
void KX_KetsjiEngine::EndFrame()
|
||||
{
|
||||
m_rendertools->MotionBlur(m_rasterizer);
|
||||
|
||||
// Show profiling info
|
||||
m_logger->StartLog(tc_overhead, m_kxsystem->GetTimeInSeconds(), true);
|
||||
if (m_show_framerate || m_show_profile || (m_show_debug_properties && m_propertiesPresent))
|
||||
@@ -1344,7 +1346,6 @@ void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene)
|
||||
m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight());
|
||||
|
||||
m_rasterizer->FlushDebugShapes();
|
||||
m_rendertools->MotionBlur(m_rasterizer);
|
||||
scene->Render2DFilters(m_canvas);
|
||||
#ifdef WITH_PYTHON
|
||||
scene->RunDrawingCallbacks(scene->GetPostDrawCB());
|
||||
|
||||
@@ -676,12 +676,12 @@ static PyObject *gLibLoad(PyObject*, PyObject* args, PyObject* kwds)
|
||||
char *err_str= NULL;
|
||||
|
||||
short options=0;
|
||||
int load_actions=0, verbose=0;
|
||||
int load_actions=0, verbose=0, load_scripts=1;
|
||||
|
||||
static const char *kwlist[] = {"path", "group", "buffer", "load_actions", "verbose", NULL};
|
||||
static const char *kwlist[] = {"path", "group", "buffer", "load_actions", "verbose", "load_scripts", NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|y*ii:LibLoad", const_cast<char**>(kwlist),
|
||||
&path, &group, &py_buffer, &load_actions, &verbose))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|y*iii:LibLoad", const_cast<char**>(kwlist),
|
||||
&path, &group, &py_buffer, &load_actions, &verbose, &load_scripts))
|
||||
return NULL;
|
||||
|
||||
/* setup options */
|
||||
@@ -689,6 +689,8 @@ static PyObject *gLibLoad(PyObject*, PyObject* args, PyObject* kwds)
|
||||
options |= KX_BlenderSceneConverter::LIB_LOAD_LOAD_ACTIONS;
|
||||
if (verbose != 0)
|
||||
options |= KX_BlenderSceneConverter::LIB_LOAD_VERBOSE;
|
||||
if (load_scripts != 0)
|
||||
options |= KX_BlenderSceneConverter::LIB_LOAD_LOAD_SCRIPTS;
|
||||
|
||||
if (!py_buffer.buf)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user