Cleanup: trailing space
Remove from blender/nodes, collada, blenfont & render.
This commit is contained in:
parent
009c38df53
commit
a25c11fd8d
|
@ -164,7 +164,7 @@ static int blf_search_available(void)
|
|||
for (i = 0; i < BLF_MAX_FONT; i++)
|
||||
if (!global_font[i])
|
||||
return i;
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ static ListBase global_font_dir = { NULL, NULL };
|
|||
static DirBLF *blf_dir_find(const char *path)
|
||||
{
|
||||
DirBLF *p;
|
||||
|
||||
|
||||
p = global_font_dir.first;
|
||||
while (p) {
|
||||
if (BLI_path_cmp(p->path, path) == 0)
|
||||
|
@ -74,11 +74,11 @@ static DirBLF *blf_dir_find(const char *path)
|
|||
void BLF_dir_add(const char *path)
|
||||
{
|
||||
DirBLF *dir;
|
||||
|
||||
|
||||
dir = blf_dir_find(path);
|
||||
if (dir) /* already in the list ? just return. */
|
||||
return;
|
||||
|
||||
|
||||
dir = (DirBLF *)MEM_callocN(sizeof(DirBLF), "BLF_dir_add");
|
||||
dir->path = BLI_strdup(path);
|
||||
BLI_addhead(&global_font_dir, dir);
|
||||
|
@ -87,7 +87,7 @@ void BLF_dir_add(const char *path)
|
|||
void BLF_dir_rem(const char *path)
|
||||
{
|
||||
DirBLF *dir;
|
||||
|
||||
|
||||
dir = blf_dir_find(path);
|
||||
if (dir) {
|
||||
BLI_remlink(&global_font_dir, dir);
|
||||
|
@ -102,11 +102,11 @@ char **BLF_dir_get(int *ndir)
|
|||
char **dirs;
|
||||
char *path;
|
||||
int i, count;
|
||||
|
||||
|
||||
count = BLI_listbase_count(&global_font_dir);
|
||||
if (!count)
|
||||
return NULL;
|
||||
|
||||
|
||||
dirs = (char **)MEM_callocN(sizeof(char *) * count, "BLF_dir_get");
|
||||
p = global_font_dir.first;
|
||||
i = 0;
|
||||
|
@ -123,7 +123,7 @@ void BLF_dir_free(char **dirs, int count)
|
|||
{
|
||||
char *path;
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
path = dirs[i];
|
||||
MEM_freeN(path);
|
||||
|
@ -159,7 +159,7 @@ int blf_dir_split(const char *str, char *file, int *size)
|
|||
{
|
||||
int i, len;
|
||||
char *s;
|
||||
|
||||
|
||||
/* Window, Linux or Mac, this is always / */
|
||||
s = strrchr(str, '/');
|
||||
if (s) {
|
||||
|
|
|
@ -343,7 +343,7 @@ static void blf_font_draw_buffer_ex(
|
|||
width_clip -= chx + width_clip - buf_info->w;
|
||||
if (height_clip + pen_y > buf_info->h)
|
||||
height_clip -= pen_y + height_clip - buf_info->h;
|
||||
|
||||
|
||||
/* drawing below the image? */
|
||||
if (pen_y < 0) {
|
||||
yb_start += (g->pitch < 0) ? -pen_y : pen_y;
|
||||
|
|
|
@ -245,11 +245,11 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
|
|||
|
||||
if (font->flags & BLF_HINTING)
|
||||
flags &= ~FT_LOAD_NO_HINTING;
|
||||
|
||||
|
||||
if (is_sharp)
|
||||
err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_MONO);
|
||||
else
|
||||
err = FT_Load_Glyph(font->face, (FT_UInt)index, flags);
|
||||
err = FT_Load_Glyph(font->face, (FT_UInt)index, flags);
|
||||
|
||||
if (err) {
|
||||
BLI_spin_unlock(font->ft_lib_mutex);
|
||||
|
@ -336,13 +336,13 @@ static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, floa
|
|||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(uv[0][0], uv[0][1]);
|
||||
glVertex2f(dx, y1);
|
||||
|
||||
|
||||
glTexCoord2f(uv[0][0], uv[1][1]);
|
||||
glVertex2f(dx, y2);
|
||||
|
||||
|
||||
glTexCoord2f(uv[1][0], uv[1][1]);
|
||||
glVertex2f(dx1, y2);
|
||||
|
||||
|
||||
glTexCoord2f(uv[1][0], uv[0][1]);
|
||||
glVertex2f(dx1, y1);
|
||||
glEnd();
|
||||
|
@ -355,7 +355,7 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x
|
|||
2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f,
|
||||
1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f,
|
||||
1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f};
|
||||
|
||||
|
||||
const float *fp = soft;
|
||||
float color[4];
|
||||
float dx, dy;
|
||||
|
@ -363,7 +363,7 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x
|
|||
color[0] = shadow_col[0];
|
||||
color[1] = shadow_col[1];
|
||||
color[2] = shadow_col[2];
|
||||
|
||||
|
||||
for (dx = -2; dx < 3; dx++) {
|
||||
for (dy = -2; dy < 3; dy++, fp++) {
|
||||
color[3] = *(fp) * shadow_col[3];
|
||||
|
@ -371,7 +371,7 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x
|
|||
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glColor4fv(color);
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x
|
|||
blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glColor4fv(color);
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ typedef struct FontBLF {
|
|||
|
||||
/* angle in radians. */
|
||||
float angle;
|
||||
|
||||
|
||||
/* blur: 3 or 5 large kernel */
|
||||
int blur;
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve
|
|||
create_sampled_animation(3, ctimes, baked_curves[SCALE], ob_name, "scale", "", false);
|
||||
create_sampled_animation(3, ctimes, baked_curves[LOC], ob_name, "location", "", false);
|
||||
|
||||
/* Not sure how to export rotation as a 3channel animation,
|
||||
/* Not sure how to export rotation as a 3channel animation,
|
||||
* so separate into 3 single animations for now:
|
||||
*/
|
||||
|
||||
|
@ -314,7 +314,7 @@ void AnimationExporter::operator()(Object *ob)
|
|||
|
||||
//This needs to be handled by extra profiles, so postponed for now
|
||||
//export_morph_animation(ob);
|
||||
|
||||
|
||||
//Export Lamp parameter animations
|
||||
if ( (ob->type == OB_LAMP) && ((Lamp *)ob->data)->adt && ((Lamp *)ob->data)->adt->action) {
|
||||
FCurve *fcu = (FCurve *)(((Lamp *)ob->data)->adt->action->curves.first);
|
||||
|
@ -338,7 +338,7 @@ void AnimationExporter::operator()(Object *ob)
|
|||
|
||||
if ((STREQ(transformName, "lens")) ||
|
||||
(STREQ(transformName, "ortho_scale")) ||
|
||||
(STREQ(transformName, "clip_end")) ||
|
||||
(STREQ(transformName, "clip_end")) ||
|
||||
(STREQ(transformName, "clip_start")))
|
||||
{
|
||||
create_keyframed_animation(ob, fcu, transformName, true);
|
||||
|
@ -380,7 +380,7 @@ void AnimationExporter::export_object_constraint_animation(Object *ob)
|
|||
}
|
||||
|
||||
void AnimationExporter::export_morph_animation(Object *ob)
|
||||
{
|
||||
{
|
||||
FCurve *fcu;
|
||||
char *transformName;
|
||||
Key *key = BKE_key_from_object(ob);
|
||||
|
@ -388,12 +388,12 @@ void AnimationExporter::export_morph_animation(Object *ob)
|
|||
|
||||
if (key->adt && key->adt->action) {
|
||||
fcu = (FCurve *)key->adt->action->curves.first;
|
||||
|
||||
|
||||
while (fcu) {
|
||||
transformName = extract_transform_name(fcu->rna_path);
|
||||
|
||||
create_keyframed_animation(ob, fcu, transformName, true);
|
||||
|
||||
|
||||
fcu = fcu->next;
|
||||
}
|
||||
}
|
||||
|
@ -407,17 +407,17 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl
|
|||
bConstraint *con;
|
||||
for (con = (bConstraint *)conlist->first; con; con = con->next) {
|
||||
ListBase targets = {NULL, NULL};
|
||||
|
||||
|
||||
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
||||
|
||||
|
||||
if (!validateConstraints(con)) continue;
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
bConstraintTarget *ct;
|
||||
Object *obtar;
|
||||
/* get targets
|
||||
/* get targets
|
||||
* - constraints should use ct->matrix, not directly accessing values
|
||||
* - ct->matrix members have not yet been calculated here!
|
||||
* - ct->matrix members have not yet been calculated here!
|
||||
*/
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
|
@ -438,7 +438,7 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl
|
|||
float *AnimationExporter::get_eul_source_for_quat(Object *ob)
|
||||
{
|
||||
FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
|
||||
const int keys = fcu->totvert;
|
||||
const int keys = fcu->totvert;
|
||||
float *quat = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values");
|
||||
float *eul = (float *)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values");
|
||||
float temp_quat[4];
|
||||
|
@ -520,11 +520,11 @@ void AnimationExporter::create_keyframed_animation(Object *ob, FCurve *fcu, char
|
|||
|
||||
/*
|
||||
* Note: Handle transformation animations separately (to apply matrix inverse to fcurves)
|
||||
* We will use the object to evaluate the animation on all keyframes and calculate the
|
||||
* We will use the object to evaluate the animation on all keyframes and calculate the
|
||||
* resulting object matrix. We need this to incorporate the
|
||||
* effects of the parent inverse matrix (when it contains a rotation component)
|
||||
*
|
||||
* TODO: try to combine exported fcurves into 3 channel animations like done
|
||||
* TODO: try to combine exported fcurves into 3 channel animations like done
|
||||
* in export_sampled_animation(). For now each channel is exported as separate <Animation>.
|
||||
*/
|
||||
|
||||
|
@ -648,7 +648,7 @@ void AnimationExporter::create_keyframed_animation(Object *ob, FCurve *fcu, char
|
|||
"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true);
|
||||
//if shape key animation, this is the main problem, how to define the channel targets.
|
||||
/*target = get_morph_id(ob) +
|
||||
"/value" +*/
|
||||
"/value" +*/
|
||||
}
|
||||
addChannel(COLLADABU::URI(empty, sampler_id), target);
|
||||
|
||||
|
@ -673,7 +673,7 @@ void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone)
|
|||
}
|
||||
|
||||
bool AnimationExporter::is_bone_deform_group(Bone *bone)
|
||||
{
|
||||
{
|
||||
bool is_def;
|
||||
//Check if current bone is deform
|
||||
if ((bone->flag & BONE_NO_DEFORM) == 0) return true;
|
||||
|
@ -707,7 +707,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
|
|||
fcu = fcu->next;
|
||||
}
|
||||
|
||||
if (!(fcu)) return;*/
|
||||
if (!(fcu)) return;*/
|
||||
|
||||
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name);
|
||||
if (!pchan)
|
||||
|
@ -728,7 +728,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B
|
|||
dae_baked_animation(fra, ob_arm, bone);
|
||||
}
|
||||
|
||||
if (flag & ARM_RESTPOS)
|
||||
if (flag & ARM_RESTPOS)
|
||||
arm->flag = flag;
|
||||
BKE_pose_where_is(scene, ob_arm);
|
||||
}
|
||||
|
@ -921,7 +921,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa
|
|||
if (axis) {
|
||||
param.push_back(axis);
|
||||
}
|
||||
else
|
||||
else
|
||||
if (transform) {
|
||||
param.push_back("TRANSFORM");
|
||||
}
|
||||
|
@ -1307,7 +1307,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
|
|||
|
||||
enable_fcurves(ob->adt->action, bone->name);
|
||||
}
|
||||
|
||||
|
||||
std::vector<float>::iterator it;
|
||||
int j = 0;
|
||||
for (it = frames.begin(); it != frames.end(); it++) {
|
||||
|
@ -1325,7 +1325,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
|
|||
else {
|
||||
BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1);
|
||||
}
|
||||
|
||||
|
||||
// compute bone local mat
|
||||
if (bone->parent) {
|
||||
invert_m4_m4(ipar, parchan->pose_mat);
|
||||
|
@ -1333,7 +1333,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
|
|||
}
|
||||
else
|
||||
copy_m4_m4(mat, pchan->pose_mat);
|
||||
|
||||
|
||||
/* OPEN_SIM_COMPATIBILITY
|
||||
* AFAIK animation to second life is via BVH, but no
|
||||
* reason to not have the collada-animation be correct
|
||||
|
@ -1358,7 +1358,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
|
|||
else {
|
||||
copy_m4_m4(mat, ob->obmat);
|
||||
}
|
||||
|
||||
|
||||
UnitConverter converter;
|
||||
|
||||
double outmat[4][4];
|
||||
|
@ -1514,7 +1514,7 @@ std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type,
|
|||
if (tm_name.size()) {
|
||||
if (axis_name[0])
|
||||
return tm_name + "." + std::string(axis_name);
|
||||
else
|
||||
else
|
||||
return tm_name;
|
||||
}
|
||||
|
||||
|
@ -1563,7 +1563,7 @@ std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type,
|
|||
if (tm_name.size()) {
|
||||
if (axis_name[0])
|
||||
return tm_name + "." + std::string(axis_name);
|
||||
else
|
||||
else
|
||||
return tm_name;
|
||||
}
|
||||
|
||||
|
@ -1750,7 +1750,7 @@ void AnimationExporter::find_sampleframes(Object *ob, std::vector<float> &fra)
|
|||
} while (true);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* find keyframes of all the objects animations
|
||||
*/
|
||||
void AnimationExporter::find_keyframes(Object *ob, std::vector<float> &fra)
|
||||
|
@ -1843,7 +1843,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
|
|||
arm->flag &= ~ARM_RESTPOS;
|
||||
BKE_pose_where_is(scene, ob_arm);
|
||||
}
|
||||
//v array will hold all values which will be exported.
|
||||
//v array will hold all values which will be exported.
|
||||
if (fra.size()) {
|
||||
float *values = (float *)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames");
|
||||
sample_animation(values, fra, transform_type, bone, ob_arm, pchan);
|
||||
|
@ -1869,7 +1869,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo
|
|||
}
|
||||
|
||||
// restore restpos
|
||||
if (flag & ARM_RESTPOS)
|
||||
if (flag & ARM_RESTPOS)
|
||||
arm->flag = flag;
|
||||
BKE_pose_where_is(scene, ob_arm);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
@ -99,8 +99,8 @@ public:
|
|||
bool exportAnimations(Scene *sce);
|
||||
|
||||
// called for each exported object
|
||||
void operator() (Object *ob);
|
||||
|
||||
void operator() (Object *ob);
|
||||
|
||||
protected:
|
||||
const ExportSettings *export_settings;
|
||||
|
||||
|
@ -126,7 +126,7 @@ protected:
|
|||
// dae_bone_animation -> add_bone_animation
|
||||
// (blend this into dae_bone_animation)
|
||||
void dae_bone_animation(std::vector<float> &fra, float *v, int tm_type, int axis, std::string ob_name, std::string bone_name);
|
||||
|
||||
|
||||
void dae_baked_animation(std::vector<float> &fra, Object *ob_arm, Bone *bone);
|
||||
|
||||
void dae_baked_object_animation(std::vector<float> &fra, Object *ob);
|
||||
|
@ -139,9 +139,9 @@ protected:
|
|||
|
||||
void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param,
|
||||
COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform);
|
||||
|
||||
|
||||
void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool is_angle, float *values, int *length);
|
||||
|
||||
|
||||
float* get_eul_source_for_quat(Object *ob );
|
||||
|
||||
bool is_flat_line(std::vector<float> &values, int channel_count);
|
||||
|
@ -170,12 +170,12 @@ protected:
|
|||
std::string create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents);
|
||||
|
||||
std::string fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name);
|
||||
|
||||
|
||||
// for rotation, axis name is always appended and the value of append_axis is ignored
|
||||
std::string get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
|
||||
std::string get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
|
||||
std::string get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
|
||||
|
||||
|
||||
void find_keyframes(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name);
|
||||
void find_keyframes(Object *ob, std::vector<float> &fra);
|
||||
void find_sampleframes(Object *ob, std::vector<float> &fra);
|
||||
|
@ -184,13 +184,13 @@ protected:
|
|||
void make_anim_frames_from_targets(Object *ob, std::vector<float> &frames );
|
||||
|
||||
void find_rotation_frames(Object *ob, std::vector<float> &fra, const char *prefix, int rotmode);
|
||||
|
||||
|
||||
// enable fcurves driving a specific bone, disable all the rest
|
||||
// if bone_name = NULL enable all fcurves
|
||||
void enable_fcurves(bAction *act, char *bone_name);
|
||||
|
||||
|
||||
bool hasAnimations(Scene *sce);
|
||||
|
||||
|
||||
char *extract_transform_name(char *rna_path);
|
||||
|
||||
std::string getObjectBoneName(Object *ob, const FCurve * fcu);
|
||||
|
|
|
@ -118,7 +118,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
|
|||
|
||||
|
||||
// input, output
|
||||
bez.vec[1][0] = bc_get_float_value(input, j) * fps;
|
||||
bez.vec[1][0] = bc_get_float_value(input, j) * fps;
|
||||
bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
|
||||
|
||||
|
||||
|
@ -135,14 +135,14 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
|
|||
// outtangent
|
||||
bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i)) * fps;
|
||||
bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim) + (2 * i) + 1);
|
||||
if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER)
|
||||
if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER)
|
||||
bez.ipo = BEZT_IPO_BEZ;
|
||||
else
|
||||
else
|
||||
bez.ipo = BEZT_IPO_CONST;
|
||||
//bez.h1 = bez.h2 = HD_AUTO;
|
||||
}
|
||||
else {
|
||||
bez.h1 = bez.h2 = HD_AUTO;
|
||||
bez.h1 = bez.h2 = HD_AUTO;
|
||||
bez.ipo = BEZT_IPO_LIN;
|
||||
}
|
||||
// bez.ipo = U.ipo_new; /* use default interpolation mode here... */
|
||||
|
@ -183,10 +183,10 @@ void AnimationImporter::fcurve_is_used(FCurve *fcu)
|
|||
void AnimationImporter::add_fcurves_to_object(Main *bmain, Object *ob, std::vector<FCurve *>& curves, char *rna_path, int array_index, Animation *animated)
|
||||
{
|
||||
bAction *act;
|
||||
|
||||
|
||||
if (!ob->adt || !ob->adt->action) act = verify_adt_action(bmain, (ID *)&ob->id, 1);
|
||||
else act = ob->adt->action;
|
||||
|
||||
|
||||
std::vector<FCurve *>::iterator it;
|
||||
int i;
|
||||
|
||||
|
@ -198,39 +198,39 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, Object *ob, std::vect
|
|||
if (is_rotation)
|
||||
fcurve_deg_to_rad(fcu);
|
||||
#endif
|
||||
|
||||
|
||||
for (it = curves.begin(), i = 0; it != curves.end(); it++, i++) {
|
||||
FCurve *fcu = *it;
|
||||
fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
|
||||
|
||||
|
||||
if (array_index == -1) fcu->array_index = i;
|
||||
else fcu->array_index = array_index;
|
||||
|
||||
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
bActionGroup *grp = NULL;
|
||||
const char *bone_name = bc_get_joint_name(animated->node);
|
||||
|
||||
|
||||
if (bone_name) {
|
||||
/* try to find group */
|
||||
grp = BKE_action_group_find_name(act, bone_name);
|
||||
|
||||
|
||||
/* no matching groups, so add one */
|
||||
if (grp == NULL) {
|
||||
/* Add a new group, and make it active */
|
||||
grp = (bActionGroup *)MEM_callocN(sizeof(bActionGroup), "bActionGroup");
|
||||
|
||||
|
||||
grp->flag = AGRP_SELECTED;
|
||||
BLI_strncpy(grp->name, bone_name, sizeof(grp->name));
|
||||
|
||||
|
||||
BLI_addtail(&act->groups, grp);
|
||||
BLI_uniquename(&act->groups, grp, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "Group"), '.',
|
||||
offsetof(bActionGroup, name), 64);
|
||||
}
|
||||
|
||||
|
||||
/* add F-Curve to group */
|
||||
action_groups_add_channel(act, grp, fcu);
|
||||
fcurve_is_used(fcu);
|
||||
|
||||
|
||||
}
|
||||
#if 0
|
||||
if (is_rotation) {
|
||||
|
@ -263,7 +263,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
|
|||
{
|
||||
if (anim->getAnimationType() == COLLADAFW::Animation::ANIMATION_CURVE) {
|
||||
COLLADAFW::AnimationCurve *curve = (COLLADAFW::AnimationCurve *)anim;
|
||||
|
||||
|
||||
// XXX Don't know if it's necessary
|
||||
// Should we check outPhysicalDimension?
|
||||
if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) {
|
||||
|
@ -296,10 +296,10 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
|
|||
else {
|
||||
fprintf(stderr, "FORMULA animation type is not supported yet.\n");
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// called on post-process stage after writeVisualScenes
|
||||
bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList *animlist)
|
||||
{
|
||||
|
@ -340,16 +340,16 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
|
|||
{
|
||||
bActionGroup *grp;
|
||||
int i;
|
||||
|
||||
|
||||
for (grp = (bActionGroup *)act->groups.first; grp; grp = grp->next) {
|
||||
|
||||
FCurve *eulcu[3] = {NULL, NULL, NULL};
|
||||
|
||||
|
||||
if (fcurves_actionGroup_map.find(grp) == fcurves_actionGroup_map.end())
|
||||
continue;
|
||||
|
||||
std::vector<FCurve *> &rot_fcurves = fcurves_actionGroup_map[grp];
|
||||
|
||||
|
||||
if (rot_fcurves.size() > 3) continue;
|
||||
|
||||
for (i = 0; i < rot_fcurves.size(); i++)
|
||||
|
@ -437,7 +437,7 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves, const char
|
|||
for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) {
|
||||
FCurve *fcu = *it;
|
||||
fcu->rna_path = BLI_strdup(rna_path);
|
||||
|
||||
|
||||
if (array_index == -1) fcu->array_index = i;
|
||||
else fcu->array_index = array_index;
|
||||
|
||||
|
@ -674,7 +674,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
float AnimationImporter::convert_to_focal_length(float in_xfov, int fov_type, float aspect, float sensorx)
|
||||
|
@ -711,7 +711,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId& listid
|
|||
//Add the curves of the current animation to the object
|
||||
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
|
||||
FCurve *fcu = *iter;
|
||||
|
||||
|
||||
for (unsigned int i = 0; i < fcu->totvert; i++) {
|
||||
fcu->bezt[i].vec[0][1] = convert_to_focal_length(fcu->bezt[i].vec[0][1], fov_type, aspect, cam->sensor_x);
|
||||
fcu->bezt[i].vec[1][1] = convert_to_focal_length(fcu->bezt[i].vec[1][1], fov_type, aspect, cam->sensor_x);
|
||||
|
@ -949,7 +949,7 @@ void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node,
|
|||
|
||||
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
|
||||
|
||||
//for each transformation in node
|
||||
//for each transformation in node
|
||||
for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
|
||||
COLLADAFW::Transformation *transform = nodeTransforms[i];
|
||||
COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
|
||||
|
@ -986,12 +986,12 @@ void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node,
|
|||
//Add the curves of the current animation to the object
|
||||
for (iter = animcurves.begin(); iter != animcurves.end(); iter++) {
|
||||
FCurve *fcu = *iter;
|
||||
|
||||
|
||||
BLI_addtail(AnimCurves, fcu);
|
||||
fcurve_is_used(fcu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1017,7 +1017,7 @@ void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node,
|
|||
const COLLADAFW::Color *col = &(light->getColor());
|
||||
const COLLADAFW::UniqueId& listid = col->getAnimationList();
|
||||
|
||||
Assign_color_animations(listid, AnimCurves, "color");
|
||||
Assign_color_animations(listid, AnimCurves, "color");
|
||||
}
|
||||
if ((animType->light & LIGHT_FOA) != 0) {
|
||||
const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle());
|
||||
|
@ -1051,14 +1051,14 @@ void AnimationImporter::translate_Animations(Main *bmain, COLLADAFW::Node *node,
|
|||
if ((animType->camera & CAMERA_XFOV) != 0) {
|
||||
const COLLADAFW::AnimatableFloat *xfov = &(camera->getXFov());
|
||||
const COLLADAFW::UniqueId& listid = xfov->getAnimationList();
|
||||
double aspect = get_aspect_ratio(camera);
|
||||
double aspect = get_aspect_ratio(camera);
|
||||
Assign_lens_animations(listid, AnimCurves, aspect, cam, "lens", CAMERA_XFOV);
|
||||
}
|
||||
|
||||
else if ((animType->camera & CAMERA_YFOV) != 0) {
|
||||
const COLLADAFW::AnimatableFloat *yfov = &(camera->getYFov());
|
||||
const COLLADAFW::UniqueId& listid = yfov->getAnimationList();
|
||||
double aspect = get_aspect_ratio(camera);
|
||||
double aspect = get_aspect_ratio(camera);
|
||||
Assign_lens_animations(listid, AnimCurves, aspect, cam, "lens", CAMERA_YFOV);
|
||||
}
|
||||
|
||||
|
@ -1281,7 +1281,7 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(const COLLADAF
|
|||
|
||||
const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
|
||||
|
||||
//for each transformation in node
|
||||
//for each transformation in node
|
||||
for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
|
||||
COLLADAFW::Transformation *transform = nodeTransforms[i];
|
||||
const COLLADAFW::UniqueId& listid = transform->getAnimationList();
|
||||
|
@ -1369,7 +1369,7 @@ int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types,
|
|||
anim_type = types;
|
||||
|
||||
return anim_type;
|
||||
}
|
||||
}
|
||||
|
||||
// Is not used anymore.
|
||||
void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::Node *node, COLLADAFW::Transformation::TransformationType tm_type)
|
||||
|
@ -1391,7 +1391,7 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames, COLLADAFW::N
|
|||
const COLLADAFW::UniqueId& listid = transform->getAnimationList();
|
||||
//if transform is animated its animlist must exist.
|
||||
if (animlist_map.find(listid) != animlist_map.end()) {
|
||||
|
||||
|
||||
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
|
||||
const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
|
||||
|
||||
|
@ -1441,11 +1441,11 @@ Object *AnimationImporter::translate_animation_OLD(Main *bmain, COLLADAFW::Node
|
|||
COLLADAFW::Transformation::TransformationType tm_type,
|
||||
Object *par_job)
|
||||
{
|
||||
|
||||
|
||||
bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
|
||||
bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
|
||||
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
|
||||
|
||||
|
||||
COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()];
|
||||
Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) : object_map[node->getUniqueId()];
|
||||
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
|
||||
|
@ -1456,11 +1456,11 @@ Object *AnimationImporter::translate_animation_OLD(Main *bmain, COLLADAFW::Node
|
|||
|
||||
// frames at which to sample
|
||||
std::vector<float> frames;
|
||||
|
||||
|
||||
find_frames_old(&frames, node, tm_type);
|
||||
|
||||
|
||||
unsigned int i;
|
||||
|
||||
|
||||
float irest_dae[4][4];
|
||||
float rest[4][4], irest[4][4];
|
||||
|
||||
|
@ -1731,9 +1731,9 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::
|
|||
}
|
||||
}
|
||||
|
||||
static void report_class_type_unsupported(const char *path,
|
||||
static void report_class_type_unsupported(const char *path,
|
||||
const COLLADAFW::AnimationList::AnimationClass animclass,
|
||||
const COLLADAFW::Transformation::TransformationType type)
|
||||
const COLLADAFW::Transformation::TransformationType type)
|
||||
{
|
||||
if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) {
|
||||
fprintf(stderr, "%s: UNKNOWN animation class\n", path);
|
||||
|
@ -1828,7 +1828,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float
|
|||
fprintf(stderr, "%s: expected 1 curve, got %d\n", path, (int)curves.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
switch (animclass) {
|
||||
case COLLADAFW::AnimationList::POSITION_X:
|
||||
vec[0] = evaluate_fcurve(curves[0], fra);
|
||||
|
@ -2010,7 +2010,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv
|
|||
{
|
||||
const char *bone_name = bc_get_joint_name(node);
|
||||
bAction *act = ob->adt->action;
|
||||
|
||||
|
||||
/* try to find group */
|
||||
bActionGroup *grp = BKE_action_group_find_name(act, bone_name);
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
|
||||
/** \file AnimationImporter.h
|
||||
* \ingroup collada
|
||||
*/
|
||||
|
@ -75,9 +75,9 @@ private:
|
|||
std::map<COLLADAFW::UniqueId, const COLLADAFW::AnimationList*> animlist_map;
|
||||
std::vector<FCurve*> unused_curves;
|
||||
std::map<COLLADAFW::UniqueId, Object*> joint_objects;
|
||||
|
||||
|
||||
FCurve *create_fcurve(int array_index, const char *rna_path);
|
||||
|
||||
|
||||
void add_bezt(FCurve *fcu, float frame, float value, eBezTriple_Interpolation ipo=BEZT_IPO_LIN);
|
||||
|
||||
// create one or several fcurves depending on the number of parameters being animated
|
||||
|
@ -89,7 +89,7 @@ private:
|
|||
|
||||
void add_fcurves_to_object(Main *bmain, Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated);
|
||||
|
||||
|
||||
|
||||
int typeFlag;
|
||||
|
||||
std::string import_from_version;
|
||||
|
@ -121,7 +121,7 @@ private:
|
|||
MATERIAL_TRANSPARENCY = 1 << 4,
|
||||
MATERIAL_IOR = 1 << 5
|
||||
};
|
||||
|
||||
|
||||
enum AnimationType
|
||||
{
|
||||
INANIMATE = 0,
|
||||
|
@ -144,7 +144,7 @@ public:
|
|||
|
||||
void set_import_from_version(std::string import_from_version);
|
||||
bool write_animation(const COLLADAFW::Animation* anim);
|
||||
|
||||
|
||||
// called on post-process stage after writeVisualScenes
|
||||
bool write_animation_list(const COLLADAFW::AnimationList* animlist);
|
||||
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
|
||||
void apply_matrix_curves(Main *bmain, Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node,
|
||||
COLLADAFW::Transformation * tm );
|
||||
|
||||
|
||||
void add_bone_animation_sampled(Main *bmain, Object *ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node, COLLADAFW::Transformation * tm);
|
||||
|
||||
void Assign_transform_animations(COLLADAFW::Transformation* transform,
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
void Assign_lens_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, const double aspect, Camera *cam, const char *anim_type, int fov_type);
|
||||
|
||||
int setAnimType ( const COLLADAFW::Animatable * prop, int type, int addition);
|
||||
|
||||
|
||||
void modify_fcurve(std::vector<FCurve*>* curves, const char *rna_path, int array_index );
|
||||
void unused_fcurve(std::vector<FCurve*>* curves );
|
||||
// prerequisites:
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
|
||||
COLLADAFW::Transformation::TransformationType tm_type,
|
||||
Object *par_job = NULL);
|
||||
|
||||
|
||||
void find_frames( std::vector<float>* frames, std::vector<FCurve*>* curves );
|
||||
void find_frames_old( std::vector<float>* frames, COLLADAFW::Node * node, COLLADAFW::Transformation::TransformationType tm_type );
|
||||
// internal, better make it private
|
||||
|
|
|
@ -117,11 +117,11 @@ bool ArmatureExporter::add_instance_controller(Object *ob)
|
|||
write_bone_URLs(ins, ob_arm, bone);
|
||||
}
|
||||
|
||||
InstanceWriter::add_material_bindings(ins.getBindMaterial(),
|
||||
ob,
|
||||
InstanceWriter::add_material_bindings(ins.getBindMaterial(),
|
||||
ob,
|
||||
this->export_settings->active_uv_only,
|
||||
this->export_settings->export_texture_type);
|
||||
|
||||
|
||||
ins.add();
|
||||
return true;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
|
|||
Base *base = (Base *) sce->base.first;
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
|
||||
if (ob->type == OB_MESH && get_assigned_armature(ob) == ob_arm) {
|
||||
objects.push_back(ob);
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
|
|||
if (!has_restmat) {
|
||||
|
||||
/* Have no restpose matrix stored, try old style <= Blender 2.78 */
|
||||
|
||||
|
||||
bc_create_restpose_mat(this->export_settings, bone, bone_rest_mat, bone->arm_mat, true);
|
||||
|
||||
if (bone->parent) {
|
||||
|
|
|
@ -59,7 +59,7 @@ ArmatureImporter::ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh,
|
|||
scene(sce),
|
||||
unit_converter(conv),
|
||||
import_settings(import_settings),
|
||||
empty(NULL),
|
||||
empty(NULL),
|
||||
mesh_importer(mesh) {
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
|
|||
std::vector<COLLADAFW::Node *>::iterator it;
|
||||
it = std::find(finished_joints.begin(), finished_joints.end(), node);
|
||||
if (it != finished_joints.end()) return chain_length;
|
||||
|
||||
|
||||
EditBone *bone = ED_armature_ebone_add(arm, bc_get_joint_name(node));
|
||||
totbone++;
|
||||
|
||||
|
@ -139,7 +139,7 @@ int ArmatureImporter::create_bone(SkinInfo *skin, COLLADAFW::Node *node, EditBon
|
|||
|
||||
if (parent) bone->parent = parent;
|
||||
|
||||
float loc[3], size[3], rot[3][3];
|
||||
float loc[3], size[3], rot[3][3];
|
||||
BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(arm);
|
||||
BoneExtended &be = add_bone_extended(bone, node, totchild, layer_labels, extended_bones);
|
||||
int layer = be.get_bone_layers();
|
||||
|
@ -384,7 +384,7 @@ void ArmatureImporter::set_euler_rotmode()
|
|||
COLLADAFW::Node *joint = it->second;
|
||||
|
||||
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator sit;
|
||||
|
||||
|
||||
for (sit = skin_by_data_uid.begin(); sit != skin_by_data_uid.end(); sit++) {
|
||||
SkinInfo& skin = sit->second;
|
||||
|
||||
|
@ -408,7 +408,7 @@ void ArmatureImporter::set_euler_rotmode()
|
|||
Object *ArmatureImporter::get_empty_for_leaves()
|
||||
{
|
||||
if (empty) return empty;
|
||||
|
||||
|
||||
empty = bc_add_object(scene, OB_EMPTY, NULL);
|
||||
empty->empty_drawtype = OB_EMPTY_SPHERE;
|
||||
|
||||
|
@ -454,7 +454,7 @@ void ArmatureImporter::create_armature_bones(Main *bmain, std::vector<Object *>
|
|||
//if there is an armature created for root_joint next root_joint
|
||||
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
|
||||
if (get_armature_for_joint(*ri) != NULL) continue;
|
||||
|
||||
|
||||
Object *ob_arm = joint_parent_map[(*ri)->getUniqueId()];
|
||||
if (!ob_arm)
|
||||
continue;
|
||||
|
@ -570,8 +570,8 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo& skin)
|
|||
}
|
||||
|
||||
if (!shared && this->joint_parent_map.size() > 0) {
|
||||
// All armatures have been created while creating the Node tree.
|
||||
// The Collada exporter currently does not create a
|
||||
// All armatures have been created while creating the Node tree.
|
||||
// The Collada exporter currently does not create a
|
||||
// strict relationship between geometries and armatures
|
||||
// So when we reimport a Blender collada file, then we have
|
||||
// to guess what is meant.
|
||||
|
@ -655,12 +655,12 @@ void ArmatureImporter::set_pose(Object *ob_arm, COLLADAFW::Node *root_node, con
|
|||
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
copy_m4_m4(mat, obmat);
|
||||
float invObmat[4][4];
|
||||
invert_m4_m4(invObmat, ob_arm->obmat);
|
||||
mul_m4_m4m4(pchan->pose_mat, invObmat, mat);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//float angle = 0.0f;
|
||||
|
@ -756,7 +756,7 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
|
|||
// free memory stolen from SkinControllerData
|
||||
skin.free();
|
||||
}
|
||||
|
||||
|
||||
//for bones without skins
|
||||
create_armature_bones(bmain, ob_arms);
|
||||
|
||||
|
@ -806,9 +806,9 @@ bool ArmatureImporter::write_skin_controller_data(const COLLADAFW::SkinControlle
|
|||
|
||||
// don't forget to call defgroup_unique_name before we copy
|
||||
|
||||
// controller data uid -> [armature] -> joint data,
|
||||
// controller data uid -> [armature] -> joint data,
|
||||
// [mesh object]
|
||||
//
|
||||
//
|
||||
|
||||
SkinInfo skin(unit_converter);
|
||||
skin.borrow_skin_controller_data(data);
|
||||
|
@ -866,7 +866,7 @@ void ArmatureImporter::make_shape_keys()
|
|||
|
||||
//Prereq: all the geometries must be imported and mesh objects must be made
|
||||
Object *source_ob = this->mesh_importer->get_object_by_geom_uid((*mc)->getSource());
|
||||
|
||||
|
||||
if (source_ob) {
|
||||
|
||||
Mesh *source_me = (Mesh *)source_ob->data;
|
||||
|
@ -874,7 +874,7 @@ void ArmatureImporter::make_shape_keys()
|
|||
Key *key = source_me->key = BKE_key_add((ID *)source_me);
|
||||
key->type = KEY_RELATIVE;
|
||||
KeyBlock *kb;
|
||||
|
||||
|
||||
//insert basis key
|
||||
kb = BKE_keyblock_add_ctime(key, "Basis", false);
|
||||
BKE_keyblock_convert_from_mesh(source_me, kb);
|
||||
|
@ -885,14 +885,14 @@ void ArmatureImporter::make_shape_keys()
|
|||
//This'll do for now since only mesh morphing is imported
|
||||
|
||||
Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]);
|
||||
|
||||
|
||||
if (me) {
|
||||
me->key = key;
|
||||
std::string morph_name = *this->mesh_importer->get_geometry_name(me->id.name);
|
||||
|
||||
kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), false);
|
||||
BKE_keyblock_convert_from_mesh(me, kb);
|
||||
|
||||
|
||||
//apply weights
|
||||
weight = morphWeights.getFloatValues()->getData()[i];
|
||||
kb->curval = weight;
|
||||
|
@ -988,14 +988,14 @@ BoneExtended &ArmatureImporter::add_bone_extended(EditBone *bone, COLLADAFW::Nod
|
|||
|
||||
has_connect = et->setData("connect", &connect_type);
|
||||
bool has_roll = et->setData("roll", &roll);
|
||||
|
||||
|
||||
layers = et->setData("layer", layers);
|
||||
|
||||
if (has_tail && !has_connect)
|
||||
{
|
||||
/* got a bone tail definition but no connect info -> bone is not connected */
|
||||
has_connect = true;
|
||||
connect_type = 0;
|
||||
connect_type = 0;
|
||||
}
|
||||
|
||||
be->set_bone_layers(layers, layer_labels);
|
||||
|
|
|
@ -157,16 +157,16 @@ public:
|
|||
bool write_controller(const COLLADAFW::Controller* controller);
|
||||
|
||||
COLLADAFW::UniqueId *get_geometry_uid(const COLLADAFW::UniqueId& controller_uid);
|
||||
|
||||
|
||||
Object *get_armature_for_joint(COLLADAFW::Node *node);
|
||||
|
||||
void get_rna_path_for_joint(COLLADAFW::Node *node, char *joint_path, size_t count);
|
||||
|
||||
|
||||
// gives a world-space mat
|
||||
bool get_joint_bind_mat(float m[4][4], COLLADAFW::Node *joint);
|
||||
|
||||
void set_tags_map( TagsMap& tags_map);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -56,9 +56,9 @@ void forEachCameraObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set
|
|||
void CamerasExporter::exportCameras(Scene *sce)
|
||||
{
|
||||
openLibrary();
|
||||
|
||||
|
||||
forEachCameraObjectInExportSet(sce, *this, this->export_settings->export_set);
|
||||
|
||||
|
||||
closeLibrary();
|
||||
}
|
||||
void CamerasExporter::operator()(Object *ob, Scene *sce)
|
||||
|
|
|
@ -99,10 +99,10 @@ bool ControllerExporter::add_instance_controller(Object *ob)
|
|||
}
|
||||
|
||||
InstanceWriter::add_material_bindings(ins.getBindMaterial(),
|
||||
ob,
|
||||
ob,
|
||||
this->export_settings->active_uv_only,
|
||||
this->export_settings->export_texture_type);
|
||||
|
||||
|
||||
ins.add();
|
||||
return true;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O
|
|||
Base *base = (Base *) sce->base.first;
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
|
||||
|
||||
if (ob->type == OB_MESH && get_assigned_armature(ob) == ob_arm) {
|
||||
objects.push_back(ob);
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
|
|||
this->export_settings->export_mesh_type,
|
||||
this->export_settings->apply_modifiers,
|
||||
this->export_settings->triangulate);
|
||||
|
||||
|
||||
if (!me->dvert) return;
|
||||
|
||||
std::string controller_name = id_name(ob_arm);
|
||||
|
@ -248,7 +248,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
|
|||
for (j = 0; j < vert->totweight; j++) {
|
||||
int idx = vert->dw[j].def_nr;
|
||||
if (idx >= joint_index_by_def_index.size()) {
|
||||
// XXX: Maybe better find out where and
|
||||
// XXX: Maybe better find out where and
|
||||
// why the Out Of Bound indexes get created ?
|
||||
oob_counter += 1;
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ void ControllerExporter::export_morph_controller(Object *ob, Key *key)
|
|||
|
||||
std::string targets_id = add_morph_targets(key, ob);
|
||||
std::string morph_weights_id = add_morph_weights(key, ob);
|
||||
|
||||
|
||||
COLLADASW::TargetsElement targets(mSW);
|
||||
|
||||
COLLADASW::InputList &input = targets.getInputList();
|
||||
|
@ -378,7 +378,7 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
|
|||
|
||||
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
||||
param.push_back("MORPH_WEIGHT");
|
||||
|
||||
|
||||
source.prepareToAppendValues();
|
||||
|
||||
KeyBlock *kb = (KeyBlock *)key->block.first;
|
||||
|
@ -398,7 +398,7 @@ void ControllerExporter::add_weight_extras(Key *key)
|
|||
{
|
||||
// can also try the base element and param alternative
|
||||
COLLADASW::BaseExtraTechnique extra;
|
||||
|
||||
|
||||
KeyBlock * kb = (KeyBlock *)key->block.first;
|
||||
//skip the basis
|
||||
kb = kb->next;
|
||||
|
@ -449,7 +449,7 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm, ListBase *defb
|
|||
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
|
||||
source.setAccessorCount(totjoint);
|
||||
source.setAccessorStride(1);
|
||||
|
||||
|
||||
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
||||
param.push_back("JOINT");
|
||||
|
||||
|
@ -482,7 +482,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
|
|||
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
|
||||
source.setAccessorCount(totjoint); //BLI_listbase_count(defbase));
|
||||
source.setAccessorStride(16);
|
||||
|
||||
|
||||
source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4);
|
||||
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
||||
param.push_back("TRANSFORM");
|
||||
|
@ -511,7 +511,7 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm, ListBas
|
|||
float bind_mat[4][4]; /* derived from bone->arm_mat */
|
||||
|
||||
bool has_bindmat = bc_get_property_matrix(pchan->bone, "bind_mat", bind_mat);
|
||||
|
||||
|
||||
if (!has_bindmat) {
|
||||
|
||||
/* Have no bind matrix stored, try old style <= Blender 2.78 */
|
||||
|
@ -573,7 +573,7 @@ std::string ControllerExporter::add_weights_source(Mesh *me, const std::string&
|
|||
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
|
||||
source.setAccessorCount(weights.size());
|
||||
source.setAccessorStride(1);
|
||||
|
||||
|
||||
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
||||
param.push_back("WEIGHT");
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
#include "COLLADASWInstanceNode.h"
|
||||
#include "COLLADASWBaseInputElement.h"
|
||||
|
||||
extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
@ -258,14 +258,14 @@ int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *e
|
|||
#endif
|
||||
asset.getContributor().mAuthoringTool = version_buf;
|
||||
asset.add();
|
||||
|
||||
|
||||
LinkNode *export_set = this->export_settings->export_set;
|
||||
// <library_cameras>
|
||||
if (bc_has_object_type(export_set, OB_CAMERA)) {
|
||||
CamerasExporter ce(writer, this->export_settings);
|
||||
ce.exportCameras(sce);
|
||||
}
|
||||
|
||||
|
||||
// <library_lights>
|
||||
if (bc_has_object_type(export_set, OB_LAMP)) {
|
||||
LightsExporter le(writer, this->export_settings);
|
||||
|
@ -275,11 +275,11 @@ int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *e
|
|||
// <library_images>
|
||||
ImagesExporter ie(writer, this->export_settings);
|
||||
ie.exportImages(sce);
|
||||
|
||||
|
||||
// <library_effects>
|
||||
EffectsExporter ee(writer, this->export_settings);
|
||||
ee.exportEffects(sce);
|
||||
|
||||
|
||||
// <library_materials>
|
||||
MaterialsExporter me(writer, this->export_settings);
|
||||
me.exportMaterials(sce);
|
||||
|
@ -293,7 +293,7 @@ int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *e
|
|||
// <library_controllers>
|
||||
ArmatureExporter arm_exporter(writer, this->export_settings);
|
||||
ControllerExporter controller_exporter(writer, this->export_settings);
|
||||
if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys)
|
||||
if (bc_has_object_type(export_set, OB_ARMATURE) || this->export_settings->include_shapekeys)
|
||||
{
|
||||
controller_exporter.export_controllers(sce);
|
||||
}
|
||||
|
@ -308,13 +308,13 @@ int DocumentExporter::exportCurrentScene(bContext *C, const EvaluationContext *e
|
|||
ae.exportAnimations(sce);
|
||||
}
|
||||
se.exportScene(C, sce);
|
||||
|
||||
|
||||
// <scene>
|
||||
std::string scene_name(translate_id(id_name(sce)));
|
||||
COLLADASW::Scene scene(writer, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING,
|
||||
scene_name));
|
||||
scene.add();
|
||||
|
||||
|
||||
// close <Collada>
|
||||
writer->endDocument();
|
||||
delete writer;
|
||||
|
|
|
@ -126,7 +126,7 @@ bool DocumentImporter::import()
|
|||
COLLADASaxFWL::Loader loader(&errorHandler);
|
||||
COLLADAFW::Root root(&loader, this);
|
||||
ExtraHandler *ehandler = new ExtraHandler(this, &(this->anim_importer));
|
||||
|
||||
|
||||
loader.registerExtraDataCallbackHandler(ehandler);
|
||||
|
||||
// deselect all to select new objects
|
||||
|
@ -139,19 +139,19 @@ bool DocumentImporter::import()
|
|||
delete ehandler;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (errorHandler.hasError()) {
|
||||
delete ehandler;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** TODO set up scene graph and such here */
|
||||
|
||||
|
||||
mImportStage = Controller;
|
||||
|
||||
|
||||
COLLADASaxFWL::Loader loader2;
|
||||
COLLADAFW::Root root2(&loader2, this);
|
||||
|
||||
|
||||
if (!root2.loadDocument(encodedFilename)) {
|
||||
fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 2nd pass\n");
|
||||
delete ehandler;
|
||||
|
@ -194,7 +194,7 @@ void DocumentImporter::finish()
|
|||
for (sit = vscenes.begin(); sit != vscenes.end(); sit++) {
|
||||
PointerRNA sceneptr, unit_settings;
|
||||
PropertyRNA *system, *scale;
|
||||
|
||||
|
||||
// for scene unit settings: system, scale_length
|
||||
|
||||
RNA_id_pointer_create(&sce->id, &sceneptr);
|
||||
|
@ -203,7 +203,7 @@ void DocumentImporter::finish()
|
|||
scale = RNA_struct_find_property(&unit_settings, "scale_length");
|
||||
|
||||
if (this->import_settings->import_units) {
|
||||
|
||||
|
||||
switch (unit_converter.isMetricSystem()) {
|
||||
case UnitConverter::Metric:
|
||||
RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC);
|
||||
|
@ -276,7 +276,7 @@ void DocumentImporter::finish()
|
|||
|
||||
DAG_relations_tag_update(bmain);
|
||||
}
|
||||
|
||||
|
||||
bc_match_scale(objects_to_scale, unit_converter, !this->import_settings->import_units);
|
||||
|
||||
delete objects_to_scale;
|
||||
|
@ -477,7 +477,7 @@ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob)
|
|||
short type = 0;
|
||||
et->setData("type", &type);
|
||||
BKE_constraint_add_for_object(ob, "Test_con", type);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,7 +639,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA
|
|||
root_objects->push_back(ob);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// XXX: if there're multiple instances, only one is stored
|
||||
|
||||
if (!ob) {
|
||||
|
@ -705,7 +705,7 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
// this method called on post process after writeGeometry, writeMaterial, etc.
|
||||
|
||||
// for each <node> in <visual_scene>:
|
||||
|
@ -717,18 +717,18 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
|
|||
// we link Objects with Meshes here
|
||||
|
||||
vscenes.push_back(visualScene);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** When this method is called, the writer must handle all nodes contained in the
|
||||
/** When this method is called, the writer must handle all nodes contained in the
|
||||
* library nodes.
|
||||
* \return The writer should return true, if writing succeeded, false otherwise.*/
|
||||
bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryNodes)
|
||||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
Scene *sce = CTX_data_scene(mContext);
|
||||
|
||||
const COLLADAFW::NodePointerArray& nodes = libraryNodes->getNodes();
|
||||
|
@ -748,7 +748,7 @@ bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom)
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
return mesh_importer.write_geometry(geom);
|
||||
}
|
||||
|
||||
|
@ -758,13 +758,13 @@ bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat)
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId();
|
||||
Material *ma = BKE_material_add(G.main, (char *)str_mat_id.c_str());
|
||||
|
||||
|
||||
this->uid_effect_map[cmat->getInstantiatedEffect()] = ma;
|
||||
this->uid_material_map[cmat->getUniqueId()] = ma;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -774,29 +774,29 @@ MTex *DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::T
|
|||
{
|
||||
COLLADAFW::SamplerPointerArray& samp_array = ef->getSamplerPointerArray();
|
||||
COLLADAFW::Sampler *sampler = samp_array[ctex.getSamplerId()];
|
||||
|
||||
|
||||
const COLLADAFW::UniqueId& ima_uid = sampler->getSourceImage();
|
||||
|
||||
|
||||
if (uid_image_map.find(ima_uid) == uid_image_map.end()) {
|
||||
fprintf(stderr, "Couldn't find an image by UID.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
ma->mtex[i] = BKE_texture_mtex_add();
|
||||
ma->mtex[i]->texco = TEXCO_UV;
|
||||
ma->mtex[i]->tex = BKE_texture_add(G.main, "Texture");
|
||||
ma->mtex[i]->tex->type = TEX_IMAGE;
|
||||
ma->mtex[i]->tex->ima = uid_image_map[ima_uid];
|
||||
|
||||
|
||||
texindex_texarray_map[ctex.getTextureMapId()].push_back(ma->mtex[i]);
|
||||
|
||||
|
||||
return ma->mtex[i];
|
||||
}
|
||||
|
||||
void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Material *ma)
|
||||
{
|
||||
COLLADAFW::EffectCommon::ShaderType shader = ef->getShaderType();
|
||||
|
||||
|
||||
// blinn
|
||||
if (shader == COLLADAFW::EffectCommon::SHADER_BLINN) {
|
||||
ma->spec_shader = MA_SPEC_BLINN;
|
||||
|
@ -820,12 +820,12 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
|
|||
ma->ray_mirror = ef->getReflectivity().getFloatValue();
|
||||
// index of refraction
|
||||
ma->ang = ef->getIndexOfRefraction().getFloatValue();
|
||||
|
||||
|
||||
int i = 0;
|
||||
COLLADAFW::Color col;
|
||||
MTex *mtex = NULL;
|
||||
TexIndexTextureArrayMap texindex_texarray_map;
|
||||
|
||||
|
||||
// DIFFUSE
|
||||
// color
|
||||
if (ef->getDiffuse().isColor()) {
|
||||
|
@ -840,7 +840,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
|
|||
}
|
||||
// texture
|
||||
else if (ef->getDiffuse().isTexture()) {
|
||||
COLLADAFW::Texture ctex = ef->getDiffuse().getTexture();
|
||||
COLLADAFW::Texture ctex = ef->getDiffuse().getTexture();
|
||||
mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
|
||||
if (mtex != NULL) {
|
||||
mtex->mapto = MAP_COL;
|
||||
|
@ -858,10 +858,10 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
|
|||
}
|
||||
// texture
|
||||
else if (ef->getAmbient().isTexture()) {
|
||||
COLLADAFW::Texture ctex = ef->getAmbient().getTexture();
|
||||
COLLADAFW::Texture ctex = ef->getAmbient().getTexture();
|
||||
mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
|
||||
if (mtex != NULL) {
|
||||
mtex->mapto = MAP_AMB;
|
||||
mtex->mapto = MAP_AMB;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -875,10 +875,10 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
|
|||
}
|
||||
// texture
|
||||
else if (ef->getSpecular().isTexture()) {
|
||||
COLLADAFW::Texture ctex = ef->getSpecular().getTexture();
|
||||
COLLADAFW::Texture ctex = ef->getSpecular().getTexture();
|
||||
mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
|
||||
if (mtex != NULL) {
|
||||
mtex->mapto = MAP_SPEC;
|
||||
mtex->mapto = MAP_SPEC;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -892,10 +892,10 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
|
|||
}
|
||||
// texture
|
||||
else if (ef->getReflective().isTexture()) {
|
||||
COLLADAFW::Texture ctex = ef->getReflective().getTexture();
|
||||
COLLADAFW::Texture ctex = ef->getReflective().getTexture();
|
||||
mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
|
||||
if (mtex != NULL) {
|
||||
mtex->mapto = MAP_REF;
|
||||
mtex->mapto = MAP_REF;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -908,10 +908,10 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
|
|||
}
|
||||
// texture
|
||||
else if (ef->getEmission().isTexture()) {
|
||||
COLLADAFW::Texture ctex = ef->getEmission().getTexture();
|
||||
COLLADAFW::Texture ctex = ef->getEmission().getTexture();
|
||||
mtex = create_texture(ef, ctex, ma, i, texindex_texarray_map);
|
||||
if (mtex != NULL) {
|
||||
mtex->mapto = MAP_EMIT;
|
||||
mtex->mapto = MAP_EMIT;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -951,14 +951,14 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
const COLLADAFW::UniqueId& uid = effect->getUniqueId();
|
||||
|
||||
|
||||
if (uid_effect_map.find(uid) == uid_effect_map.end()) {
|
||||
fprintf(stderr, "Couldn't find a material by UID.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Material *ma = uid_effect_map[uid];
|
||||
std::map<COLLADAFW::UniqueId, Material *>::iterator iter;
|
||||
for (iter = uid_material_map.begin(); iter != uid_material_map.end(); iter++) {
|
||||
|
@ -977,7 +977,7 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
|
|||
COLLADAFW::EffectCommon *ef = common_efs[0];
|
||||
write_profile_COMMON(ef, ma);
|
||||
this->FW_object_map[effect->getUniqueId()] = effect;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -988,16 +988,16 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
Camera *cam = NULL;
|
||||
std::string cam_id, cam_name;
|
||||
|
||||
|
||||
ExtraTags *et=getExtraTags(camera->getUniqueId());
|
||||
cam_id = camera->getOriginalId();
|
||||
cam_name = camera->getName();
|
||||
if (cam_name.size()) cam = (Camera *)BKE_camera_add(G.main, (char *)cam_name.c_str());
|
||||
else cam = (Camera *)BKE_camera_add(G.main, (char *)cam_id.c_str());
|
||||
|
||||
|
||||
if (!cam) {
|
||||
fprintf(stderr, "Cannot create camera.\n");
|
||||
return true;
|
||||
|
@ -1010,7 +1010,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
|
|||
}
|
||||
cam->clipsta = camera->getNearClippingPlane().getValue();
|
||||
cam->clipend = camera->getFarClippingPlane().getValue();
|
||||
|
||||
|
||||
COLLADAFW::Camera::CameraType type = camera->getCameraType();
|
||||
switch (type) {
|
||||
case COLLADAFW::Camera::ORTHOGRAPHIC:
|
||||
|
@ -1030,7 +1030,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch (camera->getDescriptionType()) {
|
||||
case COLLADAFW::Camera::ASPECTRATIO_AND_Y:
|
||||
{
|
||||
|
@ -1100,7 +1100,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
|
|||
// read nothing, use blender defaults.
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
this->uid_camera_map[camera->getUniqueId()] = cam;
|
||||
this->FW_object_map[camera->getUniqueId()] = camera;
|
||||
// XXX import camera options
|
||||
|
@ -1113,7 +1113,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
const std::string& imagepath = image->getImageURI().toNativePath();
|
||||
|
||||
char dir[FILE_MAX];
|
||||
|
@ -1124,7 +1124,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
|
|||
BLI_join_dirfile(absolute_path, sizeof(absolute_path), dir, imagepath.c_str());
|
||||
if (BLI_exists(absolute_path)) {
|
||||
workpath = absolute_path;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Maybe imagepath was already absolute ?
|
||||
if (!BLI_exists(imagepath.c_str())) {
|
||||
|
@ -1140,7 +1140,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
|
|||
return true;
|
||||
}
|
||||
this->uid_image_map[image->getUniqueId()] = ima;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1261,7 +1261,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
|||
// assuming point light (const att = 1.0);
|
||||
att1 = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
d *= (1.0f / unit_converter.getLinearMeter());
|
||||
|
||||
lamp->energy = e;
|
||||
|
@ -1324,7 +1324,7 @@ bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
// return true;
|
||||
return anim_importer.write_animation(anim);
|
||||
}
|
||||
|
@ -1334,7 +1334,7 @@ bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animat
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
// return true;
|
||||
return anim_importer.write_animation_list(animationList);
|
||||
}
|
||||
|
@ -1351,7 +1351,7 @@ bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
|
|||
{
|
||||
if (mImportStage != General)
|
||||
return true;
|
||||
|
||||
|
||||
return armature_importer.write_controller(controller);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
std::vector<Object *> *write_node(COLLADAFW::Node*, COLLADAFW::Node*, Scene*, Object*, bool);
|
||||
MTex* create_texture(COLLADAFW::EffectCommon*, COLLADAFW::Texture&, Material*, int, TexIndexTextureArrayMap&);
|
||||
void write_profile_COMMON(COLLADAFW::EffectCommon*, Material*);
|
||||
|
||||
|
||||
void translate_anim_recursive(COLLADAFW::Node*, COLLADAFW::Node*, Object*);
|
||||
|
||||
/**
|
||||
|
@ -149,7 +149,7 @@ private:
|
|||
ArmatureImporter armature_importer;
|
||||
MeshImporter mesh_importer;
|
||||
AnimationImporter anim_importer;
|
||||
|
||||
|
||||
/** TagsMap typedef for uid_tags_map. */
|
||||
typedef std::map<std::string, ExtraTags*> TagsMap;
|
||||
/** Tags map of unique id as a string and ExtraTags instance. */
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> node_map;
|
||||
std::vector<const COLLADAFW::VisualScene*> vscenes;
|
||||
std::vector<Object*> libnode_ob;
|
||||
|
||||
|
||||
std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root joint by child joint uid, for bone tree evaluation during resampling
|
||||
std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map;
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ EffectsExporter::EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettin
|
|||
bool EffectsExporter::hasEffects(Scene *sce)
|
||||
{
|
||||
Base *base = (Base *)sce->base.first;
|
||||
|
||||
|
||||
while (base) {
|
||||
Object *ob = base->object;
|
||||
int a;
|
||||
|
@ -75,7 +75,7 @@ bool EffectsExporter::hasEffects(Scene *sce)
|
|||
void EffectsExporter::exportEffects(Scene *sce)
|
||||
{
|
||||
this->scene = sce;
|
||||
|
||||
|
||||
if (this->export_settings->export_texture_type == BC_TEXTURE_TYPE_MAT) {
|
||||
if (hasEffects(sce)) {
|
||||
MaterialFunctor mf;
|
||||
|
@ -152,7 +152,7 @@ void EffectsExporter::writePhong(COLLADASW::EffectProfile &ep, Material *ma)
|
|||
void EffectsExporter::writeTextures(
|
||||
COLLADASW::EffectProfile &ep,
|
||||
std::string &key,
|
||||
COLLADASW::Sampler *sampler,
|
||||
COLLADASW::Sampler *sampler,
|
||||
MTex *t, Image *ima,
|
||||
std::string &uvname )
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ void EffectsExporter::writeTextures(
|
|||
ep.setTransparent(createTexture(ima, uvname, sampler));
|
||||
}
|
||||
// extension:
|
||||
// Normal map --> Must be stored with <extra> tag as different technique,
|
||||
// Normal map --> Must be stored with <extra> tag as different technique,
|
||||
// since COLLADA doesn't support normal maps, even in current COLLADA 1.5.
|
||||
if (t->mapto & MAP_NORM) {
|
||||
COLLADASW::Texture texture(key);
|
||||
|
@ -205,7 +205,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
|
|||
createTextureIndices(ma, tex_indices);
|
||||
|
||||
openEffect(translate_id(id_name(ma)) + "-effect");
|
||||
|
||||
|
||||
COLLADASW::EffectProfile ep(mSW);
|
||||
ep.setProfileType(COLLADASW::EffectProfile::COMMON);
|
||||
ep.openProfile();
|
||||
|
@ -229,7 +229,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
|
|||
writePhong(ep, ma);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// index of refraction
|
||||
if (ma->mode & MA_RAYTRANSP) {
|
||||
ep.setIndexOfRefraction(ma->ang, false, "index_of_refraction");
|
||||
|
@ -290,7 +290,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
|
|||
//COLLADASW::Surface surfaces[MAX_MTEX];
|
||||
//void *samp_surf[MAX_MTEX][2];
|
||||
void *samp_surf[MAX_MTEX];
|
||||
|
||||
|
||||
// image to index to samp_surf map
|
||||
// samp_surf[index] stores 2 pointers, sampler and surface
|
||||
std::map<std::string, int> im_samp_map;
|
||||
|
@ -299,10 +299,10 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
|
|||
for (a = 0, b = 0; a < tex_indices.size(); a++) {
|
||||
MTex *t = ma->mtex[tex_indices[a]];
|
||||
Image *ima = t->tex->ima;
|
||||
|
||||
|
||||
// Image not set for texture
|
||||
if (!ima) continue;
|
||||
|
||||
|
||||
std::string key(id_name(ima));
|
||||
key = translate_id(key);
|
||||
|
||||
|
@ -317,7 +317,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
|
|||
|
||||
// COLLADASW::NewParamSurface surface(mSW);
|
||||
// surface->setParamType(COLLADASW::CSW_SURFACE_TYPE_2D);
|
||||
|
||||
|
||||
//<newparam> <sampler> <source>
|
||||
COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D,
|
||||
key + COLLADASW::Sampler::SAMPLER_SID_SUFFIX,
|
||||
|
@ -326,11 +326,11 @@ void EffectsExporter::operator()(Material *ma, Object *ob)
|
|||
// copy values to arrays since they will live longer
|
||||
samplers[a] = sampler;
|
||||
//surfaces[a] = surface;
|
||||
|
||||
|
||||
// store pointers so they can be used later when we create <texture>s
|
||||
samp_surf[b] = &samplers[a];
|
||||
//samp_surf[b][1] = &surfaces[a];
|
||||
|
||||
|
||||
im_samp_map[key] = b;
|
||||
b++;
|
||||
}
|
||||
|
@ -381,12 +381,12 @@ COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima,
|
|||
COLLADASW::Sampler *sampler
|
||||
/*COLLADASW::Surface *surface*/)
|
||||
{
|
||||
|
||||
|
||||
COLLADASW::Texture texture(translate_id(id_name(ima)));
|
||||
texture.setTexcoord(uv_layer_name);
|
||||
//texture.setSurface(*surface);
|
||||
texture.setSampler(*sampler);
|
||||
|
||||
|
||||
COLLADASW::ColorOrTexture cot(texture);
|
||||
return cot;
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ COLLADASW::ColorOrTexture EffectsExporter::getcol(float r, float g, float b, flo
|
|||
return cot;
|
||||
}
|
||||
|
||||
//returns the array of mtex indices which have image
|
||||
//returns the array of mtex indices which have image
|
||||
//need this for exporting textures
|
||||
void EffectsExporter::createTextureIndices(Material *ma, std::vector<int> &indices)
|
||||
{
|
||||
|
|
|
@ -49,30 +49,30 @@ public:
|
|||
EffectsExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||
void exportEffects(Scene *sce);
|
||||
void operator()(Material *ma, Object *ob);
|
||||
|
||||
|
||||
COLLADASW::ColorOrTexture createTexture(Image *ima,
|
||||
std::string& uv_layer_name,
|
||||
COLLADASW::Sampler *sampler
|
||||
/*COLLADASW::Surface *surface*/);
|
||||
|
||||
|
||||
COLLADASW::ColorOrTexture getcol(float r, float g, float b, float a);
|
||||
private:
|
||||
/** Fills the array of mtex indices which have image. Used for exporting images. */
|
||||
void createTextureIndices(Material *ma, std::vector<int> &indices);
|
||||
|
||||
|
||||
void writeBlinn(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
void writeLambert(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
void writePhong(COLLADASW::EffectProfile &ep, Material *ma);
|
||||
void writeTextures(COLLADASW::EffectProfile &ep,
|
||||
std::string &key,
|
||||
COLLADASW::Sampler *sampler,
|
||||
COLLADASW::Sampler *sampler,
|
||||
MTex *t, Image *ima,
|
||||
std::string &uvname );
|
||||
|
||||
bool hasEffects(Scene *sce);
|
||||
|
||||
|
||||
const ExportSettings *export_settings;
|
||||
|
||||
|
||||
Scene *scene;
|
||||
};
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error)
|
|||
See https://github.com/KhronosGroup/OpenCOLLADA/issues/442
|
||||
*/
|
||||
bool isWarning = false;
|
||||
|
||||
|
||||
if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER) {
|
||||
COLLADASaxFWL::SaxParserError *saxParserError = (COLLADASaxFWL::SaxParserError *) error;
|
||||
const GeneratedSaxParser::ParserError& parserError = saxParserError->getError();
|
||||
|
|
|
@ -54,9 +54,9 @@ bool ExtraHandler::elementEnd(const char *elementName)
|
|||
bool ExtraHandler::textData(const char *text, size_t textLength)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
|
||||
if (currentElement.length() == 0 || currentExtraTags == 0) return false;
|
||||
|
||||
|
||||
BLI_strncpy(buf, text, textLength + 1);
|
||||
currentExtraTags->addTag(currentElement, std::string(buf));
|
||||
return true;
|
||||
|
|
|
@ -50,31 +50,31 @@ public:
|
|||
|
||||
/** Handle the beginning of an element. */
|
||||
bool elementBegin( const char* elementName, const char** attributes);
|
||||
|
||||
|
||||
/** Handle the end of an element. */
|
||||
bool elementEnd(const char* elementName );
|
||||
|
||||
|
||||
/** Receive the data in text format. */
|
||||
bool textData(const char* text, size_t textLength);
|
||||
|
||||
/** Method to ask, if the current callback handler want to read the data of the given extra element. */
|
||||
bool parseElement (
|
||||
const char* profileName,
|
||||
const unsigned long& elementHash,
|
||||
bool parseElement (
|
||||
const char* profileName,
|
||||
const unsigned long& elementHash,
|
||||
const COLLADAFW::UniqueId& uniqueId,
|
||||
COLLADAFW::Object* object);
|
||||
|
||||
/** For backwards compatibility with older OpenCollada, new version added object parameter */
|
||||
bool parseElement (
|
||||
const char* profileName,
|
||||
const unsigned long& elementHash,
|
||||
bool parseElement (
|
||||
const char* profileName,
|
||||
const unsigned long& elementHash,
|
||||
const COLLADAFW::UniqueId& uniqueId);
|
||||
private:
|
||||
/** Disable default copy constructor. */
|
||||
ExtraHandler(const ExtraHandler& pre);
|
||||
/** Disable default assignment operator. */
|
||||
const ExtraHandler& operator= ( const ExtraHandler& pre );
|
||||
|
||||
|
||||
/** Handle to DocumentImporter for interface to extra element data saving. */
|
||||
DocumentImporter* dimp;
|
||||
AnimationImporter* aimp;
|
||||
|
|
|
@ -50,7 +50,7 @@ bool ExtraTags::isProfile(std::string profile)
|
|||
bool ExtraTags::addTag(std::string tag, std::string data)
|
||||
{
|
||||
tags[tag] = data;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,35 +41,35 @@ public:
|
|||
|
||||
/** Handle the beginning of an element. */
|
||||
bool addTag(std::string tag, std::string data);
|
||||
|
||||
|
||||
/** Set given short pointer to value of tag, if it exists. */
|
||||
bool setData(std::string tag, short *data);
|
||||
|
||||
|
||||
/** Set given int pointer to value of tag, if it exists. */
|
||||
bool setData(std::string tag, int *data);
|
||||
|
||||
|
||||
/** Set given float pointer to value of tag, if it exists. */
|
||||
bool setData(std::string tag, float *data);
|
||||
|
||||
|
||||
/** Set given char pointer to value of tag, if it exists. */
|
||||
bool setData(std::string tag, char *data);
|
||||
std::string setData(std::string tag, std::string &data);
|
||||
|
||||
/** Return true if the extra tags is for specified profile. */
|
||||
bool isProfile(std::string profile);
|
||||
|
||||
|
||||
private:
|
||||
/** Disable default copy constructor. */
|
||||
ExtraTags(const ExtraTags& pre);
|
||||
/** Disable default assignment operator. */
|
||||
const ExtraTags& operator= ( const ExtraTags& pre );
|
||||
|
||||
|
||||
/** The profile for which the tags are. */
|
||||
std::string profile;
|
||||
|
||||
|
||||
/** Map of tag and text pairs. */
|
||||
std::map<std::string, std::string> tags;
|
||||
|
||||
|
||||
/** Get text data for tag as an int. */
|
||||
int asInt(std::string tag, bool *ok);
|
||||
/** Get text data for tag as a float. */
|
||||
|
|
|
@ -70,14 +70,14 @@ void GeometryExporter::exportGeom(Scene *sce)
|
|||
}
|
||||
|
||||
void GeometryExporter::operator()(Object *ob)
|
||||
{
|
||||
{
|
||||
// XXX don't use DerivedMesh, Mesh instead?
|
||||
#if 0
|
||||
#if 0
|
||||
DerivedMesh *dm = mesh_get_derived_final(mScene, ob, CD_MASK_BAREMESH);
|
||||
#endif
|
||||
|
||||
bool use_instantiation = this->export_settings->use_object_instantiation;
|
||||
Mesh *me = bc_get_mesh_copy( mScene,
|
||||
Mesh *me = bc_get_mesh_copy( mScene,
|
||||
ob,
|
||||
this->export_settings->export_mesh_type,
|
||||
this->export_settings->apply_modifiers,
|
||||
|
@ -88,7 +88,7 @@ void GeometryExporter::operator()(Object *ob)
|
|||
std::vector<BCPolygonNormalsIndices> norind;
|
||||
|
||||
// Skip if linked geometry was already exported from another reference
|
||||
if (use_instantiation &&
|
||||
if (use_instantiation &&
|
||||
exportedGeometry.find(geom_id) != exportedGeometry.end())
|
||||
{
|
||||
return;
|
||||
|
@ -104,15 +104,15 @@ void GeometryExporter::operator()(Object *ob)
|
|||
|
||||
// openMesh(geoId, geoName, meshId)
|
||||
openMesh(geom_id, geom_name);
|
||||
|
||||
|
||||
// writes <source> for vertex coords
|
||||
createVertsSource(geom_id, me);
|
||||
|
||||
|
||||
// writes <source> for normal coords
|
||||
createNormalsSource(geom_id, me, nor);
|
||||
|
||||
bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE);
|
||||
|
||||
|
||||
// writes <source> for uv coords if mesh has uv coords
|
||||
if (has_uvs) {
|
||||
createTexcoordsSource(geom_id, me);
|
||||
|
@ -153,9 +153,9 @@ void GeometryExporter::operator()(Object *ob)
|
|||
createPolylists(uv_image_set, has_uvs, has_color, ob, me, geom_id, norind);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
closeMesh();
|
||||
|
||||
|
||||
if (me->flag & ME_TWOSIDED) {
|
||||
mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>");
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
|
|||
std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name);
|
||||
std::vector<Normal> nor;
|
||||
std::vector<BCPolygonNormalsIndices> norind;
|
||||
|
||||
|
||||
if (exportedGeometry.find(geom_id) != exportedGeometry.end())
|
||||
{
|
||||
return;
|
||||
|
@ -200,15 +200,15 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
|
|||
|
||||
// openMesh(geoId, geoName, meshId)
|
||||
openMesh(geom_id, geom_name);
|
||||
|
||||
|
||||
// writes <source> for vertex coords
|
||||
createVertsSource(geom_id, me);
|
||||
|
||||
|
||||
// writes <source> for normal coords
|
||||
createNormalsSource(geom_id, me, nor);
|
||||
|
||||
bool has_uvs = (bool)CustomData_has_layer(&me->fdata, CD_MTFACE);
|
||||
|
||||
|
||||
// writes <source> for uv coords if mesh has uv coords
|
||||
if (has_uvs) {
|
||||
createTexcoordsSource(geom_id, me);
|
||||
|
@ -229,7 +229,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
|
|||
|
||||
//createLooseEdgeList(ob, me, geom_id, norind);
|
||||
|
||||
// XXX slow
|
||||
// XXX slow
|
||||
if (ob->totcol && this->export_settings->export_texture_type == BC_TEXTURE_TYPE_MAT) {
|
||||
for (int a = 0; a < ob->totcol; a++) {
|
||||
createPolylist(a, has_uvs, has_color, ob, me, geom_id, norind);
|
||||
|
@ -240,9 +240,9 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb)
|
|||
std::set<Image *> uv_images = bc_getUVImages(ob, all_uv_layers);
|
||||
createPolylists(uv_images, has_uvs, has_color, ob, me, geom_id, norind);
|
||||
}
|
||||
|
||||
|
||||
closeMesh();
|
||||
|
||||
|
||||
if (me->flag & ME_TWOSIDED) {
|
||||
mSW->appendTextBlock("<extra><technique profile=\"MAYA\"><double_sided>1</double_sided></technique></extra>");
|
||||
}
|
||||
|
@ -261,9 +261,9 @@ void GeometryExporter::createLooseEdgeList(Object *ob,
|
|||
std::vector<unsigned int> edge_list;
|
||||
int index;
|
||||
|
||||
// Find all loose edges in Mesh
|
||||
// Find all loose edges in Mesh
|
||||
// and save vertex indices in edge_list
|
||||
for (index = 0; index < totedges; index++)
|
||||
for (index = 0; index < totedges; index++)
|
||||
{
|
||||
MEdge *edge = &medges[index];
|
||||
|
||||
|
@ -284,14 +284,14 @@ void GeometryExporter::createLooseEdgeList(Object *ob,
|
|||
|
||||
|
||||
COLLADASW::InputList &til = lines.getInputList();
|
||||
|
||||
// creates <input> in <lines> for vertices
|
||||
|
||||
// creates <input> in <lines> for vertices
|
||||
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
|
||||
til.push_back(input1);
|
||||
|
||||
lines.prepareToAppendValues();
|
||||
|
||||
for (index = 0; index < edges_in_linelist; index++)
|
||||
for (index = 0; index < edges_in_linelist; index++)
|
||||
{
|
||||
lines.appendValues(edge_list[2 * index + 1]);
|
||||
lines.appendValues(edge_list[2 * index]);
|
||||
|
@ -366,7 +366,7 @@ void GeometryExporter::createPolylist(short material_index,
|
|||
// count faces with this material
|
||||
for (i = 0; i < totpolys; i++) {
|
||||
MPoly *p = &mpolys[i];
|
||||
|
||||
|
||||
if (p->mat_nr == material_index) {
|
||||
faces_in_polylist++;
|
||||
vcount_list.push_back(p->totloop);
|
||||
|
@ -381,14 +381,14 @@ void GeometryExporter::createPolylist(short material_index,
|
|||
fprintf(stderr, "%s: material with index %d is not used.\n", id_name(ob).c_str(), material_index);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Material *ma = ob->totcol ? give_current_material(ob, material_index + 1) : NULL;
|
||||
COLLADASW::PrimitivesBase *facelist = getFacelist(is_triangulated, mSW);
|
||||
|
||||
|
||||
|
||||
// sets count attribute in <polylist>
|
||||
facelist->setCount(faces_in_polylist);
|
||||
|
||||
|
||||
// sets material name
|
||||
if (ma) {
|
||||
std::string material_id = get_material_id(ma);
|
||||
|
@ -398,22 +398,22 @@ void GeometryExporter::createPolylist(short material_index,
|
|||
}
|
||||
|
||||
COLLADASW::InputList &til = facelist->getInputList();
|
||||
|
||||
// creates <input> in <polylist> for vertices
|
||||
|
||||
// creates <input> in <polylist> for vertices
|
||||
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
|
||||
|
||||
|
||||
// creates <input> in <polylist> for normals
|
||||
COLLADASW::Input input2(COLLADASW::InputSemantic::NORMAL, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::NORMAL), 1);
|
||||
|
||||
|
||||
til.push_back(input1);
|
||||
til.push_back(input2);
|
||||
|
||||
|
||||
// if mesh has uv coords writes <input> for TEXCOORD
|
||||
int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
|
||||
int active_uv_index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE)-1;
|
||||
for (i = 0; i < num_layers; i++) {
|
||||
if (!this->export_settings->active_uv_only || i == active_uv_index) {
|
||||
|
||||
|
||||
std::string uv_name(bc_get_uvlayer_name(me, i));
|
||||
std::string effective_id = geom_id; // (uv_name == "") ? geom_id : uv_name;
|
||||
std::string layer_id = makeTexcoordSourceId(
|
||||
|
@ -421,7 +421,7 @@ void GeometryExporter::createPolylist(short material_index,
|
|||
i, this->export_settings->active_uv_only);
|
||||
|
||||
/* Note: the third parameter denotes the offset of TEXCOORD in polylist elements
|
||||
For now this is always 2 (This may change sometime/maybe)
|
||||
For now this is always 2 (This may change sometime/maybe)
|
||||
*/
|
||||
COLLADASW::Input input3(COLLADASW::InputSemantic::TEXCOORD,
|
||||
makeUrl(layer_id),
|
||||
|
@ -447,8 +447,8 @@ void GeometryExporter::createPolylist(short material_index,
|
|||
map_index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// performs the actual writing
|
||||
prepareToAppendValues(is_triangulated, facelist, vcount_list);
|
||||
|
||||
|
@ -504,7 +504,7 @@ void GeometryExporter::createPolylists(std::set<Image *> uv_images,
|
|||
norind);
|
||||
}
|
||||
|
||||
/* We msut add an additional collector for the case when
|
||||
/* We msut add an additional collector for the case when
|
||||
* some parts of the object are not textured at all.
|
||||
* The next call creates a polylist for all untextured polygons
|
||||
*/
|
||||
|
@ -580,7 +580,7 @@ void GeometryExporter::createPolylist(std::string imageid,
|
|||
}
|
||||
COLLADASW::InputList &til = facelist->getInputList();
|
||||
|
||||
// creates <input> in <polylist> for vertices
|
||||
// creates <input> in <polylist> for vertices
|
||||
COLLADASW::Input input1(COLLADASW::InputSemantic::VERTEX, getUrlBySemantics(geom_id, COLLADASW::InputSemantic::VERTEX), 0);
|
||||
|
||||
// creates <input> in <polylist> for normals
|
||||
|
@ -670,7 +670,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
|
|||
#endif
|
||||
int totverts = me->totvert;
|
||||
MVert *verts = me->mvert;
|
||||
|
||||
|
||||
COLLADASW::FloatSourceF source(mSW);
|
||||
source.setId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION));
|
||||
source.setArrayId(getIdBySemantics(geom_id, COLLADASW::InputSemantic::POSITION) +
|
||||
|
@ -690,7 +690,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me)
|
|||
for (i = 0; i < totverts; i++) {
|
||||
source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]);
|
||||
}
|
||||
|
||||
|
||||
source.finish();
|
||||
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
source.finish();
|
||||
}
|
||||
}
|
||||
|
@ -777,26 +777,26 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
|
|||
int layer_index = CustomData_get_layer_index_n(&me->ldata, CD_MLOOPUV, a);
|
||||
if (!this->export_settings->active_uv_only || layer_index == active_uv_index) {
|
||||
MLoopUV *mloops = (MLoopUV *)CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, a);
|
||||
|
||||
|
||||
COLLADASW::FloatSourceF source(mSW);
|
||||
std::string active_uv_name(bc_get_active_uvlayer_name(me));
|
||||
std::string effective_id = geom_id; // (active_uv_name == "") ? geom_id : active_uv_name;
|
||||
std::string layer_id = makeTexcoordSourceId(
|
||||
effective_id,
|
||||
a,
|
||||
effective_id,
|
||||
a,
|
||||
this->export_settings->active_uv_only );
|
||||
|
||||
source.setId(layer_id);
|
||||
source.setArrayId(layer_id + ARRAY_ID_SUFFIX);
|
||||
|
||||
|
||||
source.setAccessorCount(totuv);
|
||||
source.setAccessorStride(2);
|
||||
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
||||
param.push_back("S");
|
||||
param.push_back("T");
|
||||
|
||||
|
||||
source.prepareToAppendValues();
|
||||
|
||||
|
||||
for (int index = 0; index < totpoly; index++) {
|
||||
MPoly *mpoly = mpolys+index;
|
||||
MLoopUV *mloop = mloops+mpoly->loopstart;
|
||||
|
@ -805,7 +805,7 @@ void GeometryExporter::createTexcoordsSource(std::string geom_id, Mesh *me)
|
|||
mloop[j].uv[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
source.finish();
|
||||
}
|
||||
}
|
||||
|
@ -835,7 +835,7 @@ void GeometryExporter::createNormalsSource(std::string geom_id, Mesh *me, std::v
|
|||
param.push_back("X");
|
||||
param.push_back("Y");
|
||||
param.push_back("Z");
|
||||
|
||||
|
||||
source.prepareToAppendValues();
|
||||
|
||||
std::vector<Normal>::iterator it;
|
||||
|
@ -920,10 +920,10 @@ std::string GeometryExporter::getIdBySemantics(std::string geom_id, COLLADASW::I
|
|||
|
||||
COLLADASW::URI GeometryExporter::getUrlBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix)
|
||||
{
|
||||
|
||||
|
||||
std::string id(getIdBySemantics(geom_id, type, other_suffix));
|
||||
return COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
COLLADASW::URI GeometryExporter::makeUrl(std::string id)
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
void createNormalsSource(std::string geom_id, Mesh *me, std::vector<Normal>& nor);
|
||||
|
||||
void create_normals(std::vector<Normal> &nor, std::vector<BCPolygonNormalsIndices> &ind, Mesh *me);
|
||||
|
||||
|
||||
std::string getIdBySemantics(std::string geom_id, COLLADASW::InputSemantic::Semantics type, std::string other_suffix = "");
|
||||
std::string makeVertexColorSourceId(std::string& geom_id, char *layer_name);
|
||||
|
||||
|
@ -136,10 +136,10 @@ public:
|
|||
COLLADASW::URI makeUrl(std::string id);
|
||||
|
||||
void export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb);
|
||||
|
||||
|
||||
private:
|
||||
std::set<std::string> exportedGeometry;
|
||||
|
||||
|
||||
const ExportSettings *export_settings;
|
||||
|
||||
Mesh * get_mesh(Scene *sce, Object *ob, int apply_modifiers);
|
||||
|
|
|
@ -34,7 +34,7 @@ extern "C" {
|
|||
#include "DNA_image_types.h"
|
||||
#include "DNA_meshdata_types.h"
|
||||
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_customdata.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_main.h"
|
||||
|
@ -53,7 +53,7 @@ ImagesExporter::ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings
|
|||
{
|
||||
}
|
||||
|
||||
void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
|
||||
void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
|
||||
{
|
||||
std::string id(id_name(image));
|
||||
std::string translated_id(translate_id(id));
|
||||
|
@ -117,7 +117,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
|
|||
BLI_cleanup_path(NULL, source_path);
|
||||
|
||||
if (use_copies) {
|
||||
|
||||
|
||||
// This image is already located on the file system.
|
||||
// But we want to create copies here.
|
||||
// To move images into the same export directory.
|
||||
|
@ -144,7 +144,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies)
|
|||
}
|
||||
|
||||
/* set name also to mNameNC. This helps other viewers import files exported from Blender better */
|
||||
COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)), translated_id, translated_id);
|
||||
COLLADASW::Image img(COLLADABU::URI(COLLADABU::URI::nativePathToUri(export_path)), translated_id, translated_id);
|
||||
img.add(mSW);
|
||||
fprintf(stdout, "Collada export: Added image: %s\n", export_file);
|
||||
mImages.push_back(translated_id);
|
||||
|
@ -200,7 +200,7 @@ void ImagesExporter::export_UV_Images()
|
|||
bool ImagesExporter::hasImages(Scene *sce)
|
||||
{
|
||||
LinkNode *node;
|
||||
|
||||
|
||||
for (node = this->export_settings->export_set; node; node = node->next) {
|
||||
Object *ob = (Object *)node->link;
|
||||
|
||||
|
|
|
@ -45,13 +45,13 @@ class ImagesExporter: COLLADASW::LibraryImages
|
|||
{
|
||||
public:
|
||||
ImagesExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings);
|
||||
|
||||
|
||||
void exportImages(Scene *sce);
|
||||
void operator()(Material *ma, Object *ob);
|
||||
private:
|
||||
std::vector<std::string> mImages; // contains list of written images, to avoid duplicates
|
||||
|
||||
void export_UV_Images();
|
||||
void export_UV_Images();
|
||||
void export_UV_Image(Image *image, bool use_texture_copies);
|
||||
bool hasImages(Scene *sce);
|
||||
const ExportSettings *export_settings;
|
||||
|
|
|
@ -54,9 +54,9 @@ LightsExporter::LightsExporter(COLLADASW::StreamWriter *sw, const ExportSettings
|
|||
void LightsExporter::exportLights(Scene *sce)
|
||||
{
|
||||
openLibrary();
|
||||
|
||||
|
||||
forEachLampObjectInExportSet(sce, *this, this->export_settings->export_set);
|
||||
|
||||
|
||||
closeLibrary();
|
||||
}
|
||||
|
||||
|
@ -67,11 +67,11 @@ void LightsExporter::operator()(Object *ob)
|
|||
std::string la_name(id_name(la));
|
||||
COLLADASW::Color col(la->r * la->energy, la->g * la->energy, la->b * la->energy);
|
||||
float d, constatt, linatt, quadatt;
|
||||
|
||||
|
||||
d = la->dist;
|
||||
|
||||
|
||||
constatt = 1.0f;
|
||||
|
||||
|
||||
if (la->falloff_type == LA_FALLOFF_INVLINEAR) {
|
||||
linatt = 1.0f / d;
|
||||
quadatt = 0.0f;
|
||||
|
@ -80,7 +80,7 @@ void LightsExporter::operator()(Object *ob)
|
|||
linatt = 0.0f;
|
||||
quadatt = 1.0f / (d * d);
|
||||
}
|
||||
|
||||
|
||||
// sun
|
||||
if (la->type == LA_SUN) {
|
||||
COLLADASW::DirectionalLight cla(mSW, la_id, la_name);
|
||||
|
@ -130,7 +130,7 @@ void LightsExporter::operator()(Object *ob)
|
|||
exportBlenderProfile(cla, la);
|
||||
addLight(cla);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
|
||||
|
@ -190,6 +190,6 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la)
|
|||
cla.addExtraTechniqueParameter("blender", "skyblendfac", la->skyblendfac);
|
||||
cla.addExtraTechniqueParameter("blender", "sky_exposure", la->sky_exposure);
|
||||
cla.addExtraTechniqueParameter("blender", "sky_colorspace", la->sky_colorspace);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class ForEachMaterialFunctor
|
|||
Functor *f;
|
||||
public:
|
||||
ForEachMaterialFunctor(Functor*f) : f(f) {}
|
||||
|
||||
|
||||
void operator ()(Object *ob)
|
||||
{
|
||||
int a;
|
||||
|
|
|
@ -154,7 +154,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv)
|
|||
if (values->empty()) return;
|
||||
uv[0] = (*values)[uv_index * stride];
|
||||
uv[1] = (*values)[uv_index * stride + 1];
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE:
|
||||
|
@ -163,7 +163,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv)
|
|||
if (values->empty()) return;
|
||||
uv[0] = (float)(*values)[uv_index * stride];
|
||||
uv[1] = (float)(*values)[uv_index * stride + 1];
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_UNKNOWN:
|
||||
|
@ -316,7 +316,7 @@ bool MeshImporter::is_nice_mesh(COLLADAFW::Mesh *mesh) // checks if mesh has su
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ bool MeshImporter::primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp) {
|
|||
int normals_count = mp->getNormalIndices().getCount();
|
||||
if (normals_count > 0) {
|
||||
int index_count = mp->getPositionIndices().getCount();
|
||||
if (index_count == normals_count)
|
||||
if (index_count == normals_count)
|
||||
has_useable_normals = true;
|
||||
else {
|
||||
fprintf(stderr,
|
||||
|
@ -387,7 +387,7 @@ bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp) {
|
|||
break;
|
||||
}
|
||||
default: {
|
||||
has_faces = false;
|
||||
has_faces = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
|||
size_t prim_poly_count = mpvc->getFaceCount();
|
||||
|
||||
size_t prim_loop_count = 0;
|
||||
for (int index=0; index < prim_poly_count; index++)
|
||||
for (int index=0; index < prim_poly_count; index++)
|
||||
{
|
||||
int vcount = get_vertex_count(mpvc, index);
|
||||
if (vcount > 0) {
|
||||
|
@ -545,7 +545,7 @@ unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) {
|
|||
// This functin is copied from source/blender/editors/mesh/mesh_data.c
|
||||
//
|
||||
// TODO: (As discussed with sergey-) :
|
||||
// Maybe move this function to blenderkernel/intern/mesh.c
|
||||
// Maybe move this function to blenderkernel/intern/mesh.c
|
||||
// and add definition to BKE_mesh.c
|
||||
// =================================================================
|
||||
void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
|
||||
|
@ -580,7 +580,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
|
|||
|
||||
// =================================================================
|
||||
// Read all loose edges.
|
||||
// Important: This function assumes that all edges from existing
|
||||
// Important: This function assumes that all edges from existing
|
||||
// faces have allready been generated and added to me->medge
|
||||
// So this function MUST be called after read_faces() (see below)
|
||||
// =================================================================
|
||||
|
@ -591,21 +591,21 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
|
|||
|
||||
unsigned int face_edge_count = me->totedge;
|
||||
/* unsigned int total_edge_count = loose_edge_count + face_edge_count; */ /* UNUSED */
|
||||
|
||||
|
||||
mesh_add_edges(me, loose_edge_count);
|
||||
MEdge *med = me->medge + face_edge_count;
|
||||
|
||||
COLLADAFW::MeshPrimitiveArray& prim_arr = mesh->getMeshPrimitives();
|
||||
|
||||
for (int i = 0; i < prim_arr.getCount(); i++) {
|
||||
|
||||
|
||||
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
|
||||
|
||||
int type = mp->getPrimitiveType();
|
||||
if (type == COLLADAFW::MeshPrimitive::LINES) {
|
||||
unsigned int edge_count = mp->getFaceCount();
|
||||
unsigned int *indices = mp->getPositionIndices().getData();
|
||||
|
||||
|
||||
for (int j = 0; j < edge_count; j++, med++) {
|
||||
med->bweight = 0;
|
||||
med->crease = 0;
|
||||
|
@ -622,7 +622,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
|
|||
|
||||
// =======================================================================
|
||||
// Read all faces from TRIANGLES, TRIANGLE_FANS, POLYLIST, POLYGON
|
||||
// Important: This function MUST be called before read_lines()
|
||||
// Important: This function MUST be called before read_lines()
|
||||
// Otherwise we will loose all edges from faces (see read_lines() above)
|
||||
//
|
||||
// TODO: import uv set names
|
||||
|
@ -630,7 +630,7 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me)
|
|||
void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
|
||||
allocate_poly_data(collada_mesh, me);
|
||||
|
||||
UVDataWrapper uvs(collada_mesh->getUVCoords());
|
||||
|
@ -646,7 +646,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
|||
COLLADAFW::MeshVertexData& nor = collada_mesh->getNormals();
|
||||
|
||||
for (i = 0; i < prim_arr.getCount(); i++) {
|
||||
|
||||
|
||||
COLLADAFW::MeshPrimitive *mp = prim_arr[i];
|
||||
|
||||
// faces
|
||||
|
@ -659,7 +659,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
|||
bool mp_has_faces = primitive_has_faces(mp);
|
||||
|
||||
int collada_meshtype = mp->getPrimitiveType();
|
||||
|
||||
|
||||
// since we cannot set mpoly->mat_nr here, we store a portion of me->mpoly in Primitive
|
||||
Primitive prim = {mpoly, 0};
|
||||
|
||||
|
@ -686,7 +686,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
|||
mpoly->flag |= ME_SMOOTH;
|
||||
normal_indices++;
|
||||
}
|
||||
|
||||
|
||||
mpoly++;
|
||||
mloop += 3;
|
||||
loop_index += 3;
|
||||
|
@ -796,7 +796,7 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
|||
void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, int stride)
|
||||
{
|
||||
i *= stride;
|
||||
|
||||
|
||||
switch (arr.getType()) {
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT:
|
||||
{
|
||||
|
@ -884,33 +884,33 @@ MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBindi
|
|||
const COLLADAFW::TextureMapId texture_index = ctexture.getTextureMapId();
|
||||
size_t setindex = ctexture.getSetIndex();
|
||||
std::string uvname = ctexture.getSemantic();
|
||||
|
||||
|
||||
if (setindex == -1) return NULL;
|
||||
|
||||
|
||||
const CustomData *data = &me->fdata;
|
||||
int layer_index = CustomData_get_layer_index(data, CD_MTFACE);
|
||||
|
||||
if (layer_index == -1) return NULL;
|
||||
|
||||
CustomDataLayer *cdl = &data->layers[layer_index + setindex];
|
||||
|
||||
|
||||
/* set uvname to bind_vertex_input semantic */
|
||||
BLI_strncpy(cdl->name, uvname.c_str(), sizeof(cdl->name));
|
||||
|
||||
if (texindex_texarray_map.find(texture_index) == texindex_texarray_map.end()) {
|
||||
|
||||
|
||||
fprintf(stderr, "Cannot find texture array by texture index.\n");
|
||||
return color_texture;
|
||||
}
|
||||
|
||||
|
||||
std::vector<MTex *> textures = texindex_texarray_map[texture_index];
|
||||
|
||||
|
||||
std::vector<MTex *>::iterator it;
|
||||
|
||||
|
||||
for (it = textures.begin(); it != textures.end(); it++) {
|
||||
|
||||
|
||||
MTex *texture = *it;
|
||||
|
||||
|
||||
if (texture) {
|
||||
BLI_strncpy(texture->uvname, uvname.c_str(), sizeof(texture->uvname));
|
||||
if (texture->mapto == MAP_COL) color_texture = texture;
|
||||
|
@ -928,7 +928,7 @@ static bool bc_has_same_material_configuration(Object *ob1, Object *ob2)
|
|||
{
|
||||
if (ob1->totcol != ob2->totcol) return false; // not same number of materials
|
||||
if (ob1->totcol == 0) return false; // no material at all
|
||||
|
||||
|
||||
for (int index=0; index < ob1->totcol; index++) {
|
||||
if (ob1->matbits[index] != ob2->matbits[index]) return false; // shouldn't happen
|
||||
if (ob1->matbits[index] == 0) return false; // shouldn't happen
|
||||
|
@ -1061,35 +1061,35 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
|
|||
MTex *color_texture = NULL;
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
const COLLADAFW::UniqueId& ma_uid = cmaterial.getReferencedMaterial();
|
||||
|
||||
|
||||
// do we know this material?
|
||||
if (uid_material_map.find(ma_uid) == uid_material_map.end()) {
|
||||
|
||||
|
||||
fprintf(stderr, "Cannot find material by UID.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// first time we get geom_uid, ma_uid pair. Save for later check.
|
||||
materials_mapped_to_geom.insert(std::pair<COLLADAFW::UniqueId, COLLADAFW::UniqueId>(*geom_uid, ma_uid));
|
||||
|
||||
|
||||
Material *ma = uid_material_map[ma_uid];
|
||||
|
||||
// Attention! This temporaly assigns material to object on purpose!
|
||||
// See note above.
|
||||
ob->actcol=0;
|
||||
assign_material(G.main, ob, ma, mat_index + 1, BKE_MAT_ASSIGN_OBJECT);
|
||||
|
||||
COLLADAFW::TextureCoordinateBindingArray& tex_array =
|
||||
|
||||
COLLADAFW::TextureCoordinateBindingArray& tex_array =
|
||||
cmaterial.getTextureCoordinateBindingArray();
|
||||
TexIndexTextureArrayMap texindex_texarray_map = material_texture_mapping_map[ma];
|
||||
unsigned int i;
|
||||
// loop through <bind_vertex_inputs>
|
||||
for (i = 0; i < tex_array.getCount(); i++) {
|
||||
|
||||
|
||||
color_texture = assign_textures_to_uvlayer(tex_array[i], me, texindex_texarray_map,
|
||||
color_texture);
|
||||
}
|
||||
|
||||
|
||||
// set texture face
|
||||
if (color_texture &&
|
||||
strlen((color_texture)->uvname) &&
|
||||
|
@ -1099,17 +1099,17 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
|
|||
color_texture->uvname);
|
||||
strcpy(layername, color_texture->uvname);
|
||||
}
|
||||
|
||||
|
||||
MaterialIdPrimitiveArrayMap& mat_prim_map = geom_uid_mat_mapping_map[*geom_uid];
|
||||
COLLADAFW::MaterialId mat_id = cmaterial.getMaterialId();
|
||||
|
||||
|
||||
// assign material indices to mesh faces
|
||||
if (mat_prim_map.find(mat_id) != mat_prim_map.end()) {
|
||||
|
||||
|
||||
std::vector<Primitive>& prims = mat_prim_map[mat_id];
|
||||
|
||||
|
||||
std::vector<Primitive>::iterator it;
|
||||
|
||||
|
||||
for (it = prims.begin(); it != prims.end(); it++) {
|
||||
Primitive& prim = *it;
|
||||
MPoly *mpoly = prim.mpoly;
|
||||
|
@ -1123,7 +1123,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return texture_face;
|
||||
}
|
||||
|
||||
|
@ -1133,19 +1133,19 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
|
|||
std::map<Material *, TexIndexTextureArrayMap>& material_texture_mapping_map)
|
||||
{
|
||||
const COLLADAFW::UniqueId *geom_uid = &geom->getInstanciatedObjectId();
|
||||
|
||||
|
||||
// check if node instanciates controller or geometry
|
||||
if (isController) {
|
||||
|
||||
|
||||
geom_uid = armature_importer->get_geometry_uid(*geom_uid);
|
||||
|
||||
|
||||
if (!geom_uid) {
|
||||
fprintf(stderr, "Couldn't find a mesh UID by controller's UID.\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
if (uid_mesh_map.find(*geom_uid) == uid_mesh_map.end()) {
|
||||
// this could happen if a mesh was not created
|
||||
// (e.g. if it contains unsupported geometry)
|
||||
|
@ -1154,11 +1154,11 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
|
|||
}
|
||||
}
|
||||
if (!uid_mesh_map[*geom_uid]) return NULL;
|
||||
|
||||
|
||||
// name Object
|
||||
const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId();
|
||||
const char *name = (id.length()) ? id.c_str() : NULL;
|
||||
|
||||
|
||||
// add object
|
||||
Object *ob = bc_add_object(scene, OB_MESH, name);
|
||||
bc_set_mark(ob); // used later for material assignement optimization
|
||||
|
@ -1167,7 +1167,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
|
|||
// store object pointer for ArmatureImporter
|
||||
uid_object_map[*geom_uid] = ob;
|
||||
imported_objects.push_back(ob);
|
||||
|
||||
|
||||
// replace ob->data freeing the old one
|
||||
Mesh *old_mesh = (Mesh *)ob->data;
|
||||
Mesh *new_mesh = uid_mesh_map[*geom_uid];
|
||||
|
@ -1181,13 +1181,13 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
|
|||
char layername[100];
|
||||
layername[0] = '\0';
|
||||
MTFace *texture_face = NULL;
|
||||
|
||||
|
||||
COLLADAFW::MaterialBindingArray& mat_array =
|
||||
geom->getMaterialBindings();
|
||||
|
||||
|
||||
// loop through geom's materials
|
||||
for (unsigned int i = 0; i < mat_array.getCount(); i++) {
|
||||
|
||||
|
||||
if (mat_array[i].getReferencedMaterial().isValid()) {
|
||||
texture_face = assign_material_to_geom(mat_array[i], uid_material_map, ob, geom_uid,
|
||||
layername, texture_face,
|
||||
|
@ -1210,14 +1210,14 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
|
|||
fprintf(stderr, "Mesh type %s is not supported\n", bc_geomTypeToStr(geom->getType()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
COLLADAFW::Mesh *mesh = (COLLADAFW::Mesh *)geom;
|
||||
|
||||
|
||||
if (!is_nice_mesh(mesh)) {
|
||||
fprintf(stderr, "Ignoring mesh %s\n", bc_get_dae_name(mesh).c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId();
|
||||
Mesh *me = BKE_mesh_add(G.main, (char *)str_geom_id.c_str());
|
||||
id_us_min(&me->id); // is already 1 here, but will be set later in BKE_mesh_assign_object
|
||||
|
@ -1226,7 +1226,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom)
|
|||
// mesh_geom_map needed to map mesh to its geometry name (for shape key naming)
|
||||
this->uid_mesh_map[mesh->getUniqueId()] = me;
|
||||
this->mesh_geom_map[std::string(me->id.name)] = str_geom_id;
|
||||
|
||||
|
||||
read_vertices(mesh, me);
|
||||
read_polys(mesh, me);
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ private:
|
|||
typedef std::map<COLLADAFW::MaterialId, std::vector<Primitive> > MaterialIdPrimitiveArrayMap;
|
||||
std::map<COLLADAFW::UniqueId, MaterialIdPrimitiveArrayMap> geom_uid_mat_mapping_map; // crazy name!
|
||||
std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId> materials_mapped_to_geom; //< materials that have already been mapped to a geometry. A pair of geom uid and mat uid, one geometry can have several materials
|
||||
|
||||
|
||||
bool set_poly_indices(MPoly *mpoly,
|
||||
MLoop *mloop,
|
||||
int loop_index,
|
||||
|
@ -134,7 +134,7 @@ private:
|
|||
bool is_nice_mesh(COLLADAFW::Mesh *mesh);
|
||||
|
||||
void read_vertices(COLLADAFW::Mesh *mesh, Mesh *me);
|
||||
|
||||
|
||||
bool primitive_has_useable_normals(COLLADAFW::MeshPrimitive *mp);
|
||||
bool primitive_has_faces(COLLADAFW::MeshPrimitive *mp);
|
||||
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid);
|
||||
|
||||
virtual Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId& geom_uid);
|
||||
|
||||
|
||||
MTex *assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture,
|
||||
Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map,
|
||||
MTex *color_texture);
|
||||
|
@ -176,8 +176,8 @@ public:
|
|||
Object *ob, const COLLADAFW::UniqueId *geom_uid,
|
||||
char *layername, MTFace *texture_face,
|
||||
std::map<Material*, TexIndexTextureArrayMap>& material_texture_mapping_map, short mat_index);
|
||||
|
||||
|
||||
|
||||
|
||||
Object *create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom,
|
||||
bool isController,
|
||||
std::map<COLLADAFW::UniqueId, Material*>& uid_material_map,
|
||||
|
|
|
@ -49,7 +49,7 @@ void SceneExporter::exportScene(bContext *C, Scene *sce)
|
|||
}
|
||||
|
||||
void SceneExporter::exportHierarchy(bContext *C, Scene *sce)
|
||||
{
|
||||
{
|
||||
LinkNode *node;
|
||||
std::vector<Object *> base_objects;
|
||||
|
||||
|
@ -58,7 +58,7 @@ void SceneExporter::exportHierarchy(bContext *C, Scene *sce)
|
|||
Object *ob = (Object *) node->link;
|
||||
ob->id.tag |= LIB_TAG_DOIT;
|
||||
}
|
||||
|
||||
|
||||
// Now find all exportable base ojects (highest in export hierarchy)
|
||||
for (node = this->export_settings->export_set; node; node = node->next) {
|
||||
Object *ob = (Object *) node->link;
|
||||
|
@ -146,9 +146,9 @@ void SceneExporter::writeNodes(bContext *C, Object *ob, Scene *sce)
|
|||
COLLADASW::InstanceGeometry instGeom(mSW);
|
||||
instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, this->export_settings->use_object_instantiation)));
|
||||
instGeom.setName(translate_id(id_name(ob)));
|
||||
InstanceWriter::add_material_bindings(instGeom.getBindMaterial(),
|
||||
ob,
|
||||
this->export_settings->active_uv_only,
|
||||
InstanceWriter::add_material_bindings(instGeom.getBindMaterial(),
|
||||
ob,
|
||||
this->export_settings->active_uv_only,
|
||||
this->export_settings->export_texture_type);
|
||||
|
||||
instGeom.add();
|
||||
|
@ -204,17 +204,17 @@ void SceneExporter::writeNodes(bContext *C, Object *ob, Scene *sce)
|
|||
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"rot_error",con->rot_error);
|
||||
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"tar_space",con->tarspace);
|
||||
colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"lin_error",con->lin_error);
|
||||
|
||||
//not ideal: add the target object name as another parameter.
|
||||
|
||||
//not ideal: add the target object name as another parameter.
|
||||
//No real mapping in the .dae
|
||||
//Need support for multiple target objects also.
|
||||
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
|
||||
|
||||
bConstraintTarget *ct;
|
||||
Object *obtar;
|
||||
|
||||
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) {
|
||||
|
|
|
@ -102,7 +102,7 @@ private:
|
|||
friend class ArmatureExporter;
|
||||
void exportHierarchy(bContext *C, Scene *sce);
|
||||
void writeNodes(bContext *C, Object *ob, Scene *sce);
|
||||
|
||||
|
||||
ArmatureExporter *arm_exporter;
|
||||
const ExportSettings *export_settings;
|
||||
};
|
||||
|
|
|
@ -121,7 +121,7 @@ void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData *
|
|||
|
||||
unit_converter->dae_matrix_to_mat4_(bind_shape_matrix, skin->getBindShapeMatrix());
|
||||
}
|
||||
|
||||
|
||||
void SkinInfo::free()
|
||||
{
|
||||
joints_per_vertex.releaseMemory();
|
||||
|
@ -199,7 +199,7 @@ const COLLADAFW::UniqueId& SkinInfo::get_controller_uid()
|
|||
}
|
||||
|
||||
// check if this skin controller references a joint or any descendant of it
|
||||
//
|
||||
//
|
||||
// some nodes may not be referenced by SkinController,
|
||||
// in this case to determine if the node belongs to this armature,
|
||||
// we need to search down the tree
|
||||
|
@ -259,9 +259,9 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::map<COLLADAFW::Unique
|
|||
|
||||
// skip joints that have invalid UID
|
||||
if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) continue;
|
||||
|
||||
|
||||
// name group by joint node name
|
||||
|
||||
|
||||
if (joint_by_uid.find((*it).joint_uid) != joint_by_uid.end()) {
|
||||
name = bc_get_joint_name(joint_by_uid[(*it).joint_uid]);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
void transfer_uint_array_data_const(const COLLADAFW::UIntValuesArray& src, COLLADAFW::UIntValuesArray& dest);
|
||||
|
||||
void borrow_skin_controller_data(const COLLADAFW::SkinControllerData* skin);
|
||||
|
||||
|
||||
void free();
|
||||
|
||||
// using inverse bind matrices to construct armature
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
const COLLADAFW::UniqueId& get_controller_uid();
|
||||
|
||||
// check if this skin controller references a joint or any descendant of it
|
||||
//
|
||||
//
|
||||
// some nodes may not be referenced by SkinController,
|
||||
// in this case to determine if the node belongs to this armature,
|
||||
// we need to search down the tree
|
||||
|
|
|
@ -54,7 +54,7 @@ void TransformReader::get_node_mat(
|
|||
float copy[4][4];
|
||||
|
||||
unit_m4(mat);
|
||||
|
||||
|
||||
for (unsigned int i = 0; i < node->getTransformations().getCount(); i++) {
|
||||
|
||||
COLLADAFW::Transformation *tm = node->getTransformations()[i];
|
||||
|
@ -87,11 +87,11 @@ void TransformReader::get_node_mat(
|
|||
|
||||
copy_m4_m4(copy, mat);
|
||||
mul_m4_m4m4(mat, copy, cur);
|
||||
|
||||
|
||||
if (animation_map) {
|
||||
// AnimationList that drives this Transformation
|
||||
const COLLADAFW::UniqueId& anim_list_id = tm->getAnimationList();
|
||||
|
||||
|
||||
// store this so later we can link animation data with ob
|
||||
Animation anim = {ob, node, tm};
|
||||
(*animation_map)[anim_list_id] = anim;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
|
||||
/** \file TransformReader.h
|
||||
* \ingroup collada
|
||||
*/
|
||||
|
|
|
@ -116,7 +116,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, B
|
|||
{
|
||||
float loc[3], rot[3], scale[3];
|
||||
bc_decompose(f_obmat, loc, rot, NULL, scale);
|
||||
add_transform(node, loc, rot, scale);
|
||||
add_transform(node, loc, rot, scale);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ private:
|
|||
float y_up_mat4[4][4];
|
||||
float z_up_mat4[4][4];
|
||||
float scale_mat4[4][4];
|
||||
|
||||
|
||||
public:
|
||||
|
||||
enum UnitSystem {
|
||||
|
@ -66,11 +66,11 @@ public:
|
|||
void read_asset(const COLLADAFW::FileInfo *asset);
|
||||
|
||||
void convertVector3(COLLADABU::Math::Vector3 &vec, float *v);
|
||||
|
||||
|
||||
UnitConverter::UnitSystem isMetricSystem(void);
|
||||
|
||||
|
||||
float getLinearMeter(void);
|
||||
|
||||
|
||||
// TODO need also for angle conversion, time conversion...
|
||||
|
||||
void dae_matrix_to_mat4_(float out[4][4], const COLLADABU::Math::Matrix4& in);
|
||||
|
|
|
@ -74,7 +74,7 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned in
|
|||
|
||||
if (array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT)
|
||||
return array.getFloatValues()->getData()[index];
|
||||
else
|
||||
else
|
||||
return array.getDoubleValues()->getData()[index];
|
||||
}
|
||||
|
||||
|
@ -82,10 +82,10 @@ float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned in
|
|||
int bc_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 bc_test_parent_loop(par->parent, ob);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
|
|||
{
|
||||
Object workob;
|
||||
Scene *sce = CTX_data_scene(C);
|
||||
|
||||
|
||||
if (!par || bc_test_parent_loop(par, ob))
|
||||
return false;
|
||||
|
||||
|
@ -113,7 +113,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space)
|
|||
mul_m4_m4m4(mat, par->obmat, ob->obmat);
|
||||
copy_m4_m4(ob->obmat, mat);
|
||||
}
|
||||
|
||||
|
||||
// apply child obmat (i.e. decompose it into rot/loc/size)
|
||||
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
|
||||
|
||||
|
@ -224,7 +224,7 @@ Object *bc_get_assigned_armature(Object *ob)
|
|||
// IMPORTANT: This function expects that
|
||||
// all exported objects have set:
|
||||
// ob->id.tag & LIB_TAG_DOIT
|
||||
Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob)
|
||||
Object *bc_get_highest_selected_ancestor_or_self(LinkNode *export_set, Object *ob)
|
||||
{
|
||||
Object *ancestor = ob;
|
||||
while (ob->parent && bc_is_marked(ob->parent)) {
|
||||
|
@ -249,7 +249,7 @@ bool bc_is_in_Export_set(LinkNode *export_set, Object *ob)
|
|||
bool bc_has_object_type(LinkNode *export_set, short obtype)
|
||||
{
|
||||
LinkNode *node;
|
||||
|
||||
|
||||
for (node = export_set; node; node = node->next) {
|
||||
Object *ob = (Object *)node->link;
|
||||
/* XXX - why is this checking for ob->data? - we could be looking for empties */
|
||||
|
@ -283,7 +283,7 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set)
|
|||
for (node = export_set; node->next && !sorted; node = node->next) {
|
||||
|
||||
sorted = true;
|
||||
|
||||
|
||||
LinkNode *current;
|
||||
for (current = export_set; current->next; current = current->next) {
|
||||
Object *a = (Object *)current->link;
|
||||
|
@ -294,12 +294,12 @@ void bc_bubble_sort_by_Object_name(LinkNode *export_set)
|
|||
current->next->link = a;
|
||||
sorted = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if a bone is the top most exportable bone in the bone hierarchy.
|
||||
/* Check if a bone is the top most exportable bone in the bone hierarchy.
|
||||
* When deform_bones_only == false, then only bones with NO parent
|
||||
* can be root bones. Otherwise the top most deform bones in the hierarchy
|
||||
* are root bones.
|
||||
|
@ -360,13 +360,13 @@ void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene)
|
|||
BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
|
||||
}
|
||||
|
||||
void bc_match_scale(std::vector<Object *> *objects_done,
|
||||
void bc_match_scale(std::vector<Object *> *objects_done,
|
||||
UnitConverter &bc_unit,
|
||||
bool scale_to_scene)
|
||||
{
|
||||
for (std::vector<Object *>::iterator it = objects_done->begin();
|
||||
it != objects_done->end();
|
||||
++it)
|
||||
++it)
|
||||
{
|
||||
Object *ob = *it;
|
||||
if (ob -> parent == NULL) {
|
||||
|
@ -774,7 +774,7 @@ float bc_get_property(Bone *bone, std::string key, float def)
|
|||
/**
|
||||
* Read a custom bone property and convert to matrix
|
||||
* Return true if conversion was succesfull
|
||||
*
|
||||
*
|
||||
* Return false if:
|
||||
* - the property does not exist
|
||||
* - is not an array of size 16
|
||||
|
|
|
@ -90,8 +90,8 @@ extern void bc_bubble_sort_by_Object_name(LinkNode *export_set);
|
|||
extern bool bc_is_root_bone(Bone *aBone, bool deform_bones_only);
|
||||
extern int bc_get_active_UVLayer(Object *ob);
|
||||
|
||||
extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement);
|
||||
extern std::string bc_url_encode(std::string data);
|
||||
extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement);
|
||||
extern std::string bc_url_encode(std::string data);
|
||||
extern void bc_match_scale(Object *ob, UnitConverter &bc_unit, bool scale_to_scene);
|
||||
extern void bc_match_scale(std::vector<Object *> *objects_done, UnitConverter &unit_converter, bool scale_to_scene);
|
||||
|
||||
|
@ -141,8 +141,8 @@ class BCPolygonNormalsIndices
|
|||
normal_indices.push_back(index);
|
||||
}
|
||||
|
||||
unsigned int operator[](unsigned int i) {
|
||||
return normal_indices[i];
|
||||
unsigned int operator[](unsigned int i) {
|
||||
return normal_indices[i];
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -386,7 +386,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
const char *path_src;
|
||||
const char *file_dst;
|
||||
|
||||
|
||||
|
||||
if (argc < 3) {
|
||||
printf("Usage: datatoc_icon <dir_icons> <data_icon_to.png>\n");
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
remove_extra_strict_flags()
|
||||
|
||||
set(INC
|
||||
set(INC
|
||||
.
|
||||
../blenkernel
|
||||
../blenlib
|
||||
|
|
|
@ -89,7 +89,7 @@ static IKPlugin *get_plugin(bPose *pose)
|
|||
/*----------------------------------------*/
|
||||
/* Plugin API */
|
||||
|
||||
void BIK_initialize_tree(Scene *scene, Object *ob, float ctime)
|
||||
void BIK_initialize_tree(Scene *scene, Object *ob, float ctime)
|
||||
{
|
||||
IKPlugin *plugin = get_plugin(ob->pose);
|
||||
|
||||
|
@ -97,7 +97,7 @@ void BIK_initialize_tree(Scene *scene, Object *ob, float ctime)
|
|||
plugin->initialize_tree_func(scene, ob, ctime);
|
||||
}
|
||||
|
||||
void BIK_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
|
||||
void BIK_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan, float ctime)
|
||||
{
|
||||
IKPlugin *plugin = get_plugin(ob->pose);
|
||||
|
||||
|
@ -105,7 +105,7 @@ void BIK_execute_tree(struct Scene *scene, Object *ob, bPoseChannel *pchan, floa
|
|||
plugin->execute_tree_func(scene, ob, pchan, ctime);
|
||||
}
|
||||
|
||||
void BIK_release_tree(struct Scene *scene, Object *ob, float ctime)
|
||||
void BIK_release_tree(struct Scene *scene, Object *ob, float ctime)
|
||||
{
|
||||
IKPlugin *plugin = get_plugin(ob->pose);
|
||||
|
||||
|
|
|
@ -877,7 +877,7 @@ static int convert_channels(IK_Scene *ikscene, PoseTree *tree, float ctime)
|
|||
ikchan->owner = ikscene->blArmature;
|
||||
|
||||
// the constraint and channels must be applied before we build the iTaSC scene,
|
||||
// this is because some of the pose data (e.g. pose head) don't have corresponding
|
||||
// this is because some of the pose data (e.g. pose head) don't have corresponding
|
||||
// joint angles and can't be applied to the iTaSC armature dynamically
|
||||
if (!(pchan->flag & POSE_DONE))
|
||||
BKE_pose_where_is_bone(ikscene->blscene, ikscene->blArmature, pchan, ctime, 1);
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
static void composite_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
|
||||
*r_from = NULL;
|
||||
*r_id = &scene->id;
|
||||
*r_ntree = scene->nodetree;
|
||||
|
@ -83,7 +83,7 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa
|
|||
static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node)
|
||||
{
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
for (sock = node->outputs.first; sock; sock = sock->next) {
|
||||
if (sock->cache) {
|
||||
sock->cache = NULL;
|
||||
|
@ -103,15 +103,15 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree)
|
|||
{
|
||||
bNode *node;
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
/* ensure new user input gets handled ok */
|
||||
node->need_exec = 0;
|
||||
node->new_node->original = node;
|
||||
|
||||
|
||||
/* move over the compbufs */
|
||||
/* right after ntreeCopyTree() oldsock pointers are valid */
|
||||
|
||||
|
||||
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
||||
if (node->id) {
|
||||
if (node->flag & NODE_DO_OUTPUT)
|
||||
|
@ -120,7 +120,7 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree)
|
|||
node->new_node->id = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (sock = node->outputs.first; sock; sock = sock->next) {
|
||||
sock->new_sock->cache = sock->cache;
|
||||
sock->cache = NULL;
|
||||
|
@ -138,10 +138,10 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
|
|||
{
|
||||
bNode *lnode;
|
||||
bNodeSocket *lsock;
|
||||
|
||||
|
||||
/* move over the compbufs and previews */
|
||||
BKE_node_preview_merge_tree(ntree, localtree, true);
|
||||
|
||||
|
||||
for (lnode = localtree->nodes.first; lnode; lnode = lnode->next) {
|
||||
if (ntreeNodeExists(ntree, lnode->new_node)) {
|
||||
if (ELEM(lnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
|
||||
|
@ -161,7 +161,7 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
|
|||
lnode->new_node->storage = BKE_tracking_distortion_copy(lnode->storage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (lsock = lnode->outputs.first; lsock; lsock = lsock->next) {
|
||||
if (ntreeOutputExists(lnode->new_node, lsock->new_sock)) {
|
||||
lsock->new_sock->cache = lsock->cache;
|
||||
|
@ -176,9 +176,9 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
|
|||
static void update(bNodeTree *ntree)
|
||||
{
|
||||
ntreeSetOutput(ntree);
|
||||
|
||||
|
||||
ntree_update_reroute_nodes(ntree);
|
||||
|
||||
|
||||
if (ntree->update & NTREE_UPDATE_NODES) {
|
||||
/* clean up preview cache, in case nodes have been removed */
|
||||
BKE_node_preview_remove_unused(ntree);
|
||||
|
@ -187,12 +187,12 @@ static void update(bNodeTree *ntree)
|
|||
|
||||
static void composite_node_add_init(bNodeTree *UNUSED(bnodetree), bNode *bnode)
|
||||
{
|
||||
/* Composite node will only show previews for input classes
|
||||
* by default, other will be hidden
|
||||
/* Composite node will only show previews for input classes
|
||||
* by default, other will be hidden
|
||||
* but can be made visible with the show_preview option */
|
||||
if (bnode->typeinfo->nclass != NODE_CLASS_INPUT) {
|
||||
bnode->flag &= ~NODE_PREVIEW;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bNodeTreeType *ntreeType_Composite;
|
||||
|
@ -200,13 +200,13 @@ bNodeTreeType *ntreeType_Composite;
|
|||
void register_node_tree_type_cmp(void)
|
||||
{
|
||||
bNodeTreeType *tt = ntreeType_Composite = MEM_callocN(sizeof(bNodeTreeType), "compositor node tree type");
|
||||
|
||||
|
||||
tt->type = NTREE_COMPOSIT;
|
||||
strcpy(tt->idname, "CompositorNodeTree");
|
||||
strcpy(tt->ui_name, "Compositing");
|
||||
tt->ui_icon = 0; /* defined in drawnode.c */
|
||||
strcpy(tt->ui_description, "Compositing nodes");
|
||||
|
||||
|
||||
tt->free_cache = free_cache;
|
||||
tt->free_node_cache = free_node_cache;
|
||||
tt->foreach_nodeclass = foreach_nodeclass;
|
||||
|
@ -216,9 +216,9 @@ void register_node_tree_type_cmp(void)
|
|||
tt->update = update;
|
||||
tt->get_from_context = composite_get_from_context;
|
||||
tt->node_add_init = composite_node_add_init;
|
||||
|
||||
|
||||
tt->ext.srna = &RNA_CompositorNodeTree;
|
||||
|
||||
|
||||
ntreeTypeAdd(tt);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ void cmp_node_update_default(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
void cmp_node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag)
|
||||
{
|
||||
node_type_base(ntype, type, name, nclass, flag);
|
||||
|
||||
|
||||
ntype->poll = cmp_node_poll_default;
|
||||
ntype->updatefunc = cmp_node_update_default;
|
||||
ntype->insert_link = node_insert_link_default;
|
||||
|
|
|
@ -60,6 +60,6 @@ void register_node_type_cmp_bokehblur(void)
|
|||
cmp_node_type_base(&ntype, CMP_NODE_BOKEHBLUR, "Bokeh Blur", NODE_CLASS_OP_FILTER, 0);
|
||||
node_type_socket_templates(&ntype, cmp_node_bokehblur_in, cmp_node_bokehblur_out);
|
||||
node_type_init(&ntype, node_composit_init_bokehblur);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ static void node_composit_init_bokehimage(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
void register_node_type_cmp_bokehimage(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_BOKEHIMAGE, "Bokeh Image", NODE_CLASS_INPUT, NODE_PREVIEW);
|
||||
node_type_socket_templates(&ntype, NULL, cmp_node_bokehimage_out);
|
||||
node_type_init(&ntype, node_composit_init_bokehimage);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "../node_composite_util.h"
|
||||
|
||||
/* **************** SCALAR MATH ******************** */
|
||||
/* **************** SCALAR MATH ******************** */
|
||||
static bNodeSocketTemplate cmp_node_boxmask_in[] = {
|
||||
{ SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
||||
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
||||
|
|
|
@ -54,7 +54,7 @@ static void node_composit_init_brightcontrast(bNodeTree *UNUSED(ntree), bNode *n
|
|||
void register_node_type_cmp_brightcontrast(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
|
||||
node_type_socket_templates(&ntype, cmp_node_brightcontrast_in, cmp_node_brightcontrast_out);
|
||||
node_type_init(&ntype, node_composit_init_brightcontrast);
|
||||
|
|
|
@ -57,7 +57,7 @@ static void node_composit_init_color_spill(bNodeTree *UNUSED(ntree), bNode *node
|
|||
void register_node_type_cmp_color_spill(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_COLOR_SPILL, "Color Spill", NODE_CLASS_MATTE, 0);
|
||||
node_type_socket_templates(&ntype, cmp_node_color_spill_in, cmp_node_color_spill_out);
|
||||
node_type_init(&ntype, node_composit_init_color_spill);
|
||||
|
|
|
@ -52,7 +52,7 @@ void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
{
|
||||
NodeColorBalance *n = node->storage;
|
||||
int c;
|
||||
|
||||
|
||||
for (c = 0; c < 3; ++c) {
|
||||
n->slope[c] = (2.0f - n->lift[c]) * n->gain[c];
|
||||
n->offset[c] = (n->lift[c] - 1.0f) * n->gain[c];
|
||||
|
@ -64,7 +64,7 @@ void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
{
|
||||
NodeColorBalance *n = node->storage;
|
||||
int c;
|
||||
|
||||
|
||||
for (c = 0; c < 3; ++c) {
|
||||
float d = n->slope[c] + n->offset[c];
|
||||
n->lift[c] = (d != 0.0f ? n->slope[c] + 2.0f * n->offset[c] / d : 0.0f);
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
void register_node_type_cmp_group(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
/* NB: cannot use sh_node_type_base for node group, because it would map the node type
|
||||
* to the shared NODE_GROUP integer type id.
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@ void register_node_type_cmp_group(void)
|
|||
ntype.ext.srna = RNA_struct_find("CompositorNodeGroup");
|
||||
BLI_assert(ntype.ext.srna != NULL);
|
||||
RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
|
||||
|
||||
|
||||
node_type_socket_templates(&ntype, NULL, NULL);
|
||||
node_type_size(&ntype, 140, 60, 400);
|
||||
node_type_label(&ntype, node_group_label);
|
||||
|
|
|
@ -54,7 +54,7 @@ static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode *node
|
|||
void register_node_type_cmp_dilateerode(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_DILATEERODE, "Dilate/Erode", NODE_CLASS_OP_FILTER, 0);
|
||||
node_type_socket_templates(&ntype, cmp_node_dilateerode_in, cmp_node_dilateerode_out);
|
||||
node_type_init(&ntype, node_composit_init_dilateerode);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "../node_composite_util.h"
|
||||
|
||||
/* **************** SCALAR MATH ******************** */
|
||||
/* **************** SCALAR MATH ******************** */
|
||||
static bNodeSocketTemplate cmp_node_ellipsemask_in[] = {
|
||||
{ SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
||||
{ SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
||||
|
|
|
@ -47,9 +47,9 @@ static bNodeSocketTemplate cmp_node_gamma_out[] = {
|
|||
void register_node_type_cmp_gamma(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
|
||||
node_type_socket_templates(&ntype, cmp_node_gamma_in, cmp_node_gamma_out);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -47,14 +47,14 @@ static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
{
|
||||
CurveMapping *cumapping = node->storage = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
int c;
|
||||
|
||||
|
||||
cumapping->preset = CURVE_PRESET_MID9;
|
||||
|
||||
|
||||
for (c = 0; c < 3; c++) {
|
||||
CurveMap *cuma = &cumapping->cm[c];
|
||||
curvemap_reset(cuma, &cumapping->clipr, cumapping->preset, CURVEMAP_SLOPE_POSITIVE);
|
||||
}
|
||||
|
||||
|
||||
/* default to showing Saturation */
|
||||
cumapping->cur = 1;
|
||||
}
|
||||
|
|
|
@ -149,10 +149,10 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node, LinkNod
|
|||
|
||||
/* make sure ima->type is correct */
|
||||
ibuf = BKE_image_acquire_ibuf(ima, &load_iuser, NULL);
|
||||
|
||||
|
||||
if (ima->rr) {
|
||||
RenderLayer *rl = BLI_findlink(&ima->rr->layers, iuser->layer);
|
||||
|
||||
|
||||
if (rl) {
|
||||
RenderPass *rpass;
|
||||
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
|
||||
|
@ -250,7 +250,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
|
|||
bNodeSocket *sock, *sock_next;
|
||||
LinkNodePair available_sockets = {NULL, NULL};
|
||||
int sock_index;
|
||||
|
||||
|
||||
/* XXX make callback */
|
||||
if (rlayer)
|
||||
cmp_node_rlayer_create_outputs(ntree, node, &available_sockets);
|
||||
|
@ -305,7 +305,7 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node)
|
|||
iuser->sfra = 1;
|
||||
iuser->fie_ima = 2;
|
||||
iuser->ok = 1;
|
||||
|
||||
|
||||
/* setup initial outputs */
|
||||
cmp_node_image_verify_outputs(ntree, node, false);
|
||||
}
|
||||
|
@ -313,20 +313,20 @@ static void node_composit_init_image(bNodeTree *ntree, bNode *node)
|
|||
static void node_composit_free_image(bNode *node)
|
||||
{
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
/* free extra socket info */
|
||||
for (sock = node->outputs.first; sock; sock = sock->next)
|
||||
MEM_freeN(sock->storage);
|
||||
|
||||
|
||||
MEM_freeN(node->storage);
|
||||
}
|
||||
|
||||
static void node_composit_copy_image(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
|
||||
{
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
dest_node->storage = MEM_dupallocN(src_node->storage);
|
||||
|
||||
|
||||
/* copy extra socket info */
|
||||
for (sock = src_node->outputs.first; sock; sock = sock->next)
|
||||
sock->new_sock->storage = MEM_dupallocN(sock->storage);
|
||||
|
@ -392,7 +392,7 @@ static int node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntree
|
|||
{
|
||||
if (STREQ(ntree->idname, "CompositorNodeTree")) {
|
||||
Scene *scene;
|
||||
|
||||
|
||||
/* XXX ugly: check if ntree is a local scene node tree.
|
||||
* Render layers node can only be used in local scene->nodetree,
|
||||
* since it directly links to the scene.
|
||||
|
@ -400,7 +400,7 @@ static int node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntree
|
|||
for (scene = G.main->scene.first; scene; scene = scene->id.next)
|
||||
if (scene->nodetree == ntree)
|
||||
break;
|
||||
|
||||
|
||||
return (scene != NULL);
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -47,7 +47,7 @@ static bNodeSocketTemplate cmp_node_inpaint_out[] = {
|
|||
void register_node_type_cmp_inpaint(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_INPAINT, "Inpaint", NODE_CLASS_OP_FILTER, 0);
|
||||
node_type_socket_templates(&ntype, cmp_node_inpaint_in, cmp_node_inpaint_out);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "node_composite_util.h"
|
||||
|
||||
/* **************** SCALAR MATH ******************** */
|
||||
/* **************** SCALAR MATH ******************** */
|
||||
static bNodeSocketTemplate cmp_node_math_in[] = {
|
||||
{ SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
|
||||
{ SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
|
||||
|
|
|
@ -58,7 +58,7 @@ static void init(const bContext *C, PointerRNA *ptr)
|
|||
{
|
||||
bNode *node = ptr->data;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
|
||||
node->id = (ID *)scene->clip;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,9 +46,9 @@ static bNodeSocketTemplate cmp_node_normalize_out[] = {
|
|||
void register_node_type_cmp_normalize(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_NORMALIZE, "Normalize", NODE_CLASS_OP_VECTOR, 0);
|
||||
node_type_socket_templates(&ntype, cmp_node_normalize_in, cmp_node_normalize_out);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -107,16 +107,16 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con
|
|||
{
|
||||
NodeImageMultiFile *nimf = node->storage;
|
||||
bNodeSocket *sock = nodeAddStaticSocket(ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, NULL, name);
|
||||
|
||||
|
||||
/* create format data for the input socket */
|
||||
NodeImageMultiFileSocket *sockdata = MEM_callocN(sizeof(NodeImageMultiFileSocket), "socket image format");
|
||||
sock->storage = sockdata;
|
||||
|
||||
|
||||
BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path));
|
||||
ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_');
|
||||
BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer));
|
||||
ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_');
|
||||
|
||||
|
||||
if (im_format) {
|
||||
sockdata->format = *im_format;
|
||||
if (BKE_imtype_is_movie(sockdata->format.imtype)) {
|
||||
|
@ -129,7 +129,7 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con
|
|||
sockdata->use_node_format = true;
|
||||
|
||||
nimf->active_input = BLI_findindex(&node->inputs, sock);
|
||||
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
|
@ -138,16 +138,16 @@ int ntreeCompositOutputFileRemoveActiveSocket(bNodeTree *ntree, bNode *node)
|
|||
NodeImageMultiFile *nimf = node->storage;
|
||||
bNodeSocket *sock = BLI_findlink(&node->inputs, nimf->active_input);
|
||||
int totinputs = BLI_listbase_count(&node->inputs);
|
||||
|
||||
|
||||
if (!sock)
|
||||
return 0;
|
||||
|
||||
|
||||
if (nimf->active_input == totinputs - 1)
|
||||
--nimf->active_input;
|
||||
|
||||
|
||||
/* free format data */
|
||||
MEM_freeN(sock->storage);
|
||||
|
||||
|
||||
nodeRemoveSocket(ntree, node, sock);
|
||||
return 1;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
|
|||
NodeImageMultiFile *nimf = MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file");
|
||||
ImageFormatData *format = NULL;
|
||||
node->storage = nimf;
|
||||
|
||||
|
||||
if (scene) {
|
||||
RenderData *rd = &scene->r;
|
||||
|
||||
|
@ -184,7 +184,7 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
|
|||
if (BKE_imtype_is_movie(nimf->format.imtype)) {
|
||||
nimf->format.imtype = R_IMF_IMTYPE_OPENEXR;
|
||||
}
|
||||
|
||||
|
||||
format = &nimf->format;
|
||||
}
|
||||
else
|
||||
|
@ -197,21 +197,21 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
|
|||
static void free_output_file(bNode *node)
|
||||
{
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
/* free storage data in sockets */
|
||||
for (sock = node->inputs.first; sock; sock = sock->next) {
|
||||
MEM_freeN(sock->storage);
|
||||
}
|
||||
|
||||
|
||||
MEM_freeN(node->storage);
|
||||
}
|
||||
|
||||
static void copy_output_file(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
|
||||
{
|
||||
bNodeSocket *src_sock, *dest_sock;
|
||||
|
||||
|
||||
dest_node->storage = MEM_dupallocN(src_node->storage);
|
||||
|
||||
|
||||
/* duplicate storage data in sockets */
|
||||
for (src_sock = src_node->inputs.first, dest_sock = dest_node->inputs.first; src_sock && dest_sock; src_sock = src_sock->next, dest_sock = dest_sock->next) {
|
||||
dest_sock->storage = MEM_dupallocN(src_sock->storage);
|
||||
|
@ -222,7 +222,7 @@ static void update_output_file(bNodeTree *ntree, bNode *node)
|
|||
{
|
||||
bNodeSocket *sock, *sock_next;
|
||||
PointerRNA ptr;
|
||||
|
||||
|
||||
/* XXX fix for #36706: remove invalid sockets added with bpy API.
|
||||
* This is not ideal, but prevents crashes from missing storage.
|
||||
* FileOutput node needs a redesign to support this properly.
|
||||
|
@ -237,9 +237,9 @@ static void update_output_file(bNodeTree *ntree, bNode *node)
|
|||
sock_next = sock->next;
|
||||
nodeRemoveSocket(ntree, node, sock);
|
||||
}
|
||||
|
||||
|
||||
cmp_node_update_default(ntree, node);
|
||||
|
||||
|
||||
/* automatically update the socket type based on linked input */
|
||||
for (sock = node->inputs.first; sock; sock = sock->next) {
|
||||
if (sock->link) {
|
||||
|
|
|
@ -49,7 +49,7 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node
|
|||
iuser->fie_ima = 2;
|
||||
iuser->ok = 1;
|
||||
node->custom1 = 50; /* default 50% split */
|
||||
|
||||
|
||||
node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
}
|
||||
|
||||
|
|
|
@ -50,9 +50,9 @@ static void init(const bContext *C, PointerRNA *ptr)
|
|||
{
|
||||
bNode *node = ptr->data;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
|
||||
node->id = (ID *)scene->clip;
|
||||
|
||||
|
||||
/* default to bilinear, see node_sampler_type_items in rna_nodetree.c */
|
||||
node->custom1 = 1;
|
||||
}
|
||||
|
|
|
@ -77,10 +77,10 @@ static bNodeSocketTemplate cmp_node_rgbtobw_out[] = {
|
|||
void register_node_type_cmp_rgbtobw(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
cmp_node_type_base(&ntype, CMP_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0);
|
||||
node_type_socket_templates(&ntype, cmp_node_rgbtobw_in, cmp_node_rgbtobw_out);
|
||||
node_type_size_preset(&ntype, NODE_SIZE_SMALL);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
iuser->ok = 1;
|
||||
node->custom3 = 0.5f;
|
||||
node->custom4 = 0.5f;
|
||||
|
||||
|
||||
node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
|
||||
}
|
||||
|
||||
|
|
|
@ -98,16 +98,16 @@ int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
|
|||
{
|
||||
bNode *node;
|
||||
int valid = 1;
|
||||
|
||||
|
||||
/* unspecified node group, generally allowed
|
||||
* (if anything, should be avoided on operator level)
|
||||
*/
|
||||
if (grouptree == NULL)
|
||||
return 1;
|
||||
|
||||
|
||||
if (nodetree == grouptree)
|
||||
return 0;
|
||||
|
||||
|
||||
for (node = grouptree->nodes.first; node; node = node->next) {
|
||||
if (node->typeinfo->poll_instance && !node->typeinfo->poll_instance(node, nodetree)) {
|
||||
valid = 0;
|
||||
|
@ -121,27 +121,27 @@ int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
|
|||
static bNodeSocket *group_verify_socket(bNodeTree *ntree, bNode *gnode, bNodeSocket *iosock, ListBase *verify_lb, int in_out)
|
||||
{
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
for (sock = verify_lb->first; sock; sock = sock->next) {
|
||||
if (STREQ(sock->identifier, iosock->identifier))
|
||||
break;
|
||||
}
|
||||
if (sock) {
|
||||
strcpy(sock->name, iosock->name);
|
||||
|
||||
|
||||
if (iosock->typeinfo->interface_verify_socket)
|
||||
iosock->typeinfo->interface_verify_socket(ntree, iosock, gnode, sock, "interface");
|
||||
}
|
||||
else {
|
||||
sock = nodeAddSocket(ntree, gnode, in_out, iosock->idname, iosock->identifier, iosock->name);
|
||||
|
||||
|
||||
if (iosock->typeinfo->interface_init_socket)
|
||||
iosock->typeinfo->interface_init_socket(ntree, iosock, gnode, sock, "interface");
|
||||
}
|
||||
|
||||
|
||||
/* remove from list temporarily, to distinguish from orphaned sockets */
|
||||
BLI_remlink(verify_lb, sock);
|
||||
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
|
@ -150,9 +150,9 @@ static void group_verify_socket_list(bNodeTree *ntree, bNode *gnode,
|
|||
ListBase *iosock_lb, ListBase *verify_lb, int in_out)
|
||||
{
|
||||
bNodeSocket *iosock, *sock, *nextsock;
|
||||
|
||||
|
||||
/* step by step compare */
|
||||
|
||||
|
||||
iosock = iosock_lb->first;
|
||||
for (; iosock; iosock = iosock->next) {
|
||||
/* abusing new_sock pointer for verification here! only used inside this function */
|
||||
|
@ -195,9 +195,9 @@ static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
{
|
||||
NodeFrame *data = (NodeFrame *)MEM_callocN(sizeof(NodeFrame), "frame node storage");
|
||||
node->storage = data;
|
||||
|
||||
|
||||
data->flag |= NODE_FRAME_SHRINK;
|
||||
|
||||
|
||||
data->label_size = 20;
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ void register_node_type_frame(void)
|
|||
node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage);
|
||||
node_type_size(ntype, 150, 100, 0);
|
||||
node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
|
||||
|
||||
|
||||
ntype->needs_free = 1;
|
||||
nodeRegisterType(ntype);
|
||||
}
|
||||
|
@ -251,11 +251,11 @@ void register_node_type_reroute(void)
|
|||
{
|
||||
/* frame type is used for all tree types, needs dynamic allocation */
|
||||
bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "frame node type");
|
||||
|
||||
|
||||
node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0);
|
||||
node_type_init(ntype, node_reroute_init);
|
||||
node_type_internal_links(ntype, node_reroute_update_internal_links);
|
||||
|
||||
|
||||
ntype->needs_free = 1;
|
||||
nodeRegisterType(ntype);
|
||||
}
|
||||
|
@ -267,14 +267,14 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
|
|||
bNodeLink *link;
|
||||
int type = SOCK_FLOAT;
|
||||
const char *type_idname = nodeStaticSocketType(type, PROP_NONE);
|
||||
|
||||
|
||||
/* XXX it would be a little bit more efficient to restrict actual updates
|
||||
* to rerout nodes connected to an updated node, but there's no reliable flag
|
||||
* to indicate updated nodes (node->update is not set on linking).
|
||||
*/
|
||||
|
||||
|
||||
node->done = 1;
|
||||
|
||||
|
||||
/* recursive update */
|
||||
for (link = ntree->links.first; link; link = link->next) {
|
||||
bNode *fromnode = link->fromnode;
|
||||
|
@ -283,7 +283,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
|
|||
continue;
|
||||
if (nodeLinkIsHidden(link))
|
||||
continue;
|
||||
|
||||
|
||||
if (flag & REFINE_FORWARD) {
|
||||
if (tonode == node && fromnode->type == NODE_REROUTE && !fromnode->done)
|
||||
node_reroute_inherit_type_recursive(ntree, fromnode, REFINE_FORWARD);
|
||||
|
@ -293,7 +293,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
|
|||
node_reroute_inherit_type_recursive(ntree, tonode, REFINE_BACKWARD);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* determine socket type from unambiguous input/output connection if possible */
|
||||
if (input->limit == 1 && input->link) {
|
||||
type = input->link->fromsock->type;
|
||||
|
@ -303,7 +303,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
|
|||
type = output->link->tosock->type;
|
||||
type_idname = nodeStaticSocketType(type, PROP_NONE);
|
||||
}
|
||||
|
||||
|
||||
if (input->type != type) {
|
||||
bNodeSocket *ninput = nodeAddSocket(ntree, node, SOCK_IN, type_idname, "input", "Input");
|
||||
for (link = ntree->links.first; link; link = link->next) {
|
||||
|
@ -314,7 +314,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
|
|||
}
|
||||
nodeRemoveSocket(ntree, node, input);
|
||||
}
|
||||
|
||||
|
||||
if (output->type != type) {
|
||||
bNodeSocket *noutput = nodeAddSocket(ntree, node, SOCK_OUT, type_idname, "output", "Output");
|
||||
for (link = ntree->links.first; link; link = link->next) {
|
||||
|
@ -324,7 +324,7 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
|
|||
}
|
||||
nodeRemoveSocket(ntree, node, output);
|
||||
}
|
||||
|
||||
|
||||
nodeUpdateInternalLinks(ntree, node);
|
||||
}
|
||||
|
||||
|
@ -334,11 +334,11 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
|
|||
void ntree_update_reroute_nodes(bNodeTree *ntree)
|
||||
{
|
||||
bNode *node;
|
||||
|
||||
|
||||
/* clear tags */
|
||||
for (node = ntree->nodes.first; node; node = node->next)
|
||||
node->done = 0;
|
||||
|
||||
|
||||
for (node = ntree->nodes.first; node; node = node->next)
|
||||
if (node->type == NODE_REROUTE && !node->done)
|
||||
node_reroute_inherit_type_recursive(ntree, node, REFINE_FORWARD | REFINE_BACKWARD);
|
||||
|
@ -411,7 +411,7 @@ void node_group_input_verify(bNodeTree *ntree, bNode *node, ID *id)
|
|||
if (id == (ID *)ntree) {
|
||||
/* value_in_out inverted for interface nodes to get correct socket value_property */
|
||||
group_verify_socket_list(ntree, node, &ntree->inputs, &node->outputs, SOCK_OUT);
|
||||
|
||||
|
||||
/* add virtual extension socket */
|
||||
nodeAddSocket(ntree, node, SOCK_OUT, "NodeSocketVirtual", "__extend__", "");
|
||||
}
|
||||
|
@ -426,23 +426,23 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
|
|||
* so they can be recreated after verification.
|
||||
*/
|
||||
ListBase tmplinks;
|
||||
|
||||
|
||||
/* find links from the extension socket and store them */
|
||||
BLI_listbase_clear(&tmplinks);
|
||||
for (link = ntree->links.first; link; link = linknext) {
|
||||
linknext = link->next;
|
||||
if (nodeLinkIsHidden(link))
|
||||
continue;
|
||||
|
||||
|
||||
if (link->fromsock == extsock) {
|
||||
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
|
||||
*tlink = *link;
|
||||
BLI_addtail(&tmplinks, tlink);
|
||||
|
||||
|
||||
nodeRemLink(ntree, link);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* find valid link to expose */
|
||||
exposelink = NULL;
|
||||
for (link = tmplinks.first; link; link = link->next) {
|
||||
|
@ -456,22 +456,22 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (exposelink) {
|
||||
bNodeSocket *gsock, *newsock;
|
||||
|
||||
|
||||
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->tonode, exposelink->tosock);
|
||||
|
||||
|
||||
node_group_input_verify(ntree, node, (ID *)ntree);
|
||||
newsock = node_group_input_find_socket(node, gsock->identifier);
|
||||
|
||||
|
||||
/* redirect links from the extension socket */
|
||||
for (link = tmplinks.first; link; link = link->next) {
|
||||
nodeAddLink(ntree, node, newsock, link->tonode, link->tosock);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
BLI_freelistN(&tmplinks);
|
||||
}
|
||||
|
||||
|
@ -479,13 +479,13 @@ void register_node_type_group_input(void)
|
|||
{
|
||||
/* used for all tree types, needs dynamic allocation */
|
||||
bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "node type");
|
||||
|
||||
|
||||
node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE, 0);
|
||||
node_type_size(ntype, 140, 80, 400);
|
||||
node_type_init(ntype, node_group_input_init);
|
||||
node_type_update(ntype, node_group_input_update, node_group_input_verify);
|
||||
node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
|
||||
|
||||
|
||||
ntype->needs_free = 1;
|
||||
nodeRegisterType(ntype);
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ void node_group_output_verify(bNodeTree *ntree, bNode *node, ID *id)
|
|||
if (id == (ID *)ntree) {
|
||||
/* value_in_out inverted for interface nodes to get correct socket value_property */
|
||||
group_verify_socket_list(ntree, node, &ntree->outputs, &node->inputs, SOCK_IN);
|
||||
|
||||
|
||||
/* add virtual extension socket */
|
||||
nodeAddSocket(ntree, node, SOCK_IN, "NodeSocketVirtual", "__extend__", "");
|
||||
}
|
||||
|
@ -525,23 +525,23 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
|
|||
* so they can be recreated after verification.
|
||||
*/
|
||||
ListBase tmplinks;
|
||||
|
||||
|
||||
/* find links to the extension socket and store them */
|
||||
BLI_listbase_clear(&tmplinks);
|
||||
for (link = ntree->links.first; link; link = linknext) {
|
||||
linknext = link->next;
|
||||
if (nodeLinkIsHidden(link))
|
||||
continue;
|
||||
|
||||
|
||||
if (link->tosock == extsock) {
|
||||
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
|
||||
*tlink = *link;
|
||||
BLI_addtail(&tmplinks, tlink);
|
||||
|
||||
|
||||
nodeRemLink(ntree, link);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* find valid link to expose */
|
||||
exposelink = NULL;
|
||||
for (link = tmplinks.first; link; link = link->next) {
|
||||
|
@ -555,22 +555,22 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (exposelink) {
|
||||
bNodeSocket *gsock, *newsock;
|
||||
|
||||
|
||||
/* XXX what if connecting virtual to virtual socket?? */
|
||||
gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->fromnode, exposelink->fromsock);
|
||||
|
||||
|
||||
node_group_output_verify(ntree, node, (ID *)ntree);
|
||||
newsock = node_group_output_find_socket(node, gsock->identifier);
|
||||
|
||||
|
||||
/* redirect links to the extension socket */
|
||||
for (link = tmplinks.first; link; link = link->next) {
|
||||
nodeAddLink(ntree, link->fromnode, link->fromsock, node, newsock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BLI_freelistN(&tmplinks);
|
||||
}
|
||||
|
||||
|
@ -578,13 +578,13 @@ void register_node_type_group_output(void)
|
|||
{
|
||||
/* used for all tree types, needs dynamic allocation */
|
||||
bNodeType *ntype = MEM_callocN(sizeof(bNodeType), "node type");
|
||||
|
||||
|
||||
node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE, 0);
|
||||
node_type_size(ntype, 140, 80, 400);
|
||||
node_type_init(ntype, node_group_output_init);
|
||||
node_type_update(ntype, node_group_output_update, node_group_output_verify);
|
||||
node_type_compatibility(ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
|
||||
|
||||
|
||||
ntype->needs_free = 1;
|
||||
nodeRegisterType(ntype);
|
||||
}
|
||||
|
|
|
@ -61,14 +61,14 @@ bNodeStack *node_get_socket_stack(bNodeStack *stack, bNodeSocket *sock)
|
|||
void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
/* build pointer stack */
|
||||
if (in) {
|
||||
for (sock = node->inputs.first; sock; sock = sock->next) {
|
||||
*(in++) = node_get_socket_stack(stack, sock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (out) {
|
||||
for (sock = node->outputs.first; sock; sock = sock->next) {
|
||||
*(out++) = node_get_socket_stack(stack, sock);
|
||||
|
@ -127,13 +127,13 @@ static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeTree *ntree, bNode
|
|||
bNodeStack *ns = node_get_socket_stack(stack, sock);
|
||||
if (!ns)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* don't mess with remote socket stacks, these are initialized by other nodes! */
|
||||
if (sock->link)
|
||||
return ns;
|
||||
|
||||
|
||||
ns->sockettype = sock->type;
|
||||
|
||||
|
||||
switch (sock->type) {
|
||||
case SOCK_FLOAT:
|
||||
ns->vec[0] = node_socket_get_float(ntree, node, sock);
|
||||
|
@ -145,7 +145,7 @@ static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeTree *ntree, bNode
|
|||
node_socket_get_color(ntree, node, sock, ns->vec);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
||||
|
@ -161,29 +161,29 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo
|
|||
bNode **nodelist;
|
||||
int totnodes, n;
|
||||
/* XXX texnodes have threading issues with muting, have to disable it there ... */
|
||||
|
||||
|
||||
/* ensure all sock->link pointers and node levels are correct */
|
||||
ntreeUpdateTree(G.main, ntree);
|
||||
|
||||
|
||||
/* get a dependency-sorted list of nodes */
|
||||
ntreeGetDependencyList(ntree, &nodelist, &totnodes);
|
||||
|
||||
|
||||
/* XXX could let callbacks do this for specialized data */
|
||||
exec = MEM_callocN(sizeof(bNodeTreeExec), "node tree execution data");
|
||||
/* backpointer to node tree */
|
||||
exec->nodetree = ntree;
|
||||
|
||||
|
||||
/* set stack indices */
|
||||
index = 0;
|
||||
for (n = 0; n < totnodes; ++n) {
|
||||
node = nodelist[n];
|
||||
|
||||
|
||||
node->stack_index = index;
|
||||
|
||||
|
||||
/* init node socket stack indexes */
|
||||
for (sock = node->inputs.first; sock; sock = sock->next)
|
||||
node_init_input_index(sock, &index);
|
||||
|
||||
|
||||
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
|
||||
for (sock = node->outputs.first; sock; sock = sock->next)
|
||||
node_init_output_index(sock, &index, &node->internal_links);
|
||||
|
@ -193,48 +193,48 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context, bNodeTree *ntree, bNo
|
|||
node_init_output_index(sock, &index, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* allocated exec data pointers for nodes */
|
||||
exec->totnodes = totnodes;
|
||||
exec->nodeexec = MEM_callocN(exec->totnodes * sizeof(bNodeExec), "node execution data");
|
||||
/* allocate data pointer for node stack */
|
||||
exec->stacksize = index;
|
||||
exec->stack = MEM_callocN(exec->stacksize * sizeof(bNodeStack), "bNodeStack");
|
||||
|
||||
|
||||
/* all non-const results are considered inputs */
|
||||
for (n = 0; n < exec->stacksize; ++n)
|
||||
exec->stack[n].hasinput = 1;
|
||||
|
||||
|
||||
/* prepare all nodes for execution */
|
||||
for (n = 0, nodeexec = exec->nodeexec; n < totnodes; ++n, ++nodeexec) {
|
||||
node = nodeexec->node = nodelist[n];
|
||||
nodeexec->freeexecfunc = node->typeinfo->freeexecfunc;
|
||||
|
||||
|
||||
/* tag inputs */
|
||||
for (sock = node->inputs.first; sock; sock = sock->next) {
|
||||
/* disable the node if an input link is invalid */
|
||||
if (sock->link && !(sock->link->flag & NODE_LINK_VALID))
|
||||
node->need_exec = 0;
|
||||
|
||||
|
||||
ns = setup_stack(exec->stack, ntree, node, sock);
|
||||
if (ns)
|
||||
ns->hasoutput = 1;
|
||||
}
|
||||
|
||||
|
||||
/* tag all outputs */
|
||||
for (sock = node->outputs.first; sock; sock = sock->next) {
|
||||
/* ns = */ setup_stack(exec->stack, ntree, node, sock);
|
||||
}
|
||||
|
||||
|
||||
nodekey = BKE_node_instance_key(parent_key, ntree, node);
|
||||
nodeexec->data.preview = context->previews ? BKE_node_instance_hash_lookup(context->previews, nodekey) : NULL;
|
||||
if (node->typeinfo->initexecfunc)
|
||||
nodeexec->data.data = node->typeinfo->initexecfunc(context, node, nodekey);
|
||||
}
|
||||
|
||||
|
||||
if (nodelist)
|
||||
MEM_freeN(nodelist);
|
||||
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
|
@ -242,18 +242,18 @@ void ntree_exec_end(bNodeTreeExec *exec)
|
|||
{
|
||||
bNodeExec *nodeexec;
|
||||
int n;
|
||||
|
||||
|
||||
if (exec->stack)
|
||||
MEM_freeN(exec->stack);
|
||||
|
||||
|
||||
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
|
||||
if (nodeexec->freeexecfunc)
|
||||
nodeexec->freeexecfunc(nodeexec->data.data);
|
||||
}
|
||||
|
||||
|
||||
if (exec->nodeexec)
|
||||
MEM_freeN(exec->nodeexec);
|
||||
|
||||
|
||||
MEM_freeN(exec);
|
||||
}
|
||||
|
||||
|
@ -263,14 +263,14 @@ bNodeThreadStack *ntreeGetThreadStack(bNodeTreeExec *exec, int thread)
|
|||
{
|
||||
ListBase *lb = &exec->threadstack[thread];
|
||||
bNodeThreadStack *nts;
|
||||
|
||||
|
||||
for (nts = lb->first; nts; nts = nts->next) {
|
||||
if (!nts->used) {
|
||||
nts->used = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!nts) {
|
||||
nts = MEM_callocN(sizeof(bNodeThreadStack), "bNodeThreadStack");
|
||||
nts->stack = MEM_dupallocN(exec->stack);
|
||||
|
@ -293,9 +293,9 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
|
|||
bNodeExec *nodeexec;
|
||||
bNode *node;
|
||||
int n;
|
||||
|
||||
|
||||
/* nodes are presorted, so exec is in order of list */
|
||||
|
||||
|
||||
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
|
||||
node = nodeexec->node;
|
||||
if (node->need_exec) {
|
||||
|
@ -310,7 +310,7 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
|
|||
node->typeinfo->execfunc(callerdata, thread, node, &nodeexec->data, nsin, nsout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* signal to that all went OK, for render */
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,17 +51,17 @@ struct bNodeStack;
|
|||
typedef struct bNodeExec {
|
||||
struct bNode *node; /* backpointer to node */
|
||||
bNodeExecData data;
|
||||
|
||||
|
||||
NodeFreeExecFunction freeexecfunc; /* free function, stored in exec itself to avoid dangling node pointer access */
|
||||
} bNodeExec;
|
||||
|
||||
/* Execution Data for each instance of node tree execution */
|
||||
typedef struct bNodeTreeExec {
|
||||
struct bNodeTree *nodetree; /* backpointer to node tree */
|
||||
|
||||
|
||||
int totnodes; /* total node count */
|
||||
struct bNodeExec *nodeexec; /* per-node execution data */
|
||||
|
||||
|
||||
int stacksize;
|
||||
struct bNodeStack *stack; /* socket data stack */
|
||||
/* only used by material and texture trees to keep one stack for each thread */
|
||||
|
|
|
@ -52,9 +52,9 @@ struct Main;
|
|||
struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocketTemplate *stemp, int in_out)
|
||||
{
|
||||
bNodeSocket *sock = nodeAddStaticSocket(ntree, node, in_out, stemp->type, stemp->subtype, stemp->identifier, stemp->name);
|
||||
|
||||
|
||||
sock->flag |= stemp->flag;
|
||||
|
||||
|
||||
/* initialize default_value */
|
||||
switch (stemp->type) {
|
||||
case SOCK_FLOAT:
|
||||
|
@ -99,14 +99,14 @@ struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struc
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in_out, ListBase *socklist, bNodeSocketTemplate *stemp)
|
||||
{
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
for (sock = socklist->first; sock; sock = sock->next) {
|
||||
if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR))
|
||||
break;
|
||||
|
@ -127,7 +127,7 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in
|
|||
/* remove the new socket from the node socket list first,
|
||||
* will be added back after verification. */
|
||||
BLI_remlink(socklist, sock);
|
||||
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou
|
|||
{
|
||||
bNodeSocket *sock, *nextsock;
|
||||
bNodeSocketTemplate *stemp;
|
||||
|
||||
|
||||
/* no inputs anymore? */
|
||||
if (stemp_first == NULL) {
|
||||
for (sock = (bNodeSocket *)socklist->first; sock; sock = nextsock) {
|
||||
|
@ -155,7 +155,7 @@ static void verify_socket_template_list(bNodeTree *ntree, bNode *node, int in_ou
|
|||
nextsock = sock->next;
|
||||
nodeRemoveSocket(ntree, node, sock);
|
||||
}
|
||||
|
||||
|
||||
/* and we put back the verified sockets */
|
||||
stemp = stemp_first;
|
||||
if (socklist->first) {
|
||||
|
@ -199,10 +199,10 @@ void node_socket_init_default_value(bNodeSocket *sock)
|
|||
{
|
||||
int type = sock->typeinfo->type;
|
||||
int subtype = sock->typeinfo->subtype;
|
||||
|
||||
|
||||
if (sock->default_value)
|
||||
return; /* already initialized */
|
||||
|
||||
|
||||
switch (type) {
|
||||
case SOCK_FLOAT:
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
|
|||
dval->value = 0.0f;
|
||||
dval->min = -FLT_MAX;
|
||||
dval->max = FLT_MAX;
|
||||
|
||||
|
||||
sock->default_value = dval;
|
||||
break;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
|
|||
dval->value = 0;
|
||||
dval->min = INT_MIN;
|
||||
dval->max = INT_MAX;
|
||||
|
||||
|
||||
sock->default_value = dval;
|
||||
break;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
|
|||
{
|
||||
bNodeSocketValueBoolean *dval = MEM_callocN(sizeof(bNodeSocketValueBoolean), "node socket value bool");
|
||||
dval->value = false;
|
||||
|
||||
|
||||
sock->default_value = dval;
|
||||
break;
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
|
|||
copy_v3_v3(dval->value, default_value);
|
||||
dval->min = -FLT_MAX;
|
||||
dval->max = FLT_MAX;
|
||||
|
||||
|
||||
sock->default_value = dval;
|
||||
break;
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
|
|||
static float default_value[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
bNodeSocketValueRGBA *dval = MEM_callocN(sizeof(bNodeSocketValueRGBA), "node socket value color");
|
||||
copy_v4_v4(dval->value, default_value);
|
||||
|
||||
|
||||
sock->default_value = dval;
|
||||
break;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ void node_socket_init_default_value(bNodeSocket *sock)
|
|||
bNodeSocketValueString *dval = MEM_callocN(sizeof(bNodeSocketValueString), "node socket value string");
|
||||
dval->subtype = subtype;
|
||||
dval->value[0] = '\0';
|
||||
|
||||
|
||||
sock->default_value = dval;
|
||||
break;
|
||||
}
|
||||
|
@ -272,12 +272,12 @@ void node_socket_copy_default_value(bNodeSocket *to, bNodeSocket *from)
|
|||
/* sanity check */
|
||||
if (to->type != from->type)
|
||||
return;
|
||||
|
||||
|
||||
/* make sure both exist */
|
||||
if (!from->default_value)
|
||||
return;
|
||||
node_socket_init_default_value(to);
|
||||
|
||||
|
||||
switch (from->typeinfo->type) {
|
||||
case SOCK_FLOAT:
|
||||
{
|
||||
|
@ -330,7 +330,7 @@ static void standard_node_socket_interface_init_socket(bNodeTree *UNUSED(ntree),
|
|||
{
|
||||
/* initialize the type value */
|
||||
sock->type = sock->typeinfo->type;
|
||||
|
||||
|
||||
/* XXX socket interface 'type' value is not used really,
|
||||
* but has to match or the copy function will bail out
|
||||
*/
|
||||
|
@ -345,12 +345,12 @@ static void standard_node_socket_interface_verify_socket(bNodeTree *UNUSED(ntree
|
|||
/* sanity check */
|
||||
if (sock->type != stemp->typeinfo->type)
|
||||
return;
|
||||
|
||||
|
||||
/* make sure both exist */
|
||||
if (!stemp->default_value)
|
||||
return;
|
||||
node_socket_init_default_value(sock);
|
||||
|
||||
|
||||
switch (stemp->typeinfo->type) {
|
||||
case SOCK_FLOAT:
|
||||
{
|
||||
|
@ -389,65 +389,65 @@ static void standard_node_socket_interface_from_socket(bNodeTree *UNUSED(ntree),
|
|||
static bNodeSocketType *make_standard_socket_type(int type, int subtype)
|
||||
{
|
||||
extern void ED_init_standard_node_socket_type(bNodeSocketType *);
|
||||
|
||||
|
||||
const char *socket_idname = nodeStaticSocketType(type, subtype);
|
||||
const char *interface_idname = nodeStaticSocketInterfaceType(type, subtype);
|
||||
bNodeSocketType *stype;
|
||||
StructRNA *srna;
|
||||
|
||||
|
||||
stype = MEM_callocN(sizeof(bNodeSocketType), "node socket C type");
|
||||
BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname));
|
||||
|
||||
|
||||
/* set the RNA type
|
||||
* uses the exact same identifier as the socket type idname */
|
||||
srna = stype->ext_socket.srna = RNA_struct_find(socket_idname);
|
||||
BLI_assert(srna != NULL);
|
||||
/* associate the RNA type with the socket type */
|
||||
RNA_struct_blender_type_set(srna, stype);
|
||||
|
||||
|
||||
/* set the interface RNA type */
|
||||
srna = stype->ext_interface.srna = RNA_struct_find(interface_idname);
|
||||
BLI_assert(srna != NULL);
|
||||
/* associate the RNA type with the socket type */
|
||||
RNA_struct_blender_type_set(srna, stype);
|
||||
|
||||
|
||||
/* extra type info for standard socket types */
|
||||
stype->type = type;
|
||||
stype->subtype = subtype;
|
||||
|
||||
|
||||
/* XXX bad-level call! needed for setting draw callbacks */
|
||||
ED_init_standard_node_socket_type(stype);
|
||||
|
||||
|
||||
stype->interface_init_socket = standard_node_socket_interface_init_socket;
|
||||
stype->interface_from_socket = standard_node_socket_interface_from_socket;
|
||||
stype->interface_verify_socket = standard_node_socket_interface_verify_socket;
|
||||
|
||||
|
||||
return stype;
|
||||
}
|
||||
|
||||
static bNodeSocketType *make_socket_type_virtual(void)
|
||||
{
|
||||
extern void ED_init_node_socket_type_virtual(bNodeSocketType *);
|
||||
|
||||
|
||||
const char *socket_idname = "NodeSocketVirtual";
|
||||
bNodeSocketType *stype;
|
||||
StructRNA *srna;
|
||||
|
||||
|
||||
stype = MEM_callocN(sizeof(bNodeSocketType), "node socket C type");
|
||||
BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname));
|
||||
|
||||
|
||||
/* set the RNA type
|
||||
* uses the exact same identifier as the socket type idname */
|
||||
srna = stype->ext_socket.srna = RNA_struct_find(socket_idname);
|
||||
BLI_assert(srna != NULL);
|
||||
/* associate the RNA type with the socket type */
|
||||
RNA_struct_blender_type_set(srna, stype);
|
||||
|
||||
|
||||
/* extra type info for standard socket types */
|
||||
stype->type = SOCK_CUSTOM;
|
||||
|
||||
|
||||
ED_init_node_socket_type_virtual(stype);
|
||||
|
||||
|
||||
return stype;
|
||||
}
|
||||
|
||||
|
@ -455,21 +455,21 @@ static bNodeSocketType *make_socket_type_virtual(void)
|
|||
void register_standard_node_socket_types(void)
|
||||
{
|
||||
/* draw callbacks are set in drawnode.c to avoid bad-level calls */
|
||||
|
||||
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_NONE));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_UNSIGNED));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_PERCENTAGE));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_FACTOR));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_ANGLE));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_FLOAT, PROP_TIME));
|
||||
|
||||
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_NONE));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_UNSIGNED));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_PERCENTAGE));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_INT, PROP_FACTOR));
|
||||
|
||||
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_BOOLEAN, PROP_NONE));
|
||||
|
||||
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_NONE));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_TRANSLATION));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_DIRECTION));
|
||||
|
@ -477,12 +477,12 @@ void register_standard_node_socket_types(void)
|
|||
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_ACCELERATION));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_EULER));
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_VECTOR, PROP_XYZ));
|
||||
|
||||
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_RGBA, PROP_NONE));
|
||||
|
||||
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_STRING, PROP_NONE));
|
||||
|
||||
|
||||
nodeRegisterSocketType(make_standard_socket_type(SOCK_SHADER, PROP_NONE));
|
||||
|
||||
|
||||
nodeRegisterSocketType(make_socket_type_virtual());
|
||||
}
|
||||
|
|
|
@ -165,10 +165,10 @@ static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
|
|||
static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNodeSocket *cur)
|
||||
{
|
||||
/* link swapping: try to find a free slot with a matching name */
|
||||
|
||||
|
||||
bNodeSocket *first = cur->in_out == SOCK_IN ? node->inputs.first : node->outputs.first;
|
||||
bNodeSocket *sock;
|
||||
|
||||
|
||||
sock = cur->next ? cur->next : first; /* wrap around the list end */
|
||||
while (sock != cur) {
|
||||
if (!nodeSocketIsHidden(sock) && node_link_socket_match(sock, cur)) {
|
||||
|
@ -177,7 +177,7 @@ static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNo
|
|||
if (link_count + 1 <= sock->limit)
|
||||
return sock; /* found a valid free socket we can swap to */
|
||||
}
|
||||
|
||||
|
||||
sock = sock->next ? sock->next : first; /* wrap around the list end */
|
||||
}
|
||||
return NULL;
|
||||
|
@ -187,18 +187,18 @@ void node_insert_link_default(bNodeTree *ntree, bNode *node, bNodeLink *link)
|
|||
{
|
||||
bNodeSocket *sock = link->tosock;
|
||||
bNodeLink *tlink, *tlink_next;
|
||||
|
||||
|
||||
/* inputs can have one link only, outputs can have unlimited links */
|
||||
if (node != link->tonode)
|
||||
return;
|
||||
|
||||
|
||||
for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
|
||||
bNodeSocket *new_sock;
|
||||
tlink_next = tlink->next;
|
||||
|
||||
|
||||
if (sock != tlink->tosock)
|
||||
continue;
|
||||
|
||||
|
||||
new_sock = node_find_linkable_socket(ntree, node, sock);
|
||||
if (new_sock && new_sock != sock) {
|
||||
/* redirect existing link */
|
||||
|
@ -287,12 +287,12 @@ static bNodeSocket *select_internal_link_input(bNode *node, bNodeSocket *output)
|
|||
int i;
|
||||
int sel_priority = -1;
|
||||
bool sel_is_linked = false;
|
||||
|
||||
|
||||
for (input = node->inputs.first, i = 0; input; input = input->next, ++i) {
|
||||
int priority = node_datatype_priority(input->type, output->type);
|
||||
bool is_linked = (input->link != NULL);
|
||||
bool preferred;
|
||||
|
||||
|
||||
if (nodeSocketIsHidden(input) || /* ignore hidden sockets */
|
||||
input->flag & SOCK_NO_INTERNAL_LINK || /* ignore if input is not allowed for internal connections */
|
||||
priority < 0 || /* ignore incompatible types */
|
||||
|
@ -300,18 +300,18 @@ static bNodeSocket *select_internal_link_input(bNode *node, bNodeSocket *output)
|
|||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* determine if this input is preferred over the currently selected */
|
||||
preferred = (priority > sel_priority) || /* prefer higher datatype priority */
|
||||
(is_linked && !sel_is_linked); /* prefer linked over unlinked */
|
||||
|
||||
|
||||
if (preferred) {
|
||||
selected = input;
|
||||
sel_is_linked = is_linked;
|
||||
sel_priority = priority;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
|
@ -319,29 +319,29 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
|
|||
{
|
||||
bNodeLink *link;
|
||||
bNodeSocket *output, *input;
|
||||
|
||||
|
||||
/* sanity check */
|
||||
if (!ntree)
|
||||
return;
|
||||
|
||||
|
||||
/* use link pointer as a tag for handled sockets (for outputs is unused anyway) */
|
||||
for (output = node->outputs.first; output; output = output->next)
|
||||
output->link = NULL;
|
||||
|
||||
|
||||
for (link = ntree->links.first; link; link = link->next) {
|
||||
if (nodeLinkIsHidden(link))
|
||||
continue;
|
||||
|
||||
|
||||
output = link->fromsock;
|
||||
if (link->fromnode != node || output->link)
|
||||
continue;
|
||||
if (nodeSocketIsHidden(output) || output->flag & SOCK_NO_INTERNAL_LINK)
|
||||
continue;
|
||||
output->link = link; /* not really used, just for tagging handled sockets */
|
||||
|
||||
|
||||
/* look for suitable input */
|
||||
input = select_internal_link_input(node, output);
|
||||
|
||||
|
||||
if (input) {
|
||||
bNodeLink *ilink = MEM_callocN(sizeof(bNodeLink), "internal node link");
|
||||
ilink->fromnode = node;
|
||||
|
@ -353,7 +353,7 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
|
|||
BLI_addtail(&node->internal_links, ilink);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* clean up */
|
||||
for (output = node->outputs.first; output; output = output->next)
|
||||
output->link = NULL;
|
||||
|
|
|
@ -80,7 +80,7 @@ static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(tre
|
|||
SpaceNode *snode = CTX_wm_space_node(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = OBACT;
|
||||
|
||||
|
||||
if ((snode->shaderfrom == SNODE_SHADER_OBJECT) ||
|
||||
(BKE_scene_use_new_shading_nodes(scene) == false))
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback f
|
|||
func(calldata, NODE_CLASS_SHADER, N_("Shader"));
|
||||
func(calldata, NODE_CLASS_TEXTURE, N_("Texture"));
|
||||
}
|
||||
|
||||
|
||||
func(calldata, NODE_CLASS_OP_COLOR, N_("Color"));
|
||||
func(calldata, NODE_CLASS_OP_VECTOR, N_("Vector"));
|
||||
func(calldata, NODE_CLASS_CONVERTOR, N_("Convertor"));
|
||||
|
@ -140,11 +140,11 @@ static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback f
|
|||
static void localize(bNodeTree *localtree, bNodeTree *UNUSED(ntree))
|
||||
{
|
||||
bNode *node, *node_next;
|
||||
|
||||
|
||||
/* replace muted nodes and reroute nodes by internal links */
|
||||
for (node = localtree->nodes.first; node; node = node_next) {
|
||||
node_next = node->next;
|
||||
|
||||
|
||||
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
|
||||
nodeInternalRelink(localtree, node);
|
||||
nodeFreeNode(localtree, node);
|
||||
|
@ -165,9 +165,9 @@ static void local_merge(bNodeTree *localtree, bNodeTree *ntree)
|
|||
static void update(bNodeTree *ntree)
|
||||
{
|
||||
ntreeSetOutput(ntree);
|
||||
|
||||
|
||||
ntree_update_reroute_nodes(ntree);
|
||||
|
||||
|
||||
if (ntree->update & NTREE_UPDATE_NODES) {
|
||||
/* clean up preview cache, in case nodes have been removed */
|
||||
BKE_node_preview_remove_unused(ntree);
|
||||
|
@ -179,13 +179,13 @@ bNodeTreeType *ntreeType_Shader;
|
|||
void register_node_tree_type_sh(void)
|
||||
{
|
||||
bNodeTreeType *tt = ntreeType_Shader = MEM_callocN(sizeof(bNodeTreeType), "shader node tree type");
|
||||
|
||||
|
||||
tt->type = NTREE_SHADER;
|
||||
strcpy(tt->idname, "ShaderNodeTree");
|
||||
strcpy(tt->ui_name, "Shader");
|
||||
tt->ui_icon = 0; /* defined in drawnode.c */
|
||||
strcpy(tt->ui_description, "Shader nodes");
|
||||
|
||||
|
||||
tt->foreach_nodeclass = foreach_nodeclass;
|
||||
tt->localize = localize;
|
||||
tt->local_sync = local_sync;
|
||||
|
@ -193,9 +193,9 @@ void register_node_tree_type_sh(void)
|
|||
tt->update = update;
|
||||
tt->poll = shader_tree_poll;
|
||||
tt->get_from_context = shader_get_from_context;
|
||||
|
||||
|
||||
tt->ext.srna = &RNA_ShaderNodeTree;
|
||||
|
||||
|
||||
ntreeTypeAdd(tt);
|
||||
}
|
||||
|
||||
|
@ -524,19 +524,19 @@ bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context, bNod
|
|||
{
|
||||
bNodeTreeExec *exec;
|
||||
bNode *node;
|
||||
|
||||
|
||||
/* ensures only a single output node is enabled */
|
||||
ntreeSetOutput(ntree);
|
||||
|
||||
|
||||
/* common base initialization */
|
||||
exec = ntree_exec_begin(context, ntree, parent_key);
|
||||
|
||||
|
||||
/* allocate the thread stack listbase array */
|
||||
exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
|
||||
|
||||
|
||||
for (node = exec->nodetree->nodes.first; node; node = node->next)
|
||||
node->need_exec = 1;
|
||||
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
|
@ -544,22 +544,22 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree)
|
|||
{
|
||||
bNodeExecContext context;
|
||||
bNodeTreeExec *exec;
|
||||
|
||||
|
||||
/* XXX hack: prevent exec data from being generated twice.
|
||||
* this should be handled by the renderer!
|
||||
*/
|
||||
if (ntree->execdata)
|
||||
return ntree->execdata;
|
||||
|
||||
|
||||
context.previews = ntree->previews;
|
||||
|
||||
|
||||
exec = ntreeShaderBeginExecTree_internal(&context, ntree, NODE_INSTANCE_KEY_BASE);
|
||||
|
||||
|
||||
/* XXX this should not be necessary, but is still used for cmp/sha/tex nodes,
|
||||
* which only store the ntree pointer. Should be fixed at some point!
|
||||
*/
|
||||
ntree->execdata = exec;
|
||||
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
|
@ -567,18 +567,18 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec)
|
|||
{
|
||||
bNodeThreadStack *nts;
|
||||
int a;
|
||||
|
||||
|
||||
if (exec->threadstack) {
|
||||
for (a = 0; a < BLENDER_MAX_THREADS; a++) {
|
||||
for (nts = exec->threadstack[a].first; nts; nts = nts->next)
|
||||
if (nts->stack) MEM_freeN(nts->stack);
|
||||
BLI_freelistN(&exec->threadstack[a]);
|
||||
}
|
||||
|
||||
|
||||
MEM_freeN(exec->threadstack);
|
||||
exec->threadstack = NULL;
|
||||
}
|
||||
|
||||
|
||||
ntree_exec_end(exec);
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ void ntreeShaderEndExecTree(bNodeTreeExec *exec)
|
|||
/* exec may get freed, so assign ntree */
|
||||
bNodeTree *ntree = exec->nodetree;
|
||||
ntreeShaderEndExecTree_internal(exec);
|
||||
|
||||
|
||||
/* XXX clear nodetree backpointer to exec data, same problem as noted in ntreeBeginExecTree */
|
||||
ntree->execdata = NULL;
|
||||
}
|
||||
|
@ -606,14 +606,14 @@ bool ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
|
|||
bNodeThreadStack *nts = NULL;
|
||||
bNodeTreeExec *exec = ntree->execdata;
|
||||
int compat;
|
||||
|
||||
|
||||
/* convert caller data to struct */
|
||||
scd.shi = shi;
|
||||
scd.shr = shr;
|
||||
|
||||
|
||||
/* each material node has own local shaderesult, with optional copying */
|
||||
memset(shr, 0, sizeof(ShadeResult));
|
||||
|
||||
|
||||
/* ensure execdata is only initialized once */
|
||||
if (!exec) {
|
||||
BLI_thread_lock(LOCK_NODES);
|
||||
|
@ -623,19 +623,19 @@ bool ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
|
|||
|
||||
exec = ntree->execdata;
|
||||
}
|
||||
|
||||
|
||||
nts = ntreeGetThreadStack(exec, shi->thread);
|
||||
compat = ntreeExecThreadNodes(exec, nts, &scd, shi->thread);
|
||||
ntreeReleaseThreadStack(nts);
|
||||
|
||||
|
||||
// \note: set material back to preserved material
|
||||
shi->mat = mat;
|
||||
|
||||
|
||||
/* better not allow negative for now */
|
||||
if (shr->combined[0] < 0.0f) shr->combined[0] = 0.0f;
|
||||
if (shr->combined[1] < 0.0f) shr->combined[1] = 0.0f;
|
||||
if (shr->combined[2] < 0.0f) shr->combined[2] = 0.0f;
|
||||
|
||||
|
||||
/* if compat is zero, it has been using non-compatible nodes */
|
||||
return compat;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ int sh_node_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree)
|
|||
void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
|
||||
{
|
||||
node_type_base(ntype, type, name, nclass, flag);
|
||||
|
||||
|
||||
ntype->poll = sh_node_poll_default;
|
||||
ntype->insert_link = node_insert_link_default;
|
||||
ntype->update_internal_links = node_update_internal_links_default;
|
||||
|
@ -56,11 +56,11 @@ void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, shor
|
|||
void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
|
||||
{
|
||||
const float *from = ns->vec;
|
||||
|
||||
|
||||
if (type_in == SOCK_FLOAT) {
|
||||
if (ns->sockettype == SOCK_FLOAT)
|
||||
*in = *from;
|
||||
else
|
||||
else
|
||||
*in = (from[0] + from[1] + from[2]) / 3.0f;
|
||||
}
|
||||
else if (type_in == SOCK_VECTOR) {
|
||||
|
@ -98,7 +98,7 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo
|
|||
bNode *node;
|
||||
bNodeSocket *sock;
|
||||
int a;
|
||||
|
||||
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->type == SH_NODE_TEXTURE) {
|
||||
if ((r_mode & R_OSA) && node->id) {
|
||||
|
@ -117,15 +117,15 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo
|
|||
for (a = 0, sock = node->outputs.first; sock; sock = sock->next, a++) {
|
||||
if (sock->flag & SOCK_IN_USE) {
|
||||
switch (a) {
|
||||
case GEOM_OUT_GLOB:
|
||||
case GEOM_OUT_GLOB:
|
||||
*texco |= TEXCO_GLOB | NEED_UV; break;
|
||||
case GEOM_OUT_VIEW:
|
||||
case GEOM_OUT_VIEW:
|
||||
*texco |= TEXCO_VIEW | NEED_UV; break;
|
||||
case GEOM_OUT_ORCO:
|
||||
case GEOM_OUT_ORCO:
|
||||
*texco |= TEXCO_ORCO | NEED_UV; break;
|
||||
case GEOM_OUT_UV:
|
||||
case GEOM_OUT_UV:
|
||||
*texco |= TEXCO_UV | NEED_UV; break;
|
||||
case GEOM_OUT_NORMAL:
|
||||
case GEOM_OUT_NORMAL:
|
||||
*texco |= TEXCO_NORM | NEED_UV; break;
|
||||
case GEOM_OUT_VCOL:
|
||||
*texco |= NEED_UV; *mode |= MA_VERTEXCOL; break;
|
||||
|
@ -141,7 +141,7 @@ void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mo
|
|||
void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
|
||||
{
|
||||
memset(gs, 0, sizeof(*gs));
|
||||
|
||||
|
||||
if (ns == NULL) {
|
||||
/* node_get_stack() will generate NULL bNodeStack pointers for unknown/unsuported types of sockets... */
|
||||
zero_v4(gs->vec);
|
||||
|
@ -155,7 +155,7 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
|
|||
else {
|
||||
nodestack_get_vec(gs->vec, type, ns);
|
||||
gs->link = ns->data;
|
||||
|
||||
|
||||
if (type == SOCK_FLOAT)
|
||||
gs->type = GPU_FLOAT;
|
||||
else if (type == SOCK_VECTOR)
|
||||
|
@ -189,10 +189,10 @@ static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeS
|
|||
{
|
||||
bNodeSocket *sock;
|
||||
int i;
|
||||
|
||||
|
||||
for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
|
||||
node_gpu_stack_from_data(&gs[i], sock->type, ns[i]);
|
||||
|
||||
|
||||
gs[i].type = GPU_NONE;
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
|
|||
|
||||
if (activetexnode)
|
||||
return activetexnode;
|
||||
|
||||
|
||||
if (hasgroup) {
|
||||
/* node active texture node in this tree, look inside groups */
|
||||
for (node = ntree->nodes.first; node; node = node->next) {
|
||||
|
@ -252,7 +252,7 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return inactivenode;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, int do_outputs, sh
|
|||
|
||||
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
|
||||
node = nodeexec->node;
|
||||
|
||||
|
||||
do_it = false;
|
||||
/* for groups, only execute outputs for edited group */
|
||||
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
|
||||
|
|
|
@ -50,13 +50,13 @@ static int gpu_shader_brightcontrast(GPUMaterial *mat, bNode *UNUSED(node), bNod
|
|||
void register_node_type_sh_brightcontrast(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
|
||||
node_type_compatibility(&ntype, NODE_NEW_SHADING);
|
||||
node_type_socket_templates(&ntype, sh_node_brightcontrast_in, sh_node_brightcontrast_out);
|
||||
node_type_init(&ntype, NULL);
|
||||
node_type_storage(&ntype, "", NULL, NULL);
|
||||
node_type_gpu(&ntype, gpu_shader_brightcontrast);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "node_shader_util.h"
|
||||
|
||||
/* **************** BUMP ******************** */
|
||||
/* **************** BUMP ******************** */
|
||||
static bNodeSocketTemplate sh_node_bump_in[] = {
|
||||
{ SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
|
||||
{ SOCK_FLOAT, 1, N_("Distance"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f},
|
||||
|
|
|
@ -45,7 +45,7 @@ static void node_shader_exec_camera(void *data, int UNUSED(thread), bNode *UNUSE
|
|||
{
|
||||
if (data) {
|
||||
ShadeInput *shi = ((ShaderCallData *)data)->shi; /* Data we need for shading. */
|
||||
|
||||
|
||||
copy_v3_v3(out[0]->vec, shi->co); /* get view vector */
|
||||
out[1]->vec[0] = fabsf(shi->co[2]); /* get view z-depth */
|
||||
out[2]->vec[0] = normalize_v3(out[0]->vec); /* get view distance */
|
||||
|
|
|
@ -50,7 +50,7 @@ static void copy_stack(bNodeStack *to, bNodeStack *from)
|
|||
copy_v4_v4(to->vec, from->vec);
|
||||
to->data = from->data;
|
||||
to->datatype = from->datatype;
|
||||
|
||||
|
||||
/* tag as copy to prevent freeing */
|
||||
to->is_copy = 1;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ static void move_stack(bNodeStack *to, bNodeStack *from)
|
|||
to->data = from->data;
|
||||
to->datatype = from->datatype;
|
||||
to->is_copy = from->is_copy;
|
||||
|
||||
|
||||
from->data = NULL;
|
||||
from->is_copy = 0;
|
||||
}
|
||||
|
@ -75,20 +75,20 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
|
|||
{
|
||||
bNodeTree *ngroup = (bNodeTree *)node->id;
|
||||
bNodeTreeExec *exec;
|
||||
|
||||
|
||||
if (!ngroup)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* initialize the internal node tree execution */
|
||||
exec = ntreeShaderBeginExecTree_internal(context, ngroup, key);
|
||||
|
||||
|
||||
return exec;
|
||||
}
|
||||
|
||||
static void group_freeexec(void *nodedata)
|
||||
{
|
||||
bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
|
||||
|
||||
|
||||
if (gexec)
|
||||
ntreeShaderEndExecTree_internal(gexec);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack)
|
|||
bNodeSocket *sock;
|
||||
bNodeStack *ns;
|
||||
int a;
|
||||
|
||||
|
||||
for (node = ngroup->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_GROUP_INPUT) {
|
||||
for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
|
||||
|
@ -123,7 +123,7 @@ static void group_move_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstac
|
|||
bNodeSocket *sock;
|
||||
bNodeStack *ns;
|
||||
int a;
|
||||
|
||||
|
||||
for (node = ngroup->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
|
||||
for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
|
||||
|
@ -140,10 +140,10 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD
|
|||
{
|
||||
bNodeTreeExec *exec = execdata->data;
|
||||
bNodeThreadStack *nts;
|
||||
|
||||
|
||||
if (!exec)
|
||||
return;
|
||||
|
||||
|
||||
/* XXX same behavior as trunk: all nodes inside group are executed.
|
||||
* it's stupid, but just makes it work. compo redesign will do this better.
|
||||
*/
|
||||
|
@ -152,13 +152,13 @@ static void group_execute(void *data, int thread, struct bNode *node, bNodeExecD
|
|||
for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
|
||||
inode->need_exec = 1;
|
||||
}
|
||||
|
||||
|
||||
nts = ntreeGetThreadStack(exec, thread);
|
||||
|
||||
|
||||
group_copy_inputs(node, in, nts->stack);
|
||||
ntreeExecThreadNodes(exec, nts, data, thread);
|
||||
group_move_outputs(node, out, nts->stack);
|
||||
|
||||
|
||||
ntreeReleaseThreadStack(nts);
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ static void group_gpu_copy_inputs(bNode *gnode, GPUNodeStack *in, bNodeStack *gs
|
|||
bNodeSocket *sock;
|
||||
bNodeStack *ns;
|
||||
int a;
|
||||
|
||||
|
||||
for (node = ngroup->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_GROUP_INPUT) {
|
||||
for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
|
||||
|
@ -192,7 +192,7 @@ static void group_gpu_move_outputs(bNode *gnode, GPUNodeStack *out, bNodeStack *
|
|||
bNodeSocket *sock;
|
||||
bNodeStack *ns;
|
||||
int a;
|
||||
|
||||
|
||||
for (node = ngroup->nodes.first; node; node = node->next) {
|
||||
if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
|
||||
for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
|
||||
|
@ -210,10 +210,10 @@ static void group_gpu_move_outputs(bNode *gnode, GPUNodeStack *out, bNodeStack *
|
|||
static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execdata, GPUNodeStack *in, GPUNodeStack *out)
|
||||
{
|
||||
bNodeTreeExec *exec = execdata->data;
|
||||
|
||||
|
||||
if (!node->id)
|
||||
return 0;
|
||||
|
||||
|
||||
group_gpu_copy_inputs(node, in, exec->stack);
|
||||
#if 0 /* XXX NODE_GROUP_EDIT is deprecated, depends on node space */
|
||||
ntreeExecGPUNodes(exec, mat, (node->flag & NODE_GROUP_EDIT));
|
||||
|
@ -221,14 +221,14 @@ static int gpu_group_execute(GPUMaterial *mat, bNode *node, bNodeExecData *execd
|
|||
ntreeExecGPUNodes(exec, mat, 0, NODE_NEW_SHADING | NODE_OLD_SHADING);
|
||||
#endif
|
||||
group_gpu_move_outputs(node, out, exec->stack);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void register_node_type_sh_group(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
/* NB: cannot use sh_node_type_base for node group, because it would map the node type
|
||||
* to the shared NODE_GROUP integer type id.
|
||||
*/
|
||||
|
@ -241,7 +241,7 @@ void register_node_type_sh_group(void)
|
|||
ntype.ext.srna = RNA_struct_find("ShaderNodeGroup");
|
||||
BLI_assert(ntype.ext.srna != NULL);
|
||||
RNA_struct_blender_type_set(ntype.ext.srna, &ntype);
|
||||
|
||||
|
||||
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
|
||||
node_type_socket_templates(&ntype, NULL, NULL);
|
||||
node_type_size(&ntype, 140, 60, 400);
|
||||
|
@ -249,6 +249,6 @@ void register_node_type_sh_group(void)
|
|||
node_type_update(&ntype, NULL, node_group_verify);
|
||||
node_type_exec(&ntype, group_initexec, group_freeexec, group_execute);
|
||||
node_type_gpu(&ntype, gpu_group_execute);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_curve_vec_out[] = {
|
|||
static void node_shader_exec_curve_vec(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
float vec[3];
|
||||
|
||||
|
||||
/* stack order input: vec */
|
||||
/* stack order output: vec */
|
||||
nodestack_get_vec(vec, SOCK_VECTOR, in[1]);
|
||||
|
@ -102,7 +102,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), int UNUSED(thread), b
|
|||
{
|
||||
float vec[3];
|
||||
float fac;
|
||||
|
||||
|
||||
/* stack order input: vec */
|
||||
/* stack order output: vec */
|
||||
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
|
||||
|
|
|
@ -47,7 +47,7 @@ static int node_shader_gpu_fresnel(GPUMaterial *mat, bNode *UNUSED(node), bNodeE
|
|||
else if (GPU_material_use_world_space_shading(mat)) {
|
||||
GPU_link(mat, "direction_transform_m4v3", in[1].link, GPU_builtin(GPU_VIEW_MATRIX), &in[1].link);
|
||||
}
|
||||
|
||||
|
||||
return GPU_stack_link(mat, "node_fresnel", in, out, GPU_builtin(GPU_VIEW_POSITION));
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ static int node_shader_gpu_gamma(GPUMaterial *mat, bNode *UNUSED(node), bNodeExe
|
|||
void register_node_type_sh_gamma(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
sh_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
|
||||
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
|
||||
node_type_socket_templates(&ntype, sh_node_gamma_in, sh_node_gamma_out);
|
||||
|
@ -68,6 +68,6 @@ void register_node_type_sh_gamma(void)
|
|||
node_type_storage(&ntype, "", NULL, NULL);
|
||||
node_type_exec(&ntype, NULL, NULL, node_shader_exec_gamma);
|
||||
node_type_gpu(&ntype, node_shader_gpu_gamma);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ static void node_shader_exec_geom(void *data, int UNUSED(thread), bNode *node, b
|
|||
memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol));
|
||||
out[GEOM_OUT_VCOL_ALPHA]->vec[0] = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
if (shi->osatex) {
|
||||
out[GEOM_OUT_GLOB]->data = shi->dxgl;
|
||||
out[GEOM_OUT_GLOB]->datatype = NS_OSA_VECTORS;
|
||||
|
@ -118,7 +118,7 @@ static void node_shader_exec_geom(void *data, int UNUSED(thread), bNode *node, b
|
|||
out[GEOM_OUT_NORMAL]->data = shi->dxno;
|
||||
out[GEOM_OUT_NORMAL]->datatype = NS_OSA_VECTORS;
|
||||
}
|
||||
|
||||
|
||||
/* front/back, normal flipping was stored */
|
||||
out[GEOM_OUT_FRONTBACK]->vec[0] = (shi->flippednor) ? 0.0f : 1.0f;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat
|
|||
{
|
||||
if (fac != 0.0f && (hue != 0.5f || sat != 1.0f || val != 1.0f)) {
|
||||
float col[3], hsv[3], mfac = 1.0f - fac;
|
||||
|
||||
|
||||
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2);
|
||||
hsv[0] += (hue - 0.5f);
|
||||
if (hsv[0] > 1.0f) hsv[0] -= 1.0f; else if (hsv[0] < 0.0f) hsv[0] += 1.0f;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
|
||||
|
||||
/* **************** INVERT ******************** */
|
||||
/* **************** INVERT ******************** */
|
||||
static bNodeSocketTemplate sh_node_invert_in[] = {
|
||||
{ SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
|
||||
{ SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
|
||||
|
@ -46,18 +46,18 @@ static bNodeSocketTemplate sh_node_invert_out[] = {
|
|||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static void node_shader_exec_invert(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in,
|
||||
static void node_shader_exec_invert(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in,
|
||||
bNodeStack **out)
|
||||
{
|
||||
float col[3], icol[3], fac;
|
||||
|
||||
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
|
||||
nodestack_get_vec(col, SOCK_VECTOR, in[1]);
|
||||
|
||||
|
||||
icol[0] = 1.0f - col[0];
|
||||
icol[1] = 1.0f - col[1];
|
||||
icol[2] = 1.0f - col[2];
|
||||
|
||||
|
||||
/* if fac, blend result against original input */
|
||||
if (fac < 1.0f)
|
||||
interp_v3_v3v3(out[0]->vec, col, icol, fac);
|
||||
|
|
|
@ -56,7 +56,7 @@ static void node_shader_exec_mapping(void *UNUSED(data), int UNUSED(thread), bNo
|
|||
{
|
||||
TexMapping *texmap = node->storage;
|
||||
float *vec = out[0]->vec;
|
||||
|
||||
|
||||
/* stack order input: vector */
|
||||
/* stack order output: vector */
|
||||
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
|
||||
|
@ -105,7 +105,7 @@ static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS
|
|||
void register_node_type_sh_mapping(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR, 0);
|
||||
node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING);
|
||||
node_type_socket_templates(&ntype, sh_node_mapping_in, sh_node_mapping_out);
|
||||
|
@ -114,6 +114,6 @@ void register_node_type_sh_mapping(void)
|
|||
node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage);
|
||||
node_type_exec(&ntype, node_shader_initexec_mapping, NULL, node_shader_exec_mapping);
|
||||
node_type_gpu(&ntype, gpu_shader_mapping);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
|
|||
bNodeSocket *sock;
|
||||
char hasinput[NUM_MAT_IN] = {'\0'};
|
||||
int i, mode;
|
||||
|
||||
|
||||
/* note: cannot use the in[]->hasinput flags directly, as these are not necessarily
|
||||
* the constant input stack values (e.g. in case material node is inside a group).
|
||||
* we just want to know if a node input uses external data or the material setting.
|
||||
|
@ -93,24 +93,24 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
|
|||
*/
|
||||
for (sock = node->inputs.first, i = 0; sock; sock = sock->next, ++i)
|
||||
hasinput[i] = (sock->link != NULL);
|
||||
|
||||
|
||||
shi = shcd->shi;
|
||||
shi->mat = (Material *)node->id;
|
||||
|
||||
|
||||
/* copy all relevant material vars, note, keep this synced with render_types.h */
|
||||
memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float));
|
||||
shi->har = shi->mat->har;
|
||||
|
||||
|
||||
/* write values */
|
||||
if (hasinput[MAT_IN_COLOR])
|
||||
nodestack_get_vec(&shi->r, SOCK_VECTOR, in[MAT_IN_COLOR]);
|
||||
|
||||
|
||||
if (hasinput[MAT_IN_SPEC])
|
||||
nodestack_get_vec(&shi->specr, SOCK_VECTOR, in[MAT_IN_SPEC]);
|
||||
|
||||
|
||||
if (hasinput[MAT_IN_REFL])
|
||||
nodestack_get_vec(&shi->refl, SOCK_FLOAT, in[MAT_IN_REFL]);
|
||||
|
||||
|
||||
/* retrieve normal */
|
||||
if (hasinput[MAT_IN_NORMAL]) {
|
||||
nodestack_get_vec(shi->vn, SOCK_VECTOR, in[MAT_IN_NORMAL]);
|
||||
|
@ -122,12 +122,12 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
|
|||
}
|
||||
else
|
||||
copy_v3_v3(shi->vn, shi->vno);
|
||||
|
||||
|
||||
/* custom option to flip normal */
|
||||
if (node->custom1 & SH_NODE_MAT_NEG) {
|
||||
negate_v3(shi->vn);
|
||||
}
|
||||
|
||||
|
||||
if (node->type == SH_NODE_MATERIAL_EXT) {
|
||||
if (hasinput[MAT_IN_MIR])
|
||||
nodestack_get_vec(&shi->mirr, SOCK_VECTOR, in[MAT_IN_MIR]);
|
||||
|
@ -144,7 +144,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
|
|||
if (hasinput[MAT_IN_TRANSLUCENCY])
|
||||
nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]);
|
||||
}
|
||||
|
||||
|
||||
/* make alpha output give results even if transparency is only enabled on
|
||||
* the material linked in this not and not on the parent material */
|
||||
mode = shi->mode;
|
||||
|
@ -154,7 +154,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
|
|||
shi->nodes = 1; /* temp hack to prevent trashadow recursion */
|
||||
node_shader_lamp_loop(shi, &shrnode); /* clears shrnode */
|
||||
shi->nodes = 0;
|
||||
|
||||
|
||||
shi->mode = mode;
|
||||
|
||||
/* write to outputs */
|
||||
|
@ -169,21 +169,21 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
|
|||
}
|
||||
else
|
||||
col[0] = col[1] = col[2] = 0.0f;
|
||||
|
||||
|
||||
col[3] = shrnode.alpha;
|
||||
|
||||
|
||||
if (shi->do_preview)
|
||||
BKE_node_preview_set_pixel(execdata->preview, col, shi->xs, shi->ys, shi->do_manage);
|
||||
|
||||
|
||||
copy_v3_v3(out[MAT_OUT_COLOR]->vec, col);
|
||||
out[MAT_OUT_ALPHA]->vec[0] = shrnode.alpha;
|
||||
|
||||
|
||||
if (node->custom1 & SH_NODE_MAT_NEG) {
|
||||
shi->vn[0] = -shi->vn[0];
|
||||
shi->vn[1] = -shi->vn[1];
|
||||
shi->vn[2] = -shi->vn[2];
|
||||
}
|
||||
|
||||
|
||||
copy_v3_v3(out[MAT_OUT_NORMAL]->vec, shi->vn);
|
||||
|
||||
if (shi->use_world_space_shading) {
|
||||
|
@ -198,7 +198,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
|
|||
copy_v3_v3(out[MAT_OUT_SPEC]->vec, shrnode.spec);
|
||||
copy_v3_v3(out[MAT_OUT_AO]->vec, shrnode.ao);
|
||||
}
|
||||
|
||||
|
||||
/* copy passes, now just active node */
|
||||
if (node->flag & NODE_ACTIVE_ID) {
|
||||
float combined[4], alpha;
|
||||
|
@ -254,7 +254,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
|
|||
bNodeSocket *sock;
|
||||
char hasinput[NUM_MAT_IN] = {'\0'};
|
||||
int i;
|
||||
|
||||
|
||||
/* note: cannot use the in[]->hasinput flags directly, as these are not necessarily
|
||||
* the constant input stack values (e.g. in case material node is inside a group).
|
||||
* we just want to know if a node input uses external data or the material setting.
|
||||
|
@ -267,13 +267,13 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
|
|||
/* write values */
|
||||
if (hasinput[MAT_IN_COLOR])
|
||||
shi.rgb = gpu_get_input_link(mat, &in[MAT_IN_COLOR]);
|
||||
|
||||
|
||||
if (hasinput[MAT_IN_SPEC])
|
||||
shi.specrgb = gpu_get_input_link(mat, &in[MAT_IN_SPEC]);
|
||||
|
||||
|
||||
if (hasinput[MAT_IN_REFL])
|
||||
shi.refl = gpu_get_input_link(mat, &in[MAT_IN_REFL]);
|
||||
|
||||
|
||||
/* retrieve normal */
|
||||
if (hasinput[MAT_IN_NORMAL]) {
|
||||
GPUNodeLink *tmp;
|
||||
|
@ -284,7 +284,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
|
|||
}
|
||||
GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn, &tmp);
|
||||
}
|
||||
|
||||
|
||||
/* custom option to flip normal */
|
||||
if (node->custom1 & SH_NODE_MAT_NEG)
|
||||
GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
|
||||
|
@ -303,7 +303,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
|
|||
}
|
||||
|
||||
GPU_shaderesult_set(&shi, &shr); /* clears shr */
|
||||
|
||||
|
||||
/* write to outputs */
|
||||
if (node->custom1 & SH_NODE_MAT_DIFF) {
|
||||
out[MAT_OUT_COLOR].link = shr.combined;
|
||||
|
@ -322,7 +322,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, bNodeExecData *UNU
|
|||
GPU_link(mat, "mtex_alpha_to_col", out[MAT_OUT_COLOR].link, shr.alpha, &out[MAT_OUT_COLOR].link);
|
||||
|
||||
out[MAT_OUT_ALPHA].link = shr.alpha; //
|
||||
|
||||
|
||||
if (node->custom1 & SH_NODE_MAT_NEG)
|
||||
GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
|
||||
out[MAT_OUT_NORMAL].link = shi.vn;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "node_shader_util.h"
|
||||
|
||||
|
||||
/* **************** SCALAR MATH ******************** */
|
||||
/* **************** SCALAR MATH ******************** */
|
||||
static bNodeSocketTemplate sh_node_math_in[] = {
|
||||
{ SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
|
||||
{ SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE},
|
||||
|
@ -45,15 +45,15 @@ static bNodeSocketTemplate sh_node_math_out[] = {
|
|||
{ -1, 0, "" }
|
||||
};
|
||||
|
||||
static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
|
||||
static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
float a, b, r = 0.0f;
|
||||
|
||||
|
||||
nodestack_get_vec(&a, SOCK_FLOAT, in[0]);
|
||||
nodestack_get_vec(&b, SOCK_FLOAT, in[1]);
|
||||
|
||||
|
||||
switch (node->custom1) {
|
||||
|
||||
|
||||
case NODE_MATH_ADD:
|
||||
r = a + b;
|
||||
break;
|
||||
|
@ -147,7 +147,7 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode
|
|||
}
|
||||
else {
|
||||
float y_mod_1 = fabsf(fmodf(b, 1.0f));
|
||||
|
||||
|
||||
/* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */
|
||||
if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) {
|
||||
r = powf(a, floorf(b + 0.5f));
|
||||
|
|
|
@ -54,7 +54,7 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), int UNUSED(thread), bNo
|
|||
|
||||
nodestack_get_vec(&fac, SOCK_FLOAT, in[0]);
|
||||
CLAMP(fac, 0.0f, 1.0f);
|
||||
|
||||
|
||||
nodestack_get_vec(col, SOCK_VECTOR, in[1]);
|
||||
nodestack_get_vec(vec, SOCK_VECTOR, in[2]);
|
||||
|
||||
|
|
|
@ -48,12 +48,12 @@ static bNodeSocketTemplate sh_node_normal_out[] = {
|
|||
static void node_shader_exec_normal(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
float vec[3];
|
||||
|
||||
|
||||
/* stack order input: normal */
|
||||
/* stack order output: normal, value */
|
||||
|
||||
|
||||
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
|
||||
|
||||
|
||||
/* render normals point inside... the widget points outside */
|
||||
out[1]->vec[0] = -dot_v3v3(vec, out[0]->vec);
|
||||
}
|
||||
|
@ -72,12 +72,12 @@ static int gpu_shader_normal(GPUMaterial *mat, bNode *UNUSED(node), bNodeExecDat
|
|||
void register_node_type_sh_normal(void)
|
||||
{
|
||||
static bNodeType ntype;
|
||||
|
||||
|
||||
sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR, 0);
|
||||
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_exec(&ntype, NULL, NULL, node_shader_exec_normal);
|
||||
node_type_gpu(&ntype, gpu_shader_normal);
|
||||
|
||||
|
||||
nodeRegisterType(&ntype);
|
||||
}
|
||||
|
|
|
@ -44,22 +44,22 @@ static void node_shader_exec_output(void *data, int UNUSED(thread), bNode *node,
|
|||
if (data) {
|
||||
ShadeInput *shi = ((ShaderCallData *)data)->shi;
|
||||
float col[4];
|
||||
|
||||
|
||||
/* stack order input sockets: col, alpha, normal */
|
||||
nodestack_get_vec(col, SOCK_VECTOR, in[0]);
|
||||
nodestack_get_vec(col + 3, SOCK_FLOAT, in[1]);
|
||||
|
||||
|
||||
if (shi->do_preview) {
|
||||
BKE_node_preview_set_pixel(execdata->preview, col, shi->xs, shi->ys, shi->do_manage);
|
||||
node->lasty = shi->ys;
|
||||
}
|
||||
|
||||
|
||||
if (node->flag & NODE_DO_OUTPUT) {
|
||||
ShadeResult *shr = ((ShaderCallData *)data)->shr;
|
||||
|
||||
|
||||
copy_v4_v4(shr->combined, col);
|
||||
shr->alpha = col[3];
|
||||
|
||||
|
||||
// copy_v3_v3(shr->nor, in[3]->vec);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ void register_node_type_sh_output_world(void)
|
|||
node_type_init(&ntype, NULL);
|
||||
node_type_storage(&ntype, "", NULL, NULL);
|
||||
node_type_gpu(&ntype, node_shader_gpu_output_world);
|
||||
|
||||
|
||||
/* Do not allow muting output node. */
|
||||
node_type_internal_links(&ntype, NULL);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static void node_shader_exec_sephsv(void *UNUSED(data), int UNUSED(thread), bNod
|
|||
{
|
||||
float col[3];
|
||||
nodestack_get_vec(col, SOCK_VECTOR, in[0]);
|
||||
|
||||
|
||||
rgb_to_hsv(col[0], col[1], col[2],
|
||||
&out[0]->vec[0], &out[1]->vec[0], &out[2]->vec[0]);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ static void node_shader_exec_combhsv(void *UNUSED(data), int UNUSED(thread), bNo
|
|||
nodestack_get_vec(&h, SOCK_FLOAT, in[0]);
|
||||
nodestack_get_vec(&s, SOCK_FLOAT, in[1]);
|
||||
nodestack_get_vec(&v, SOCK_FLOAT, in[2]);
|
||||
|
||||
|
||||
hsv_to_rgb(h, s, v, &out[0]->vec[0], &out[0]->vec[1], &out[0]->vec[2]);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ static void node_shader_exec_seprgb(void *UNUSED(data), int UNUSED(thread), bNod
|
|||
{
|
||||
float col[3];
|
||||
nodestack_get_vec(col, SOCK_VECTOR, in[0]);
|
||||
|
||||
|
||||
out[0]->vec[0] = col[0];
|
||||
out[1]->vec[0] = col[1];
|
||||
out[2]->vec[0] = col[2];
|
||||
|
@ -92,7 +92,7 @@ static void node_shader_exec_combrgb(void *UNUSED(data), int UNUSED(thread), bNo
|
|||
nodestack_get_vec(&r, SOCK_FLOAT, in[0]);
|
||||
nodestack_get_vec(&g, SOCK_FLOAT, in[1]);
|
||||
nodestack_get_vec(&b, SOCK_FLOAT, in[2]);
|
||||
|
||||
|
||||
out[0]->vec[0] = r;
|
||||
out[0]->vec[1] = g;
|
||||
out[0]->vec[2] = b;
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "node_shader_util.h"
|
||||
|
||||
/* **************** VALUE SQUEEZE ******************** */
|
||||
/* **************** VALUE SQUEEZE ******************** */
|
||||
static bNodeSocketTemplate sh_node_squeeze_in[] = {
|
||||
{ SOCK_FLOAT, 1, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
|
||||
{ SOCK_FLOAT, 1, N_("Width"), 1.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
|
||||
|
@ -48,7 +48,7 @@ static bNodeSocketTemplate sh_node_squeeze_out[] = {
|
|||
static void node_shader_exec_squeeze(void *UNUSED(data), int UNUSED(thread), bNode *UNUSED(node), bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out)
|
||||
{
|
||||
float vec[3];
|
||||
|
||||
|
||||
nodestack_get_vec(vec, SOCK_FLOAT, in[0]);
|
||||
nodestack_get_vec(vec + 1, SOCK_FLOAT, in[1]);
|
||||
nodestack_get_vec(vec + 2, SOCK_FLOAT, in[2]);
|
||||
|
|
|
@ -54,7 +54,7 @@ static void node_shader_init_tex_brick(bNodeTree *UNUSED(ntree), bNode *node)
|
|||
NodeTexBrick *tex = MEM_callocN(sizeof(NodeTexBrick), "NodeTexBrick");
|
||||
BKE_texture_mapping_default(&tex->base.tex_mapping, TEXMAP_TYPE_POINT);
|
||||
BKE_texture_colormapping_default(&tex->base.color_mapping);
|
||||
|
||||
|
||||
tex->offset = 0.5f;
|
||||
tex->squash = 1.0f;
|
||||
tex->offset_freq = 2;
|
||||
|
|
|
@ -47,7 +47,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *UNUSED(node), bNod
|
|||
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
|
||||
GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, "");
|
||||
GPUMatType type = GPU_Material_get_type(mat);
|
||||
|
||||
|
||||
if (type == GPU_MATERIAL_TYPE_MESH) {
|
||||
return GPU_stack_link(mat, "node_tex_coord", in, out,
|
||||
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
|
||||
|
@ -57,7 +57,7 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat, bNode *UNUSED(node), bNod
|
|||
else {
|
||||
return GPU_stack_link(mat, "node_tex_coord_background", in, out,
|
||||
GPU_builtin(GPU_VIEW_POSITION), GPU_builtin(GPU_VIEW_NORMAL),
|
||||
GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
|
||||
GPU_builtin(GPU_INVERSE_VIEW_MATRIX), GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
|
||||
GPU_builtin(GPU_CAMERA_TEXCO_FACTORS), orco, mtface);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,20 +66,20 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, bNodeE
|
|||
|
||||
if (!in[0].link) {
|
||||
GPUMatType type = GPU_Material_get_type(mat);
|
||||
|
||||
|
||||
if (type == GPU_MATERIAL_TYPE_MESH)
|
||||
in[0].link = GPU_builtin(GPU_VIEW_POSITION);
|
||||
else
|
||||
GPU_link(mat, "background_transform_to_world", GPU_builtin(GPU_VIEW_POSITION), &in[0].link);
|
||||
}
|
||||
|
||||
|
||||
node_shader_gpu_tex_mapping(mat, node, in, out);
|
||||
|
||||
if (tex->projection == SHD_PROJ_EQUIRECTANGULAR)
|
||||
GPU_stack_link(mat, "node_tex_environment_equirectangular", in, out, GPU_image(ima, iuser, isdata));
|
||||
else
|
||||
GPU_stack_link(mat, "node_tex_environment_mirror_ball", in, out, GPU_image(ima, iuser, isdata));
|
||||
|
||||
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
|
||||
if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 &&
|
||||
GPU_material_do_color_management(mat))
|
||||
|
|
|
@ -56,19 +56,19 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node
|
|||
float vec[3], nor[3] = {0.0f, 0.0f, 0.0f};
|
||||
int retval;
|
||||
short which_output = node->custom1;
|
||||
|
||||
|
||||
short thread = shi->thread;
|
||||
|
||||
|
||||
/* out: value, color, normal */
|
||||
|
||||
|
||||
/* we should find out if a normal as output is needed, for now we do all */
|
||||
texres.nor = nor;
|
||||
texres.tr = texres.tg = texres.tb = 0.0f;
|
||||
|
||||
|
||||
/* don't use in[0]->hasinput, see material node for explanation */
|
||||
if (sock_vector->link) {
|
||||
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
|
||||
|
||||
|
||||
if (in[0]->datatype == NS_OSA_VECTORS) {
|
||||
float *fp = in[0]->data;
|
||||
retval = multitex_nodes((Tex *)node->id, vec, fp, fp + 3, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL);
|
||||
|
@ -76,7 +76,7 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node
|
|||
else if (in[0]->datatype == NS_OSA_VALUES) {
|
||||
const float *fp = in[0]->data;
|
||||
float dxt[3], dyt[3];
|
||||
|
||||
|
||||
dxt[0] = fp[0]; dxt[1] = dxt[2] = 0.0f;
|
||||
dyt[0] = fp[1]; dyt[1] = dyt[2] = 0.0f;
|
||||
retval = multitex_nodes((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL);
|
||||
|
@ -88,19 +88,19 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node
|
|||
copy_v3_v3(vec, shi->lo);
|
||||
retval = multitex_nodes((Tex *)node->id, vec, NULL, NULL, 0, &texres, thread, which_output, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* stupid exception */
|
||||
if ( ((Tex *)node->id)->type == TEX_STUCCI) {
|
||||
texres.tin = 0.5f + 0.7f * texres.nor[0];
|
||||
CLAMP(texres.tin, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
/* intensity and color need some handling */
|
||||
if (texres.talpha)
|
||||
out[0]->vec[0] = texres.ta;
|
||||
else
|
||||
out[0]->vec[0] = texres.tin;
|
||||
|
||||
|
||||
if ((retval & TEX_RGB) == 0) {
|
||||
copy_v3_fl(out[1]->vec, out[0]->vec[0]);
|
||||
out[1]->vec[3] = 1.0f;
|
||||
|
@ -109,13 +109,13 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node
|
|||
copy_v3_v3(out[1]->vec, &texres.tr);
|
||||
out[1]->vec[3] = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
copy_v3_v3(out[2]->vec, nor);
|
||||
|
||||
|
||||
if (shi->do_preview) {
|
||||
BKE_node_preview_set_pixel(execdata->preview, out[1]->vec, shi->xs, shi->ys, shi->do_manage);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue