svn merge ^/trunk/blender -r42660:42669
This commit is contained in:
@@ -368,6 +368,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
|
||||
xml_read_enum(&wood->type, WaveTextureNode::type_enum, node, "type");
|
||||
snode = wood;
|
||||
}
|
||||
else if(string_iequals(node.name(), "normal")) {
|
||||
snode = new NormalNode();
|
||||
}
|
||||
else if(string_iequals(node.name(), "mapping")) {
|
||||
snode = new MappingNode();
|
||||
}
|
||||
|
||||
@@ -132,7 +132,6 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
|
||||
case BL::ShaderNode::type_GEOMETRY: break;
|
||||
case BL::ShaderNode::type_MATERIAL: break;
|
||||
case BL::ShaderNode::type_MATERIAL_EXT: break;
|
||||
case BL::ShaderNode::type_NORMAL: break;
|
||||
case BL::ShaderNode::type_OUTPUT: break;
|
||||
case BL::ShaderNode::type_SCRIPT: break;
|
||||
case BL::ShaderNode::type_SQUEEZE: break;
|
||||
@@ -198,6 +197,17 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Node *
|
||||
node = vmath;
|
||||
break;
|
||||
}
|
||||
case BL::ShaderNode::type_NORMAL: {
|
||||
BL::Node::outputs_iterator out_it;
|
||||
b_node.outputs.begin(out_it);
|
||||
BL::NodeSocketVectorNone vec_sock(*out_it);
|
||||
|
||||
NormalNode *norm = new NormalNode();
|
||||
norm->direction = get_float3(vec_sock.default_value());
|
||||
|
||||
node = norm;
|
||||
break;
|
||||
}
|
||||
case BL::ShaderNode::type_MAPPING: {
|
||||
BL::ShaderNodeMapping b_mapping_node(b_node);
|
||||
MappingNode *mapping = new MappingNode();
|
||||
|
||||
@@ -72,6 +72,7 @@ set(SRC_SVM_HEADERS
|
||||
svm/svm_musgrave.h
|
||||
svm/svm_noise.h
|
||||
svm/svm_noisetex.h
|
||||
svm/svm_normal.h
|
||||
svm/svm_sepcomb_rgb.h
|
||||
svm/svm_sky.h
|
||||
svm/svm_tex_coord.h
|
||||
|
||||
@@ -33,6 +33,7 @@ set(SRC_OSL
|
||||
node_mix.osl
|
||||
node_mix_closure.osl
|
||||
node_musgrave_texture.osl
|
||||
node_normal.osl
|
||||
node_blend_weight_texture.osl
|
||||
node_noise_texture.osl
|
||||
node_output_displacement.osl
|
||||
|
||||
31
intern/cycles/kernel/osl/nodes/node_normal.osl
Normal file
31
intern/cycles/kernel/osl/nodes/node_normal.osl
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2011, Blender Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "stdosl.h"
|
||||
|
||||
shader node_normal(
|
||||
normal Direction = normal(0.0, 0.0, 0.0),
|
||||
normal NormalIn = normal(0.0, 0.0, 0.0),
|
||||
output normal NormalOut = normal(0.0, 0.0, 0.0),
|
||||
output float Dot = 1.0
|
||||
{
|
||||
Direction = normalize(Direction);
|
||||
NormalOut = Direction;
|
||||
Dot = dot(Direction, NormalIn);
|
||||
}
|
||||
|
||||
@@ -134,6 +134,7 @@ CCL_NAMESPACE_END
|
||||
#include "svm_light_path.h"
|
||||
#include "svm_magic.h"
|
||||
#include "svm_mapping.h"
|
||||
#include "svm_normal.h"
|
||||
#include "svm_wave.h"
|
||||
#include "svm_math.h"
|
||||
#include "svm_mix.h"
|
||||
@@ -300,6 +301,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
|
||||
case NODE_VECTOR_MATH:
|
||||
svm_node_vector_math(kg, sd, stack, node.y, node.z, node.w, &offset);
|
||||
break;
|
||||
case NODE_NORMAL:
|
||||
svm_node_normal(kg, sd, stack, node.y, node.z, node.w, &offset);
|
||||
break;
|
||||
case NODE_MAPPING:
|
||||
svm_node_mapping(kg, sd, stack, node.y, node.z, &offset);
|
||||
break;
|
||||
|
||||
41
intern/cycles/kernel/svm/svm_normal.h
Normal file
41
intern/cycles/kernel/svm/svm_normal.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2011, Blender Foundation.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
__device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset)
|
||||
{
|
||||
/* read extra data */
|
||||
uint4 node1 = read_node(kg, offset);
|
||||
float3 normal = stack_load_float3(stack, in_normal_offset);
|
||||
|
||||
float3 direction;
|
||||
direction.x = node1.x;
|
||||
direction.y = node1.y;
|
||||
direction.z = node1.z;
|
||||
direction = normalize(direction);
|
||||
|
||||
if (stack_valid(out_normal_offset))
|
||||
stack_store_float3(stack, out_normal_offset, direction);
|
||||
|
||||
if (stack_valid(out_dot_offset))
|
||||
stack_store_float(stack, out_dot_offset, dot(direction, normalize(normal)));
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
@@ -84,7 +84,8 @@ typedef enum NodeType {
|
||||
NODE_COMBINE_RGB = 5100,
|
||||
NODE_HSV = 5200,
|
||||
NODE_CAMERA = 5300,
|
||||
NODE_INVERT = 5400
|
||||
NODE_INVERT = 5400,
|
||||
NODE_NORMAL = 5500
|
||||
} NodeType;
|
||||
|
||||
typedef enum NodeAttributeType {
|
||||
|
||||
@@ -713,6 +713,41 @@ void MagicTextureNode::compile(OSLCompiler& compiler)
|
||||
compiler.add(this, "node_magic_texture");
|
||||
}
|
||||
|
||||
/* Normal */
|
||||
|
||||
NormalNode::NormalNode()
|
||||
: ShaderNode("normal")
|
||||
{
|
||||
direction = make_float3(0.0f, 0.0f, 1.0f);
|
||||
|
||||
add_input("Normal", SHADER_SOCKET_NORMAL);
|
||||
add_output("Normal", SHADER_SOCKET_NORMAL);
|
||||
add_output("Dot", SHADER_SOCKET_FLOAT);
|
||||
}
|
||||
|
||||
void NormalNode::compile(SVMCompiler& compiler)
|
||||
{
|
||||
ShaderInput *normal_in = input("Normal");
|
||||
ShaderOutput *normal_out = output("Normal");
|
||||
ShaderOutput *dot_out = output("Dot");
|
||||
|
||||
compiler.stack_assign(normal_in);
|
||||
compiler.stack_assign(normal_out);
|
||||
compiler.stack_assign(dot_out);
|
||||
|
||||
compiler.add_node(NODE_NORMAL, normal_in->stack_offset, normal_out->stack_offset, dot_out->stack_offset);
|
||||
compiler.add_node(
|
||||
__float_as_int(direction.x),
|
||||
__float_as_int(direction.y),
|
||||
__float_as_int(direction.z));
|
||||
}
|
||||
|
||||
void NormalNode::compile(OSLCompiler& compiler)
|
||||
{
|
||||
compiler.parameter_vector("Direction", direction);
|
||||
compiler.add(this, "node_normal");
|
||||
}
|
||||
|
||||
/* Mapping */
|
||||
|
||||
MappingNode::MappingNode()
|
||||
|
||||
@@ -343,6 +343,13 @@ public:
|
||||
static ShaderEnum type_enum;
|
||||
};
|
||||
|
||||
class NormalNode : public ShaderNode {
|
||||
public:
|
||||
SHADER_NODE_CLASS(NormalNode)
|
||||
|
||||
float3 direction;
|
||||
};
|
||||
|
||||
class VectorMathNode : public ShaderNode {
|
||||
public:
|
||||
SHADER_NODE_CLASS(VectorMathNode)
|
||||
|
||||
@@ -120,6 +120,8 @@ void BKE_scene_foreach_display_point(
|
||||
const short flag,
|
||||
void (*func_cb)(const float[3], void *), void *user_data);
|
||||
|
||||
int BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob);
|
||||
|
||||
void solve_tracking (struct Object *ob, float targetmat[][4]);
|
||||
int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]);
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "BKE_image.h"
|
||||
#include "BLI_math_color.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLF_api.h"
|
||||
|
||||
void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4])
|
||||
@@ -161,21 +162,6 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt
|
||||
#define BLEND_FLOAT(real, add) (real+add <= 1.0f) ? (real+add) : 1.0f
|
||||
#define BLEND_CHAR(real, add) ((real + (char)(add * 255.0f)) <= 255) ? (real + (char)(add * 255.0f)) : 255
|
||||
|
||||
static int is_pow2(int n)
|
||||
{
|
||||
return ((n)&(n-1))==0;
|
||||
}
|
||||
static int larger_pow2(int n)
|
||||
{
|
||||
if (is_pow2(n))
|
||||
return n;
|
||||
|
||||
while(!is_pow2(n))
|
||||
n= n&(n-1);
|
||||
|
||||
return n*2;
|
||||
}
|
||||
|
||||
static void checker_board_color_fill(unsigned char *rect, float *rect_float, int width, int height)
|
||||
{
|
||||
int hue_step, y, x;
|
||||
@@ -183,7 +169,7 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int
|
||||
|
||||
sat= 1.0;
|
||||
|
||||
hue_step= larger_pow2(width / 8);
|
||||
hue_step= power_of_2_max_i(width / 8);
|
||||
if(hue_step < 8) hue_step= 8;
|
||||
|
||||
for(y= 0; y < height; y++)
|
||||
|
||||
@@ -2488,6 +2488,14 @@ void object_tfm_restore(Object *ob, void *obtfm_pt)
|
||||
copy_m4_m4(ob->imat, obtfm->imat);
|
||||
}
|
||||
|
||||
int BKE_object_parent_loop_check(const Object *par, const Object *ob)
|
||||
{
|
||||
/* test if 'ob' is a parent somewhere in par's parents */
|
||||
if(par == NULL) return 0;
|
||||
if(ob == par) return 1;
|
||||
return BKE_object_parent_loop_check(par->parent, ob);
|
||||
}
|
||||
|
||||
/* proxy rule: lib_object->proxy_from == the one we borrow from, only set temporal and cleared here */
|
||||
/* local_object->proxy == pointer to library object, saved in files and read */
|
||||
|
||||
|
||||
@@ -1491,7 +1491,7 @@ static int ptcache_old_elemsize(PTCacheID *pid)
|
||||
static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *fra1, int *fra2)
|
||||
{
|
||||
if(pid->cache->flag & PTCACHE_DISK_CACHE) {
|
||||
int cfra1=frame-1, cfra2=frame+1;
|
||||
int cfra1=frame, cfra2=frame+1;
|
||||
|
||||
while(cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1))
|
||||
cfra1--;
|
||||
@@ -1518,7 +1518,7 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *
|
||||
PTCacheMem *pm = pid->cache->mem_cache.first;
|
||||
PTCacheMem *pm2 = pid->cache->mem_cache.last;
|
||||
|
||||
while(pm->next && pm->next->frame < frame)
|
||||
while(pm->next && pm->next->frame <= frame)
|
||||
pm= pm->next;
|
||||
|
||||
if(pm2->frame < frame) {
|
||||
@@ -1841,7 +1841,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
|
||||
/* possible to get old or interpolated result */
|
||||
int BKE_ptcache_read(PTCacheID *pid, float cfra)
|
||||
{
|
||||
int cfrai = (int)cfra, cfra1=0, cfra2=0;
|
||||
int cfrai = (int)floor(cfra), cfra1=0, cfra2=0;
|
||||
int ret = 0;
|
||||
|
||||
/* nothing to read to */
|
||||
|
||||
@@ -167,6 +167,11 @@ MINLINE float signf(float f);
|
||||
|
||||
MINLINE float power_of_2(float f);
|
||||
|
||||
/* these dont really fit anywhere but were being copied about a lot */
|
||||
MINLINE int is_power_of_2_i(int n);
|
||||
MINLINE int power_of_2_max_i(int n);
|
||||
MINLINE int power_of_2_min_i(int n);
|
||||
|
||||
MINLINE float shell_angle_to_dist(float angle);
|
||||
|
||||
#if (defined(WIN32) || defined(WIN64)) && !defined(FREE_WINDOWS)
|
||||
|
||||
@@ -115,6 +115,31 @@ MINLINE float power_of_2(float val)
|
||||
return (float)pow(2.0, ceil(log((double)val) / M_LN2));
|
||||
}
|
||||
|
||||
MINLINE int is_power_of_2_i(int n)
|
||||
{
|
||||
return (n & (n - 1)) == 0;
|
||||
}
|
||||
|
||||
MINLINE int power_of_2_max_i(int n)
|
||||
{
|
||||
if (is_power_of_2_i(n))
|
||||
return n;
|
||||
|
||||
while(!is_power_of_2_i(n))
|
||||
n = n & (n - 1);
|
||||
|
||||
return n * 2;
|
||||
}
|
||||
|
||||
MINLINE int power_of_2_min_i(int n)
|
||||
{
|
||||
while (!is_power_of_2_i(n))
|
||||
n = n & (n - 1);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
MINLINE float minf(float a, float b)
|
||||
{
|
||||
return (a < b)? a: b;
|
||||
@@ -130,5 +155,6 @@ MINLINE float signf(float f)
|
||||
return (f < 0.f)? -1.f: 1.f;
|
||||
}
|
||||
|
||||
|
||||
#endif /* BLI_MATH_BASE_INLINE_H */
|
||||
|
||||
|
||||
@@ -776,7 +776,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
|
||||
* - only include entry if it exists
|
||||
*/
|
||||
if (scene->active_keyingset) {
|
||||
uiItemIntO(layout, "Active Keying Set", ICON_NONE, op_name, "type", i++);
|
||||
uiItemEnumO(layout, op_name, "Active Keying Set", ICON_NONE, "type", i++);
|
||||
uiItemS(layout);
|
||||
}
|
||||
else
|
||||
@@ -788,7 +788,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
|
||||
if (scene->keyingsets.first) {
|
||||
for (ks= scene->keyingsets.first; ks; ks=ks->next, i++) {
|
||||
if (ANIM_keyingset_context_ok_poll(C, ks))
|
||||
uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i);
|
||||
uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i);
|
||||
}
|
||||
uiItemS(layout);
|
||||
}
|
||||
@@ -798,7 +798,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op
|
||||
for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) {
|
||||
/* only show KeyingSet if context is suitable */
|
||||
if (ANIM_keyingset_context_ok_poll(C, ks))
|
||||
uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i);
|
||||
uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i);
|
||||
}
|
||||
|
||||
uiPupMenuEnd(C, pup);
|
||||
|
||||
@@ -99,6 +99,9 @@ struct ToolSettings;
|
||||
|
||||
float *bm_get_cd_float(struct CustomData *cdata, void *data, int type);
|
||||
|
||||
intptr_t mesh_octree_table(struct Object *ob, struct BMEditMesh *em, float *co, char mode);
|
||||
int mesh_mirrtopo_table(struct Object *ob, char mode);
|
||||
|
||||
/* bmeshutils.c */
|
||||
|
||||
/*
|
||||
@@ -198,9 +201,6 @@ void EDBM_automerge(struct Scene *scene, struct Object *ob, int update);
|
||||
/* editmesh_mods.c */
|
||||
extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs;
|
||||
|
||||
intptr_t mesh_octree_table(struct Object *ob, struct BMEditMesh *em, float *co, char mode);
|
||||
long mesh_mirrtopo_table(struct Object *ob, char mode);
|
||||
|
||||
int mouse_mesh(struct bContext *C, const int mval[2], short extend);
|
||||
|
||||
struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em, struct BMVert *eve, float *co, int index);
|
||||
|
||||
@@ -2833,7 +2833,7 @@ uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x1, i
|
||||
*/
|
||||
static int findBitIndex(unsigned int x)
|
||||
{
|
||||
if (!x || (x&(x-1))!=0) { /* x&(x-1) strips lowest bit */
|
||||
if (!x || !is_power_of_2_i(x)) { /* is_power_of_2_i(x) strips lowest bit */
|
||||
return -1;
|
||||
} else {
|
||||
int idx= 0;
|
||||
|
||||
@@ -722,17 +722,17 @@ static void mesh_octree_free_node(MocNode **bt)
|
||||
|
||||
|
||||
/* temporal define, just to make nicer code below */
|
||||
#define MOC_ADDNODE(vx, vy, vz) mesh_octree_add_node(basetable + ((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz), index)
|
||||
#define MOC_INDEX(vx, vy, vz) (((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz))
|
||||
|
||||
static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, float *div, intptr_t index)
|
||||
{
|
||||
float fx, fy, fz;
|
||||
int vx, vy, vz;
|
||||
|
||||
if (!finite(co[0]) ||
|
||||
!finite(co[1]) ||
|
||||
!finite(co[2])
|
||||
) {
|
||||
if ( !finite(co[0]) ||
|
||||
!finite(co[1]) ||
|
||||
!finite(co[2]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -743,33 +743,33 @@ static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, f
|
||||
CLAMP(fy, 0.0f, MOC_RES-MOC_THRESH);
|
||||
CLAMP(fz, 0.0f, MOC_RES-MOC_THRESH);
|
||||
|
||||
vx= floor(fx);
|
||||
vy= floor(fy);
|
||||
vz= floor(fz);
|
||||
|
||||
MOC_ADDNODE(vx, vy, vz);
|
||||
|
||||
if( vx>0 )
|
||||
if( fx-((float)vx)-MOC_THRESH < 0.0f)
|
||||
MOC_ADDNODE(vx-1, vy, vz);
|
||||
if( vx<MOC_RES-2 )
|
||||
if( fx-((float)vx)+MOC_THRESH > 1.0f)
|
||||
MOC_ADDNODE(vx+1, vy, vz);
|
||||
vx= (int)floorf(fx);
|
||||
vy= (int)floorf(fy);
|
||||
vz= (int)floorf(fz);
|
||||
|
||||
if( vy>0 )
|
||||
if( fy-((float)vy)-MOC_THRESH < 0.0f)
|
||||
MOC_ADDNODE(vx, vy-1, vz);
|
||||
if( vy<MOC_RES-2 )
|
||||
if( fy-((float)vy)+MOC_THRESH > 1.0f)
|
||||
MOC_ADDNODE(vx, vy+1, vz);
|
||||
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz), index);
|
||||
|
||||
if (vx > 0)
|
||||
if (fx-((float)vx)-MOC_THRESH < 0.0f)
|
||||
mesh_octree_add_node(basetable + MOC_INDEX(vx - 1, vy, vz), index);
|
||||
if (vx < MOC_RES - 2)
|
||||
if (fx-((float)vx)+MOC_THRESH > 1.0f)
|
||||
mesh_octree_add_node(basetable + MOC_INDEX(vx + 1, vy, vz), index);
|
||||
|
||||
if (vy > 0)
|
||||
if (fy-((float)vy)-MOC_THRESH < 0.0f)
|
||||
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy - 1, vz), index);
|
||||
if (vy < MOC_RES - 2)
|
||||
if (fy-((float)vy)+MOC_THRESH > 1.0f)
|
||||
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy + 1, vz), index);
|
||||
|
||||
if (vz > 0)
|
||||
if (fz-((float)vz)-MOC_THRESH < 0.0f)
|
||||
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz - 1), index);
|
||||
if (vz <MOC_RES - 2)
|
||||
if (fz-((float)vz)+MOC_THRESH > 1.0f)
|
||||
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz + 1), index);
|
||||
|
||||
if( vz>0 )
|
||||
if( fz-((float)vz)-MOC_THRESH < 0.0f)
|
||||
MOC_ADDNODE(vx, vy, vz-1);
|
||||
if( vz<MOC_RES-2 )
|
||||
if( fz-((float)vz)+MOC_THRESH > 1.0f)
|
||||
MOC_ADDNODE(vx, vy, vz+1);
|
||||
|
||||
}
|
||||
|
||||
static intptr_t mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co)
|
||||
@@ -904,35 +904,36 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode)
|
||||
|
||||
/* ********************* MESH VERTEX MIRR TOPO LOOKUP *************** */
|
||||
|
||||
#define MIRRHASH_TYPE int
|
||||
typedef int MirrTopoHash_t;
|
||||
|
||||
typedef struct MirrTopoPair {
|
||||
long hash;
|
||||
int vIndex;
|
||||
} MirrTopoPair;
|
||||
typedef struct MirrTopoPair_t {
|
||||
MirrTopoHash_t hash;
|
||||
int vIndex;
|
||||
} MirrTopoPair_t;
|
||||
|
||||
static int MirrTopo_long_sort(const void *l1, const void *l2)
|
||||
{
|
||||
if( (MIRRHASH_TYPE)(intptr_t)l1 > (MIRRHASH_TYPE)(intptr_t)l2 ) return 1;
|
||||
else if( (MIRRHASH_TYPE)(intptr_t)l1 < (MIRRHASH_TYPE)(intptr_t)l2 ) return -1;
|
||||
if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2 ) return 1;
|
||||
else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2 ) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int MirrTopo_item_sort(const void *v1, const void *v2)
|
||||
{
|
||||
if( ((MirrTopoPair *)v1)->hash > ((MirrTopoPair *)v2)->hash ) return 1;
|
||||
else if( ((MirrTopoPair *)v1)->hash < ((MirrTopoPair *)v2)->hash ) return -1;
|
||||
if (((MirrTopoPair_t *)v1)->hash > ((MirrTopoPair_t *)v2)->hash ) return 1;
|
||||
else if (((MirrTopoPair_t *)v1)->hash < ((MirrTopoPair_t *)v2)->hash ) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long *mesh_topo_lookup = NULL;
|
||||
static intptr_t *mesh_topo_lookup = NULL;
|
||||
static int mesh_topo_lookup_vert_tot = -1;
|
||||
static int mesh_topo_lookup_edge_tot = -1;
|
||||
static int mesh_topo_lookup_mode = -1;
|
||||
static int mesh_topo_lookup_mode = -1;
|
||||
|
||||
/* mode is 's' start, or 'e' end, or 'u' use */
|
||||
/* if end, ob can be NULL */
|
||||
long mesh_mirrtopo_table(Object *ob, char mode)
|
||||
/* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */
|
||||
int mesh_mirrtopo_table(Object *ob, char mode)
|
||||
{
|
||||
if(mode=='u') { /* use table */
|
||||
Mesh *me= ob->data;
|
||||
@@ -951,13 +952,14 @@ long mesh_mirrtopo_table(Object *ob, char mode)
|
||||
BMEditMesh *em= me->edit_btmesh;
|
||||
BMEdge *eed;
|
||||
BMIter iter;
|
||||
MIRRHASH_TYPE *MirrTopoHash = NULL;
|
||||
MIRRHASH_TYPE *MirrTopoHash_Prev = NULL;
|
||||
MirrTopoPair *MirrTopoPairs;
|
||||
int a, last;
|
||||
int totvert, totedge;
|
||||
int totUnique= -1, totUniqueOld= -1;
|
||||
|
||||
MirrTopoHash_t *MirrTopoHash = NULL;
|
||||
MirrTopoHash_t *MirrTopoHash_Prev = NULL;
|
||||
MirrTopoPair_t *MirrTopoPairs;
|
||||
|
||||
mesh_topo_lookup_mode= ob->mode;
|
||||
|
||||
/* reallocate if needed */
|
||||
@@ -975,7 +977,7 @@ long mesh_mirrtopo_table(Object *ob, char mode)
|
||||
totvert = me->totvert;
|
||||
}
|
||||
|
||||
MirrTopoHash = MEM_callocN( totvert * sizeof(MIRRHASH_TYPE), "TopoMirr" );
|
||||
MirrTopoHash = MEM_callocN( totvert * sizeof(MirrTopoHash_t), "TopoMirr" );
|
||||
|
||||
/* Initialize the vert-edge-user counts used to detect unique topology */
|
||||
if(em) {
|
||||
@@ -1011,10 +1013,10 @@ long mesh_mirrtopo_table(Object *ob, char mode)
|
||||
MirrTopoHash[medge->v2] += MirrTopoHash_Prev[medge->v1];
|
||||
}
|
||||
}
|
||||
memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MIRRHASH_TYPE) * totvert);
|
||||
memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MirrTopoHash_t) * totvert);
|
||||
|
||||
/* sort so we can count unique values */
|
||||
qsort(MirrTopoHash_Prev, totvert, sizeof(MIRRHASH_TYPE), MirrTopo_long_sort);
|
||||
qsort(MirrTopoHash_Prev, totvert, sizeof(MirrTopoHash_t), MirrTopo_long_sort);
|
||||
|
||||
totUnique = 1; /* account for skiping the first value */
|
||||
for(a=1; a<totvert; a++) {
|
||||
@@ -1031,11 +1033,11 @@ long mesh_mirrtopo_table(Object *ob, char mode)
|
||||
totUniqueOld = totUnique;
|
||||
}
|
||||
/* Copy the hash calculated this iter, so we can use them next time */
|
||||
memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MIRRHASH_TYPE) * totvert);
|
||||
memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MirrTopoHash_t) * totvert);
|
||||
}
|
||||
|
||||
/* Hash/Index pairs are needed for sorting to find index pairs */
|
||||
MirrTopoPairs= MEM_callocN( sizeof(MirrTopoPair) * totvert, "MirrTopoPairs");
|
||||
MirrTopoPairs= MEM_callocN( sizeof(MirrTopoPair_t) * totvert, "MirrTopoPairs");
|
||||
|
||||
/* since we are looping through verts, initialize these values here too */
|
||||
mesh_topo_lookup = MEM_mallocN( totvert * sizeof(long), "mesh_topo_lookup" );
|
||||
@@ -1053,7 +1055,7 @@ long mesh_mirrtopo_table(Object *ob, char mode)
|
||||
mesh_topo_lookup[a] = -1;
|
||||
}
|
||||
|
||||
qsort(MirrTopoPairs, totvert, sizeof(MirrTopoPair), MirrTopo_item_sort);
|
||||
qsort(MirrTopoPairs, totvert, sizeof(MirrTopoPair_t), MirrTopo_item_sort);
|
||||
|
||||
/* Since the loop starts at 2, we must define the last index where the hash's differ */
|
||||
last = ((totvert >= 2) && (MirrTopoPairs[0].hash == MirrTopoPairs[1].hash)) ? 0 : 1;
|
||||
@@ -1065,8 +1067,8 @@ long mesh_mirrtopo_table(Object *ob, char mode)
|
||||
if ((a==totvert) || (MirrTopoPairs[a-1].hash != MirrTopoPairs[a].hash)) {
|
||||
if (a-last==2) {
|
||||
if(em) {
|
||||
mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] = (long)EDBM_get_vert_for_index(em, MirrTopoPairs[a-2].vIndex);
|
||||
mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] = (long)EDBM_get_vert_for_index(em, MirrTopoPairs[a-1].vIndex);
|
||||
mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] = (intptr_t)EDBM_get_vert_for_index(em, MirrTopoPairs[a-2].vIndex);
|
||||
mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] = (intptr_t)EDBM_get_vert_for_index(em, MirrTopoPairs[a-1].vIndex);
|
||||
} else {
|
||||
mesh_topo_lookup[MirrTopoPairs[a-1].vIndex] = MirrTopoPairs[a-2].vIndex;
|
||||
mesh_topo_lookup[MirrTopoPairs[a-2].vIndex] = MirrTopoPairs[a-1].vIndex;
|
||||
@@ -1155,7 +1157,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spacial(Object *ob, BMEditMesh *em, f
|
||||
|
||||
static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *em, BMVert *eve, int index)
|
||||
{
|
||||
long poinval;
|
||||
intptr_t poinval;
|
||||
if (mesh_mirrtopo_table(ob, 'u')==-1)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -510,19 +510,9 @@ static EnumPropertyItem prop_make_parent_types[] = {
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
static int test_parent_loop(Object *par, Object *ob)
|
||||
{
|
||||
/* test if 'ob' is a parent somewhere in par's parents */
|
||||
|
||||
if(par == NULL) return 0;
|
||||
if(ob == par) return 1;
|
||||
|
||||
return test_parent_loop(par->parent, ob);
|
||||
}
|
||||
|
||||
void ED_object_parent(Object *ob, Object *par, int type, const char *substr)
|
||||
{
|
||||
if(!par || test_parent_loop(par, ob)) {
|
||||
if (!par || BKE_object_parent_loop_check(par, ob)) {
|
||||
ob->parent= NULL;
|
||||
ob->partype= PAROBJECT;
|
||||
ob->parsubstr[0]= 0;
|
||||
@@ -591,7 +581,7 @@ static int parent_set_exec(bContext *C, wmOperator *op)
|
||||
|
||||
if(ob!=par) {
|
||||
|
||||
if( test_parent_loop(par, ob) ) {
|
||||
if (BKE_object_parent_loop_check(par, ob)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
|
||||
}
|
||||
else {
|
||||
@@ -764,7 +754,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op)
|
||||
/* context iterator */
|
||||
CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
|
||||
if (ob != par) {
|
||||
if (test_parent_loop(par, ob)) {
|
||||
if (BKE_object_parent_loop_check(par, ob)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Loop in parents");
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -360,6 +360,8 @@ static EnumPropertyItem prop_column_select_types[] = {
|
||||
/* ------------------- */
|
||||
|
||||
/* Selects all visible keyframes between the specified markers */
|
||||
/* TODO, this is almost an _exact_ duplicate of a function of the same name in graph_select.c
|
||||
* should de-duplicate - campbell */
|
||||
static void markers_selectkeys_between (bAnimContext *ac)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
|
||||
@@ -386,6 +386,8 @@ static EnumPropertyItem prop_column_select_types[] = {
|
||||
/* ------------------- */
|
||||
|
||||
/* Selects all visible keyframes between the specified markers */
|
||||
/* TODO, this is almost an _exact_ duplicate of a function of the same name in action_select.c
|
||||
* should de-duplicate - campbell */
|
||||
static void markers_selectkeys_between (bAnimContext *ac)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
@@ -393,7 +395,7 @@ static void markers_selectkeys_between (bAnimContext *ac)
|
||||
int filter;
|
||||
|
||||
KeyframeEditFunc ok_cb, select_cb;
|
||||
KeyframeEditData ked;
|
||||
KeyframeEditData ked= {{NULL}};
|
||||
float min, max;
|
||||
|
||||
/* get extreme markers */
|
||||
@@ -404,9 +406,8 @@ static void markers_selectkeys_between (bAnimContext *ac)
|
||||
/* get editing funcs + data */
|
||||
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
|
||||
select_cb= ANIM_editkeyframes_select(SELECT_ADD);
|
||||
|
||||
memset(&ked, 0, sizeof(KeyframeEditData));
|
||||
ked.f1= min;
|
||||
|
||||
ked.f1= min;
|
||||
ked.f2= max;
|
||||
|
||||
/* filter data */
|
||||
@@ -416,8 +417,8 @@ static void markers_selectkeys_between (bAnimContext *ac)
|
||||
/* select keys in-between */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
if (adt) {
|
||||
|
||||
if (adt) {
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
|
||||
|
||||
@@ -312,269 +312,3 @@ void draw_motion_paths_cleanup(View3D *v3d)
|
||||
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
#if 0 // XXX temp file guards
|
||||
|
||||
/* ***************************** Onion Skinning (Ghosts) ******************************** */
|
||||
|
||||
#if 0 // XXX only for bones
|
||||
/* helper function for ghost drawing - sets/removes flags for temporarily
|
||||
* hiding unselected bones while drawing ghosts
|
||||
*/
|
||||
static void ghost_poses_tag_unselected(Object *ob, short unset)
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
bPose *pose= ob->pose;
|
||||
bPoseChannel *pchan;
|
||||
|
||||
/* don't do anything if no hiding any bones */
|
||||
if ((arm->flag & ARM_GHOST_ONLYSEL)==0)
|
||||
return;
|
||||
|
||||
/* loop over all pchans, adding/removing tags as appropriate */
|
||||
for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
if ((pchan->bone) && (arm->layer & pchan->bone->layer)) {
|
||||
if (unset) {
|
||||
/* remove tags from all pchans if cleaning up */
|
||||
pchan->bone->flag &= ~BONE_HIDDEN_PG;
|
||||
}
|
||||
else {
|
||||
/* set tags on unselected pchans only */
|
||||
if ((pchan->bone->flag & BONE_SELECTED)==0)
|
||||
pchan->bone->flag |= BONE_HIDDEN_PG;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // XXX only for bones
|
||||
|
||||
/* draw ghosts that occur within a frame range
|
||||
* note: object should be in posemode
|
||||
*/
|
||||
static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
|
||||
{
|
||||
Object *ob= base->object;
|
||||
AnimData *adt= BKE_animdata_from_id(&ob->id);
|
||||
bArmature *arm= ob->data;
|
||||
bPose *posen, *poseo;
|
||||
float start, end, stepsize, range, colfac;
|
||||
int cfrao, flago, ipoflago;
|
||||
|
||||
start = (float)arm->ghostsf;
|
||||
end = (float)arm->ghostef;
|
||||
if (end <= start)
|
||||
return;
|
||||
|
||||
stepsize= (float)(arm->ghostsize);
|
||||
range= (float)(end - start);
|
||||
|
||||
/* store values */
|
||||
ob->mode &= ~OB_MODE_POSE;
|
||||
cfrao= CFRA;
|
||||
flago= arm->flag;
|
||||
arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
|
||||
ipoflago= ob->ipoflag;
|
||||
ob->ipoflag |= OB_DISABLE_PATH;
|
||||
|
||||
/* copy the pose */
|
||||
poseo= ob->pose;
|
||||
copy_pose(&posen, ob->pose, 1);
|
||||
ob->pose= posen;
|
||||
armature_rebuild_pose(ob, ob->data); /* child pointers for IK */
|
||||
ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
|
||||
|
||||
/* draw from first frame of range to last */
|
||||
for (CFRA= (int)start; CFRA < end; CFRA += (int)stepsize) {
|
||||
colfac = (end - (float)CFRA) / range;
|
||||
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac)));
|
||||
|
||||
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
|
||||
where_is_pose(scene, ob);
|
||||
draw_pose_bones(scene, v3d, ar, base, OB_WIRE);
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
||||
|
||||
ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
|
||||
free_pose(posen);
|
||||
|
||||
/* restore */
|
||||
CFRA= cfrao;
|
||||
ob->pose= poseo;
|
||||
arm->flag= flago;
|
||||
armature_rebuild_pose(ob, ob->data);
|
||||
ob->mode |= OB_MODE_POSE;
|
||||
ob->ipoflag= ipoflago;
|
||||
}
|
||||
|
||||
/* draw ghosts on keyframes in action within range
|
||||
* - object should be in posemode
|
||||
*/
|
||||
static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
|
||||
{
|
||||
Object *ob= base->object;
|
||||
AnimData *adt= BKE_animdata_from_id(&ob->id);
|
||||
bAction *act= (adt) ? adt->action : NULL;
|
||||
bArmature *arm= ob->data;
|
||||
bPose *posen, *poseo;
|
||||
DLRBT_Tree keys;
|
||||
ActKeyColumn *ak, *akn;
|
||||
float start, end, range, colfac, i;
|
||||
int cfrao, flago;
|
||||
|
||||
start = (float)arm->ghostsf;
|
||||
end = (float)arm->ghostef;
|
||||
if (end <= start)
|
||||
return;
|
||||
|
||||
/* get keyframes - then clip to only within range */
|
||||
BLI_dlrbTree_init(&keys);
|
||||
action_to_keylist(adt, act, &keys, NULL);
|
||||
BLI_dlrbTree_linkedlist_sync(&keys);
|
||||
|
||||
range= 0;
|
||||
for (ak= keys.first; ak; ak= akn) {
|
||||
akn= ak->next;
|
||||
|
||||
if ((ak->cfra < start) || (ak->cfra > end))
|
||||
BLI_freelinkN((ListBase *)&keys, ak);
|
||||
else
|
||||
range++;
|
||||
}
|
||||
if (range == 0) return;
|
||||
|
||||
/* store values */
|
||||
ob->mode &= ~OB_MODE_POSE;
|
||||
cfrao= CFRA;
|
||||
flago= arm->flag;
|
||||
arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
|
||||
ob->ipoflag |= OB_DISABLE_PATH;
|
||||
|
||||
/* copy the pose */
|
||||
poseo= ob->pose;
|
||||
copy_pose(&posen, ob->pose, 1);
|
||||
ob->pose= posen;
|
||||
armature_rebuild_pose(ob, ob->data); /* child pointers for IK */
|
||||
ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
|
||||
|
||||
/* draw from first frame of range to last */
|
||||
for (ak=keys.first, i=0; ak; ak=ak->next, i++) {
|
||||
colfac = i/range;
|
||||
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac)));
|
||||
|
||||
CFRA= (int)ak->cfra;
|
||||
|
||||
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
|
||||
where_is_pose(scene, ob);
|
||||
draw_pose_bones(scene, v3d, ar, base, OB_WIRE);
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
||||
|
||||
ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
|
||||
BLI_dlrbTree_free(&keys);
|
||||
free_pose(posen);
|
||||
|
||||
/* restore */
|
||||
CFRA= cfrao;
|
||||
ob->pose= poseo;
|
||||
arm->flag= flago;
|
||||
armature_rebuild_pose(ob, ob->data);
|
||||
ob->mode |= OB_MODE_POSE;
|
||||
}
|
||||
|
||||
/* draw ghosts around current frame
|
||||
* - object is supposed to be armature in posemode
|
||||
*/
|
||||
static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base)
|
||||
{
|
||||
Object *ob= base->object;
|
||||
AnimData *adt= BKE_animdata_from_id(&ob->id);
|
||||
bArmature *arm= ob->data;
|
||||
bPose *posen, *poseo;
|
||||
float cur, start, end, stepsize, range, colfac, actframe, ctime;
|
||||
int cfrao, flago;
|
||||
|
||||
/* pre conditions, get an action with sufficient frames */
|
||||
if ELEM(NULL, adt, adt->action)
|
||||
return;
|
||||
|
||||
calc_action_range(adt->action, &start, &end, 0);
|
||||
if (start == end)
|
||||
return;
|
||||
|
||||
stepsize= (float)(arm->ghostsize);
|
||||
range= (float)(arm->ghostep)*stepsize + 0.5f; /* plus half to make the for loop end correct */
|
||||
|
||||
/* store values */
|
||||
ob->mode &= ~OB_MODE_POSE;
|
||||
cfrao= CFRA;
|
||||
actframe= BKE_nla_tweakedit_remap(adt, (float)CFRA, 0);
|
||||
flago= arm->flag;
|
||||
arm->flag &= ~(ARM_DRAWNAMES|ARM_DRAWAXES);
|
||||
|
||||
/* copy the pose */
|
||||
poseo= ob->pose;
|
||||
copy_pose(&posen, ob->pose, 1);
|
||||
ob->pose= posen;
|
||||
armature_rebuild_pose(ob, ob->data); /* child pointers for IK */
|
||||
ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
|
||||
|
||||
/* draw from darkest blend to lowest */
|
||||
for(cur= stepsize; cur<range; cur+=stepsize) {
|
||||
ctime= cur - (float)fmod(cfrao, stepsize); /* ensures consistent stepping */
|
||||
colfac= ctime/range;
|
||||
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac)));
|
||||
|
||||
/* only within action range */
|
||||
if (actframe+ctime >= start && actframe+ctime <= end) {
|
||||
CFRA= (int)BKE_nla_tweakedit_remap(adt, actframe+ctime, NLATIME_CONVERT_MAP);
|
||||
|
||||
if (CFRA != cfrao) {
|
||||
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
|
||||
where_is_pose(scene, ob);
|
||||
draw_pose_bones(scene, v3d, ar, base, OB_WIRE);
|
||||
}
|
||||
}
|
||||
|
||||
ctime= cur + (float)fmod((float)cfrao, stepsize) - stepsize+1.0f; /* ensures consistent stepping */
|
||||
colfac= ctime/range;
|
||||
UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128-(int)(120.0*sqrt(colfac)));
|
||||
|
||||
/* only within action range */
|
||||
if ((actframe-ctime >= start) && (actframe-ctime <= end)) {
|
||||
CFRA= (int)BKE_nla_tweakedit_remap(adt, actframe-ctime, NLATIME_CONVERT_MAP);
|
||||
|
||||
if (CFRA != cfrao) {
|
||||
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
|
||||
where_is_pose(scene, ob);
|
||||
draw_pose_bones(scene, v3d, ar, base, OB_WIRE);
|
||||
}
|
||||
}
|
||||
}
|
||||
glDisable(GL_BLEND);
|
||||
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
||||
|
||||
ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */
|
||||
free_pose(posen);
|
||||
|
||||
/* restore */
|
||||
CFRA= cfrao;
|
||||
ob->pose= poseo;
|
||||
arm->flag= flago;
|
||||
armature_rebuild_pose(ob, ob->data);
|
||||
ob->mode |= OB_MODE_POSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // XXX temp file guards
|
||||
|
||||
@@ -158,23 +158,6 @@ static int convex(float *p0, float *up, float *a, float *b)
|
||||
return dot_v3v3(up, tmp) >= 0;
|
||||
}
|
||||
|
||||
// copied from gpu_extension.c
|
||||
static int is_pow2(int n)
|
||||
{
|
||||
return ((n)&(n-1))==0;
|
||||
}
|
||||
|
||||
static int larger_pow2(int n)
|
||||
{
|
||||
if (is_pow2(n))
|
||||
return n;
|
||||
|
||||
while(!is_pow2(n))
|
||||
n= n&(n-1);
|
||||
|
||||
return n*2;
|
||||
}
|
||||
|
||||
void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3], float dx, GPUTexture *tex_shadow)
|
||||
{
|
||||
RegionView3D *rv3d= ar->regiondata;
|
||||
@@ -379,9 +362,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float *min, float *max, int res[3
|
||||
printf("No volume shadow\n");
|
||||
|
||||
if (!GPU_non_power_of_two_support()) {
|
||||
cor[0] = (float)res[0]/(float)larger_pow2(res[0]);
|
||||
cor[1] = (float)res[1]/(float)larger_pow2(res[1]);
|
||||
cor[2] = (float)res[2]/(float)larger_pow2(res[2]);
|
||||
cor[0] = (float)res[0]/(float)power_of_2_max_i(res[0]);
|
||||
cor[1] = (float)res[1]/(float)power_of_2_max_i(res[1]);
|
||||
cor[2] = (float)res[2]/(float)power_of_2_max_i(res[2]);
|
||||
}
|
||||
|
||||
// our slices are defined by the plane equation a*x + b*y +c*z + d = 0
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include "BKE_screen.h"
|
||||
#include "BKE_tessmesh.h"
|
||||
#include "BKE_deform.h"
|
||||
#include "BKE_object.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
@@ -1120,14 +1121,6 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
/* test if 'ob' is a parent somewhere in par's parents */
|
||||
static int test_parent_loop(Object *par, Object *ob)
|
||||
{
|
||||
if(par == NULL) return 0;
|
||||
if(ob == par) return 1;
|
||||
return test_parent_loop(par->parent, ob);
|
||||
}
|
||||
|
||||
static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
@@ -1159,7 +1152,7 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event
|
||||
/* note; this case also used for parbone */
|
||||
case B_OBJECTPANELPARENT:
|
||||
if(ob) {
|
||||
if(ob->id.lib || test_parent_loop(ob->parent, ob) )
|
||||
if (ob->id.lib || BKE_object_parent_loop_check(ob->parent, ob))
|
||||
ob->parent= NULL;
|
||||
else {
|
||||
DAG_scene_sort(bmain, scene);
|
||||
|
||||
@@ -189,20 +189,6 @@ void GPU_render_text(MTFace *tface, int mode,
|
||||
|
||||
/* Checking powers of two for images since opengl 1.x requires it */
|
||||
|
||||
static int is_pow2(int num)
|
||||
{
|
||||
/* (n&(n-1)) zeros the least significant bit of n */
|
||||
return ((num)&(num-1))==0;
|
||||
}
|
||||
|
||||
static int smaller_pow2(int num)
|
||||
{
|
||||
while (!is_pow2(num))
|
||||
num= num&(num-1);
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
static int is_pow2_limit(int num)
|
||||
{
|
||||
/* take texture clamping into account */
|
||||
@@ -214,7 +200,7 @@ static int is_pow2_limit(int num)
|
||||
if (U.glreslimit != 0 && num > U.glreslimit)
|
||||
return 0;
|
||||
|
||||
return ((num)&(num-1))==0;
|
||||
return is_power_of_2_i(num);
|
||||
}
|
||||
|
||||
static int smaller_pow2_limit(int num)
|
||||
@@ -227,7 +213,7 @@ static int smaller_pow2_limit(int num)
|
||||
if (U.glreslimit != 0 && num > U.glreslimit)
|
||||
return U.glreslimit;
|
||||
|
||||
return smaller_pow2(num);
|
||||
return power_of_2_min_i(num);
|
||||
}
|
||||
|
||||
/* Current OpenGL state caching for GPU_set_tpage */
|
||||
@@ -692,7 +678,7 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h, int mipmap)
|
||||
ibuf = BKE_image_get_ibuf(ima, NULL);
|
||||
|
||||
if (ima->repbind || (gpu_get_mipmap() && mipmap) || !ima->bindcode || !ibuf ||
|
||||
(!is_pow2(ibuf->x) || !is_pow2(ibuf->y)) ||
|
||||
(!is_power_of_2_i(ibuf->x) || !is_power_of_2_i(ibuf->y)) ||
|
||||
(w == 0) || (h == 0)) {
|
||||
/* these cases require full reload still */
|
||||
GPU_free_image(ima);
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#include "GPU_draw.h"
|
||||
#include "GPU_extensions.h"
|
||||
@@ -292,22 +293,6 @@ static unsigned char *GPU_texture_convert_pixels(int length, float *fpixels)
|
||||
return pixels;
|
||||
}
|
||||
|
||||
static int is_pow2(int n)
|
||||
{
|
||||
return ((n)&(n-1))==0;
|
||||
}
|
||||
|
||||
static int larger_pow2(int n)
|
||||
{
|
||||
if (is_pow2(n))
|
||||
return n;
|
||||
|
||||
while(!is_pow2(n))
|
||||
n= n&(n-1);
|
||||
|
||||
return n*2;
|
||||
}
|
||||
|
||||
static void GPU_glTexSubImageEmpty(GLenum target, GLenum format, int x, int y, int w, int h)
|
||||
{
|
||||
void *pixels = MEM_callocN(sizeof(char)*4*w*h, "GPUTextureEmptyPixels");
|
||||
@@ -353,8 +338,8 @@ static GPUTexture *GPU_texture_create_nD(int w, int h, int n, float *fpixels, in
|
||||
}
|
||||
|
||||
if (!GPU_non_power_of_two_support()) {
|
||||
tex->w = larger_pow2(tex->w);
|
||||
tex->h = larger_pow2(tex->h);
|
||||
tex->w = power_of_2_max_i(tex->w);
|
||||
tex->h = power_of_2_max_i(tex->h);
|
||||
}
|
||||
|
||||
tex->number = 0;
|
||||
@@ -462,9 +447,9 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels)
|
||||
}
|
||||
|
||||
if (!GPU_non_power_of_two_support()) {
|
||||
tex->w = larger_pow2(tex->w);
|
||||
tex->h = larger_pow2(tex->h);
|
||||
tex->depth = larger_pow2(tex->depth);
|
||||
tex->w = power_of_2_max_i(tex->w);
|
||||
tex->h = power_of_2_max_i(tex->h);
|
||||
tex->depth = power_of_2_max_i(tex->depth);
|
||||
}
|
||||
|
||||
tex->number = 0;
|
||||
|
||||
@@ -84,7 +84,7 @@ void register_node_type_sh_normal(bNodeTreeType *ttype)
|
||||
static bNodeType ntype;
|
||||
|
||||
node_type_base(ttype, &ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, NODE_OPTIONS);
|
||||
node_type_compatibility(&ntype, NODE_OLD_SHADING);
|
||||
node_type_compatibility(&ntype, NODE_OLD_SHADING|NODE_NEW_SHADING);
|
||||
node_type_socket_templates(&ntype, sh_node_normal_in, sh_node_normal_out);
|
||||
node_type_init(&ntype, node_shader_init_normal);
|
||||
node_type_exec(&ntype, node_shader_exec_normal);
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
@@ -355,36 +356,12 @@ typedef struct wmDrawTriple {
|
||||
GLenum target;
|
||||
} wmDrawTriple;
|
||||
|
||||
static int is_pow2(int n)
|
||||
{
|
||||
return ((n)&(n-1))==0;
|
||||
}
|
||||
|
||||
static int smaller_pow2(int n)
|
||||
{
|
||||
while (!is_pow2(n))
|
||||
n= n&(n-1);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static int larger_pow2(int n)
|
||||
{
|
||||
if (is_pow2(n))
|
||||
return n;
|
||||
|
||||
while(!is_pow2(n))
|
||||
n= n&(n-1);
|
||||
|
||||
return n*2;
|
||||
}
|
||||
|
||||
static void split_width(int x, int n, int *splitx, int *nx)
|
||||
{
|
||||
int a, newnx, waste;
|
||||
|
||||
/* if already power of two just use it */
|
||||
if(is_pow2(x)) {
|
||||
if(is_power_of_2_i(x)) {
|
||||
splitx[0]= x;
|
||||
(*nx)++;
|
||||
return;
|
||||
@@ -392,12 +369,12 @@ static void split_width(int x, int n, int *splitx, int *nx)
|
||||
|
||||
if(n == 1) {
|
||||
/* last part, we have to go larger */
|
||||
splitx[0]= larger_pow2(x);
|
||||
splitx[0]= power_of_2_max_i(x);
|
||||
(*nx)++;
|
||||
}
|
||||
else {
|
||||
/* two or more parts to go, use smaller part */
|
||||
splitx[0]= smaller_pow2(x);
|
||||
splitx[0]= power_of_2_min_i(x);
|
||||
newnx= ++(*nx);
|
||||
split_width(x-splitx[0], n-1, splitx+1, &newnx);
|
||||
|
||||
@@ -406,8 +383,8 @@ static void split_width(int x, int n, int *splitx, int *nx)
|
||||
|
||||
/* if we waste more space or use the same amount,
|
||||
* revert deeper splits and just use larger */
|
||||
if(waste >= larger_pow2(x)) {
|
||||
splitx[0]= larger_pow2(x);
|
||||
if(waste >= power_of_2_max_i(x)) {
|
||||
splitx[0]= power_of_2_max_i(x);
|
||||
memset(splitx+1, 0, sizeof(int)*(n-1));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -38,11 +38,11 @@ extern "C" {
|
||||
}
|
||||
|
||||
// (n&(n-1)) zeros the least significant bit of n
|
||||
static int is_pow2(int num) {
|
||||
static int is_power_of_2_i(int num) {
|
||||
return ((num)&(num-1))==0;
|
||||
}
|
||||
static int smaller_pow2(int num) {
|
||||
while (!is_pow2(num))
|
||||
static int power_of_2_min_i(int num) {
|
||||
while (!is_power_of_2_i(num))
|
||||
num= num&(num-1);
|
||||
return num;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ bool BL_Texture::InitFromImage(int unit, Image *img, bool mipmap)
|
||||
|
||||
void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap)
|
||||
{
|
||||
if (!is_pow2(x) || !is_pow2(y) ) {
|
||||
if (!is_power_of_2_i(x) || !is_power_of_2_i(y) ) {
|
||||
InitNonPow2Tex(pix, x,y,mipmap);
|
||||
return;
|
||||
}
|
||||
@@ -184,8 +184,8 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap)
|
||||
|
||||
void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap)
|
||||
{
|
||||
int nx= smaller_pow2(x);
|
||||
int ny= smaller_pow2(y);
|
||||
int nx= power_of_2_min_i(x);
|
||||
int ny= power_of_2_min_i(y);
|
||||
|
||||
unsigned int *newPixels = (unsigned int *)malloc(nx*ny*sizeof(unsigned int));
|
||||
|
||||
@@ -274,7 +274,7 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap)
|
||||
my_envmap_split_ima(cubemap, ibuf);
|
||||
|
||||
|
||||
if (!is_pow2(cubemap->cube[0]->x) || !is_pow2(cubemap->cube[0]->y))
|
||||
if (!is_power_of_2_i(cubemap->cube[0]->x) || !is_power_of_2_i(cubemap->cube[0]->y))
|
||||
{
|
||||
spit("invalid envmap size please render with CubeRes @ power of two");
|
||||
|
||||
@@ -610,8 +610,8 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate)
|
||||
|
||||
int BL_Texture::GetPow2(int n)
|
||||
{
|
||||
if(!is_pow2(n))
|
||||
n = smaller_pow2(n);
|
||||
if(!is_power_of_2_i(n))
|
||||
n = power_of_2_min_i(n);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user