Cleanup: style, use braces in source/
Automated using clang-tidy.
This commit is contained in:
@@ -807,8 +807,9 @@ int BKE_sound_scene_playing(Scene *scene)
|
||||
}
|
||||
|
||||
// in case of a "Null" audio device, we have no playback information
|
||||
if (AUD_Device_getRate(sound_device) == AUD_RATE_INVALID)
|
||||
if (AUD_Device_getRate(sound_device) == AUD_RATE_INVALID) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (scene->audio.flag & AUDIO_SYNC) {
|
||||
return AUD_isSynchronizerPlaying();
|
||||
|
||||
@@ -1043,16 +1043,21 @@ bool invert_m4_m4_fallback(float inverse[4][4], const float mat[4][4])
|
||||
BLI_assert(inverse != mat);
|
||||
|
||||
/* Set inverse to identity */
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
inverse[i][j] = 0;
|
||||
for (i = 0; i < 4; i++)
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 4; i++) {
|
||||
inverse[i][i] = 1;
|
||||
}
|
||||
|
||||
/* Copy original matrix so we don't mess it up */
|
||||
for (i = 0; i < 4; i++)
|
||||
for (j = 0; j < 4; j++)
|
||||
for (i = 0; i < 4; i++) {
|
||||
for (j = 0; j < 4; j++) {
|
||||
tempmat[i][j] = mat[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
/* Look for row with max pivot */
|
||||
@@ -1441,10 +1446,11 @@ bool is_orthonormal_m4(const float m[4][4])
|
||||
if (is_orthogonal_m4(m)) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (fabsf(dot_v4v4(m[i], m[i]) - 1) > 1e-5f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1256,8 +1256,9 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
|
||||
pro->super_r = bp->pro_super_r;
|
||||
/* projection direction is direction of the edge */
|
||||
sub_v3_v3v3(pro->proj_dir, e->e->v1->co, e->e->v2->co);
|
||||
if (e->is_rev)
|
||||
if (e->is_rev) {
|
||||
negate_v3(pro->proj_dir);
|
||||
}
|
||||
normalize_v3(pro->proj_dir);
|
||||
project_to_edge(e->e, co1, co2, pro->midco);
|
||||
if (DEBUG_OLD_PROJ_TO_PERP_PLANE) {
|
||||
@@ -1832,8 +1833,9 @@ static void bevel_extend_edge_data(BevVert *bv)
|
||||
{
|
||||
VMesh *vm = bv->vmesh;
|
||||
|
||||
if (vm->mesh_kind == M_TRI_FAN)
|
||||
if (vm->mesh_kind == M_TRI_FAN) {
|
||||
return;
|
||||
}
|
||||
|
||||
BoundVert *bcur = bv->vmesh->boundstart, *start = bcur;
|
||||
|
||||
@@ -2180,10 +2182,11 @@ static int count_bound_vert_seams(BevVert *bv)
|
||||
}
|
||||
|
||||
ans = 0;
|
||||
for (i = 0; i < bv->edgecount; i++)
|
||||
for (i = 0; i < bv->edgecount; i++) {
|
||||
if (bv->edges[i].is_seam) {
|
||||
ans++;
|
||||
}
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,14 @@ std::string AnimationExporter::get_axis_name(std::string channel, int id)
|
||||
|
||||
std::map<std::string, std::vector<std::string>>::const_iterator it;
|
||||
it = BC_COLLADA_AXIS_FROM_TYPE.find(channel);
|
||||
if (it == BC_COLLADA_AXIS_FROM_TYPE.end())
|
||||
if (it == BC_COLLADA_AXIS_FROM_TYPE.end()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const std::vector<std::string> &subchannel = it->second;
|
||||
if (id >= subchannel.size())
|
||||
if (id >= subchannel.size()) {
|
||||
return "";
|
||||
}
|
||||
return subchannel[id];
|
||||
}
|
||||
|
||||
@@ -71,8 +73,9 @@ void AnimationExporter::openAnimationWithClip(std::string action_id, std::string
|
||||
|
||||
void AnimationExporter::close_animation_container(bool has_container)
|
||||
{
|
||||
if (has_container)
|
||||
if (has_container) {
|
||||
closeAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
bool AnimationExporter::exportAnimations()
|
||||
@@ -152,8 +155,9 @@ void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
|
||||
|
||||
/* Export skeletal animation (if any) */
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next)
|
||||
for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next) {
|
||||
export_bone_animations_recursive(ob, root_bone, sampler);
|
||||
}
|
||||
}
|
||||
|
||||
close_animation_container(container_is_open);
|
||||
@@ -265,8 +269,9 @@ void AnimationExporter::export_bone_animations_recursive(Object *ob,
|
||||
}
|
||||
}
|
||||
|
||||
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next)
|
||||
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
|
||||
export_bone_animations_recursive(ob, child, sampler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -382,15 +387,17 @@ bool AnimationExporter::is_bone_deform_group(Bone *bone)
|
||||
{
|
||||
bool is_def;
|
||||
/* Check if current bone is deform */
|
||||
if ((bone->flag & BONE_NO_DEFORM) == 0)
|
||||
if ((bone->flag & BONE_NO_DEFORM) == 0) {
|
||||
return true;
|
||||
/* Check child bones */
|
||||
/* Check child bones */
|
||||
}
|
||||
else {
|
||||
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
|
||||
/* loop through all the children until deform bone is found, and then return */
|
||||
is_def = is_bone_deform_group(child);
|
||||
if (is_def)
|
||||
if (is_def) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* no deform bone found in children also */
|
||||
@@ -424,10 +431,12 @@ void AnimationExporter::export_collada_curve_animation(
|
||||
|
||||
bool has_tangents = false;
|
||||
std::string interpolation_id;
|
||||
if (this->export_settings.get_keep_smooth_curves())
|
||||
if (this->export_settings.get_keep_smooth_curves()) {
|
||||
interpolation_id = collada_interpolation_source(curve, id, axis, &has_tangents);
|
||||
else
|
||||
}
|
||||
else {
|
||||
interpolation_id = collada_linear_interpolation_source(frames.size(), id);
|
||||
}
|
||||
|
||||
std::string intangent_id;
|
||||
std::string outtangent_id;
|
||||
@@ -803,8 +812,9 @@ const std::string AnimationExporter::get_collada_name(std::string channel_target
|
||||
|
||||
std::map<std::string, std::string>::iterator name_it = BC_CHANNEL_BLENDER_TO_COLLADA.find(
|
||||
channel_target);
|
||||
if (name_it == BC_CHANNEL_BLENDER_TO_COLLADA.end())
|
||||
if (name_it == BC_CHANNEL_BLENDER_TO_COLLADA.end()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string tm_name = name_it->second;
|
||||
return tm_name;
|
||||
@@ -823,12 +833,15 @@ std::string AnimationExporter::get_collada_sid(const BCAnimationCurve &curve,
|
||||
bool is_angle = curve.is_rotation_curve();
|
||||
|
||||
if (tm_name.size()) {
|
||||
if (is_angle)
|
||||
if (is_angle) {
|
||||
return tm_name + std::string(axis_name) + ".ANGLE";
|
||||
else if (axis_name != "")
|
||||
}
|
||||
else if (axis_name != "") {
|
||||
return tm_name + "." + std::string(axis_name);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return tm_name;
|
||||
}
|
||||
}
|
||||
|
||||
return tm_name;
|
||||
|
||||
@@ -185,10 +185,12 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
|
||||
{
|
||||
bAction *act;
|
||||
|
||||
if (!ob->adt || !ob->adt->action)
|
||||
if (!ob->adt || !ob->adt->action) {
|
||||
act = verify_adt_action(bmain, (ID *)&ob->id, 1);
|
||||
else
|
||||
}
|
||||
else {
|
||||
act = ob->adt->action;
|
||||
}
|
||||
|
||||
std::vector<FCurve *>::iterator it;
|
||||
int i;
|
||||
@@ -206,10 +208,12 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
|
||||
FCurve *fcu = *it;
|
||||
fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
|
||||
|
||||
if (array_index == -1)
|
||||
if (array_index == -1) {
|
||||
fcu->array_index = i;
|
||||
else
|
||||
}
|
||||
else {
|
||||
fcu->array_index = array_index;
|
||||
}
|
||||
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
bActionGroup *grp = NULL;
|
||||
@@ -256,11 +260,14 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain,
|
||||
AnimationImporter::~AnimationImporter()
|
||||
{
|
||||
/* free unused FCurves */
|
||||
for (std::vector<FCurve *>::iterator it = unused_curves.begin(); it != unused_curves.end(); it++)
|
||||
for (std::vector<FCurve *>::iterator it = unused_curves.begin(); it != unused_curves.end();
|
||||
it++) {
|
||||
free_fcurve(*it);
|
||||
}
|
||||
|
||||
if (unused_curves.size())
|
||||
if (unused_curves.size()) {
|
||||
fprintf(stderr, "removed %d unused curves\n", (int)unused_curves.size());
|
||||
}
|
||||
}
|
||||
|
||||
bool AnimationImporter::write_animation(const COLLADAFW::Animation *anim)
|
||||
@@ -444,10 +451,12 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve *> *curves,
|
||||
FCurve *fcu = *it;
|
||||
fcu->rna_path = BLI_strdup(rna_path);
|
||||
|
||||
if (array_index == -1)
|
||||
if (array_index == -1) {
|
||||
fcu->array_index = i;
|
||||
else
|
||||
}
|
||||
else {
|
||||
fcu->array_index = array_index;
|
||||
}
|
||||
|
||||
fcurve_is_used(fcu);
|
||||
}
|
||||
@@ -473,8 +482,9 @@ void AnimationImporter::find_frames(std::vector<float> *frames, std::vector<FCur
|
||||
/* get frame value from bezTriple */
|
||||
float fra = fcu->bezt[k].vec[1][0];
|
||||
/* if frame already not added add frame to frames */
|
||||
if (std::find(frames->begin(), frames->end(), fra) == frames->end())
|
||||
if (std::find(frames->begin(), frames->end(), fra) == frames->end()) {
|
||||
frames->push_back(fra);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -508,10 +518,12 @@ void AnimationImporter::Assign_transform_animations(
|
||||
case COLLADAFW::Transformation::TRANSLATE:
|
||||
case COLLADAFW::Transformation::SCALE: {
|
||||
bool loc = tm_type == COLLADAFW::Transformation::TRANSLATE;
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, loc ? "location" : "scale");
|
||||
else
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path));
|
||||
}
|
||||
|
||||
switch (binding->animationClass) {
|
||||
case COLLADAFW::AnimationList::POSITION_X:
|
||||
@@ -537,17 +549,20 @@ void AnimationImporter::Assign_transform_animations(
|
||||
}
|
||||
|
||||
case COLLADAFW::Transformation::ROTATE: {
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path);
|
||||
else
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path));
|
||||
}
|
||||
std::vector<FCurve *>::iterator iter;
|
||||
for (iter = curves->begin(); iter != curves->end(); iter++) {
|
||||
FCurve *fcu = *iter;
|
||||
|
||||
/* if transform is rotation the fcurves values must be turned in to radian. */
|
||||
if (is_rotation)
|
||||
if (is_rotation) {
|
||||
fcurve_deg_to_rad(fcu);
|
||||
}
|
||||
}
|
||||
COLLADAFW::Rotate *rot = (COLLADAFW::Rotate *)transform;
|
||||
COLLADABU::Math::Vector3 &axis = rot->getRotationAxis();
|
||||
@@ -563,8 +578,9 @@ void AnimationImporter::Assign_transform_animations(
|
||||
else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
|
||||
modify_fcurve(curves, rna_path, 2);
|
||||
}
|
||||
else
|
||||
else {
|
||||
unused_fcurve(curves);
|
||||
}
|
||||
break;
|
||||
case COLLADAFW::AnimationList::AXISANGLE:
|
||||
/* TODO convert axis-angle to quat? or XYZ? */
|
||||
@@ -767,8 +783,9 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
|
||||
bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
|
||||
const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
|
||||
char joint_path[200];
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
|
||||
}
|
||||
|
||||
std::vector<float> frames;
|
||||
find_frames(&frames, &animcurves);
|
||||
@@ -812,16 +829,19 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
|
||||
axis = i - 7;
|
||||
}
|
||||
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str);
|
||||
else
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(rna_path, tm_str, sizeof(rna_path));
|
||||
}
|
||||
newcu[i] = create_fcurve(axis, rna_path);
|
||||
newcu[i]->totvert = frames.size();
|
||||
}
|
||||
|
||||
if (frames.size() == 0)
|
||||
if (frames.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::sort(frames.begin(), frames.end());
|
||||
|
||||
@@ -872,12 +892,15 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
|
||||
|
||||
/* add keys */
|
||||
for (int i = 0; i < totcu; i++) {
|
||||
if (i < 4)
|
||||
if (i < 4) {
|
||||
add_bezt(newcu[i], fra, rot[i]);
|
||||
else if (i < 7)
|
||||
}
|
||||
else if (i < 7) {
|
||||
add_bezt(newcu[i], fra, loc[i - 4]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
add_bezt(newcu[i], fra, scale[i - 7]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Main *bmain = CTX_data_main(mContext);
|
||||
@@ -887,10 +910,12 @@ void AnimationImporter::apply_matrix_curves(Object *ob,
|
||||
|
||||
/* add curves */
|
||||
for (int i = 0; i < totcu; i++) {
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
add_bone_fcurve(ob, node, newcu[i]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
BLI_addtail(curves, newcu[i]);
|
||||
}
|
||||
#if 0
|
||||
fcurve_is_used(newcu[i]); /* never added to unused */
|
||||
#endif
|
||||
@@ -929,10 +954,12 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera)
|
||||
}
|
||||
else {
|
||||
const double xfov = camera->getXFov().getValue();
|
||||
if (xfov == 0)
|
||||
if (xfov == 0) {
|
||||
aspect = 1;
|
||||
else
|
||||
}
|
||||
else {
|
||||
aspect = xfov / yfov;
|
||||
}
|
||||
}
|
||||
}
|
||||
return aspect;
|
||||
@@ -941,10 +968,12 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera)
|
||||
static ListBase &get_animation_curves(Main *bmain, Material *ma)
|
||||
{
|
||||
bAction *act;
|
||||
if (!ma->adt || !ma->adt->action)
|
||||
if (!ma->adt || !ma->adt->action) {
|
||||
act = verify_adt_action(bmain, (ID *)&ma->id, 1);
|
||||
else
|
||||
}
|
||||
else {
|
||||
act = ma->adt->action;
|
||||
}
|
||||
|
||||
return act->curves;
|
||||
}
|
||||
@@ -961,10 +990,12 @@ void AnimationImporter::translate_Animations(
|
||||
COLLADAFW::Node *root = root_map.find(uid) == root_map.end() ? node : root_map[uid];
|
||||
|
||||
Object *ob;
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
ob = armature_importer->get_armature_for_joint(root);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ob = object_map.find(uid) == object_map.end() ? NULL : object_map.find(uid)->second;
|
||||
}
|
||||
|
||||
if (!ob) {
|
||||
fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str());
|
||||
@@ -979,14 +1010,16 @@ void AnimationImporter::translate_Animations(
|
||||
/* const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; */ /* UNUSED */
|
||||
char joint_path[200];
|
||||
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
|
||||
}
|
||||
|
||||
if (!ob->adt || !ob->adt->action)
|
||||
if (!ob->adt || !ob->adt->action) {
|
||||
act = verify_adt_action(bmain, (ID *)&ob->id, 1);
|
||||
|
||||
else
|
||||
}
|
||||
else {
|
||||
act = ob->adt->action;
|
||||
}
|
||||
|
||||
/* Get the list of animation curves of the object */
|
||||
ListBase *AnimCurves = &(act->curves);
|
||||
@@ -1049,10 +1082,12 @@ void AnimationImporter::translate_Animations(
|
||||
|
||||
if ((animType->light) != 0) {
|
||||
Light *lamp = (Light *)ob->data;
|
||||
if (!lamp->adt || !lamp->adt->action)
|
||||
if (!lamp->adt || !lamp->adt->action) {
|
||||
act = verify_adt_action(bmain, (ID *)&lamp->id, 1);
|
||||
else
|
||||
}
|
||||
else {
|
||||
act = lamp->adt->action;
|
||||
}
|
||||
|
||||
ListBase *AnimCurves = &(act->curves);
|
||||
const COLLADAFW::InstanceLightPointerArray &nodeLights = node->getInstanceLights();
|
||||
@@ -1085,10 +1120,12 @@ void AnimationImporter::translate_Animations(
|
||||
if (animType->camera != 0) {
|
||||
|
||||
Camera *cam = (Camera *)ob->data;
|
||||
if (!cam->adt || !cam->adt->action)
|
||||
if (!cam->adt || !cam->adt->action) {
|
||||
act = verify_adt_action(bmain, (ID *)&cam->id, 1);
|
||||
else
|
||||
}
|
||||
else {
|
||||
act = cam->adt->action;
|
||||
}
|
||||
|
||||
ListBase *AnimCurves = &(act->curves);
|
||||
const COLLADAFW::InstanceCameraPointerArray &nodeCameras = node->getInstanceCameras();
|
||||
@@ -1139,10 +1176,12 @@ void AnimationImporter::translate_Animations(
|
||||
if (animType->material != 0) {
|
||||
|
||||
Material *ma = give_current_material(ob, 1);
|
||||
if (!ma->adt || !ma->adt->action)
|
||||
if (!ma->adt || !ma->adt->action) {
|
||||
act = verify_adt_action(bmain, (ID *)&ma->id, 1);
|
||||
else
|
||||
}
|
||||
else {
|
||||
act = ma->adt->action;
|
||||
}
|
||||
|
||||
const COLLADAFW::InstanceGeometryPointerArray &nodeGeoms = node->getInstanceGeometries();
|
||||
for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) {
|
||||
@@ -1260,8 +1299,9 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
|
||||
newcu[i]->totvert = frames.size();
|
||||
}
|
||||
|
||||
if (frames.size() == 0)
|
||||
if (frames.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::sort(frames.begin(), frames.end());
|
||||
|
||||
@@ -1308,12 +1348,15 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob,
|
||||
|
||||
/* add keys */
|
||||
for (int i = 0; i < totcu; i++) {
|
||||
if (i < 4)
|
||||
if (i < 4) {
|
||||
add_bezt(newcu[i], fra, rot[i]);
|
||||
else if (i < 7)
|
||||
}
|
||||
else if (i < 7) {
|
||||
add_bezt(newcu[i], fra, loc[i - 4]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
add_bezt(newcu[i], fra, scale[i - 7]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Main *bmain = CTX_data_main(mContext);
|
||||
@@ -1364,8 +1407,9 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
|
||||
types->light = setAnimType(&(light->getFallOffAngle()), (types->light), LIGHT_FOA);
|
||||
types->light = setAnimType(&(light->getFallOffExponent()), (types->light), LIGHT_FOE);
|
||||
|
||||
if (types->light != 0)
|
||||
if (types->light != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const COLLADAFW::InstanceCameraPointerArray &nodeCameras = node->getInstanceCameras();
|
||||
@@ -1395,8 +1439,9 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(
|
||||
types->camera = setAnimType(&(camera->getFarClippingPlane()), (types->camera), CAMERA_ZFAR);
|
||||
types->camera = setAnimType(&(camera->getNearClippingPlane()), (types->camera), CAMERA_ZNEAR);
|
||||
|
||||
if (types->camera != 0)
|
||||
if (types->camera != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const COLLADAFW::InstanceGeometryPointerArray &nodeGeoms = node->getInstanceGeometries();
|
||||
@@ -1431,10 +1476,12 @@ int AnimationImporter::setAnimType(const COLLADAFW::Animatable *prop, int types,
|
||||
{
|
||||
int anim_type;
|
||||
const COLLADAFW::UniqueId &listid = prop->getAnimationList();
|
||||
if (animlist_map.find(listid) != animlist_map.end())
|
||||
if (animlist_map.find(listid) != animlist_map.end()) {
|
||||
anim_type = types | addition;
|
||||
else
|
||||
}
|
||||
else {
|
||||
anim_type = types;
|
||||
}
|
||||
|
||||
return anim_type;
|
||||
}
|
||||
@@ -1480,15 +1527,17 @@ void AnimationImporter::find_frames_old(std::vector<float> *frames,
|
||||
FCurve *fcu = *iter;
|
||||
|
||||
/* if transform is rotation the fcurves values must be turned in to radian. */
|
||||
if (is_rotation)
|
||||
if (is_rotation) {
|
||||
fcurve_deg_to_rad(fcu);
|
||||
}
|
||||
|
||||
for (unsigned int k = 0; k < fcu->totvert; k++) {
|
||||
/* get frame value from bezTriple */
|
||||
float fra = fcu->bezt[k].vec[1][0];
|
||||
/* if frame already not added add frame to frames */
|
||||
if (std::find(frames->begin(), frames->end(), fra) == frames->end())
|
||||
if (std::find(frames->begin(), frames->end(), fra) == frames->end()) {
|
||||
frames->push_back(fra);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1560,8 +1609,9 @@ Object *AnimationImporter::translate_animation_OLD(
|
||||
job = get_joint_object(root, node, par_job);
|
||||
#endif
|
||||
|
||||
if (frames.size() == 0)
|
||||
if (frames.size() == 0) {
|
||||
return job;
|
||||
}
|
||||
|
||||
std::sort(frames.begin(), frames.end());
|
||||
|
||||
@@ -1585,8 +1635,9 @@ Object *AnimationImporter::translate_animation_OLD(
|
||||
char rna_path[200];
|
||||
char joint_path[200];
|
||||
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path));
|
||||
}
|
||||
|
||||
/* new curves */
|
||||
FCurve *newcu[10]; /* if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale */
|
||||
@@ -1611,10 +1662,12 @@ Object *AnimationImporter::translate_animation_OLD(
|
||||
}
|
||||
}
|
||||
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str);
|
||||
else
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(rna_path, tm_str, sizeof(rna_path));
|
||||
}
|
||||
newcu[i] = create_fcurve(axis, rna_path);
|
||||
|
||||
#ifdef ARMATURE_TEST
|
||||
@@ -1683,12 +1736,15 @@ Object *AnimationImporter::translate_animation_OLD(
|
||||
/* add keys */
|
||||
for (i = 0; i < totcu; i++) {
|
||||
if (is_matrix) {
|
||||
if (i < 4)
|
||||
if (i < 4) {
|
||||
add_bezt(newcu[i], fra, rot[i]);
|
||||
else if (i < 7)
|
||||
}
|
||||
else if (i < 7) {
|
||||
add_bezt(newcu[i], fra, loc[i - 4]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
add_bezt(newcu[i], fra, scale[i - 7]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
add_bezt(newcu[i], fra, val[i]);
|
||||
@@ -1739,10 +1795,12 @@ Object *AnimationImporter::translate_animation_OLD(
|
||||
|
||||
/* add curves */
|
||||
for (i = 0; i < totcu; i++) {
|
||||
if (is_joint)
|
||||
if (is_joint) {
|
||||
add_bone_fcurve(ob, node, newcu[i]);
|
||||
else
|
||||
}
|
||||
else {
|
||||
BLI_addtail(curves, newcu[i]);
|
||||
}
|
||||
|
||||
#ifdef ARMATURE_TEST
|
||||
if (is_joint)
|
||||
@@ -1839,8 +1897,9 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (animlist_map.find(listid) == animlist_map.end())
|
||||
if (animlist_map.find(listid) == animlist_map.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const COLLADAFW::AnimationList *animlist = animlist_map[listid];
|
||||
const COLLADAFW::AnimationList::AnimationBindings &bindings = animlist->getAnimationBindings();
|
||||
@@ -1851,10 +1910,12 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
|
||||
bool is_scale = (type == COLLADAFW::Transformation::SCALE);
|
||||
bool is_translate = (type == COLLADAFW::Transformation::TRANSLATE);
|
||||
|
||||
if (is_scale)
|
||||
if (is_scale) {
|
||||
dae_scale_to_v3(tm, vec);
|
||||
else if (is_translate)
|
||||
}
|
||||
else if (is_translate) {
|
||||
dae_translate_to_v3(tm, vec);
|
||||
}
|
||||
|
||||
for (unsigned int index = 0; index < bindings.getCount(); index++) {
|
||||
const COLLADAFW::AnimationList::AnimationBinding &binding = bindings[index];
|
||||
@@ -1903,10 +1964,12 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
|
||||
bool is_xyz = animclass == COLLADAFW::AnimationList::POSITION_XYZ;
|
||||
|
||||
if ((!is_xyz && curves.size() != 1) || (is_xyz && curves.size() != 3)) {
|
||||
if (is_xyz)
|
||||
if (is_xyz) {
|
||||
fprintf(stderr, "%s: expected 3 curves, got %d\n", path, (int)curves.size());
|
||||
else
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s: expected 1 curve, got %d\n", path, (int)curves.size());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1955,10 +2018,12 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm,
|
||||
}
|
||||
}
|
||||
|
||||
if (is_scale)
|
||||
if (is_scale) {
|
||||
size_to_mat4(mat, vec);
|
||||
else
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(mat[3], vec);
|
||||
}
|
||||
|
||||
return is_scale || is_translate;
|
||||
}
|
||||
@@ -2009,8 +2074,9 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4],
|
||||
|
||||
COLLADAFW::NodePointerArray &children = node->getChildNodes();
|
||||
for (unsigned int i = 0; i < children.getCount(); i++) {
|
||||
if (calc_joint_parent_mat_rest(mat, m, children[i], end))
|
||||
if (calc_joint_parent_mat_rest(mat, m, children[i], end)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -94,8 +94,9 @@ bool ArmatureExporter::add_instance_controller(Object *ob)
|
||||
ins.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, controller_id));
|
||||
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
if (!me->dvert)
|
||||
if (!me->dvert) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// write root bone URLs
|
||||
Bone *bone;
|
||||
@@ -234,8 +235,9 @@ void ArmatureExporter::add_bone_node(Bone *bone,
|
||||
copy_m4_m4(ob->parentinv, backup_parinv);
|
||||
iter = child_objects.erase(iter);
|
||||
}
|
||||
else
|
||||
else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
|
||||
|
||||
@@ -105,8 +105,9 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
|
||||
/* Checking if bone is already made. */
|
||||
std::vector<COLLADAFW::Node *>::iterator it;
|
||||
it = std::find(finished_joints.begin(), finished_joints.end(), node);
|
||||
if (it != finished_joints.end())
|
||||
if (it != finished_joints.end()) {
|
||||
return chain_length;
|
||||
}
|
||||
|
||||
EditBone *bone = ED_armature_ebone_add(arm, bc_get_joint_name(node));
|
||||
totbone++;
|
||||
@@ -143,15 +144,17 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
|
||||
get_node_mat(mat, node, NULL, NULL, parent_mat);
|
||||
}
|
||||
|
||||
if (parent)
|
||||
if (parent) {
|
||||
bone->parent = parent;
|
||||
}
|
||||
|
||||
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();
|
||||
if (layer)
|
||||
if (layer) {
|
||||
bone->layer = layer;
|
||||
}
|
||||
arm->layer |= layer; // ensure that all populated bone layers are visible after import
|
||||
|
||||
float *tail = be.get_tail();
|
||||
@@ -205,8 +208,9 @@ int ArmatureImporter::create_bone(SkinInfo *skin,
|
||||
|
||||
for (unsigned int i = 0; i < children.getCount(); i++) {
|
||||
int cl = create_bone(skin, children[i], bone, children.getCount(), mat, arm, layer_labels);
|
||||
if (cl > chain_length)
|
||||
if (cl > chain_length) {
|
||||
chain_length = cl;
|
||||
}
|
||||
}
|
||||
|
||||
bone->length = len_v3v3(bone->head, bone->tail);
|
||||
@@ -228,8 +232,9 @@ void ArmatureImporter::fix_leaf_bone_hierarchy(bArmature *armature,
|
||||
Bone *bone,
|
||||
bool fix_orientation)
|
||||
{
|
||||
if (bone == NULL)
|
||||
if (bone == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bc_is_leaf_bone(bone)) {
|
||||
BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(armature);
|
||||
@@ -276,8 +281,9 @@ void ArmatureImporter::fix_leaf_bone(bArmature *armature,
|
||||
void ArmatureImporter::fix_parent_connect(bArmature *armature, Bone *bone)
|
||||
{
|
||||
/* armature has no bones */
|
||||
if (bone == NULL)
|
||||
if (bone == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (bone->parent && bone->flag & BONE_CONNECTED) {
|
||||
copy_v3_v3(bone->parent->tail, bone->head);
|
||||
@@ -294,8 +300,9 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone
|
||||
BoneExtended *dominant_child = NULL;
|
||||
int maxlen = 0;
|
||||
|
||||
if (parentbone == NULL)
|
||||
if (parentbone == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Bone *child = (Bone *)parentbone->childbase.first;
|
||||
if (child && (import_settings->find_chains || child->next == NULL)) {
|
||||
@@ -356,8 +363,9 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone
|
||||
}
|
||||
else {
|
||||
/* can't connect this Bone. Proceed with children ... */
|
||||
if (pbe)
|
||||
if (pbe) {
|
||||
pbe->set_leaf_bone(true);
|
||||
}
|
||||
for (Bone *ch = (Bone *)parentbone->childbase.first; ch; ch = ch->next) {
|
||||
ArmatureImporter::connect_bone_chains(armature, ch, UNLIMITED_CHAIN_MAX);
|
||||
}
|
||||
@@ -417,8 +425,9 @@ void ArmatureImporter::set_euler_rotmode()
|
||||
|
||||
Object *ArmatureImporter::get_empty_for_leaves()
|
||||
{
|
||||
if (empty)
|
||||
if (empty) {
|
||||
return empty;
|
||||
}
|
||||
|
||||
empty = bc_add_object(m_bmain, scene, view_layer, OB_EMPTY, NULL);
|
||||
empty->empty_drawtype = OB_EMPTY_SPHERE;
|
||||
@@ -467,16 +476,19 @@ 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)
|
||||
if (get_armature_for_joint(*ri) != NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Object *ob_arm = joint_parent_map[(*ri)->getUniqueId()];
|
||||
if (!ob_arm)
|
||||
if (!ob_arm) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bArmature *armature = (bArmature *)ob_arm->data;
|
||||
if (!armature)
|
||||
if (!armature) {
|
||||
continue;
|
||||
}
|
||||
|
||||
char *bone_name = (char *)bc_get_joint_name(*ri);
|
||||
Bone *bone = BKE_armature_find_bone_name(armature, bone_name);
|
||||
@@ -568,8 +580,9 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
|
||||
std::map<COLLADAFW::UniqueId, SkinInfo>::iterator it;
|
||||
for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) {
|
||||
SkinInfo *b = &it->second;
|
||||
if (b == a || b->BKE_armature_from_object() == NULL)
|
||||
if (b == a || b->BKE_armature_from_object() == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
skin_root_joints.clear();
|
||||
|
||||
@@ -583,8 +596,9 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
|
||||
}
|
||||
}
|
||||
|
||||
if (shared != NULL)
|
||||
if (shared != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!shared && this->joint_parent_map.size() > 0) {
|
||||
@@ -620,9 +634,10 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
|
||||
std::vector<COLLADAFW::Node *>::iterator ri;
|
||||
for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
|
||||
/* for shared armature check if bone tree is already created */
|
||||
if (shared &&
|
||||
std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) != skin_root_joints.end())
|
||||
if (shared && std::find(skin_root_joints.begin(), skin_root_joints.end(), *ri) !=
|
||||
skin_root_joints.end()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* since root_joints may contain joints for multiple controllers, we need to filter */
|
||||
if (skin.uses_joint_or_descendant(*ri)) {
|
||||
@@ -631,8 +646,9 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
|
||||
&skin, *ri, NULL, (*ri)->getChildNodes().getCount(), NULL, armature, layer_labels);
|
||||
|
||||
if (joint_parent_map.find((*ri)->getUniqueId()) != joint_parent_map.end() &&
|
||||
!skin.get_parent())
|
||||
!skin.get_parent()) {
|
||||
skin.set_parent(joint_parent_map[(*ri)->getUniqueId()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -767,16 +783,19 @@ void ArmatureImporter::make_armatures(bContext *C, std::vector<Object *> &object
|
||||
ob_arms.push_back(ob_arm);
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
fprintf(stderr, "Cannot find object to link armature with.\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
else {
|
||||
fprintf(stderr, "Cannot find geometry to link armature with.\n");
|
||||
}
|
||||
|
||||
/* set armature parent if any */
|
||||
Object *par = skin.get_parent();
|
||||
if (par)
|
||||
if (par) {
|
||||
bc_set_parent(skin.BKE_armature_from_object(), par, C, false);
|
||||
}
|
||||
|
||||
/* free memory stolen from SkinControllerData */
|
||||
skin.free();
|
||||
@@ -938,8 +957,9 @@ void ArmatureImporter::make_shape_keys(bContext *C)
|
||||
|
||||
COLLADAFW::UniqueId *ArmatureImporter::get_geometry_uid(const COLLADAFW::UniqueId &controller_uid)
|
||||
{
|
||||
if (geom_uid_by_controller_uid.find(controller_uid) == geom_uid_by_controller_uid.end())
|
||||
if (geom_uid_by_controller_uid.find(controller_uid) == geom_uid_by_controller_uid.end()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &geom_uid_by_controller_uid[controller_uid];
|
||||
}
|
||||
@@ -950,14 +970,16 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node)
|
||||
for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) {
|
||||
SkinInfo &skin = it->second;
|
||||
|
||||
if (skin.uses_joint_or_descendant(node))
|
||||
if (skin.uses_joint_or_descendant(node)) {
|
||||
return skin.BKE_armature_from_object();
|
||||
}
|
||||
}
|
||||
|
||||
std::map<COLLADAFW::UniqueId, Object *>::iterator arm;
|
||||
for (arm = unskinned_armature_map.begin(); arm != unskinned_armature_map.end(); arm++) {
|
||||
if (arm->first == node->getUniqueId())
|
||||
if (arm->first == node->getUniqueId()) {
|
||||
return arm->second;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -1031,10 +1053,12 @@ BoneExtended &ArmatureImporter::add_bone_extended(EditBone *bone,
|
||||
}
|
||||
|
||||
be->set_bone_layers(layers, layer_labels);
|
||||
if (has_tail)
|
||||
if (has_tail) {
|
||||
be->set_tail(tail);
|
||||
if (has_roll)
|
||||
}
|
||||
if (has_roll) {
|
||||
be->set_roll(roll);
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_connect && this->import_settings->auto_connect) {
|
||||
|
||||
@@ -145,8 +145,9 @@ const std::string BCAnimationCurve::get_animation_name(Object *ob) const
|
||||
} break;
|
||||
|
||||
case BC_ANIMATION_TYPE_BONE: {
|
||||
if (fcurve == NULL || fcurve->rna_path == NULL)
|
||||
if (fcurve == NULL || fcurve->rna_path == NULL) {
|
||||
name = "";
|
||||
}
|
||||
else {
|
||||
const char *boneName = BLI_str_quoted_substrN(fcurve->rna_path, "pose.bones[");
|
||||
name = (boneName) ? std::string(boneName) : "";
|
||||
@@ -193,27 +194,31 @@ const std::string BCAnimationCurve::get_rna_path() const
|
||||
|
||||
const int BCAnimationCurve::sample_count() const
|
||||
{
|
||||
if (fcurve == NULL)
|
||||
if (fcurve == NULL) {
|
||||
return 0;
|
||||
}
|
||||
return fcurve->totvert;
|
||||
}
|
||||
|
||||
const int BCAnimationCurve::closest_index_above(const float sample_frame, const int start_at) const
|
||||
{
|
||||
if (fcurve == NULL)
|
||||
if (fcurve == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
const int cframe = fcurve->bezt[start_at].vec[1][0]; // inacurate!
|
||||
|
||||
if (fabs(cframe - sample_frame) < 0.00001)
|
||||
if (fabs(cframe - sample_frame) < 0.00001) {
|
||||
return start_at;
|
||||
}
|
||||
return (fcurve->totvert > start_at + 1) ? start_at + 1 : start_at;
|
||||
}
|
||||
|
||||
const int BCAnimationCurve::closest_index_below(const float sample_frame) const
|
||||
{
|
||||
if (fcurve == NULL)
|
||||
if (fcurve == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
float lower_frame = sample_frame;
|
||||
float upper_frame = sample_frame;
|
||||
@@ -234,8 +239,9 @@ const int BCAnimationCurve::closest_index_below(const float sample_frame) const
|
||||
}
|
||||
}
|
||||
|
||||
if (lower_index == upper_index)
|
||||
if (lower_index == upper_index) {
|
||||
return lower_index;
|
||||
}
|
||||
|
||||
const float fraction = float(sample_frame - lower_frame) / (upper_frame - lower_frame);
|
||||
return (fraction < 0.5) ? lower_index : upper_index;
|
||||
@@ -244,8 +250,9 @@ const int BCAnimationCurve::closest_index_below(const float sample_frame) const
|
||||
const int BCAnimationCurve::get_interpolation_type(float sample_frame) const
|
||||
{
|
||||
const int index = closest_index_below(sample_frame);
|
||||
if (index < 0)
|
||||
if (index < 0) {
|
||||
return BEZT_IPO_BEZ;
|
||||
}
|
||||
return fcurve->bezt[index].ipo;
|
||||
}
|
||||
|
||||
@@ -273,8 +280,9 @@ FCurve *BCAnimationCurve::get_edit_fcurve()
|
||||
|
||||
void BCAnimationCurve::clean_handles()
|
||||
{
|
||||
if (fcurve == NULL)
|
||||
if (fcurve == NULL) {
|
||||
fcurve = get_edit_fcurve();
|
||||
}
|
||||
|
||||
/* Keep old bezt data for copy)*/
|
||||
BezTriple *old_bezts = fcurve->bezt;
|
||||
@@ -292,8 +300,9 @@ void BCAnimationCurve::clean_handles()
|
||||
}
|
||||
|
||||
/* now free the memory used by the old BezTriples */
|
||||
if (old_bezts)
|
||||
if (old_bezts) {
|
||||
MEM_freeN(old_bezts);
|
||||
}
|
||||
}
|
||||
|
||||
const bool BCAnimationCurve::is_transform_curve() const
|
||||
@@ -500,15 +509,18 @@ bool BCAnimationCurve::is_animated()
|
||||
|
||||
bool BCAnimationCurve::is_keyframe(int frame)
|
||||
{
|
||||
if (this->fcurve == NULL)
|
||||
if (this->fcurve == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < fcurve->totvert; ++i) {
|
||||
const int cframe = nearbyint(fcurve->bezt[i].vec[1][0]);
|
||||
if (cframe == frame)
|
||||
if (cframe == frame) {
|
||||
return true;
|
||||
if (cframe > frame)
|
||||
}
|
||||
if (cframe > frame) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -523,8 +535,9 @@ inline bool operator<(const BCAnimationCurve &lhs, const BCAnimationCurve &rhs)
|
||||
const int rha = rhs.get_channel_index();
|
||||
return lha < rha;
|
||||
}
|
||||
else
|
||||
else {
|
||||
return lhtgt < rhtgt;
|
||||
}
|
||||
}
|
||||
|
||||
BCCurveKey::BCCurveKey()
|
||||
@@ -587,14 +600,17 @@ const BC_animation_type BCCurveKey::get_animation_type() const
|
||||
const bool BCCurveKey::operator<(const BCCurveKey &other) const
|
||||
{
|
||||
/* needed for using this class as key in maps and sets */
|
||||
if (this->key_type != other.key_type)
|
||||
if (this->key_type != other.key_type) {
|
||||
return this->key_type < other.key_type;
|
||||
}
|
||||
|
||||
if (this->curve_subindex != other.curve_subindex)
|
||||
if (this->curve_subindex != other.curve_subindex) {
|
||||
return this->curve_subindex < other.curve_subindex;
|
||||
}
|
||||
|
||||
if (this->rna_path != other.rna_path)
|
||||
if (this->rna_path != other.rna_path) {
|
||||
return this->rna_path < other.rna_path;
|
||||
}
|
||||
|
||||
return this->curve_array_index < other.curve_array_index;
|
||||
}
|
||||
|
||||
@@ -76,8 +76,9 @@ void BCAnimationSampler::add_object(Object *ob)
|
||||
BCAnimationCurveMap *BCAnimationSampler::get_curves(Object *ob)
|
||||
{
|
||||
BCAnimation &animation = *objects[ob];
|
||||
if (animation.curve_map.size() == 0)
|
||||
if (animation.curve_map.size() == 0) {
|
||||
initialize_curves(animation.curve_map, ob);
|
||||
}
|
||||
return &animation.curve_map;
|
||||
}
|
||||
|
||||
@@ -88,8 +89,9 @@ static void get_sample_frames(BCFrameSet &sample_frames,
|
||||
{
|
||||
sample_frames.clear();
|
||||
|
||||
if (sampling_rate < 1)
|
||||
if (sampling_rate < 1) {
|
||||
return; // no sample frames in this case
|
||||
}
|
||||
|
||||
float sfra = scene->r.sfra;
|
||||
float efra = scene->r.efra;
|
||||
@@ -237,8 +239,9 @@ bool BCAnimationSampler::is_animated_by_constraint(Object *ob,
|
||||
|
||||
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
||||
|
||||
if (!bc_validateConstraints(con))
|
||||
if (!bc_validateConstraints(con)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
bConstraintTarget *ct;
|
||||
@@ -247,8 +250,9 @@ bool BCAnimationSampler::is_animated_by_constraint(Object *ob,
|
||||
for (ct = (bConstraintTarget *)targets.first; ct; ct = ct->next) {
|
||||
obtar = ct->tar;
|
||||
if (obtar) {
|
||||
if (animated_objects.find(obtar) != animated_objects.end())
|
||||
if (animated_objects.find(obtar) != animated_objects.end()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -297,8 +301,9 @@ void BCAnimationSampler::get_animated_from_export_set(std::set<Object *> &animat
|
||||
}
|
||||
else {
|
||||
ListBase conlist = cob->constraints;
|
||||
if (conlist.first)
|
||||
if (conlist.first) {
|
||||
candidates.insert(cob);
|
||||
}
|
||||
}
|
||||
}
|
||||
find_depending_animated(animated_objects, candidates);
|
||||
@@ -403,8 +408,9 @@ void BCAnimationSampler::generate_transforms(Object *ob, Bone *bone, BCAnimation
|
||||
std::string prep = "pose.bones[\"" + std::string(bone->name) + "\"].";
|
||||
generate_transforms(ob, prep, BC_ANIMATION_TYPE_BONE, curves);
|
||||
|
||||
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next)
|
||||
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
|
||||
generate_transforms(ob, child, curves);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,8 +459,9 @@ void BCAnimationSampler::initialize_curves(BCAnimationCurveMap &curves, Object *
|
||||
generate_transforms(ob, EMPTY_STRING, object_type, curves);
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next)
|
||||
for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next) {
|
||||
generate_transforms(ob, root_bone, curves);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add curves on Object->data actions */
|
||||
|
||||
@@ -203,13 +203,15 @@ void BCMatrix::unit()
|
||||
* precision = -1 indicates to not limit the precision. */
|
||||
void BCMatrix::get_matrix(DMatrix &mat, const bool transposed, const int precision) const
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
float val = (transposed) ? matrix[j][i] : matrix[i][j];
|
||||
if (precision >= 0)
|
||||
if (precision >= 0) {
|
||||
val = floor((val * pow(10, precision) + 0.5)) / pow(10, precision);
|
||||
}
|
||||
mat[i][j] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BCMatrix::get_matrix(Matrix &mat,
|
||||
@@ -217,13 +219,15 @@ void BCMatrix::get_matrix(Matrix &mat,
|
||||
const int precision,
|
||||
const bool inverted) const
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
float val = (transposed) ? matrix[j][i] : matrix[i][j];
|
||||
if (precision >= 0)
|
||||
if (precision >= 0) {
|
||||
val = floor((val * pow(10, precision) + 0.5)) / pow(10, precision);
|
||||
}
|
||||
mat[i][j] = val;
|
||||
}
|
||||
}
|
||||
|
||||
if (inverted) {
|
||||
invert_m4(mat);
|
||||
|
||||
@@ -79,8 +79,9 @@ bool ControllerExporter::add_instance_controller(Object *ob)
|
||||
ins.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, controller_id));
|
||||
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
if (!me->dvert)
|
||||
if (!me->dvert) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* write root bone URLs */
|
||||
Bone *bone;
|
||||
@@ -227,10 +228,12 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
|
||||
bDeformGroup *def;
|
||||
|
||||
for (def = (bDeformGroup *)ob->defbase.first, i = 0, j = 0; def; def = def->next, i++) {
|
||||
if (is_bone_defgroup(ob_arm, def))
|
||||
if (is_bone_defgroup(ob_arm, def)) {
|
||||
joint_index_by_def_index.push_back(j++);
|
||||
else
|
||||
}
|
||||
else {
|
||||
joint_index_by_def_index.push_back(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int oob_counter = 0;
|
||||
@@ -440,8 +443,9 @@ void ControllerExporter::add_bind_shape_mat(Object *ob)
|
||||
|
||||
// UnitConverter::mat4_to_dae_double(bind_mat, ob->obmat);
|
||||
UnitConverter::mat4_to_dae_double(bind_mat, f_obmat);
|
||||
if (this->export_settings.get_limit_precision())
|
||||
if (this->export_settings.get_limit_precision()) {
|
||||
bc_sanitize_mat(bind_mat, LIMITTED_PRECISION);
|
||||
}
|
||||
|
||||
addBindShapeTransform(bind_mat);
|
||||
}
|
||||
@@ -455,8 +459,9 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm,
|
||||
int totjoint = 0;
|
||||
bDeformGroup *def;
|
||||
for (def = (bDeformGroup *)defbase->first; def; def = def->next) {
|
||||
if (is_bone_defgroup(ob_arm, def))
|
||||
if (is_bone_defgroup(ob_arm, def)) {
|
||||
totjoint++;
|
||||
}
|
||||
}
|
||||
|
||||
COLLADASW::NameSource source(mSW);
|
||||
@@ -472,8 +477,9 @@ std::string ControllerExporter::add_joints_source(Object *ob_arm,
|
||||
|
||||
for (def = (bDeformGroup *)defbase->first; def; def = def->next) {
|
||||
Bone *bone = get_bone_from_defgroup(ob_arm, def);
|
||||
if (bone)
|
||||
if (bone) {
|
||||
source.appendValues(get_joint_sid(bone));
|
||||
}
|
||||
}
|
||||
|
||||
source.finish();
|
||||
@@ -489,8 +495,9 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
|
||||
|
||||
int totjoint = 0;
|
||||
for (bDeformGroup *def = (bDeformGroup *)defbase->first; def; def = def->next) {
|
||||
if (is_bone_defgroup(ob_arm, def))
|
||||
if (is_bone_defgroup(ob_arm, def)) {
|
||||
totjoint++;
|
||||
}
|
||||
}
|
||||
|
||||
COLLADASW::FloatSourceF source(mSW);
|
||||
@@ -561,8 +568,9 @@ std::string ControllerExporter::add_inv_bind_mats_source(Object *ob_arm,
|
||||
|
||||
invert_m4_m4(mat, world);
|
||||
UnitConverter::mat4_to_dae(inv_bind_mat, mat);
|
||||
if (this->export_settings.get_limit_precision())
|
||||
if (this->export_settings.get_limit_precision()) {
|
||||
bc_sanitize_mat(inv_bind_mat, LIMITTED_PRECISION);
|
||||
}
|
||||
source.appendValues(inv_bind_mat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,8 +130,9 @@ extern bool bc_has_object_type(LinkNode *export_set, short obtype);
|
||||
char *bc_CustomData_get_layer_name(const struct CustomData *data, int type, int n)
|
||||
{
|
||||
int layer_index = CustomData_get_layer_index(data, type);
|
||||
if (layer_index < 0)
|
||||
if (layer_index < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data->layers[layer_index + n].name;
|
||||
}
|
||||
@@ -140,8 +141,9 @@ char *bc_CustomData_get_active_layer_name(const CustomData *data, int type)
|
||||
{
|
||||
/* get the layer index of the active layer of type */
|
||||
int layer_index = CustomData_get_active_layer_index(data, type);
|
||||
if (layer_index < 0)
|
||||
if (layer_index < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data->layers[layer_index].name;
|
||||
}
|
||||
|
||||
@@ -179,8 +179,9 @@ void DocumentImporter::start()
|
||||
|
||||
void DocumentImporter::finish()
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
Main *bmain = CTX_data_main(mContext);
|
||||
/* TODO: create a new scene except the selected <visual_scene> -
|
||||
@@ -287,10 +288,12 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node,
|
||||
* part in skinning. */
|
||||
if (par) { // && par->getType() == COLLADAFW::Node::JOINT) {
|
||||
/* par is root if there's no corresp. key in root_map */
|
||||
if (root_map.find(par->getUniqueId()) == root_map.end())
|
||||
if (root_map.find(par->getUniqueId()) == root_map.end()) {
|
||||
root_map[node->getUniqueId()] = node;
|
||||
else
|
||||
}
|
||||
else {
|
||||
root_map[node->getUniqueId()] = root_map[par->getUniqueId()];
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -446,8 +449,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
|
||||
for (unsigned int i = 0; i < children.getCount(); i++) {
|
||||
COLLADAFW::Node *child_node = children[i];
|
||||
const COLLADAFW::UniqueId &child_id = child_node->getUniqueId();
|
||||
if (object_map.find(child_id) == object_map.end())
|
||||
if (object_map.find(child_id) == object_map.end()) {
|
||||
continue;
|
||||
}
|
||||
COLLADAFW::InstanceNodePointerArray &inodes = child_node->getInstanceNodes();
|
||||
Object *new_child = NULL;
|
||||
if (inodes.getCount()) { // \todo loop through instance nodes
|
||||
@@ -462,8 +466,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob,
|
||||
}
|
||||
bc_set_parent(new_child, obn, mContext, true);
|
||||
|
||||
if (is_library_node)
|
||||
if (is_library_node) {
|
||||
libnode_ob.push_back(new_child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,8 +670,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
|
||||
object_map.insert(std::pair<COLLADAFW::UniqueId, Object *>(node->getUniqueId(), ob));
|
||||
node_map[node->getUniqueId()] = node;
|
||||
|
||||
if (is_library_node)
|
||||
if (is_library_node) {
|
||||
libnode_ob.push_back(ob);
|
||||
}
|
||||
}
|
||||
|
||||
// create_constraints(et,ob);
|
||||
@@ -676,8 +682,9 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node,
|
||||
++it) {
|
||||
ob = *it;
|
||||
|
||||
if (read_transform)
|
||||
if (read_transform) {
|
||||
anim_importer.read_node_transform(node, ob); // overwrites location set earlier
|
||||
}
|
||||
|
||||
if (!is_joint) {
|
||||
if (par && ob) {
|
||||
@@ -715,8 +722,9 @@ finally:
|
||||
*/
|
||||
bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* This method called on post process after writeGeometry, writeMaterial, etc. */
|
||||
|
||||
@@ -739,8 +747,9 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
|
||||
* \return The writer should return true, if writing succeeded, false otherwise.*/
|
||||
bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryNodes)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Scene *sce = CTX_data_scene(mContext);
|
||||
|
||||
@@ -759,8 +768,9 @@ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryN
|
||||
* \return The writer should return true, if writing succeeded, false otherwise.*/
|
||||
bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mesh_importer.write_geometry(geom);
|
||||
}
|
||||
@@ -769,8 +779,9 @@ bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom)
|
||||
* \return The writer should return true, if writing succeeded, false otherwise.*/
|
||||
bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Main *bmain = CTX_data_main(mContext);
|
||||
const std::string &str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId();
|
||||
@@ -800,8 +811,9 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
|
||||
|
||||
bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const COLLADAFW::UniqueId &uid = effect->getUniqueId();
|
||||
|
||||
@@ -836,8 +848,9 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
|
||||
* \return The writer should return true, if writing succeeded, false otherwise.*/
|
||||
bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Main *bmain = CTX_data_main(mContext);
|
||||
Camera *cam = NULL;
|
||||
@@ -846,10 +859,12 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
|
||||
ExtraTags *et = getExtraTags(camera->getUniqueId());
|
||||
cam_id = camera->getOriginalId();
|
||||
cam_name = camera->getName();
|
||||
if (cam_name.size())
|
||||
if (cam_name.size()) {
|
||||
cam = (Camera *)BKE_camera_add(bmain, (char *)cam_name.c_str());
|
||||
else
|
||||
}
|
||||
else {
|
||||
cam = (Camera *)BKE_camera_add(bmain, (char *)cam_id.c_str());
|
||||
}
|
||||
|
||||
if (!cam) {
|
||||
fprintf(stderr, "Cannot create camera.\n");
|
||||
@@ -944,8 +959,9 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
|
||||
* \return The writer should return true, if writing succeeded, false otherwise.*/
|
||||
bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string &imagepath = image->getImageURI().toNativePath();
|
||||
|
||||
@@ -981,8 +997,9 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
|
||||
* \return The writer should return true, if writing succeeded, false otherwise.*/
|
||||
bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Main *bmain = CTX_data_main(mContext);
|
||||
Light *lamp = NULL;
|
||||
@@ -1000,10 +1017,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
||||
|
||||
la_id = light->getOriginalId();
|
||||
la_name = light->getName();
|
||||
if (la_name.size())
|
||||
if (la_name.size()) {
|
||||
lamp = (Light *)BKE_light_add(bmain, (char *)la_name.c_str());
|
||||
else
|
||||
}
|
||||
else {
|
||||
lamp = (Light *)BKE_light_add(bmain, (char *)la_id.c_str());
|
||||
}
|
||||
|
||||
if (!lamp) {
|
||||
fprintf(stderr, "Cannot create light.\n");
|
||||
@@ -1087,10 +1106,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
||||
lamp->type = LA_SPOT;
|
||||
lamp->att1 = att1;
|
||||
lamp->att2 = att2;
|
||||
if (IS_EQ(att1, 0.0f) && att2 > 0)
|
||||
if (IS_EQ(att1, 0.0f) && att2 > 0) {
|
||||
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
|
||||
if (IS_EQ(att2, 0.0f) && att1 > 0)
|
||||
}
|
||||
if (IS_EQ(att2, 0.0f) && att1 > 0) {
|
||||
lamp->falloff_type = LA_FALLOFF_INVLINEAR;
|
||||
}
|
||||
lamp->spotsize = DEG2RADF(light->getFallOffAngle().getValue());
|
||||
lamp->spotblend = light->getFallOffExponent().getValue();
|
||||
} break;
|
||||
@@ -1102,10 +1123,12 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
||||
lamp->type = LA_LOCAL;
|
||||
lamp->att1 = att1;
|
||||
lamp->att2 = att2;
|
||||
if (IS_EQ(att1, 0.0f) && att2 > 0)
|
||||
if (IS_EQ(att1, 0.0f) && att2 > 0) {
|
||||
lamp->falloff_type = LA_FALLOFF_INVSQUARE;
|
||||
if (IS_EQ(att2, 0.0f) && att1 > 0)
|
||||
}
|
||||
if (IS_EQ(att2, 0.0f) && att1 > 0) {
|
||||
lamp->falloff_type = LA_FALLOFF_INVLINEAR;
|
||||
}
|
||||
} break;
|
||||
case COLLADAFW::Light::UNDEFINED: {
|
||||
fprintf(stderr, "Current light type is not supported.\n");
|
||||
@@ -1122,8 +1145,9 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
|
||||
/* this function is called only for animations that pass COLLADAFW::validate */
|
||||
bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return anim_importer.write_animation(anim);
|
||||
}
|
||||
@@ -1131,8 +1155,9 @@ bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
|
||||
/* called on post-process stage after writeVisualScenes */
|
||||
bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animationList)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* return true; */
|
||||
return anim_importer.write_animation_list(animationList);
|
||||
@@ -1143,8 +1168,9 @@ bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animat
|
||||
* called on post-process stage after writeVisualScenes */
|
||||
bool DocumentImporter::writeAnimationClip(const COLLADAFW::AnimationClip *animationClip)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
/* TODO: implement import of AnimationClips */
|
||||
@@ -1162,8 +1188,9 @@ bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerDa
|
||||
/* this is called on postprocess, before writeVisualScenes */
|
||||
bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
|
||||
{
|
||||
if (mImportStage == Fetching_Controller_data)
|
||||
if (mImportStage == Fetching_Controller_data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return armature_importer.write_controller(controller);
|
||||
}
|
||||
|
||||
@@ -46,8 +46,9 @@ static std::string getActiveUVLayerName(Object *ob)
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
|
||||
int num_layers = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
|
||||
if (num_layers)
|
||||
if (num_layers) {
|
||||
return std::string(bc_CustomData_get_active_layer_name(&me->ldata, CD_MLOOPUV));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -67,8 +68,9 @@ bool EffectsExporter::hasEffects(Scene *sce)
|
||||
Material *ma = give_current_material(ob, a + 1);
|
||||
|
||||
// no material, but check all of the slots
|
||||
if (!ma)
|
||||
if (!ma) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -79,9 +79,10 @@ bool ErrorHandler::handleError(const COLLADASaxFWL::IError *error)
|
||||
error_context = "File access";
|
||||
}
|
||||
|
||||
else
|
||||
else {
|
||||
isError = (parserError.getSeverity() !=
|
||||
GeneratedSaxParser::ParserError::Severity::SEVERITY_ERROR_NONCRITICAL);
|
||||
}
|
||||
}
|
||||
else if (error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL) {
|
||||
error_context = "Sax FWL";
|
||||
|
||||
@@ -50,8 +50,9 @@ bool ExtraHandler::textData(const char *text, size_t textLength)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
if (currentElement.length() == 0 || currentExtraTags == 0)
|
||||
if (currentElement.length() == 0 || currentExtraTags == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BLI_strncpy(buf, text, textLength + 1);
|
||||
currentExtraTags->addTag(currentElement, std::string(buf));
|
||||
|
||||
@@ -82,8 +82,9 @@ bool ExtraTags::setData(std::string tag, short *data)
|
||||
{
|
||||
bool ok = false;
|
||||
int tmp = asInt(tag, &ok);
|
||||
if (ok)
|
||||
if (ok) {
|
||||
*data = (short)tmp;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -91,8 +92,9 @@ bool ExtraTags::setData(std::string tag, int *data)
|
||||
{
|
||||
bool ok = false;
|
||||
int tmp = asInt(tag, &ok);
|
||||
if (ok)
|
||||
if (ok) {
|
||||
*data = tmp;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -100,8 +102,9 @@ bool ExtraTags::setData(std::string tag, float *data)
|
||||
{
|
||||
bool ok = false;
|
||||
float tmp = asFloat(tag, &ok);
|
||||
if (ok)
|
||||
if (ok) {
|
||||
*data = tmp;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -109,8 +112,9 @@ bool ExtraTags::setData(std::string tag, char *data)
|
||||
{
|
||||
bool ok = false;
|
||||
int tmp = asInt(tag, &ok);
|
||||
if (ok)
|
||||
if (ok) {
|
||||
*data = (char)tmp;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
@@ -311,8 +311,9 @@ static bool collect_vertex_counts_per_poly(Mesh *me,
|
||||
if (p->mat_nr == material_index) {
|
||||
int vertex_count = p->totloop;
|
||||
vcount_list.push_back(vertex_count);
|
||||
if (vertex_count != 3)
|
||||
if (vertex_count != 3) {
|
||||
is_triangulated = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_triangulated;
|
||||
@@ -426,11 +427,13 @@ void GeometryExporter::create_mesh_primitive_list(short material_index,
|
||||
for (int j = 0; j < loop_count; j++) {
|
||||
primitive_list->appendValues(l[j].v);
|
||||
primitive_list->appendValues(normal_indices[j]);
|
||||
if (has_uvs)
|
||||
if (has_uvs) {
|
||||
primitive_list->appendValues(texindex + j);
|
||||
}
|
||||
|
||||
if (has_color)
|
||||
if (has_color) {
|
||||
primitive_list->appendValues(texindex + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,8 +487,9 @@ void GeometryExporter::createVertexColorSource(std::string geom_id, Mesh *me)
|
||||
{
|
||||
/* Find number of vertex color layers */
|
||||
int totlayer_mcol = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
|
||||
if (totlayer_mcol == 0)
|
||||
if (totlayer_mcol == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int map_index = 0;
|
||||
for (int a = 0; a < totlayer_mcol; a++) {
|
||||
|
||||
@@ -52,8 +52,9 @@ bool MaterialsExporter::hasMaterials(Scene *sce)
|
||||
Material *ma = give_current_material(ob, a + 1);
|
||||
|
||||
// no material, but check all of the slots
|
||||
if (!ma)
|
||||
if (!ma) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -68,8 +68,9 @@ template<class Functor> class ForEachMaterialFunctor {
|
||||
|
||||
Material *ma = give_current_material(ob, a + 1);
|
||||
|
||||
if (!ma)
|
||||
if (!ma) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string translated_id = translate_id(id_name(ma));
|
||||
if (find(mMat.begin(), mMat.end(), translated_id) == mMat.end()) {
|
||||
|
||||
@@ -131,22 +131,25 @@ void WVDataWrapper::print()
|
||||
void UVDataWrapper::getUV(int uv_index, float *uv)
|
||||
{
|
||||
int stride = mVData->getStride(0);
|
||||
if (stride == 0)
|
||||
if (stride == 0) {
|
||||
stride = 2;
|
||||
}
|
||||
|
||||
switch (mVData->getType()) {
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
|
||||
COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
|
||||
if (values->empty())
|
||||
if (values->empty()) {
|
||||
return;
|
||||
}
|
||||
uv[0] = (*values)[uv_index * stride];
|
||||
uv[1] = (*values)[uv_index * stride + 1];
|
||||
|
||||
} break;
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
|
||||
COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
|
||||
if (values->empty())
|
||||
if (values->empty()) {
|
||||
return;
|
||||
}
|
||||
uv[0] = (float)(*values)[uv_index * stride];
|
||||
uv[1] = (float)(*values)[uv_index * stride + 1];
|
||||
|
||||
@@ -164,14 +167,16 @@ VCOLDataWrapper::VCOLDataWrapper(COLLADAFW::MeshVertexData &vdata) : mVData(&vda
|
||||
void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
|
||||
{
|
||||
int stride = mVData->getStride(0);
|
||||
if (stride == 0)
|
||||
if (stride == 0) {
|
||||
stride = 3;
|
||||
}
|
||||
|
||||
switch (mVData->getType()) {
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
|
||||
COLLADAFW::ArrayPrimitiveType<float> *values = mVData->getFloatValues();
|
||||
if (values->empty() || values->getCount() <= (v_index * stride + 2))
|
||||
if (values->empty() || values->getCount() <= (v_index * stride + 2)) {
|
||||
return; // xxx need to create an error instead
|
||||
}
|
||||
|
||||
mloopcol->r = unit_float_to_uchar_clamp((*values)[v_index * stride]);
|
||||
mloopcol->g = unit_float_to_uchar_clamp((*values)[v_index * stride + 1]);
|
||||
@@ -180,8 +185,9 @@ void VCOLDataWrapper::get_vcol(int v_index, MLoopCol *mloopcol)
|
||||
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
|
||||
COLLADAFW::ArrayPrimitiveType<double> *values = mVData->getDoubleValues();
|
||||
if (values->empty() || values->getCount() <= (v_index * stride + 2))
|
||||
if (values->empty() || values->getCount() <= (v_index * stride + 2)) {
|
||||
return; // xxx need to create an error instead
|
||||
}
|
||||
|
||||
mloopcol->r = unit_float_to_uchar_clamp((*values)[v_index * stride]);
|
||||
mloopcol->g = unit_float_to_uchar_clamp((*values)[v_index * stride + 1]);
|
||||
@@ -340,8 +346,9 @@ void MeshImporter::read_vertices(COLLADAFW::Mesh *mesh, Mesh *me)
|
||||
}
|
||||
|
||||
int stride = pos.getStride(0);
|
||||
if (stride == 0)
|
||||
if (stride == 0) {
|
||||
stride = 3;
|
||||
}
|
||||
|
||||
me->totvert = pos.getFloatValues()->getCount() / stride;
|
||||
me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, me->totvert);
|
||||
@@ -368,8 +375,9 @@ 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,
|
||||
"Warning: Number of normals %d is different from the number of vertices %d, "
|
||||
@@ -562,8 +570,9 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
|
||||
MEdge *medge;
|
||||
int totedge;
|
||||
|
||||
if (len == 0)
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
totedge = mesh->totedge + len;
|
||||
|
||||
@@ -571,8 +580,9 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
|
||||
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH.emask, CD_DEFAULT, totedge);
|
||||
CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge);
|
||||
|
||||
if (!CustomData_has_layer(&edata, CD_MEDGE))
|
||||
if (!CustomData_has_layer(&edata, CD_MEDGE)) {
|
||||
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
|
||||
}
|
||||
|
||||
CustomData_free(&mesh->edata, mesh->totedge);
|
||||
mesh->edata = edata;
|
||||
@@ -580,8 +590,9 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len)
|
||||
|
||||
/* set default flags */
|
||||
medge = &mesh->medge[mesh->totedge];
|
||||
for (int i = 0; i < len; i++, medge++)
|
||||
for (int i = 0; i < len; i++, medge++) {
|
||||
medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
|
||||
}
|
||||
|
||||
mesh->totedge = totedge;
|
||||
}
|
||||
@@ -688,8 +699,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
||||
// the same for vertces normals
|
||||
unsigned int vertex_normal_indices[3] = {
|
||||
first_normal, normal_indices[1], normal_indices[2]};
|
||||
if (!is_flat_face(vertex_normal_indices, nor, 3))
|
||||
if (!is_flat_face(vertex_normal_indices, nor, 3)) {
|
||||
mpoly->flag |= ME_SMOOTH;
|
||||
}
|
||||
normal_indices++;
|
||||
}
|
||||
|
||||
@@ -700,8 +712,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
||||
}
|
||||
|
||||
// Moving cursor to the next triangle fan.
|
||||
if (mp_has_normals)
|
||||
if (mp_has_normals) {
|
||||
normal_indices += 2;
|
||||
}
|
||||
|
||||
position_indices += 2;
|
||||
}
|
||||
@@ -752,8 +765,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
||||
}
|
||||
|
||||
if (mp_has_normals) {
|
||||
if (!is_flat_face(normal_indices, nor, vcount))
|
||||
if (!is_flat_face(normal_indices, nor, vcount)) {
|
||||
mpoly->flag |= ME_SMOOTH;
|
||||
}
|
||||
}
|
||||
|
||||
if (mp->hasColorIndices()) {
|
||||
@@ -783,8 +797,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
||||
start_index += vcount;
|
||||
prim.totpoly++;
|
||||
|
||||
if (mp_has_normals)
|
||||
if (mp_has_normals) {
|
||||
normal_indices += vcount;
|
||||
}
|
||||
|
||||
position_indices += vcount;
|
||||
}
|
||||
@@ -801,8 +816,9 @@ void MeshImporter::read_polys(COLLADAFW::Mesh *collada_mesh, Mesh *me)
|
||||
continue; // read the lines later after all the rest is done
|
||||
}
|
||||
|
||||
if (mp_has_faces)
|
||||
if (mp_has_faces) {
|
||||
mat_prim_map[mp->getMaterialId()].push_back(prim);
|
||||
}
|
||||
}
|
||||
|
||||
geom_uid_mat_mapping_map[collada_mesh->getUniqueId()] = mat_prim_map;
|
||||
@@ -815,8 +831,9 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData &arr, int i,
|
||||
switch (arr.getType()) {
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: {
|
||||
COLLADAFW::ArrayPrimitiveType<float> *values = arr.getFloatValues();
|
||||
if (values->empty())
|
||||
if (values->empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
v[0] = (*values)[i++];
|
||||
v[1] = (*values)[i++];
|
||||
@@ -830,8 +847,9 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData &arr, int i,
|
||||
} break;
|
||||
case COLLADAFW::MeshVertexData::DATA_TYPE_DOUBLE: {
|
||||
COLLADAFW::ArrayPrimitiveType<double> *values = arr.getDoubleValues();
|
||||
if (values->empty())
|
||||
if (values->empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
v[0] = (float)(*values)[i++];
|
||||
v[1] = (float)(*values)[i++];
|
||||
@@ -862,8 +880,9 @@ bool MeshImporter::is_flat_face(unsigned int *nind, COLLADAFW::MeshVertexData &n
|
||||
|
||||
float dp = dot_v3v3(a, b);
|
||||
|
||||
if (dp < 0.99999f || dp > 1.00001f)
|
||||
if (dp < 0.99999f || dp > 1.00001f) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -871,22 +890,25 @@ bool MeshImporter::is_flat_face(unsigned int *nind, COLLADAFW::MeshVertexData &n
|
||||
|
||||
Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId &geom_uid)
|
||||
{
|
||||
if (uid_object_map.find(geom_uid) != uid_object_map.end())
|
||||
if (uid_object_map.find(geom_uid) != uid_object_map.end()) {
|
||||
return uid_object_map[geom_uid];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Mesh *MeshImporter::get_mesh_by_geom_uid(const COLLADAFW::UniqueId &mesh_uid)
|
||||
{
|
||||
if (uid_mesh_map.find(mesh_uid) != uid_mesh_map.end())
|
||||
if (uid_mesh_map.find(mesh_uid) != uid_mesh_map.end()) {
|
||||
return uid_mesh_map[mesh_uid];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string *MeshImporter::get_geometry_name(const std::string &mesh_name)
|
||||
{
|
||||
if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end())
|
||||
if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end()) {
|
||||
return &this->mesh_geom_map[mesh_name];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -897,18 +919,23 @@ std::string *MeshImporter::get_geometry_name(const std::string &mesh_name)
|
||||
*/
|
||||
static bool bc_has_same_material_configuration(Object *ob1, Object *ob2)
|
||||
{
|
||||
if (ob1->totcol != ob2->totcol)
|
||||
if (ob1->totcol != ob2->totcol) {
|
||||
return false; // not same number of materials
|
||||
if (ob1->totcol == 0)
|
||||
}
|
||||
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])
|
||||
if (ob1->matbits[index] != ob2->matbits[index]) {
|
||||
return false; // shouldn't happen
|
||||
if (ob1->matbits[index] == 0)
|
||||
}
|
||||
if (ob1->matbits[index] == 0) {
|
||||
return false; // shouldn't happen
|
||||
if (ob1->mat[index] != ob2->mat[index])
|
||||
}
|
||||
if (ob1->mat[index] != ob2->mat[index]) {
|
||||
return false; // different material assignment
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -955,8 +982,9 @@ std::vector<Object *> MeshImporter::get_all_users_of(Mesh *reference_mesh)
|
||||
if (bc_is_marked(ob)) {
|
||||
bc_remove_mark(ob);
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
if (me == reference_mesh)
|
||||
if (me == reference_mesh) {
|
||||
mesh_users.push_back(ob);
|
||||
}
|
||||
}
|
||||
}
|
||||
return mesh_users;
|
||||
@@ -1098,8 +1126,9 @@ Object *MeshImporter::create_mesh_object(
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (!uid_mesh_map[*geom_uid])
|
||||
if (!uid_mesh_map[*geom_uid]) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// name Object
|
||||
const std::string &id = node->getName().size() ? node->getName() : node->getOriginalId();
|
||||
|
||||
@@ -223,8 +223,9 @@ void SceneExporter::writeNode(Object *ob)
|
||||
colladaNode.addExtraTechniqueChildParameter("blender", con_tag, "target_id", tar_id);
|
||||
}
|
||||
|
||||
if (cti->flush_constraint_targets)
|
||||
if (cti->flush_constraint_targets) {
|
||||
cti->flush_constraint_targets(con, &targets, 1);
|
||||
}
|
||||
}
|
||||
|
||||
con = con->next;
|
||||
|
||||
@@ -111,8 +111,9 @@ void SkinInfo::borrow_skin_controller_data(const COLLADAFW::SkinControllerData *
|
||||
|
||||
/* cannot transfer data for FloatOrDoubleArray, copy values manually */
|
||||
const COLLADAFW::FloatOrDoubleArray &weight = skin->getWeights();
|
||||
for (unsigned int i = 0; i < weight.getValuesCount(); i++)
|
||||
for (unsigned int i = 0; i < weight.getValuesCount(); i++) {
|
||||
weights.push_back(bc_get_float_value(weight, i));
|
||||
}
|
||||
|
||||
unit_converter->dae_matrix_to_mat4_(bind_shape_matrix, skin->getBindShapeMatrix());
|
||||
}
|
||||
@@ -162,8 +163,9 @@ Object *SkinInfo::create_armature(Main *bmain, Scene *scene, ViewLayer *view_lay
|
||||
|
||||
Object *SkinInfo::set_armature(Object *ob_arm)
|
||||
{
|
||||
if (this->ob_arm)
|
||||
if (this->ob_arm) {
|
||||
return this->ob_arm;
|
||||
}
|
||||
|
||||
this->ob_arm = ob_arm;
|
||||
return ob_arm;
|
||||
@@ -203,14 +205,16 @@ bool SkinInfo::uses_joint_or_descendant(COLLADAFW::Node *node)
|
||||
const COLLADAFW::UniqueId &uid = node->getUniqueId();
|
||||
std::vector<JointData>::iterator it;
|
||||
for (it = joint_data.begin(); it != joint_data.end(); it++) {
|
||||
if ((*it).joint_uid == uid)
|
||||
if ((*it).joint_uid == uid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
COLLADAFW::NodePointerArray &children = node->getChildNodes();
|
||||
for (unsigned int i = 0; i < children.getCount(); i++) {
|
||||
if (uses_joint_or_descendant(children[i]))
|
||||
if (uses_joint_or_descendant(children[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -255,8 +259,9 @@ void SkinInfo::link_armature(bContext *C,
|
||||
const char *name = "Group";
|
||||
|
||||
/* skip joints that have invalid UID */
|
||||
if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID)
|
||||
if ((*it).joint_uid == COLLADAFW::UniqueId::INVALID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* name group by joint node name */
|
||||
|
||||
@@ -326,8 +331,9 @@ void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node *> &root_joint
|
||||
|
||||
/* find if joint node is in the tree belonging to the root_joint */
|
||||
if (find_node_in_tree(joint, root)) {
|
||||
if (std::find(result.begin(), result.end(), root) == result.end())
|
||||
if (std::find(result.begin(), result.end(), root) == result.end()) {
|
||||
result.push_back(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -336,13 +342,15 @@ void SkinInfo::find_root_joints(const std::vector<COLLADAFW::Node *> &root_joint
|
||||
|
||||
bool SkinInfo::find_node_in_tree(COLLADAFW::Node *node, COLLADAFW::Node *tree_root)
|
||||
{
|
||||
if (node == tree_root)
|
||||
if (node == tree_root) {
|
||||
return true;
|
||||
}
|
||||
|
||||
COLLADAFW::NodePointerArray &children = tree_root->getChildNodes();
|
||||
for (unsigned int i = 0; i < children.getCount(); i++) {
|
||||
if (find_node_in_tree(node, children[i]))
|
||||
if (find_node_in_tree(node, children[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -86,8 +86,9 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node &node,
|
||||
UnitConverter converter;
|
||||
double d_obmat[4][4];
|
||||
converter.mat4_to_dae_double(d_obmat, f_obmat);
|
||||
if (limit_precision)
|
||||
if (limit_precision) {
|
||||
bc_sanitize_mat(d_obmat, LIMITTED_PRECISION);
|
||||
}
|
||||
node.addMatrix("transform", d_obmat);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -73,10 +73,12 @@ int collada_export(bContext *C, ExportSettings *export_settings)
|
||||
ViewLayer *view_layer = blender_context.get_view_layer();
|
||||
|
||||
int includeFilter = OB_REL_NONE;
|
||||
if (export_settings->include_armatures)
|
||||
if (export_settings->include_armatures) {
|
||||
includeFilter |= OB_REL_MOD_ARMATURE;
|
||||
if (export_settings->include_children)
|
||||
}
|
||||
if (export_settings->include_children) {
|
||||
includeFilter |= OB_REL_CHILDREN_RECURSIVE;
|
||||
}
|
||||
|
||||
/* Fetch the complete set of exported objects
|
||||
* ATTENTION: Invisible objects will not be exported
|
||||
@@ -98,8 +100,9 @@ int collada_export(bContext *C, ExportSettings *export_settings)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (export_settings->sort_by_name)
|
||||
if (export_settings->sort_by_name) {
|
||||
bc_bubble_sort_by_Object_name(export_settings->export_set);
|
||||
}
|
||||
}
|
||||
|
||||
DocumentExporter exporter(blender_context, export_settings);
|
||||
|
||||
@@ -94,9 +94,11 @@ void UnitConverter::mat4_to_dae_double(double out[4][4], float in[4][4])
|
||||
|
||||
mat4_to_dae(mat, in);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
out[i][j] = mat[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float (&UnitConverter::get_rotation())[4][4]
|
||||
|
||||
@@ -83,13 +83,16 @@ extern "C" {
|
||||
|
||||
float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray &array, unsigned int index)
|
||||
{
|
||||
if (index >= array.getValuesCount())
|
||||
if (index >= array.getValuesCount()) {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT)
|
||||
if (array.getType() == COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT) {
|
||||
return array.getFloatValues()->getData()[index];
|
||||
else
|
||||
}
|
||||
else {
|
||||
return array.getDoubleValues()->getData()[index];
|
||||
}
|
||||
}
|
||||
|
||||
/* copied from /editors/object/object_relations.c */
|
||||
@@ -97,10 +100,12 @@ int bc_test_parent_loop(Object *par, Object *ob)
|
||||
{
|
||||
/* test if 'ob' is a parent somewhere in par's parents */
|
||||
|
||||
if (par == NULL)
|
||||
if (par == NULL) {
|
||||
return 0;
|
||||
if (ob == par)
|
||||
}
|
||||
if (ob == par) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return bc_test_parent_loop(par->parent, ob);
|
||||
}
|
||||
@@ -110,18 +115,22 @@ bool bc_validateConstraints(bConstraint *con)
|
||||
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
||||
|
||||
/* these we can skip completely (invalid constraints...) */
|
||||
if (cti == NULL)
|
||||
if (cti == NULL) {
|
||||
return false;
|
||||
if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))
|
||||
}
|
||||
if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* these constraints can't be evaluated anyway */
|
||||
if (cti->evaluate_constraint == NULL)
|
||||
if (cti->evaluate_constraint == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* influence == 0 should be ignored */
|
||||
if (con->enforce == 0.0f)
|
||||
if (con->enforce == 0.0f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* validation passed */
|
||||
return true;
|
||||
@@ -171,10 +180,12 @@ std::string bc_get_action_id(std::string action_name,
|
||||
std::string axis_separator)
|
||||
{
|
||||
std::string result = action_name + "_" + channel_type;
|
||||
if (ob_name.length() > 0)
|
||||
if (ob_name.length() > 0) {
|
||||
result = ob_name + "_" + result;
|
||||
if (axis_name.length() > 0)
|
||||
}
|
||||
if (axis_name.length() > 0) {
|
||||
result += axis_separator + axis_name;
|
||||
}
|
||||
return translate_id(result);
|
||||
}
|
||||
|
||||
@@ -314,14 +325,16 @@ bool bc_is_root_bone(Bone *aBone, bool deform_bones_only)
|
||||
Bone *root = NULL;
|
||||
Bone *bone = aBone;
|
||||
while (bone) {
|
||||
if (!(bone->flag & BONE_NO_DEFORM))
|
||||
if (!(bone->flag & BONE_NO_DEFORM)) {
|
||||
root = bone;
|
||||
}
|
||||
bone = bone->parent;
|
||||
}
|
||||
return (aBone == root);
|
||||
}
|
||||
else
|
||||
else {
|
||||
return !(aBone->parent);
|
||||
}
|
||||
}
|
||||
|
||||
int bc_get_active_UVLayer(Object *ob)
|
||||
@@ -455,8 +468,9 @@ void bc_triangulate_mesh(Mesh *me)
|
||||
bool bc_is_leaf_bone(Bone *bone)
|
||||
{
|
||||
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
|
||||
if (child->flag & BONE_CONNECTED)
|
||||
if (child->flag & BONE_CONNECTED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -466,8 +480,9 @@ EditBone *bc_get_edit_bone(bArmature *armature, char *name)
|
||||
EditBone *eBone;
|
||||
|
||||
for (eBone = (EditBone *)armature->edbo->first; eBone; eBone = eBone->next) {
|
||||
if (STREQ(name, eBone->name))
|
||||
if (STREQ(name, eBone->name)) {
|
||||
return eBone;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -481,10 +496,12 @@ int bc_set_layer(int bitfield, int layer, bool enable)
|
||||
{
|
||||
int bit = 1u << layer;
|
||||
|
||||
if (enable)
|
||||
if (enable) {
|
||||
bitfield |= bit;
|
||||
else
|
||||
}
|
||||
else {
|
||||
bitfield &= ~bit;
|
||||
}
|
||||
|
||||
return bitfield;
|
||||
}
|
||||
@@ -513,8 +530,9 @@ BoneExtensionManager::~BoneExtensionManager()
|
||||
for (BoneExtensionMap::iterator ext_it = extended_bones->begin();
|
||||
ext_it != extended_bones->end();
|
||||
++ext_it) {
|
||||
if (ext_it->second != NULL)
|
||||
if (ext_it->second != NULL) {
|
||||
delete ext_it->second;
|
||||
}
|
||||
}
|
||||
extended_bones->clear();
|
||||
delete extended_bones;
|
||||
@@ -609,8 +627,9 @@ float *BoneExtended::get_tail()
|
||||
|
||||
inline bool isInteger(const std::string &s)
|
||||
{
|
||||
if (s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+')))
|
||||
if (s.empty() || ((!isdigit(s[0])) && (s[0] != '-') && (s[0] != '+'))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
char *p;
|
||||
strtol(s.c_str(), &p, 10);
|
||||
@@ -706,9 +725,11 @@ void bc_set_IDPropertyMatrix(EditBone *ebone, const char *key, float mat[4][4])
|
||||
|
||||
IDProperty *data = IDP_New(IDP_ARRAY, &val, key);
|
||||
float *array = (float *)IDP_Array(data);
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
array[4 * i + j] = mat[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
IDP_AddToGroup(idgroup, data);
|
||||
}
|
||||
@@ -782,9 +803,11 @@ bool bc_get_property_matrix(Bone *bone, std::string key, float mat[4][4])
|
||||
IDProperty *property = bc_get_IDProperty(bone, key);
|
||||
if (property && property->type == IDP_ARRAY && property->len == 16) {
|
||||
float *array = (float *)IDP_Array(property);
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
mat[i][j] = array[4 * i + j];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -805,8 +828,9 @@ void bc_get_property_vector(Bone *bone, std::string key, float val[3], const flo
|
||||
*/
|
||||
static bool has_custom_props(Bone *bone, bool enabled, std::string key)
|
||||
{
|
||||
if (!enabled)
|
||||
if (!enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bc_get_IDProperty(bone, key + "_x") || bc_get_IDProperty(bone, key + "_y") ||
|
||||
bc_get_IDProperty(bone, key + "_z"));
|
||||
@@ -817,15 +841,18 @@ void bc_enable_fcurves(bAction *act, char *bone_name)
|
||||
FCurve *fcu;
|
||||
char prefix[200];
|
||||
|
||||
if (bone_name)
|
||||
if (bone_name) {
|
||||
BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name);
|
||||
}
|
||||
|
||||
for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) {
|
||||
if (bone_name) {
|
||||
if (STREQLEN(fcu->rna_path, prefix, strlen(prefix)))
|
||||
if (STREQLEN(fcu->rna_path, prefix, strlen(prefix))) {
|
||||
fcu->flag &= ~FCURVE_DISABLED;
|
||||
else
|
||||
}
|
||||
else {
|
||||
fcu->flag |= FCURVE_DISABLED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fcu->flag &= ~FCURVE_DISABLED;
|
||||
@@ -853,8 +880,9 @@ bool bc_bone_matrix_local_get(Object *ob, Bone *bone, Matrix &mat, bool for_open
|
||||
invert_m4_m4(ipar, parchan->pose_mat);
|
||||
mul_m4_m4m4(mat, ipar, pchan->pose_mat);
|
||||
}
|
||||
else
|
||||
else {
|
||||
copy_m4_m4(mat, pchan->pose_mat);
|
||||
}
|
||||
|
||||
/* OPEN_SIM_COMPATIBILITY
|
||||
* AFAIK animation to second life is via BVH, but no
|
||||
@@ -882,8 +910,9 @@ bool bc_is_animated(BCMatrixSampleMap &values)
|
||||
{
|
||||
static float MIN_DISTANCE = 0.00001;
|
||||
|
||||
if (values.size() < 2)
|
||||
if (values.size() < 2) {
|
||||
return false; /* need at least 2 entries to be not flat */
|
||||
}
|
||||
|
||||
BCMatrixSampleMap::iterator it;
|
||||
const BCMatrix *refmat = NULL;
|
||||
@@ -895,8 +924,9 @@ bool bc_is_animated(BCMatrixSampleMap &values)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!matrix->in_range(*refmat, MIN_DISTANCE))
|
||||
if (!matrix->in_range(*refmat, MIN_DISTANCE)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -906,21 +936,25 @@ bool bc_has_animations(Object *ob)
|
||||
/* Check for object, light and camera transform animations */
|
||||
if ((bc_getSceneObjectAction(ob) && bc_getSceneObjectAction(ob)->curves.first) ||
|
||||
(bc_getSceneLightAction(ob) && bc_getSceneLightAction(ob)->curves.first) ||
|
||||
(bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first))
|
||||
(bc_getSceneCameraAction(ob) && bc_getSceneCameraAction(ob)->curves.first)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check Material Effect parameter animations. */
|
||||
for (int a = 0; a < ob->totcol; a++) {
|
||||
Material *ma = give_current_material(ob, a + 1);
|
||||
if (!ma)
|
||||
if (!ma) {
|
||||
continue;
|
||||
if (ma->adt && ma->adt->action && ma->adt->action->curves.first)
|
||||
}
|
||||
if (ma->adt && ma->adt->action && ma->adt->action->curves.first) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Key *key = BKE_key_from_object(ob);
|
||||
if ((key && key->adt && key->adt->action) && key->adt->action->curves.first)
|
||||
if ((key && key->adt && key->adt->action) && key->adt->action->curves.first) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -932,8 +966,9 @@ bool bc_has_animations(Scene *sce, LinkNode *export_set)
|
||||
for (node = export_set; node; node = node->next) {
|
||||
Object *ob = (Object *)node->link;
|
||||
|
||||
if (bc_has_animations(ob))
|
||||
if (bc_has_animations(ob)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -1032,12 +1067,15 @@ void bc_create_restpose_mat(BCExportSettings &export_settings,
|
||||
}
|
||||
|
||||
if (export_settings.get_keep_bind_info()) {
|
||||
if (bc_get_IDProperty(bone, "restpose_rot_x"))
|
||||
if (bc_get_IDProperty(bone, "restpose_rot_x")) {
|
||||
rot[0] = DEG2RADF(bc_get_property(bone, "restpose_rot_x", 0));
|
||||
if (bc_get_IDProperty(bone, "restpose_rot_y"))
|
||||
}
|
||||
if (bc_get_IDProperty(bone, "restpose_rot_y")) {
|
||||
rot[1] = DEG2RADF(bc_get_property(bone, "restpose_rot_y", 0));
|
||||
if (bc_get_IDProperty(bone, "restpose_rot_z"))
|
||||
}
|
||||
if (bc_get_IDProperty(bone, "restpose_rot_z")) {
|
||||
rot[2] = DEG2RADF(bc_get_property(bone, "restpose_rot_z", 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (export_settings.get_keep_bind_info()) {
|
||||
@@ -1052,12 +1090,13 @@ void bc_create_restpose_mat(BCExportSettings &export_settings,
|
||||
*/
|
||||
void bc_sanitize_mat(float mat[4][4], int precision)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
double val = (double)mat[i][j];
|
||||
val = double_round(val, precision);
|
||||
mat[i][j] = (float)val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bc_sanitize_v3(float v[3], int precision)
|
||||
@@ -1071,9 +1110,11 @@ void bc_sanitize_v3(float v[3], int precision)
|
||||
|
||||
void bc_sanitize_mat(double mat[4][4], int precision)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
mat[i][j] = double_round(mat[i][j], precision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bc_sanitize_v3(double v[3], int precision)
|
||||
@@ -1085,23 +1126,29 @@ void bc_sanitize_v3(double v[3], int precision)
|
||||
|
||||
void bc_copy_m4_farray(float r[4][4], float *a)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
r[i][j] = *a++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bc_copy_farray_m4(float *r, float a[4][4])
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
*r++ = a[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bc_copy_darray_m4d(double *r, double a[4][4])
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
*r++ = a[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bc_copy_v44_m4d(std::vector<std::vector<double>> &r, double (&a)[4][4])
|
||||
|
||||
@@ -92,8 +92,9 @@ inline bAction *bc_getSceneObjectAction(Object *ob)
|
||||
/* Returns Light Action or NULL */
|
||||
inline bAction *bc_getSceneLightAction(Object *ob)
|
||||
{
|
||||
if (ob->type != OB_LAMP)
|
||||
if (ob->type != OB_LAMP) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Light *lamp = (Light *)ob->data;
|
||||
return (lamp->adt && lamp->adt->action) ? lamp->adt->action : NULL;
|
||||
@@ -102,8 +103,9 @@ inline bAction *bc_getSceneLightAction(Object *ob)
|
||||
/* Return Camera Action or NULL */
|
||||
inline bAction *bc_getSceneCameraAction(Object *ob)
|
||||
{
|
||||
if (ob->type != OB_CAMERA)
|
||||
if (ob->type != OB_CAMERA) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Camera *camera = (Camera *)ob->data;
|
||||
return (camera->adt && camera->adt->action) ? camera->adt->action : NULL;
|
||||
@@ -112,16 +114,18 @@ inline bAction *bc_getSceneCameraAction(Object *ob)
|
||||
/* returns material action or NULL */
|
||||
inline bAction *bc_getSceneMaterialAction(Material *ma)
|
||||
{
|
||||
if (ma == NULL)
|
||||
if (ma == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (ma->adt && ma->adt->action) ? ma->adt->action : NULL;
|
||||
}
|
||||
|
||||
inline void bc_setSceneObjectAction(bAction *action, Object *ob)
|
||||
{
|
||||
if (ob->adt)
|
||||
if (ob->adt) {
|
||||
ob->adt->action = action;
|
||||
}
|
||||
}
|
||||
|
||||
std::string bc_get_action_id(std::string action_name,
|
||||
@@ -167,8 +171,9 @@ inline std::string bc_string_after(const std::string &s, const char c)
|
||||
|
||||
inline bool bc_startswith(std::string const &value, std::string const &starting)
|
||||
{
|
||||
if (starting.size() > value.size())
|
||||
if (starting.size() > value.size()) {
|
||||
return false;
|
||||
}
|
||||
return (value.substr(0, starting.size()) == starting);
|
||||
}
|
||||
|
||||
|
||||
@@ -209,8 +209,9 @@ static void applyarmature_process_selected_rec(bArmature *arm,
|
||||
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name);
|
||||
const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(pose_eval, bone->name);
|
||||
|
||||
if (!pchan || !pchan_eval)
|
||||
if (!pchan || !pchan_eval) {
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyArmature_ParentState new_pstate = {.bone = bone};
|
||||
|
||||
|
||||
@@ -104,8 +104,9 @@ void AppCanvas::init()
|
||||
void AppCanvas::postDraw()
|
||||
{
|
||||
for (unsigned int i = 0; i < _StyleModules.size(); i++) {
|
||||
if (!_StyleModules[i]->getDisplayed() || !_Layers[i])
|
||||
if (!_StyleModules[i]->getDisplayed() || !_Layers[i]) {
|
||||
continue;
|
||||
}
|
||||
_Layers[i]->ScaleThickness(thickness());
|
||||
}
|
||||
Canvas::postDraw();
|
||||
@@ -152,12 +153,14 @@ void AppCanvas::readColorPixels(int x, int y, int w, int h, RGBImage &oImage) co
|
||||
int ii, jj;
|
||||
for (int j = 0; j < h; j++) {
|
||||
jj = (int)((y - ymin + j) * yfac);
|
||||
if (jj < 0 || jj >= recty)
|
||||
if (jj < 0 || jj >= recty) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < w; i++) {
|
||||
ii = (int)((x - xmin + i) * xfac);
|
||||
if (ii < 0 || ii >= rectx)
|
||||
if (ii < 0 || ii >= rectx) {
|
||||
continue;
|
||||
}
|
||||
memcpy(
|
||||
rgb + (w * j + i) * 3, _pass_diffuse.buf + (rectx * jj + ii) * 3, sizeof(float) * 3);
|
||||
}
|
||||
@@ -200,12 +203,14 @@ void AppCanvas::readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) c
|
||||
int ii, jj;
|
||||
for (int j = 0; j < h; j++) {
|
||||
jj = (int)((y - ymin + j) * yfac);
|
||||
if (jj < 0 || jj >= recty)
|
||||
if (jj < 0 || jj >= recty) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < w; i++) {
|
||||
ii = (int)((x - xmin + i) * xfac);
|
||||
if (ii < 0 || ii >= rectx)
|
||||
if (ii < 0 || ii >= rectx) {
|
||||
continue;
|
||||
}
|
||||
z[w * j + i] = _pass_z.buf[rectx * jj + ii];
|
||||
}
|
||||
}
|
||||
@@ -215,10 +220,12 @@ void AppCanvas::readDepthPixels(int x, int y, int w, int h, GrayImage &oImage) c
|
||||
|
||||
void AppCanvas::RenderStroke(Stroke *iStroke)
|
||||
{
|
||||
if (_basic)
|
||||
if (_basic) {
|
||||
iStroke->RenderBasic(_Renderer);
|
||||
else
|
||||
}
|
||||
else {
|
||||
iStroke->Render(_Renderer);
|
||||
}
|
||||
}
|
||||
|
||||
void AppCanvas::update()
|
||||
|
||||
@@ -136,8 +136,9 @@ Controller::~Controller()
|
||||
{
|
||||
if (NULL != _RootNode) {
|
||||
int ref = _RootNode->destroy();
|
||||
if (0 == ref)
|
||||
if (0 == ref) {
|
||||
delete _RootNode;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -184,8 +185,9 @@ Controller::~Controller()
|
||||
|
||||
void Controller::setView(AppView *iView)
|
||||
{
|
||||
if (NULL == iView)
|
||||
if (NULL == iView) {
|
||||
return;
|
||||
}
|
||||
|
||||
_pView = iView;
|
||||
_Canvas->setViewer(_pView);
|
||||
@@ -279,16 +281,19 @@ int Controller::LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph
|
||||
_pView->setModel(_RootNode);
|
||||
//_pView->FitBBox();
|
||||
|
||||
if (_pRenderMonitor->testBreak())
|
||||
if (_pRenderMonitor->testBreak()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_EnableViewMapCache) {
|
||||
|
||||
NodeCamera *cam;
|
||||
if (g_freestyle.proj[3][3] != 0.0)
|
||||
if (g_freestyle.proj[3][3] != 0.0) {
|
||||
cam = new NodeOrthographicCamera;
|
||||
else
|
||||
}
|
||||
else {
|
||||
cam = new NodePerspectiveCamera;
|
||||
}
|
||||
double proj[16];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
@@ -389,8 +394,9 @@ void Controller::ClearRootNode()
|
||||
_pView->DetachModel();
|
||||
if (NULL != _RootNode) {
|
||||
int ref = _RootNode->destroy();
|
||||
if (0 == ref)
|
||||
if (0 == ref) {
|
||||
_RootNode->addRef();
|
||||
}
|
||||
_RootNode->clearBBox();
|
||||
}
|
||||
}
|
||||
@@ -460,8 +466,9 @@ void Controller::DeleteViewMap(bool freeCache)
|
||||
|
||||
void Controller::ComputeViewMap()
|
||||
{
|
||||
if (!_ListOfModels.size())
|
||||
if (!_ListOfModels.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DeleteViewMap(true);
|
||||
|
||||
@@ -520,8 +527,9 @@ void Controller::ComputeViewMap()
|
||||
}
|
||||
|
||||
int viewport[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
viewport[i] = g_freestyle.viewport[i];
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (G.debug & G_DEBUG_FREESTYLE) {
|
||||
@@ -554,8 +562,9 @@ void Controller::ComputeViewMap()
|
||||
printf("Feature lines : %lf\n", duration);
|
||||
}
|
||||
|
||||
if (_pRenderMonitor->testBreak())
|
||||
if (_pRenderMonitor->testBreak()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Builds the view map structure from the flagged WSEdge structure:
|
||||
//----------------------------------------------------------
|
||||
@@ -863,8 +872,9 @@ bool Controller::getComputeSteerableViewMapFlag() const
|
||||
|
||||
int Controller::DrawStrokes()
|
||||
{
|
||||
if (_ViewMap == 0)
|
||||
if (_ViewMap == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (G.debug & G_DEBUG_FREESTYLE) {
|
||||
cout << "\n=== Stroke drawing ===" << endl;
|
||||
@@ -1047,15 +1057,17 @@ string Controller::getModulesDir() const
|
||||
|
||||
void Controller::resetInterpreter()
|
||||
{
|
||||
if (_inter)
|
||||
if (_inter) {
|
||||
_inter->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Controller::displayDensityCurves(int x, int y)
|
||||
{
|
||||
SteerableViewMap *svm = _Canvas->getSteerableViewMap();
|
||||
if (!svm)
|
||||
if (!svm) {
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int i, j;
|
||||
typedef vector<Vec3r> densityCurve;
|
||||
@@ -1065,8 +1077,9 @@ void Controller::displayDensityCurves(int x, int y)
|
||||
// collect the curves values
|
||||
unsigned nbCurves = svm->getNumberOfOrientations() + 1;
|
||||
unsigned nbPoints = svm->getNumberOfPyramidLevels();
|
||||
if (!nbPoints)
|
||||
if (!nbPoints) {
|
||||
return;
|
||||
}
|
||||
|
||||
// build the density/nbLevels curves for each orientation
|
||||
for (i = 0; i < nbCurves; ++i) {
|
||||
|
||||
@@ -156,16 +156,20 @@ int BlenderFileLoader::countClippedFaces(float v1[3], float v2[3], float v3[3],
|
||||
numTris = 2; // tetragon
|
||||
break;
|
||||
case 2:
|
||||
if (sum == 0)
|
||||
if (sum == 0) {
|
||||
numTris = 3; // pentagon
|
||||
else
|
||||
}
|
||||
else {
|
||||
numTris = 1; // triangle
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (sum == 3 || sum == -3)
|
||||
if (sum == 3 || sum == -3) {
|
||||
numTris = 0;
|
||||
else
|
||||
}
|
||||
else {
|
||||
numTris = 2; // tetragon
|
||||
}
|
||||
break;
|
||||
}
|
||||
return numTris;
|
||||
@@ -188,8 +192,9 @@ void BlenderFileLoader::clipLine(float v1[3], float v2[3], float c[3], float z)
|
||||
q = v1;
|
||||
}
|
||||
double d[3];
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int i = 0; i < 3; i++) {
|
||||
d[i] = q[i] - p[i];
|
||||
}
|
||||
double t = (z - p[2]) / d[2];
|
||||
c[0] = p[0] + t * d[0];
|
||||
c[1] = p[1] + t * d[1];
|
||||
@@ -303,11 +308,13 @@ void BlenderFileLoader::addTriangle(struct LoaderState *ls,
|
||||
|
||||
// update the bounding box
|
||||
for (j = 0; j < 3; j++) {
|
||||
if (ls->minBBox[j] > ls->pv[j])
|
||||
if (ls->minBBox[j] > ls->pv[j]) {
|
||||
ls->minBBox[j] = ls->pv[j];
|
||||
}
|
||||
|
||||
if (ls->maxBBox[j] < ls->pv[j])
|
||||
if (ls->maxBBox[j] < ls->pv[j]) {
|
||||
ls->maxBBox[j] = ls->pv[j];
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -329,14 +336,18 @@ void BlenderFileLoader::addTriangle(struct LoaderState *ls,
|
||||
ls->pmi++;
|
||||
}
|
||||
|
||||
if (fm)
|
||||
if (fm) {
|
||||
marks |= IndexedFaceSet::FACE_MARK;
|
||||
if (em1)
|
||||
}
|
||||
if (em1) {
|
||||
marks |= IndexedFaceSet::EDGE_MARK_V1V2;
|
||||
if (em2)
|
||||
}
|
||||
if (em2) {
|
||||
marks |= IndexedFaceSet::EDGE_MARK_V2V3;
|
||||
if (em3)
|
||||
}
|
||||
if (em3) {
|
||||
marks |= IndexedFaceSet::EDGE_MARK_V3V1;
|
||||
}
|
||||
*(ls->pm++) = marks;
|
||||
}
|
||||
|
||||
@@ -543,8 +554,9 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
|
||||
}
|
||||
|
||||
unsigned int numTris = countClippedFaces(v1, v2, v3, clip);
|
||||
if (numTris == 0)
|
||||
if (numTris == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool fm = (ffa) ? (ffa[lt->poly].flag & FREESTYLE_FACE_MARK) != 0 : false;
|
||||
bool em1 = false, em2 = false, em3 = false;
|
||||
@@ -688,8 +700,9 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *me, int id)
|
||||
detri.v = zero;
|
||||
detri.n = 0;
|
||||
for (unsigned int j = 0; j < viSize; j += 3) {
|
||||
if (i == j)
|
||||
if (i == j) {
|
||||
continue;
|
||||
}
|
||||
vi0 = cleanVIndices[j];
|
||||
vi1 = cleanVIndices[j + 1];
|
||||
vi2 = cleanVIndices[j + 2];
|
||||
|
||||
@@ -219,8 +219,9 @@ float BlenderStrokeRenderer::get_stroke_vertex_z(void) const
|
||||
{
|
||||
float z = _z;
|
||||
BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
|
||||
if (!(_z < _z_delta * 100000.0f))
|
||||
if (!(_z < _z_delta * 100000.0f)) {
|
||||
self->_z_delta *= 10.0f;
|
||||
}
|
||||
self->_z += _z_delta;
|
||||
return -z;
|
||||
}
|
||||
@@ -472,8 +473,9 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
|
||||
|
||||
// count visible faces and strip segments
|
||||
test_strip_visibility(strip_vertices, &visible_faces, &visible_segments);
|
||||
if (visible_faces == 0)
|
||||
if (visible_faces == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
totvert += visible_faces + visible_segments * 2;
|
||||
totedge += visible_faces * 2 + visible_segments;
|
||||
@@ -509,14 +511,18 @@ bool BlenderStrokeRenderer::test_triangle_visibility(StrokeVertexRep *svRep[3])
|
||||
xl = xu = yl = yu = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
p = svRep[i]->point2d();
|
||||
if (p[0] < 0.0)
|
||||
if (p[0] < 0.0) {
|
||||
xl++;
|
||||
else if (p[0] > _width)
|
||||
}
|
||||
else if (p[0] > _width) {
|
||||
xu++;
|
||||
if (p[1] < 0.0)
|
||||
}
|
||||
if (p[1] < 0.0) {
|
||||
yl++;
|
||||
else if (p[1] > _height)
|
||||
}
|
||||
else if (p[1] > _height) {
|
||||
yu++;
|
||||
}
|
||||
}
|
||||
return !(xl == 3 || xu == 3 || yl == 3 || yu == 3);
|
||||
}
|
||||
@@ -545,8 +551,9 @@ void BlenderStrokeRenderer::test_strip_visibility(Strip::vertex_container &strip
|
||||
svRep[2] = *(v[2]);
|
||||
if (test_triangle_visibility(svRep)) {
|
||||
(*visible_faces)++;
|
||||
if (!visible)
|
||||
if (!visible) {
|
||||
(*visible_segments)++;
|
||||
}
|
||||
visible = true;
|
||||
}
|
||||
else {
|
||||
@@ -671,8 +678,9 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
|
||||
|
||||
// count visible faces and strip segments
|
||||
test_strip_visibility(strip_vertices, &visible_faces, &visible_segments);
|
||||
if (visible_faces == 0)
|
||||
if (visible_faces == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
v[0] = strip_vertices.begin();
|
||||
v[1] = v[0] + 1;
|
||||
@@ -869,8 +877,9 @@ Object *BlenderStrokeRenderer::NewMesh() const
|
||||
Render *BlenderStrokeRenderer::RenderScene(Render * /*re*/, bool render)
|
||||
{
|
||||
Camera *camera = (Camera *)freestyle_scene->camera->data;
|
||||
if (camera->clip_end < _z)
|
||||
if (camera->clip_end < _z) {
|
||||
camera->clip_end = _z + _z_delta * 100.0f;
|
||||
}
|
||||
#if 0
|
||||
if (G.debug & G_DEBUG_FREESTYLE) {
|
||||
cout << "clip_start " << camera->clip_start << ", clip_end " << camera->clip_end << endl;
|
||||
|
||||
@@ -99,8 +99,9 @@ static bCallbackFuncStore load_post_callback_funcstore = {
|
||||
|
||||
void FRS_initialize()
|
||||
{
|
||||
if (freestyle_is_initialized)
|
||||
if (freestyle_is_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
pathconfig = new Config::Path;
|
||||
controller = new Controller();
|
||||
@@ -166,9 +167,10 @@ static void init_view(Render *re)
|
||||
cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl;
|
||||
cout << "Width : " << width << endl;
|
||||
cout << "Height : " << height << endl;
|
||||
if (re->r.mode & R_BORDER)
|
||||
if (re->r.mode & R_BORDER) {
|
||||
cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")"
|
||||
<< endl;
|
||||
}
|
||||
cout << "Unit line thickness : " << thickness << " pixel(s)" << endl;
|
||||
}
|
||||
}
|
||||
@@ -196,8 +198,9 @@ static char *escape_quotes(char *name)
|
||||
char *s = (char *)MEM_mallocN(strlen(name) * 2 + 1, "escape_quotes");
|
||||
char *p = s;
|
||||
while (*name) {
|
||||
if (*name == '\'')
|
||||
if (*name == '\'') {
|
||||
*(p++) = '\\';
|
||||
}
|
||||
*(p++) = *(name++);
|
||||
}
|
||||
*p = '\0';
|
||||
@@ -231,54 +234,71 @@ static bool test_edge_type_conditions(struct edge_type_condition *conditions,
|
||||
int num_non_target_negative_conditions = 0;
|
||||
|
||||
for (int i = 0; i < num_edge_types; i++) {
|
||||
if (conditions[i].edge_type == target)
|
||||
if (conditions[i].edge_type == target) {
|
||||
target_condition = conditions[i].value;
|
||||
else if (conditions[i].value > 0)
|
||||
}
|
||||
else if (conditions[i].value > 0) {
|
||||
++num_non_target_positive_conditions;
|
||||
else if (conditions[i].value < 0)
|
||||
}
|
||||
else if (conditions[i].value < 0) {
|
||||
++num_non_target_negative_conditions;
|
||||
}
|
||||
}
|
||||
if (distinct) {
|
||||
// In this case, the 'target' edge type is assumed to appear on distinct edge
|
||||
// of its own and never together with other edge types.
|
||||
if (logical_and) {
|
||||
if (num_non_target_positive_conditions > 0)
|
||||
if (num_non_target_positive_conditions > 0) {
|
||||
return false;
|
||||
if (target_condition > 0)
|
||||
}
|
||||
if (target_condition > 0) {
|
||||
return true;
|
||||
if (target_condition < 0)
|
||||
}
|
||||
if (target_condition < 0) {
|
||||
return false;
|
||||
if (num_non_target_negative_conditions > 0)
|
||||
}
|
||||
if (num_non_target_negative_conditions > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (target_condition > 0)
|
||||
if (target_condition > 0) {
|
||||
return true;
|
||||
if (num_non_target_negative_conditions > 0)
|
||||
}
|
||||
if (num_non_target_negative_conditions > 0) {
|
||||
return true;
|
||||
if (target_condition < 0)
|
||||
}
|
||||
if (target_condition < 0) {
|
||||
return false;
|
||||
if (num_non_target_positive_conditions > 0)
|
||||
}
|
||||
if (num_non_target_positive_conditions > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// In this case, the 'target' edge type may appear together with other edge types.
|
||||
if (target_condition > 0)
|
||||
if (target_condition > 0) {
|
||||
return true;
|
||||
if (target_condition < 0)
|
||||
}
|
||||
if (target_condition < 0) {
|
||||
return true;
|
||||
}
|
||||
if (logical_and) {
|
||||
if (num_non_target_positive_conditions > 0)
|
||||
if (num_non_target_positive_conditions > 0) {
|
||||
return false;
|
||||
if (num_non_target_negative_conditions > 0)
|
||||
}
|
||||
if (num_non_target_negative_conditions > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (num_non_target_negative_conditions > 0)
|
||||
if (num_non_target_negative_conditions > 0) {
|
||||
return true;
|
||||
if (num_non_target_positive_conditions > 0)
|
||||
}
|
||||
if (num_non_target_positive_conditions > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -291,10 +311,12 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
|
||||
re->stats_draw(re->sdh, &re->i);
|
||||
re->i.infostr = NULL;
|
||||
if (controller->LoadMesh(
|
||||
re, view_layer, depsgraph)) // returns if scene cannot be loaded or if empty
|
||||
re, view_layer, depsgraph)) { // returns if scene cannot be loaded or if empty
|
||||
return;
|
||||
if (re->test_break(re->tbh))
|
||||
}
|
||||
if (re->test_break(re->tbh)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add style modules
|
||||
FreestyleConfig *config = &view_layer->freestyle_config;
|
||||
@@ -316,8 +338,9 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
|
||||
const char *id_name = module_conf->script->id.name + 2;
|
||||
if (G.debug & G_DEBUG_FREESTYLE) {
|
||||
cout << " " << layer_count + 1 << ": " << id_name;
|
||||
if (module_conf->script->name)
|
||||
if (module_conf->script->name) {
|
||||
cout << " (" << module_conf->script->name << ")";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
controller->InsertStyleModule(layer_count, id_name, module_conf->script);
|
||||
@@ -373,12 +396,15 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
|
||||
else {
|
||||
// conditions for feature edge selection by edge types
|
||||
for (int i = 0; i < num_edge_types; i++) {
|
||||
if (!(lineset->edge_types & conditions[i].edge_type))
|
||||
if (!(lineset->edge_types & conditions[i].edge_type)) {
|
||||
conditions[i].value = 0; // no condition specified
|
||||
else if (!(lineset->exclude_edge_types & conditions[i].edge_type))
|
||||
}
|
||||
else if (!(lineset->exclude_edge_types & conditions[i].edge_type)) {
|
||||
conditions[i].value = 1; // condition: X
|
||||
else
|
||||
}
|
||||
else {
|
||||
conditions[i].value = -1; // condition: NOT X
|
||||
}
|
||||
}
|
||||
// logical operator for the selection conditions
|
||||
bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0);
|
||||
@@ -388,8 +414,9 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
|
||||
// Inclusive equivalent using De Morgan's laws:
|
||||
// - NOT (X OR Y) --> (NOT X) AND (NOT Y)
|
||||
// - NOT (X AND Y) --> (NOT X) OR (NOT Y)
|
||||
for (int i = 0; i < num_edge_types; i++)
|
||||
for (int i = 0; i < num_edge_types; i++) {
|
||||
conditions[i].value *= -1;
|
||||
}
|
||||
logical_and = !logical_and;
|
||||
}
|
||||
if (test_edge_type_conditions(
|
||||
@@ -470,8 +497,9 @@ static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
|
||||
cout << " Z = " << (z ? "enabled" : "disabled") << endl;
|
||||
}
|
||||
|
||||
if (controller->hitViewMapCache())
|
||||
if (controller->hitViewMapCache()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// compute view map
|
||||
re->i.infostr = IFACE_("Freestyle: View map creation");
|
||||
@@ -486,8 +514,9 @@ void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_r
|
||||
float *src, *dest, *pixSrc, *pixDest;
|
||||
int x, y, rectx, recty;
|
||||
|
||||
if (freestyle_render == NULL || freestyle_render->result == NULL)
|
||||
if (freestyle_render == NULL || freestyle_render->result == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
rl = render_get_active_layer(freestyle_render, freestyle_render->result);
|
||||
if (!rl) {
|
||||
@@ -553,8 +582,9 @@ static int displayed_layer_count(ViewLayer *view_layer)
|
||||
(FreestyleModuleConfig *)view_layer->freestyle_config.modules.first;
|
||||
module;
|
||||
module = module->next) {
|
||||
if (module->script && module->is_displayed)
|
||||
if (module->script && module->is_displayed) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FREESTYLE_CONTROL_EDITOR_MODE:
|
||||
@@ -562,8 +592,9 @@ static int displayed_layer_count(ViewLayer *view_layer)
|
||||
(FreestyleLineSet *)view_layer->freestyle_config.linesets.first;
|
||||
lineset;
|
||||
lineset = lineset->next) {
|
||||
if (lineset->flags & FREESTYLE_LINESET_ENABLED)
|
||||
if (lineset->flags & FREESTYLE_LINESET_ENABLED) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -599,8 +630,9 @@ Render *FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer, int render)
|
||||
{
|
||||
Render *freestyle_render = NULL;
|
||||
|
||||
if (!render)
|
||||
if (!render) {
|
||||
return controller->RenderStrokes(re, false);
|
||||
}
|
||||
|
||||
RenderMonitor monitor(re);
|
||||
controller->setRenderMonitor(&monitor);
|
||||
@@ -704,17 +736,20 @@ void FRS_copy_active_lineset(FreestyleConfig *config)
|
||||
|
||||
void FRS_paste_active_lineset(FreestyleConfig *config)
|
||||
{
|
||||
if (!lineset_copied)
|
||||
if (!lineset_copied) {
|
||||
return;
|
||||
}
|
||||
|
||||
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(config);
|
||||
|
||||
if (lineset) {
|
||||
if (lineset->linestyle)
|
||||
if (lineset->linestyle) {
|
||||
id_us_min(&lineset->linestyle->id);
|
||||
}
|
||||
lineset->linestyle = lineset_buffer.linestyle;
|
||||
if (lineset->linestyle)
|
||||
if (lineset->linestyle) {
|
||||
id_us_plus(&lineset->linestyle->id);
|
||||
}
|
||||
lineset->flags = lineset_buffer.flags;
|
||||
lineset->selection = lineset_buffer.selection;
|
||||
lineset->qi = lineset_buffer.qi;
|
||||
|
||||
@@ -59,10 +59,12 @@ template<class Point> class BBox {
|
||||
return;
|
||||
}
|
||||
for (unsigned int i = 0; i < Point::dim(); i++) {
|
||||
if (p[i] < _min[i])
|
||||
if (p[i] < _min[i]) {
|
||||
_min[i] = p[i];
|
||||
else if (p[i] > _max[i])
|
||||
}
|
||||
else if (p[i] > _max[i]) {
|
||||
_max[i] = p[i];
|
||||
}
|
||||
}
|
||||
_empty = false;
|
||||
}
|
||||
@@ -106,10 +108,12 @@ template<class Point> class BBox {
|
||||
}
|
||||
else {
|
||||
for (unsigned int i = 0; i < Point::dim(); i++) {
|
||||
if (b.getMin()[i] < _min[i])
|
||||
if (b.getMin()[i] < _min[i]) {
|
||||
_min[i] = b.getMin()[i];
|
||||
if (b.getMax()[i] > _max[i])
|
||||
}
|
||||
if (b.getMax()[i] > _max[i]) {
|
||||
_max[i] = b.getMax()[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@@ -117,11 +121,13 @@ template<class Point> class BBox {
|
||||
|
||||
inline bool inside(const Point &p)
|
||||
{
|
||||
if (empty())
|
||||
if (empty()) {
|
||||
return false;
|
||||
}
|
||||
for (unsigned int i = 0; i < Point::dim(); i++) {
|
||||
if ((_min[i] > p[i]) || (_max[i] < p[i]))
|
||||
if ((_min[i] > p[i]) || (_max[i] < p[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,14 +37,16 @@ BezierCurveSegment::~BezierCurveSegment()
|
||||
void BezierCurveSegment::AddControlPoint(const Vec2d &iPoint)
|
||||
{
|
||||
_ControlPolygon.push_back(iPoint);
|
||||
if (_ControlPolygon.size() == 4)
|
||||
if (_ControlPolygon.size() == 4) {
|
||||
Build();
|
||||
}
|
||||
}
|
||||
|
||||
void BezierCurveSegment::Build()
|
||||
{
|
||||
if (_ControlPolygon.size() != 4)
|
||||
if (_ControlPolygon.size() != 4) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute the rightmost part of the matrix:
|
||||
vector<Vec2d>::const_iterator p0, p1, p2, p3;
|
||||
@@ -92,8 +94,9 @@ BezierCurve::BezierCurve(vector<Vec2d> &iPoints, double error)
|
||||
int i = 0;
|
||||
vector<Vec2d>::iterator v, vend;
|
||||
for (v = curve.begin(), vend = curve.end(); v != vend; ++v) {
|
||||
if ((i == 0) || (i % 4 != 0))
|
||||
if ((i == 0) || (i % 4 != 0)) {
|
||||
AddControlPoint(*v);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -102,11 +105,13 @@ BezierCurve::~BezierCurve()
|
||||
{
|
||||
if (!_Segments.empty()) {
|
||||
vector<BezierCurveSegment *>::iterator v, vend;
|
||||
for (v = _Segments.begin(), vend = _Segments.end(); v != vend; ++v)
|
||||
for (v = _Segments.begin(), vend = _Segments.end(); v != vend; ++v) {
|
||||
delete *v;
|
||||
}
|
||||
}
|
||||
if (_currentSegment)
|
||||
if (_currentSegment) {
|
||||
delete _currentSegment;
|
||||
}
|
||||
}
|
||||
|
||||
void BezierCurve::AddControlPoint(const Vec2d &iPoint)
|
||||
|
||||
@@ -30,12 +30,14 @@ namespace Freestyle {
|
||||
|
||||
void FastGrid::clear()
|
||||
{
|
||||
if (!_cells)
|
||||
if (!_cells) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < _cells_size; i++) {
|
||||
if (_cells[i])
|
||||
if (_cells[i]) {
|
||||
delete _cells[i];
|
||||
}
|
||||
}
|
||||
delete[] _cells;
|
||||
_cells = NULL;
|
||||
|
||||
@@ -266,8 +266,9 @@ static double NewtonRaphsonRootFind(BezierCurve Q, Vector2 P, double u)
|
||||
(Q_u[1] - P[1]) * (Q2_u[1]);
|
||||
|
||||
/* u = u - f(u)/f'(u) */
|
||||
if (denominator == 0) // FIXME
|
||||
if (denominator == 0) { // FIXME
|
||||
return u;
|
||||
}
|
||||
uPrime = u - (numerator / denominator);
|
||||
return uPrime;
|
||||
}
|
||||
@@ -472,8 +473,9 @@ FitCurveWrapper::~FitCurveWrapper()
|
||||
|
||||
void FitCurveWrapper::DrawBezierCurve(int n, Vector2 *curve)
|
||||
{
|
||||
for (int i = 0; i <= n; ++i)
|
||||
for (int i = 0; i <= n; ++i) {
|
||||
_vertices.push_back(curve[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void FitCurveWrapper::FitCurve(vector<Vec2d> &data, vector<Vec2d> &oCurve, double error)
|
||||
|
||||
@@ -115,8 +115,9 @@ void GeomCleaner::CompressIndexedVertexArray(const float *iVertices,
|
||||
i = 1;
|
||||
for (; v != vertices.end(); v++) {
|
||||
current = *v;
|
||||
if (current == previous)
|
||||
if (current == previous) {
|
||||
mapVertex[i] = compressedVertices.size() - 1;
|
||||
}
|
||||
else {
|
||||
compressedVertices.push_back(current);
|
||||
mapVertex[i] = compressedVertices.size() - 1;
|
||||
@@ -205,8 +206,9 @@ void GeomCleaner::CleanIndexedVertexArray(const float *iVertices,
|
||||
typedef map<Vec3f, unsigned> cleanHashTable;
|
||||
vector<Vec3f> vertices;
|
||||
unsigned i;
|
||||
for (i = 0; i < iVSize; i += 3)
|
||||
for (i = 0; i < iVSize; i += 3) {
|
||||
vertices.push_back(Vec3f(iVertices[i], iVertices[i + 1], iVertices[i + 2]));
|
||||
}
|
||||
|
||||
cleanHashTable ht;
|
||||
vector<unsigned> newIndices;
|
||||
@@ -244,8 +246,9 @@ void GeomCleaner::CleanIndexedVertexArray(const float *iVertices,
|
||||
|
||||
// map new indices:
|
||||
*oIndices = new unsigned[iISize];
|
||||
for (i = 0; i < iISize; i++)
|
||||
for (i = 0; i < iISize; i++) {
|
||||
(*oIndices)[i] = 3 * newIndices[iIndices[i] / 3];
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace Freestyle */
|
||||
|
||||
@@ -76,8 +76,9 @@ intersection_test intersect2dSeg2dSeg(
|
||||
|
||||
// Check signs of r3 and r4. If both point 3 and point 4 lie on same side of line 1,
|
||||
// the line segments do not intersect.
|
||||
if (r3 != 0 && r4 != 0 && r3 * r4 > 0.0)
|
||||
if (r3 != 0 && r4 != 0 && r3 * r4 > 0.0) {
|
||||
return (DONT_INTERSECT);
|
||||
}
|
||||
|
||||
// Compute a2, b2, c2
|
||||
a2 = p4[1] - p3[1];
|
||||
@@ -90,13 +91,15 @@ intersection_test intersect2dSeg2dSeg(
|
||||
|
||||
// Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line
|
||||
// segment, the line segments do not intersect.
|
||||
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0)
|
||||
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0) {
|
||||
return (DONT_INTERSECT);
|
||||
}
|
||||
|
||||
// Line segments intersect: compute intersection point.
|
||||
denom = a1 * b2 - a2 * b1;
|
||||
if (fabs(denom) < M_EPSILON)
|
||||
if (fabs(denom) < M_EPSILON) {
|
||||
return (COLINEAR);
|
||||
}
|
||||
|
||||
num = b1 * c2 - b2 * c1;
|
||||
res[0] = num / denom;
|
||||
@@ -125,8 +128,9 @@ intersection_test intersect2dLine2dLine(
|
||||
|
||||
// Line segments intersect: compute intersection point.
|
||||
denom = a1 * b2 - a2 * b1;
|
||||
if (fabs(denom) < M_EPSILON)
|
||||
if (fabs(denom) < M_EPSILON) {
|
||||
return (COLINEAR);
|
||||
}
|
||||
|
||||
num = b1 * c2 - b2 * c1;
|
||||
res[0] = num / denom;
|
||||
@@ -160,8 +164,9 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
|
||||
|
||||
// Check signs of r3 and r4. If both point 3 and point 4 lie on same side of line 1,
|
||||
// the line segments do not intersect.
|
||||
if (r3 != 0 && r4 != 0 && r3 * r4 > 0.0)
|
||||
if (r3 != 0 && r4 != 0 && r3 * r4 > 0.0) {
|
||||
return (DONT_INTERSECT);
|
||||
}
|
||||
|
||||
// Compute a2, b2, c2
|
||||
a2 = p4[1] - p3[1];
|
||||
@@ -174,13 +179,15 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1,
|
||||
|
||||
// Check signs of r1 and r2. If both point 1 and point 2 lie on same side of second line
|
||||
// segment, the line segments do not intersect.
|
||||
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0)
|
||||
if (r1 != 0 && r2 != 0 && r1 * r2 > 0.0) {
|
||||
return (DONT_INTERSECT);
|
||||
}
|
||||
|
||||
// Line segments intersect: compute intersection point.
|
||||
denom = a1 * b2 - a2 * b1;
|
||||
if (fabs(denom) < epsilon)
|
||||
if (fabs(denom) < epsilon) {
|
||||
return (COLINEAR);
|
||||
}
|
||||
|
||||
real d1, e1;
|
||||
|
||||
@@ -387,26 +394,30 @@ bool overlapTriangleBox(Vec3r &boxcenter, Vec3r &boxhalfsize, Vec3r triverts[3])
|
||||
|
||||
// test in X-direction
|
||||
FINDMINMAX(v0[X], v1[X], v2[X], min, max);
|
||||
if (min > boxhalfsize[X] || max < -boxhalfsize[X])
|
||||
if (min > boxhalfsize[X] || max < -boxhalfsize[X]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// test in Y-direction
|
||||
FINDMINMAX(v0[Y], v1[Y], v2[Y], min, max);
|
||||
if (min > boxhalfsize[Y] || max < -boxhalfsize[Y])
|
||||
if (min > boxhalfsize[Y] || max < -boxhalfsize[Y]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// test in Z-direction
|
||||
FINDMINMAX(v0[Z], v1[Z], v2[Z], min, max);
|
||||
if (min > boxhalfsize[Z] || max < -boxhalfsize[Z])
|
||||
if (min > boxhalfsize[Z] || max < -boxhalfsize[Z]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bullet 2:
|
||||
// test if the box intersects the plane of the triangle
|
||||
// compute plane equation of triangle: normal * x + d = 0
|
||||
normal = e0 ^ e1;
|
||||
d = -(normal * v0); // plane eq: normal.x + d = 0
|
||||
if (!overlapPlaneBox(normal, d, boxhalfsize))
|
||||
if (!overlapPlaneBox(normal, d, boxhalfsize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // box and triangle overlaps
|
||||
}
|
||||
@@ -453,24 +464,28 @@ bool intersectRayTriangle(const Vec3r &orig,
|
||||
|
||||
if (det > epsilon) {
|
||||
u = tvec * pvec;
|
||||
if (u < 0.0 || u > det)
|
||||
if (u < 0.0 || u > det) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// calculate V parameter and test bounds
|
||||
v = dir * qvec;
|
||||
if (v < 0.0 || u + v > det)
|
||||
if (v < 0.0 || u + v > det) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (det < -epsilon) {
|
||||
// calculate U parameter and test bounds
|
||||
u = tvec * pvec;
|
||||
if (u > 0.0 || u < det)
|
||||
if (u > 0.0 || u < det) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// calculate V parameter and test bounds
|
||||
v = dir * qvec;
|
||||
if (v > 0.0 || u + v < det)
|
||||
if (v > 0.0 || u + v < det) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false; // ray is parallell to the plane of the triangle
|
||||
@@ -496,16 +511,19 @@ intersection_test intersectRayPlane(const Vec3r &orig,
|
||||
real denom = norm * dir;
|
||||
|
||||
if (fabs(denom) <= epsilon) { // plane and ray are parallel
|
||||
if (fabs((norm * orig) + d) <= epsilon)
|
||||
if (fabs((norm * orig) + d) <= epsilon) {
|
||||
return COINCIDENT; // plane and ray are coincident
|
||||
else
|
||||
}
|
||||
else {
|
||||
return COLINEAR;
|
||||
}
|
||||
}
|
||||
|
||||
t = -(d + (norm * orig)) / denom;
|
||||
|
||||
if (t < 0.0f)
|
||||
if (t < 0.0f) {
|
||||
return DONT_INTERSECT;
|
||||
}
|
||||
|
||||
return DO_INTERSECT;
|
||||
}
|
||||
@@ -535,20 +553,26 @@ bool intersectRayBBox(const Vec3r &orig,
|
||||
tmax = (bounds[1 - sign[0]].x() - orig.x()) * inv_direction.x();
|
||||
tymin = (bounds[sign[1]].y() - orig.y()) * inv_direction.y();
|
||||
tymax = (bounds[1 - sign[1]].y() - orig.y()) * inv_direction.y();
|
||||
if ((tmin > tymax) || (tymin > tmax))
|
||||
if ((tmin > tymax) || (tymin > tmax)) {
|
||||
return false;
|
||||
if (tymin > tmin)
|
||||
}
|
||||
if (tymin > tmin) {
|
||||
tmin = tymin;
|
||||
if (tymax < tmax)
|
||||
}
|
||||
if (tymax < tmax) {
|
||||
tmax = tymax;
|
||||
}
|
||||
tzmin = (bounds[sign[2]].z() - orig.z()) * inv_direction.z();
|
||||
tzmax = (bounds[1 - sign[2]].z() - orig.z()) * inv_direction.z();
|
||||
if ((tmin > tzmax) || (tzmin > tmax))
|
||||
if ((tmin > tzmax) || (tzmin > tmax)) {
|
||||
return false;
|
||||
if (tzmin > tmin)
|
||||
}
|
||||
if (tzmin > tmin) {
|
||||
tmin = tzmin;
|
||||
if (tzmax < tmax)
|
||||
}
|
||||
if (tzmax < tmax) {
|
||||
tmax = tzmax;
|
||||
}
|
||||
return ((tmin < t1) && (tmax > t0));
|
||||
}
|
||||
|
||||
@@ -571,14 +595,17 @@ bool includePointTriangle(const Vec3r &P, const Vec3r &A, const Vec3r &B, const
|
||||
K.normalize();
|
||||
L.normalize();
|
||||
|
||||
if (J * N < 0)
|
||||
if (J * N < 0) {
|
||||
return false; // on the right of AB
|
||||
}
|
||||
|
||||
if (K * N < 0)
|
||||
if (K * N < 0) {
|
||||
return false; // on the right of BC
|
||||
}
|
||||
|
||||
if (L * N < 0)
|
||||
if (L * N < 0) {
|
||||
return false; // on the right of CA
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -589,8 +616,9 @@ void transformVertex(const Vec3r &vert, const Matrix44r &matrix, Vec3r &res)
|
||||
real scale;
|
||||
for (unsigned int j = 0; j < 4; j++) {
|
||||
scale = hvert[j];
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
for (unsigned int i = 0; i < 4; i++) {
|
||||
res_tmp[i] += matrix(i, j) * scale;
|
||||
}
|
||||
}
|
||||
|
||||
res[0] = res_tmp.x();
|
||||
@@ -612,8 +640,9 @@ Vec3r rotateVector(const Matrix44r &mat, const Vec3r &v)
|
||||
Vec3r res;
|
||||
for (unsigned int i = 0; i < 3; i++) {
|
||||
res[i] = 0;
|
||||
for (unsigned int j = 0; j < 3; j++)
|
||||
for (unsigned int j = 0; j < 3; j++) {
|
||||
res[i] += mat(i, j) * v[j];
|
||||
}
|
||||
}
|
||||
res.normalize();
|
||||
return res;
|
||||
@@ -698,8 +727,9 @@ void fromCameraToWorld(const Vec3r &p, Vec3r &q, const real model_view_matrix[4]
|
||||
};
|
||||
for (unsigned short i = 0; i < 3; i++) {
|
||||
q[i] = 0.0;
|
||||
for (unsigned short j = 0; j < 3; j++)
|
||||
for (unsigned short j = 0; j < 3; j++) {
|
||||
q[i] += model_view_matrix[j][i] * (p[j] - translation[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -718,8 +748,9 @@ void fromCameraToWorld(const Vec3r &p, Vec3r &q, const real model_view_matrix[4]
|
||||
|
||||
inline bool intersect2dSegPoly(Vec2r *seg, Vec2r *poly, unsigned n)
|
||||
{
|
||||
if (seg[0] == seg[1])
|
||||
if (seg[0] == seg[1]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
real tE = 0; // the maximum entering segment parameter
|
||||
real tL = 1; // the minimum leaving segment parameter
|
||||
@@ -732,25 +763,29 @@ inline bool intersect2dSegPoly(Vec2r *seg, Vec2r *poly, unsigned n)
|
||||
N = PERP(e, seg[0] - poly[i]);
|
||||
D = -PERP(e, dseg);
|
||||
if (fabs(D) < M_EPSILON) {
|
||||
if (N < 0)
|
||||
if (N < 0) {
|
||||
return false;
|
||||
else
|
||||
}
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
t = N / D;
|
||||
if (D < 0) { // segment seg is entering across this edge
|
||||
if (t > tE) { // new max tE
|
||||
tE = t;
|
||||
if (tE > tL) // seg enters after leaving polygon
|
||||
if (tE > tL) { // seg enters after leaving polygon
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // segment seg is leaving across this edge
|
||||
if (t < tL) { // new min tL
|
||||
tL = t;
|
||||
if (tL < tE) // seg leaves before entering polygon
|
||||
if (tL < tE) { // seg leaves before entering polygon
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -773,10 +808,12 @@ inline bool overlapPlaneBox(Vec3r &normal, real d, Vec3r &maxbox)
|
||||
vmax[q] = -maxbox[q];
|
||||
}
|
||||
}
|
||||
if ((normal * vmin) + d > 0.0f)
|
||||
if ((normal * vmin) + d > 0.0f) {
|
||||
return false;
|
||||
if ((normal * vmax) + d >= 0.0f)
|
||||
}
|
||||
if ((normal * vmax) + d >= 0.0f) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -796,8 +833,9 @@ inline void fromCoordAToCoordB(const Vec3r &p, Vec3r &q, const real transform[4]
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int k = 0; k < 3; k++)
|
||||
for (unsigned int k = 0; k < 3; k++) {
|
||||
q[k] = hq[k] / hq[3];
|
||||
}
|
||||
}
|
||||
|
||||
} // end of namespace GeomUtils
|
||||
|
||||
@@ -50,12 +50,14 @@ template<class T> real distPointSegment(const T &P, const T &A, const T &B)
|
||||
BP = P - B;
|
||||
|
||||
real c1(AB * AP);
|
||||
if (c1 <= 0)
|
||||
if (c1 <= 0) {
|
||||
return AP.norm();
|
||||
}
|
||||
|
||||
real c2(AB * AB);
|
||||
if (c2 <= c1)
|
||||
if (c2 <= c1) {
|
||||
return BP.norm();
|
||||
}
|
||||
|
||||
real b = c1 / c2;
|
||||
T Pb, PPb;
|
||||
|
||||
@@ -83,8 +83,9 @@ void firstIntersectionGridVisitor::examineOccluder(Polygon3r *occ)
|
||||
|
||||
bool firstIntersectionGridVisitor::stop()
|
||||
{
|
||||
if (occluder_)
|
||||
if (occluder_) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -139,20 +140,23 @@ void Grid::configure(const Vec3r &orig, const Vec3r &size, unsigned nb)
|
||||
|
||||
// We compute the number of cells par edge such as we cover at least the whole box.
|
||||
unsigned i;
|
||||
for (i = 0; i < 3; i++)
|
||||
for (i = 0; i < 3; i++) {
|
||||
_cells_nb[i] = (unsigned)floor(tmpSize[i] / edge) + 1;
|
||||
}
|
||||
|
||||
_size = tmpSize;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
for (i = 0; i < 3; i++) {
|
||||
_cell_size[i] = _size[i] / _cells_nb[i];
|
||||
}
|
||||
}
|
||||
|
||||
void Grid::insertOccluder(Polygon3r *occluder)
|
||||
{
|
||||
const vector<Vec3r> vertices = occluder->getVertices();
|
||||
if (vertices.size() == 0)
|
||||
if (vertices.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add this occluder to the grid's occluders list
|
||||
addOccluder(occluder);
|
||||
@@ -244,12 +248,15 @@ bool Grid::nextRayCell(Vec3u ¤t_cell, Vec3u &next_cell)
|
||||
// coresponding to the intersections with the plans:
|
||||
// x = _cell_size[0], y = _cell_size[1], z = _cell_size[2]
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (_ray_dir[i] == 0)
|
||||
if (_ray_dir[i] == 0) {
|
||||
continue;
|
||||
if (_ray_dir[i] > 0)
|
||||
}
|
||||
if (_ray_dir[i] > 0) {
|
||||
t = (_cell_size[i] - _pt[i]) / _ray_dir[i];
|
||||
else
|
||||
}
|
||||
else {
|
||||
t = -_pt[i] / _ray_dir[i];
|
||||
}
|
||||
if (t < t_min) {
|
||||
t_min = t;
|
||||
coord = i;
|
||||
@@ -266,20 +273,23 @@ bool Grid::nextRayCell(Vec3u ¤t_cell, Vec3u &next_cell)
|
||||
next_cell[coord]++;
|
||||
_pt[coord] -= _cell_size[coord];
|
||||
// if we are out of the grid, we must stop
|
||||
if (next_cell[coord] >= _cells_nb[coord])
|
||||
if (next_cell[coord] >= _cells_nb[coord]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
int tmp = next_cell[coord] - 1;
|
||||
_pt[coord] = _cell_size[coord];
|
||||
if (tmp < 0)
|
||||
if (tmp < 0) {
|
||||
return false;
|
||||
}
|
||||
next_cell[coord]--;
|
||||
}
|
||||
|
||||
_t += t_min;
|
||||
if (_t >= _t_end)
|
||||
if (_t >= _t_end) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -301,8 +311,9 @@ void Grid::castInfiniteRay(const Vec3r &orig,
|
||||
{
|
||||
Vec3r end = Vec3r(orig + FLT_MAX * dir / dir.norm());
|
||||
bool inter = initInfiniteRay(orig, dir, timestamp);
|
||||
if (!inter)
|
||||
if (!inter) {
|
||||
return;
|
||||
}
|
||||
allOccludersGridVisitor visitor(occluders);
|
||||
castRayInternal(visitor);
|
||||
}
|
||||
@@ -371,8 +382,9 @@ bool Grid::initInfiniteRay(const Vec3r &orig, const Vec3r &dir, unsigned timesta
|
||||
Vec3r newOrig = orig + tmin * _ray_dir;
|
||||
for (unsigned int i = 0; i < 3; i++) {
|
||||
_current_cell[i] = (unsigned)floor((newOrig[i] - _orig[i]) / _cell_size[i]);
|
||||
if (_current_cell[i] == _cells_nb[i])
|
||||
if (_current_cell[i] == _cells_nb[i]) {
|
||||
_current_cell[i] = _cells_nb[i] - 1;
|
||||
}
|
||||
// soc unused - unsigned u = _current_cell[i];
|
||||
_pt[i] = newOrig[i] - _orig[i] - _current_cell[i] * _cell_size[i];
|
||||
}
|
||||
|
||||
@@ -67,8 +67,9 @@ class Cell {
|
||||
|
||||
inline void addOccluder(Polygon3r *o)
|
||||
{
|
||||
if (o)
|
||||
if (o) {
|
||||
_occluders.push_back(o);
|
||||
}
|
||||
}
|
||||
|
||||
inline const Vec3r &getOrigin()
|
||||
@@ -227,12 +228,15 @@ class Grid {
|
||||
int tmp;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
tmp = (int)((p[i] - _orig[i]) / _cell_size[i]);
|
||||
if (tmp < 0)
|
||||
if (tmp < 0) {
|
||||
res[i] = 0;
|
||||
else if ((unsigned int)tmp >= _cells_nb[i])
|
||||
}
|
||||
else if ((unsigned int)tmp >= _cells_nb[i]) {
|
||||
res[i] = _cells_nb[i] - 1;
|
||||
else
|
||||
}
|
||||
else {
|
||||
res[i] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,8 +267,9 @@ class Grid {
|
||||
*/
|
||||
inline void getCellOrigin(const Vec3u &cell_coord, Vec3r &orig)
|
||||
{
|
||||
for (unsigned int i = 0; i < 3; i++)
|
||||
for (unsigned int i = 0; i < 3; i++) {
|
||||
orig[i] = _orig[i] + cell_coord[i] * _cell_size[i];
|
||||
}
|
||||
}
|
||||
|
||||
/*! Retrieves the box corresponding to the cell whose coordinates are passed as argument:
|
||||
|
||||
@@ -87,8 +87,9 @@ class HashGrid : public Grid {
|
||||
Cell *found_cell = NULL;
|
||||
|
||||
GridHashTable::const_iterator found = _cells.find(p);
|
||||
if (found != _cells.end())
|
||||
if (found != _cells.end()) {
|
||||
found_cell = (*found).second;
|
||||
}
|
||||
return found_cell;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,12 +245,14 @@ Noise::Noise(long seed)
|
||||
p[i] = i;
|
||||
g1[i] = (float)((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B;
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
for (j = 0; j < 2; j++) {
|
||||
g2[i][j] = (float)((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B;
|
||||
}
|
||||
normalize2(g2[i]);
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
for (j = 0; j < 3; j++) {
|
||||
g3[i][j] = (float)((BLI_rng_get_int(rng) % (_NOISE_B + _NOISE_B)) - _NOISE_B) / _NOISE_B;
|
||||
}
|
||||
normalize3(g3[i]);
|
||||
}
|
||||
|
||||
@@ -264,11 +266,13 @@ Noise::Noise(long seed)
|
||||
p[_NOISE_B + i] = p[i];
|
||||
g1[_NOISE_B + i] = g1[i];
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
for (j = 0; j < 2; j++) {
|
||||
g2[_NOISE_B + i][j] = g2[i][j];
|
||||
}
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
for (j = 0; j < 3; j++) {
|
||||
g3[_NOISE_B + i][j] = g3[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
BLI_rng_free(rng);
|
||||
|
||||
@@ -100,8 +100,9 @@ template<class Point> class Polygon {
|
||||
inline Point getCenter()
|
||||
{
|
||||
Point result;
|
||||
for (typename vector<Point>::iterator it = _vertices.begin(); it != _vertices.end(); it++)
|
||||
for (typename vector<Point>::iterator it = _vertices.begin(); it != _vertices.end(); it++) {
|
||||
result += *it;
|
||||
}
|
||||
result /= _vertices.size();
|
||||
return result;
|
||||
}
|
||||
@@ -138,18 +139,21 @@ template<class Point> class Polygon {
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
inline void computeBBox()
|
||||
{
|
||||
if (_vertices.empty())
|
||||
if (_vertices.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
_max = _vertices[0];
|
||||
_min = _vertices[0];
|
||||
|
||||
for (typename vector<Point>::iterator it = _vertices.begin(); it != _vertices.end(); it++) {
|
||||
for (unsigned int i = 0; i < Point::dim(); i++) {
|
||||
if ((*it)[i] > _max[i])
|
||||
if ((*it)[i] > _max[i]) {
|
||||
_max[i] = (*it)[i];
|
||||
if ((*it)[i] < _min[i])
|
||||
}
|
||||
if ((*it)[i] < _min[i]) {
|
||||
_min[i] = (*it)[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,9 @@ template<class T, unsigned N> class Vec {
|
||||
// constructors
|
||||
inline Vec()
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
~Vec()
|
||||
@@ -70,20 +71,23 @@ template<class T, unsigned N> class Vec {
|
||||
|
||||
template<class U> explicit inline Vec(const U tab[N])
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] = (T)tab[i];
|
||||
}
|
||||
}
|
||||
|
||||
template<class U> explicit inline Vec(const std::vector<U> &tab)
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] = (T)tab[i];
|
||||
}
|
||||
}
|
||||
|
||||
template<class U> explicit inline Vec(const Vec<U, N> &v)
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] = (T)v[i];
|
||||
}
|
||||
}
|
||||
|
||||
// accessors
|
||||
@@ -116,8 +120,9 @@ template<class T, unsigned N> class Vec {
|
||||
inline Vec<T, N> &normalize()
|
||||
{
|
||||
value_type n = norm();
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] /= n;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -125,8 +130,9 @@ template<class T, unsigned N> class Vec {
|
||||
{
|
||||
value_type n = norm();
|
||||
if (n) {
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] /= n;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -156,8 +162,9 @@ template<class T, unsigned N> class Vec {
|
||||
inline Vec<T, N> operator/(const typename Vec<T, N>::value_type r) const
|
||||
{
|
||||
Vec<T, N> res(*this);
|
||||
if (r)
|
||||
if (r) {
|
||||
res /= r;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -165,46 +172,52 @@ template<class T, unsigned N> class Vec {
|
||||
inline value_type operator*(const Vec<T, N> &v) const
|
||||
{
|
||||
value_type sum = 0;
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
sum += (*this)[i] * v[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
template<class U> inline Vec<T, N> &operator=(const Vec<U, N> &v)
|
||||
{
|
||||
if (this != &v) {
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] = (T)v[i];
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class U> inline Vec<T, N> &operator+=(const Vec<U, N> &v)
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] += (T)v[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class U> inline Vec<T, N> &operator-=(const Vec<U, N> &v)
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] -= (T)v[i];
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class U> inline Vec<T, N> &operator*=(const U r)
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] *= r;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class U> inline Vec<T, N> &operator/=(const U r)
|
||||
{
|
||||
if (r) {
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
this->_coord[i] /= r;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -212,8 +225,9 @@ template<class T, unsigned N> class Vec {
|
||||
inline bool operator==(const Vec<T, N> &v) const
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
if (this->_coord[i] != v[i])
|
||||
if (this->_coord[i] != v[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -221,8 +235,9 @@ template<class T, unsigned N> class Vec {
|
||||
inline bool operator!=(const Vec<T, N> &v) const
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
if (this->_coord[i] != v[i])
|
||||
if (this->_coord[i] != v[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -230,12 +245,15 @@ template<class T, unsigned N> class Vec {
|
||||
inline bool operator<(const Vec<T, N> &v) const
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
if (this->_coord[i] < v[i])
|
||||
if (this->_coord[i] < v[i]) {
|
||||
return true;
|
||||
if (this->_coord[i] > v[i])
|
||||
}
|
||||
if (this->_coord[i] > v[i]) {
|
||||
return false;
|
||||
if (this->_coord[i] == v[i])
|
||||
}
|
||||
if (this->_coord[i] == v[i]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -243,12 +261,15 @@ template<class T, unsigned N> class Vec {
|
||||
inline bool operator>(const Vec<T, N> &v) const
|
||||
{
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
if (this->_coord[i] > v[i])
|
||||
if (this->_coord[i] > v[i]) {
|
||||
return true;
|
||||
if (this->_coord[i] < v[i])
|
||||
}
|
||||
if (this->_coord[i] < v[i]) {
|
||||
return false;
|
||||
if (this->_coord[i] == v[i])
|
||||
}
|
||||
if (this->_coord[i] == v[i]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -351,8 +372,9 @@ template<class T> class Vec2 : public Vec<T, 2> {
|
||||
inline Vec2<T> operator/(const value_type r) const
|
||||
{
|
||||
Vec2<T> res(*this);
|
||||
if (r)
|
||||
if (r) {
|
||||
res /= r;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -360,8 +382,9 @@ template<class T> class Vec2 : public Vec<T, 2> {
|
||||
inline value_type operator*(const Vec2<T> &v) const
|
||||
{
|
||||
value_type sum = 0;
|
||||
for (unsigned int i = 0; i < 2; i++)
|
||||
for (unsigned int i = 0; i < 2; i++) {
|
||||
sum += (*this)[i] * v[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
};
|
||||
@@ -578,8 +601,9 @@ template<class T> class Vec3 : public Vec<T, 3> {
|
||||
inline Vec3<T> operator/(const value_type r) const
|
||||
{
|
||||
Vec3<T> res(*this);
|
||||
if (r)
|
||||
if (r) {
|
||||
res /= r;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -587,8 +611,9 @@ template<class T> class Vec3 : public Vec<T, 3> {
|
||||
inline value_type operator*(const Vec3<T> &v) const
|
||||
{
|
||||
value_type sum = 0;
|
||||
for (unsigned int i = 0; i < 3; i++)
|
||||
for (unsigned int i = 0; i < 3; i++) {
|
||||
sum += (*this)[i] * v[i];
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
@@ -629,8 +654,9 @@ template<class T, unsigned M, unsigned N> class Matrix {
|
||||
|
||||
inline Matrix()
|
||||
{
|
||||
for (unsigned int i = 0; i < _SIZE; i++)
|
||||
for (unsigned int i = 0; i < _SIZE; i++) {
|
||||
this->_coord[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
~Matrix()
|
||||
@@ -641,21 +667,24 @@ template<class T, unsigned M, unsigned N> class Matrix {
|
||||
|
||||
template<class U> explicit inline Matrix(const U tab[_SIZE])
|
||||
{
|
||||
for (unsigned int i = 0; i < _SIZE; i++)
|
||||
for (unsigned int i = 0; i < _SIZE; i++) {
|
||||
this->_coord[i] = tab[i];
|
||||
}
|
||||
}
|
||||
|
||||
template<class U> explicit inline Matrix(const std::vector<U> &tab)
|
||||
{
|
||||
for (unsigned int i = 0; i < _SIZE; i++)
|
||||
for (unsigned int i = 0; i < _SIZE; i++) {
|
||||
this->_coord[i] = tab[i];
|
||||
}
|
||||
}
|
||||
|
||||
template<class U> inline Matrix(const Matrix<U, M, N> &m)
|
||||
{
|
||||
for (unsigned int i = 0; i < M; i++) {
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
for (unsigned int j = 0; j < N; j++) {
|
||||
this->_coord[i * N + j] = (T)m(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,8 +712,9 @@ template<class T, unsigned M, unsigned N> class Matrix {
|
||||
{
|
||||
Matrix<T, N, M> res;
|
||||
for (unsigned int i = 0; i < M; i++) {
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
for (unsigned int j = 0; j < N; j++) {
|
||||
res(j, i) = this->_coord[i * N + j];
|
||||
}
|
||||
}
|
||||
*this = res;
|
||||
return *this;
|
||||
@@ -694,8 +724,9 @@ template<class T, unsigned M, unsigned N> class Matrix {
|
||||
{
|
||||
if (this != &m) {
|
||||
for (unsigned int i = 0; i < M; i++) {
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
for (unsigned int j = 0; j < N; j++) {
|
||||
this->_coord[i * N + j] = (T)m(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@@ -704,8 +735,9 @@ template<class T, unsigned M, unsigned N> class Matrix {
|
||||
template<class U> inline Matrix<T, M, N> &operator+=(const Matrix<U, M, N> &m)
|
||||
{
|
||||
for (unsigned int i = 0; i < M; i++) {
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
for (unsigned int j = 0; j < N; j++) {
|
||||
this->_coord[i * N + j] += (T)m(i, j);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -713,8 +745,9 @@ template<class T, unsigned M, unsigned N> class Matrix {
|
||||
template<class U> inline Matrix<T, M, N> &operator-=(const Matrix<U, M, N> &m)
|
||||
{
|
||||
for (unsigned int i = 0; i < M; i++) {
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
for (unsigned int j = 0; j < N; j++) {
|
||||
this->_coord[i * N + j] -= (T)m(i, j);
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -722,8 +755,9 @@ template<class T, unsigned M, unsigned N> class Matrix {
|
||||
template<class U> inline Matrix<T, M, N> &operator*=(const U lambda)
|
||||
{
|
||||
for (unsigned int i = 0; i < M; i++) {
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
for (unsigned int j = 0; j < N; j++) {
|
||||
this->_coord[i * N + j] *= lambda;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -732,8 +766,9 @@ template<class T, unsigned M, unsigned N> class Matrix {
|
||||
{
|
||||
if (lambda) {
|
||||
for (unsigned int i = 0; i < M; i++) {
|
||||
for (unsigned int j = 0; j < N; j++)
|
||||
for (unsigned int j = 0; j < N; j++) {
|
||||
this->_coord[i * N + j] /= lambda;
|
||||
}
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
@@ -782,8 +817,9 @@ template<class T, unsigned N> class SquareMatrix : public Matrix<T, N, N> {
|
||||
static inline SquareMatrix<T, N> identity()
|
||||
{
|
||||
SquareMatrix<T, N> res;
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
res(i, i) = 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
@@ -861,8 +897,9 @@ template<class T, unsigned N> inline std::ostream &operator<<(std::ostream &s, c
|
||||
{
|
||||
unsigned int i;
|
||||
s << "[";
|
||||
for (i = 0; i < N - 1; i++)
|
||||
for (i = 0; i < N - 1; i++) {
|
||||
s << v[i] << ", ";
|
||||
}
|
||||
s << v[i] << "]";
|
||||
return s;
|
||||
}
|
||||
@@ -925,8 +962,9 @@ inline Matrix<T, M, P> operator*(const Matrix<T, M, N> &m1, const Matrix<T, N, P
|
||||
for (j = 0; j < P; j++) {
|
||||
for (k = 0; k < N; k++) {
|
||||
scale = m2(k, j);
|
||||
for (i = 0; i < N; i++)
|
||||
for (i = 0; i < N; i++) {
|
||||
res(i, j) += m1(i, k) * scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@@ -940,8 +978,9 @@ inline Vec<T, M> operator*(const Matrix<T, M, N> &m, const Vec<T, N> &v)
|
||||
|
||||
for (unsigned int j = 0; j < M; j++) {
|
||||
scale = v[j];
|
||||
for (unsigned int i = 0; i < N; i++)
|
||||
for (unsigned int i = 0; i < N; i++) {
|
||||
res[i] += m(i, j) * scale;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -953,8 +992,9 @@ inline std::ostream &operator<<(std::ostream &s, const Matrix<T, M, N> &m)
|
||||
unsigned int i, j;
|
||||
for (i = 0; i < M; i++) {
|
||||
s << "[";
|
||||
for (j = 0; j < N - 1; j++)
|
||||
for (j = 0; j < N - 1; j++) {
|
||||
s << m(i, j) << ", ";
|
||||
}
|
||||
s << m(i, j) << "]" << std::endl;
|
||||
}
|
||||
return s;
|
||||
|
||||
@@ -63,8 +63,9 @@ GaussianFilter::~GaussianFilter()
|
||||
int GaussianFilter::computeMaskSize(float sigma)
|
||||
{
|
||||
int maskSize = (int)floor(4 * sigma) + 1;
|
||||
if (0 == (maskSize % 2))
|
||||
if (0 == (maskSize % 2)) {
|
||||
++maskSize;
|
||||
}
|
||||
|
||||
return maskSize;
|
||||
}
|
||||
|
||||
@@ -134,11 +134,13 @@ template<class Map> float GaussianFilter::getSmoothedPixel(Map *map, int x, int
|
||||
// Current pixel is x,y
|
||||
// Sum surrounding pixels L value:
|
||||
for (int i = -_bound; i <= _bound; ++i) {
|
||||
if ((y + i < 0) || (y + i >= h))
|
||||
if ((y + i < 0) || (y + i >= h)) {
|
||||
continue;
|
||||
}
|
||||
for (int j = -_bound; j <= _bound; ++j) {
|
||||
if ((x + j < 0) || (x + j >= w))
|
||||
if ((x + j < 0) || (x + j >= w)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
float tmpL = map->pixel(x + j, y + i);
|
||||
float m = _mask[abs(i) * _storedMaskSize + abs(j)];
|
||||
|
||||
@@ -238,8 +238,9 @@ class RGBImage : public FrsImage {
|
||||
|
||||
virtual ~RGBImage()
|
||||
{
|
||||
if (_rgb)
|
||||
if (_rgb) {
|
||||
delete[] _rgb;
|
||||
}
|
||||
}
|
||||
|
||||
inline float getR(unsigned x, unsigned y) const
|
||||
@@ -376,8 +377,9 @@ class GrayImage : public FrsImage {
|
||||
|
||||
virtual ~GrayImage()
|
||||
{
|
||||
if (_lvl)
|
||||
if (_lvl) {
|
||||
delete[] _lvl;
|
||||
}
|
||||
}
|
||||
|
||||
inline void setPixel(unsigned x, unsigned y, float v)
|
||||
|
||||
@@ -71,10 +71,12 @@ float ImagePyramid::pixel(int x, int y, int level)
|
||||
unsigned int i = 1 << level;
|
||||
unsigned int sx = x >> level;
|
||||
unsigned int sy = y >> level;
|
||||
if (sx >= img->width())
|
||||
if (sx >= img->width()) {
|
||||
sx = img->width() - 1;
|
||||
if (sy >= img->height())
|
||||
}
|
||||
if (sy >= img->height()) {
|
||||
sy = img->height() - 1;
|
||||
}
|
||||
|
||||
// bilinear interpolation
|
||||
float A = i * (sx + 1) - x;
|
||||
@@ -85,8 +87,9 @@ float ImagePyramid::pixel(int x, int y, int level)
|
||||
float P1(0), P2(0);
|
||||
P1 = A * img->pixel(sx, sy);
|
||||
if (sx < img->width() - 1) {
|
||||
if (x % i != 0)
|
||||
if (x % i != 0) {
|
||||
P1 += B * img->pixel(sx + 1, sy);
|
||||
}
|
||||
}
|
||||
else {
|
||||
P1 += B * img->pixel(sx, sy);
|
||||
@@ -95,8 +98,9 @@ float ImagePyramid::pixel(int x, int y, int level)
|
||||
if (y % i != 0) {
|
||||
P2 = A * img->pixel(sx, sy + 1);
|
||||
if (sx < img->width() - 1) {
|
||||
if (x % i != 0)
|
||||
if (x % i != 0) {
|
||||
P2 += B * img->pixel(sx + 1, sy + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
P2 += B * img->pixel(sx, sy + 1);
|
||||
|
||||
@@ -29,11 +29,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int BBox_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&BBox_Type) < 0)
|
||||
if (PyType_Ready(&BBox_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&BBox_Type);
|
||||
PyModule_AddObject(module, "BBox", (PyObject *)&BBox_Type);
|
||||
|
||||
@@ -53,8 +55,9 @@ static int BBox_init(BPy_BBox *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->bb = new BBox<Vec3r>();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -32,11 +32,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int BinaryPredicate0D_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&BinaryPredicate0D_Type) < 0)
|
||||
if (PyType_Ready(&BinaryPredicate0D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&BinaryPredicate0D_Type);
|
||||
PyModule_AddObject(module, "BinaryPredicate0D", (PyObject *)&BinaryPredicate0D_Type);
|
||||
|
||||
@@ -72,8 +74,9 @@ static int BinaryPredicate0D___init__(BPy_BinaryPredicate0D *self, PyObject *arg
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->bp0D = new BinaryPredicate0D();
|
||||
self->bp0D->py_bp0D = (PyObject *)self;
|
||||
return 0;
|
||||
@@ -81,8 +84,9 @@ static int BinaryPredicate0D___init__(BPy_BinaryPredicate0D *self, PyObject *arg
|
||||
|
||||
static void BinaryPredicate0D___dealloc__(BPy_BinaryPredicate0D *self)
|
||||
{
|
||||
if (self->bp0D)
|
||||
if (self->bp0D) {
|
||||
delete self->bp0D;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,36 +38,43 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int BinaryPredicate1D_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&BinaryPredicate1D_Type) < 0)
|
||||
if (PyType_Ready(&BinaryPredicate1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&BinaryPredicate1D_Type);
|
||||
PyModule_AddObject(module, "BinaryPredicate1D", (PyObject *)&BinaryPredicate1D_Type);
|
||||
|
||||
if (PyType_Ready(&FalseBP1D_Type) < 0)
|
||||
if (PyType_Ready(&FalseBP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FalseBP1D_Type);
|
||||
PyModule_AddObject(module, "FalseBP1D", (PyObject *)&FalseBP1D_Type);
|
||||
|
||||
if (PyType_Ready(&Length2DBP1D_Type) < 0)
|
||||
if (PyType_Ready(&Length2DBP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Length2DBP1D_Type);
|
||||
PyModule_AddObject(module, "Length2DBP1D", (PyObject *)&Length2DBP1D_Type);
|
||||
|
||||
if (PyType_Ready(&SameShapeIdBP1D_Type) < 0)
|
||||
if (PyType_Ready(&SameShapeIdBP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&SameShapeIdBP1D_Type);
|
||||
PyModule_AddObject(module, "SameShapeIdBP1D", (PyObject *)&SameShapeIdBP1D_Type);
|
||||
|
||||
if (PyType_Ready(&TrueBP1D_Type) < 0)
|
||||
if (PyType_Ready(&TrueBP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&TrueBP1D_Type);
|
||||
PyModule_AddObject(module, "TrueBP1D", (PyObject *)&TrueBP1D_Type);
|
||||
|
||||
if (PyType_Ready(&ViewMapGradientNormBP1D_Type) < 0)
|
||||
if (PyType_Ready(&ViewMapGradientNormBP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ViewMapGradientNormBP1D_Type);
|
||||
PyModule_AddObject(module, "ViewMapGradientNormBP1D", (PyObject *)&ViewMapGradientNormBP1D_Type);
|
||||
|
||||
@@ -103,8 +110,9 @@ static int BinaryPredicate1D___init__(BPy_BinaryPredicate1D *self, PyObject *arg
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->bp1D = new BinaryPredicate1D();
|
||||
self->bp1D->py_bp1D = (PyObject *)self;
|
||||
return 0;
|
||||
@@ -112,8 +120,9 @@ static int BinaryPredicate1D___init__(BPy_BinaryPredicate1D *self, PyObject *arg
|
||||
|
||||
static void BinaryPredicate1D___dealloc__(BPy_BinaryPredicate1D *self)
|
||||
{
|
||||
if (self->bp1D)
|
||||
if (self->bp1D) {
|
||||
delete self->bp1D;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,8 +116,9 @@ static PyObject *ContextFunctions_load_map(PyObject * /*self*/, PyObject *args,
|
||||
float sigma = 1.0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "ss|If", (char **)kwlist, &fileName, &mapName, &nbLevels, &sigma))
|
||||
args, kwds, "ss|If", (char **)kwlist, &fileName, &mapName, &nbLevels, &sigma)) {
|
||||
return NULL;
|
||||
}
|
||||
ContextFunctions::LoadMapCF(fileName, mapName, nbLevels, sigma);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -150,8 +151,10 @@ static PyObject *ContextFunctions_read_map_pixel(PyObject * /*self*/,
|
||||
int level;
|
||||
unsigned x, y;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "siII", (char **)kwlist, &mapName, &level, &x, &y))
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "siII", (char **)kwlist, &mapName, &level, &x, &y)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(ContextFunctions::ReadMapPixelCF(mapName, level, x, y));
|
||||
}
|
||||
|
||||
@@ -180,8 +183,9 @@ static PyObject *ContextFunctions_read_complete_view_map_pixel(PyObject * /*self
|
||||
int level;
|
||||
unsigned x, y;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "iII", (char **)kwlist, &level, &x, &y))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "iII", (char **)kwlist, &level, &x, &y)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(ContextFunctions::ReadCompleteViewMapPixelCF(level, x, y));
|
||||
}
|
||||
|
||||
@@ -214,8 +218,9 @@ static PyObject *ContextFunctions_read_directional_view_map_pixel(PyObject * /*s
|
||||
unsigned x, y;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "iiII", (char **)kwlist, &orientation, &level, &x, &y))
|
||||
args, kwds, "iiII", (char **)kwlist, &orientation, &level, &x, &y)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(
|
||||
ContextFunctions::ReadDirectionalViewMapPixelCF(orientation, level, x, y));
|
||||
}
|
||||
@@ -231,8 +236,9 @@ static char ContextFunctions_get_selected_fedge___doc__[] =
|
||||
static PyObject *ContextFunctions_get_selected_fedge(PyObject * /*self*/)
|
||||
{
|
||||
FEdge *fe = ContextFunctions::GetSelectedFEdgeCF();
|
||||
if (fe)
|
||||
if (fe) {
|
||||
return Any_BPy_FEdge_from_FEdge(*fe);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -298,12 +304,14 @@ int ContextFunctions_Init(PyObject *module)
|
||||
{
|
||||
PyObject *m;
|
||||
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
m = PyModule_Create(&module_definition);
|
||||
if (m == NULL)
|
||||
if (m == NULL) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(m);
|
||||
PyModule_AddObject(module, "ContextFunctions", m);
|
||||
|
||||
|
||||
@@ -527,47 +527,60 @@ Nature::EdgeNature EdgeNature_from_BPy_Nature(PyObject *obj)
|
||||
|
||||
bool Vec2f_ptr_from_PyObject(PyObject *obj, Vec2f &vec)
|
||||
{
|
||||
if (Vec2f_ptr_from_Vector(obj, vec))
|
||||
if (Vec2f_ptr_from_Vector(obj, vec)) {
|
||||
return true;
|
||||
if (Vec2f_ptr_from_PyList(obj, vec))
|
||||
}
|
||||
if (Vec2f_ptr_from_PyList(obj, vec)) {
|
||||
return true;
|
||||
if (Vec2f_ptr_from_PyTuple(obj, vec))
|
||||
}
|
||||
if (Vec2f_ptr_from_PyTuple(obj, vec)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Vec3f_ptr_from_PyObject(PyObject *obj, Vec3f &vec)
|
||||
{
|
||||
if (Vec3f_ptr_from_Vector(obj, vec))
|
||||
if (Vec3f_ptr_from_Vector(obj, vec)) {
|
||||
return true;
|
||||
if (Vec3f_ptr_from_Color(obj, vec))
|
||||
}
|
||||
if (Vec3f_ptr_from_Color(obj, vec)) {
|
||||
return true;
|
||||
if (Vec3f_ptr_from_PyList(obj, vec))
|
||||
}
|
||||
if (Vec3f_ptr_from_PyList(obj, vec)) {
|
||||
return true;
|
||||
if (Vec3f_ptr_from_PyTuple(obj, vec))
|
||||
}
|
||||
if (Vec3f_ptr_from_PyTuple(obj, vec)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Vec3r_ptr_from_PyObject(PyObject *obj, Vec3r &vec)
|
||||
{
|
||||
if (Vec3r_ptr_from_Vector(obj, vec))
|
||||
if (Vec3r_ptr_from_Vector(obj, vec)) {
|
||||
return true;
|
||||
if (Vec3r_ptr_from_Color(obj, vec))
|
||||
}
|
||||
if (Vec3r_ptr_from_Color(obj, vec)) {
|
||||
return true;
|
||||
if (Vec3r_ptr_from_PyList(obj, vec))
|
||||
}
|
||||
if (Vec3r_ptr_from_PyList(obj, vec)) {
|
||||
return true;
|
||||
if (Vec3r_ptr_from_PyTuple(obj, vec))
|
||||
}
|
||||
if (Vec3r_ptr_from_PyTuple(obj, vec)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f &vec)
|
||||
{
|
||||
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2)
|
||||
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 2) {
|
||||
return false;
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
|
||||
}
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = ((VectorObject *)obj)->vec[0];
|
||||
vec[1] = ((VectorObject *)obj)->vec[1];
|
||||
return true;
|
||||
@@ -575,10 +588,12 @@ bool Vec2f_ptr_from_Vector(PyObject *obj, Vec2f &vec)
|
||||
|
||||
bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f &vec)
|
||||
{
|
||||
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
|
||||
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) {
|
||||
return false;
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
|
||||
}
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = ((VectorObject *)obj)->vec[0];
|
||||
vec[1] = ((VectorObject *)obj)->vec[1];
|
||||
vec[2] = ((VectorObject *)obj)->vec[2];
|
||||
@@ -587,10 +602,12 @@ bool Vec3f_ptr_from_Vector(PyObject *obj, Vec3f &vec)
|
||||
|
||||
bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r &vec)
|
||||
{
|
||||
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3)
|
||||
if (!VectorObject_Check(obj) || ((VectorObject *)obj)->size != 3) {
|
||||
return false;
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
|
||||
}
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = ((VectorObject *)obj)->vec[0];
|
||||
vec[1] = ((VectorObject *)obj)->vec[1];
|
||||
vec[2] = ((VectorObject *)obj)->vec[2];
|
||||
@@ -599,10 +616,12 @@ bool Vec3r_ptr_from_Vector(PyObject *obj, Vec3r &vec)
|
||||
|
||||
bool Vec3f_ptr_from_Color(PyObject *obj, Vec3f &vec)
|
||||
{
|
||||
if (!ColorObject_Check(obj))
|
||||
if (!ColorObject_Check(obj)) {
|
||||
return false;
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
|
||||
}
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = ((ColorObject *)obj)->col[0];
|
||||
vec[1] = ((ColorObject *)obj)->col[1];
|
||||
vec[2] = ((ColorObject *)obj)->col[2];
|
||||
@@ -611,10 +630,12 @@ bool Vec3f_ptr_from_Color(PyObject *obj, Vec3f &vec)
|
||||
|
||||
bool Vec3r_ptr_from_Color(PyObject *obj, Vec3r &vec)
|
||||
{
|
||||
if (!ColorObject_Check(obj))
|
||||
if (!ColorObject_Check(obj)) {
|
||||
return false;
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
|
||||
}
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = ((ColorObject *)obj)->col[0];
|
||||
vec[1] = ((ColorObject *)obj)->col[1];
|
||||
vec[2] = ((ColorObject *)obj)->col[2];
|
||||
@@ -637,10 +658,12 @@ bool Vec2f_ptr_from_PyList(PyObject *obj, Vec2f &vec)
|
||||
{
|
||||
float v[2];
|
||||
|
||||
if (!PyList_Check(obj) || PyList_GET_SIZE(obj) != 2)
|
||||
if (!PyList_Check(obj) || PyList_GET_SIZE(obj) != 2) {
|
||||
return false;
|
||||
if (!float_array_from_PyList(obj, v, 2))
|
||||
}
|
||||
if (!float_array_from_PyList(obj, v, 2)) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = v[0];
|
||||
vec[1] = v[1];
|
||||
return true;
|
||||
@@ -650,10 +673,12 @@ bool Vec3f_ptr_from_PyList(PyObject *obj, Vec3f &vec)
|
||||
{
|
||||
float v[3];
|
||||
|
||||
if (!PyList_Check(obj) || PyList_GET_SIZE(obj) != 3)
|
||||
if (!PyList_Check(obj) || PyList_GET_SIZE(obj) != 3) {
|
||||
return false;
|
||||
if (!float_array_from_PyList(obj, v, 3))
|
||||
}
|
||||
if (!float_array_from_PyList(obj, v, 3)) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = v[0];
|
||||
vec[1] = v[1];
|
||||
vec[2] = v[2];
|
||||
@@ -664,10 +689,12 @@ bool Vec3r_ptr_from_PyList(PyObject *obj, Vec3r &vec)
|
||||
{
|
||||
float v[3];
|
||||
|
||||
if (!PyList_Check(obj) || PyList_GET_SIZE(obj) != 3)
|
||||
if (!PyList_Check(obj) || PyList_GET_SIZE(obj) != 3) {
|
||||
return false;
|
||||
if (!float_array_from_PyList(obj, v, 3))
|
||||
}
|
||||
if (!float_array_from_PyList(obj, v, 3)) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = v[0];
|
||||
vec[1] = v[1];
|
||||
vec[2] = v[2];
|
||||
@@ -690,10 +717,12 @@ bool Vec2f_ptr_from_PyTuple(PyObject *obj, Vec2f &vec)
|
||||
{
|
||||
float v[2];
|
||||
|
||||
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 2)
|
||||
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 2) {
|
||||
return false;
|
||||
if (!float_array_from_PyTuple(obj, v, 2))
|
||||
}
|
||||
if (!float_array_from_PyTuple(obj, v, 2)) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = v[0];
|
||||
vec[1] = v[1];
|
||||
return true;
|
||||
@@ -703,10 +732,12 @@ bool Vec3f_ptr_from_PyTuple(PyObject *obj, Vec3f &vec)
|
||||
{
|
||||
float v[3];
|
||||
|
||||
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 3)
|
||||
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 3) {
|
||||
return false;
|
||||
if (!float_array_from_PyTuple(obj, v, 3))
|
||||
}
|
||||
if (!float_array_from_PyTuple(obj, v, 3)) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = v[0];
|
||||
vec[1] = v[1];
|
||||
vec[2] = v[2];
|
||||
@@ -717,10 +748,12 @@ bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r &vec)
|
||||
{
|
||||
float v[3];
|
||||
|
||||
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 3)
|
||||
if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 3) {
|
||||
return false;
|
||||
if (!float_array_from_PyTuple(obj, v, 3))
|
||||
}
|
||||
if (!float_array_from_PyTuple(obj, v, 3)) {
|
||||
return false;
|
||||
}
|
||||
vec[0] = v[0];
|
||||
vec[1] = v[1];
|
||||
vec[2] = v[2];
|
||||
@@ -732,17 +765,21 @@ bool Vec3r_ptr_from_PyTuple(PyObject *obj, Vec3r &vec)
|
||||
bool float_array_from_PyObject(PyObject *obj, float *v, int n)
|
||||
{
|
||||
if (VectorObject_Check(obj) && ((VectorObject *)obj)->size == n) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
|
||||
return 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
v[i] = ((VectorObject *)obj)->vec[i];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (ColorObject_Check(obj) && n == 3) {
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1)
|
||||
if (BaseMath_ReadCallback((BaseMathObject *)obj) == -1) {
|
||||
return 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
v[i] = ((ColorObject *)obj)->col[i];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (PyList_Check(obj) && PyList_GET_SIZE(obj) == n) {
|
||||
|
||||
@@ -83,42 +83,60 @@ static PyObject *Freestyle_getCurrentScene(PyObject * /*self*/)
|
||||
|
||||
static int ramp_blend_type(const char *type)
|
||||
{
|
||||
if (STREQ(type, "MIX"))
|
||||
if (STREQ(type, "MIX")) {
|
||||
return MA_RAMP_BLEND;
|
||||
if (STREQ(type, "ADD"))
|
||||
}
|
||||
if (STREQ(type, "ADD")) {
|
||||
return MA_RAMP_ADD;
|
||||
if (STREQ(type, "MULTIPLY"))
|
||||
}
|
||||
if (STREQ(type, "MULTIPLY")) {
|
||||
return MA_RAMP_MULT;
|
||||
if (STREQ(type, "SUBTRACT"))
|
||||
}
|
||||
if (STREQ(type, "SUBTRACT")) {
|
||||
return MA_RAMP_SUB;
|
||||
if (STREQ(type, "SCREEN"))
|
||||
}
|
||||
if (STREQ(type, "SCREEN")) {
|
||||
return MA_RAMP_SCREEN;
|
||||
if (STREQ(type, "DIVIDE"))
|
||||
}
|
||||
if (STREQ(type, "DIVIDE")) {
|
||||
return MA_RAMP_DIV;
|
||||
if (STREQ(type, "DIFFERENCE"))
|
||||
}
|
||||
if (STREQ(type, "DIFFERENCE")) {
|
||||
return MA_RAMP_DIFF;
|
||||
if (STREQ(type, "DARKEN"))
|
||||
}
|
||||
if (STREQ(type, "DARKEN")) {
|
||||
return MA_RAMP_DARK;
|
||||
if (STREQ(type, "LIGHTEN"))
|
||||
}
|
||||
if (STREQ(type, "LIGHTEN")) {
|
||||
return MA_RAMP_LIGHT;
|
||||
if (STREQ(type, "OVERLAY"))
|
||||
}
|
||||
if (STREQ(type, "OVERLAY")) {
|
||||
return MA_RAMP_OVERLAY;
|
||||
if (STREQ(type, "DODGE"))
|
||||
}
|
||||
if (STREQ(type, "DODGE")) {
|
||||
return MA_RAMP_DODGE;
|
||||
if (STREQ(type, "BURN"))
|
||||
}
|
||||
if (STREQ(type, "BURN")) {
|
||||
return MA_RAMP_BURN;
|
||||
if (STREQ(type, "HUE"))
|
||||
}
|
||||
if (STREQ(type, "HUE")) {
|
||||
return MA_RAMP_HUE;
|
||||
if (STREQ(type, "SATURATION"))
|
||||
}
|
||||
if (STREQ(type, "SATURATION")) {
|
||||
return MA_RAMP_SAT;
|
||||
if (STREQ(type, "VALUE"))
|
||||
}
|
||||
if (STREQ(type, "VALUE")) {
|
||||
return MA_RAMP_VAL;
|
||||
if (STREQ(type, "COLOR"))
|
||||
}
|
||||
if (STREQ(type, "COLOR")) {
|
||||
return MA_RAMP_COLOR;
|
||||
if (STREQ(type, "SOFT_LIGHT"))
|
||||
}
|
||||
if (STREQ(type, "SOFT_LIGHT")) {
|
||||
return MA_RAMP_SOFT;
|
||||
if (STREQ(type, "LINEAR_LIGHT"))
|
||||
}
|
||||
if (STREQ(type, "LINEAR_LIGHT")) {
|
||||
return MA_RAMP_LINEAR;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -147,8 +165,9 @@ static PyObject *Freestyle_blendRamp(PyObject * /*self*/, PyObject *args)
|
||||
int type;
|
||||
float a[3], fac, b[3];
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sOfO", &s, &obj1, &fac, &obj2))
|
||||
if (!PyArg_ParseTuple(args, "sOfO", &s, &obj1, &fac, &obj2)) {
|
||||
return NULL;
|
||||
}
|
||||
type = ramp_blend_type(s);
|
||||
if (type < 0) {
|
||||
PyErr_SetString(PyExc_TypeError, "argument 1 is an unknown ramp blend type");
|
||||
@@ -194,8 +213,9 @@ static PyObject *Freestyle_evaluateColorRamp(PyObject * /*self*/, PyObject *args
|
||||
ColorBand *coba;
|
||||
float in, out[4];
|
||||
|
||||
if (!(PyArg_ParseTuple(args, "O!f", &pyrna_struct_Type, &py_srna, &in)))
|
||||
if (!(PyArg_ParseTuple(args, "O!f", &pyrna_struct_Type, &py_srna, &in))) {
|
||||
return NULL;
|
||||
}
|
||||
if (!RNA_struct_is_a(py_srna->ptr.type, &RNA_ColorRamp)) {
|
||||
PyErr_SetString(PyExc_TypeError, "1st argument is not a ColorRamp object");
|
||||
return NULL;
|
||||
@@ -232,8 +252,9 @@ static PyObject *Freestyle_evaluateCurveMappingF(PyObject * /*self*/, PyObject *
|
||||
int cur;
|
||||
float value;
|
||||
|
||||
if (!(PyArg_ParseTuple(args, "O!if", &pyrna_struct_Type, &py_srna, &cur, &value)))
|
||||
if (!(PyArg_ParseTuple(args, "O!if", &pyrna_struct_Type, &py_srna, &cur, &value))) {
|
||||
return NULL;
|
||||
}
|
||||
if (!RNA_struct_is_a(py_srna->ptr.type, &RNA_CurveMapping)) {
|
||||
PyErr_SetString(PyExc_TypeError, "1st argument is not a CurveMapping object");
|
||||
return NULL;
|
||||
@@ -514,8 +535,9 @@ PyObject *Freestyle_Init(void)
|
||||
|
||||
// initialize modules
|
||||
module = PyModule_Create(&module_definition);
|
||||
if (!module)
|
||||
if (!module) {
|
||||
return NULL;
|
||||
}
|
||||
PyDict_SetItemString(PySys_GetObject("modules"), module_definition.m_name, module);
|
||||
|
||||
// update 'sys.path' for Freestyle Python API modules
|
||||
|
||||
@@ -33,11 +33,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int FrsMaterial_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&FrsMaterial_Type) < 0)
|
||||
if (PyType_Ready(&FrsMaterial_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FrsMaterial_Type);
|
||||
PyModule_AddObject(module, "Material", (PyObject *)&FrsMaterial_Type);
|
||||
|
||||
@@ -154,8 +156,9 @@ static PyObject *FrsMaterial_repr(BPy_FrsMaterial *self)
|
||||
|
||||
static int FrsMaterial_mathutils_check(BaseMathObject *bmo)
|
||||
{
|
||||
if (!BPy_FrsMaterial_Check(bmo->cb_user))
|
||||
if (!BPy_FrsMaterial_Check(bmo->cb_user)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,11 +34,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int FrsNoise_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&FrsNoise_Type) < 0)
|
||||
if (PyType_Ready(&FrsNoise_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FrsNoise_Type);
|
||||
PyModule_AddObject(module, "Noise", (PyObject *)&FrsNoise_Type);
|
||||
|
||||
@@ -64,8 +66,9 @@ static int FrsNoise_init(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
|
||||
static const char *kwlist[] = {"seed", NULL};
|
||||
long seed = -1;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|l", (char **)kwlist, &seed))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|l", (char **)kwlist, &seed)) {
|
||||
return -1;
|
||||
}
|
||||
self->n = new Noise(seed);
|
||||
self->pn = new PseudoNoise();
|
||||
return 0;
|
||||
@@ -120,8 +123,9 @@ static PyObject *FrsNoise_turbulence_smooth(BPy_FrsNoise *self, PyObject *args,
|
||||
double x; // note: this has to be a double (not float)
|
||||
unsigned nbOctaves = 8;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "d|I", (char **)kwlist, &x, &nbOctaves))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "d|I", (char **)kwlist, &x, &nbOctaves)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(self->pn->turbulenceSmooth(x, nbOctaves));
|
||||
}
|
||||
|
||||
@@ -131,8 +135,9 @@ static PyObject *FrsNoise_turbulence1(BPy_FrsNoise *self, PyObject *args, PyObje
|
||||
float f1, f2, f3;
|
||||
unsigned int i = 4;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "fff|I", (char **)kwlist, &f1, &f2, &f3, &i))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "fff|I", (char **)kwlist, &f1, &f2, &f3, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(self->n->turbulence1(f1, f2, f3, i));
|
||||
}
|
||||
|
||||
@@ -160,8 +165,9 @@ static PyObject *FrsNoise_turbulence2(BPy_FrsNoise *self, PyObject *args, PyObje
|
||||
unsigned int i = 4;
|
||||
Vec2f vec;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!Vec2f_ptr_from_PyObject(obj1, vec)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
|
||||
@@ -195,8 +201,9 @@ static PyObject *FrsNoise_turbulence3(BPy_FrsNoise *self, PyObject *args, PyObje
|
||||
unsigned int i = 4;
|
||||
Vec3f vec;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "Off|I", (char **)kwlist, &obj1, &f2, &f3, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!Vec3f_ptr_from_PyObject(obj1, vec)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
|
||||
@@ -221,8 +228,9 @@ static PyObject *FrsNoise_smoothNoise1(BPy_FrsNoise *self, PyObject *args, PyObj
|
||||
static const char *kwlist[] = {"v", NULL};
|
||||
float f;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist, &f)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(self->n->smoothNoise1(f));
|
||||
}
|
||||
|
||||
@@ -242,8 +250,9 @@ static PyObject *FrsNoise_smoothNoise2(BPy_FrsNoise *self, PyObject *args, PyObj
|
||||
PyObject *obj;
|
||||
Vec2f vec;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!Vec2f_ptr_from_PyObject(obj, vec)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"argument 1 must be a 2D vector (either a list of 2 elements or Vector)");
|
||||
@@ -269,8 +278,9 @@ static PyObject *FrsNoise_smoothNoise3(BPy_FrsNoise *self, PyObject *args, PyObj
|
||||
PyObject *obj;
|
||||
Vec3f vec;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!Vec3f_ptr_from_PyObject(obj, vec)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
|
||||
|
||||
@@ -31,11 +31,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int Id_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&Id_Type) < 0)
|
||||
if (PyType_Ready(&Id_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Py_INCREF(&Id_Type);
|
||||
PyModule_AddObject(module, "Id", (PyObject *)&Id_Type);
|
||||
|
||||
@@ -211,11 +211,13 @@ int IntegrationType_Init(PyObject *module)
|
||||
{
|
||||
PyObject *m, *d, *f;
|
||||
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&IntegrationType_Type) < 0)
|
||||
if (PyType_Ready(&IntegrationType_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&IntegrationType_Type);
|
||||
PyModule_AddObject(module, "IntegrationType", (PyObject *)&IntegrationType_Type);
|
||||
|
||||
@@ -226,8 +228,9 @@ int IntegrationType_Init(PyObject *module)
|
||||
PyDict_SetItemString(IntegrationType_Type.tp_dict, "LAST", BPy_IntegrationType_LAST);
|
||||
|
||||
m = PyModule_Create(&module_definition);
|
||||
if (m == NULL)
|
||||
if (m == NULL) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(m);
|
||||
PyModule_AddObject(module, "Integrator", m);
|
||||
|
||||
|
||||
@@ -39,41 +39,49 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int Interface0D_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&Interface0D_Type) < 0)
|
||||
if (PyType_Ready(&Interface0D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Interface0D_Type);
|
||||
PyModule_AddObject(module, "Interface0D", (PyObject *)&Interface0D_Type);
|
||||
|
||||
if (PyType_Ready(&CurvePoint_Type) < 0)
|
||||
if (PyType_Ready(&CurvePoint_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&CurvePoint_Type);
|
||||
PyModule_AddObject(module, "CurvePoint", (PyObject *)&CurvePoint_Type);
|
||||
|
||||
if (PyType_Ready(&SVertex_Type) < 0)
|
||||
if (PyType_Ready(&SVertex_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&SVertex_Type);
|
||||
PyModule_AddObject(module, "SVertex", (PyObject *)&SVertex_Type);
|
||||
|
||||
if (PyType_Ready(&ViewVertex_Type) < 0)
|
||||
if (PyType_Ready(&ViewVertex_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ViewVertex_Type);
|
||||
PyModule_AddObject(module, "ViewVertex", (PyObject *)&ViewVertex_Type);
|
||||
|
||||
if (PyType_Ready(&StrokeVertex_Type) < 0)
|
||||
if (PyType_Ready(&StrokeVertex_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&StrokeVertex_Type);
|
||||
PyModule_AddObject(module, "StrokeVertex", (PyObject *)&StrokeVertex_Type);
|
||||
|
||||
if (PyType_Ready(&NonTVertex_Type) < 0)
|
||||
if (PyType_Ready(&NonTVertex_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&NonTVertex_Type);
|
||||
PyModule_AddObject(module, "NonTVertex", (PyObject *)&NonTVertex_Type);
|
||||
|
||||
if (PyType_Ready(&TVertex_Type) < 0)
|
||||
if (PyType_Ready(&TVertex_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&TVertex_Type);
|
||||
PyModule_AddObject(module, "TVertex", (PyObject *)&TVertex_Type);
|
||||
|
||||
@@ -96,8 +104,9 @@ static int Interface0D_init(BPy_Interface0D *self, PyObject *args, PyObject *kwd
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->if0D = new Interface0D();
|
||||
self->borrowed = false;
|
||||
return 0;
|
||||
@@ -105,8 +114,9 @@ static int Interface0D_init(BPy_Interface0D *self, PyObject *args, PyObject *kwd
|
||||
|
||||
static void Interface0D_dealloc(BPy_Interface0D *self)
|
||||
{
|
||||
if (self->if0D && !self->borrowed)
|
||||
if (self->if0D && !self->borrowed) {
|
||||
delete self->if0D;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -132,13 +142,17 @@ static PyObject *Interface0D_get_fedge(BPy_Interface0D *self, PyObject *args, Py
|
||||
static const char *kwlist[] = {"inter", NULL};
|
||||
PyObject *py_if0D;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface0D_Type, &py_if0D))
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "O!", (char **)kwlist, &Interface0D_Type, &py_if0D)) {
|
||||
return NULL;
|
||||
}
|
||||
FEdge *fe = self->if0D->getFEdge(*(((BPy_Interface0D *)py_if0D)->if0D));
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
if (fe)
|
||||
}
|
||||
if (fe) {
|
||||
return Any_BPy_FEdge_from_FEdge(*fe);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -170,8 +184,9 @@ PyDoc_STRVAR(Interface0D_point_3d_doc,
|
||||
static PyObject *Interface0D_point_3d_get(BPy_Interface0D *self, void *UNUSED(closure))
|
||||
{
|
||||
Vec3f p(self->if0D->getPoint3D());
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return Vector_from_Vec3f(p);
|
||||
}
|
||||
|
||||
@@ -183,8 +198,9 @@ PyDoc_STRVAR(Interface0D_projected_x_doc,
|
||||
static PyObject *Interface0D_projected_x_get(BPy_Interface0D *self, void *UNUSED(closure))
|
||||
{
|
||||
real x = self->if0D->getProjectedX();
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(x);
|
||||
}
|
||||
|
||||
@@ -196,8 +212,9 @@ PyDoc_STRVAR(Interface0D_projected_y_doc,
|
||||
static PyObject *Interface0D_projected_y_get(BPy_Interface0D *self, void *UNUSED(closure))
|
||||
{
|
||||
real y = self->if0D->getProjectedY();
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(y);
|
||||
}
|
||||
|
||||
@@ -209,8 +226,9 @@ PyDoc_STRVAR(Interface0D_projected_z_doc,
|
||||
static PyObject *Interface0D_projected_z_get(BPy_Interface0D *self, void *UNUSED(closure))
|
||||
{
|
||||
real z = self->if0D->getProjectedZ();
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(z);
|
||||
}
|
||||
|
||||
@@ -222,8 +240,9 @@ PyDoc_STRVAR(Interface0D_point_2d_doc,
|
||||
static PyObject *Interface0D_point_2d_get(BPy_Interface0D *self, void *UNUSED(closure))
|
||||
{
|
||||
Vec2f p(self->if0D->getPoint2D());
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return Vector_from_Vec2f(p);
|
||||
}
|
||||
|
||||
@@ -235,8 +254,9 @@ PyDoc_STRVAR(Interface0D_id_doc,
|
||||
static PyObject *Interface0D_id_get(BPy_Interface0D *self, void *UNUSED(closure))
|
||||
{
|
||||
Id id(self->if0D->getId());
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return BPy_Id_from_Id(id); // return a copy
|
||||
}
|
||||
|
||||
@@ -248,8 +268,9 @@ PyDoc_STRVAR(Interface0D_nature_doc,
|
||||
static PyObject *Interface0D_nature_get(BPy_Interface0D *self, void *UNUSED(closure))
|
||||
{
|
||||
Nature::VertexNature nature = self->if0D->getNature();
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return BPy_Nature_from_Nature(nature);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,41 +40,49 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int Interface1D_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&Interface1D_Type) < 0)
|
||||
if (PyType_Ready(&Interface1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Interface1D_Type);
|
||||
PyModule_AddObject(module, "Interface1D", (PyObject *)&Interface1D_Type);
|
||||
|
||||
if (PyType_Ready(&FrsCurve_Type) < 0)
|
||||
if (PyType_Ready(&FrsCurve_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FrsCurve_Type);
|
||||
PyModule_AddObject(module, "Curve", (PyObject *)&FrsCurve_Type);
|
||||
|
||||
if (PyType_Ready(&Chain_Type) < 0)
|
||||
if (PyType_Ready(&Chain_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Chain_Type);
|
||||
PyModule_AddObject(module, "Chain", (PyObject *)&Chain_Type);
|
||||
|
||||
if (PyType_Ready(&FEdge_Type) < 0)
|
||||
if (PyType_Ready(&FEdge_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FEdge_Type);
|
||||
PyModule_AddObject(module, "FEdge", (PyObject *)&FEdge_Type);
|
||||
|
||||
if (PyType_Ready(&FEdgeSharp_Type) < 0)
|
||||
if (PyType_Ready(&FEdgeSharp_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FEdgeSharp_Type);
|
||||
PyModule_AddObject(module, "FEdgeSharp", (PyObject *)&FEdgeSharp_Type);
|
||||
|
||||
if (PyType_Ready(&FEdgeSmooth_Type) < 0)
|
||||
if (PyType_Ready(&FEdgeSmooth_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FEdgeSmooth_Type);
|
||||
PyModule_AddObject(module, "FEdgeSmooth", (PyObject *)&FEdgeSmooth_Type);
|
||||
|
||||
if (PyType_Ready(&Stroke_Type) < 0)
|
||||
if (PyType_Ready(&Stroke_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Stroke_Type);
|
||||
PyModule_AddObject(module, "Stroke", (PyObject *)&Stroke_Type);
|
||||
|
||||
@@ -82,8 +90,9 @@ int Interface1D_Init(PyObject *module)
|
||||
PyDict_SetItemString(Stroke_Type.tp_dict, "HUMID_MEDIUM", BPy_MediumType_HUMID_MEDIUM);
|
||||
PyDict_SetItemString(Stroke_Type.tp_dict, "OPAQUE_MEDIUM", BPy_MediumType_OPAQUE_MEDIUM);
|
||||
|
||||
if (PyType_Ready(&ViewEdge_Type) < 0)
|
||||
if (PyType_Ready(&ViewEdge_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ViewEdge_Type);
|
||||
PyModule_AddObject(module, "ViewEdge", (PyObject *)&ViewEdge_Type);
|
||||
|
||||
@@ -106,8 +115,9 @@ static int Interface1D_init(BPy_Interface1D *self, PyObject *args, PyObject *kwd
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->if1D = new Interface1D();
|
||||
self->borrowed = false;
|
||||
return 0;
|
||||
@@ -115,8 +125,9 @@ static int Interface1D_init(BPy_Interface1D *self, PyObject *args, PyObject *kwd
|
||||
|
||||
static void Interface1D_dealloc(BPy_Interface1D *self)
|
||||
{
|
||||
if (self->if1D && !self->borrowed)
|
||||
if (self->if1D && !self->borrowed) {
|
||||
delete self->if1D;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -175,8 +186,9 @@ static PyObject *Interface1D_points_begin(BPy_Interface1D *self, PyObject *args,
|
||||
static const char *kwlist[] = {"t", NULL};
|
||||
float f = 0.0f;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) {
|
||||
return NULL;
|
||||
}
|
||||
Interface0DIterator if0D_it(self->if1D->pointsBegin(f));
|
||||
return BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, false);
|
||||
}
|
||||
@@ -200,8 +212,9 @@ static PyObject *Interface1D_points_end(BPy_Interface1D *self, PyObject *args, P
|
||||
static const char *kwlist[] = {"t", NULL};
|
||||
float f = 0.0f;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) {
|
||||
return NULL;
|
||||
}
|
||||
Interface0DIterator if0D_it(self->if1D->pointsEnd(f));
|
||||
return BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, true);
|
||||
}
|
||||
@@ -246,8 +259,9 @@ PyDoc_STRVAR(Interface1D_id_doc,
|
||||
static PyObject *Interface1D_id_get(BPy_Interface1D *self, void *UNUSED(closure))
|
||||
{
|
||||
Id id(self->if1D->getId());
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return BPy_Id_from_Id(id); // return a copy
|
||||
}
|
||||
|
||||
@@ -259,8 +273,9 @@ PyDoc_STRVAR(Interface1D_nature_doc,
|
||||
static PyObject *Interface1D_nature_get(BPy_Interface1D *self, void *UNUSED(closure))
|
||||
{
|
||||
Nature::VertexNature nature = self->if1D->getNature();
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return BPy_Nature_from_Nature(nature);
|
||||
}
|
||||
|
||||
@@ -272,8 +287,9 @@ PyDoc_STRVAR(Interface1D_length_2d_doc,
|
||||
static PyObject *Interface1D_length_2d_get(BPy_Interface1D *self, void *UNUSED(closure))
|
||||
{
|
||||
real length = self->if1D->getLength2D();
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble((double)length);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,62 +41,74 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int Iterator_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&Iterator_Type) < 0)
|
||||
if (PyType_Ready(&Iterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Iterator_Type);
|
||||
PyModule_AddObject(module, "Iterator", (PyObject *)&Iterator_Type);
|
||||
|
||||
if (PyType_Ready(&AdjacencyIterator_Type) < 0)
|
||||
if (PyType_Ready(&AdjacencyIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&AdjacencyIterator_Type);
|
||||
PyModule_AddObject(module, "AdjacencyIterator", (PyObject *)&AdjacencyIterator_Type);
|
||||
|
||||
if (PyType_Ready(&Interface0DIterator_Type) < 0)
|
||||
if (PyType_Ready(&Interface0DIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Interface0DIterator_Type);
|
||||
PyModule_AddObject(module, "Interface0DIterator", (PyObject *)&Interface0DIterator_Type);
|
||||
|
||||
if (PyType_Ready(&CurvePointIterator_Type) < 0)
|
||||
if (PyType_Ready(&CurvePointIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&CurvePointIterator_Type);
|
||||
PyModule_AddObject(module, "CurvePointIterator", (PyObject *)&CurvePointIterator_Type);
|
||||
|
||||
if (PyType_Ready(&StrokeVertexIterator_Type) < 0)
|
||||
if (PyType_Ready(&StrokeVertexIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&StrokeVertexIterator_Type);
|
||||
PyModule_AddObject(module, "StrokeVertexIterator", (PyObject *)&StrokeVertexIterator_Type);
|
||||
|
||||
if (PyType_Ready(&SVertexIterator_Type) < 0)
|
||||
if (PyType_Ready(&SVertexIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&SVertexIterator_Type);
|
||||
PyModule_AddObject(module, "SVertexIterator", (PyObject *)&SVertexIterator_Type);
|
||||
|
||||
if (PyType_Ready(&orientedViewEdgeIterator_Type) < 0)
|
||||
if (PyType_Ready(&orientedViewEdgeIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&orientedViewEdgeIterator_Type);
|
||||
PyModule_AddObject(
|
||||
module, "orientedViewEdgeIterator", (PyObject *)&orientedViewEdgeIterator_Type);
|
||||
|
||||
if (PyType_Ready(&ViewEdgeIterator_Type) < 0)
|
||||
if (PyType_Ready(&ViewEdgeIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ViewEdgeIterator_Type);
|
||||
PyModule_AddObject(module, "ViewEdgeIterator", (PyObject *)&ViewEdgeIterator_Type);
|
||||
|
||||
if (PyType_Ready(&ChainingIterator_Type) < 0)
|
||||
if (PyType_Ready(&ChainingIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ChainingIterator_Type);
|
||||
PyModule_AddObject(module, "ChainingIterator", (PyObject *)&ChainingIterator_Type);
|
||||
|
||||
if (PyType_Ready(&ChainPredicateIterator_Type) < 0)
|
||||
if (PyType_Ready(&ChainPredicateIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ChainPredicateIterator_Type);
|
||||
PyModule_AddObject(module, "ChainPredicateIterator", (PyObject *)&ChainPredicateIterator_Type);
|
||||
|
||||
if (PyType_Ready(&ChainSilhouetteIterator_Type) < 0)
|
||||
if (PyType_Ready(&ChainSilhouetteIterator_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ChainSilhouetteIterator_Type);
|
||||
PyModule_AddObject(module, "ChainSilhouetteIterator", (PyObject *)&ChainSilhouetteIterator_Type);
|
||||
|
||||
@@ -116,16 +128,18 @@ static int Iterator_init(BPy_Iterator *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->it = new Iterator();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void Iterator_dealloc(BPy_Iterator *self)
|
||||
{
|
||||
if (self->it)
|
||||
if (self->it) {
|
||||
delete self->it;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +96,13 @@ PyLongObject _BPy_MediumType_OPAQUE_MEDIUM = {
|
||||
|
||||
int MediumType_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&MediumType_Type) < 0)
|
||||
if (PyType_Ready(&MediumType_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&MediumType_Type);
|
||||
PyModule_AddObject(module, "MediumType", (PyObject *)&MediumType_Type);
|
||||
|
||||
|
||||
@@ -186,11 +186,13 @@ static PyLongObject _Nature_EDGE_MARK = {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int Nature_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&Nature_Type) < 0)
|
||||
if (PyType_Ready(&Nature_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Nature_Type);
|
||||
PyModule_AddObject(module, "Nature", (PyObject *)&Nature_Type);
|
||||
|
||||
@@ -248,12 +250,14 @@ static PyObject *BPy_Nature_bitwise(PyObject *a, int op, PyObject *b)
|
||||
PyErr_BadArgument();
|
||||
return NULL;
|
||||
}
|
||||
if (v == 0)
|
||||
if (v == 0) {
|
||||
result = PyObject_NewVar(BPy_Nature, &Nature_Type, 0);
|
||||
}
|
||||
else {
|
||||
result = PyObject_NewVar(BPy_Nature, &Nature_Type, 1);
|
||||
if (result)
|
||||
if (result) {
|
||||
result->i.ob_digit[0] = v;
|
||||
}
|
||||
}
|
||||
return (PyObject *)result;
|
||||
}
|
||||
|
||||
@@ -41,11 +41,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int Operators_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&Operators_Type) < 0)
|
||||
if (PyType_Ready(&Operators_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&Operators_Type);
|
||||
PyModule_AddObject(module, "Operators", (PyObject *)&Operators_Type);
|
||||
|
||||
@@ -80,16 +82,18 @@ static PyObject *Operators_select(BPy_Operators * /*self*/, PyObject *args, PyOb
|
||||
PyObject *obj = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "O!", (char **)kwlist, &UnaryPredicate1D_Type, &obj))
|
||||
args, kwds, "O!", (char **)kwlist, &UnaryPredicate1D_Type, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!((BPy_UnaryPredicate1D *)obj)->up1D) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Operators.select(): 1st argument: invalid UnaryPredicate1D object");
|
||||
return NULL;
|
||||
}
|
||||
if (Operators::select(*(((BPy_UnaryPredicate1D *)obj)->up1D)) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.select() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
@@ -165,8 +169,9 @@ static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObj
|
||||
if (!obj3) {
|
||||
if (Operators::chain(*(((BPy_ChainingIterator *)obj1)->c_it),
|
||||
*(((BPy_UnaryPredicate1D *)obj2)->up1D)) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.chain() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -179,8 +184,9 @@ static PyObject *Operators_chain(BPy_Operators * /*self*/, PyObject *args, PyObj
|
||||
if (Operators::chain(*(((BPy_ChainingIterator *)obj1)->c_it),
|
||||
*(((BPy_UnaryPredicate1D *)obj2)->up1D),
|
||||
*(((BPy_UnaryFunction1DVoid *)obj3)->uf1D_void)) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.chain() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -255,8 +261,9 @@ static PyObject *Operators_bidirectional_chain(BPy_Operators * /*self*/,
|
||||
}
|
||||
if (!obj2) {
|
||||
if (Operators::bidirectionalChain(*(((BPy_ChainingIterator *)obj1)->c_it)) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.bidirectional_chain() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -269,8 +276,9 @@ static PyObject *Operators_bidirectional_chain(BPy_Operators * /*self*/,
|
||||
}
|
||||
if (Operators::bidirectionalChain(*(((BPy_ChainingIterator *)obj1)->c_it),
|
||||
*(((BPy_UnaryPredicate1D *)obj2)->up1D)) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.bidirectional_chain() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -351,8 +359,9 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/,
|
||||
if (Operators::sequentialSplit(*(((BPy_UnaryPredicate0D *)obj1)->up0D),
|
||||
*(((BPy_UnaryPredicate0D *)obj2)->up0D),
|
||||
f) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.sequential_split() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -367,8 +376,9 @@ static PyObject *Operators_sequential_split(BPy_Operators * /*self*/,
|
||||
return NULL;
|
||||
}
|
||||
if (Operators::sequentialSplit(*(((BPy_UnaryPredicate0D *)obj1)->up0D), f) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.sequential_split() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -468,8 +478,9 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/,
|
||||
if (Operators::recursiveSplit(*(((BPy_UnaryFunction0DDouble *)obj1)->uf0D_double),
|
||||
*(((BPy_UnaryPredicate1D *)obj2)->up1D),
|
||||
f) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.recursive_split() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -508,8 +519,9 @@ static PyObject *Operators_recursive_split(BPy_Operators * /*self*/,
|
||||
*(((BPy_UnaryPredicate0D *)obj2)->up0D),
|
||||
*(((BPy_UnaryPredicate1D *)obj3)->up1D),
|
||||
f) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.recursive_split() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -535,16 +547,18 @@ static PyObject *Operators_sort(BPy_Operators * /*self*/, PyObject *args, PyObje
|
||||
PyObject *obj = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "O!", (char **)kwlist, &BinaryPredicate1D_Type, &obj))
|
||||
args, kwds, "O!", (char **)kwlist, &BinaryPredicate1D_Type, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!((BPy_BinaryPredicate1D *)obj)->bp1D) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"Operators.sort(): 1st argument: invalid BinaryPredicate1D object");
|
||||
return NULL;
|
||||
}
|
||||
if (Operators::sort(*(((BPy_BinaryPredicate1D *)obj)->bp1D)) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.sort() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
@@ -603,8 +617,9 @@ static PyObject *Operators_create(BPy_Operators * /*self*/, PyObject *args, PyOb
|
||||
shaders.push_back(shader);
|
||||
}
|
||||
if (Operators::create(*(((BPy_UnaryPredicate1D *)obj1)->up1D), shaders) < 0) {
|
||||
if (!PyErr_Occurred())
|
||||
if (!PyErr_Occurred()) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "Operators.create() failed");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
@@ -651,8 +666,9 @@ static PyObject *Operators_get_viewedge_from_index(BPy_Operators * /*self*/,
|
||||
static const char *kwlist[] = {"i", NULL};
|
||||
unsigned int i;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
if (i >= Operators::getViewEdgesSize()) {
|
||||
PyErr_SetString(PyExc_IndexError, "index out of range");
|
||||
return NULL;
|
||||
@@ -677,8 +693,9 @@ static PyObject *Operators_get_chain_from_index(BPy_Operators * /*self*/,
|
||||
static const char *kwlist[] = {"i", NULL};
|
||||
unsigned int i;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
if (i >= Operators::getChainsSize()) {
|
||||
PyErr_SetString(PyExc_IndexError, "index out of range");
|
||||
return NULL;
|
||||
@@ -703,8 +720,9 @@ static PyObject *Operators_get_stroke_from_index(BPy_Operators * /*self*/,
|
||||
static const char *kwlist[] = {"i", NULL};
|
||||
unsigned int i;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", (char **)kwlist, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
if (i >= Operators::getStrokesSize()) {
|
||||
PyErr_SetString(PyExc_IndexError, "index out of range");
|
||||
return NULL;
|
||||
|
||||
@@ -35,11 +35,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int SShape_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&SShape_Type) < 0)
|
||||
if (PyType_Ready(&SShape_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&SShape_Type);
|
||||
PyModule_AddObject(module, "SShape", (PyObject *)&SShape_Type);
|
||||
|
||||
@@ -68,20 +70,24 @@ static int SShape_init(BPy_SShape *self, PyObject *args, PyObject *kwds)
|
||||
static const char *kwlist[] = {"brother", NULL};
|
||||
PyObject *brother = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &SShape_Type, &brother))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &SShape_Type, &brother)) {
|
||||
return -1;
|
||||
if (!brother)
|
||||
}
|
||||
if (!brother) {
|
||||
self->ss = new SShape();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->ss = new SShape(*(((BPy_SShape *)brother)->ss));
|
||||
}
|
||||
self->borrowed = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SShape_dealloc(BPy_SShape *self)
|
||||
{
|
||||
if (self->ss && !self->borrowed)
|
||||
if (self->ss && !self->borrowed) {
|
||||
delete self->ss;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -103,8 +109,9 @@ static PyObject *SShape_add_edge(BPy_SShape *self, PyObject *args, PyObject *kwd
|
||||
static const char *kwlist[] = {"edge", NULL};
|
||||
PyObject *py_fe = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) {
|
||||
return NULL;
|
||||
}
|
||||
self->ss->AddEdge(((BPy_FEdge *)py_fe)->fe);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -123,8 +130,9 @@ static PyObject *SShape_add_vertex(BPy_SShape *self, PyObject *args, PyObject *k
|
||||
static const char *kwlist[] = {"edge", NULL};
|
||||
PyObject *py_sv = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &SVertex_Type, &py_sv))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &SVertex_Type, &py_sv)) {
|
||||
return NULL;
|
||||
}
|
||||
self->ss->AddNewVertex(((BPy_SVertex *)py_sv)->sv);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -31,11 +31,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int StrokeAttribute_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&StrokeAttribute_Type) < 0)
|
||||
if (PyType_Ready(&StrokeAttribute_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&StrokeAttribute_Type);
|
||||
PyModule_AddObject(module, "StrokeAttribute", (PyObject *)&StrokeAttribute_Type);
|
||||
|
||||
@@ -101,10 +103,12 @@ static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObj
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "|O!", (char **)kwlist_1, &StrokeAttribute_Type, &obj1)) {
|
||||
if (!obj1)
|
||||
if (!obj1) {
|
||||
self->sa = new StrokeAttribute();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->sa = new StrokeAttribute(*(((BPy_StrokeAttribute *)obj1)->sa));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(),
|
||||
PyArg_ParseTupleAndKeywords(args,
|
||||
@@ -142,8 +146,9 @@ static int StrokeAttribute_init(BPy_StrokeAttribute *self, PyObject *args, PyObj
|
||||
|
||||
static void StrokeAttribute_dealloc(BPy_StrokeAttribute *self)
|
||||
{
|
||||
if (self->sa && !self->borrowed)
|
||||
if (self->sa && !self->borrowed) {
|
||||
delete self->sa;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -174,8 +179,9 @@ static PyObject *StrokeAttribute_get_attribute_real(BPy_StrokeAttribute *self,
|
||||
static const char *kwlist[] = {"name", NULL};
|
||||
char *attr;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
|
||||
return NULL;
|
||||
}
|
||||
double a = self->sa->getAttributeReal(attr);
|
||||
return PyFloat_FromDouble(a);
|
||||
}
|
||||
@@ -197,8 +203,9 @@ static PyObject *StrokeAttribute_get_attribute_vec2(BPy_StrokeAttribute *self,
|
||||
static const char *kwlist[] = {"name", NULL};
|
||||
char *attr;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
|
||||
return NULL;
|
||||
}
|
||||
Vec2f a = self->sa->getAttributeVec2f(attr);
|
||||
return Vector_from_Vec2f(a);
|
||||
}
|
||||
@@ -220,8 +227,9 @@ static PyObject *StrokeAttribute_get_attribute_vec3(BPy_StrokeAttribute *self,
|
||||
static const char *kwlist[] = {"name", NULL};
|
||||
char *attr;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
|
||||
return NULL;
|
||||
}
|
||||
Vec3f a = self->sa->getAttributeVec3f(attr);
|
||||
return Vector_from_Vec3f(a);
|
||||
}
|
||||
@@ -243,8 +251,9 @@ static PyObject *StrokeAttribute_has_attribute_real(BPy_StrokeAttribute *self,
|
||||
static const char *kwlist[] = {"name", NULL};
|
||||
char *attr;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyBool_from_bool(self->sa->isAttributeAvailableReal(attr));
|
||||
}
|
||||
|
||||
@@ -266,8 +275,9 @@ static PyObject *StrokeAttribute_has_attribute_vec2(BPy_StrokeAttribute *self,
|
||||
static const char *kwlist[] = {"name", NULL};
|
||||
char *attr;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyBool_from_bool(self->sa->isAttributeAvailableVec2f(attr));
|
||||
}
|
||||
|
||||
@@ -289,8 +299,9 @@ static PyObject *StrokeAttribute_has_attribute_vec3(BPy_StrokeAttribute *self,
|
||||
static const char *kwlist[] = {"name", NULL};
|
||||
char *attr;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", (char **)kwlist, &attr)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyBool_from_bool(self->sa->isAttributeAvailableVec3f(attr));
|
||||
}
|
||||
|
||||
@@ -314,8 +325,9 @@ static PyObject *StrokeAttribute_set_attribute_real(BPy_StrokeAttribute *self,
|
||||
char *s = 0;
|
||||
double d = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sd", (char **)kwlist, &s, &d))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sd", (char **)kwlist, &s, &d)) {
|
||||
return NULL;
|
||||
}
|
||||
self->sa->setAttributeReal(s, d);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -341,8 +353,9 @@ static PyObject *StrokeAttribute_set_attribute_vec2(BPy_StrokeAttribute *self,
|
||||
PyObject *obj = 0;
|
||||
Vec2f vec;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!Vec2f_ptr_from_PyObject(obj, vec)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"argument 2 must be a 2D vector (either a list of 2 elements or Vector)");
|
||||
@@ -373,8 +386,9 @@ static PyObject *StrokeAttribute_set_attribute_vec3(BPy_StrokeAttribute *self,
|
||||
PyObject *obj = 0;
|
||||
Vec3f vec;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO", (char **)kwlist, &s, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!Vec3f_ptr_from_PyObject(obj, vec)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"argument 2 must be a 3D vector (either a list of 3 elements or Vector)");
|
||||
@@ -432,8 +446,9 @@ static PyMethodDef BPy_StrokeAttribute_methods[] = {
|
||||
|
||||
static int StrokeAttribute_mathutils_check(BaseMathObject *bmo)
|
||||
{
|
||||
if (!BPy_StrokeAttribute_Check(bmo->cb_user))
|
||||
if (!BPy_StrokeAttribute_Check(bmo->cb_user)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,104 +51,124 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int StrokeShader_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&StrokeShader_Type) < 0)
|
||||
if (PyType_Ready(&StrokeShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&StrokeShader_Type);
|
||||
PyModule_AddObject(module, "StrokeShader", (PyObject *)&StrokeShader_Type);
|
||||
|
||||
if (PyType_Ready(&BackboneStretcherShader_Type) < 0)
|
||||
if (PyType_Ready(&BackboneStretcherShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&BackboneStretcherShader_Type);
|
||||
PyModule_AddObject(module, "BackboneStretcherShader", (PyObject *)&BackboneStretcherShader_Type);
|
||||
|
||||
if (PyType_Ready(&BezierCurveShader_Type) < 0)
|
||||
if (PyType_Ready(&BezierCurveShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&BezierCurveShader_Type);
|
||||
PyModule_AddObject(module, "BezierCurveShader", (PyObject *)&BezierCurveShader_Type);
|
||||
|
||||
if (PyType_Ready(&BlenderTextureShader_Type) < 0)
|
||||
if (PyType_Ready(&BlenderTextureShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&BlenderTextureShader_Type);
|
||||
PyModule_AddObject(module, "BlenderTextureShader", (PyObject *)&BlenderTextureShader_Type);
|
||||
|
||||
if (PyType_Ready(&CalligraphicShader_Type) < 0)
|
||||
if (PyType_Ready(&CalligraphicShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&CalligraphicShader_Type);
|
||||
PyModule_AddObject(module, "CalligraphicShader", (PyObject *)&CalligraphicShader_Type);
|
||||
|
||||
if (PyType_Ready(&ColorNoiseShader_Type) < 0)
|
||||
if (PyType_Ready(&ColorNoiseShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ColorNoiseShader_Type);
|
||||
PyModule_AddObject(module, "ColorNoiseShader", (PyObject *)&ColorNoiseShader_Type);
|
||||
|
||||
if (PyType_Ready(&ConstantColorShader_Type) < 0)
|
||||
if (PyType_Ready(&ConstantColorShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ConstantColorShader_Type);
|
||||
PyModule_AddObject(module, "ConstantColorShader", (PyObject *)&ConstantColorShader_Type);
|
||||
|
||||
if (PyType_Ready(&ConstantThicknessShader_Type) < 0)
|
||||
if (PyType_Ready(&ConstantThicknessShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ConstantThicknessShader_Type);
|
||||
PyModule_AddObject(module, "ConstantThicknessShader", (PyObject *)&ConstantThicknessShader_Type);
|
||||
|
||||
if (PyType_Ready(&ConstrainedIncreasingThicknessShader_Type) < 0)
|
||||
if (PyType_Ready(&ConstrainedIncreasingThicknessShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ConstrainedIncreasingThicknessShader_Type);
|
||||
PyModule_AddObject(module,
|
||||
"ConstrainedIncreasingThicknessShader",
|
||||
(PyObject *)&ConstrainedIncreasingThicknessShader_Type);
|
||||
|
||||
if (PyType_Ready(&GuidingLinesShader_Type) < 0)
|
||||
if (PyType_Ready(&GuidingLinesShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&GuidingLinesShader_Type);
|
||||
PyModule_AddObject(module, "GuidingLinesShader", (PyObject *)&GuidingLinesShader_Type);
|
||||
|
||||
if (PyType_Ready(&IncreasingColorShader_Type) < 0)
|
||||
if (PyType_Ready(&IncreasingColorShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&IncreasingColorShader_Type);
|
||||
PyModule_AddObject(module, "IncreasingColorShader", (PyObject *)&IncreasingColorShader_Type);
|
||||
|
||||
if (PyType_Ready(&IncreasingThicknessShader_Type) < 0)
|
||||
if (PyType_Ready(&IncreasingThicknessShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&IncreasingThicknessShader_Type);
|
||||
PyModule_AddObject(
|
||||
module, "IncreasingThicknessShader", (PyObject *)&IncreasingThicknessShader_Type);
|
||||
|
||||
if (PyType_Ready(&PolygonalizationShader_Type) < 0)
|
||||
if (PyType_Ready(&PolygonalizationShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&PolygonalizationShader_Type);
|
||||
PyModule_AddObject(module, "PolygonalizationShader", (PyObject *)&PolygonalizationShader_Type);
|
||||
|
||||
if (PyType_Ready(&SamplingShader_Type) < 0)
|
||||
if (PyType_Ready(&SamplingShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&SamplingShader_Type);
|
||||
PyModule_AddObject(module, "SamplingShader", (PyObject *)&SamplingShader_Type);
|
||||
|
||||
if (PyType_Ready(&SmoothingShader_Type) < 0)
|
||||
if (PyType_Ready(&SmoothingShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&SmoothingShader_Type);
|
||||
PyModule_AddObject(module, "SmoothingShader", (PyObject *)&SmoothingShader_Type);
|
||||
|
||||
if (PyType_Ready(&SpatialNoiseShader_Type) < 0)
|
||||
if (PyType_Ready(&SpatialNoiseShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&SpatialNoiseShader_Type);
|
||||
PyModule_AddObject(module, "SpatialNoiseShader", (PyObject *)&SpatialNoiseShader_Type);
|
||||
|
||||
if (PyType_Ready(&StrokeTextureStepShader_Type) < 0)
|
||||
if (PyType_Ready(&StrokeTextureStepShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&StrokeTextureStepShader_Type);
|
||||
PyModule_AddObject(module, "StrokeTextureStepShader", (PyObject *)&StrokeTextureStepShader_Type);
|
||||
|
||||
if (PyType_Ready(&ThicknessNoiseShader_Type) < 0)
|
||||
if (PyType_Ready(&ThicknessNoiseShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ThicknessNoiseShader_Type);
|
||||
PyModule_AddObject(module, "ThicknessNoiseShader", (PyObject *)&ThicknessNoiseShader_Type);
|
||||
|
||||
if (PyType_Ready(&TipRemoverShader_Type) < 0)
|
||||
if (PyType_Ready(&TipRemoverShader_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&TipRemoverShader_Type);
|
||||
PyModule_AddObject(module, "TipRemoverShader", (PyObject *)&TipRemoverShader_Type);
|
||||
|
||||
@@ -180,8 +200,9 @@ static int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObjec
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->ss = new StrokeShader();
|
||||
self->ss->py_ss = (PyObject *)self;
|
||||
return 0;
|
||||
@@ -189,8 +210,9 @@ static int StrokeShader___init__(BPy_StrokeShader *self, PyObject *args, PyObjec
|
||||
|
||||
static void StrokeShader___dealloc__(BPy_StrokeShader *self)
|
||||
{
|
||||
if (self->ss)
|
||||
if (self->ss) {
|
||||
delete self->ss;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -212,8 +234,9 @@ static PyObject *StrokeShader_shade(BPy_StrokeShader *self, PyObject *args, PyOb
|
||||
static const char *kwlist[] = {"stroke", NULL};
|
||||
PyObject *py_s = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Stroke_Type, &py_s))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Stroke_Type, &py_s)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (typeid(*(self->ss)) == typeid(StrokeShader)) {
|
||||
PyErr_SetString(PyExc_TypeError, "shade method not properly overridden");
|
||||
|
||||
@@ -40,11 +40,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int UnaryFunction0D_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&UnaryFunction0D_Type) < 0)
|
||||
if (PyType_Ready(&UnaryFunction0D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&UnaryFunction0D_Type);
|
||||
PyModule_AddObject(module, "UnaryFunction0D", (PyObject *)&UnaryFunction0D_Type);
|
||||
|
||||
|
||||
@@ -38,11 +38,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int UnaryFunction1D_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&UnaryFunction1D_Type) < 0)
|
||||
if (PyType_Ready(&UnaryFunction1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&UnaryFunction1D_Type);
|
||||
PyModule_AddObject(module, "UnaryFunction1D", (PyObject *)&UnaryFunction1D_Type);
|
||||
|
||||
|
||||
@@ -34,21 +34,25 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int UnaryPredicate0D_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&UnaryPredicate0D_Type) < 0)
|
||||
if (PyType_Ready(&UnaryPredicate0D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&UnaryPredicate0D_Type);
|
||||
PyModule_AddObject(module, "UnaryPredicate0D", (PyObject *)&UnaryPredicate0D_Type);
|
||||
|
||||
if (PyType_Ready(&FalseUP0D_Type) < 0)
|
||||
if (PyType_Ready(&FalseUP0D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FalseUP0D_Type);
|
||||
PyModule_AddObject(module, "FalseUP0D", (PyObject *)&FalseUP0D_Type);
|
||||
|
||||
if (PyType_Ready(&TrueUP0D_Type) < 0)
|
||||
if (PyType_Ready(&TrueUP0D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&TrueUP0D_Type);
|
||||
PyModule_AddObject(module, "TrueUP0D", (PyObject *)&TrueUP0D_Type);
|
||||
|
||||
@@ -83,8 +87,9 @@ static int UnaryPredicate0D___init__(BPy_UnaryPredicate0D *self, PyObject *args,
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->up0D = new UnaryPredicate0D();
|
||||
self->up0D->py_up0D = (PyObject *)self;
|
||||
return 0;
|
||||
@@ -92,8 +97,9 @@ static int UnaryPredicate0D___init__(BPy_UnaryPredicate0D *self, PyObject *args,
|
||||
|
||||
static void UnaryPredicate0D___dealloc__(BPy_UnaryPredicate0D *self)
|
||||
{
|
||||
if (self->up0D)
|
||||
if (self->up0D) {
|
||||
delete self->up0D;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -110,8 +116,9 @@ static PyObject *UnaryPredicate0D___call__(BPy_UnaryPredicate0D *self,
|
||||
PyObject *py_if0D_it;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &py_if0D_it))
|
||||
args, kwds, "O!", (char **)kwlist, &Interface0DIterator_Type, &py_if0D_it)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Interface0DIterator *if0D_it = ((BPy_Interface0DIterator *)py_if0D_it)->if0D_it;
|
||||
|
||||
|
||||
@@ -43,63 +43,75 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int UnaryPredicate1D_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&UnaryPredicate1D_Type) < 0)
|
||||
if (PyType_Ready(&UnaryPredicate1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&UnaryPredicate1D_Type);
|
||||
PyModule_AddObject(module, "UnaryPredicate1D", (PyObject *)&UnaryPredicate1D_Type);
|
||||
|
||||
if (PyType_Ready(&ContourUP1D_Type) < 0)
|
||||
if (PyType_Ready(&ContourUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ContourUP1D_Type);
|
||||
PyModule_AddObject(module, "ContourUP1D", (PyObject *)&ContourUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&DensityLowerThanUP1D_Type) < 0)
|
||||
if (PyType_Ready(&DensityLowerThanUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&DensityLowerThanUP1D_Type);
|
||||
PyModule_AddObject(module, "DensityLowerThanUP1D", (PyObject *)&DensityLowerThanUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&EqualToChainingTimeStampUP1D_Type) < 0)
|
||||
if (PyType_Ready(&EqualToChainingTimeStampUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&EqualToChainingTimeStampUP1D_Type);
|
||||
PyModule_AddObject(
|
||||
module, "EqualToChainingTimeStampUP1D", (PyObject *)&EqualToChainingTimeStampUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&EqualToTimeStampUP1D_Type) < 0)
|
||||
if (PyType_Ready(&EqualToTimeStampUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&EqualToTimeStampUP1D_Type);
|
||||
PyModule_AddObject(module, "EqualToTimeStampUP1D", (PyObject *)&EqualToTimeStampUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&ExternalContourUP1D_Type) < 0)
|
||||
if (PyType_Ready(&ExternalContourUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ExternalContourUP1D_Type);
|
||||
PyModule_AddObject(module, "ExternalContourUP1D", (PyObject *)&ExternalContourUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&FalseUP1D_Type) < 0)
|
||||
if (PyType_Ready(&FalseUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&FalseUP1D_Type);
|
||||
PyModule_AddObject(module, "FalseUP1D", (PyObject *)&FalseUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&QuantitativeInvisibilityUP1D_Type) < 0)
|
||||
if (PyType_Ready(&QuantitativeInvisibilityUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&QuantitativeInvisibilityUP1D_Type);
|
||||
PyModule_AddObject(
|
||||
module, "QuantitativeInvisibilityUP1D", (PyObject *)&QuantitativeInvisibilityUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&ShapeUP1D_Type) < 0)
|
||||
if (PyType_Ready(&ShapeUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ShapeUP1D_Type);
|
||||
PyModule_AddObject(module, "ShapeUP1D", (PyObject *)&ShapeUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&TrueUP1D_Type) < 0)
|
||||
if (PyType_Ready(&TrueUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&TrueUP1D_Type);
|
||||
PyModule_AddObject(module, "TrueUP1D", (PyObject *)&TrueUP1D_Type);
|
||||
|
||||
if (PyType_Ready(&WithinImageBoundaryUP1D_Type) < 0)
|
||||
if (PyType_Ready(&WithinImageBoundaryUP1D_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&WithinImageBoundaryUP1D_Type);
|
||||
PyModule_AddObject(module, "WithinImageBoundaryUP1D", (PyObject *)&WithinImageBoundaryUP1D_Type);
|
||||
|
||||
@@ -133,8 +145,9 @@ static int UnaryPredicate1D___init__(BPy_UnaryPredicate1D *self, PyObject *args,
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->up1D = new UnaryPredicate1D();
|
||||
self->up1D->py_up1D = (PyObject *)self;
|
||||
return 0;
|
||||
@@ -142,8 +155,9 @@ static int UnaryPredicate1D___init__(BPy_UnaryPredicate1D *self, PyObject *args,
|
||||
|
||||
static void UnaryPredicate1D___dealloc__(BPy_UnaryPredicate1D *self)
|
||||
{
|
||||
if (self->up1D)
|
||||
if (self->up1D) {
|
||||
delete self->up1D;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -159,8 +173,10 @@ static PyObject *UnaryPredicate1D___call__(BPy_UnaryPredicate1D *self,
|
||||
static const char *kwlist[] = {"inter", NULL};
|
||||
PyObject *py_if1D;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &py_if1D))
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "O!", (char **)kwlist, &Interface1D_Type, &py_if1D)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Interface1D *if1D = ((BPy_Interface1D *)py_if1D)->if1D;
|
||||
|
||||
|
||||
@@ -34,11 +34,13 @@ extern "C" {
|
||||
//-------------------MODULE INITIALIZATION--------------------------------
|
||||
int ViewMap_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&ViewMap_Type) < 0)
|
||||
if (PyType_Ready(&ViewMap_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ViewMap_Type);
|
||||
PyModule_AddObject(module, "ViewMap", (PyObject *)&ViewMap_Type);
|
||||
|
||||
@@ -58,16 +60,18 @@ static int ViewMap_init(BPy_ViewMap *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->vm = new ViewMap();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ViewMap_dealloc(BPy_ViewMap *self)
|
||||
{
|
||||
if (self->vm)
|
||||
if (self->vm) {
|
||||
delete self->vm;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -93,11 +97,13 @@ static PyObject *ViewMap_get_closest_viewedge(BPy_ViewMap *self, PyObject *args,
|
||||
static const char *kwlist[] = {"x", "y", NULL};
|
||||
double x, y;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "dd", (char **)kwlist, &x, &y))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "dd", (char **)kwlist, &x, &y)) {
|
||||
return NULL;
|
||||
}
|
||||
ViewEdge *ve = const_cast<ViewEdge *>(self->vm->getClosestViewEdge(x, y));
|
||||
if (ve)
|
||||
if (ve) {
|
||||
return BPy_ViewEdge_from_ViewEdge(*ve);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -118,11 +124,13 @@ static PyObject *ViewMap_get_closest_fedge(BPy_ViewMap *self, PyObject *args, Py
|
||||
static const char *kwlist[] = {"x", "y", NULL};
|
||||
double x, y;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "dd", (char **)kwlist, &x, &y))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "dd", (char **)kwlist, &x, &y)) {
|
||||
return NULL;
|
||||
}
|
||||
FEdge *fe = const_cast<FEdge *>(self->vm->getClosestFEdge(x, y));
|
||||
if (fe)
|
||||
if (fe) {
|
||||
return Any_BPy_FEdge_from_FEdge(*fe);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,11 +35,13 @@ extern "C" {
|
||||
|
||||
int ViewShape_Init(PyObject *module)
|
||||
{
|
||||
if (module == NULL)
|
||||
if (module == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (PyType_Ready(&ViewShape_Type) < 0)
|
||||
if (PyType_Ready(&ViewShape_Type) < 0) {
|
||||
return -1;
|
||||
}
|
||||
Py_INCREF(&ViewShape_Type);
|
||||
PyModule_AddObject(module, "ViewShape", (PyObject *)&ViewShape_Type);
|
||||
|
||||
@@ -107,8 +109,9 @@ static void ViewShape_dealloc(BPy_ViewShape *self)
|
||||
self->vs->setSShape((SShape *)NULL);
|
||||
Py_DECREF(self->py_ss);
|
||||
}
|
||||
if (self->vs && !self->borrowed)
|
||||
if (self->vs && !self->borrowed) {
|
||||
delete self->vs;
|
||||
}
|
||||
Py_TYPE(self)->tp_free((PyObject *)self);
|
||||
}
|
||||
|
||||
@@ -130,8 +133,9 @@ static PyObject *ViewShape_add_edge(BPy_ViewShape *self, PyObject *args, PyObjec
|
||||
static const char *kwlist[] = {"edge", NULL};
|
||||
PyObject *py_ve = 0;
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve))
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
|
||||
return NULL;
|
||||
}
|
||||
self->vs->AddEdge(((BPy_ViewEdge *)py_ve)->ve);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -149,8 +153,9 @@ static PyObject *ViewShape_add_vertex(BPy_ViewShape *self, PyObject *args, PyObj
|
||||
static const char *kwlist[] = {"vertex", NULL};
|
||||
PyObject *py_vv = 0;
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewVertex_Type, &py_vv))
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewVertex_Type, &py_vv)) {
|
||||
return NULL;
|
||||
}
|
||||
self->vs->AddVertex(((BPy_ViewVertex *)py_vv)->vv);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -179,8 +184,9 @@ PyDoc_STRVAR(ViewShape_sshape_doc,
|
||||
static PyObject *ViewShape_sshape_get(BPy_ViewShape *self, void *UNUSED(closure))
|
||||
{
|
||||
SShape *ss = self->vs->sshape();
|
||||
if (!ss)
|
||||
if (!ss) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
return BPy_SShape_from_SShape(*ss);
|
||||
}
|
||||
|
||||
@@ -192,8 +198,9 @@ static int ViewShape_sshape_set(BPy_ViewShape *self, PyObject *value, void *UNUS
|
||||
}
|
||||
BPy_SShape *py_ss = (BPy_SShape *)value;
|
||||
self->vs->setSShape(py_ss->ss);
|
||||
if (self->py_ss)
|
||||
if (self->py_ss) {
|
||||
Py_DECREF(self->py_ss);
|
||||
}
|
||||
if (!py_ss->borrowed) {
|
||||
self->py_ss = py_ss;
|
||||
Py_INCREF(self->py_ss);
|
||||
|
||||
@@ -46,8 +46,9 @@ static int FalseBP1D___init__(BPy_FalseBP1D *self, PyObject *args, PyObject *kwd
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->py_bp1D.bp1D = new Predicates1D::FalseBP1D();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -47,8 +47,9 @@ static int Length2DBP1D___init__(BPy_Length2DBP1D *self, PyObject *args, PyObjec
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->py_bp1D.bp1D = new Predicates1D::Length2DBP1D();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,9 @@ static int SameShapeIdBP1D___init__(BPy_SameShapeIdBP1D *self, PyObject *args, P
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->py_bp1D.bp1D = new Predicates1D::SameShapeIdBP1D();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -46,8 +46,9 @@ static int TrueBP1D___init__(BPy_TrueBP1D *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->py_bp1D.bp1D = new Predicates1D::TrueBP1D();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -75,8 +75,9 @@ static int ViewMapGradientNormBP1D___init__(BPy_ViewMapGradientNormBP1D *self,
|
||||
float f = 2.0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f))
|
||||
args, kwds, "i|O!f", (char **)kwlist, &i, &IntegrationType_Type, &obj, &f)) {
|
||||
return -1;
|
||||
}
|
||||
IntegrationType t = (obj) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN;
|
||||
self->py_bp1D.bp1D = new Predicates1D::ViewMapGradientNormBP1D(i, t, f);
|
||||
return 0;
|
||||
|
||||
@@ -75,12 +75,14 @@ int Director_BPy_BinaryPredicate0D___call__(BinaryPredicate0D *bp0D,
|
||||
PyObject *result = PyObject_CallMethod((PyObject *)bp0D->py_bp0D, "__call__", "OO", arg1, arg2);
|
||||
Py_DECREF(arg1);
|
||||
Py_DECREF(arg2);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
int ret = PyObject_IsTrue(result);
|
||||
Py_DECREF(result);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
bp0D->result = ret;
|
||||
return 0;
|
||||
}
|
||||
@@ -104,12 +106,14 @@ int Director_BPy_BinaryPredicate1D___call__(BinaryPredicate1D *bp1D,
|
||||
PyObject *result = PyObject_CallMethod((PyObject *)bp1D->py_bp1D, "__call__", "OO", arg1, arg2);
|
||||
Py_DECREF(arg1);
|
||||
Py_DECREF(arg2);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
int ret = PyObject_IsTrue(result);
|
||||
Py_DECREF(result);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
bp1D->result = ret;
|
||||
return 0;
|
||||
}
|
||||
@@ -122,16 +126,19 @@ int Director_BPy_UnaryPredicate0D___call__(UnaryPredicate0D *up0D, Interface0DIt
|
||||
return -1;
|
||||
}
|
||||
PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, false);
|
||||
if (!arg)
|
||||
if (!arg) {
|
||||
return -1;
|
||||
}
|
||||
PyObject *result = PyObject_CallMethod((PyObject *)up0D->py_up0D, "__call__", "O", arg);
|
||||
Py_DECREF(arg);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
int ret = PyObject_IsTrue(result);
|
||||
Py_DECREF(result);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
up0D->result = ret;
|
||||
return 0;
|
||||
}
|
||||
@@ -144,16 +151,19 @@ int Director_BPy_UnaryPredicate1D___call__(UnaryPredicate1D *up1D, Interface1D &
|
||||
return -1;
|
||||
}
|
||||
PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D);
|
||||
if (!arg)
|
||||
if (!arg) {
|
||||
return -1;
|
||||
}
|
||||
PyObject *result = PyObject_CallMethod((PyObject *)up1D->py_up1D, "__call__", "O", arg);
|
||||
Py_DECREF(arg);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
int ret = PyObject_IsTrue(result);
|
||||
Py_DECREF(result);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
return -1;
|
||||
}
|
||||
up1D->result = ret;
|
||||
return 0;
|
||||
}
|
||||
@@ -166,12 +176,14 @@ int Director_BPy_StrokeShader_shade(StrokeShader *ss, Stroke &s)
|
||||
return -1;
|
||||
}
|
||||
PyObject *arg = BPy_Stroke_from_Stroke(s);
|
||||
if (!arg)
|
||||
if (!arg) {
|
||||
return -1;
|
||||
}
|
||||
PyObject *result = PyObject_CallMethod((PyObject *)ss->py_ss, "shade", "O", arg);
|
||||
Py_DECREF(arg);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
Py_DECREF(result);
|
||||
return 0;
|
||||
}
|
||||
@@ -184,8 +196,9 @@ int Director_BPy_ChainingIterator_init(ChainingIterator *c_it)
|
||||
return -1;
|
||||
}
|
||||
PyObject *result = PyObject_CallMethod((PyObject *)c_it->py_c_it, "init", NULL);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
Py_DECREF(result);
|
||||
return 0;
|
||||
}
|
||||
@@ -197,12 +210,14 @@ int Director_BPy_ChainingIterator_traverse(ChainingIterator *c_it, AdjacencyIter
|
||||
return -1;
|
||||
}
|
||||
PyObject *arg = BPy_AdjacencyIterator_from_AdjacencyIterator(a_it);
|
||||
if (!arg)
|
||||
if (!arg) {
|
||||
return -1;
|
||||
}
|
||||
PyObject *result = PyObject_CallMethod((PyObject *)c_it->py_c_it, "traverse", "O", arg);
|
||||
Py_DECREF(arg);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
if (BPy_ViewEdge_Check(result)) {
|
||||
c_it->result = ((BPy_ViewEdge *)result)->ve;
|
||||
}
|
||||
@@ -227,12 +242,14 @@ int Director_BPy_UnaryFunction0D___call__(void *uf0D, void *py_uf0D, Interface0D
|
||||
}
|
||||
PyObject *obj = (PyObject *)py_uf0D;
|
||||
PyObject *arg = BPy_Interface0DIterator_from_Interface0DIterator(if0D_it, false);
|
||||
if (!arg)
|
||||
if (!arg) {
|
||||
return -1;
|
||||
}
|
||||
PyObject *result = PyObject_CallMethod(obj, "__call__", "O", arg);
|
||||
Py_DECREF(arg);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
if (BPy_UnaryFunction0DDouble_Check(obj)) {
|
||||
((UnaryFunction0D<double> *)uf0D)->result = PyFloat_AsDouble(result);
|
||||
}
|
||||
@@ -253,14 +270,16 @@ int Director_BPy_UnaryFunction0D___call__(void *uf0D, void *py_uf0D, Interface0D
|
||||
}
|
||||
else if (BPy_UnaryFunction0DVec2f_Check(obj)) {
|
||||
Vec2f vec;
|
||||
if (!Vec2f_ptr_from_Vector(result, vec))
|
||||
if (!Vec2f_ptr_from_Vector(result, vec)) {
|
||||
return -1;
|
||||
}
|
||||
((UnaryFunction0D<Vec2f> *)uf0D)->result = vec;
|
||||
}
|
||||
else if (BPy_UnaryFunction0DVec3f_Check(obj)) {
|
||||
Vec3f vec;
|
||||
if (!Vec3f_ptr_from_Vector(result, vec))
|
||||
if (!Vec3f_ptr_from_Vector(result, vec)) {
|
||||
return -1;
|
||||
}
|
||||
((UnaryFunction0D<Vec3f> *)uf0D)->result = vec;
|
||||
}
|
||||
else if (BPy_UnaryFunction0DVectorViewShape_Check(obj)) {
|
||||
@@ -287,12 +306,14 @@ int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D
|
||||
}
|
||||
PyObject *obj = (PyObject *)py_uf1D;
|
||||
PyObject *arg = Any_BPy_Interface1D_from_Interface1D(if1D);
|
||||
if (!arg)
|
||||
if (!arg) {
|
||||
return -1;
|
||||
}
|
||||
PyObject *result = PyObject_CallMethod(obj, "__call__", "O", arg);
|
||||
Py_DECREF(arg);
|
||||
if (!result)
|
||||
if (!result) {
|
||||
return -1;
|
||||
}
|
||||
if (BPy_UnaryFunction1DDouble_Check(obj)) {
|
||||
((UnaryFunction1D<double> *)uf1D)->result = PyFloat_AsDouble(result);
|
||||
}
|
||||
@@ -307,14 +328,16 @@ int Director_BPy_UnaryFunction1D___call__(void *uf1D, void *py_uf1D, Interface1D
|
||||
}
|
||||
else if (BPy_UnaryFunction1DVec2f_Check(obj)) {
|
||||
Vec2f vec;
|
||||
if (!Vec2f_ptr_from_Vector(result, vec))
|
||||
if (!Vec2f_ptr_from_Vector(result, vec)) {
|
||||
return -1;
|
||||
}
|
||||
((UnaryFunction1D<Vec2f> *)uf1D)->result = vec;
|
||||
}
|
||||
else if (BPy_UnaryFunction1DVec3f_Check(obj)) {
|
||||
Vec3f vec;
|
||||
if (!Vec3f_ptr_from_Vector(result, vec))
|
||||
if (!Vec3f_ptr_from_Vector(result, vec)) {
|
||||
return -1;
|
||||
}
|
||||
((UnaryFunction1D<Vec3f> *)uf1D)->result = vec;
|
||||
}
|
||||
else if (BPy_UnaryFunction1DVectorViewShape_Check(obj)) {
|
||||
|
||||
@@ -88,10 +88,12 @@ static int CurvePoint_init(BPy_CurvePoint *self, PyObject *args, PyObject *kwds)
|
||||
float t2d;
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &CurvePoint_Type, &obj1)) {
|
||||
if (!obj1)
|
||||
if (!obj1) {
|
||||
self->cp = new CurvePoint();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->cp = new CurvePoint(*(((BPy_CurvePoint *)obj1)->cp));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(),
|
||||
PyArg_ParseTupleAndKeywords(args,
|
||||
@@ -148,8 +150,9 @@ PyDoc_STRVAR(CurvePoint_first_svertex_doc,
|
||||
static PyObject *CurvePoint_first_svertex_get(BPy_CurvePoint *self, void *UNUSED(closure))
|
||||
{
|
||||
SVertex *A = self->cp->A();
|
||||
if (A)
|
||||
if (A) {
|
||||
return BPy_SVertex_from_SVertex(*A);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -173,8 +176,9 @@ PyDoc_STRVAR(CurvePoint_second_svertex_doc,
|
||||
static PyObject *CurvePoint_second_svertex_get(BPy_CurvePoint *self, void *UNUSED(closure))
|
||||
{
|
||||
SVertex *B = self->cp->B();
|
||||
if (B)
|
||||
if (B) {
|
||||
return BPy_SVertex_from_SVertex(*B);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -201,8 +205,9 @@ static PyObject *CurvePoint_fedge_get(BPy_CurvePoint *self, void *UNUSED(closure
|
||||
SVertex *A = self->cp->A();
|
||||
Interface0D *B = (Interface0D *)self->cp->B();
|
||||
// B can be NULL under certain circumstances
|
||||
if (B)
|
||||
if (B) {
|
||||
return Any_BPy_Interface1D_from_Interface1D(*(A->getFEdge(*B)));
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,10 +65,12 @@ static int SVertex_init(BPy_SVertex *self, PyObject *args, PyObject *kwds)
|
||||
float v[3];
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &SVertex_Type, &obj)) {
|
||||
if (!obj)
|
||||
if (!obj) {
|
||||
self->sv = new SVertex();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->sv = new SVertex(*(((BPy_SVertex *)obj)->sv));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(),
|
||||
PyArg_ParseTupleAndKeywords(
|
||||
@@ -100,8 +102,9 @@ static PyObject *SVertex_add_normal(BPy_SVertex *self, PyObject *args, PyObject
|
||||
PyObject *py_normal;
|
||||
Vec3r n;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_normal))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_normal)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!Vec3r_ptr_from_PyObject(py_normal, n)) {
|
||||
PyErr_SetString(PyExc_TypeError,
|
||||
"argument 1 must be a 3D vector (either a list of 3 elements or Vector)");
|
||||
@@ -124,8 +127,9 @@ static PyObject *SVertex_add_fedge(BPy_SVertex *self, PyObject *args, PyObject *
|
||||
static const char *kwlist[] = {"fedge", NULL};
|
||||
PyObject *py_fe;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) {
|
||||
return NULL;
|
||||
}
|
||||
self->sv->AddFEdge(((BPy_FEdge *)py_fe)->fe);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -152,8 +156,9 @@ static PyMethodDef BPy_SVertex_methods[] = {
|
||||
|
||||
static int SVertex_mathutils_check(BaseMathObject *bmo)
|
||||
{
|
||||
if (!BPy_SVertex_Check(bmo->cb_user))
|
||||
if (!BPy_SVertex_Check(bmo->cb_user)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -378,8 +383,9 @@ PyDoc_STRVAR(SVertex_viewvertex_doc,
|
||||
static PyObject *SVertex_viewvertex_get(BPy_SVertex *self, void *UNUSED(closure))
|
||||
{
|
||||
ViewVertex *vv = self->sv->viewvertex();
|
||||
if (vv)
|
||||
if (vv) {
|
||||
return Any_BPy_ViewVertex_from_ViewVertex(*vv);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -399,8 +405,9 @@ PyDoc_STRVAR(SVertex_curvatures_doc,
|
||||
static PyObject *SVertex_curvatures_get(BPy_SVertex *self, void *UNUSED(closure))
|
||||
{
|
||||
const CurvatureInfo *info = self->sv->getCurvatureInfo();
|
||||
if (!info)
|
||||
if (!info) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
Vec3r e1(info->e1.x(), info->e1.y(), info->e1.z());
|
||||
Vec3r e2(info->e2.x(), info->e2.y(), info->e2.z());
|
||||
Vec3r er(info->er.x(), info->er.y(), info->er.z());
|
||||
|
||||
@@ -105,8 +105,9 @@ static PyObject *ViewVertex_edges_iterator(BPy_ViewVertex *self, PyObject *args,
|
||||
static const char *kwlist[] = {"edge", NULL};
|
||||
PyObject *py_ve;
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve))
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
|
||||
return NULL;
|
||||
}
|
||||
ViewEdge *ve = ((BPy_ViewEdge *)py_ve)->ve;
|
||||
ViewVertexInternal::orientedViewEdgeIterator ove_it(self->vv->edgesIterator(ve));
|
||||
return BPy_orientedViewEdgeIterator_from_orientedViewEdgeIterator(ove_it, false);
|
||||
@@ -132,8 +133,9 @@ PyDoc_STRVAR(ViewVertex_nature_doc,
|
||||
static PyObject *ViewVertex_nature_get(BPy_ViewVertex *self, void *UNUSED(closure))
|
||||
{
|
||||
Nature::VertexNature nature = self->vv->getNature();
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
return BPy_Nature_from_Nature(nature); // return a copy
|
||||
}
|
||||
|
||||
|
||||
@@ -149,10 +149,12 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k
|
||||
&obj1,
|
||||
&StrokeAttribute_Type,
|
||||
&obj2)) {
|
||||
if (!obj2)
|
||||
if (!obj2) {
|
||||
self->sv = new StrokeVertex(((BPy_SVertex *)obj1)->sv);
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->sv = new StrokeVertex(((BPy_SVertex *)obj1)->sv, *(((BPy_StrokeAttribute *)obj2)->sa));
|
||||
}
|
||||
}
|
||||
else {
|
||||
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
|
||||
@@ -171,8 +173,9 @@ static int StrokeVertex_init(BPy_StrokeVertex *self, PyObject *args, PyObject *k
|
||||
|
||||
static int StrokeVertex_mathutils_check(BaseMathObject *bmo)
|
||||
{
|
||||
if (!BPy_StrokeVertex_Check(bmo->cb_user))
|
||||
if (!BPy_StrokeVertex_Check(bmo->cb_user)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,12 +55,15 @@ static int NonTVertex_init(BPy_NonTVertex *self, PyObject *args, PyObject *kwds)
|
||||
static const char *kwlist[] = {"svertex", NULL};
|
||||
PyObject *obj = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &SVertex_Type, &obj))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &SVertex_Type, &obj)) {
|
||||
return -1;
|
||||
if (!obj)
|
||||
}
|
||||
if (!obj) {
|
||||
self->ntv = new NonTVertex();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->ntv = new NonTVertex(((BPy_SVertex *)obj)->sv);
|
||||
}
|
||||
self->py_vv.vv = self->ntv;
|
||||
self->py_vv.py_if0D.if0D = self->ntv;
|
||||
self->py_vv.py_if0D.borrowed = false;
|
||||
@@ -77,8 +80,9 @@ PyDoc_STRVAR(NonTVertex_svertex_doc,
|
||||
static PyObject *NonTVertex_svertex_get(BPy_NonTVertex *self, void *UNUSED(closure))
|
||||
{
|
||||
SVertex *v = self->ntv->svertex();
|
||||
if (v)
|
||||
if (v) {
|
||||
return BPy_SVertex_from_SVertex(*v);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,8 +53,9 @@ static int TVertex_init(BPy_TVertex *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
static const char *kwlist[] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "", (char **)kwlist)) {
|
||||
return -1;
|
||||
}
|
||||
self->tv = new TVertex();
|
||||
self->py_vv.vv = self->tv;
|
||||
self->py_vv.py_if0D.if0D = self->tv;
|
||||
@@ -77,11 +78,13 @@ static PyObject *TVertex_get_svertex(BPy_TVertex *self, PyObject *args, PyObject
|
||||
static const char *kwlist[] = {"fedge", NULL};
|
||||
PyObject *py_fe;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &FEdge_Type, &py_fe)) {
|
||||
return NULL;
|
||||
}
|
||||
SVertex *sv = self->tv->getSVertex(((BPy_FEdge *)py_fe)->fe);
|
||||
if (sv)
|
||||
if (sv) {
|
||||
return BPy_SVertex_from_SVertex(*sv);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -102,11 +105,13 @@ static PyObject *TVertex_get_mate(BPy_TVertex *self, PyObject *args, PyObject *k
|
||||
static const char *kwlist[] = {"viewedge", NULL};
|
||||
PyObject *py_ve;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &ViewEdge_Type, &py_ve)) {
|
||||
return NULL;
|
||||
}
|
||||
ViewEdge *ve = self->tv->mate(((BPy_ViewEdge *)py_ve)->ve);
|
||||
if (ve)
|
||||
if (ve) {
|
||||
return BPy_ViewEdge_from_ViewEdge(*ve);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -132,8 +137,9 @@ PyDoc_STRVAR(TVertex_front_svertex_doc,
|
||||
static PyObject *TVertex_front_svertex_get(BPy_TVertex *self, void *UNUSED(closure))
|
||||
{
|
||||
SVertex *v = self->tv->frontSVertex();
|
||||
if (v)
|
||||
if (v) {
|
||||
return BPy_SVertex_from_SVertex(*v);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -155,8 +161,9 @@ PyDoc_STRVAR(TVertex_back_svertex_doc,
|
||||
static PyObject *TVertex_back_svertex_get(BPy_TVertex *self, void *UNUSED(closure))
|
||||
{
|
||||
SVertex *v = self->tv->backSVertex();
|
||||
if (v)
|
||||
if (v) {
|
||||
return BPy_SVertex_from_SVertex(*v);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,10 +74,12 @@ static int FEdge_init(BPy_FEdge *self, PyObject *args, PyObject *kwds)
|
||||
PyObject *obj1 = 0, *obj2 = 0;
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FEdge_Type, &obj1)) {
|
||||
if (!obj1)
|
||||
if (!obj1) {
|
||||
self->fe = new FEdge();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->fe = new FEdge(*(((BPy_FEdge *)obj1)->fe));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(),
|
||||
PyArg_ParseTupleAndKeywords(args,
|
||||
@@ -108,12 +110,14 @@ static Py_ssize_t FEdge_sq_length(BPy_FEdge * /*self*/)
|
||||
|
||||
static PyObject *FEdge_sq_item(BPy_FEdge *self, int keynum)
|
||||
{
|
||||
if (keynum < 0)
|
||||
if (keynum < 0) {
|
||||
keynum += FEdge_sq_length(self);
|
||||
}
|
||||
if (keynum == 0 || keynum == 1) {
|
||||
SVertex *v = self->fe->operator[](keynum);
|
||||
if (v)
|
||||
if (v) {
|
||||
return BPy_SVertex_from_SVertex(*v);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
PyErr_Format(PyExc_IndexError, "FEdge[index]: index %d out of range", keynum);
|
||||
@@ -143,8 +147,9 @@ PyDoc_STRVAR(FEdge_first_svertex_doc,
|
||||
static PyObject *FEdge_first_svertex_get(BPy_FEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
SVertex *A = self->fe->vertexA();
|
||||
if (A)
|
||||
if (A) {
|
||||
return BPy_SVertex_from_SVertex(*A);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -166,8 +171,9 @@ PyDoc_STRVAR(FEdge_second_svertex_doc,
|
||||
static PyObject *FEdge_second_svertex_get(BPy_FEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
SVertex *B = self->fe->vertexB();
|
||||
if (B)
|
||||
if (B) {
|
||||
return BPy_SVertex_from_SVertex(*B);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -190,8 +196,9 @@ PyDoc_STRVAR(FEdge_next_fedge_doc,
|
||||
static PyObject *FEdge_next_fedge_get(BPy_FEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
FEdge *fe = self->fe->nextEdge();
|
||||
if (fe)
|
||||
if (fe) {
|
||||
return Any_BPy_FEdge_from_FEdge(*fe);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -214,8 +221,9 @@ PyDoc_STRVAR(FEdge_previous_fedge_doc,
|
||||
static PyObject *FEdge_previous_fedge_get(BPy_FEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
FEdge *fe = self->fe->previousEdge();
|
||||
if (fe)
|
||||
if (fe) {
|
||||
return Any_BPy_FEdge_from_FEdge(*fe);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -237,8 +245,9 @@ PyDoc_STRVAR(FEdge_viewedge_doc,
|
||||
static PyObject *FEdge_viewedge_get(BPy_FEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
ViewEdge *ve = self->fe->viewedge();
|
||||
if (ve)
|
||||
if (ve) {
|
||||
return BPy_ViewEdge_from_ViewEdge(*ve);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,10 +65,12 @@ static int FrsCurve_init(BPy_FrsCurve *self, PyObject *args, PyObject *kwds)
|
||||
PyObject *obj = 0;
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FrsCurve_Type, &obj)) {
|
||||
if (!obj)
|
||||
if (!obj) {
|
||||
self->c = new Curve();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->c = new Curve(*(((BPy_FrsCurve *)obj)->c));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(),
|
||||
PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj)) {
|
||||
@@ -96,8 +98,9 @@ static PyObject *FrsCurve_push_vertex_back(BPy_FrsCurve *self, PyObject *args, P
|
||||
static const char *kwlist[] = {"vertex", NULL};
|
||||
PyObject *obj = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (BPy_CurvePoint_Check(obj)) {
|
||||
self->c->push_vertex_back(((BPy_CurvePoint *)obj)->cp);
|
||||
@@ -125,8 +128,9 @@ static PyObject *FrsCurve_push_vertex_front(BPy_FrsCurve *self, PyObject *args,
|
||||
static const char *kwlist[] = {"vertex", NULL};
|
||||
PyObject *obj = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (BPy_CurvePoint_Check(obj)) {
|
||||
self->c->push_vertex_front(((BPy_CurvePoint *)obj)->cp);
|
||||
|
||||
@@ -62,12 +62,15 @@ static int Stroke_init(BPy_Stroke *self, PyObject *args, PyObject *kwds)
|
||||
static const char *kwlist[] = {"brother", NULL};
|
||||
PyObject *brother = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &Stroke_Type, &brother))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &Stroke_Type, &brother)) {
|
||||
return -1;
|
||||
if (!brother)
|
||||
}
|
||||
if (!brother) {
|
||||
self->s = new Stroke();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->s = new Stroke(*(((BPy_Stroke *)brother)->s));
|
||||
}
|
||||
self->py_if1D.if1D = self->s;
|
||||
self->py_if1D.borrowed = false;
|
||||
return 0;
|
||||
@@ -86,8 +89,9 @@ static Py_ssize_t Stroke_sq_length(BPy_Stroke *self)
|
||||
|
||||
static PyObject *Stroke_sq_item(BPy_Stroke *self, int keynum)
|
||||
{
|
||||
if (keynum < 0)
|
||||
if (keynum < 0) {
|
||||
keynum += Stroke_sq_length(self);
|
||||
}
|
||||
if (keynum < 0 || keynum >= Stroke_sq_length(self)) {
|
||||
PyErr_Format(PyExc_IndexError, "Stroke[index]: index %d out of range", keynum);
|
||||
return NULL;
|
||||
@@ -115,8 +119,9 @@ static PyObject *Stroke_compute_sampling(BPy_Stroke *self, PyObject *args, PyObj
|
||||
static const char *kwlist[] = {"n", NULL};
|
||||
int i;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", (char **)kwlist, &i))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", (char **)kwlist, &i)) {
|
||||
return NULL;
|
||||
}
|
||||
return PyFloat_FromDouble(self->s->ComputeSampling(i));
|
||||
}
|
||||
|
||||
@@ -215,8 +220,10 @@ static PyObject *Stroke_remove_vertex(BPy_Stroke *self, PyObject *args, PyObject
|
||||
static const char *kwlist[] = {"vertex", NULL};
|
||||
PyObject *py_sv = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist, &StrokeVertex_Type, &py_sv))
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "O!", (char **)kwlist, &StrokeVertex_Type, &py_sv)) {
|
||||
return NULL;
|
||||
}
|
||||
if (((BPy_StrokeVertex *)py_sv)->sv) {
|
||||
self->s->RemoveVertex(((BPy_StrokeVertex *)py_sv)->sv);
|
||||
}
|
||||
@@ -267,8 +274,9 @@ static PyObject *Stroke_stroke_vertices_begin(BPy_Stroke *self, PyObject *args,
|
||||
static const char *kwlist[] = {"t", NULL};
|
||||
float f = 0.0f;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|f", (char **)kwlist, &f)) {
|
||||
return NULL;
|
||||
}
|
||||
StrokeInternal::StrokeVertexIterator sv_it(self->s->strokeVerticesBegin(f));
|
||||
return BPy_StrokeVertexIterator_from_StrokeVertexIterator(sv_it, false);
|
||||
}
|
||||
@@ -386,8 +394,9 @@ static PyObject *Stroke_texture_id_get(BPy_Stroke *self, void *UNUSED(closure))
|
||||
static int Stroke_texture_id_set(BPy_Stroke *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
unsigned int i = PyLong_AsUnsignedLong(value);
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return -1;
|
||||
}
|
||||
self->s->setTextureId(i);
|
||||
return 0;
|
||||
}
|
||||
@@ -404,8 +413,9 @@ static PyObject *Stroke_tips_get(BPy_Stroke *self, void *UNUSED(closure))
|
||||
|
||||
static int Stroke_tips_set(BPy_Stroke *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
if (!PyBool_Check(value))
|
||||
if (!PyBool_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->s->setTips(bool_from_PyBool(value));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -59,12 +59,15 @@ static int ViewEdge_init(BPy_ViewEdge *self, PyObject *args, PyObject *kwds)
|
||||
static const char *kwlist[] = {"brother", NULL};
|
||||
PyObject *brother = 0;
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &ViewEdge_Type, &brother))
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist, &ViewEdge_Type, &brother)) {
|
||||
return -1;
|
||||
if (!brother)
|
||||
}
|
||||
if (!brother) {
|
||||
self->ve = new ViewEdge();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->ve = new ViewEdge(*(((BPy_ViewEdge *)brother)->ve));
|
||||
}
|
||||
self->py_if1D.if1D = self->ve;
|
||||
self->py_if1D.borrowed = false;
|
||||
return 0;
|
||||
@@ -99,8 +102,9 @@ PyDoc_STRVAR(ViewEdge_first_viewvertex_doc,
|
||||
static PyObject *ViewEdge_first_viewvertex_get(BPy_ViewEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
ViewVertex *v = self->ve->A();
|
||||
if (v)
|
||||
if (v) {
|
||||
return Any_BPy_ViewVertex_from_ViewVertex(*v);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -108,8 +112,9 @@ static int ViewEdge_first_viewvertex_set(BPy_ViewEdge *self,
|
||||
PyObject *value,
|
||||
void *UNUSED(closure))
|
||||
{
|
||||
if (!BPy_ViewVertex_Check(value))
|
||||
if (!BPy_ViewVertex_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->ve->setA(((BPy_ViewVertex *)value)->vv);
|
||||
return 0;
|
||||
}
|
||||
@@ -122,15 +127,17 @@ PyDoc_STRVAR(ViewEdge_last_viewvertex_doc,
|
||||
static PyObject *ViewEdge_last_viewvertex_get(BPy_ViewEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
ViewVertex *v = self->ve->B();
|
||||
if (v)
|
||||
if (v) {
|
||||
return Any_BPy_ViewVertex_from_ViewVertex(*v);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int ViewEdge_last_viewvertex_set(BPy_ViewEdge *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
if (!BPy_ViewVertex_Check(value))
|
||||
if (!BPy_ViewVertex_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->ve->setB(((BPy_ViewVertex *)value)->vv);
|
||||
return 0;
|
||||
}
|
||||
@@ -143,15 +150,17 @@ PyDoc_STRVAR(ViewEdge_first_fedge_doc,
|
||||
static PyObject *ViewEdge_first_fedge_get(BPy_ViewEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
FEdge *fe = self->ve->fedgeA();
|
||||
if (fe)
|
||||
if (fe) {
|
||||
return Any_BPy_FEdge_from_FEdge(*fe);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int ViewEdge_first_fedge_set(BPy_ViewEdge *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
if (!BPy_FEdge_Check(value))
|
||||
if (!BPy_FEdge_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->ve->setFEdgeA(((BPy_FEdge *)value)->fe);
|
||||
return 0;
|
||||
}
|
||||
@@ -164,15 +173,17 @@ PyDoc_STRVAR(ViewEdge_last_fedge_doc,
|
||||
static PyObject *ViewEdge_last_fedge_get(BPy_ViewEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
FEdge *fe = self->ve->fedgeB();
|
||||
if (fe)
|
||||
if (fe) {
|
||||
return Any_BPy_FEdge_from_FEdge(*fe);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int ViewEdge_last_fedge_set(BPy_ViewEdge *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
if (!BPy_FEdge_Check(value))
|
||||
if (!BPy_FEdge_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->ve->setFEdgeB(((BPy_FEdge *)value)->fe);
|
||||
return 0;
|
||||
}
|
||||
@@ -185,15 +196,17 @@ PyDoc_STRVAR(ViewEdge_viewshape_doc,
|
||||
static PyObject *ViewEdge_viewshape_get(BPy_ViewEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
ViewShape *vs = self->ve->viewShape();
|
||||
if (vs)
|
||||
if (vs) {
|
||||
return BPy_ViewShape_from_ViewShape(*vs);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int ViewEdge_viewshape_set(BPy_ViewEdge *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
if (!BPy_ViewShape_Check(value))
|
||||
if (!BPy_ViewShape_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->ve->setShape(((BPy_ViewShape *)value)->vs);
|
||||
return 0;
|
||||
}
|
||||
@@ -207,15 +220,17 @@ PyDoc_STRVAR(ViewEdge_occludee_doc,
|
||||
static PyObject *ViewEdge_occludee_get(BPy_ViewEdge *self, void *UNUSED(closure))
|
||||
{
|
||||
ViewShape *vs = self->ve->aShape();
|
||||
if (vs)
|
||||
if (vs) {
|
||||
return BPy_ViewShape_from_ViewShape(*vs);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static int ViewEdge_occludee_set(BPy_ViewEdge *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
if (!BPy_ViewShape_Check(value))
|
||||
if (!BPy_ViewShape_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->ve->setaShape(((BPy_ViewShape *)value)->vs);
|
||||
return 0;
|
||||
}
|
||||
@@ -285,8 +300,9 @@ static int ViewEdge_qi_set(BPy_ViewEdge *self, PyObject *value, void *UNUSED(clo
|
||||
{
|
||||
int qi;
|
||||
|
||||
if ((qi = PyLong_AsLong(value)) == -1 && PyErr_Occurred())
|
||||
if ((qi = PyLong_AsLong(value)) == -1 && PyErr_Occurred()) {
|
||||
return -1;
|
||||
}
|
||||
self->ve->setQI(qi);
|
||||
return 0;
|
||||
}
|
||||
@@ -307,8 +323,9 @@ static int ViewEdge_chaining_time_stamp_set(BPy_ViewEdge *self,
|
||||
{
|
||||
int timestamp;
|
||||
|
||||
if ((timestamp = PyLong_AsLong(value)) == -1 && PyErr_Occurred())
|
||||
if ((timestamp = PyLong_AsLong(value)) == -1 && PyErr_Occurred()) {
|
||||
return -1;
|
||||
}
|
||||
self->ve->setChainingTimeStamp(timestamp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -64,10 +64,12 @@ static int Chain_init(BPy_Chain *self, PyObject *args, PyObject *kwds)
|
||||
PyObject *obj = 0;
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &Chain_Type, &obj)) {
|
||||
if (!obj)
|
||||
if (!obj) {
|
||||
self->c = new Chain();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->c = new Chain(*(((BPy_Chain *)obj)->c));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(),
|
||||
PyArg_ParseTupleAndKeywords(args, kwds, "O!", (char **)kwlist_2, &Id_Type, &obj)) {
|
||||
|
||||
@@ -68,10 +68,12 @@ static int FEdgeSharp_init(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds)
|
||||
PyObject *obj1 = 0, *obj2 = 0;
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FEdgeSharp_Type, &obj1)) {
|
||||
if (!obj1)
|
||||
if (!obj1) {
|
||||
self->fes = new FEdgeSharp();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->fes = new FEdgeSharp(*(((BPy_FEdgeSharp *)obj1)->fes));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(),
|
||||
PyArg_ParseTupleAndKeywords(args,
|
||||
@@ -102,8 +104,9 @@ static int FEdgeSharp_init(BPy_FEdgeSharp *self, PyObject *args, PyObject *kwds)
|
||||
|
||||
static int FEdgeSharp_mathutils_check(BaseMathObject *bmo)
|
||||
{
|
||||
if (!BPy_FEdgeSharp_Check(bmo->cb_user))
|
||||
if (!BPy_FEdgeSharp_Check(bmo->cb_user)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -266,8 +269,9 @@ static int FEdgeSharp_material_index_right_set(BPy_FEdgeSharp *self,
|
||||
void *UNUSED(closure))
|
||||
{
|
||||
unsigned int i = PyLong_AsUnsignedLong(value);
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return -1;
|
||||
}
|
||||
self->fes->setaFrsMaterialIndex(i);
|
||||
return 0;
|
||||
}
|
||||
@@ -287,8 +291,9 @@ static int FEdgeSharp_material_index_left_set(BPy_FEdgeSharp *self,
|
||||
void *UNUSED(closure))
|
||||
{
|
||||
unsigned int i = PyLong_AsUnsignedLong(value);
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return -1;
|
||||
}
|
||||
self->fes->setbFrsMaterialIndex(i);
|
||||
return 0;
|
||||
}
|
||||
@@ -330,8 +335,9 @@ static int FEdgeSharp_face_mark_right_set(BPy_FEdgeSharp *self,
|
||||
PyObject *value,
|
||||
void *UNUSED(closure))
|
||||
{
|
||||
if (!PyBool_Check(value))
|
||||
if (!PyBool_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->fes->setaFaceMark(bool_from_PyBool(value));
|
||||
return 0;
|
||||
}
|
||||
@@ -350,8 +356,9 @@ static int FEdgeSharp_face_mark_left_set(BPy_FEdgeSharp *self,
|
||||
PyObject *value,
|
||||
void *UNUSED(closure))
|
||||
{
|
||||
if (!PyBool_Check(value))
|
||||
if (!PyBool_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->fes->setbFaceMark(bool_from_PyBool(value));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -66,10 +66,12 @@ static int FEdgeSmooth_init(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwd
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "|O!", (char **)kwlist_1, &FEdgeSmooth_Type, &obj1)) {
|
||||
if (!obj1)
|
||||
if (!obj1) {
|
||||
self->fes = new FEdgeSmooth();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->fes = new FEdgeSmooth(*(((BPy_FEdgeSmooth *)obj1)->fes));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(),
|
||||
PyArg_ParseTupleAndKeywords(args,
|
||||
@@ -96,8 +98,9 @@ static int FEdgeSmooth_init(BPy_FEdgeSmooth *self, PyObject *args, PyObject *kwd
|
||||
|
||||
static int FEdgeSmooth_mathutils_check(BaseMathObject *bmo)
|
||||
{
|
||||
if (!BPy_FEdgeSmooth_Check(bmo->cb_user))
|
||||
if (!BPy_FEdgeSmooth_Check(bmo->cb_user)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -189,8 +192,9 @@ static int FEdgeSmooth_material_index_set(BPy_FEdgeSmooth *self,
|
||||
void *UNUSED(closure))
|
||||
{
|
||||
unsigned int i = PyLong_AsUnsignedLong(value);
|
||||
if (PyErr_Occurred())
|
||||
if (PyErr_Occurred()) {
|
||||
return -1;
|
||||
}
|
||||
self->fes->setFrsMaterialIndex(i);
|
||||
return 0;
|
||||
}
|
||||
@@ -217,8 +221,9 @@ static PyObject *FEdgeSmooth_face_mark_get(BPy_FEdgeSmooth *self, void *UNUSED(c
|
||||
|
||||
static int FEdgeSmooth_face_mark_set(BPy_FEdgeSmooth *self, PyObject *value, void *UNUSED(closure))
|
||||
{
|
||||
if (!PyBool_Check(value))
|
||||
if (!PyBool_Check(value)) {
|
||||
return -1;
|
||||
}
|
||||
self->fes->setFaceMark(bool_from_PyBool(value));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,9 @@ static PyObject *AdjacencyIterator_iternext(BPy_AdjacencyIterator *self)
|
||||
PyErr_SetNone(PyExc_StopIteration);
|
||||
return NULL;
|
||||
}
|
||||
if (self->at_start)
|
||||
if (self->at_start) {
|
||||
self->at_start = false;
|
||||
}
|
||||
else {
|
||||
self->a_it->increment();
|
||||
if (self->a_it->isEnd()) {
|
||||
@@ -148,8 +149,9 @@ static PyObject *AdjacencyIterator_object_get(BPy_AdjacencyIterator *self, void
|
||||
return NULL;
|
||||
}
|
||||
ViewEdge *ve = self->a_it->operator*();
|
||||
if (ve)
|
||||
if (ve) {
|
||||
return BPy_ViewEdge_from_ViewEdge(*ve);
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,8 +85,9 @@ PyDoc_STRVAR(ChainPredicateIterator_doc,
|
||||
|
||||
static int check_begin(PyObject *obj, void *v)
|
||||
{
|
||||
if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj))
|
||||
if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
|
||||
return 0;
|
||||
}
|
||||
*((PyObject **)v) = obj;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -72,8 +72,9 @@ PyDoc_STRVAR(ChainSilhouetteIterator_doc,
|
||||
|
||||
static int check_begin(PyObject *obj, void *v)
|
||||
{
|
||||
if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj))
|
||||
if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
|
||||
return 0;
|
||||
}
|
||||
*((PyObject **)v) = obj;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -73,8 +73,9 @@ PyDoc_STRVAR(
|
||||
|
||||
static int check_begin(PyObject *obj, void *v)
|
||||
{
|
||||
if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj))
|
||||
if (obj != NULL && obj != Py_None && !BPy_ViewEdge_Check(obj)) {
|
||||
return 0;
|
||||
}
|
||||
*((PyObject **)v) = obj;
|
||||
return 1;
|
||||
}
|
||||
@@ -166,10 +167,12 @@ static PyObject *ChainingIterator_traverse(BPy_ChainingIterator *self,
|
||||
return NULL;
|
||||
}
|
||||
if (!PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "O!", (char **)kwlist, &AdjacencyIterator_Type, &py_a_it))
|
||||
args, kwds, "O!", (char **)kwlist, &AdjacencyIterator_Type, &py_a_it)) {
|
||||
return NULL;
|
||||
if (((BPy_AdjacencyIterator *)py_a_it)->a_it)
|
||||
}
|
||||
if (((BPy_AdjacencyIterator *)py_a_it)->a_it) {
|
||||
self->c_it->traverse(*(((BPy_AdjacencyIterator *)py_a_it)->a_it));
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -196,8 +199,9 @@ static PyObject *ChainingIterator_object_get(BPy_ChainingIterator *self, void *U
|
||||
return NULL;
|
||||
}
|
||||
ViewEdge *ve = self->c_it->operator*();
|
||||
if (ve)
|
||||
if (ve) {
|
||||
return BPy_ViewEdge_from_ViewEdge(*ve);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
@@ -211,8 +215,9 @@ static PyObject *ChainingIterator_next_vertex_get(BPy_ChainingIterator *self,
|
||||
void *UNUSED(closure))
|
||||
{
|
||||
ViewVertex *v = self->c_it->getVertex();
|
||||
if (v)
|
||||
if (v) {
|
||||
return Any_BPy_ViewVertex_from_ViewVertex(*v);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -67,11 +67,13 @@ static int CurvePointIterator_init(BPy_CurvePointIterator *self, PyObject *args,
|
||||
|
||||
if (PyArg_ParseTupleAndKeywords(
|
||||
args, kwds, "|O!", (char **)kwlist_1, &CurvePointIterator_Type, &brother)) {
|
||||
if (!brother)
|
||||
if (!brother) {
|
||||
self->cp_it = new CurveInternal::CurvePointIterator();
|
||||
else
|
||||
}
|
||||
else {
|
||||
self->cp_it = new CurveInternal::CurvePointIterator(
|
||||
*(((BPy_CurvePointIterator *)brother)->cp_it));
|
||||
}
|
||||
}
|
||||
else if (PyErr_Clear(), PyArg_ParseTupleAndKeywords(args, kwds, "f", (char **)kwlist_2, &step)) {
|
||||
self->cp_it = new CurveInternal::CurvePointIterator(step);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user