From cbdc67e2e81cb136a0dca2218dd0ccb6ecc557ca Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Wed, 3 Aug 2011 19:12:18 +0000 Subject: Find all key frames for baked animation export. --- source/blender/collada/AnimationExporter.cpp | 53 ++++++++++++++++++++++++++++ source/blender/collada/AnimationExporter.h | 6 ++++ 2 files changed, 59 insertions(+) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 2f92d9212a9..5a5ec4fea2d 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -61,6 +61,13 @@ void AnimationExporter::exportAnimations(Scene *sce) bool isMatAnim = false; if(ob->adt && ob->adt->action) { + if ( ob->type == OB_ARMATURE ) + { + bArmature *arm = (bArmature*)ob->data; + for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) + bake_bone_animation(ob, bone); + + } fcu = (FCurve*)ob->adt->action->curves.first; while (fcu) { transformName = extract_transform_name( fcu->rna_path ); @@ -318,6 +325,17 @@ void AnimationExporter::exportAnimations(Scene *sce) closeAnimation(); } + void AnimationExporter::bake_bone_animation(Object *ob_arm, Bone *bone) + { + if (!ob_arm->adt) + return; + + sample_and_bake_bone_animation(ob_arm, bone); + + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) + bake_bone_animation(ob_arm, child); + } + void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone) { if (!ob_arm->adt) @@ -334,6 +352,22 @@ void AnimationExporter::exportAnimations(Scene *sce) write_bone_animation(ob_arm, child); } + void AnimationExporter::sample_and_bake_bone_animation(Object *ob_arm, Bone *bone) + { + bArmature *arm = (bArmature*)ob_arm->data; + int flag = arm->flag; + std::vector fra; + char prefix[256]; + + BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); + + bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + if (!pchan) + return; + + find_all_frames(ob_arm, fra); + } + void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) { bArmature *arm = (bArmature*)ob_arm->data; @@ -920,6 +954,25 @@ void AnimationExporter::exportAnimations(Scene *sce) return dot ? (dot + 1) : rna_path; } + void AnimationExporter::find_all_frames(Object *ob, std::vector &fra) + { + FCurve *fcu= (FCurve*)ob->adt->action->curves.first; + std::vector keys; + for (unsigned int i = 0; i < fcu->totvert; i++) { + float f = fcu->bezt[i].vec[1][0]; // + if (std::find(keys.begin(), keys.end(), f) == keys.end()) + keys.push_back(f); + } + + std::sort(keys.begin(), keys.end()); + + for ( float fAll = *(keys.begin()) ; fAll != *(keys.end()) ; fAll+=1.0f ) + { + fra.push_back(fAll); + } + return; + + } void AnimationExporter::find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name) { FCurve *fcu= (FCurve*)ob->adt->action->curves.first; diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 3e3150cd8ef..388d7dbb24d 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -96,10 +96,14 @@ protected: void dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, Material *ma = NULL); + void bake_bone_animation(Object *ob_arm, Bone *bone); + void write_bone_animation(Object *ob_arm, Bone *bone); void sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type); + void sample_and_bake_bone_animation(Object *ob_arm, Bone *bone); + void sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pChan); // dae_bone_animation -> add_bone_animation @@ -134,6 +138,8 @@ protected: std::string get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); void find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name); + + void find_all_frames(Object *ob, std::vector &fra); void find_rotation_frames(Object *ob, std::vector &fra, const char *prefix, int rotmode); -- cgit v1.2.3 From c284725a1a69be3f9a80d88e17be922e6ce63f72 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Thu, 4 Aug 2011 07:12:03 +0000 Subject: 3D Audio GSoC: * versioning stuff for btheme->tv3d.speaker * separating object.c speaker functions in own source file Thanks Brecht for the suggestions. --- source/blender/blenkernel/BKE_object.h | 5 - source/blender/blenkernel/BKE_speaker.h | 43 +++++++ source/blender/blenkernel/CMakeLists.txt | 2 + source/blender/blenkernel/intern/library.c | 1 + source/blender/blenkernel/intern/object.c | 95 +--------------- source/blender/blenkernel/intern/speaker.c | 139 +++++++++++++++++++++++ source/blender/editors/interface/resources.c | 7 ++ source/blender/editors/object/object_add.c | 1 + source/blender/editors/object/object_relations.c | 1 + source/blender/makesrna/intern/rna_main_api.c | 1 + 10 files changed, 196 insertions(+), 99 deletions(-) create mode 100644 source/blender/blenkernel/BKE_speaker.h create mode 100644 source/blender/blenkernel/intern/speaker.c (limited to 'source') diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index f9e01a524ab..a6b5c04b5c3 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -88,11 +88,6 @@ void make_local_lamp(struct Lamp *la); void free_camera(struct Camera *ca); void free_lamp(struct Lamp *la); -void *add_speaker(const char *name); -struct Speaker *copy_speaker(struct Speaker *spk); -void make_local_speaker(struct Speaker *spk); -void free_speaker(struct Speaker *spk); - struct Object *add_only_object(int type, const char *name); struct Object *add_object(struct Scene *scene, int type); diff --git a/source/blender/blenkernel/BKE_speaker.h b/source/blender/blenkernel/BKE_speaker.h new file mode 100644 index 00000000000..111bd86fdd3 --- /dev/null +++ b/source/blender/blenkernel/BKE_speaker.h @@ -0,0 +1,43 @@ +/* + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Jörg Müller. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BKE_SPEAKER_H +#define BKE_SPEAKER_H + +/** \file BKE_speaker.h + * \ingroup bke + * \brief General operations for speakers. + */ + +void *add_speaker(const char *name); +struct Speaker *copy_speaker(struct Speaker *spk); +void make_local_speaker(struct Speaker *spk); +void free_speaker(struct Speaker *spk); + +#endif diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index defcef58463..c1797427cc2 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -140,6 +140,7 @@ set(SRC intern/smoke.c intern/softbody.c intern/sound.c + intern/speaker.c intern/subsurf_ccg.c intern/suggestions.c intern/text.c @@ -220,6 +221,7 @@ set(SRC BKE_smoke.h BKE_softbody.h BKE_sound.h + BKE_speaker.h BKE_subsurf.h BKE_suggestions.h BKE_text.h diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 85f87992c28..8668168936b 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -109,6 +109,7 @@ #include "BKE_particle.h" #include "BKE_gpencil.h" #include "BKE_fcurve.h" +#include "BKE_speaker.h" #include "RNA_access.h" diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 66bf4ea208b..a615bc42f66 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -56,7 +56,6 @@ #include "DNA_sequence_types.h" #include "DNA_sound_types.h" #include "DNA_space_types.h" -#include "DNA_speaker_types.h" #include "DNA_view3d_types.h" #include "DNA_world_types.h" @@ -98,6 +97,7 @@ #include "BKE_sca.h" #include "BKE_scene.h" #include "BKE_sequencer.h" +#include "BKE_speaker.h" #include "BKE_softbody.h" #include "BKE_material.h" @@ -977,99 +977,6 @@ void free_lamp(Lamp *la) la->id.icon_id = 0; } -void *add_speaker(const char *name) -{ - Speaker *spk; - - spk= alloc_libblock(&G.main->speaker, ID_SPK, name); - - spk->attenuation = 1.0f; - spk->cone_angle_inner = 360.0f; - spk->cone_angle_outer = 360.0f; - spk->cone_volume_outer = 1.0f; - spk->distance_max = FLT_MAX; - spk->distance_reference = 1.0f; - spk->flag = 0; - spk->pitch = 1.0f; - spk->sound = NULL; - spk->volume = 1.0f; - spk->volume_max = 1.0f; - spk->volume_min = 0.0f; - - return spk; -} - -Speaker *copy_speaker(Speaker *spk) -{ - Speaker *spkn; - - spkn= copy_libblock(spk); - if(spkn->sound) - spkn->sound->id.us++; - - return spkn; -} - -void make_local_speaker(Speaker *spk) -{ - Main *bmain= G.main; - Object *ob; - int local=0, lib=0; - - /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - - if(spk->id.lib==NULL) return; - if(spk->id.us==1) { - spk->id.lib= NULL; - spk->id.flag= LIB_LOCAL; - new_id(&bmain->speaker, (ID *)spk, NULL); - return; - } - - ob= bmain->object.first; - while(ob) { - if(ob->data==spk) { - if(ob->id.lib) lib= 1; - else local= 1; - } - ob= ob->id.next; - } - - if(local && lib==0) { - spk->id.lib= NULL; - spk->id.flag= LIB_LOCAL; - new_id(&bmain->speaker, (ID *)spk, NULL); - } - else if(local && lib) { - Speaker *spkn= copy_speaker(spk); - spkn->id.us= 0; - - ob= bmain->object.first; - while(ob) { - if(ob->data==spk) { - - if(ob->id.lib==NULL) { - ob->data= spkn; - spkn->id.us++; - spk->id.us--; - } - } - ob= ob->id.next; - } - } -} - -void free_speaker(Speaker *spk) -{ - if(spk->sound) - spk->sound->id.us--; - - BKE_free_animdata((ID *)spk); -} - /* *************************************************** */ static void *add_obdata_from_type(int type) diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c new file mode 100644 index 00000000000..200dbd41899 --- /dev/null +++ b/source/blender/blenkernel/intern/speaker.c @@ -0,0 +1,139 @@ +/* speaker.c + * + * + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Jörg Müller. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/speaker.c + * \ingroup bke + */ + +#include "DNA_object_types.h" +#include "DNA_sound_types.h" +#include "DNA_speaker_types.h" + +#include "BLI_math.h" + +#include "BKE_animsys.h" +#include "BKE_global.h" +#include "BKE_library.h" +#include "BKE_main.h" +#include "BKE_speaker.h" + +void *add_speaker(const char *name) +{ + Speaker *spk; + + spk= alloc_libblock(&G.main->speaker, ID_SPK, name); + + spk->attenuation = 1.0f; + spk->cone_angle_inner = 360.0f; + spk->cone_angle_outer = 360.0f; + spk->cone_volume_outer = 1.0f; + spk->distance_max = FLT_MAX; + spk->distance_reference = 1.0f; + spk->flag = 0; + spk->pitch = 1.0f; + spk->sound = NULL; + spk->volume = 1.0f; + spk->volume_max = 1.0f; + spk->volume_min = 0.0f; + + return spk; +} + +Speaker *copy_speaker(Speaker *spk) +{ + Speaker *spkn; + + spkn= copy_libblock(spk); + if(spkn->sound) + spkn->sound->id.us++; + + return spkn; +} + +void make_local_speaker(Speaker *spk) +{ + Main *bmain= G.main; + Object *ob; + int local=0, lib=0; + + /* - only lib users: do nothing + * - only local users: set flag + * - mixed: make copy + */ + + if(spk->id.lib==NULL) return; + if(spk->id.us==1) { + spk->id.lib= NULL; + spk->id.flag= LIB_LOCAL; + new_id(&bmain->speaker, (ID *)spk, NULL); + return; + } + + ob= bmain->object.first; + while(ob) { + if(ob->data==spk) { + if(ob->id.lib) lib= 1; + else local= 1; + } + ob= ob->id.next; + } + + if(local && lib==0) { + spk->id.lib= NULL; + spk->id.flag= LIB_LOCAL; + new_id(&bmain->speaker, (ID *)spk, NULL); + } + else if(local && lib) { + Speaker *spkn= copy_speaker(spk); + spkn->id.us= 0; + + ob= bmain->object.first; + while(ob) { + if(ob->data==spk) { + + if(ob->id.lib==NULL) { + ob->data= spkn; + spkn->id.us++; + spk->id.us--; + } + } + ob= ob->id.next; + } + } +} + +void free_speaker(Speaker *spk) +{ + if(spk->sound) + spk->sound->id.us--; + + BKE_free_animdata((ID *)spk); +} diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index adabfe5f230..dd63cdf5861 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1594,6 +1594,13 @@ void init_userdef_do_versions(void) NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE; } + { + bTheme *btheme; + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + btheme->tv3d.speaker[3] = 255; + } + } + /* funny name, but it is GE stuff, moves userdef stuff to engine */ // XXX space_set_commmandline_options(); /* this timer uses U */ diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 97a98d2017f..22e6a5243c7 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -73,6 +73,7 @@ #include "BKE_particle.h" #include "BKE_report.h" #include "BKE_sca.h" +#include "BKE_speaker.h" #include "BKE_texture.h" #include "RNA_access.h" diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ce1f47c1b7b..39300cabd5e 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -76,6 +76,7 @@ #include "BKE_report.h" #include "BKE_sca.h" #include "BKE_scene.h" +#include "BKE_speaker.h" #include "BKE_texture.h" #include "WM_api.h" diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 7b951294aee..e99958c2217 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -63,6 +63,7 @@ #include "BKE_particle.h" #include "BKE_font.h" #include "BKE_node.h" +#include "BKE_speaker.h" #include "DNA_armature_types.h" #include "DNA_camera_types.h" -- cgit v1.2.3 From 2ed11158db7cfc157c26475a2dcb5f513043cd72 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 4 Aug 2011 14:06:30 +0000 Subject: Bugfix: Setting of new default settings for new Graph Editors was done in wrong place, leading to loss of settings everytime the view changed (i.e. after open/saving) --- source/blender/editors/space_graph/space_graph.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index fea9e5d71e8..3cc83b12124 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -110,6 +110,10 @@ static SpaceLink *graph_new(const bContext *C) sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); sipo->ads->source= (ID *)scene; + /* settings for making it easier by default to just see what you're interested in tweaking */ + sipo->ads->filterflag |= ADS_FILTER_ONLYSEL; + sipo->flag |= SIPO_SELVHANDLESONLY; + /* header */ ar= MEM_callocN(sizeof(ARegion), "header for graphedit"); @@ -187,10 +191,6 @@ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) sipo->ads->source= (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... } - /* settings for making it easier by default to just see what you're interested in tweaking */ - sipo->ads->filterflag |= ADS_FILTER_ONLYSEL; - sipo->flag |= SIPO_SELVHANDLESONLY; - ED_area_tag_refresh(sa); } -- cgit v1.2.3 From 900928f8bf47b8f1bbb1b2cd863d2d9649c940a0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 4 Aug 2011 14:13:05 +0000 Subject: Bassam Feature Request: "Auto Clamped" handles can now be set per handle/key This used to be a weird per-curve setting which would happen to get applied/work correctly if handles were set to "auto", and was a source of constant confusion for both old and new animators. The main effect of this handle-type/option was really to just ensure that auto-handles stayed horizontal, instead of tilting as the keys were moved. This commit simply changes this from a per-curve to per keyframe/handle setting. --- source/blender/blenkernel/intern/curve.c | 10 ++--- source/blender/blenkernel/intern/fcurve.c | 11 ++---- source/blender/blenkernel/intern/ipo.c | 13 ++++++- source/blender/blenkernel/intern/nla.c | 4 +- source/blender/blenloader/intern/readfile.c | 32 ++++++++++++++++ source/blender/editors/animation/drivers.c | 6 +-- source/blender/editors/animation/keyframes_edit.c | 46 ++++++++++++++--------- source/blender/editors/animation/keyframing.c | 2 +- source/blender/editors/include/UI_resources.h | 2 + source/blender/editors/interface/resources.c | 23 +++++++++++- source/blender/editors/space_action/action_edit.c | 19 +--------- source/blender/editors/space_graph/graph_edit.c | 19 +--------- source/blender/makesdna/DNA_anim_types.h | 2 + source/blender/makesdna/DNA_curve_types.h | 2 +- source/blender/makesdna/DNA_userdef_types.h | 7 +++- source/blender/makesrna/RNA_enum_types.h | 1 + source/blender/makesrna/intern/rna_curve.c | 8 ++++ source/blender/makesrna/intern/rna_fcurve.c | 9 +---- source/blender/makesrna/intern/rna_userdef.c | 17 ++++++++- 19 files changed, 147 insertions(+), 86 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index eb364af6ff8..2f1a85c57b3 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2473,7 +2473,7 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) if(len2==0.0f) len2=1.0f; - if(bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) { /* auto */ + if(ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) || ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { /* auto */ vx= dx1/len2 + dx/len1; vy= dy1/len2 + dy/len1; vz= dz1/len2 + dz/len1; @@ -2484,13 +2484,13 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) if(len1>5.0f*len2) len1= 5.0f*len2; if(len2>5.0f*len1) len2= 5.0f*len1; - if(bezt->h1==HD_AUTO) { + if(ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM)) { len1/=len; *(p2-3)= *p2-vx*len1; *(p2-2)= *(p2+1)-vy*len1; *(p2-1)= *(p2+2)-vz*len1; - if(mode==2 && next && prev) { // keep horizontal if extrema + if((bezt->h1==HD_AUTO_ANIM) && next && prev) { // keep horizontal if extrema float ydiff1= prev->vec[1][1] - bezt->vec[1][1]; float ydiff2= next->vec[1][1] - bezt->vec[1][1]; if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { @@ -2512,13 +2512,13 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) } } } - if(bezt->h2==HD_AUTO) { + if(ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { len2/=len; *(p2+3)= *p2+vx*len2; *(p2+4)= *(p2+1)+vy*len2; *(p2+5)= *(p2+2)+vz*len2; - if(mode==2 && next && prev) { // keep horizontal if extrema + if((bezt->h2==HD_AUTO_ANIM) && next && prev) { // keep horizontal if extrema float ydiff1= prev->vec[1][1] - bezt->vec[1][1]; float ydiff2= next->vec[1][1] - bezt->vec[1][1]; if( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index aa8f817ae3c..28f17b3cf86 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -792,13 +792,10 @@ void calchandles_fcurve (FCurve *fcu) if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0]; /* calculate auto-handles */ - if (fcu->flag & FCURVE_AUTO_HANDLES) - calchandleNurb(bezt, prev, next, 2); /* 2==special autohandle && keep extrema horizontal */ - else - calchandleNurb(bezt, prev, next, 1); /* 1==special autohandle */ + calchandleNurb(bezt, prev, next, 1); /* 1==special autohandle */ /* for automatic ease in and out */ - if ((bezt->h1==HD_AUTO) && (bezt->h2==HD_AUTO)) { + if (ELEM(bezt->h1,HD_AUTO,HD_AUTO_ANIM) && ELEM(bezt->h2,HD_AUTO,HD_AUTO_ANIM)) { /* only do this on first or last beztriple */ if ((a == 0) || (a == fcu->totvert-1)) { /* set both handles to have same horizontal value as keyframe */ @@ -846,9 +843,9 @@ void testhandles_fcurve (FCurve *fcu) /* one or two handles selected only */ if (ELEM(flag, 0, 7)==0) { /* auto handles become aligned */ - if (bezt->h1==HD_AUTO) + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) bezt->h1= HD_ALIGN; - if (bezt->h2==HD_AUTO) + if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) bezt->h2= HD_ALIGN; /* vector handles become 'free' when only one half selected */ diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 104ce2b3b32..d41a3a36b2d 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1157,7 +1157,6 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * if (icu->flag & IPO_ACTIVE) fcu->flag |= FCURVE_ACTIVE; if (icu->flag & IPO_MUTE) fcu->flag |= FCURVE_MUTED; if (icu->flag & IPO_PROTECT) fcu->flag |= FCURVE_PROTECTED; - if (icu->flag & IPO_AUTO_HORIZ) fcu->flag |= FCURVE_AUTO_HANDLES; /* set extrapolation */ switch (icu->extrap) { @@ -1242,6 +1241,12 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* 'hide' flag is now used for keytype - only 'keyframes' existed before */ dst->hide= BEZT_KEYTYPE_KEYFRAME; + /* auto-handles - per curve to per handle */ + if (icu->flag & IPO_AUTO_HORIZ) { + if (dst->h1 == HD_AUTO) dst->h1 = HD_AUTO_ANIM; + if (dst->h2 == HD_AUTO) dst->h2 = HD_AUTO_ANIM; + } + /* correct values, by checking if the flag of interest is set */ if ( ((int)(dst->vec[1][1])) & (abp->bit) ) dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 1.0f; @@ -1292,6 +1297,12 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* 'hide' flag is now used for keytype - only 'keyframes' existed before */ dst->hide= BEZT_KEYTYPE_KEYFRAME; + + /* auto-handles - per curve to per handle */ + if (icu->flag & IPO_AUTO_HORIZ) { + if (dst->h1 == HD_AUTO) dst->h1 = HD_AUTO_ANIM; + if (dst->h2 == HD_AUTO) dst->h2 = HD_AUTO_ANIM; + } /* correct values for euler rotation curves * - they were degrees/10 diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 8391e9f6ab1..f2ce8e4e6f1 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1185,7 +1185,7 @@ void BKE_nlastrip_validate_fcurves (NlaStrip *strip) BLI_addtail(&strip->fcurves, fcu); /* set default flags */ - fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED); + fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); /* store path - make copy, and store that */ fcu->rna_path= BLI_strdupn("influence", 9); @@ -1206,7 +1206,7 @@ void BKE_nlastrip_validate_fcurves (NlaStrip *strip) BLI_addtail(&strip->fcurves, fcu); /* set default flags */ - fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED); + fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); /* store path - make copy, and store that */ fcu->rna_path= BLI_strdupn("strip_time", 10); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1737b44a56f..435ae62123a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11799,6 +11799,38 @@ static void do_versions(FileData *fd, Library *lib, Main *main) SEQ_END } } + { + /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve + * + * We're only patching F-Curves in Actions here, since it is assumed that most + * drivers out there won't be using this (and if they are, they're in the minority). + * While we should aim to fix everything ideally, in practice it's far too hard + * to get to every animdata block, not to mention the performance hit that'd have + */ + bAction *act; + FCurve *fcu; + + for (act = main->action.first; act; act = act->id.next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { + BezTriple *bezt; + unsigned int i = 0; + + /* only need to touch curves that had this flag set */ + if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0) + continue; + if ((fcu->totvert == 0) || (fcu->bezt == NULL)) + continue; + + /* only change auto-handles to auto-clamped */ + for (bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + if (bezt->h1 == HD_AUTO) bezt->h1 = HD_AUTO_ANIM; + if (bezt->h2 == HD_AUTO) bezt->h2 = HD_AUTO_ANIM; + } + + fcu->flag &= ~FCURVE_AUTO_HANDLES; + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index c9e422baa3e..3df65a942da 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -108,7 +108,7 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind /* use default settings to make a F-Curve */ fcu= MEM_callocN(sizeof(FCurve), "FCurve"); - fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED); + fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); /* store path - make copy, and store that */ fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path)); @@ -386,10 +386,6 @@ short ANIM_paste_driver (ReportList *reports, ID *id, const char rna_path[], int copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers); /* flags - on a per-relevant-flag basis */ - if (channeldriver_copypaste_buf->flag & FCURVE_AUTO_HANDLES) - fcu->flag |= FCURVE_AUTO_HANDLES; - else - fcu->flag &= ~FCURVE_AUTO_HANDLES; /* extrapolation mode */ fcu->extend= channeldriver_copypaste_buf->extend; diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 9f3d40a5709..ae9107ebe5a 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -756,20 +756,37 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type) /* ******************************************* */ /* Settings */ +/* standard validation step for a few of these (implemented as macro for inlining without fn-call overhead): + * "if the handles are not of the same type, set them to type free" + */ +#define ENSURE_HANDLES_MATCH(bezt) \ + if (bezt->h1 != bezt->h2) { \ + if ELEM3(bezt->h1, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM) bezt->h1= HD_FREE; \ + if ELEM3(bezt->h2, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM) bezt->h2= HD_FREE; \ + } + /* Sets the selected bezier handles to type 'auto' */ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1= HD_AUTO; /* the secret code for auto */ + if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { + if (bezt->f1 & SELECT) bezt->h1= HD_AUTO; if (bezt->f3 & SELECT) bezt->h2= HD_AUTO; - /* if the handles are not of the same type, set them - * to type free - */ - if (bezt->h1 != bezt->h2) { - if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE; - if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE; - } + ENSURE_HANDLES_MATCH(bezt); + } + return 0; +} + +/* Sets the selected bezier handles to type 'auto-clamped' + * NOTE: this is like auto above, but they're handled a bit different + */ +static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +{ + if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { + if (bezt->f1 & SELECT) bezt->h1= HD_AUTO_ANIM; + if (bezt->f3 & SELECT) bezt->h2= HD_AUTO_ANIM; + + ENSURE_HANDLES_MATCH(bezt); } return 0; } @@ -781,13 +798,7 @@ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt) if (bezt->f1 & SELECT) bezt->h1= HD_VECT; if (bezt->f3 & SELECT) bezt->h2= HD_VECT; - /* if the handles are not of the same type, set them - * to type free - */ - if (bezt->h1 != bezt->h2) { - if ELEM(bezt->h1, HD_ALIGN, HD_AUTO) bezt->h1= HD_FREE; - if ELEM(bezt->h2, HD_ALIGN, HD_AUTO) bezt->h2= HD_FREE; - } + ENSURE_HANDLES_MATCH(bezt); } return 0; } @@ -824,8 +835,9 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code) { switch (code) { case HD_AUTO: /* auto */ - case HD_AUTO_ANIM: /* auto clamped */ return set_bezier_auto; + case HD_AUTO_ANIM: /* auto clamped */ + return set_bezier_auto_clamped; case HD_VECT: /* vector */ return set_bezier_vector; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 109da669ce6..fbedb466f7e 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -174,7 +174,7 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], /* use default settings to make a F-Curve */ fcu= MEM_callocN(sizeof(FCurve), "FCurve"); - fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED); + fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); if (act->curves.first==NULL) fcu->flag |= FCURVE_ACTIVE; /* first one added active */ diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 2bc2aac165f..ff9a1f539a1 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -183,10 +183,12 @@ enum { TH_HANDLE_AUTO, TH_HANDLE_VECT, TH_HANDLE_ALIGN, + TH_HANDLE_AUTOCLAMP, TH_HANDLE_SEL_FREE, TH_HANDLE_SEL_AUTO, TH_HANDLE_SEL_VECT, TH_HANDLE_SEL_ALIGN, + TH_HANDLE_SEL_AUTOCLAMP, TH_ACTIVE_SPLINE, TH_LASTSEL_POINT, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index dd63cdf5861..00c92b85ee7 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -328,6 +328,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp= ts->handle_free; break; case TH_HANDLE_AUTO: cp= ts->handle_auto; break; + case TH_HANDLE_AUTOCLAMP: + cp= ts->handle_auto_clamped; break; case TH_HANDLE_VECT: cp= ts->handle_vect; break; case TH_HANDLE_ALIGN: @@ -336,11 +338,13 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp= ts->handle_sel_free; break; case TH_HANDLE_SEL_AUTO: cp= ts->handle_sel_auto; break; + case TH_HANDLE_SEL_AUTOCLAMP: + cp= ts->handle_sel_auto_clamped; break; case TH_HANDLE_SEL_VECT: cp= ts->handle_sel_vect; break; case TH_HANDLE_SEL_ALIGN: cp= ts->handle_sel_align; break; - + case TH_SYNTAX_B: cp= ts->syntaxb; break; case TH_SYNTAX_V: @@ -667,6 +671,8 @@ void ui_theme_init_default(void) SETCOL(btheme->tipo.handle_vertex, 0, 0, 0, 255); SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255); + SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255); + SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255); btheme->tipo.handle_vertex_size= 4; SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255); @@ -1557,6 +1563,21 @@ void init_userdef_do_versions(void) U.autokey_flag &= ~AUTOKEY_FLAG_ONLYKEYINGSET; } + if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) { + bTheme *btheme; + + /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead */ + if (U.keyhandles_new == HD_AUTO) + U.keyhandles_new = HD_AUTO_ANIM; + + /* theme color additions */ + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + /* auto-clamped handles -> based on auto */ + SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255); + SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255); + } + } + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 40d73a59a42..5276e62b9eb 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1103,17 +1103,6 @@ void ACTION_OT_interpolation_type (wmOperatorType *ot) /* ******************** Set Handle-Type Operator *********************** */ -static EnumPropertyItem actkeys_handle_type_items[] = { - {HD_FREE, "FREE", 0, "Free", ""}, - {HD_VECT, "VECTOR", 0, "Vector", ""}, - {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, - {0, "", 0, "", ""}, - {HD_AUTO, "AUTO", 0, "Auto", "Handles that are automatically adjusted upon moving the keyframe"}, - {HD_AUTO_ANIM, "ANIM_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot"}, - {0, NULL, 0, NULL, NULL}}; - -/* ------------------- */ - /* this function is responsible for setting handle-type of selected keyframes */ static void sethandles_action_keys(bAnimContext *ac, short mode) { @@ -1136,12 +1125,6 @@ static void sethandles_action_keys(bAnimContext *ac, short mode) /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { - /* for auto/auto-clamped, toggle the auto-handles flag on the F-Curve */ - if (mode == HD_AUTO_ANIM) - fcu->flag |= FCURVE_AUTO_HANDLES; - else if (mode == HD_AUTO) - fcu->flag &= ~FCURVE_AUTO_HANDLES; - /* change type of selected handles */ ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve); } @@ -1195,7 +1178,7 @@ void ACTION_OT_handle_type (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - ot->prop= RNA_def_enum(ot->srna, "type", actkeys_handle_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", ""); } /* ******************** Set Keyframe-Type Operator *********************** */ diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index d88a18ffcbc..900aa6f6197 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1447,8 +1447,6 @@ void GRAPH_OT_interpolation_type (wmOperatorType *ot) /* ******************** Set Handle-Type Operator *********************** */ -/* ------------------- */ - /* this function is responsible for setting handle-type of selected keyframes */ static void sethandles_graph_keys(bAnimContext *ac, short mode) { @@ -1471,12 +1469,6 @@ static void sethandles_graph_keys(bAnimContext *ac, short mode) /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { - /* for auto/auto-clamped, toggle the auto-handles flag on the F-Curve */ - if (mode == HD_AUTO_ANIM) - fcu->flag |= FCURVE_AUTO_HANDLES; - else if (mode == HD_AUTO) - fcu->flag &= ~FCURVE_AUTO_HANDLES; - /* change type of selected handles */ ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, edit_cb, calchandles_fcurve); } @@ -1513,15 +1505,6 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) void GRAPH_OT_handle_type (wmOperatorType *ot) { - /* sync with editcurve_handle_type_items */ - static EnumPropertyItem graphkeys_handle_type_items[] = { - {HD_AUTO, "AUTO", 0, "Automatic", "Handles that are automatically adjusted upon moving the keyframe. Whole curve"}, - {HD_VECT, "VECTOR", 0, "Vector", ""}, - {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, - {HD_FREE, "FREE_ALIGN", 0, "Free", ""}, - {HD_AUTO_ANIM, "ANIM_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot. Whole curve"}, - {0, NULL, 0, NULL, NULL}}; - /* identifiers */ ot->name= "Set Keyframe Handle Type"; ot->idname= "GRAPH_OT_handle_type"; @@ -1536,7 +1519,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* id-props */ - ot->prop= RNA_def_enum(ot->srna, "type", graphkeys_handle_type_items, 0, "Type", ""); + ot->prop= RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", ""); } /* ************************************************************************** */ diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 00a9786fc6f..374799ecf08 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -473,7 +473,9 @@ typedef enum eFCurve_Flags { FCURVE_PROTECTED = (1<<3), /* fcurve will not be evaluated for the next round */ FCURVE_MUTED = (1<<4), + /* fcurve uses 'auto-handles', which stay horizontal... */ + // DEPRECATED FCURVE_AUTO_HANDLES = (1<<5), /* skip evaluation, as RNA-path cannot be resolved (similar to muting, but cannot be set by user) */ diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index b51612037fc..a38b33e6640 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -314,7 +314,7 @@ typedef enum eBezTriple_Handle { HD_AUTO, HD_VECT, HD_ALIGN, - HD_AUTO_ANIM /* not real handle type, but is just used as dummy item for anim code */ + HD_AUTO_ANIM /* auto-clamped handles for animation */ } eBezTriple_Handle; /* interpolation modes (used only for BezTriple->ipo) */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 85a64e02ddb..e5558c1738b 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -210,10 +210,13 @@ typedef struct ThemeSpace { char bone_solid[4], bone_pose[4]; char strip[4], strip_select[4]; char cframe[4]; + char nurb_uline[4], nurb_vline[4]; char act_spline[4], nurb_sel_uline[4], nurb_sel_vline[4], lastsel_point[4]; - char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4]; - char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4]; + + char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4], handle_auto_clamped[4]; + char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4], handle_sel_auto_clamped[4]; + char ds_channel[4], ds_subchannel[4]; // dopesheet char console_output[4], console_input[4], console_info[4], console_error[4]; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 56eb20f01b2..d09d1359ce8 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -58,6 +58,7 @@ extern EnumPropertyItem image_type_items[]; extern EnumPropertyItem beztriple_keyframe_type_items[]; extern EnumPropertyItem beztriple_handle_type_items[]; extern EnumPropertyItem beztriple_interpolation_mode_items[]; +extern EnumPropertyItem keyframe_handle_type_items[]; extern EnumPropertyItem keyingset_path_grouping_items[]; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 260d483b9d2..4e7fceed7e1 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -51,6 +51,14 @@ EnumPropertyItem beztriple_handle_type_items[] = { {HD_VECT, "VECTOR", 0, "Vector", ""}, {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, {0, NULL, 0, NULL, NULL}}; + +EnumPropertyItem keyframe_handle_type_items[] = { + {HD_FREE, "FREE", 0, "Free", ""}, + {HD_AUTO, "AUTO", 0, "Auto", ""}, + {HD_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot"}, + {HD_VECT, "VECTOR", 0, "Vector", ""}, + {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, + {0, NULL, 0, NULL, NULL}}; EnumPropertyItem beztriple_interpolation_mode_items[] = { {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""}, diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index cd85e100521..2f37a6921d1 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -1336,13 +1336,13 @@ static void rna_def_fkeyframe(BlenderRNA *brna) /* Enums */ prop= RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "h1"); - RNA_def_property_enum_items(prop, beztriple_handle_type_items); + RNA_def_property_enum_items(prop, keyframe_handle_type_items); RNA_def_property_ui_text(prop, "Left Handle Type", "Handle types"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); prop= RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "h2"); - RNA_def_property_enum_items(prop, beztriple_handle_type_items); + RNA_def_property_enum_items(prop, keyframe_handle_type_items); RNA_def_property_ui_text(prop, "Right Handle Type", "Handle types"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); @@ -1541,11 +1541,6 @@ static void rna_def_fcurve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated"); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); - prop= RNA_def_property(srna, "use_auto_handle_clamp", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_AUTO_HANDLES); - RNA_def_property_ui_text(prop, "Auto Clamped Handles", "All auto-handles for F-Curve are clamped"); - RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); - prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE); RNA_def_property_ui_text(prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 64cd7dc646f..7cafc39d0ff 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -878,6 +878,21 @@ static void rna_def_userdef_theme_spaces_curves(StructRNA *srna, short incl_nurb RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Align handle selected color", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + + if (incl_nurbs == 0) { + /* assume that when nurbs are off, this is for 2D (i.e. anim) editors */ + prop= RNA_def_property(srna, "handle_auto_clamped", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "handle_auto_clamped"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Auto-Clamped handle color", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop= RNA_def_property(srna, "handle_sel_auto_clamped", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "handle_sel_auto_clamped"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Auto-Clamped handle selected color", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + } prop= RNA_def_property(srna, "lastsel_point", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "lastsel_point"); @@ -2254,7 +2269,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "New Interpolation Type", ""); prop= RNA_def_property(srna, "keyframe_new_handle_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, beztriple_handle_type_items); + RNA_def_property_enum_items(prop, keyframe_handle_type_items); RNA_def_property_enum_sdna(prop, NULL, "keyhandles_new"); RNA_def_property_ui_text(prop, "New Handles Type", ""); -- cgit v1.2.3 From e9bd246e3bb71403690364ffb4b58d2cdd7e3998 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 4 Aug 2011 14:19:35 +0000 Subject: Clarifying tooltips on userpref keyframing options These probably still need a good review (based on discussions I've had with animators), but this should be a good stop-gap measure in the mean time --- source/blender/makesrna/intern/rna_userdef.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 7cafc39d0ff..879ff3f3090 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2238,13 +2238,13 @@ static void rna_def_userdef_edit(BlenderRNA *brna) /* auto keyframing */ prop= RNA_def_property(srna, "use_auto_keying", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "autokey_mode", AUTOKEY_ON); - RNA_def_property_ui_text(prop, "Auto Keying Enable", "Automatic keyframe insertion for Objects and Bones"); + RNA_def_property_ui_text(prop, "Auto Keying Enable", "Automatic keyframe insertion for Objects and Bones (default setting used for new Scenes)"); RNA_def_property_ui_icon(prop, ICON_REC, 0); prop= RNA_def_property(srna, "auto_keying_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, auto_key_modes); RNA_def_property_enum_funcs(prop, "rna_userdef_autokeymode_get", "rna_userdef_autokeymode_set", NULL); - RNA_def_property_ui_text(prop, "Auto Keying Mode", "Mode of automatic keyframe insertion for Objects and Bones"); + RNA_def_property_ui_text(prop, "Auto Keying Mode", "Mode of automatic keyframe insertion for Objects and Bones (default setting used for new Scenes)"); prop= RNA_def_property(srna, "use_keyframe_insert_available", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_INSERTAVAIL); @@ -2266,12 +2266,12 @@ static void rna_def_userdef_edit(BlenderRNA *brna) prop= RNA_def_property(srna, "keyframe_new_interpolation_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items); RNA_def_property_enum_sdna(prop, NULL, "ipo_new"); - RNA_def_property_ui_text(prop, "New Interpolation Type", ""); + RNA_def_property_ui_text(prop, "New Interpolation Type", "Interpolation mode used for first keyframe on newly added F-Curves. Subsequent keyframes take interpolation from preceeding keyframe"); prop= RNA_def_property(srna, "keyframe_new_handle_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, keyframe_handle_type_items); RNA_def_property_enum_sdna(prop, NULL, "keyhandles_new"); - RNA_def_property_ui_text(prop, "New Handles Type", ""); + RNA_def_property_ui_text(prop, "New Handles Type", "Handle type for handles of new keyframes"); /* frame numbers */ prop= RNA_def_property(srna, "use_negative_frames", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3 From 74b94dcdf64000c7d681530bf8c833196c58f17d Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Fri, 5 Aug 2011 01:21:08 +0000 Subject: BGE Animations: Moving the do_versions code for the actuators back into the "put compatibility code here until next subversion bump" block. It got sucked into the 2.58.1 block during a merge sometime. --- source/blender/blenloader/intern/readfile.c | 77 ++++++++++++++--------------- 1 file changed, 38 insertions(+), 39 deletions(-) (limited to 'source') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 435ae62123a..e22f5dcb3de 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -11733,45 +11733,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } - - { - /* convert fcurve and shape action actuators to action actuators */ - Object *ob; - bActuator *act; - bIpoActuator *ia; - bActionActuator *aa; - - for (ob= main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { - if (act->type == ACT_IPO) { - // Create the new actuator - ia= act->data; - aa= MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); - - // Copy values - aa->type = ia->type; - aa->flag = ia->flag; - aa->sta = ia->sta; - aa->end = ia->end; - strcpy(aa->name, ia->name); - strcpy(aa->frameProp, ia->frameProp); - if (ob->adt) - aa->act = ob->adt->action; - - // Get rid of the old actuator - MEM_freeN(ia); - - // Assign the new actuator - act->data = aa; - act->type= act->otype= ACT_ACTION; - - } - else if (act->type == ACT_SHAPEACTION) { - act->type = act->otype = ACT_ACTION; - } - } - } - } { ParticleSettings *part; @@ -11831,6 +11792,44 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + { + /* convert fcurve and shape action actuators to action actuators */ + Object *ob; + bActuator *act; + bIpoActuator *ia; + bActionActuator *aa; + + for (ob= main->object.first; ob; ob= ob->id.next) { + for (act= ob->actuators.first; act; act= act->next) { + if (act->type == ACT_IPO) { + // Create the new actuator + ia= act->data; + aa= MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); + + // Copy values + aa->type = ia->type; + aa->flag = ia->flag; + aa->sta = ia->sta; + aa->end = ia->end; + strcpy(aa->name, ia->name); + strcpy(aa->frameProp, ia->frameProp); + if (ob->adt) + aa->act = ob->adt->action; + + // Get rid of the old actuator + MEM_freeN(ia); + + // Assign the new actuator + act->data = aa; + act->type= act->otype= ACT_ACTION; + + } + else if (act->type == ACT_SHAPEACTION) { + act->type = act->otype = ACT_ACTION; + } + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ -- cgit v1.2.3 From dca090abc87fc57cb0a98bbe07ea8868f04f8c97 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Aug 2011 11:23:28 +0000 Subject: Assorted loose ends for auto-clamped handles work * Tweaked order of handle types to make it easier to find Auto/Auto- clamped in the list * Fixed a number of places which were still just checking for auto- handles when they should have included auto-clamped too, including handle rotation --- source/blender/blenkernel/intern/curve.c | 10 +++++----- source/blender/editors/animation/keyframes_edit.c | 4 ++-- source/blender/editors/transform/transform_conversions.c | 2 +- source/blender/makesrna/intern/rna_curve.c | 6 +++--- source/blender/makesrna/intern/rna_fcurve.c | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2f1a85c57b3..b1beb6c449a 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2674,15 +2674,15 @@ void testhandlesNurb(Nurb *nu) if(bezt->f1 & SELECT) flag++; if(bezt->f2 & SELECT) flag += 2; if(bezt->f3 & SELECT) flag += 4; - + if( !(flag==0 || flag==7) ) { - if(bezt->h1==HD_AUTO) { /* auto */ + if(ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ bezt->h1= HD_ALIGN; } - if(bezt->h2==HD_AUTO) { /* auto */ + if(ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ bezt->h2= HD_ALIGN; } - + if(bezt->h1==HD_VECT) { /* vector */ if(flag < 4) bezt->h1= 0; } @@ -2692,7 +2692,7 @@ void testhandlesNurb(Nurb *nu) } bezt++; } - + calchandlesNurb(nu); } diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index ae9107ebe5a..d5fb8b17440 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -634,8 +634,8 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be if (bezt->f2 & SELECT) { bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1]; - if ((bezt->h1==HD_AUTO) || (bezt->h1==HD_VECT)) bezt->h1= HD_ALIGN; - if ((bezt->h2==HD_AUTO) || (bezt->h2==HD_VECT)) bezt->h2= HD_ALIGN; + if (ELEM3(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1= HD_ALIGN; + if (ELEM3(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2= HD_ALIGN; } return 0; } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index b0488ef8b08..7b43d0955a7 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3452,7 +3452,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) * then check if we're using auto-handles. * - If so, change them auto-handles to aligned handles so that handles get affected too */ - if ((bezt->h1 == HD_AUTO) && (bezt->h2 == HD_AUTO) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM) && ELEM(t->mode, TFM_ROTATION, TFM_RESIZE)) { if (hdata && (sel1) && (sel3)) { bezt->h1= HD_ALIGN; bezt->h2= HD_ALIGN; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 4e7fceed7e1..95a76dd7729 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -47,17 +47,17 @@ EnumPropertyItem beztriple_handle_type_items[] = { {HD_FREE, "FREE", 0, "Free", ""}, - {HD_AUTO, "AUTO", 0, "Auto", ""}, {HD_VECT, "VECTOR", 0, "Vector", ""}, {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, + {HD_AUTO, "AUTO", 0, "Auto", ""}, {0, NULL, 0, NULL, NULL}}; EnumPropertyItem keyframe_handle_type_items[] = { {HD_FREE, "FREE", 0, "Free", ""}, - {HD_AUTO, "AUTO", 0, "Auto", ""}, - {HD_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot"}, {HD_VECT, "VECTOR", 0, "Vector", ""}, {HD_ALIGN, "ALIGNED", 0, "Aligned", ""}, + {HD_AUTO, "AUTO", 0, "Automatic", ""}, + {HD_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot"}, {0, NULL, 0, NULL, NULL}}; EnumPropertyItem beztriple_interpolation_mode_items[] = { diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 2f37a6921d1..6bb1416e7fc 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -596,15 +596,15 @@ static void rna_FKeyframe_points_add(FCurve *fcu, int tot) else { fcu->bezt= MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add"); } - + bezt= fcu->bezt + fcu->totvert; fcu->totvert += tot; - + while(tot--) { /* defaults, no userprefs gives pradictable results for API */ bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->ipo= BEZT_IPO_BEZ; - bezt->h1= bezt->h2= HD_AUTO; + bezt->h1= bezt->h2= HD_AUTO_ANIM; bezt++; } } -- cgit v1.2.3 From 861d15738890409067eead832ceab7645c3a4708 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Aug 2011 11:31:41 +0000 Subject: Bugfix [#28106] Missing 3D view update after copy of constraints --- source/blender/editors/object/object_constraint.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index a3df25824a4..2055c906b41 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1115,14 +1115,19 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { /* if we're not handling the object we're copying from, copy all constraints over */ - if (obact != ob) + if (obact != ob) { copy_constraints(&ob->constraints, &obact->constraints, TRUE); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } } CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ DAG_scene_sort(bmain, scene); /* sort order of objects */ - + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, NULL); + return OPERATOR_FINISHED; } -- cgit v1.2.3 From d368716aed1cf5b7fd3f4edc34dbd729160c2fad Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Aug 2011 12:17:49 +0000 Subject: Timeline UI Nitpicks: * "Only Selected channels" -> "Only Selected Channels" * Use Keying Set icon for "only keying set" toggle for autokeying --- source/blender/makesrna/intern/rna_scene.c | 5 ++--- source/blender/makesrna/intern/rna_space.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4b33d23cfe2..170e590522d 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1010,9 +1010,8 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *marker) { - /* try to remove the F-Curve from the action */ if (!BLI_remlink_safe(&scene->markers, marker)) { - BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in action '%s'", marker->name, scene->id.name+2); + BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in scene '%s'", marker->name, scene->id.name+2); return; } @@ -1231,7 +1230,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) prop= RNA_def_property(srna, "use_keyframe_insert_keyingset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_ONLYKEYINGSET); RNA_def_property_ui_text(prop, "Auto Keyframe Insert Keying Set", "Automatic keyframe insertion using active Keying Set only"); - RNA_def_property_ui_icon(prop, ICON_KEY_HLT, 0); // XXX: we need a dedicated icon + RNA_def_property_ui_icon(prop, ICON_KEYINGSET, 0); /* UV */ prop= RNA_def_property(srna, "uv_select_mode", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index fccd00d36df..2ad3022bceb 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2131,7 +2131,7 @@ static void rna_def_space_time(BlenderRNA *brna) /* view settings */ prop= RNA_def_property(srna, "show_only_selected", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", TIME_ONLYACTSEL); - RNA_def_property_ui_text(prop, "Only Selected channels", "Show keyframes for active Object and/or its selected channels only"); + RNA_def_property_ui_text(prop, "Only Selected Channels", "Show keyframes for active Object and/or its selected bones only"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, NULL); prop= RNA_def_property(srna, "show_frame_indicator", PROP_BOOLEAN, PROP_NONE); -- cgit v1.2.3 From 9747e5f2a0f86517f4c96a363544d90f07821cbc Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Fri, 5 Aug 2011 17:19:31 +0000 Subject: --- source/blender/collada/AnimationExporter.cpp | 69 ++++++++++++++++++++++++++-- source/blender/collada/AnimationExporter.h | 2 + 2 files changed, 68 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 5a5ec4fea2d..be70ec137fb 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -366,6 +366,17 @@ void AnimationExporter::exportAnimations(Scene *sce) return; find_all_frames(ob_arm, fra); + + if (flag & ARM_RESTPOS) { + arm->flag &= ~ARM_RESTPOS; + where_is_pose(scene, ob_arm); + } + + if (fra.size()) { + //int total = fra.back() - fra.front(); + float *values = (float*)MEM_callocN(sizeof(float) * 16 * fra.size(), "temp. anim frames"); + sample_animation(values, fra, bone, ob_arm, pchan); + } } void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) @@ -431,6 +442,54 @@ void AnimationExporter::exportAnimations(Scene *sce) where_is_pose(scene, ob_arm); } + void AnimationExporter::sample_animation(float *v, std::vector &frames, Bone *bone, Object *ob_arm, bPoseChannel *pchan) + { + bPoseChannel *parchan = NULL; + bPose *pose = ob_arm->pose; + + pchan = get_pose_channel(pose, bone->name); + + if (!pchan) + return; + + parchan = pchan->parent; + + enable_fcurves(ob_arm->adt->action, bone->name); + + std::vector::iterator it; + int j = 0; + for (it = frames.begin(); it != frames.end(); it++) { + float mat[4][4], ipar[4][4]; + + float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + + //BKE_animsys_evaluate_animdata(&ob_arm->id, ob_arm->adt, *it, ADT_RECALC_ANIM); + //BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + + // compute bone local mat + if (bone->parent) { + invert_m4_m4(ipar, parchan->pose_mat); + mul_m4_m4m4(mat, pchan->pose_mat, ipar); + } + else + copy_m4_m4(mat, pchan->pose_mat); + + for ( int i = 0; i < 4 ; i++) + { + for ( int k = 0; k<4 ; k++ ) + { + v[j*16 + 4*i + k] = mat[i][k]; + } + + } + // copy_m4_m4(v[j*16 + i], mat ) ; + + j++; + } + + enable_fcurves(ob_arm->adt->action, NULL); + } void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) { bPoseChannel *parchan = NULL; @@ -965,10 +1024,14 @@ void AnimationExporter::exportAnimations(Scene *sce) } std::sort(keys.begin(), keys.end()); - - for ( float fAll = *(keys.begin()) ; fAll != *(keys.end()) ; fAll+=1.0f ) + float first, last; + std::vector::reference ref = keys.front(); + first = ref; + ref = keys.back(); + last = ref; + for (float i = first ; i != last ; i+=1.0f ) { - fra.push_back(fAll); + fra.push_back(i); } return; diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 388d7dbb24d..00a0402b810 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -106,6 +106,8 @@ protected: void sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pChan); + void sample_animation(float *v, std::vector &frames, Bone *bone, Object *ob_arm, bPoseChannel *pChan); + // dae_bone_animation -> add_bone_animation // (blend this into dae_bone_animation) void dae_bone_animation(std::vector &fra, float *v, int tm_type, int axis, std::string ob_name, std::string bone_name); -- cgit v1.2.3 From 6829b93c11a4a338e57509465a7d764d9802a013 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Fri, 5 Aug 2011 18:32:39 +0000 Subject: create_4x4_source function --- source/blender/collada/AnimationExporter.cpp | 88 ++++++++++++++++++++++++++-- source/blender/collada/AnimationExporter.h | 6 +- 2 files changed, 87 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index be70ec137fb..1ba9bc3cd28 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -376,6 +376,9 @@ void AnimationExporter::exportAnimations(Scene *sce) //int total = fra.back() - fra.front(); float *values = (float*)MEM_callocN(sizeof(float) * 16 * fra.size(), "temp. anim frames"); sample_animation(values, fra, bone, ob_arm, pchan); + + dae_baked_animation(fra ,values, id_name(ob_arm), bone->name ); + } } @@ -489,6 +492,8 @@ void AnimationExporter::exportAnimations(Scene *sce) } enable_fcurves(ob_arm->adt->action, NULL); + + } void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) { @@ -540,6 +545,47 @@ void AnimationExporter::exportAnimations(Scene *sce) enable_fcurves(ob_arm->adt->action, NULL); } + void AnimationExporter::dae_baked_animation(std::vector &fra, float *values, std::string ob_name, std::string bone_name) + { + char anim_id[200]; + + if (!fra.size()) + return; + + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), + (char*)translate_id(bone_name).c_str(), "pose_matrix"); + + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); + + // create input source + std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, false, anim_id, ""); + + // create output source + std::string output_id; + output_id = create_4x4_source( values, fra.size(), anim_id); + + // create interpolations source + std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, ""); + + std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; + COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); + std::string empty; + sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); + sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); + + // TODO create in/out tangents source + + // this input is required + sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); + + addSampler(sampler); + + std::string target = translate_id(ob_name + "_" + bone_name) + "/transform"; + addChannel(COLLADABU::URI(empty, sampler_id), target); + + closeAnimation(); + } + // dae_bone_animation -> add_bone_animation // (blend this into dae_bone_animation) void AnimationExporter::dae_bone_animation(std::vector &fra, float *values, int tm_type, int axis, std::string ob_name, std::string bone_name) @@ -628,7 +674,7 @@ void AnimationExporter::exportAnimations(Scene *sce) } void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, - COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis) + COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform) { switch(semantic) { case COLLADASW::InputSemantic::INPUT: @@ -642,7 +688,11 @@ void AnimationExporter::exportAnimations(Scene *sce) if (axis) { param.push_back(axis); } - else { //assumes if axis isn't specified all axises are added + else + if ( transform ) + { + param.push_back("TRANSFORM"); + }else{ //assumes if axis isn't specified all axises are added param.push_back("X"); param.push_back("Y"); param.push_back("Z"); @@ -739,7 +789,7 @@ void AnimationExporter::exportAnimations(Scene *sce) COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_angle, axis_name); + add_source_parameters(param, semantic, is_angle, axis_name, false); source.prepareToAppendValues(); @@ -768,7 +818,7 @@ void AnimationExporter::exportAnimations(Scene *sce) source.setAccessorStride(1); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_rot, axis_name); + add_source_parameters(param, semantic, is_rot, axis_name, false); source.prepareToAppendValues(); @@ -798,7 +848,7 @@ void AnimationExporter::exportAnimations(Scene *sce) source.setAccessorStride(1); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_rot, axis_name); + add_source_parameters(param, semantic, is_rot, axis_name, false); source.prepareToAppendValues(); @@ -817,6 +867,32 @@ void AnimationExporter::exportAnimations(Scene *sce) return source_id; } + std::string AnimationExporter::create_4x4_source(float *v, int tot, const std::string& anim_id) + { + COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; + std::string source_id = anim_id + get_semantic_suffix(semantic); + + COLLADASW::Float4x4Source source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(tot); + source.setAccessorStride(16); + + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, false, NULL, false); + + source.prepareToAppendValues(); + + for (int i = 0; i < tot; i++) { + for ( int j = 0 ; j < 4 ; j++ ) + source.appendValues(*(v+j*4), *(v + 4*j +1), *(v + 2 + 4*j), *(v+3 + 4*j)); + v += 16; + } + + source.finish(); + + return source_id; + } // only used for sources with OUTPUT semantic ( locations and scale) std::string AnimationExporter::create_xyz_source(float *v, int tot, const std::string& anim_id) { @@ -830,7 +906,7 @@ void AnimationExporter::exportAnimations(Scene *sce) source.setAccessorStride(3); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, false, NULL); + add_source_parameters(param, semantic, false, NULL, false); source.prepareToAppendValues(); diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 00a0402b810..cadd6940e9d 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -111,6 +111,8 @@ protected: // dae_bone_animation -> add_bone_animation // (blend this into dae_bone_animation) void dae_bone_animation(std::vector &fra, float *v, int tm_type, int axis, std::string ob_name, std::string bone_name); + + void dae_baked_animation(std::vector &fra, float *values, std::string ob_name, std::string bone_name); float convert_time(float frame); @@ -119,7 +121,7 @@ protected: std::string get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic); void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, - COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis); + COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis , bool transform); void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length); @@ -133,6 +135,8 @@ protected: std::string create_xyz_source(float *v, int tot, const std::string& anim_id); + std::string create_4x4_source(float *v, int tot, const std::string& anim_id); + std::string create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents); std::string fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name); -- cgit v1.2.3 From 7e0049d27a699d5eb9f9be0c0b014fe62a78add8 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 6 Aug 2011 00:35:16 +0000 Subject: BGE Animations: Making the ping pong mode for action actuators behave more like trunk. The behavior is a lot closer, but there are still differences when interrupting a ping pong action. I'm still trying to decide if these are acceptable differences as they don't look all that simple to fix. --- source/gameengine/Converter/BL_ActionActuator.cpp | 23 +++++++++++++++++++---- source/gameengine/Converter/BL_ActionActuator.h | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 7bfe87c773e..0932493ccb8 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -153,7 +153,18 @@ bool BL_ActionActuator::Update(double curtime, bool frame) else if (m_playtype == ACT_ACTION_LOOP_STOP) play_mode = BL_Action::ACT_MODE_LOOP; else if (m_playtype == ACT_ACTION_PINGPONG) - play_mode = BL_Action::ACT_MODE_PING_PONG; + { + // We handle ping pong ourselves to increase compabitility with the pre-Pepper actuator + play_mode = BL_Action::ACT_MODE_PLAY; + + if (m_flag & ACT_FLAG_REVERSE) + { + float tmp = start; + start = end; + end = tmp; + m_localtime = end; + } + } else if (m_playtype == ACT_ACTION_FROM_PROP) { CValue* prop = GetParent()->GetProperty(m_propname); @@ -173,13 +184,14 @@ bool BL_ActionActuator::Update(double curtime, bool frame) if (bPositiveEvent) { - if (m_flag & ACT_FLAG_ACTIVE && m_flag & ACT_FLAG_CONTINUE) + + if (m_playtype != ACT_ACTION_PINGPONG && m_flag & ACT_FLAG_ACTIVE && m_flag & ACT_FLAG_CONTINUE) start = m_localtime = obj->GetActionFrame(m_layer); if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, m_layer_weight, m_ipo_flags)) { m_flag |= ACT_FLAG_ACTIVE; - if (m_flag & ACT_FLAG_CONTINUE) + if (m_playtype != ACT_ACTION_PINGPONG && m_flag & ACT_FLAG_CONTINUE) obj->SetActionFrame(m_layer, m_localtime); if (m_playtype == ACT_ACTION_PLAY) @@ -211,7 +223,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) m_flag &= ~ACT_FLAG_ACTIVE; return false; } - else if (m_playtype == ACT_ACTION_LOOP_END) + else if (m_playtype == ACT_ACTION_LOOP_END || m_playtype == ACT_ACTION_PINGPONG) { // Convert into a play and let it finish start = obj->GetActionFrame(m_layer); @@ -219,6 +231,9 @@ bool BL_ActionActuator::Update(double curtime, bool frame) obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags); m_flag |= ACT_FLAG_PLAY_END; + + if (m_playtype == ACT_ACTION_PINGPONG) + m_flag ^= ACT_FLAG_REVERSE; } else if (m_playtype == ACT_ACTION_FLIPPER) { diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index ee8599a9052..ad57b675b0b 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -151,7 +151,7 @@ protected: STR_String m_framepropname; }; -// The first values are not used in BL_ActionActuator anymore, +// Not all of these values are used in BL_ActionActuator anymore, // but BL_ShapeActionActuator still uses them, so we keep them around // for now. enum { -- cgit v1.2.3 From d096f271513dd5e10098818d567f35b99ca9c6cb Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sat, 6 Aug 2011 06:11:31 +0000 Subject: Material ray trace transparency animation COLLADA export. --- source/blender/collada/AnimationExporter.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 1ba9bc3cd28..53f3cc9aae3 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -119,11 +119,13 @@ void AnimationExporter::exportAnimations(Scene *sce) transformName = extract_transform_name( fcu->rna_path ); if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) - ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))) + ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))|| + (!strcmp(transformName, "ior"))) dae_animation(ob ,fcu, transformName, true, ma ); fcu = fcu->next; } } + } //if (!ob->adt || !ob->adt->action) // fcu = (FCurve*)((Lamp*)ob->data)->adt->action->curves.first; //this is already checked in hasAnimations() @@ -318,7 +320,7 @@ void AnimationExporter::exportAnimations(Scene *sce) if( ma ) target = translate_id(id_name(ma)) + "-effect" - +"/common/" /* should take dynamically */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); + +"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); } addChannel(COLLADABU::URI(empty, sampler_id), target); @@ -467,7 +469,7 @@ void AnimationExporter::exportAnimations(Scene *sce) float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); //BKE_animsys_evaluate_animdata(&ob_arm->id, ob_arm->adt, *it, ADT_RECALC_ANIM); - //BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); // compute bone local mat @@ -1017,6 +1019,8 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_type = 13; else if (!strcmp(name, "alpha")) tm_type = 14; + else if (!strcmp(name, "ior")) + tm_type = 15; else tm_type = -1; @@ -1067,6 +1071,9 @@ void AnimationExporter::exportAnimations(Scene *sce) case 14: tm_name = "transparency"; break; + case 15: + tm_name = "index_of_refraction"; + break; default: tm_name = ""; -- cgit v1.2.3 From e73cf35f4ad470d553540d6adbe89af5cc0c1f4f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 6 Aug 2011 07:01:07 +0000 Subject: Graph Editor "Active Keyframe" settings This commit makes some tweaks to the way that the "active keyframe" settings in the Properties region in the Graph Editor work (for the better, hopefully). Basically, the problem was that previously, these were clunky and non- intuitive to use, since they were just directly displaying the RNA properties for those keyframes for editing purposes. But due to limitations of RNA (i.e. from a RNA pointer to a keyframe, you couldn't see which F-Curve you came from), several things were impossible, notably: 1) Doing proper updates, including validating that the handles are in a valid state - that requires access to the F-Curve to provide to the F-Curve-based curve validity checking functions 2) Having the values of the keyframes display in whatever unit that the property the F-Curve affects displays as - for this, you once again need to know the F-Curve in order to resolve the property that it affects; also the fact that only a single unit could be set for RNA properties further limited things This commit basically gets around these problems by moving away from a layout-engine based approach to one where we attach custom update callbacks and also override the units of the y-co widgets when creating the widgets for these, thus allowing the buttons to work in the ways that animators expect. --- source/blender/editors/interface/interface.c | 12 ++- source/blender/editors/space_graph/graph_buttons.c | 87 +++++++++++++++++++--- 2 files changed, 86 insertions(+), 13 deletions(-) (limited to 'source') diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 40d86ec1147..c7c2235097f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3216,11 +3216,17 @@ void uiButSetUnitType(uiBut *but, const int unit_type) int uiButGetUnitType(uiBut *but) { - if(but->rnaprop) { - return RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop)); + int ownUnit = (int)but->unit_type; + + /* own unit define always takes precidence over RNA provided, allowing for overriding + * default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit) + */ + // XXX: this doesn't allow clearing unit completely, though the same could be said for icons + if ((ownUnit != 0) || (but->rnaprop == NULL)) { + return ownUnit << 16; } else { - return ((int)but->unit_type)<<16; + return RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop)); } } diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 3073ff13075..d8fd53b83d8 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -53,6 +53,7 @@ #include "BKE_fcurve.h" #include "BKE_main.h" #include "BKE_screen.h" +#include "BKE_unit.h" #include "WM_api.h" @@ -77,8 +78,7 @@ /* ******************* graph editor space & buttons ************** */ -#define B_NOP 1 -#define B_REDR 2 +#define B_REDR 1 /* -------------- */ @@ -244,6 +244,35 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT return 0; } +/* update callback for active keyframe properties - base updates stuff */ +static void graphedit_activekey_update_cb(bContext *UNUSED(C), void *fcu_ptr, void *UNUSED(bezt_ptr)) +{ + FCurve *fcu = (FCurve *)fcu_ptr; + + /* make sure F-Curve and its handles are still valid after this editing */ + sort_time_fcurve(fcu); + testhandles_fcurve(fcu); +} + +/* update callback for active keyframe properties - handle-editing wrapper */ +static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr) +{ + FCurve *fcu = (FCurve *)fcu_ptr; + BezTriple *bezt = (BezTriple *)bezt_ptr; + + /* since editing the handles, make sure they're set to types which are receptive to editing + * see transform_conversions.c :: createTransGraphEditData(), last step in second loop + */ + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { + /* by changing to aligned handles, these can now be moved... */ + bezt->h1= HD_ALIGN; + bezt->h2= HD_ALIGN; + } + + /* now call standard updates */ + graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr); +} + static void graph_panel_key_properties(const bContext *C, Panel *pa) { bAnimListElem *ale; @@ -262,27 +291,66 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) /* only show this info if there are keyframes to edit */ if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) { - PointerRNA bezt_ptr; + PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr; + PropertyRNA *fcu_prop = NULL; + uiBut *but; + int unit = B_UNIT_NONE; /* RNA pointer to keyframe, to allow editing */ RNA_pointer_create(ale->id, &RNA_Keyframe, bezt, &bezt_ptr); + /* get property that F-Curve affects, for some unit-conversion magic */ + RNA_id_pointer_create(ale->id, &id_ptr); + if (RNA_path_resolve(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop) && fcu_prop) { + /* determine the unit for this property */ + unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop)); + } + /* interpolation */ col= uiLayoutColumn(layout, 0); uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); - /* numerical coordinate editing */ + /* numerical coordinate editing + * - we use the button-versions of the calls so that we can attach special update handlers + * and unit conversion magic that cannot be achieved using a purely RNA-approach + */ + // XXX: col= uiLayoutColumn(layout, 1); /* keyframe itself */ - uiItemR(col, &bezt_ptr, "co", 0, "Key", ICON_NONE); + { + uiItemL(col, "Key:", ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, "Frame", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, "Value", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } /* previous handle - only if previous was Bezier interpolation */ - if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) - uiItemR(col, &bezt_ptr, "handle_left", 0, NULL, ICON_NONE); + if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { + uiItemL(col, "Left Handle:", ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } /* next handle - only if current is Bezier interpolation */ - if (bezt->ipo == BEZT_IPO_BEZ) - uiItemR(col, &bezt_ptr, "handle_right", 0, NULL, ICON_NONE); + if (bezt->ipo == BEZT_IPO_BEZ) { + uiItemL(col, "Right Handle:", ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } } else { if ((fcu->bezt == NULL) && (fcu->modifiers.first)) { @@ -659,7 +727,6 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event) { switch (event) { - case B_REDR: case B_FMODIFIER_REDRAW: // XXX this should send depsgraph updates too WM_event_add_notifier(C, NC_ANIMATION, NULL); // XXX need a notifier specially for F-Modifiers break; -- cgit v1.2.3 From c334bf69a7282254bb80bb2896bd8716930a4adf Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 6 Aug 2011 17:57:20 +0000 Subject: 3D Audio GSoC: Mixdown functionality. * Mixdown possible via libsndfile and ffmpeg! * Fixed some ffmpeg deprecation warnings * Mixdown UI only shows working Container, Codec and Format combinations! * Minor bugs and warnings fixed --- source/blender/editors/sound/CMakeLists.txt | 8 + source/blender/editors/sound/sound_ops.c | 287 +++++++++++++++++++++++++++- 2 files changed, 287 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/blender/editors/sound/CMakeLists.txt b/source/blender/editors/sound/CMakeLists.txt index f66288812ad..11da4165ec8 100644 --- a/source/blender/editors/sound/CMakeLists.txt +++ b/source/blender/editors/sound/CMakeLists.txt @@ -47,4 +47,12 @@ if(WITH_AUDASPACE) add_definitions(-DWITH_AUDASPACE) endif() +if(WITH_CODEC_FFMPEG) + add_definitions(-DWITH_FFMPEG) +endif() + +if(WITH_CODEC_SNDFILE) + add_definitions(-DWITH_SNDFILE) +endif() + blender_add_lib(bf_editor_sound "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 8744ec5dfd6..c6a3663d512 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -82,7 +82,7 @@ static void open_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; - + op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); uiIDContextProperty(C, &pprop->ptr, &pprop->prop); } @@ -101,7 +101,7 @@ static int open_exec(bContext *C, wmOperator *op) if(!op->customdata) open_init(C, op); - + if (sound==NULL || sound->playback_handle == NULL) { if(op->customdata) MEM_freeN(op->customdata); BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); @@ -120,15 +120,15 @@ static int open_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "cache")) { sound_cache(sound, 0); } - + /* hook into UI */ pprop= op->customdata; - + if(pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ sound->id.us--; - + RNA_id_pointer_create(&sound->id, &idptr); RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); @@ -153,12 +153,12 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *event) { if(!RNA_property_is_set(op->ptr, "relative_path")) RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); - + if(RNA_property_is_set(op->ptr, "filepath")) return open_exec(C, op); - + open_init(C, op); - + return WM_operator_filesel(C, op, event); } @@ -181,6 +181,276 @@ void SOUND_OT_open(wmOperatorType *ot) RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); } +/******************** mixdown operator ********************/ + +static int mixdown_exec(bContext *C, wmOperator *op) +{ + char path[FILE_MAX]; + char filename[FILE_MAX]; + Scene *scene; + Main *bmain; + + int bitrate, accuracy; + AUD_DeviceSpecs specs; + AUD_Container container; + AUD_Codec codec; + const char* result; + + RNA_string_get(op->ptr, "filepath", path); + bitrate = RNA_int_get(op->ptr, "bitrate") * 1000; + accuracy = RNA_int_get(op->ptr, "accuracy"); + specs.format = RNA_enum_get(op->ptr, "format"); + container = RNA_enum_get(op->ptr, "container"); + codec = RNA_enum_get(op->ptr, "codec"); + scene = CTX_data_scene(C); + bmain = CTX_data_main(C); + specs.channels = scene->r.ffcodecdata.audio_channels; + specs.rate = scene->r.ffcodecdata.audio_mixrate; + + BLI_strncpy(filename, path, sizeof(filename)); + BLI_path_abs(filename, bmain->name); + + result = AUD_mixdown(scene->sound_scene, SFRA * specs.rate / FPS, (EFRA - SFRA) * specs.rate / FPS, + accuracy, filename, specs, container, codec, bitrate); + + if(result) + { + BKE_report(op->reports, RPT_ERROR, result); + return OPERATOR_CANCELLED; + } + + return OPERATOR_FINISHED; +} + +static int mixdown_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + if(!RNA_property_is_set(op->ptr, "relative_path")) + RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); + + if(RNA_property_is_set(op->ptr, "filepath")) + return mixdown_exec(C, op); + + return WM_operator_filesel(C, op, event); +} + +static int mixdown_draw_check_prop(PropertyRNA *prop) +{ + const char *prop_id= RNA_property_identifier(prop); + return !( strcmp(prop_id, "filepath") == 0 || + strcmp(prop_id, "directory") == 0 || + strcmp(prop_id, "filename") == 0 + ); +} + +static void mixdown_draw(bContext *C, wmOperator *op) +{ + static EnumPropertyItem pcm_format_items[] = { + {AUD_FORMAT_U8, "U8", 0, "U8", "8 bit unsigned"}, + {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, +#ifdef WITH_SNDFILE + {AUD_FORMAT_S24, "S24", 0, "S24", "24 bit signed"}, +#endif + {AUD_FORMAT_S32, "S32", 0, "S32", "32 bit signed"}, + {AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"}, + {AUD_FORMAT_FLOAT64, "F64", 0, "F64", "64 bit floating point"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem mp3_format_items[] = { + {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, + {AUD_FORMAT_S32, "S32", 0, "S32", "32 bit signed"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem ac3_format_items[] = { + {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, + {AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"}, + {0, NULL, 0, NULL, NULL}}; + +#ifdef WITH_SNDFILE + static EnumPropertyItem flac_format_items[] = { + {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, + {AUD_FORMAT_S24, "S24", 0, "S24", "24 bit signed"}, + {0, NULL, 0, NULL, NULL}}; +#endif + + static EnumPropertyItem all_codec_items[] = { + {AUD_CODEC_AAC, "AAC", 0, "AAC", "Advanced Audio Coding"}, + {AUD_CODEC_AC3, "AC3", 0, "AC3", "Dolby Digital ATRAC 3"}, + {AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"}, + {AUD_CODEC_MP2, "MP2", 0, "MP2", "MPEG-1 Audio Layer II"}, + {AUD_CODEC_MP3, "MP3", 0, "MP3", "MPEG-2 Audio Layer III"}, + {AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"}, + {AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem ogg_codec_items[] = { + {AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"}, + {AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"}, + {0, NULL, 0, NULL, NULL}}; + + uiLayout *layout = op->layout; + wmWindowManager *wm= CTX_wm_manager(C); + PointerRNA ptr; + PropertyRNA *prop_format; + PropertyRNA *prop_codec; + PropertyRNA *prop_bitrate; + + AUD_Container container = RNA_enum_get(op->ptr, "container"); + AUD_Codec codec = RNA_enum_get(op->ptr, "codec"); + + prop_format = RNA_struct_find_property(op->ptr, "format"); + prop_codec = RNA_struct_find_property(op->ptr, "codec"); + prop_bitrate = RNA_struct_find_property(op->ptr, "bitrate"); + + RNA_def_property_clear_flag(prop_bitrate, PROP_HIDDEN); + RNA_def_property_flag(prop_codec, PROP_HIDDEN); + RNA_def_property_flag(prop_format, PROP_HIDDEN); + + switch(container) + { + case AUD_CONTAINER_AC3: + RNA_def_property_clear_flag(prop_format, PROP_HIDDEN); + RNA_def_property_enum_items(prop_format, ac3_format_items); + RNA_def_property_enum_items(prop_codec, all_codec_items); + RNA_enum_set(op->ptr, "codec", AUD_CODEC_AC3); + break; + case AUD_CONTAINER_FLAC: + RNA_def_property_flag(prop_bitrate, PROP_HIDDEN); + RNA_def_property_enum_items(prop_codec, all_codec_items); + RNA_enum_set(op->ptr, "codec", AUD_CODEC_FLAC); +#ifdef WITH_SNDFILE + RNA_def_property_clear_flag(prop_format, PROP_HIDDEN); + RNA_def_property_enum_items(prop_format, flac_format_items); +#else + RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16); +#endif + break; + case AUD_CONTAINER_MATROSKA: + RNA_def_property_clear_flag(prop_codec, PROP_HIDDEN); + RNA_def_property_enum_items(prop_codec, all_codec_items); + + switch(codec) + { + case AUD_CODEC_AAC: + RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16); + break; + case AUD_CODEC_AC3: + RNA_def_property_enum_items(prop_format, ac3_format_items); + RNA_def_property_clear_flag(prop_format, PROP_HIDDEN); + break; + case AUD_CODEC_FLAC: + RNA_def_property_flag(prop_bitrate, PROP_HIDDEN); + RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16); + break; + case AUD_CODEC_MP2: + RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16); + break; + case AUD_CODEC_MP3: + RNA_def_property_enum_items(prop_format, mp3_format_items); + RNA_def_property_clear_flag(prop_format, PROP_HIDDEN); + break; + case AUD_CODEC_PCM: + RNA_def_property_flag(prop_bitrate, PROP_HIDDEN); + RNA_def_property_enum_items(prop_format, pcm_format_items); + RNA_def_property_clear_flag(prop_format, PROP_HIDDEN); + break; + case AUD_CODEC_VORBIS: + RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16); + break; + } + + break; + case AUD_CONTAINER_MP2: + RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16); + RNA_enum_set(op->ptr, "codec", AUD_CODEC_MP2); + RNA_def_property_enum_items(prop_codec, all_codec_items); + break; + case AUD_CONTAINER_MP3: + RNA_def_property_clear_flag(prop_format, PROP_HIDDEN); + RNA_def_property_enum_items(prop_format, mp3_format_items); + RNA_def_property_enum_items(prop_codec, all_codec_items); + RNA_enum_set(op->ptr, "codec", AUD_CODEC_MP3); + break; + case AUD_CONTAINER_OGG: + RNA_def_property_clear_flag(prop_codec, PROP_HIDDEN); + RNA_def_property_enum_items(prop_codec, ogg_codec_items); + RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16); + break; + case AUD_CONTAINER_WAV: + RNA_def_property_flag(prop_bitrate, PROP_HIDDEN); + RNA_def_property_clear_flag(prop_format, PROP_HIDDEN); + RNA_def_property_enum_items(prop_format, pcm_format_items); + RNA_def_property_enum_items(prop_codec, all_codec_items); + RNA_enum_set(op->ptr, "codec", AUD_CODEC_PCM); + break; + } + + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); + + /* main draw call */ + uiDefAutoButsRNA(layout, &ptr, mixdown_draw_check_prop, '\0'); +} + +void SOUND_OT_mixdown(wmOperatorType *ot) +{ + static EnumPropertyItem format_items[] = { + {AUD_FORMAT_U8, "U8", 0, "U8", "8 bit unsigned"}, + {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, + {AUD_FORMAT_S24, "S24", 0, "S24", "24 bit signed"}, + {AUD_FORMAT_S32, "S32", 0, "S32", "32 bit signed"}, + {AUD_FORMAT_FLOAT32, "F32", 0, "F32", "32 bit floating point"}, + {AUD_FORMAT_FLOAT64, "F64", 0, "F64", "64 bit floating point"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem container_items[] = { +#ifdef WITH_FFMPEG + {AUD_CONTAINER_AC3, "AC3", 0, "ac3", "Dolby Digital ATRAC 3"}, +#endif + {AUD_CONTAINER_FLAC, "FLAC", 0, "flac", "Free Lossless Audio Codec"}, +#ifdef WITH_FFMPEG + {AUD_CONTAINER_MATROSKA, "MATROSKA", 0, "mkv", "Matroska"}, + {AUD_CONTAINER_MP2, "MP2", 0, "mp2", "MPEG-1 Audio Layer II"}, + {AUD_CONTAINER_MP3, "MP3", 0, "mp3", "MPEG-2 Audio Layer III"}, +#endif + {AUD_CONTAINER_OGG, "OGG", 0, "ogg", "Xiph.Org Ogg Container"}, + {AUD_CONTAINER_WAV, "WAV", 0, "wav", "Waveform Audio File Format"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem codec_items[] = { +#ifdef WITH_FFMPEG + {AUD_CODEC_AAC, "AAC", 0, "AAC", "Advanced Audio Coding"}, + {AUD_CODEC_AC3, "AC3", 0, "AC3", "Dolby Digital ATRAC 3"}, +#endif + {AUD_CODEC_FLAC, "FLAC", 0, "FLAC", "Free Lossless Audio Codec"}, +#ifdef WITH_FFMPEG + {AUD_CODEC_MP2, "MP2", 0, "MP2", "MPEG-1 Audio Layer II"}, + {AUD_CODEC_MP3, "MP3", 0, "MP3", "MPEG-2 Audio Layer III"}, +#endif + {AUD_CODEC_PCM, "PCM", 0, "PCM", "Pulse Code Modulation (RAW)"}, + {AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"}, + {0, NULL, 0, NULL, NULL}}; + + /* identifiers */ + ot->name= "Mixdown"; + ot->description= "Mixes the scene's audio to a sound file"; + ot->idname= "SOUND_OT_mixdown"; + + /* api callbacks */ + ot->exec= mixdown_exec; + ot->invoke= mixdown_invoke; + ot->ui= mixdown_draw; + + /* flags */ + ot->flag= OPTYPE_REGISTER; + + /* properties */ + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); + RNA_def_int(ot->srna, "accuracy", 1024, 1, 16777216, "Accuracy", "Sample accuracy. Important for animation data. The lower the value, the more accurate.", 1, 16777216); + RNA_def_enum(ot->srna, "container", container_items, AUD_CONTAINER_FLAC, "Container", "File format"); + RNA_def_enum(ot->srna, "codec", codec_items, AUD_CODEC_FLAC, "Codec", "Audio Codec"); + RNA_def_enum(ot->srna, "format", format_items, AUD_FORMAT_S16, "Format", "Sample format"); + RNA_def_int(ot->srna, "bitrate", 192, 32, 512, "Bitrate", "Bitrate in kbit/s", 32, 512); +} + /* ******************************************************* */ static int sound_poll(bContext *C) @@ -393,6 +663,7 @@ void SOUND_OT_bake_animation(wmOperatorType *ot) void ED_operatortypes_sound(void) { WM_operatortype_append(SOUND_OT_open); + WM_operatortype_append(SOUND_OT_mixdown); WM_operatortype_append(SOUND_OT_pack); WM_operatortype_append(SOUND_OT_unpack); WM_operatortype_append(SOUND_OT_update_animation_flags); -- cgit v1.2.3 From 5cc0bb0d1b3dbdc8494fe2ff444c683b82b7d15f Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 7 Aug 2011 04:57:23 +0000 Subject: BGE Animations: The IPO conversion code relied on objects having an adt, but this isn't always the case. object->adt can be NULL, which causes a crash. Now BL_InterpolatorLists are cached by action instead of adt. --- .../gameengine/Converter/KX_BlenderSceneConverter.cpp | 10 +++++----- source/gameengine/Converter/KX_BlenderSceneConverter.h | 4 ++-- source/gameengine/Converter/KX_IpoConvert.cpp | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 58089cc4b2d..3dd12cf6c8f 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -566,18 +566,18 @@ void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat) void KX_BlenderSceneConverter::RegisterInterpolatorList( - BL_InterpolatorList *adtList, - struct AnimData *for_adt) + BL_InterpolatorList *actList, + struct bAction *for_act) { - m_map_blender_to_gameAdtList.insert(CHashedPtr(for_adt), adtList); + m_map_blender_to_gameAdtList.insert(CHashedPtr(for_act), actList); } BL_InterpolatorList *KX_BlenderSceneConverter::FindInterpolatorList( - struct AnimData *for_adt) + struct bAction *for_act) { - BL_InterpolatorList **listp = m_map_blender_to_gameAdtList[CHashedPtr(for_adt)]; + BL_InterpolatorList **listp = m_map_blender_to_gameAdtList[CHashedPtr(for_act)]; return listp?*listp:NULL; } diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h index 2340e44d288..ba919eb9592 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.h +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h @@ -113,8 +113,8 @@ public: void RegisterBlenderMaterial(BL_Material *mat); - void RegisterInterpolatorList(BL_InterpolatorList *adtList, struct AnimData *for_adt); - BL_InterpolatorList *FindInterpolatorList(struct AnimData *for_adt); + void RegisterInterpolatorList(BL_InterpolatorList *actList, struct bAction *for_act); + BL_InterpolatorList *FindInterpolatorList(struct bAction *for_act); void RegisterGameActuator(SCA_IActuator *act, struct bActuator *for_actuator); SCA_IActuator *FindGameActuator(struct bActuator *for_actuator); diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 27ae857f45c..0e526bc818d 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -73,12 +73,12 @@ #include "STR_HashedString.h" -static BL_InterpolatorList *GetAdtList(struct AnimData *for_adt, KX_BlenderSceneConverter *converter) { - BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_adt); +static BL_InterpolatorList *GetAdtList(struct bAction *for_act, KX_BlenderSceneConverter *converter) { + BL_InterpolatorList *adtList= converter->FindInterpolatorList(for_act); if (!adtList) { - adtList = new BL_InterpolatorList(for_adt->action); - converter->RegisterInterpolatorList(adtList, for_adt); + adtList = new BL_InterpolatorList(for_act); + converter->RegisterInterpolatorList(adtList, for_act); } return adtList; @@ -128,7 +128,7 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_B drotmode = "delta_rotation_euler"; } - BL_InterpolatorList *adtList= GetAdtList(blenderobject->adt, converter); + BL_InterpolatorList *adtList= GetAdtList(action, converter); // For each active channel in the adtList add an // interpolator to the game object. @@ -222,7 +222,7 @@ void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_Ble ipocontr->m_col_rgb[2] = blenderlamp->b; ipocontr->m_dist = blenderlamp->dist; - BL_InterpolatorList *adtList= GetAdtList(blenderlamp->adt, converter); + BL_InterpolatorList *adtList= GetAdtList(blenderlamp->adt->action, converter); // For each active channel in the adtList add an // interpolator to the game object. @@ -268,7 +268,7 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj ipocontr->m_clipstart = blendercamera->clipsta; ipocontr->m_clipend = blendercamera->clipend; - BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt, converter); + BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt->action, converter); // For each active channel in the adtList add an // interpolator to the game object. @@ -316,7 +316,7 @@ void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *co ipocontr->m_mist_rgb[1] = blenderworld->horg; ipocontr->m_mist_rgb[2] = blenderworld->horb; - BL_InterpolatorList *adtList= GetAdtList(blenderworld->adt, converter); + BL_InterpolatorList *adtList= GetAdtList(blenderworld->adt->action, converter); // For each active channel in the adtList add an // interpolator to the game object. @@ -358,7 +358,7 @@ static void ConvertMaterialIpos( gameobj->GetSGNode()->AddSGController(ipocontr); ipocontr->SetObject(gameobj->GetSGNode()); - BL_InterpolatorList *adtList= GetAdtList(blendermaterial->adt, converter); + BL_InterpolatorList *adtList= GetAdtList(blendermaterial->adt->action, converter); ipocontr->m_rgba[0] = blendermaterial->r; -- cgit v1.2.3 From 2d884fc035d403d43c7a18e3e61cd56ccdfbec2b Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sun, 7 Aug 2011 11:54:58 +0000 Subject: 3D Audio GSoC: * Pepper depends on ffmpeg 0.7.1 or higher now, windows and mac build systems set to ffmpeg-0.8 * Fixed orientation retrieval in OpenAL device code. * Added stopAll() method to AUD_IDevice (also for Python) and call it on BGE exit * Changed BGE to use audaspace via native C++ instead over the C API. * Made AUD_SequencerFactory and AUD_SequencerEntry thread safe. * Changed sound caching into a flag which fixes problems on file loading, especially with undo. * Removed unused parameter from sound_mute_scene_sound * Fixed bug: changing FPS didn't update the sequencer sound positions. * Fixed bug: Properties of sequencer strips weren't set correctly. * Minor warning fixes. --- source/blender/blenkernel/BKE_sequencer.h | 3 +- source/blender/blenkernel/BKE_sound.h | 6 +- source/blender/blenkernel/intern/sequencer.c | 36 +++- source/blender/blenkernel/intern/sound.c | 35 +++- source/blender/blenloader/intern/readfile.c | 12 +- source/blender/editors/sound/sound_ops.c | 6 +- .../editors/space_sequencer/sequencer_add.c | 2 +- .../editors/space_sequencer/sequencer_edit.c | 10 +- source/blender/makesdna/DNA_sound_types.h | 3 +- source/blender/makesrna/intern/rna_scene.c | 2 + source/blender/makesrna/intern/rna_sequencer.c | 2 +- source/blender/makesrna/intern/rna_sound.c | 4 +- .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 24 ++- .../gameengine/Converter/KX_ConvertActuators.cpp | 4 +- source/gameengine/Ketsji/CMakeLists.txt | 1 + source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 21 ++- source/gameengine/Ketsji/KX_SoundActuator.cpp | 182 ++++++++++----------- source/gameengine/Ketsji/KX_SoundActuator.h | 9 +- source/gameengine/Ketsji/SConscript | 2 +- 19 files changed, 212 insertions(+), 152 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index cebf99097aa..773096d1e0d 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -282,8 +282,9 @@ void free_imbuf_seq(struct Scene *scene, struct ListBase * seqbasep, int check_m struct Sequence *seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, struct Sequence * seq, int dupe_flag); int seq_swap(struct Sequence *seq_a, struct Sequence *seq_b, const char **error_str); +void seq_update_sound_bounds_all(struct Scene *scene); void seq_update_sound_bounds(struct Scene* scene, struct Sequence *seq); -void seq_update_muting(struct Scene* scene, struct Editing *ed); +void seq_update_muting(struct Editing *ed); void seq_update_sound(struct Scene *scene, struct bSound *sound); void seqbase_sound_reload(struct Scene *scene, ListBase *seqbase); void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq); diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 632a2a0bb3b..2cd006385e0 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -62,9 +62,9 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa void sound_delete(struct bContext *C, struct bSound* sound); -void sound_cache(struct bSound* sound, int ignore); +void sound_cache(struct bSound* sound); -void sound_cache_notifying(struct Main* main, struct bSound* sound, int ignore); +void sound_cache_notifying(struct Main* main, struct bSound* sound); void sound_delete_cache(struct bSound* sound); @@ -92,7 +92,7 @@ void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int void sound_remove_scene_sound(struct Scene *scene, void* handle); -void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute); +void sound_mute_scene_sound(void* handle, char mute); void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9ff3ce7afe2..93e0c920745 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3145,6 +3145,28 @@ int shuffle_seq_time(ListBase * seqbasep, Scene *evil_scene) return offset? 0:1; } +void seq_update_sound_bounds_all(Scene *scene) +{ + Editing *ed = scene->ed; + + if(ed) + { + Sequence *seq; + + for(seq = ed->seqbase.first; seq; seq = seq->next) + { + if(seq->type == SEQ_META) + { + seq_update_sound_bounds_recursive(scene, seq); + } + else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) + { + seq_update_sound_bounds(scene, seq); + } + } + } +} + void seq_update_sound_bounds(Scene* scene, Sequence *seq) { if(seq->scene_sound) @@ -3154,7 +3176,7 @@ void seq_update_sound_bounds(Scene* scene, Sequence *seq) } } -static void seq_update_muting_recursive(Scene *scene, ListBase *seqbasep, Sequence *metaseq, int mute) +static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute) { Sequence *seq; int seqmute; @@ -3170,26 +3192,26 @@ static void seq_update_muting_recursive(Scene *scene, ListBase *seqbasep, Sequen if(seq == metaseq) seqmute= 0; - seq_update_muting_recursive(scene, &seq->seqbase, metaseq, seqmute); + seq_update_muting_recursive(&seq->seqbase, metaseq, seqmute); } else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) { if(seq->scene_sound) { - sound_mute_scene_sound(scene, seq->scene_sound, seqmute); + sound_mute_scene_sound(seq->scene_sound, seqmute); } } } } -void seq_update_muting(Scene *scene, Editing *ed) +void seq_update_muting(Editing *ed) { if(ed) { /* mute all sounds up to current metastack list */ MetaStack *ms= ed->metastack.last; if(ms) - seq_update_muting_recursive(scene, &ed->seqbase, ms->parseq, 1); + seq_update_muting_recursive(&ed->seqbase, ms->parseq, 1); else - seq_update_muting_recursive(scene, &ed->seqbase, NULL, 0); + seq_update_muting_recursive(&ed->seqbase, NULL, 0); } } @@ -3469,7 +3491,7 @@ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) if(seq_load->flag & SEQ_LOAD_SOUND_CACHE) { if(seq->sound) - sound_cache(seq->sound, 0); + sound_cache(seq->sound); } seq_load->tot_success++; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 59f5cdb678e..890fc114e68 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -91,6 +91,7 @@ void sound_free(struct bSound* sound) if(sound->cache) { AUD_unload(sound->cache); + sound->cache = NULL; } #endif // WITH_AUDASPACE } @@ -250,23 +251,25 @@ void sound_delete(struct bContext *C, struct bSound* sound) } } -void sound_cache(struct bSound* sound, int ignore) +void sound_cache(struct bSound* sound) { - if(sound->cache && !ignore) + sound->flags |= SOUND_FLAGS_CACHING; + if(sound->cache) AUD_unload(sound->cache); sound->cache = AUD_bufferSound(sound->handle); sound->playback_handle = sound->cache; } -void sound_cache_notifying(struct Main* main, struct bSound* sound, int ignore) +void sound_cache_notifying(struct Main* main, struct bSound* sound) { - sound_cache(sound, ignore); + sound_cache(sound); sound_update_sequencer(main, sound); } void sound_delete_cache(struct bSound* sound) { + sound->flags &= ~SOUND_FLAGS_CACHING; if(sound->cache) { AUD_unload(sound->cache); @@ -279,6 +282,12 @@ void sound_load(struct Main *bmain, struct bSound* sound) { if(sound) { + if(sound->cache) + { + AUD_unload(sound->cache); + sound->cache = NULL; + } + if(sound->handle) { AUD_unload(sound->handle); @@ -330,6 +339,11 @@ void sound_load(struct Main *bmain, struct bSound* sound) break; } #endif + if(sound->flags & SOUND_FLAGS_CACHING) + { + sound->cache = AUD_bufferSound(sound->handle); + } + if(sound->cache) sound->playback_handle = sound->cache; else @@ -400,7 +414,12 @@ void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) { - return AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS); + void* handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS); + AUD_muteSequence(handle, (sequence->flag & SEQ_MUTE) != 0); + AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, CFRA, &sequence->volume, 0); + AUD_setSequenceAnimData(handle, AUD_AP_PITCH, CFRA, &sequence->pitch, 0); + AUD_setSequenceAnimData(handle, AUD_AP_PANNING, CFRA, &sequence->pan, 0); + return handle; } void sound_remove_scene_sound(struct Scene *scene, void* handle) @@ -408,7 +427,7 @@ void sound_remove_scene_sound(struct Scene *scene, void* handle) AUD_removeSequence(scene->sound_scene, handle); } -void sound_mute_scene_sound(struct Scene *scene, void* handle, char mute) +void sound_mute_scene_sound(void* handle, char mute) { AUD_muteSequence(handle, mute); } @@ -612,7 +631,7 @@ void sound_force_device(int UNUSED(device)) {} void sound_init_once(void) {} void sound_init(struct Main *UNUSED(bmain)) {} void sound_exit(void) {} -void sound_cache(struct bSound* UNUSED(sound), int UNUSED(ignore)) { } +void sound_cache(struct bSound* UNUSED(sound)) { } void sound_delete_cache(struct bSound* UNUSED(sound)) {} void sound_load(struct Main *UNUSED(bmain), struct bSound* UNUSED(sound)) {} void sound_create_scene(struct Scene *UNUSED(scene)) {} @@ -621,7 +640,7 @@ void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {} void* sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; } void* sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; } void sound_remove_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle)) {} -void sound_mute_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), char UNUSED(mute)) {} +void sound_mute_scene_sound(void* UNUSED(handle), char UNUSED(mute)) {} void sound_move_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {} static void sound_start_play_scene(struct Scene *UNUSED(scene)) {} void sound_play_scene(struct Scene *UNUSED(scene)) {} diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index e22f5dcb3de..07e2bbf5bca 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4473,7 +4473,7 @@ static void lib_link_scene(FileData *fd, Main *main) #endif if(sce->ed) - seq_update_muting(sce, sce->ed); + seq_update_muting(sce->ed); if(sce->nodetree) { lib_link_ntree(fd, &sce->id, sce->nodetree); @@ -5608,6 +5608,13 @@ static void direct_link_sound(FileData *fd, bSound *sound) sound->handle = NULL; sound->playback_handle = NULL; + // versioning stuff, if there was a cache, then we enable caching: + if(sound->cache) + { + sound->flags |= SOUND_FLAGS_CACHING; + sound->cache = NULL; + } + sound->packedfile = direct_link_packedfile(fd, sound->packedfile); sound->newpackedfile = direct_link_packedfile(fd, sound->newpackedfile); } @@ -5623,9 +5630,6 @@ static void lib_link_sound(FileData *fd, Main *main) sound->ipo= newlibadr_us(fd, sound->id.lib, sound->ipo); // XXX depreceated - old animation system sound_load(main, sound); - - if(sound->cache) - sound_cache_notifying(main, sound, 1); } sound= sound->id.next; } diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index c6a3663d512..31d22f9dd54 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -118,7 +118,7 @@ static int open_exec(bContext *C, wmOperator *op) } if (RNA_boolean_get(op->ptr, "cache")) { - sound_cache(sound, 0); + sound_cache(sound); } /* hook into UI */ @@ -356,6 +356,8 @@ static void mixdown_draw(bContext *C, wmOperator *op) case AUD_CODEC_VORBIS: RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16); break; + default: + break; } break; @@ -382,6 +384,8 @@ static void mixdown_draw(bContext *C, wmOperator *op) RNA_def_property_enum_items(prop_codec, all_codec_items); RNA_enum_set(op->ptr, "codec", AUD_CODEC_PCM); break; + default: + break; } RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index b105b2507ab..54229a683a3 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -354,7 +354,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad } sort_seq(scene); - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 4252d051154..14dad30467f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1228,7 +1228,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) } } - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1275,7 +1275,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) } } - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1901,7 +1901,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -1965,7 +1965,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene); - seq_update_muting(scene, ed); + seq_update_muting(ed); seqbase_unique_name_recursive(&scene->ed->seqbase, seqm); @@ -2038,7 +2038,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) } sort_seq(scene); - seq_update_muting(scene, ed); + seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index 3e5f82a8052..56ad0e1ff84 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -106,7 +106,8 @@ typedef enum eSound_Type { #define SND_DRAWFRAMES 1 #define SND_CFRA_NUM 2 -#define SOUND_FLAGS_3D (1 << 3) +#define SOUND_FLAGS_3D (1 << 3) /* deprecated! used for sound actuator loading */ +#define SOUND_FLAGS_CACHING (1 << 4) /* to DNA_sound_types.h*/ diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 170e590522d..6d0e9661e04 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -182,6 +182,7 @@ EnumPropertyItem image_type_items[] = { #include "BKE_mesh.h" #include "BKE_sound.h" #include "BKE_screen.h" +#include "BKE_sequencer.h" #include "BKE_animsys.h" #include "WM_api.h" @@ -335,6 +336,7 @@ static void rna_Scene_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Scene_fps_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { sound_update_fps(scene); + seq_update_sound_bounds_all(scene); } static void rna_Scene_listener_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 0c889fd111f..6e18f955bf5 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -602,7 +602,7 @@ static void rna_Sequence_mute_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Editing *ed= seq_give_editing(scene, FALSE); - seq_update_muting(scene, ed); + seq_update_muting(ed); rna_Sequence_update(bmain, scene, ptr); } diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index f471e5e0fe5..e78bc092040 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -49,14 +49,14 @@ static void rna_Sound_filepath_update(Main *bmain, Scene *UNUSED(scene), Pointer static int rna_Sound_caching_get(PointerRNA *ptr) { bSound *sound = (bSound*)(ptr->data); - return sound->cache != NULL; + return (sound->flags & SOUND_FLAGS_CACHING) != 0; } static void rna_Sound_caching_set(PointerRNA *ptr, const int value) { bSound *sound = (bSound*)(ptr->data); if(value) - sound_cache(sound, 0); + sound_cache(sound); else sound_delete_cache(sound); } diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index a3ea85b605c..3c766affe56 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -95,10 +95,6 @@ extern float BKE_screen_view3d_zoom_to_fac(float camzoom); #include "BKE_ipo.h" /***/ -#ifdef WITH_AUDASPACE -# include "AUD_C-API.h" -#endif - //XXX #include "BSE_headerbuttons.h" #include "BKE_context.h" #include "../../blender/windowmanager/WM_types.h" @@ -108,6 +104,11 @@ extern float BKE_screen_view3d_zoom_to_fac(float camzoom); } #endif +#ifdef WITH_AUDASPACE +# include "AUD_C-API.h" +# include "AUD_I3DDevice.h" +# include "AUD_IDevice.h" +#endif static BlendFileData *load_game_data(char *filename) { @@ -394,9 +395,13 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c ketsjiengine->InitDome(scene->gm.dome.res, scene->gm.dome.mode, scene->gm.dome.angle, scene->gm.dome.resbuf, scene->gm.dome.tilt, scene->gm.dome.warptext); // initialize 3D Audio Settings - AUD_setSpeedOfSound(scene->audio.speed_of_sound); - AUD_setDopplerFactor(scene->audio.doppler_factor); - AUD_setDistanceModel(AUD_DistanceModel(scene->audio.distance_model)); + AUD_I3DDevice* dev = AUD_get3DDevice(); + if(dev) + { + dev->setSpeedOfSound(scene->audio.speed_of_sound); + dev->setDopplerFactor(scene->audio.doppler_factor); + dev->setDistanceModel(AUD_DistanceModel(scene->audio.distance_model)); + } // from see blender.c: // FIXME: this version patching should really be part of the file-reading code, @@ -581,7 +586,10 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c { delete canvas; canvas = NULL; - } + } + + // stop all remaining playing sounds + AUD_getDevice()->stopAll(); } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a06e16b2f1d..7b9cba7770b 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -388,7 +388,7 @@ void BL_ConvertActuators(char* maggiename, { bSound* sound = soundact->sound; bool is3d = soundact->flag & ACT_SND_3D_SOUND ? true : false; - AUD_Sound* snd_sound = NULL; + AUD_Reference snd_sound; KX_3DSoundSettings settings; settings.cone_inner_angle = soundact->sound3D.cone_inner_angle; settings.cone_outer_angle = soundact->sound3D.cone_outer_angle; @@ -406,7 +406,7 @@ void BL_ConvertActuators(char* maggiename, "\" has no sound datablock." << std::endl; } else - snd_sound = sound->playback_handle; + snd_sound = *reinterpret_cast*>(sound->playback_handle); KX_SoundActuator* tmpsoundact = new KX_SoundActuator(gameobj, snd_sound, diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index f10347e5473..73365860fce 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -251,6 +251,7 @@ endif() if(WITH_AUDASPACE) list(APPEND INC ../../../intern/audaspace/intern + ../../../intern/audaspace/FX ) add_definitions(-DWITH_AUDASPACE) endif() diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 651450f01bf..421e642a6df 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -70,6 +70,7 @@ #ifdef WITH_AUDASPACE # include "AUD_C-API.h" +# include "AUD_I3DDevice.h" #endif #include "NG_NetworkScene.h" @@ -995,16 +996,20 @@ void KX_KetsjiEngine::DoSound(KX_Scene* scene) if (!cam) return; - float f[4]; - - cam->NodeGetWorldPosition().getValue(f); - AUD_setListenerLocation(f); + AUD_I3DDevice* dev = AUD_get3DDevice(); + if(dev) + { + AUD_Vector3 v; + AUD_Quaternion q; + cam->NodeGetWorldPosition().getValue(v.get()); + dev->setListenerLocation(v); - cam->GetLinearVelocity().getValue(f); - AUD_setListenerVelocity(f); + cam->GetLinearVelocity().getValue(v.get()); + dev->setListenerVelocity(v); - cam->NodeGetWorldOrientation().getRotation().getValue(f); - AUD_setListenerOrientation(f); + cam->NodeGetWorldOrientation().getRotation().getValue(q.get()); + dev->setListenerOrientation(q); + } } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index 0f2597c336f..eb1a13f672d 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -39,6 +39,9 @@ #ifdef WITH_AUDASPACE # include "AUD_C-API.h" +# include "AUD_PingPongFactory.h" +# include "AUD_IDevice.h" +# include "AUD_I3DHandle.h" #endif #include "KX_GameObject.h" @@ -49,7 +52,7 @@ /* Native functions */ /* ------------------------------------------------------------------------- */ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj, - AUD_Sound* sound, + AUD_Reference sound, float volume, float pitch, bool is3d, @@ -57,15 +60,11 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj, KX_SOUNDACT_TYPE type)//, : SCA_IActuator(gameobj, KX_ACT_SOUND) { - if(sound) - m_sound = AUD_copy(sound); - else - m_sound = NULL; + m_sound = sound; m_volume = volume; m_pitch = pitch; m_is3d = is3d; m_3d = settings; - m_handle = NULL; m_type = type; m_isplaying = false; } @@ -74,27 +73,20 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj, KX_SoundActuator::~KX_SoundActuator() { - if(m_handle) - AUD_stop(m_handle); - if(m_sound) - AUD_unload(m_sound); + if(!m_handle.isNull()) + m_handle->stop(); } void KX_SoundActuator::play() { - if(m_handle) - { - AUD_stop(m_handle); - m_handle = NULL; - } + if(!m_handle.isNull()) + m_handle->stop(); - if(!m_sound) + if(m_sound.isNull()) return; // this is the sound that will be played and not deleted afterwards - AUD_Sound* sound = m_sound; - // this sound is for temporary stacked sounds, will be deleted if not NULL - AUD_Sound* sound2 = NULL; + AUD_Reference sound = m_sound; bool loop = false; @@ -102,7 +94,7 @@ void KX_SoundActuator::play() { case KX_SOUNDACT_LOOPBIDIRECTIONAL: case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: - sound = sound2 = AUD_pingpongSound(sound); + sound = new AUD_PingPongFactory(sound); // fall through case KX_SOUNDACT_LOOPEND: case KX_SOUNDACT_LOOPSTOP: @@ -114,31 +106,27 @@ void KX_SoundActuator::play() break; } - m_handle = AUD_play(sound, 0); + m_handle = AUD_getDevice()->play(sound, 0); - if(sound2) - AUD_unload(sound2); + AUD_Reference handle3d = AUD_Reference(m_handle); - if(!m_handle) - return; - - if(m_is3d) + if(m_is3d && !handle3d.isNull()) { - AUD_setRelative(m_handle, false); - AUD_setVolumeMaximum(m_handle, m_3d.max_gain); - AUD_setVolumeMinimum(m_handle, m_3d.min_gain); - AUD_setDistanceReference(m_handle, m_3d.reference_distance); - AUD_setDistanceMaximum(m_handle, m_3d.max_distance); - AUD_setAttenuation(m_handle, m_3d.rolloff_factor); - AUD_setConeAngleInner(m_handle, m_3d.cone_inner_angle); - AUD_setConeAngleOuter(m_handle, m_3d.cone_outer_angle); - AUD_setConeVolumeOuter(m_handle, m_3d.cone_outer_gain); + handle3d->setRelative(false); + handle3d->setVolumeMaximum(m_3d.max_gain); + handle3d->setVolumeMinimum(m_3d.min_gain); + handle3d->setDistanceReference(m_3d.reference_distance); + handle3d->setDistanceMaximum(m_3d.max_distance); + handle3d->setAttenuation(m_3d.rolloff_factor); + handle3d->setConeAngleInner(m_3d.cone_inner_angle); + handle3d->setConeAngleOuter(m_3d.cone_outer_angle); + handle3d->setConeVolumeOuter(m_3d.cone_outer_gain); } if(loop) - AUD_setLoop(m_handle, -1); - AUD_setSoundPitch(m_handle, m_pitch); - AUD_setSoundVolume(m_handle, m_volume); + m_handle->setLoopCount(-1); + m_handle->setPitch(m_pitch); + m_handle->setVolume(m_volume); m_isplaying = true; } @@ -152,7 +140,7 @@ CValue* KX_SoundActuator::GetReplica() void KX_SoundActuator::ProcessReplica() { SCA_IActuator::ProcessReplica(); - m_handle = 0; + m_handle = AUD_Reference(); } bool KX_SoundActuator::Update(double curtime, bool frame) @@ -167,11 +155,11 @@ bool KX_SoundActuator::Update(double curtime, bool frame) RemoveAllEvents(); - if(!m_sound) + if(m_sound.isNull()) return false; // actual audio device playing state - bool isplaying = m_handle ? (AUD_getStatus(m_handle) == AUD_STATUS_PLAYING) : false; + bool isplaying = m_handle.isNull() ? false : (m_handle->getStatus() == AUD_STATUS_PLAYING); if (bNegativeEvent) { @@ -185,9 +173,9 @@ bool KX_SoundActuator::Update(double curtime, bool frame) case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP: { // stop immediately - if(m_handle) - AUD_stop(m_handle); - m_handle = NULL; + if(!m_handle.isNull()) + m_handle->stop(); + m_handle = AUD_Reference(); break; } case KX_SOUNDACT_PLAYEND: @@ -199,8 +187,8 @@ bool KX_SoundActuator::Update(double curtime, bool frame) case KX_SOUNDACT_LOOPBIDIRECTIONAL: { // stop the looping so that the sound stops when it finished - if(m_handle) - AUD_setLoop(m_handle, 0); + if(!m_handle.isNull()) + m_handle->setLoopCount(0); break; } default: @@ -226,21 +214,24 @@ bool KX_SoundActuator::Update(double curtime, bool frame) play(); } // verify that the sound is still playing - isplaying = m_handle ? (AUD_getStatus(m_handle) == AUD_STATUS_PLAYING) : false; + isplaying = m_handle.isNull() ? false : (m_handle->getStatus() == AUD_STATUS_PLAYING); if (isplaying) { - if(m_is3d) + AUD_Reference handle3d = AUD_Reference(m_handle); + + if(m_is3d && !handle3d.isNull()) { KX_GameObject* obj = (KX_GameObject*)this->GetParent(); - float f[4]; - - obj->NodeGetWorldPosition().getValue(f); - AUD_setSourceLocation(m_handle, f); - obj->GetLinearVelocity().getValue(f); - AUD_setSourceVelocity(m_handle, f); - obj->NodeGetWorldOrientation().getRotation().getValue(f); - AUD_setSourceOrientation(m_handle, f); + AUD_Vector3 v; + AUD_Quaternion q; + + obj->NodeGetWorldPosition().getValue(v.get()); + handle3d->setSourceLocation(v); + obj->GetLinearVelocity().getValue(v.get()); + handle3d->setSourceVelocity(v); + obj->NodeGetWorldOrientation().getRotation().getValue(q.get()); + handle3d->setSourceOrientation(q); } result = true; } @@ -252,7 +243,6 @@ bool KX_SoundActuator::Update(double curtime, bool frame) return result; } - #ifdef WITH_PYTHON /* ------------------------------------------------------------------------- */ @@ -315,14 +305,14 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, "startSound()\n" "\tStarts the sound.\n") { - if(m_handle) + if(!m_handle.isNull()) { - switch(AUD_getStatus(m_handle)) + switch(m_handle->getStatus()) { case AUD_STATUS_PLAYING: break; case AUD_STATUS_PAUSED: - AUD_resume(m_handle); + m_handle->resume(); break; default: play(); @@ -335,8 +325,8 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound, "pauseSound()\n" "\tPauses the sound.\n") { - if(m_handle) - AUD_pause(m_handle); + if(!m_handle.isNull()) + m_handle->pause(); Py_RETURN_NONE; } @@ -344,9 +334,9 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound, "stopSound()\n" "\tStops the sound.\n") { - if(m_handle) - AUD_stop(m_handle); - m_handle = NULL; + if(!m_handle.isNull()) + m_handle->stop(); + m_handle = AUD_Reference(); Py_RETURN_NONE; } @@ -394,8 +384,8 @@ PyObject* KX_SoundActuator::pyattr_get_audposition(void *self, const struct KX_P KX_SoundActuator * actuator = static_cast (self); float position = 0.0; - if(actuator->m_handle) - position = AUD_getPosition(actuator->m_handle); + if(!actuator->m_handle.isNull()) + position = actuator->m_handle->getPosition(); PyObject* result = PyFloat_FromDouble(position); @@ -425,8 +415,8 @@ PyObject* KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRI PyObject* KX_SoundActuator::pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) { KX_SoundActuator * actuator = static_cast (self); - if(actuator->m_sound) - return AUD_getPythonFactory(actuator->m_sound); + if(!actuator->m_sound.isNull()) + return AUD_getPythonFactory(&actuator->m_sound); else Py_RETURN_NONE; } @@ -440,49 +430,50 @@ int KX_SoundActuator::pyattr_set_3d_property(void *self, const struct KX_PYATTRI if (!PyArg_Parse(value, "f", &prop_value)) return PY_SET_ATTR_FAIL; + AUD_Reference handle3d = AUD_Reference(actuator->m_handle); // if sound is working and 3D, set the new setting if(!actuator->m_is3d) return PY_SET_ATTR_FAIL; if(!strcmp(prop, "volume_maximum")) { actuator->m_3d.max_gain = prop_value; - if(actuator->m_handle) - AUD_setVolumeMaximum(actuator->m_handle, prop_value); + if(!handle3d.isNull()) + handle3d->setVolumeMaximum(prop_value); } else if (!strcmp(prop, "volume_minimum")) { actuator->m_3d.min_gain = prop_value; - if(actuator->m_handle) - AUD_setVolumeMinimum(actuator->m_handle, prop_value); + if(!handle3d.isNull()) + handle3d->setVolumeMinimum(prop_value); } else if (!strcmp(prop, "distance_reference")) { actuator->m_3d.reference_distance = prop_value; - if(actuator->m_handle) - AUD_setDistanceReference(actuator->m_handle, prop_value); + if(!handle3d.isNull()) + handle3d->setDistanceReference(prop_value); } else if (!strcmp(prop, "distance_maximum")) { actuator->m_3d.max_distance = prop_value; - if(actuator->m_handle) - AUD_setDistanceMaximum(actuator->m_handle, prop_value); + if(!handle3d.isNull()) + handle3d->setDistanceMaximum(prop_value); } else if (!strcmp(prop, "attenuation")) { actuator->m_3d.rolloff_factor = prop_value; - if(actuator->m_handle) - AUD_setAttenuation(actuator->m_handle, prop_value); + if(!handle3d.isNull()) + handle3d->setAttenuation(prop_value); } else if (!!strcmp(prop, "cone_angle_inner")) { actuator->m_3d.cone_inner_angle = prop_value; - if(actuator->m_handle) - AUD_setConeAngleInner(actuator->m_handle, prop_value); + if(!handle3d.isNull()) + handle3d->setConeAngleInner(prop_value); } else if (!strcmp(prop, "cone_angle_outer")) { actuator->m_3d.cone_outer_angle = prop_value; - if(actuator->m_handle) - AUD_setConeAngleOuter(actuator->m_handle, prop_value); + if(!handle3d.isNull()) + handle3d->setConeAngleOuter(prop_value); } else if (!strcmp(prop, "cone_volume_outer")) { actuator->m_3d.cone_outer_gain = prop_value; - if(actuator->m_handle) - AUD_setConeVolumeOuter(actuator->m_handle, prop_value); + if(!handle3d.isNull()) + handle3d->setConeVolumeOuter(prop_value); } else { return PY_SET_ATTR_FAIL; @@ -499,8 +490,8 @@ int KX_SoundActuator::pyattr_set_audposition(void *self, const struct KX_PYATTRI if (!PyArg_Parse(value, "f", &position)) return PY_SET_ATTR_FAIL; - if(actuator->m_handle) - AUD_seek(actuator->m_handle, position); + if(!actuator->m_handle.isNull()) + actuator->m_handle->seek(position); return PY_SET_ATTR_SUCCESS; } @@ -512,8 +503,8 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE return PY_SET_ATTR_FAIL; actuator->m_volume = gain; - if(actuator->m_handle) - AUD_setSoundVolume(actuator->m_handle, gain); + if(!actuator->m_handle.isNull()) + actuator->m_handle->setVolume(gain); return PY_SET_ATTR_SUCCESS; } @@ -526,8 +517,8 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D return PY_SET_ATTR_FAIL; actuator->m_pitch = pitch; - if(actuator->m_handle) - AUD_setSoundPitch(actuator->m_handle, pitch); + if(!actuator->m_handle.isNull()) + actuator->m_handle->setPitch(pitch); return PY_SET_ATTR_SUCCESS; } @@ -539,12 +530,11 @@ int KX_SoundActuator::pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_D if (!PyArg_Parse(value, "O", &sound)) return PY_SET_ATTR_FAIL; - AUD_Sound* snd = AUD_getPythonSound(sound); + AUD_Reference* snd = reinterpret_cast*>(AUD_getPythonSound(sound)); if(snd) { - if(actuator->m_sound) - AUD_unload(actuator->m_sound); - actuator->m_sound = snd; + actuator->m_sound = *snd; + delete snd; return PY_SET_ATTR_SUCCESS; } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.h b/source/gameengine/Ketsji/KX_SoundActuator.h index 395064b66be..b1161e0cad2 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.h +++ b/source/gameengine/Ketsji/KX_SoundActuator.h @@ -38,6 +38,9 @@ #ifdef WITH_AUDASPACE # include "AUD_C-API.h" +# include "AUD_Reference.h" +# include "AUD_IFactory.h" +# include "AUD_IHandle.h" #endif #include "BKE_sound.h" @@ -58,12 +61,12 @@ class KX_SoundActuator : public SCA_IActuator { Py_Header; bool m_isplaying; - AUD_Sound* m_sound; + AUD_Reference m_sound; float m_volume; float m_pitch; bool m_is3d; KX_3DSoundSettings m_3d; - AUD_Handle* m_handle; + AUD_Reference m_handle; void play(); @@ -84,7 +87,7 @@ public: KX_SOUNDACT_TYPE m_type; KX_SoundActuator(SCA_IObject* gameobj, - AUD_Sound* sound, + AUD_Reference sound, float volume, float pitch, bool is3d, diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript index 4eb9ee8b3f0..c5509dd7de8 100644 --- a/source/gameengine/Ketsji/SConscript +++ b/source/gameengine/Ketsji/SConscript @@ -11,7 +11,7 @@ incs += ' #source/blender/python/mathutils' # Only for mathutils, be very carefu incs += ' #intern/string #intern/guardedalloc #intern/container' incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer' -incs += ' #intern/audaspace/intern #source/gameengine/Converter' +incs += ' #intern/audaspace/intern #intern/audaspace/FX #source/gameengine/Converter' incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf #intern/moto/include' incs += ' #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork #source/blender/blenlib #source/blender/blenfont' incs += ' #source/blender/blenkernel #source/blender #source/blender/editors/include' -- cgit v1.2.3 From 022e815fbd6d81f9b1baa177cce1abf2f42bcb21 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 7 Aug 2011 12:27:20 +0000 Subject: Sound clip NLA Strips for Nexyon These are basically just for specifying when a speaker should fire off it's soundclip, and as such, many NLA operations are irrelevant for it. They can only be specified on object-level for speaker objects. I've still got some UI tweaks I'll need to work on in order for these to be able to be added even when the speaker doesn't have any NLA tracks yet. (EDIT: while typing this, I had an idea for how to do this, but that'll be for next commit). In the mean time, you'll need to add a single keyframe for the object, snowflake that action and delete the NLA strip before you can start editing. --- source/blender/blenkernel/BKE_nla.h | 3 + source/blender/blenkernel/intern/anim_sys.c | 3 + source/blender/blenkernel/intern/nla.c | 40 +++++++++++ source/blender/editors/animation/anim_filter.c | 3 +- source/blender/editors/space_nla/nla_buttons.c | 80 +++++++++++++++------- source/blender/editors/space_nla/nla_draw.c | 19 +++++- source/blender/editors/space_nla/nla_edit.c | 95 +++++++++++++++++++++++++- source/blender/editors/space_nla/nla_intern.h | 1 + source/blender/editors/space_nla/nla_ops.c | 2 + source/blender/makesdna/DNA_anim_types.h | 5 +- source/blender/makesrna/intern/rna_nla.c | 2 +- 11 files changed, 222 insertions(+), 31 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 0206756a1ad..49c1f8acd24 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -39,6 +39,8 @@ struct AnimData; struct NlaStrip; struct NlaTrack; struct bAction; +struct Scene; +struct Speaker; /* ----------------------------- */ /* Data Management */ @@ -54,6 +56,7 @@ void copy_nladata(ListBase *dst, ListBase *src); struct NlaTrack *add_nlatrack(struct AnimData *adt, struct NlaTrack *prev); struct NlaStrip *add_nlastrip(struct bAction *act); struct NlaStrip *add_nlastrip_to_stack(struct AnimData *adt, struct bAction *act); +struct NlaStrip *add_nla_soundstrip(struct Scene *scene, struct Speaker *spk); /* ----------------------------- */ /* API */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index a43cdc8143e..832d13c9c2f 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1921,6 +1921,9 @@ void nlastrip_evaluate (PointerRNA *ptr, ListBase *channels, ListBase *modifiers case NLASTRIP_TYPE_META: /* meta */ nlastrip_evaluate_meta(ptr, channels, modifiers, nes); break; + + default: /* do nothing */ + break; } /* clear temp recursion safe-check */ diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index f2ce8e4e6f1..dad49646622 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -46,6 +46,8 @@ #include "DNA_anim_types.h" #include "DNA_scene_types.h" +#include "DNA_sound_types.h" +#include "DNA_speaker_types.h" #include "BKE_action.h" #include "BKE_fcurve.h" @@ -53,6 +55,9 @@ #include "BKE_global.h" #include "BKE_library.h" +#ifdef WITH_AUDASPACE +# include "AUD_C-API.h" +#endif #include "RNA_access.h" #include "nla_private.h" @@ -337,6 +342,41 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act) return strip; } +/* Add a NLA Strip referencing the given speaker's sound */ +NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker) +{ + NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip"); + + /* if speaker has a sound, set the strip length to the length of the sound, + * otherwise default to length of 10 frames + */ +#ifdef WITH_AUDASPACE + if (speaker->sound) + { + AUD_SoundInfo info = AUD_getInfo(speaker->sound->playback_handle); + + strip->end = ceil(info.length * FPS); + } + else +#endif + { + strip->end = 10.0f; + } + + /* general settings */ + strip->type = NLASTRIP_TYPE_SOUND; + + strip->flag = NLASTRIP_FLAG_SELECT; + strip->extendmode = NLASTRIP_EXTEND_NOTHING; /* nothing to extend... */ + + /* strip should be referenced as-is */ + strip->scale= 1.0f; + strip->repeat = 1.0f; + + /* return this strip */ + return strip; +} + /* *************************************************** */ /* NLA Evaluation <-> Editing Stuff */ diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 4927b0f097a..b4d1253c764 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -397,6 +397,7 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac) * 2A) nla tracks: include animdata block's data as there are NLA tracks+strips there * 2B) actions to convert to nla: include animdata block's data as there is an action that can be * converted to a new NLA strip, and the filtering options allow this + * 2C) allow non-animated datablocks to be included so that datablocks can be added * 3) drivers: include drivers from animdata block (for Drivers mode in Graph Editor) * 4) normal keyframes: only when there is an active action */ @@ -1625,7 +1626,7 @@ static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, case OB_SPEAKER: /* ---------- Speaker ----------- */ { Speaker *spk= (Speaker *)ob->data; - + type= ANIMTYPE_DSSPK; expanded= FILTER_SPK_OBJD(spk); } diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index b6de8e7fb59..0f0662d84b1 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -213,6 +213,24 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt) return (strip->type == NLASTRIP_TYPE_CLIP); } +static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) +{ + PointerRNA ptr; + NlaStrip *strip; + + if (!nla_panel_context(C, NULL, NULL, &ptr)) + return 0; + if (ptr.data == NULL) + return 0; + + strip= ptr.data; + + if (strip->type == NLASTRIP_TYPE_SOUND) + return 0; + + return 1; +} + /* -------------- */ /* active AnimData */ @@ -278,6 +296,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa) uiLayout *layout= pa->layout; uiLayout *column, *row, *subcol; uiBlock *block; + short showEvalProps = 1; if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; @@ -297,32 +316,41 @@ static void nla_panel_properties(const bContext *C, Panel *pa) uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); - /* extrapolation */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); + /* Evaluation-Related Strip Properties ------------------ */ - /* blending */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); - - /* blend in/out + autoblending - * - blend in/out can only be set when autoblending is off - */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); - uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? - - subcol= uiLayoutColumn(column, 1); - uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); - uiItemR(subcol, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); - uiItemR(subcol, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); + /* sound properties strips don't have these settings */ + if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND) + showEvalProps = 0; + + /* only show if allowed to... */ + if (showEvalProps) { + /* extrapolation */ + row= uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); - /* settings */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); - uiItemL(column, "Playback Settings:", ICON_NONE); - uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); - uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE); + /* blending */ + row= uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); + + /* blend in/out + autoblending + * - blend in/out can only be set when autoblending is off + */ + column= uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); + uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? + + subcol= uiLayoutColumn(column, 1); + uiLayoutSetActive(subcol, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); + uiItemR(subcol, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); + uiItemR(subcol, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); + + /* settings */ + column= uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); + uiItemL(column, "Playback Settings:", ICON_NONE); + uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); + uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE); + } } @@ -476,14 +504,14 @@ void nla_buttons_register(ARegionType *art) strcpy(pt->idname, "NLA_PT_evaluation"); strcpy(pt->label, "Evaluation"); pt->draw= nla_panel_evaluation; - pt->poll= nla_strip_panel_poll; + pt->poll= nla_strip_eval_panel_poll; BLI_addtail(&art->paneltypes, pt); pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers"); strcpy(pt->idname, "NLA_PT_modifiers"); strcpy(pt->label, "Modifiers"); pt->draw= nla_panel_modifiers; - pt->poll= nla_strip_panel_poll; + pt->poll= nla_strip_eval_panel_poll; BLI_addtail(&art->paneltypes, pt); } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index bc0b9616836..eb9529b5186 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -198,7 +198,24 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co color[1]= 0.15f; color[2]= 0.26f; } - } + } + else if (strip->type == NLASTRIP_TYPE_SOUND) { + /* Sound Clip */ + if (strip->flag & NLASTRIP_FLAG_SELECT) { + /* selected - use a bright teal color */ + // FIXME: hardcoded temp-hack colors + color[0]= 0.12f; + color[1]= 0.48f; + color[2]= 0.48f; + } + else { + /* normal, unselected strip - use (hardly noticable) teal tinge */ + // FIXME: hardcoded temp-hack colors + color[0]= 0.17f; + color[1]= 0.24f; + color[2]= 0.24f; + } + } else { /* Action Clip (default/normal type of strip) */ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) && (adt && (adt->flag & ADT_NLA_EDIT_ON))) { diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index eb22495c977..fa24bd2f895 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -36,6 +36,7 @@ #include #include "DNA_anim_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "MEM_guardedalloc.h" @@ -536,12 +537,15 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) /* check if there's space between the two */ if (IS_EQ(s1->end, s2->start)) continue; - /* make neither one is a transition + /* make sure neither one is a transition * - although this is impossible to create with the standard tools, * the user may have altered the settings */ if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) continue; + /* also make sure neither one is a soundclip */ + if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type)) + continue; /* allocate new strip */ strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip"); @@ -608,6 +612,91 @@ void NLA_OT_transition_add (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* ******************** Add Sound Clip Operator ***************************** */ +/* Add a new sound clip */ + +static int nlaedit_add_sound_exec (bContext *C, wmOperator *op) +{ + bAnimContext ac; + + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; + + Scene *scene; + int cfra; + + /* get editor data */ + if (ANIM_animdata_get_context(C, &ac) == 0) + return OPERATOR_CANCELLED; + + scene = ac.scene; + cfra = CFRA; + + /* get a list of the editable tracks being shown in the NLA */ + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + /* for each track, add sound clips if it belongs to a speaker */ + // TODO: what happens if there aren't any tracks... well that's a more general problem for later + for (ale= anim_data.first; ale; ale= ale->next) { + Object *ob = (Object *)ale->id; /* may not be object until we actually check! */ + + AnimData *adt = ale->adt; + NlaTrack *nlt= (NlaTrack *)ale->data; + NlaStrip *strip; + + /* does this belong to speaker - assumed to live on Object level only */ + if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER)) + continue; + + /* create a new strip, and offset it to start on the current frame */ + strip= add_nla_soundstrip(ac.scene, ob->data); + + strip->start += cfra; + strip->end += cfra; + + /* firstly try adding strip to our current track, but if that fails, add to a new track */ + if (BKE_nlatrack_add_strip(nlt, strip) == 0) { + /* trying to add to the current failed (no space), + * so add a new track to the stack, and add to that... + */ + nlt= add_nlatrack(adt, NULL); + BKE_nlatrack_add_strip(nlt, strip); + } + + /* auto-name it */ + BKE_nlastrip_validate_name(adt, strip); + } + + /* free temp data */ + BLI_freelistN(&anim_data); + + /* refresh auto strip properties */ + ED_nla_postop_refresh(&ac); + + /* set notifier that things have changed */ + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + + /* done */ + return OPERATOR_FINISHED; +} + +void NLA_OT_soundclip_add (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Sound Clip"; + ot->idname= "NLA_OT_soundclip_add"; + ot->description= "Add a strip for controlling when speaker plays its sound clip"; + + /* api callbacks */ + ot->exec= nlaedit_add_sound_exec; + ot->poll= nlaop_poll_tweakmode_off; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* ******************** Add Meta-Strip Operator ***************************** */ /* Add new meta-strips incorporating the selected strips */ @@ -1923,6 +2012,10 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) continue; } + /* sound clips are not affected by FModifiers */ + if (strip->type == NLASTRIP_TYPE_SOUND) + continue; + /* add F-Modifier of specified type to selected, and make it the active one */ fcm= add_fmodifier(&strip->modifiers, type); diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 43ef5beb216..bd76d2484dd 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -99,6 +99,7 @@ void NLA_OT_view_selected(wmOperatorType *ot); void NLA_OT_actionclip_add(wmOperatorType *ot); void NLA_OT_transition_add(wmOperatorType *ot); +void NLA_OT_soundclip_add(wmOperatorType *ot); void NLA_OT_meta_add(wmOperatorType *ot); void NLA_OT_meta_remove(wmOperatorType *ot); diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 38e12c46060..8ed117755c7 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -140,6 +140,7 @@ void nla_operatortypes(void) WM_operatortype_append(NLA_OT_actionclip_add); WM_operatortype_append(NLA_OT_transition_add); + WM_operatortype_append(NLA_OT_soundclip_add); WM_operatortype_append(NLA_OT_meta_add); WM_operatortype_append(NLA_OT_meta_remove); @@ -233,6 +234,7 @@ static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap) /* add strips */ WM_keymap_add_item(keymap, "NLA_OT_actionclip_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_transition_add", TKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "NLA_OT_soundclip_add", KKEY, KM_PRESS, KM_SHIFT, 0); /* meta-strips */ WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 374799ecf08..5a031e04fe4 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -651,7 +651,10 @@ typedef enum eNlaStrip_Type { /* 'transition' - blends between the adjacent strips */ NLASTRIP_TYPE_TRANSITION, /* 'meta' - a strip which acts as a container for a few others */ - NLASTRIP_TYPE_META + NLASTRIP_TYPE_META, + + /* 'emit sound' - a strip which is used for timing when speaker emits sounds */ + NLASTRIP_TYPE_SOUND } eNlaStrip_Type; /* NLA Tracks ------------------------------------- */ diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 01bfbc0e133..5756044d12b 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -380,6 +380,7 @@ static void rna_def_nlastrip(BlenderRNA *brna) {NLASTRIP_TYPE_CLIP, "CLIP", 0, "Action Clip", "NLA Strip references some Action"}, {NLASTRIP_TYPE_TRANSITION, "TRANSITION", 0, "Transition", "NLA Strip 'transitions' between adjacent strips"}, {NLASTRIP_TYPE_META, "META", 0, "Meta", "NLA Strip acts as a container for adjacent strips"}, + {NLASTRIP_TYPE_SOUND, "SOUND", 0, "Sound Clip", "NLA Strip representing a sound event for speakers"}, {0, NULL, 0, NULL, NULL}}; /* struct definition */ @@ -447,7 +448,6 @@ static void rna_def_nlastrip(BlenderRNA *brna) RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ /* Action */ - // TODO: this should only be editable if it is not being edited atm... prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Action_id_poll"); -- cgit v1.2.3 From b057cf1bb118a070e2eeb3b2029aa80fad00a9b2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 7 Aug 2011 12:43:44 +0000 Subject: Nla Sound Strips + Add Speaker Second part of previous commit. Now, when speaker objects are created, they are created by default with an NLA sound strip so that it is easy to just start immediately using this to do cool stuff (i.e. timing when you want the sound to start). --- source/blender/editors/object/object_add.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source') diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 22e6a5243c7..97d109118d1 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -35,6 +35,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_curve_types.h" #include "DNA_group_types.h" #include "DNA_lamp_types.h" @@ -69,6 +70,7 @@ #include "BKE_mball.h" #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_nla.h" #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_report.h" @@ -778,6 +780,25 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; ob= ED_object_add_type(C, OB_SPEAKER, loc, rot, FALSE, layer); + + /* to make it easier to start using this immediately in NLA, a default sound clip is created + * ready to be moved around to retime the sound and/or make new sound clips + */ + { + /* create new data for NLA hierarchy */ + AnimData *adt = BKE_id_add_animdata(&ob->id); + NlaTrack *nlt = add_nlatrack(adt, NULL); + NlaStrip *strip = add_nla_soundstrip(CTX_data_scene(C), ob->data); + + /* hook them up */ + BKE_nlatrack_add_strip(nlt, strip); + + /* auto-name the strip, and give the track an interesting name */ + strcpy(nlt->name, "SoundTrack"); + BKE_nlastrip_validate_name(adt, strip); + + WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + } return OPERATOR_FINISHED; } -- cgit v1.2.3 From c095397c988cd2ef6a956ce2742814ea2d3e7f0d Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 7 Aug 2011 18:15:40 +0000 Subject: Armature bake animation export ( not as pose matrices. Still needs fixing ) --- source/blender/collada/AnimationExporter.cpp | 21 ++++++++++++++++++++- source/blender/collada/AnimationExporter.h | 1 + source/blender/collada/AnimationImporter.cpp | 7 +++++++ source/blender/collada/AnimationImporter.h | 3 ++- 4 files changed, 30 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 53f3cc9aae3..b1b26fa2915 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -367,7 +367,7 @@ void AnimationExporter::exportAnimations(Scene *sce) if (!pchan) return; - find_all_frames(ob_arm, fra); + find_frames(ob_arm, fra); if (flag & ARM_RESTPOS) { arm->flag &= ~ARM_RESTPOS; @@ -1119,6 +1119,25 @@ void AnimationExporter::exportAnimations(Scene *sce) return; } + + void AnimationExporter::find_frames(Object *ob, std::vector &fra) + { + FCurve *fcu= (FCurve*)ob->adt->action->curves.first; + + for (; fcu; fcu = fcu->next) { + + for (unsigned int i = 0; i < fcu->totvert; i++) { + float f = fcu->bezt[i].vec[1][0]; // + if (std::find(fra.begin(), fra.end(), f) == fra.end()) + fra.push_back(f); + } + } + + // keep the keys in ascending order + std::sort(fra.begin(), fra.end()); + } + + void AnimationExporter::find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name) { FCurve *fcu= (FCurve*)ob->adt->action->curves.first; diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index cadd6940e9d..d4559782ff4 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -144,6 +144,7 @@ protected: std::string get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); void find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name); + void find_frames(Object *ob, std::vector &fra); void find_all_frames(Object *ob, std::vector &fra); diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 8ae2d6970cd..0fc01e51020 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -929,6 +929,12 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , Assign_float_animations( listid, AnimCurves , "specular_hardness" ); } + if((animType->material & MATERIAL_IOR) != 0){ + const COLLADAFW::FloatOrParam *ior = &(efc->getIndexOfRefraction()); + const COLLADAFW::UniqueId& listid = ior->getAnimationList(); + Assign_float_animations( listid, AnimCurves , "raytrace_transparency.ior" ); + } + if((animType->material & MATERIAL_SPEC_COLOR) != 0){ const COLLADAFW::ColorOrTexture *cot = &(efc->getSpecular()); const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList(); @@ -1010,6 +1016,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD types->material = setAnimType(&(efc->getSpecular().getColor()),(types->material), MATERIAL_SPEC_COLOR); types->material = setAnimType(&(efc->getDiffuse().getColor()),(types->material), MATERIAL_DIFF_COLOR); // types->material = setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY); + types->material = setAnimType(&(efc->getIndexOfRefraction()),(types->material), MATERIAL_IOR); } } return types; diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 02b7b05afec..ea7de961382 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -111,7 +111,8 @@ private: MATERIAL_SHININESS = 2, MATERIAL_SPEC_COLOR = 4, MATERIAL_DIFF_COLOR = 1 << 3, - MATERIAL_TRANSPARENCY = 1 << 4 + MATERIAL_TRANSPARENCY = 1 << 4, + MATERIAL_IOR = 1 << 5 }; enum AnimationType -- cgit v1.2.3 From 3aa0953d95e43296e756f9763144c8c127be5ca5 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 7 Aug 2011 19:22:39 +0000 Subject: COLLADA Armature bake animation export fixed( needs more testing ) --- source/blender/collada/AnimationExporter.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index b1b26fa2915..fc13207dd2e 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -382,6 +382,10 @@ void AnimationExporter::exportAnimations(Scene *sce) dae_baked_animation(fra ,values, id_name(ob_arm), bone->name ); } + + if (flag & ARM_RESTPOS) + arm->flag = flag; + where_is_pose(scene, ob_arm); } void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) @@ -458,7 +462,7 @@ void AnimationExporter::exportAnimations(Scene *sce) return; parchan = pchan->parent; - + enable_fcurves(ob_arm->adt->action, bone->name); std::vector::iterator it; -- cgit v1.2.3 From a8096ef0acb780d5a6d93aef422ce3d82877a60c Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 7 Aug 2011 19:32:22 +0000 Subject: Updating CMake to install the correct ffmpeg libs. --- source/creator/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 43fec85b5bf..da08547e803 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -547,11 +547,11 @@ elseif(WIN32) if(WITH_CODEC_FFMPEG) install( FILES - ${LIBDIR}/ffmpeg/lib/avcodec-52.dll - ${LIBDIR}/ffmpeg/lib/avformat-52.dll - ${LIBDIR}/ffmpeg/lib/avdevice-52.dll - ${LIBDIR}/ffmpeg/lib/avutil-50.dll - ${LIBDIR}/ffmpeg/lib/swscale-0.dll + ${LIBDIR}/ffmpeg-0.8/lib/avcodec-53.dll + ${LIBDIR}/ffmpeg-0.8/lib/avformat-53.dll + ${LIBDIR}/ffmpeg-0.8/lib/avdevice-53.dll + ${LIBDIR}/ffmpeg-0.8/lib/avutil-51.dll + ${LIBDIR}/ffmpeg-0.8/lib/swscale-2.dll DESTINATION ${TARGETDIR} ) -- cgit v1.2.3 From 8883702f8a3b57d0316811e9412bd46ce0dd9c0d Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 8 Aug 2011 04:28:30 +0000 Subject: BGE Animations: Various compatibility fixes: * Blendin for Loop End works even after a negative pulse. Flipper could still use some work in this area. * Continuous works a lot better. * BL_Action::SetFrame() should work a little smoother. --- source/gameengine/Converter/BL_ActionActuator.cpp | 18 +++++----- source/gameengine/Ketsji/BL_Action.cpp | 43 ++++++++++++++++------- source/gameengine/Ketsji/BL_Action.h | 4 +++ source/gameengine/Ketsji/BL_ActionManager.cpp | 12 +++++++ source/gameengine/Ketsji/BL_ActionManager.h | 10 ++++++ source/gameengine/Ketsji/KX_GameObject.cpp | 10 ++++++ source/gameengine/Ketsji/KX_GameObject.h | 10 ++++++ 7 files changed, 86 insertions(+), 21 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 0932493ccb8..8efcdd8c551 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -139,6 +139,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) { bool bNegativeEvent = false; bool bPositiveEvent = false; + bool use_continue = false; KX_GameObject *obj = (KX_GameObject*)GetParent(); short play_mode = BL_Action::ACT_MODE_PLAY; float start = m_startframe, end = m_endframe; @@ -172,6 +173,10 @@ bool BL_ActionActuator::Update(double curtime, bool frame) play_mode = BL_Action::ACT_MODE_PLAY; start = end = prop->GetNumber(); } + + // Continue only really makes sense for play stop. All other modes go until they are complete. + if (m_flag & ACT_FLAG_CONTINUE && m_playtype == ACT_ACTION_LOOP_STOP) + use_continue = true; // Handle events @@ -184,14 +189,10 @@ bool BL_ActionActuator::Update(double curtime, bool frame) if (bPositiveEvent) { - - if (m_playtype != ACT_ACTION_PINGPONG && m_flag & ACT_FLAG_ACTIVE && m_flag & ACT_FLAG_CONTINUE) - start = m_localtime = obj->GetActionFrame(m_layer); - if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, m_layer_weight, m_ipo_flags)) { m_flag |= ACT_FLAG_ACTIVE; - if (m_playtype != ACT_ACTION_PINGPONG && m_flag & ACT_FLAG_CONTINUE) + if (use_continue) obj->SetActionFrame(m_layer, m_localtime); if (m_playtype == ACT_ACTION_PLAY) @@ -217,6 +218,8 @@ bool BL_ActionActuator::Update(double curtime, bool frame) if (m_playtype == ACT_ACTION_LOOP_STOP) { m_localtime = obj->GetActionFrame(m_layer); + if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) + m_localtime = m_startframe; obj->StopAction(m_layer); // Stop the action after getting the frame // We're done @@ -226,9 +229,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) else if (m_playtype == ACT_ACTION_LOOP_END || m_playtype == ACT_ACTION_PINGPONG) { // Convert into a play and let it finish - start = obj->GetActionFrame(m_layer); - obj->StopAction(m_layer); - obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags); + obj->SetPlayMode(m_layer, BL_Action::ACT_MODE_PLAY); m_flag |= ACT_FLAG_PLAY_END; @@ -240,7 +241,6 @@ bool BL_ActionActuator::Update(double curtime, bool frame) // Convert into a play action and play back to the beginning end = start; start = obj->GetActionFrame(m_layer); - obj->StopAction(m_layer); obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags); m_flag |= ACT_FLAG_PLAY_END; diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index caffd3cd8ca..4cf6f982006 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -67,7 +67,8 @@ BL_Action::BL_Action(class KX_GameObject* gameobj) m_priority(0), m_playmode(0), m_ipo_flags(0), - m_done(true) + m_done(true), + m_calc_localtime(true) { if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE) { @@ -215,24 +216,25 @@ float BL_Action::GetFrame() void BL_Action::SetFrame(float frame) { - float dt; - // Clamp the frame to the start and end frame if (frame < min(m_startframe, m_endframe)) frame = min(m_startframe, m_endframe); else if (frame > max(m_startframe, m_endframe)) frame = max(m_startframe, m_endframe); - // We don't set m_localtime directly since it's recalculated - // in the next update. So, we modify the value (m_starttime) - // used to calculate m_localtime the next time SetLocalTime() is called. - - dt = frame-m_startframe; + m_localtime = frame; + m_calc_localtime = false; +} - if (m_endframe < m_startframe) - dt = -dt; +void BL_Action::SetPlayMode(short play_mode) +{ + m_playmode = play_mode; +} - m_starttime -= dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed); +void BL_Action::SetTimes(float start, float end) +{ + m_startframe = start; + m_endframe = end; } void BL_Action::SetLocalTime(float curtime) @@ -245,6 +247,16 @@ void BL_Action::SetLocalTime(float curtime) m_localtime = m_startframe + dt; } +void BL_Action::ResetStartTime(float curtime) +{ + float dt = m_localtime - m_startframe; + + m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed); + printf("Before: %f, ", m_localtime); + SetLocalTime(curtime); + printf("After: %f\n", m_localtime); +} + void BL_Action::IncrementBlending(float curtime) { // Setup m_blendstart if we need to @@ -285,7 +297,14 @@ void BL_Action::Update(float curtime) return; curtime -= KX_KetsjiEngine::GetSuspendedDelta(); - SetLocalTime(curtime); + + if (m_calc_localtime) + SetLocalTime(curtime); + else + { + ResetStartTime(curtime); + m_calc_localtime = true; + } // Handle wrap around if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h index 14312e158c0..75bda56419a 100644 --- a/source/gameengine/Ketsji/BL_Action.h +++ b/source/gameengine/Ketsji/BL_Action.h @@ -71,9 +71,11 @@ private: short m_ipo_flags; bool m_done; + bool m_calc_localtime; void InitIPO(); void SetLocalTime(float curtime); + void ResetStartTime(float curtime); void IncrementBlending(float curtime); void BlendShape(struct Key* key, float srcweight, std::vector& blendshape); public: @@ -111,6 +113,8 @@ public: // Mutators void SetFrame(float frame); + void SetPlayMode(short play_mode); + void SetTimes(float start, float end); enum { diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp index 2ee0b58574a..af0d4bff8f0 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.cpp +++ b/source/gameengine/Ketsji/BL_ActionManager.cpp @@ -63,6 +63,18 @@ struct bAction *BL_ActionManager::GetCurrentAction(short layer) return 0; } +void BL_ActionManager::SetPlayMode(short layer, short mode) +{ + if (m_layers[layer]) + m_layers[layer]->SetPlayMode(mode); +} + +void BL_ActionManager::SetTimes(short layer, float start, float end) +{ + if (m_layers[layer]) + m_layers[layer]->SetTimes(start, end); +} + bool BL_ActionManager::PlayAction(const char* name, float start, float end, diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h index 3818f643b1c..c310e231ed7 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.h +++ b/source/gameengine/Ketsji/BL_ActionManager.h @@ -70,6 +70,16 @@ public: */ struct bAction *GetCurrentAction(short layer); + /** + * Sets play mode of the action on the given layer + */ + void SetPlayMode(short layer, short mode); + + /** + * Sets the start and end times of the action on the given layer + */ + void SetTimes(short layer, float start, float end); + /** * Stop playing the action on the given layer */ diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 91e62442646..4f8860f4767 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -404,6 +404,16 @@ bAction *KX_GameObject::GetCurrentAction(short layer) return GetActionManager()->GetCurrentAction(layer); } +void KX_GameObject::SetPlayMode(short layer, short mode) +{ + GetActionManager()->SetPlayMode(layer, mode); +} + +void KX_GameObject::SetTimes(short layer, float start, float end) +{ + GetActionManager()->SetTimes(layer, start, end); +} + void KX_GameObject::ProcessReplica() { SCA_IObject::ProcessReplica(); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 40bd86fed1b..6e79914172b 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -238,6 +238,16 @@ public: */ bAction *GetCurrentAction(short layer); + /** + * Sets play mode of the action on the given layer + */ + void SetPlayMode(short layer, short mode); + + /** + * Sets the start and end times of the action on the given layer + */ + void SetTimes(short layer, float start, float end); + /** * Stop playing the action on the given layer */ -- cgit v1.2.3 From cbec4e2768022596ff6acb145db3ae073e528397 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Mon, 8 Aug 2011 16:38:57 +0000 Subject: export bone transform matrix with sid. --- source/blender/collada/AnimationExporter.cpp | 2 +- source/blender/collada/TransformWriter.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index fc13207dd2e..4beab6f7608 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -586,7 +586,7 @@ void AnimationExporter::exportAnimations(Scene *sce) addSampler(sampler); - std::string target = translate_id(ob_name + "_" + bone_name) + "/transform"; + std::string target = translate_id(bone_name) + "/transform"; addChannel(COLLADABU::URI(empty, sampler_id), target); closeAnimation(); diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index 546ca3e3019..3ac0654c866 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -48,8 +48,13 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4], copy_m4_m4(local, mat); } + double dmat[4][4]; + for ( int i = 0 ; i< 4 ; i ++ ) + for ( int j =0 ; j < 4 ; j++) + dmat[i][j] = (double)local[i][j]; + TransformBase::decompose(local, loc, rot, NULL, scale); - + node.addMatrix("transform",dmat); add_transform(node, loc, rot, scale); } -- cgit v1.2.3 From 88786f6fca00aa042c5b6fb2665666d9fccb6237 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 9 Aug 2011 03:06:22 +0000 Subject: BGE Animations: Fixing the Continue option when using the Flipper play type. Also removing a couple of debug prints. --- source/gameengine/Converter/BL_ActionActuator.cpp | 17 ++++++++++++----- source/gameengine/Ketsji/BL_Action.cpp | 2 -- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 8efcdd8c551..4e4d838d8ff 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -174,8 +174,10 @@ bool BL_ActionActuator::Update(double curtime, bool frame) start = end = prop->GetNumber(); } - // Continue only really makes sense for play stop. All other modes go until they are complete. - if (m_flag & ACT_FLAG_CONTINUE && m_playtype == ACT_ACTION_LOOP_STOP) + // Continue only really makes sense for play stop and flipper. All other modes go until they are complete. + if (m_flag & ACT_FLAG_CONTINUE && + (m_playtype == ACT_ACTION_LOOP_STOP || + m_playtype == ACT_ACTION_FLIPPER)) use_continue = true; @@ -189,6 +191,9 @@ bool BL_ActionActuator::Update(double curtime, bool frame) if (bPositiveEvent) { + if (use_continue && m_flag & ACT_FLAG_ACTIVE) + start = m_localtime = obj->GetActionFrame(m_layer); + if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, m_layer_weight, m_ipo_flags)) { m_flag |= ACT_FLAG_ACTIVE; @@ -215,11 +220,13 @@ bool BL_ActionActuator::Update(double curtime, bool frame) return false; } + + m_localtime = obj->GetActionFrame(m_layer); + if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) + m_localtime = m_startframe; + if (m_playtype == ACT_ACTION_LOOP_STOP) { - m_localtime = obj->GetActionFrame(m_layer); - if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) - m_localtime = m_startframe; obj->StopAction(m_layer); // Stop the action after getting the frame // We're done diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 4cf6f982006..6682b0cea41 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -252,9 +252,7 @@ void BL_Action::ResetStartTime(float curtime) float dt = m_localtime - m_startframe; m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate()*m_speed); - printf("Before: %f, ", m_localtime); SetLocalTime(curtime); - printf("After: %f\n", m_localtime); } void BL_Action::IncrementBlending(float curtime) -- cgit v1.2.3 From 802f69df78a937cd94d855264c658212e3467c2a Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 9 Aug 2011 03:27:05 +0000 Subject: BGE Animations: Fixing issues with initialization order in BL_ShapeDeformer --- source/gameengine/Converter/BL_ShapeDeformer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index 82c73529a94..befe0f6e784 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -73,8 +73,8 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, RAS_MeshObject *mesh) : BL_SkinDeformer(gameobj,bmeshobj, mesh), - m_lastShapeUpdate(-1), - m_useShapeDrivers(false) + m_useShapeDrivers(false), + m_lastShapeUpdate(-1) { m_key = m_bmesh->key; m_bmesh->key = copy_key(m_key); @@ -90,8 +90,8 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, BL_ArmatureObject* arma) : BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, recalc_normal, arma), - m_lastShapeUpdate(-1), - m_useShapeDrivers(false) + m_useShapeDrivers(false), + m_lastShapeUpdate(-1) { m_key = m_bmesh->key; m_bmesh->key = copy_key(m_key); -- cgit v1.2.3 From 13249b925eda7752b65a36d8270a3af3bdc02981 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 9 Aug 2011 08:38:14 +0000 Subject: 3D Audio GSoC: Speaker objects fully functional! Minor changes: * Fixed three memory bugs found via valgrind. * Fixed bug with jack transport crashing after file loading. * Sound NLA Strips now start at CFRA instead of 0. --- source/blender/blenkernel/BKE_sound.h | 4 ++ source/blender/blenkernel/intern/blender.c | 3 + source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/scene.c | 3 + source/blender/blenkernel/intern/sound.c | 88 +++++++++++++++++++++++++++++- source/blender/editors/object/object_add.c | 3 + source/blender/makesdna/DNA_anim_types.h | 2 + 7 files changed, 103 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 2cd006385e0..c36532ee4cc 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -46,6 +46,8 @@ void sound_init_once(void); void sound_init(struct Main *main); +void sound_init_main(struct Main *bmain); + void sound_exit(void); void sound_force_device(int device); @@ -124,6 +126,8 @@ int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length, flo int sound_get_channels(struct bSound* sound); +void sound_update_scene(struct Main* bmain, struct Scene* scene); + void* sound_get_factory(void* sound); #endif diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index a3a4c5b555b..5f33059e117 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -82,6 +82,7 @@ #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_sequencer.h" +#include "BKE_sound.h" #include "BLO_undofile.h" @@ -247,6 +248,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath G.main= bfd->main; CTX_data_main_set(C, G.main); + + sound_init_main(G.main); if (bfd->user) { diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8668168936b..c362f3eb2fe 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -533,7 +533,6 @@ int set_listbasepointers(Main *main, ListBase **lb) lb[a++]= &(main->latt); lb[a++]= &(main->lamp); lb[a++]= &(main->camera); - lb[a++]= &(main->speaker); lb[a++]= &(main->text); lb[a++]= &(main->sound); @@ -541,6 +540,7 @@ int set_listbasepointers(Main *main, ListBase **lb) lb[a++]= &(main->brush); lb[a++]= &(main->script); lb[a++]= &(main->particle); + lb[a++]= &(main->speaker); lb[a++]= &(main->world); lb[a++]= &(main->screen); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 74126fd57a1..12e81e8296e 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -966,6 +966,9 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen /* scene drivers... */ scene_update_drivers(bmain, scene); + + /* update sound system animation */ + sound_update_scene(bmain, scene); } /* this is called in main loop, doing tagged updates before redraw */ diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 890fc114e68..17df6ba23cb 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -13,13 +13,16 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_math.h" #include "DNA_anim_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "DNA_packedFile_types.h" #include "DNA_screen_types.h" #include "DNA_sound_types.h" +#include "DNA_speaker_types.h" #ifdef WITH_AUDASPACE # include "AUD_C-API.h" @@ -175,7 +178,12 @@ void sound_init(struct Main *bmain) if(!AUD_init(device, specs, buffersize)) AUD_init(AUD_NULL_DEVICE, specs, buffersize); - + + sound_init_main(bmain); +} + +void sound_init_main(struct Main *bmain) +{ #ifdef WITH_JACK AUD_setSyncCallback(sound_sync_callback, bmain); #else @@ -617,6 +625,84 @@ int sound_get_channels(struct bSound* sound) return info.specs.channels; } +void sound_update_scene(struct Main* bmain, struct Scene* scene) +{ + Object* ob; + NlaTrack* track; + NlaStrip* strip; + Speaker* speaker; + + void* new_set = AUD_createSet(); + void* handle; + float quat[4]; + + for(ob = bmain->object.first; ob; ob = ob->id.next) + { + if(ob->type == OB_SPEAKER) + { + if(ob->adt) + { + for(track = ob->adt->nla_tracks.first; track; track = track->next) + { + for(strip = track->strips.first; strip; strip = strip->next) + { + if(strip->type == NLASTRIP_TYPE_SOUND) + { + speaker = (Speaker*)ob->data; + + if(AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) + { + AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0); + } + else + { + if(speaker && speaker->sound) + { + strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0); + AUD_setRelativeSequence(strip->speaker_handle, 0); + } + } + + if(strip->speaker_handle) + { + AUD_addSet(new_set, strip->speaker_handle); + AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max, + speaker->volume_min, speaker->distance_max, + speaker->distance_reference, speaker->attenuation, + speaker->cone_angle_outer, speaker->cone_angle_inner, + speaker->cone_volume_outer); + + mat4_to_quat(quat, ob->obmat); + AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1); + AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_ORIENTATION, CFRA, quat, 1); + AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_VOLUME, CFRA, &speaker->volume, 1); + AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_PITCH, CFRA, &speaker->pitch, 1); + AUD_updateSequenceSound(strip->speaker_handle, speaker->sound->playback_handle); + AUD_muteSequence(strip->speaker_handle, ((strip->flag & NLASTRIP_FLAG_MUTED) != 0) || ((speaker->flag & SPK_MUTED) != 0)); + } + } + } + } + } + } + } + + while((handle = AUD_getSet(scene->speaker_handles))) + { + AUD_removeSequence(scene->sound_scene, handle); + } + + if(scene->camera) + { + mat4_to_quat(quat, scene->camera->obmat); + AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_LOCATION, CFRA, scene->camera->obmat[3], 1); + AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_ORIENTATION, CFRA, quat, 1); + } + + AUD_destroySet(scene->speaker_handles); + scene->speaker_handles = new_set; +} + void* sound_get_factory(void* sound) { return ((struct bSound*) sound)->playback_handle; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 97d109118d1..09ce2562e3b 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -774,6 +774,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) int enter_editmode; unsigned int layer; float loc[3], rot[3]; + Scene *scene = CTX_data_scene(C); object_add_generic_invoke_options(C, op); if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer)) @@ -789,6 +790,8 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) AnimData *adt = BKE_id_add_animdata(&ob->id); NlaTrack *nlt = add_nlatrack(adt, NULL); NlaStrip *strip = add_nla_soundstrip(CTX_data_scene(C), ob->data); + strip->start = CFRA; + strip->end += strip->start; /* hook them up */ BKE_nlatrack_add_strip(nlt, strip); diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 5a031e04fe4..c0030cd0e5e 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -585,6 +585,8 @@ typedef struct NlaStrip { short type; /* type of NLA strip */ + void *speaker_handle; /* handle for speaker objects */ + int flag; /* settings */ int pad2; } NlaStrip; -- cgit v1.2.3 From a672ab5e737202bede956a88357a96cf2728df15 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 9 Aug 2011 14:10:32 +0000 Subject: 3D Audio GSoC: Improved waveform drawing in the sequencer. * Drawing the waveform of a sequencer strip is now independent from whether the sound is cached or not. * Improved drawing of the waveform in the sequencer (especially speed!). * Making it possible to vertically zoom more in the sequencer to better see the waveform for lipsync. * Fixed a bug which crashed blender on loading a sound file via ffmpeg. --- source/blender/blenkernel/BKE_sound.h | 12 ++++- source/blender/blenkernel/intern/sound.c | 35 +++++++++++-- source/blender/blenloader/intern/readfile.c | 31 +++++++++++ .../editors/space_sequencer/sequencer_draw.c | 61 +++++++++++++++++----- .../editors/space_sequencer/space_sequencer.c | 2 +- source/blender/makesdna/DNA_sequence_types.h | 1 + source/blender/makesdna/DNA_sound_types.h | 5 ++ source/blender/makesrna/intern/rna_sequencer.c | 5 ++ 8 files changed, 131 insertions(+), 21 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index c36532ee4cc..ecf0d7e459a 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -35,6 +35,8 @@ * \author nzc */ +#define SOUND_WAVE_SAMPLES_PER_SECOND 250 + struct PackedFile; struct bSound; struct bContext; @@ -42,6 +44,12 @@ struct ListBase; struct Main; struct Sequence; +typedef struct SoundWaveform +{ + int length; + float *data; +} SoundWaveform; + void sound_init_once(void); void sound_init(struct Main *main); @@ -122,7 +130,9 @@ float sound_sync_scene(struct Scene *scene); int sound_scene_playing(struct Scene *scene); -int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length, float start, float end); +void sound_free_waveform(struct bSound* sound); + +void sound_read_waveform(struct bSound* sound); int sound_get_channels(struct bSound* sound); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 17df6ba23cb..888c719a304 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -24,6 +24,7 @@ #include "DNA_sound_types.h" #include "DNA_speaker_types.h" +#define WITH_AUDASPACE #ifdef WITH_AUDASPACE # include "AUD_C-API.h" #endif @@ -96,6 +97,8 @@ void sound_free(struct bSound* sound) AUD_unload(sound->cache); sound->cache = NULL; } + + sound_free_waveform(sound); #endif // WITH_AUDASPACE } @@ -608,12 +611,34 @@ int sound_scene_playing(struct Scene *scene) return -1; } -int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length, float start, float end) +void sound_free_waveform(struct bSound* sound) +{ + if(sound->waveform) + { + MEM_freeN(((SoundWaveform*)sound->waveform)->data); + MEM_freeN(sound->waveform); + } + + sound->waveform = NULL; +} + +void sound_read_waveform(struct bSound* sound) { - AUD_Sound* limiter = AUD_limitSound(sound->cache, start, end); - int ret= AUD_readSound(limiter, buffer, length); - AUD_unload(limiter); - return ret; + AUD_SoundInfo info; + + info = AUD_getInfo(sound->playback_handle); + + if(info.length > 0) + { + SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");; + int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND; + + waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples"); + waveform->length = AUD_readSound(sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND); + + sound_free_waveform(sound); + sound->waveform = waveform; + } } int sound_get_channels(struct bSound* sound) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index ef71df31df4..ae5bafa2d08 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5609,6 +5609,7 @@ static void direct_link_sound(FileData *fd, bSound *sound) { sound->handle = NULL; sound->playback_handle = NULL; + sound->waveform = NULL; // versioning stuff, if there was a cache, then we enable caching: if(sound->cache) @@ -11766,6 +11767,36 @@ static void do_versions(FileData *fd, Library *lib, Main *main) SEQ_END } } + { + bScreen *screen; + for(screen= main->screen.first; screen; screen= screen->id.next) { + ScrArea *sa; + /* add regions */ + for(sa= screen->areabase.first; sa; sa= sa->next) { + SpaceLink *sl= sa->spacedata.first; + if(sl->spacetype==SPACE_SEQ) { + ARegion *ar; + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + if(ar->v2d.min[1] == 4.0f) + ar->v2d.min[1]= 0.5f; + } + } + } + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->spacetype==SPACE_SEQ) { + ARegion *ar; + for (ar=sl->regionbase.first; ar; ar= ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + if(ar->v2d.min[1] == 4.0f) + ar->v2d.min[1]= 0.5f; + } + } + } + } + } + } + } { /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve * diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 7e4207c75fe..bc97ff341db 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -173,30 +173,63 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x x2 the end x value, same for y1 and y2 stepsize is width of a pixel. */ - if(seq->sound->cache) + if(seq->flag & SEQ_AUDIO_DRAW_WAVEFORM) { - int i; + int i, j, pos; int length = floor((x2-x1)/stepsize)+1; float ymid = (y1+y2)/2; float yscale = (y2-y1)/2; - float* samples = MEM_mallocN(length * sizeof(float) * 2, "seqwave_samples"); - if(!samples) - return; - if(sound_read_sound_buffer(seq->sound, samples, length, - (seq->startofs + seq->anim_startofs)/FPS, - (seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp)/FPS) != length) + float samplestep; + float startsample, endsample; + float value; + + SoundWaveform* waveform; + + if(!seq->sound->waveform) + sound_read_waveform(seq->sound); + + waveform = seq->sound->waveform; + + startsample = floor((seq->startofs + seq->anim_startofs)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND); + endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND); + samplestep = (endsample-startsample) * stepsize / (x2-x1); + + if(length > floor((waveform->length - startsample) / samplestep)) + length = floor((waveform->length - startsample) / samplestep); + + glBegin(GL_LINE_STRIP); + for(i = 0; i < length; i++) { - MEM_freeN(samples); - return; + pos = startsample + i * samplestep; + + value = waveform->data[pos * 3]; + + for(j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++) + { + if(value > waveform->data[j * 3]) + value = waveform->data[j * 3]; + } + + glVertex2f(x1+i*stepsize, ymid + value * yscale); } - glBegin(GL_LINES); + glEnd(); + + glBegin(GL_LINE_STRIP); for(i = 0; i < length; i++) { - glVertex2f(x1+i*stepsize, ymid + samples[i * 2] * yscale); - glVertex2f(x1+i*stepsize, ymid + samples[i * 2 + 1] * yscale); + pos = startsample + i * samplestep; + + value = waveform->data[pos * 3 + 1]; + + for(j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++) + { + if(value < waveform->data[j * 3 + 1]) + value = waveform->data[j * 3 + 1]; + } + + glVertex2f(x1+i*stepsize, ymid + value * yscale); } glEnd(); - MEM_freeN(samples); } } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index d1df9699fa3..36471c7ffcf 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -223,7 +223,7 @@ static SpaceLink *sequencer_new(const bContext *C) ar->v2d.cur= ar->v2d.tot; ar->v2d.min[0]= 10.0f; - ar->v2d.min[1]= 4.0f; + ar->v2d.min[1]= 0.5f; ar->v2d.max[0]= MAXFRAMEF; ar->v2d.max[1]= MAXSEQ; diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index aa04dc9ac13..359ef8449e9 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -288,6 +288,7 @@ typedef struct SpeedControlVars { #define SEQ_AUDIO_VOLUME_ANIMATED (1<<24) #define SEQ_AUDIO_PITCH_ANIMATED (1<<25) #define SEQ_AUDIO_PAN_ANIMATED (1<<26) +#define SEQ_AUDIO_DRAW_WAVEFORM (1<<27) #define SEQ_INVALID_EFFECT (1<<31) diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index 56ad0e1ff84..d7546e84bbf 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -84,6 +84,11 @@ typedef struct bSound { */ void *cache; + /** + * Waveform display data. + */ + void *waveform; + /** * The audaspace handle that should actually be played back. * Should be cache if cache != NULL; otherwise it's handle diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 6e18f955bf5..38575242fd6 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -976,6 +976,11 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lock", "Lock strip so that it can't be transformed"); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + prop= RNA_def_property(srna, "waveform", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_AUDIO_DRAW_WAVEFORM); + RNA_def_property_ui_text(prop, "Draw Waveform", "Whether to draw the sound's waveform."); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + /* strip positioning */ prop= RNA_def_property(srna, "frame_final_duration", PROP_INT, PROP_TIME); -- cgit v1.2.3 From 8655385c9edb5e61416018406f8a3fe3b8e7d141 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 9 Aug 2011 14:34:42 +0000 Subject: Fix for last commit: MSVC dislikes ;; --- source/blender/blenkernel/intern/sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 888c719a304..80cb2072357 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -630,7 +630,7 @@ void sound_read_waveform(struct bSound* sound) if(info.length > 0) { - SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform");; + SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform"); int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND; waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples"); -- cgit v1.2.3 From 407ec19431971c4e408fa9e6cda63a71a9b1e9b0 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Tue, 9 Aug 2011 16:28:08 +0000 Subject: temporary fix for quat rotations --- source/blender/collada/AnimationExporter.cpp | 2 ++ source/blender/collada/AnimationImporter.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 4beab6f7608..337fd89a7fa 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -208,10 +208,12 @@ void AnimationExporter::exportAnimations(Scene *sce) if ( !strcmp(transformName, "rotation_quaternion") ) { + fprintf(stderr, "quaternion rotations are not supported. rotation curves will not be exported\n"); quatRotation = true; /*const char *axis_names[] = {"", "X", "Y", "Z"}; if (fcu->array_index < 4) axis_name = axis_names[fcu->array_index];*/ + return; } //maybe a list or a vector of float animations else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")|| diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 0fc01e51020..4b467c4a149 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -90,11 +90,12 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) { COLLADAFW::FloatOrDoubleArray& input = curve->getInputValues(); COLLADAFW::FloatOrDoubleArray& output = curve->getOutputValues(); - + if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ) { COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); } + float fps = (float)FPS; size_t dim = curve->getOutDimension(); unsigned int i; @@ -661,6 +662,14 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * } case COLLADAFW::Transformation::MATRIX: + /*{ + COLLADAFW::Matrix* mat = (COLLADAFW::Matrix*)transform; + COLLADABU::Math::Matrix4 mat4 = mat->getMatrix(); + switch (binding->animationClass) { + case COLLADAFW::AnimationList::TRANSFORM: + + } + }*/ case COLLADAFW::Transformation::SKEW: case COLLADAFW::Transformation::LOOKAT: fprintf(stderr, "Animation of MATRIX, SKEW and LOOKAT transformations is not supported yet.\n"); -- cgit v1.2.3 From ef40d8e4f0c69f4a2da24ea6bd8ce560aa3b180a Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 9 Aug 2011 17:37:12 +0000 Subject: Another error in last bigger commit. --- source/blender/blenkernel/intern/sound.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 80cb2072357..1b09db84125 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -24,7 +24,6 @@ #include "DNA_sound_types.h" #include "DNA_speaker_types.h" -#define WITH_AUDASPACE #ifdef WITH_AUDASPACE # include "AUD_C-API.h" #endif -- cgit v1.2.3 From 944a891b48e707eded78c0a59f14715e04302c40 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Tue, 9 Aug 2011 19:30:17 +0000 Subject: sid addressing fix --- source/blender/collada/AnimationExporter.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 337fd89a7fa..0f7edc9ad7d 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -169,7 +169,7 @@ void AnimationExporter::exportAnimations(Scene *sce) fcu = fcu->next; } - for ( int i = 0 ; i < fcu->totvert ; i++){ + for ( int i = 0 ; i < keys ; i++){ for ( int j = 0;j<4;j++) temp_quat[j] = quat[(i*4)+j]; @@ -208,7 +208,7 @@ void AnimationExporter::exportAnimations(Scene *sce) if ( !strcmp(transformName, "rotation_quaternion") ) { - fprintf(stderr, "quaternion rotations are not supported. rotation curves will not be exported\n"); + fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n"); quatRotation = true; /*const char *axis_names[] = {"", "X", "Y", "Z"}; if (fcu->array_index < 4) @@ -261,18 +261,18 @@ void AnimationExporter::exportAnimations(Scene *sce) // create output source std::string output_id ; - /*if(quatRotation) + if(quatRotation) { float * eul = get_eul_source_for_quat(ob); - float * eul_axis = + float * eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values"); for ( int i = 0 ; i< fcu->totvert ; i++) eul_axis[i] = eul[i*3 + fcu->array_index]; output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name); } - else*/ - - output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name); - + else + { + output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name); + } // create interpolations source std::string interpolation_id = create_interpolation_source(fcu, anim_id, axis_name, &has_tangents); @@ -1085,12 +1085,15 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_name = ""; break; } - + if (tm_name.size()) { if (is_rotation) - return tm_name + std::string(axis_name); + return tm_name + std::string(axis_name) + ".ANGLE"; else - return tm_name; + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; } return std::string(""); -- cgit v1.2.3 From fafe6e354044d28be71ab76c2211d785773a9c0f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 10 Aug 2011 00:46:20 +0000 Subject: Gianmichele request: Pose Sliding tools show percentage indicator in header --- source/blender/editors/armature/poseSlide.c | 43 +++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 3d6888d87dc..9b92bccd979 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -93,7 +93,8 @@ /* Temporary data shared between these operators */ typedef struct tPoseSlideOp { Scene *scene; /* current scene */ - ARegion *ar; /* region that we're operating in (needed for */ + ScrArea *sa; /* area that we're operating in (needed for modal()) */ + ARegion *ar; /* region that we're operating in (needed for modal()) */ Object *ob; /* active object that Pose Info comes from */ bArmature *arm; /* armature for pose */ @@ -132,6 +133,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode) pso->scene= CTX_data_scene(C); pso->ob= ED_object_pose_armature(CTX_data_active_object(C)); pso->arm= (pso->ob)? pso->ob->data : NULL; + pso->sa= CTX_wm_area(C); /* only really needed when doing modal() */ pso->ar= CTX_wm_region(C); /* only really needed when doing modal() */ pso->cframe= pso->scene->r.cfra; @@ -519,6 +521,33 @@ static void pose_slide_reset (tPoseSlideOp *pso) /* ------------------------------------ */ +/* draw percentage indicator in header */ +static void pose_slide_draw_status (bContext *C, tPoseSlideOp *pso) +{ + char statusStr[32]; + char mode[32]; + + switch (pso->mode) { + case POSESLIDE_PUSH: + strcpy(mode, "Push Pose"); + break; + case POSESLIDE_RELAX: + strcpy(mode, "Relax Pose"); + break; + case POSESLIDE_BREAKDOWN: + strcpy(mode, "Breakdown"); + break; + + default: + // unknown + strcpy(mode, "Sliding-Tool"); + break; + } + + sprintf(statusStr, "%s: %d %%", mode, (int)(pso->percentage*100.0f)); + ED_area_headerprint(pso->sa, statusStr); +} + /* common code for invoke() methods */ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *pso) { @@ -587,6 +616,9 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp * /* set cursor to indicate modal */ WM_cursor_modal(win, BC_EW_SCROLLCURSOR); + /* header print */ + pose_slide_draw_status(C, pso); + /* add a modal handler for this operator */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -601,7 +633,8 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) switch (evt->type) { case LEFTMOUSE: /* confirm */ { - /* return to normal cursor */ + /* return to normal cursor and header status */ + ED_area_headerprint(pso->sa, NULL); WM_cursor_restore(win); /* insert keyframes as required... */ @@ -615,7 +648,8 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) case ESCKEY: /* cancel */ case RIGHTMOUSE: { - /* return to normal cursor */ + /* return to normal cursor and header status */ + ED_area_headerprint(pso->sa, NULL); WM_cursor_restore(win); /* reset transforms back to original state */ @@ -639,6 +673,9 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) pso->percentage= (evt->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx); RNA_float_set(op->ptr, "percentage", pso->percentage); + /* update percentage indicator in header */ + pose_slide_draw_status(C, pso); + /* reset transforms (to avoid accumulation errors) */ pose_slide_reset(pso); -- cgit v1.2.3 From 11d4cfaa715bc1acb194c3b71ffb1635155d39ec Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Wed, 10 Aug 2011 17:51:18 +0000 Subject: Baked Animation re-Import fix --- source/blender/collada/AnimationImporter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 4b467c4a149..6f3406e88f7 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -667,7 +667,7 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * COLLADABU::Math::Matrix4 mat4 = mat->getMatrix(); switch (binding->animationClass) { case COLLADAFW::AnimationList::TRANSFORM: - + } }*/ case COLLADAFW::Transformation::SKEW: @@ -815,9 +815,10 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , //Add the curves of the current animation to the object for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve * fcu = *iter; - if (ob->type == OB_ARMATURE) + if ((ob->type == OB_ARMATURE)){ + if ( !is_matrix) add_bone_fcurve( ob, node , fcu ); - else + } else BLI_addtail(AnimCurves, fcu); } } -- cgit v1.2.3 From 286a6d39c7b9306b49878f07f560c89f25e65a9b Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Wed, 10 Aug 2011 19:43:40 +0000 Subject: import only transform matrix animation method ( in progress ) --- source/blender/collada/AnimationImporter.cpp | 168 ++++++++++++++++++++++++++- source/blender/collada/AnimationImporter.h | 2 + 2 files changed, 168 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 6f3406e88f7..14d081c2c53 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -750,6 +750,165 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list } +void AnimationImporter::apply_matrix_curves_to_bone( Object * ob, std::vector& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node, + COLLADAFW::Transformation * tm , char * joint_path, bool is_joint,const char * bone_name) +{ + std::vector frames; + find_frames(&frames, &animcurves); + + float irest_dae[4][4]; + float rest[4][4], irest[4][4]; + + if (is_joint) { + get_joint_rest_mat(irest_dae, root, node); + invert_m4(irest_dae); + + Bone *bone = get_named_bone((bArmature*)ob->data, bone_name); + if (!bone) { + fprintf(stderr, "cannot find bone \"%s\"\n", bone_name); + return; + } + + unit_m4(rest); + copy_m4_m4(rest, bone->arm_mat); + invert_m4_m4(irest, rest); + } + // new curves to assign matrix transform animation + FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale + unsigned int totcu = 10 ; + const char *tm_str = NULL; + char rna_path[200]; + for (int i = 0; i < totcu; i++) { + + int axis = i; + + if (i < 4) { + tm_str = "rotation_quaternion"; + axis = i; + } + else if (i < 7) { + tm_str = "location"; + axis = i - 4; + } + else { + tm_str = "scale"; + axis = i - 7; + } + + + if (is_joint) + BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str); + else + strcpy(rna_path, tm_str); + newcu[i] = create_fcurve(axis, rna_path); + +#ifdef ARMATURE_TEST + if (is_joint) + job_curves[i] = create_fcurve(axis, tm_str); +#endif + } + +// Object *job = NULL; + +#ifdef ARMATURE_TEST + FCurve *job_curves[10]; + job = get_joint_object(root, node, par_job); +#endif + + if (frames.size() == 0) + return; + +std::sort(frames.begin(), frames.end()); + //if (is_joint) + // armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); + + + std::vector::iterator it; + + // sample values at each frame + for (it = frames.begin(); it != frames.end(); it++) { + float fra = *it; + + float mat[4][4]; + float matfra[4][4]; + + unit_m4(matfra); + + float m[4][4]; + + unit_m4(m); + dae_matrix_to_mat4(tm, m); + + float temp[4][4]; + copy_m4_m4(temp, mat); + + mul_m4_m4m4(mat, m, temp); + + // for joints, we need a special matrix + if (is_joint) { + // special matrix: iR * M * iR_dae * R + // where R, iR are bone rest and inverse rest mats in world space (Blender bones), + // iR_dae is joint inverse rest matrix (DAE) and M is an evaluated joint world-space matrix (DAE) + float temp[4][4], par[4][4]; + + // calc M + calc_joint_parent_mat_rest(par, NULL, root, node); + mul_m4_m4m4(temp, matfra, par); + + // evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra); + + // calc special matrix + mul_serie_m4(mat, irest, temp, irest_dae, rest, NULL, NULL, NULL, NULL); + } + else { + copy_m4_m4(mat, matfra); + } + + float rot[4], loc[3], scale[3]; + + mat4_to_quat(rot, mat); + copy_v3_v3(loc, mat[3]); + mat4_to_size(scale, mat); + + // add keys + for (int i = 0; i < totcu; i++) { + if (i < 4) + add_bezt(newcu[i], fra, rot[i]); + else if (i < 7) + add_bezt(newcu[i], fra, loc[i - 4]); + else + add_bezt(newcu[i], fra, scale[i - 7]); + } + } + verify_adt_action((ID*)&ob->id, 1); + + ListBase *curves = &ob->adt->action->curves; + + // add curves + for (int i= 0; i < totcu; i++) { + if (is_joint) + add_bone_fcurve(ob, node, newcu[i]); + else + BLI_addtail(curves, newcu[i]); + +#ifdef ARMATURE_TEST + if (is_joint) + BLI_addtail(&job->adt->action->curves, job_curves[i]); +#endif + } + + if (is_joint) { + bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + chan->rotmode = ROT_MODE_QUAT; + } + else { + ob->rotmode = ROT_MODE_QUAT; + } + + return; + +} + void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , std::map& root_map, std::map& object_map, @@ -816,8 +975,13 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve * fcu = *iter; if ((ob->type == OB_ARMATURE)){ - if ( !is_matrix) - add_bone_fcurve( ob, node , fcu ); + if ( is_matrix){ + float irest_dae[4][4]; + get_joint_rest_mat(irest_dae, root, node); + apply_matrix_curves_to_bone(ob, animcurves, root , node, transform ,joint_path , true , bone_name ); + } + else + add_bone_fcurve( ob, node , fcu ); } else BLI_addtail(AnimCurves, fcu); } diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index ea7de961382..944e3ba5be5 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -152,6 +152,8 @@ public: AnimMix* get_animation_type( const COLLADAFW::Node * node , std::map FW_object_map ) ; + void apply_matrix_curves_to_bone( Object * ob, std::vector& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node, + COLLADAFW::Transformation * tm , char * joint_path, bool is_joint,const char * bone_name); void Assign_transform_animations(COLLADAFW::Transformation* transform , const COLLADAFW::AnimationList::AnimationBinding * binding, -- cgit v1.2.3 From 7707140fd1b227378a29361daaa9402a343fcaf1 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 10 Aug 2011 20:05:30 +0000 Subject: BGE Animations: Always update the localtime used for continuous animations. Previously this was only done on a positive or negative pulse, which could lead to some issues with a continuous flipper animation. --- source/gameengine/Converter/BL_ActionActuator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 4e4d838d8ff..cfaede5cd41 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -188,12 +188,12 @@ bool BL_ActionActuator::Update(double curtime, bool frame) bPositiveEvent = m_posevent; RemoveAllEvents(); } + + if (use_continue && m_flag & ACT_FLAG_ACTIVE) + m_localtime = obj->GetActionFrame(m_layer); if (bPositiveEvent) { - if (use_continue && m_flag & ACT_FLAG_ACTIVE) - start = m_localtime = obj->GetActionFrame(m_layer); - if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, m_layer_weight, m_ipo_flags)) { m_flag |= ACT_FLAG_ACTIVE; -- cgit v1.2.3 From 17e88915fdd7048365df1be48d615d69c0924b4c Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Thu, 11 Aug 2011 03:27:47 +0000 Subject: BGE Animations: Updating BL_ActionActuator.frame to work with the new actuator. --- source/gameengine/Converter/BL_ActionActuator.cpp | 17 ++++++++++++++++- source/gameengine/Converter/BL_ActionActuator.h | 15 ++------------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index cfaede5cd41..ec5ab423f60 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -461,7 +461,7 @@ PyAttributeDef BL_ActionActuator::Attributes[] = { KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action), KX_PYATTRIBUTE_RO_FUNCTION("channelNames", BL_ActionActuator, pyattr_get_channel_names), KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority), - KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ActionActuator, m_localtime, CheckFrame), + KX_PYATTRIBUTE_RW_FUNCTION("frame", BL_ActionActuator, pyattr_get_frame, pyattr_set_frame), KX_PYATTRIBUTE_STRING_RW("propName", 0, 31, false, BL_ActionActuator, m_propname), KX_PYATTRIBUTE_STRING_RW("framePropName", 0, 31, false, BL_ActionActuator, m_framepropname), KX_PYATTRIBUTE_RW_FUNCTION("useContinue", BL_ActionActuator, pyattr_get_use_continue, pyattr_set_use_continue), @@ -542,4 +542,19 @@ int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUT return PY_SET_ATTR_SUCCESS; } +PyObject* BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + BL_ActionActuator* self= static_cast(self_v); + return PyFloat_FromDouble(((KX_GameObject*)self->m_gameobj)->GetActionFrame(self->m_layer)); +} + +int BL_ActionActuator::pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + BL_ActionActuator* self= static_cast(self_v); + + ((KX_GameObject*)self->m_gameobj)->SetActionFrame(self->m_layer, PyFloat_AsDouble(value)); + + return PY_SET_ATTR_SUCCESS; +} + #endif // WITH_PYTHON diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index ad57b675b0b..126f2f29136 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -78,19 +78,8 @@ public: static PyObject* pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static PyObject* pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); static int pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); - - /* attribute check */ - static int CheckFrame(void *self, const PyAttributeDef*) - { - BL_ActionActuator* act = reinterpret_cast(self); - - if (act->m_localtime < act->m_startframe) - act->m_localtime = act->m_startframe; - else if (act->m_localtime > act->m_endframe) - act->m_localtime = act->m_endframe; - - return 0; - } + static PyObject* pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef); + static int pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); static int CheckBlendTime(void *self, const PyAttributeDef*) { -- cgit v1.2.3 From 78f89c3bbf6c7faa3b364f75f7fd52d9f62762e6 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Thu, 11 Aug 2011 07:19:37 +0000 Subject: BGE Animations: Animation updates are now handled separately from logic/physics updates. This allows the animations to be updated at the full fps specified by the user. Before, updates were not happening frequently enough. For example, a 30fps animation my only update at 20~30fps, which would cause some noticeable lag. This my not be the best solution since at this point we may be dropping frames (not being in the while(frames) loop), and we're not updating as often as the physics engine might want for bone parented physics objects. --- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 421e642a6df..6fb03d0a573 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -581,7 +581,7 @@ else framestep = (frames*timestep)/m_maxLogicFrame; frames = m_maxLogicFrame; } - + while (frames) { @@ -655,16 +655,6 @@ else scene->LogicUpdateFrame(m_frameTime, true); scene->LogicEndFrame(); - - // Handle animations - double anim_timestep = 1.0/scene->GetAnimationFPS(); - if (m_clockTime - m_previousAnimTime > anim_timestep) - { - m_previousAnimTime = m_clockTime; - m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true); - SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE); - scene->UpdateAnimations(m_frameTime); - } // Actuators can affect the scenegraph m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); @@ -777,7 +767,22 @@ else } } + + // Handle the animations independently of the logic time step + m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true); + SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE); + double anim_timestep = 1.0/KX_GetActiveScene()->GetAnimationFPS(); + if (m_clockTime - m_previousAnimTime > anim_timestep) + { + // Sanity/debug print to make sure we're actually going at the fps we want (should be close to anim_timestep) + // printf("Anim fps: %f\n", 1.0/(m_clockTime - m_previousAnimTime)); + m_previousAnimTime = m_clockTime; + for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit) + { + (*sceneit)->UpdateAnimations(m_frameTime); + } + } m_previousClockTime = m_clockTime; // Start logging time spend outside main loop -- cgit v1.2.3 From fee7337249342c3d5a332358883af9afe961f38d Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Thu, 11 Aug 2011 11:41:24 +0000 Subject: 3D Audio GSoC: Adding a mono flag to mixdown non-mono sounds for 3D audio. * Added mono sound loading. * Bugfix: AUD_COMPARE_SPECS usage was wrong. * Bugfix: JOS resampler = instead of ==. * Bugfix: Change of a sound should apply settings in AUD_SequencerHandle. * Bugfix: Memory leak when canceling open sound operator. --- source/blender/blenkernel/intern/sound.c | 7 ++++++ source/blender/editors/sound/sound_ops.c | 39 +++++++++++++++++++++++++++++- source/blender/makesdna/DNA_sound_types.h | 1 + source/blender/makesrna/intern/rna_sound.c | 9 +++++-- 4 files changed, 53 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 1b09db84125..9c62b92a924 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -349,6 +349,13 @@ void sound_load(struct Main *bmain, struct bSound* sound) break; } #endif + if(sound->flags & SOUND_FLAGS_MONO) + { + void* handle = AUD_monoSound(sound->handle); + AUD_unload(sound->handle); + sound->handle = handle; + } + if(sound->flags & SOUND_FLAGS_CACHING) { sound->cache = AUD_bufferSound(sound->handle); diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 31d22f9dd54..fb4355d0df7 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -79,6 +79,13 @@ /******************** open sound operator ********************/ +static int open_cancel(bContext *UNUSED(C), wmOperator *op) +{ + MEM_freeN(op->customdata); + op->customdata= NULL; + return OPERATOR_CANCELLED; +} + static void open_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; @@ -95,9 +102,10 @@ static int open_exec(bContext *C, wmOperator *op) PropertyPointerRNA *pprop; PointerRNA idptr; AUD_SoundInfo info; + Main *bmain = CTX_data_main(C); RNA_string_get(op->ptr, "filepath", path); - sound = sound_new_file(CTX_data_main(C), path); + sound = sound_new_file(bmain, path); if(!op->customdata) open_init(C, op); @@ -117,6 +125,11 @@ static int open_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + if(RNA_boolean_get(op->ptr, "mono")) { + sound->flags |= SOUND_FLAGS_MONO; + sound_load(bmain, sound); + } + if (RNA_boolean_get(op->ptr, "cache")) { sound_cache(sound); } @@ -172,6 +185,28 @@ void SOUND_OT_open(wmOperatorType *ot) /* api callbacks */ ot->exec= open_exec; ot->invoke= open_invoke; + ot->cancel= open_cancel; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH); + RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); + RNA_def_boolean(ot->srna, "mono", FALSE, "Mono", "Mixdown the sound to mono."); +} + +void SOUND_OT_open_mono(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Open Sound Mono"; + ot->description= "Load a sound file as mono"; + ot->idname= "SOUND_OT_open_mono"; + + /* api callbacks */ + ot->exec= open_exec; + ot->invoke= open_invoke; + ot->cancel= open_cancel; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -179,6 +214,7 @@ void SOUND_OT_open(wmOperatorType *ot) /* properties */ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH); RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory."); + RNA_def_boolean(ot->srna, "mono", TRUE, "Mono", "Mixdown the sound to mono."); } /******************** mixdown operator ********************/ @@ -667,6 +703,7 @@ void SOUND_OT_bake_animation(wmOperatorType *ot) void ED_operatortypes_sound(void) { WM_operatortype_append(SOUND_OT_open); + WM_operatortype_append(SOUND_OT_open_mono); WM_operatortype_append(SOUND_OT_mixdown); WM_operatortype_append(SOUND_OT_pack); WM_operatortype_append(SOUND_OT_unpack); diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index d7546e84bbf..4f727b3586b 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -113,6 +113,7 @@ typedef enum eSound_Type { #define SOUND_FLAGS_3D (1 << 3) /* deprecated! used for sound actuator loading */ #define SOUND_FLAGS_CACHING (1 << 4) +#define SOUND_FLAGS_MONO (1 << 5) /* to DNA_sound_types.h*/ diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index e78bc092040..b224b55c20c 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -41,7 +41,7 @@ #include "BKE_sound.h" #include "BKE_context.h" -static void rna_Sound_filepath_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { sound_load(bmain, (bSound*)ptr->data); } @@ -83,7 +83,7 @@ static void rna_def_sound(BlenderRNA *brna) prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound datablock"); - RNA_def_property_update(prop, 0, "rna_Sound_filepath_update"); + RNA_def_property_update(prop, 0, "rna_Sound_update"); prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "packedfile"); @@ -93,6 +93,11 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_property_boolean_funcs(prop, "rna_Sound_caching_get", "rna_Sound_caching_set"); RNA_def_property_ui_text(prop, "Caching", "The sound file is decoded and loaded into RAM"); RNA_def_property_update(prop, 0, "rna_Sound_caching_update"); + + prop= RNA_def_property(srna, "mono", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_MONO); + RNA_def_property_ui_text(prop, "Mono", "If the file contains multiple audio channels they are mixdown to a signle one."); + RNA_def_property_update(prop, 0, "rna_Sound_update"); } void RNA_def_sound(BlenderRNA *brna) -- cgit v1.2.3 From db72192c22787fdf99bc7b20c6864b37b8e871f4 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 12 Aug 2011 07:20:49 +0000 Subject: Bye bye vile relics of extinct version control systems, Causing a flurry of refresh file prompts post-commit, Confusing local diffs and causing merge conflicts, Stating the obvious; redundant and useless... We shall not miss thou, blasted expand $keywords$ --- source/blender/blenkernel/BKE_action.h | 2 -- source/blender/blenkernel/BKE_anim.h | 2 -- source/blender/blenkernel/BKE_animsys.h | 2 -- source/blender/blenkernel/BKE_armature.h | 2 -- source/blender/blenkernel/BKE_constraint.h | 2 -- source/blender/blenkernel/BKE_nla.h | 2 -- source/blender/blenkernel/intern/action.c | 2 -- source/blender/blenkernel/intern/anim.c | 6 +----- source/blender/blenkernel/intern/anim_sys.c | 2 -- source/blender/blenkernel/intern/armature.c | 2 -- source/blender/blenkernel/intern/constraint.c | 2 -- source/blender/blenkernel/intern/fcurve.c | 2 -- source/blender/blenkernel/intern/fmodifier.c | 2 -- source/blender/blenkernel/intern/gpencil.c | 2 -- source/blender/blenkernel/intern/ipo.c | 5 +---- source/blender/blenkernel/intern/nla.c | 2 -- source/blender/editors/animation/anim_channels_defines.c | 2 -- source/blender/editors/animation/anim_channels_edit.c | 2 -- source/blender/editors/animation/anim_deps.c | 2 -- source/blender/editors/animation/anim_draw.c | 2 -- source/blender/editors/animation/anim_filter.c | 2 -- source/blender/editors/animation/anim_intern.h | 2 -- source/blender/editors/animation/anim_ipo_utils.c | 2 -- source/blender/editors/animation/anim_markers.c | 2 -- source/blender/editors/animation/anim_ops.c | 2 -- source/blender/editors/animation/drivers.c | 2 -- source/blender/editors/animation/fmodifier_ui.c | 2 -- source/blender/editors/animation/keyframes_draw.c | 2 -- source/blender/editors/animation/keyframes_edit.c | 2 -- source/blender/editors/animation/keyframes_general.c | 2 -- source/blender/editors/animation/keyframing.c | 2 -- source/blender/editors/animation/keyingsets.c | 2 -- source/blender/editors/armature/armature_intern.h | 2 -- source/blender/editors/armature/armature_ops.c | 2 -- source/blender/editors/armature/editarmature.c | 2 -- source/blender/editors/armature/poseSlide.c | 2 -- source/blender/editors/armature/poseUtils.c | 2 -- source/blender/editors/armature/poselib.c | 2 -- source/blender/editors/armature/poseobject.c | 2 -- source/blender/editors/gpencil/drawgpencil.c | 2 -- source/blender/editors/gpencil/editaction_gpencil.c | 2 -- source/blender/editors/gpencil/gpencil_buttons.c | 2 -- source/blender/editors/gpencil/gpencil_edit.c | 2 -- source/blender/editors/gpencil/gpencil_intern.h | 2 -- source/blender/editors/gpencil/gpencil_ops.c | 2 -- source/blender/editors/gpencil/gpencil_paint.c | 2 -- source/blender/editors/include/ED_anim_api.h | 2 -- source/blender/editors/include/ED_gpencil.h | 2 -- source/blender/editors/include/ED_keyframes_draw.h | 2 -- source/blender/editors/include/ED_keyframes_edit.h | 2 -- source/blender/editors/include/ED_keyframing.h | 2 -- source/blender/editors/include/ED_markers.h | 2 -- source/blender/editors/space_action/action_draw.c | 2 -- source/blender/editors/space_action/action_edit.c | 2 -- source/blender/editors/space_action/action_intern.h | 2 -- source/blender/editors/space_action/action_ops.c | 2 -- source/blender/editors/space_action/action_select.c | 2 -- source/blender/editors/space_action/space_action.c | 2 -- source/blender/editors/space_graph/graph_draw.c | 2 -- source/blender/editors/space_nla/nla_buttons.c | 2 -- source/blender/editors/space_nla/nla_channels.c | 2 -- source/blender/editors/space_nla/nla_draw.c | 2 -- source/blender/editors/space_nla/nla_edit.c | 2 -- source/blender/editors/space_nla/nla_intern.h | 2 -- source/blender/editors/space_nla/nla_ops.c | 2 -- source/blender/editors/space_nla/nla_select.c | 2 -- source/blender/editors/space_nla/space_nla.c | 2 -- source/blender/editors/space_outliner/outliner_intern.h | 2 -- source/blender/editors/space_outliner/outliner_ops.c | 2 -- source/blender/editors/space_outliner/space_outliner.c | 2 -- source/blender/editors/space_time/space_time.c | 2 -- source/blender/editors/space_time/time_intern.h | 2 -- source/blender/editors/space_time/time_ops.c | 2 -- source/blender/makesdna/DNA_action_types.h | 4 +--- source/blender/makesdna/DNA_anim_types.h | 4 +--- source/blender/makesdna/DNA_armature_types.h | 2 -- source/blender/makesdna/DNA_constraint_types.h | 2 -- source/blender/makesdna/DNA_gpencil_types.h | 2 -- source/blender/makesdna/DNA_ipo_types.h | 2 -- source/blender/makesdna/DNA_nla_types.h | 2 -- source/blender/makesrna/intern/rna_action.c | 2 -- source/blender/makesrna/intern/rna_animation.c | 2 -- source/blender/makesrna/intern/rna_animation_api.c | 2 -- source/blender/makesrna/intern/rna_animviz.c | 2 -- source/blender/makesrna/intern/rna_armature.c | 2 -- source/blender/makesrna/intern/rna_constraint.c | 2 -- source/blender/makesrna/intern/rna_fcurve.c | 2 -- source/blender/makesrna/intern/rna_gpencil.c | 2 -- source/blender/makesrna/intern/rna_nla.c | 2 -- source/blender/makesrna/intern/rna_pose.c | 2 -- 90 files changed, 4 insertions(+), 187 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 7d3de68c005..67efb7752ea 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/BKE_anim.h b/source/blender/blenkernel/BKE_anim.h index 25165eeaee7..44aebdf6205 100644 --- a/source/blender/blenkernel/BKE_anim.h +++ b/source/blender/blenkernel/BKE_anim.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index bf619d76e68..98f9ee14c7e 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index efa87532859..7d60c00156d 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index ddff45c5422..925d1180dbd 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/BKE_nla.h b/source/blender/blenkernel/BKE_nla.h index 49c1f8acd24..773c5ced1cb 100644 --- a/source/blender/blenkernel/BKE_nla.h +++ b/source/blender/blenkernel/BKE_nla.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index a6539f00605..9c2467505cd 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 7ddb078ef8e..b965d14af00 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1,8 +1,4 @@ -/* anim.c - * - * - * $Id$ - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 832d13c9c2f..1c4746b1828 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 0b31e51d62e..62ce184a2d7 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index a321e718bbb..91091d3880f 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 28f17b3cf86..2e532222d5b 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index dcf81c19479..64e51023816 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index db0c9d2735f..c2e94cc97db 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index d41a3a36b2d..0d3f3cc5ae4 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1,7 +1,4 @@ -/* ipo.c - * - * $Id$ - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index dad49646622..463f3bdd5cb 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 20597ca5cdd..806af4c0ef5 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 551bc7e263e..ffa0b2d5ff5 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index 13061113926..fdccf5d4baa 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 2c2a8045b64..70974386917 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index b4d1253c764..0472731dd6d 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h index 7818e8118a3..0ac941e5630 100644 --- a/source/blender/editors/animation/anim_intern.h +++ b/source/blender/editors/animation/anim_intern.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index fc05f46929b..9c43671cdf4 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 732fc0bd267..48ddc8df5ef 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 7a94a21d41e..eaba8343f4d 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 3df65a942da..28195be943c 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 8197d6b25dd..b22a8a1cc37 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 56bc37709bc..c1e81cd0901 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index d5fb8b17440..cc360b34516 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index e2afda04d30..3d3311b35eb 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index fbedb466f7e..4e87409b7fd 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 69e7c4eb73a..69abd1cb5a4 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 9c466a79822..cc654f6d2bc 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index faf06f09141..28454fa0fa9 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index dcbbd424cdf..ec190f05987 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 9b92bccd979..b3ea568abf4 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index e1e346ab920..4b22d76ad0b 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index d09c4f1b5e0..ff6deb6a836 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 20165a67879..48d349ce837 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index a275a5f908a..440d5ee7c4d 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index e70fd2f9abf..937d24eed04 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index d95f64c31e1..192f5c10d07 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 2860d467cef..9dc764b7aac 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index 6ecdc2b054b..c31de8d30a7 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index f2efada8406..e1e4c8d5457 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 2311f4a3a64..ffe2e334772 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index b0df4070d23..b730913a368 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index e5715316a31..07dcc959e32 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index 3c1bb814c82..91723a1a33f 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index d9e7317fc66..5881e8c4bfe 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 0ca3a932266..9dbe86bc5ac 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h index a8e91add348..30a0d47eda2 100644 --- a/source/blender/editors/include/ED_markers.h +++ b/source/blender/editors/include/ED_markers.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index d4d665171bc..f541423e69d 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 5276e62b9eb..b5dfdcdc668 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 512b6e329dd..2a23f105737 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 2ccad308676..491d436741e 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 68dd0a8c256..aa29e54f436 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index a05d1d3df93..8cd6e388b08 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 7e40f2e5159..d65297e068d 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 0f0662d84b1..4392e49e5d7 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 08a4de81013..8775d256b80 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index eb9529b5186..9ce5aafd48a 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index fa24bd2f895..df638107bc3 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index bd76d2484dd..ec2e22e65fa 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 8ed117755c7..821e302c13d 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 5dc937d3ce1..c33316620eb 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index f2e0abe1e60..48859acff6a 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 85bbbd4fffb..e87b68a9ac3 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index b79bb000201..3e83da13e55 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 603be557a3c..49d8b6b5da4 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index a1347f6c306..6ea7a94b288 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_time/time_intern.h b/source/blender/editors/space_time/time_intern.h index 03ba617de14..094b0bc9e86 100644 --- a/source/blender/editors/space_time/time_intern.h +++ b/source/blender/editors/space_time/time_intern.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index e9559426b81..78d903a2997 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index f40d41f59bd..a820e59779f 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -1,6 +1,4 @@ -/* - * $Id$ - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index c0030cd0e5e..e1dfd652900 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -586,7 +584,7 @@ typedef struct NlaStrip { short type; /* type of NLA strip */ void *speaker_handle; /* handle for speaker objects */ - + int flag; /* settings */ int pad2; } NlaStrip; diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index 1675fdd3e90..442fc3ddcce 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index c2c0c6f1611..1be2c811a1b 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 6eb5f64ffc3..b259d592864 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h index 5dba9154a3a..43a4b99bc33 100644 --- a/source/blender/makesdna/DNA_ipo_types.h +++ b/source/blender/makesdna/DNA_ipo_types.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesdna/DNA_nla_types.h b/source/blender/makesdna/DNA_nla_types.h index c64dda2afd0..b92cf5c67e4 100644 --- a/source/blender/makesdna/DNA_nla_types.h +++ b/source/blender/makesdna/DNA_nla_types.h @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 25c08a57889..f24e0a92f78 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index a3b3d0ac8c9..0395a54be8e 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c index 4f1a94d62c5..b3d2c02d0e4 100644 --- a/source/blender/makesrna/intern/rna_animation_api.c +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_animviz.c b/source/blender/makesrna/intern/rna_animviz.c index 5e8c5692abe..e65b137e846 100644 --- a/source/blender/makesrna/intern/rna_animviz.c +++ b/source/blender/makesrna/intern/rna_animviz.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 19a6b482621..e2399b5b57c 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 2887232b659..22d9a19f933 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index 6bb1416e7fc..e922a007249 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 423b4e4f76b..9811d7bd797 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 5756044d12b..ef4adde6fb4 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 635fc967a5a..0dd8218d1b9 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or -- cgit v1.2.3 From ebbd232555d9671161539a6d758bc789546d5ffb Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 12 Aug 2011 07:21:44 +0000 Subject: Fixing compiler warning --- source/blender/editors/space_graph/graph_buttons.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index d8fd53b83d8..c713bc54d25 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -257,7 +257,6 @@ static void graphedit_activekey_update_cb(bContext *UNUSED(C), void *fcu_ptr, vo /* update callback for active keyframe properties - handle-editing wrapper */ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr) { - FCurve *fcu = (FCurve *)fcu_ptr; BezTriple *bezt = (BezTriple *)bezt_ptr; /* since editing the handles, make sure they're set to types which are receptive to editing -- cgit v1.2.3 From 059bbee2da03cd88cf8b28803e1917f9f065c1f9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 12 Aug 2011 07:22:29 +0000 Subject: Drat... missed one --- source/blender/editors/space_graph/graph_buttons.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index c713bc54d25..f3a70c496ef 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or -- cgit v1.2.3 From 83f0c6e56991f1312598b013a2972e3dc79d8e09 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Fri, 12 Aug 2011 20:38:29 +0000 Subject: Transform matrix Animation import fix. --- source/blender/collada/AnimationImporter.cpp | 54 +++++++++++++--------------- source/blender/collada/ArmatureImporter.cpp | 3 +- 2 files changed, 26 insertions(+), 31 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 14d081c2c53..b0e636c2aa6 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -65,7 +65,6 @@ static const char *bc_get_joint_name(T *node) FCurve *AnimationImporter::create_fcurve(int array_index, const char *rna_path) { FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve"); - fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED); fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); fcu->array_index = array_index; @@ -801,20 +800,11 @@ void AnimationImporter::apply_matrix_curves_to_bone( Object * ob, std::vectortotvert = frames.size(); } // Object *job = NULL; -#ifdef ARMATURE_TEST - FCurve *job_curves[10]; - job = get_joint_object(root, node, par_job); -#endif - if (frames.size() == 0) return; @@ -833,17 +823,11 @@ std::sort(frames.begin(), frames.end()); float matfra[4][4]; unit_m4(matfra); + + // calc object-space mat + evaluate_transform_at_frame(matfra, node, fra); - float m[4][4]; - - unit_m4(m); - dae_matrix_to_mat4(tm, m); - - float temp[4][4]; - copy_m4_m4(temp, mat); - mul_m4_m4m4(mat, m, temp); - // for joints, we need a special matrix if (is_joint) { // special matrix: iR * M * iR_dae * R @@ -865,8 +849,12 @@ std::sort(frames.begin(), frames.end()); } float rot[4], loc[3], scale[3]; - + mat4_to_quat(rot, mat); + for ( int i = 0 ; i < 4 ; i ++ ) + { + rot[i] = rot[i] * (180 / M_PI); + } copy_v3_v3(loc, mat[3]); mat4_to_size(scale, mat); @@ -979,6 +967,7 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , float irest_dae[4][4]; get_joint_rest_mat(irest_dae, root, node); apply_matrix_curves_to_bone(ob, animcurves, root , node, transform ,joint_path , true , bone_name ); + break; } else add_bone_fcurve( ob, node , fcu ); @@ -990,8 +979,8 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , if (is_rotation || is_matrix) { if (is_joint) { - bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); - chan->rotmode = ROT_MODE_EUL; + /*bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + chan->rotmode = ROT_MODE_Quat;*/ } else { @@ -1534,10 +1523,12 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW:: float m[4][4]; unit_m4(m); + if ( type != COLLADAFW::Transformation::MATRIX ) + continue; std::string nodename = node->getName().size() ? node->getName() : node->getOriginalId(); if (!evaluate_animation(tm, m, fra, nodename.c_str())) { - switch (type) { + /*switch (type) { case COLLADAFW::Transformation::ROTATE: dae_rotate_to_mat4(tm, m); break; @@ -1552,7 +1543,9 @@ void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW:: break; default: fprintf(stderr, "unsupported transformation type %d\n", type); - } + }*/ + dae_matrix_to_mat4(tm, m); + } float temp[4][4]; @@ -1588,9 +1581,9 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float bool is_scale = (type == COLLADAFW::Transformation::SCALE); bool is_translate = (type == COLLADAFW::Transformation::TRANSLATE); - if (type == COLLADAFW::Transformation::SCALE) + if (is_scale) dae_scale_to_v3(tm, vec); - else if (type == COLLADAFW::Transformation::TRANSLATE) + else if (is_translate) dae_translate_to_v3(tm, vec); for (unsigned int j = 0; j < bindings.getCount(); j++) { @@ -1618,7 +1611,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float if (animclass == COLLADAFW::AnimationList::UNKNOWN_CLASS) { fprintf(stderr, "%s: UNKNOWN animation class\n", path); - continue; + //continue; } if (type == COLLADAFW::Transformation::ROTATE) { @@ -1858,11 +1851,12 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv void AnimationImporter::add_bezt(FCurve *fcu, float fra, float value) { + //float fps = (float)FPS; BezTriple bez; memset(&bez, 0, sizeof(BezTriple)); - bez.vec[1][0] = fra; + bez.vec[1][0] = fra ; bez.vec[1][1] = value; - bez.ipo = U.ipo_new; /* use default interpolation mode here... */ + bez.ipo = BEZT_IPO_LIN ;/* use default interpolation mode here... */ bez.f1 = bez.f2 = bez.f3 = SELECT; bez.h1 = bez.h2 = HD_AUTO; insert_bezt_fcurve(fcu, &bez, 0); diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 9489ddd1525..7a3c6a0644f 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -276,7 +276,8 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: etit = uid_tags_map.find(node->getUniqueId().toAscii()); if(etit != uid_tags_map.end()) et = etit->second; - + else return; + float x,y,z; et->setData("tip_x",&x); et->setData("tip_y",&y); -- cgit v1.2.3 From c5ef9b62c1f7f407c42bb48fe3362fa6cf3cf101 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Fri, 12 Aug 2011 20:53:29 +0000 Subject: BGE Animations: Adding an option to let users choose whether or not to lock animation updates to the framerate. If this option is enabled, animations are only updated at the same speed as the animation framerate. This can give a significant speed up in performance, but at the cost of smoothness in animations. I'm defaulting this behavior to off for now, which is the behavior seen in trunk. --- source/blender/makesdna/DNA_scene_types.h | 2 + source/blender/makesrna/intern/rna_scene.c | 4 ++ .../BlenderRoutines/BL_KetsjiEmbedStart.cpp | 2 + .../GamePlayer/ghost/GPG_Application.cpp | 2 + source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 45 ++++++++++++++++------ source/gameengine/Ketsji/KX_KetsjiEngine.h | 12 ++++++ 6 files changed, 55 insertions(+), 12 deletions(-) (limited to 'source') diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 542aea00b00..be2a78ac774 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -479,6 +479,7 @@ typedef struct GameData { #define WOPHY_BULLET 5 /* GameData.flag */ +#define GAME_RESTRICT_ANIM_UPDATES (1 << 0) #define GAME_ENABLE_ALL_FRAMES (1 << 1) #define GAME_SHOW_DEBUG_PROPS (1 << 2) #define GAME_SHOW_FRAMERATE (1 << 3) @@ -494,6 +495,7 @@ typedef struct GameData { #define GAME_ENABLE_ANIMATION_RECORD (1 << 13) #define GAME_SHOW_MOUSE (1 << 14) #define GAME_GLSL_NO_COLOR_MANAGEMENT (1 << 15) +/* Note: GameData.flag is a short (max 16 flags). To add more flags, GameData.flag needs to be an int */ /* GameData.matmode */ #define GAME_MAT_TEXFACE 0 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 7313a39e5ec..7f8aeb65209 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1919,6 +1919,10 @@ static void rna_def_scene_game_data(BlenderRNA *brna) prop= RNA_def_property(srna, "use_auto_start", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_funcs(prop, "rna_GameSettings_auto_start_get", "rna_GameSettings_auto_start_set"); RNA_def_property_ui_text(prop, "Auto Start", "Automatically start game at load time"); + + prop= RNA_def_property(srna, "restrict_animation_updates", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", GAME_RESTRICT_ANIM_UPDATES); + RNA_def_property_ui_text(prop, "Restrict Animation Updates", "Restrict the number of animation updates to the animation FPS. This is better for performance, but can cause issues with smooth playback."); /* materials */ prop= RNA_def_property(srna, "material_mode", PROP_ENUM, PROP_NONE); diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 3c766affe56..4850c1459f4 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -187,6 +187,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c #endif bool novertexarrays = (SYS_GetCommandLineInt(syshandle, "novertexarrays", 0) != 0); bool mouse_state = startscene->gm.flag & GAME_SHOW_MOUSE; + bool restrictAnimFPS = startscene->gm.flag & GAME_RESTRICT_ANIM_UPDATES; if(animation_record) usefixed= true; /* override since you's always want fixed time for sim recording */ @@ -237,6 +238,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c ketsjiengine->SetNetworkDevice(networkdevice); ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); + ketsjiengine->SetRestrictAnimationFPS(restrictAnimFPS); #ifdef WITH_PYTHON CValue::SetDeprecationWarnings(nodepwarnings); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index f2b322084ed..1c6d3efc318 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -545,6 +545,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0); bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", gm->flag & GAME_DISPLAY_LISTS) != 0); bool nodepwarnings = (SYS_GetCommandLineInt(syshandle, "ignore_deprecation_warnings", 1) != 0); + bool restrictAnimFPS = gm->flag & GAME_RESTRICT_ANIM_UPDATES; if(GLEW_ARB_multitexture && GLEW_VERSION_1_1) m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0); @@ -627,6 +628,7 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) m_ketsjiengine->SetUseFixedTime(fixed_framerate); m_ketsjiengine->SetTimingDisplay(frameRate, profile, properties); + m_ketsjiengine->SetRestrictAnimationFPS(restrictAnimFPS); m_engineInitialized = true; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 6fb03d0a573..0b83e3247ff 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -110,6 +110,7 @@ double KX_KetsjiEngine::m_anim_framerate = 25.0; double KX_KetsjiEngine::m_suspendedtime = 0.0; double KX_KetsjiEngine::m_suspendeddelta = 0.0; double KX_KetsjiEngine::m_average_framerate = 0.0; +bool KX_KetsjiEngine::m_restrict_anim_fps = false; /** @@ -660,7 +661,14 @@ else m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_ACTUATOR_UPDATE); scene->UpdateParents(m_frameTime); - + + if (!GetRestrictAnimationFPS()) + { + m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true); + SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE); + scene->UpdateAnimations(m_frameTime); + } + m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true); SG_SetActiveStage(SG_STAGE_PHYSICS2); scene->GetPhysicsEnvironment()->beginFrame(); @@ -769,21 +777,24 @@ else // Handle the animations independently of the logic time step - m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true); - SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE); - - double anim_timestep = 1.0/KX_GetActiveScene()->GetAnimationFPS(); - if (m_clockTime - m_previousAnimTime > anim_timestep) + if (GetRestrictAnimationFPS()) { - // Sanity/debug print to make sure we're actually going at the fps we want (should be close to anim_timestep) - // printf("Anim fps: %f\n", 1.0/(m_clockTime - m_previousAnimTime)); - m_previousAnimTime = m_clockTime; - for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit) + m_logger->StartLog(tc_animations, m_kxsystem->GetTimeInSeconds(), true); + SG_SetActiveStage(SG_STAGE_ANIMATION_UPDATE); + + double anim_timestep = 1.0/KX_GetActiveScene()->GetAnimationFPS(); + if (m_clockTime - m_previousAnimTime > anim_timestep) { - (*sceneit)->UpdateAnimations(m_frameTime); + // Sanity/debug print to make sure we're actually going at the fps we want (should be close to anim_timestep) + // printf("Anim fps: %f\n", 1.0/(m_clockTime - m_previousAnimTime)); + m_previousAnimTime = m_clockTime; + for (sceneit = m_scenes.begin();sceneit != m_scenes.end(); ++sceneit) + { + (*sceneit)->UpdateAnimations(m_frameTime); + } } + m_previousClockTime = m_clockTime; } - m_previousClockTime = m_clockTime; // Start logging time spend outside main loop m_logger->StartLog(tc_outside, m_kxsystem->GetTimeInSeconds(), true); @@ -1821,6 +1832,16 @@ void KX_KetsjiEngine::SetMaxPhysicsFrame(int frame) m_maxPhysicsFrame = frame; } +bool KX_KetsjiEngine::GetRestrictAnimationFPS() +{ + return m_restrict_anim_fps; +} + +void KX_KetsjiEngine::SetRestrictAnimationFPS(bool bRestrictAnimFPS) +{ + m_restrict_anim_fps = bRestrictAnimFPS; +} + double KX_KetsjiEngine::GetAnimFrameRate() { return m_anim_framerate; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 89419bb7773..95a6b3401a7 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -116,6 +116,8 @@ private: static double m_ticrate; static double m_anim_framerate; /* for animation playback only - ipo and action */ + static bool m_restrict_anim_fps; + static double m_suspendedtime; static double m_suspendeddelta; @@ -322,6 +324,16 @@ public: */ static void SetMaxPhysicsFrame(int frame); + /** + * Gets whether or not to lock animation updates to the animframerate + */ + static bool GetRestrictAnimationFPS(); + + /** + * Sets whether or not to lock animation updates to the animframerate + */ + static void SetRestrictAnimationFPS(bool bRestrictAnimFPS); + /** * Gets the framerate for playing animations. (actions and ipos) */ -- cgit v1.2.3 From c106f7bee96b8b420f0c6a28cd6866305eed39f3 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sat, 13 Aug 2011 16:20:28 +0000 Subject: Light blender profile param sid addressing --- source/blender/collada/LightExporter.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index 3258b63b0c3..31ade5604a7 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -141,18 +141,18 @@ bool LightsExporter::exportBlenderProfile(COLLADASW::Light &cla, Lamp *la) cla.addExtraTechniqueParameter("blender", "type", la->type); cla.addExtraTechniqueParameter("blender", "flag", la->flag); cla.addExtraTechniqueParameter("blender", "mode", la->mode); - cla.addExtraTechniqueParameter("blender", "gamma", la->k); + cla.addExtraTechniqueParameter("blender", "gamma", la->k, "blender_gamma"); cla.addExtraTechniqueParameter("blender", "red", la->r); cla.addExtraTechniqueParameter("blender", "green", la->g); cla.addExtraTechniqueParameter("blender", "blue", la->b); - cla.addExtraTechniqueParameter("blender", "shadow_r", la->shdwr); - cla.addExtraTechniqueParameter("blender", "shadow_g", la->shdwg); - cla.addExtraTechniqueParameter("blender", "shadow_b", la->shdwb); - cla.addExtraTechniqueParameter("blender", "energy", la->energy); - cla.addExtraTechniqueParameter("blender", "dist", la->dist); + cla.addExtraTechniqueParameter("blender", "shadow_r", la->shdwr, "blender_shadow_r"); + cla.addExtraTechniqueParameter("blender", "shadow_g", la->shdwg, "blender_shadow_g"); + cla.addExtraTechniqueParameter("blender", "shadow_b", la->shdwb, "blender_shadow_b"); + cla.addExtraTechniqueParameter("blender", "energy", la->energy, "blender_energy"); + cla.addExtraTechniqueParameter("blender", "dist", la->dist, "blender_dist"); cla.addExtraTechniqueParameter("blender", "spotsize", la->spotsize); cla.addExtraTechniqueParameter("blender", "spotblend", la->spotblend); - cla.addExtraTechniqueParameter("blender", "halo_intensity", la->haint); + cla.addExtraTechniqueParameter("blender", "halo_intensity", la->haint, "blnder_halo_intensity"); cla.addExtraTechniqueParameter("blender", "att1", la->att1); cla.addExtraTechniqueParameter("blender", "att2", la->att2); // \todo figure out how we can have falloff curve supported here -- cgit v1.2.3 From a4b6cfd87229a3d838544f9474e257ab4aecd371 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sat, 13 Aug 2011 16:21:41 +0000 Subject: light parameter export expansion. --- source/blender/collada/AnimationExporter.cpp | 104 +++++++++++++++++---------- source/blender/collada/AnimationExporter.h | 1 + 2 files changed, 69 insertions(+), 36 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 0f7edc9ad7d..ecaa05e3497 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -85,9 +85,8 @@ void AnimationExporter::exportAnimations(Scene *sce) while (fcu) { transformName = extract_transform_name( fcu->rna_path ); - if ((!strcmp(transformName, "color")) || - (!strcmp(transformName, "spot_size"))|| - (!strcmp(transformName, "spot_blend"))) + if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))|| + (!strcmp(transformName, "distance")) ) dae_animation(ob , fcu, transformName, true ); fcu = fcu->next; } @@ -314,7 +313,7 @@ void AnimationExporter::exportAnimations(Scene *sce) { if ( ob->type == OB_LAMP ) target = get_light_id(ob) - + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); + + "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true); if ( ob->type == OB_CAMERA ) target = get_camera_id(ob) @@ -986,6 +985,54 @@ void AnimationExporter::exportAnimations(Scene *sce) return source_id; } + std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) + { + std::string tm_name; + bool is_rotation =false; + // when given rna_path, determine tm_type from it + if (rna_path) { + char *name = extract_transform_name(rna_path); + + if (!strcmp(name, "color")) + tm_type = 1; + else if (!strcmp(name, "spot_size")) + tm_type = 2; + else if (!strcmp(name, "spot_blend")) + tm_type = 3; + else if (!strcmp(name, "distance")) + tm_type = 4; + else + tm_type = -1; + } + + switch (tm_type) { + case 1: + tm_name = "color"; + break; + case 2: + tm_name = "fall_off_angle"; + break; + case 3: + tm_name = "fall_off_exponent"; + break; + case 4: + tm_name = "blender_dist"; + break; + + default: + tm_name = ""; + break; + } + + if (tm_name.size()) { + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; + } + + return std::string(""); + } // for rotation, axis name is always appended and the value of append_axis is ignored std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) { @@ -1003,30 +1050,24 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_type = 2; else if (!strcmp(name, "location")) tm_type = 3; - else if (!strcmp(name, "color")) - tm_type = 4; - else if (!strcmp(name, "spot_size")) - tm_type = 5; - else if (!strcmp(name, "spot_blend")) - tm_type = 6; else if (!strcmp(name, "lens")) - tm_type = 7; + tm_type = 4; else if (!strcmp(name, "ortho_scale")) - tm_type = 8; + tm_type = 5; else if (!strcmp(name, "clip_end")) - tm_type = 9; + tm_type = 6; else if (!strcmp(name, "clip_start")) - tm_type = 10; + tm_type = 7; else if (!strcmp(name, "specular_hardness")) - tm_type = 11; + tm_type = 8; else if (!strcmp(name, "specular_color")) - tm_type = 12; + tm_type = 9; else if (!strcmp(name, "diffuse_color")) - tm_type = 13; + tm_type = 10; else if (!strcmp(name, "alpha")) - tm_type = 14; + tm_type = 11; else if (!strcmp(name, "ior")) - tm_type = 15; + tm_type = 12; else tm_type = -1; @@ -1045,39 +1086,30 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_name = "location"; break; case 4: - tm_name = "color"; - break; - case 5: - tm_name = "fall_off_angle"; - break; - case 6: - tm_name = "fall_off_exponent"; - break; - case 7: tm_name = "xfov"; break; - case 8: + case 5: tm_name = "xmag"; break; - case 9: + case 6: tm_name = "zfar"; break; - case 10: + case 7: tm_name = "znear"; break; - case 11: + case 8: tm_name = "shininess"; break; - case 12: + case 9: tm_name = "specular"; break; - case 13: + case 10: tm_name = "diffuse"; break; - case 14: + case 11: tm_name = "transparency"; break; - case 15: + case 12: tm_name = "index_of_refraction"; break; diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index d4559782ff4..a4268122333 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -142,6 +142,7 @@ protected: std::string fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name); // for rotation, axis name is always appended and the value of append_axis is ignored std::string get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); + std::string get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); void find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name); void find_frames(Object *ob, std::vector &fra); -- cgit v1.2.3 From c86bcd50658f03215d93fe059d11b61401847b79 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sat, 13 Aug 2011 16:22:14 +0000 Subject: transform matrix animation import fix. --- source/blender/collada/AnimationImporter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index b0e636c2aa6..d8e6ae24b3b 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -976,11 +976,11 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , } } } - if (is_rotation || is_matrix) { + if (is_rotation) { if (is_joint) { - /*bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); - chan->rotmode = ROT_MODE_Quat;*/ + bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + chan->rotmode = ROT_MODE_EUL; } else { -- cgit v1.2.3 From 656adc53b42194e0b9da8d7ead307a023b8753e9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 14 Aug 2011 04:55:52 +0000 Subject: Show dopesheet summary for new DopeSheet editors While I originally made these so that they wouldn't be on by default due to concerns over the filtering used for these leading to reduced framerates/interactive speed, I'd since found while doing some profiling that this isn't the case. Rather, decreased framerates were more likely to stem from trying to perform the checks necessary for the long-keyframe drawing when many "child" channels are involved (affecting other channels too). So, since these are generally useful, they are now enabled by default :) --- source/blender/editors/space_action/space_action.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source') diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 8cd6e388b08..4baaa469127 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -76,6 +76,8 @@ static SpaceLink *action_new(const bContext *C) saction->autosnap = SACTSNAP_FRAME; saction->mode= SACTCONT_DOPESHEET; + saction->ads.filterflag |= ADS_FILTER_SUMMARY; + /* header */ ar= MEM_callocN(sizeof(ARegion), "header for action"); -- cgit v1.2.3 From b8473d70e2da98c90c0c085ba3e38d4e327c0d9b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 14 Aug 2011 10:19:21 +0000 Subject: Bugfix [#28244] Setting vector handle in fcurve can fail So apparently this was a regression from 2.4x, since vector handles were one of the handle types which could be set independently for each handle (vs both needing to be the same, for example, Auto Handles) --- source/blender/editors/animation/keyframes_edit.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index cc360b34516..2305848e7b3 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -792,12 +792,8 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b /* Sets the selected bezier handles to type 'vector' */ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1= HD_VECT; - if (bezt->f3 & SELECT) bezt->h2= HD_VECT; - - ENSURE_HANDLES_MATCH(bezt); - } + if (bezt->f1 & SELECT) bezt->h1= HD_VECT; + if (bezt->f3 & SELECT) bezt->h2= HD_VECT; return 0; } -- cgit v1.2.3 From fc0a5ede01d9db29471c495b18f47c0e8864e518 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 14 Aug 2011 16:13:35 +0000 Subject: Cleanup --- source/blender/collada/AnimationExporter.cpp | 26 +------------------------- source/blender/collada/AnimationExporter.h | 2 -- 2 files changed, 1 insertion(+), 27 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index ecaa05e3497..a777f4ae984 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -1016,7 +1016,7 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_name = "fall_off_exponent"; break; case 4: - tm_name = "blender_dist"; + tm_name = "blender/blender_dist"; break; default: @@ -1137,30 +1137,6 @@ void AnimationExporter::exportAnimations(Scene *sce) return dot ? (dot + 1) : rna_path; } - void AnimationExporter::find_all_frames(Object *ob, std::vector &fra) - { - FCurve *fcu= (FCurve*)ob->adt->action->curves.first; - std::vector keys; - for (unsigned int i = 0; i < fcu->totvert; i++) { - float f = fcu->bezt[i].vec[1][0]; // - if (std::find(keys.begin(), keys.end(), f) == keys.end()) - keys.push_back(f); - } - - std::sort(keys.begin(), keys.end()); - float first, last; - std::vector::reference ref = keys.front(); - first = ref; - ref = keys.back(); - last = ref; - for (float i = first ; i != last ; i+=1.0f ) - { - fra.push_back(i); - } - return; - - } - void AnimationExporter::find_frames(Object *ob, std::vector &fra) { FCurve *fcu= (FCurve*)ob->adt->action->curves.first; diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index a4268122333..6cf3207b8a0 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -147,8 +147,6 @@ protected: void find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name); void find_frames(Object *ob, std::vector &fra); - void find_all_frames(Object *ob, std::vector &fra); - void find_rotation_frames(Object *ob, std::vector &fra, const char *prefix, int rotmode); // enable fcurves driving a specific bone, disable all the rest -- cgit v1.2.3 From e93444f8167a4df8f4bfe81ed62baf5d31807ab5 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 14 Aug 2011 16:14:32 +0000 Subject: Matrix transformation animation import for other objects under the new system. --- source/blender/collada/AnimationImporter.cpp | 67 ++++++++++++++++------------ source/blender/collada/AnimationImporter.h | 6 ++- 2 files changed, 42 insertions(+), 31 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index d8e6ae24b3b..0549f133031 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -90,7 +90,8 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) COLLADAFW::FloatOrDoubleArray& input = curve->getInputValues(); COLLADAFW::FloatOrDoubleArray& output = curve->getOutputValues(); - if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ) { + if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER || + curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP ) { COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); } @@ -126,7 +127,8 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) bez.vec[1][1] = bc_get_float_value(output, j * dim + i); - if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ) + if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER || + curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP) { COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); @@ -138,7 +140,10 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) // outtangent bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps; bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1); - bez.ipo = BEZT_IPO_BEZ; + if(curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) + bez.ipo = BEZT_IPO_BEZ; + else + bez.ipo = BEZT_IPO_CONST; //bez.h1 = bez.h2 = HD_AUTO; } else @@ -276,11 +281,12 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim) switch (interp) { case COLLADAFW::AnimationCurve::INTERPOLATION_LINEAR: case COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER: + case COLLADAFW::AnimationCurve::INTERPOLATION_STEP: animation_to_fcurves(curve); break; default: // TODO there're also CARDINAL, HERMITE, BSPLINE and STEP types - fprintf(stderr, "CARDINAL, HERMITE, BSPLINE and STEP anim interpolation types not supported yet.\n"); + fprintf(stderr, "CARDINAL, HERMITE and BSPLINE anim interpolation types not supported yet.\n"); break; } } @@ -749,9 +755,15 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list } -void AnimationImporter::apply_matrix_curves_to_bone( Object * ob, std::vector& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node, - COLLADAFW::Transformation * tm , char * joint_path, bool is_joint,const char * bone_name) +void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node, + COLLADAFW::Transformation * tm ) { + 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 ) + armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); + std::vector frames; find_frames(&frames, &animcurves); @@ -878,11 +890,6 @@ std::sort(frames.begin(), frames.end()); add_bone_fcurve(ob, node, newcu[i]); else BLI_addtail(curves, newcu[i]); - -#ifdef ARMATURE_TEST - if (is_joint) - BLI_addtail(&job->adt->action->curves, job_curves[i]); -#endif } if (is_joint) { @@ -955,25 +962,22 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { animcurves = curve_map[bindings[j].animation]; - //calculate rnapaths and array index of fcurves according to transformation and animation class - Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path ); - - std::vector::iterator iter; - //Add the curves of the current animation to the object - for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { - FCurve * fcu = *iter; - if ((ob->type == OB_ARMATURE)){ - if ( is_matrix){ - float irest_dae[4][4]; - get_joint_rest_mat(irest_dae, root, node); - apply_matrix_curves_to_bone(ob, animcurves, root , node, transform ,joint_path , true , bone_name ); - break; - } - else + if ( is_matrix ) + apply_matrix_curves(ob, animcurves, root , node, transform ); + else { + //calculate rnapaths and array index of fcurves according to transformation and animation class + Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path ); + + std::vector::iterator iter; + //Add the curves of the current animation to the object + for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { + FCurve * fcu = *iter; + if ((ob->type == OB_ARMATURE)) add_bone_fcurve( ob, node , fcu ); - } else - BLI_addtail(AnimCurves, fcu); - } + else + BLI_addtail(AnimCurves, fcu); + } + } } } if (is_rotation) { @@ -1862,3 +1866,8 @@ void AnimationImporter::add_bezt(FCurve *fcu, float fra, float value) insert_bezt_fcurve(fcu, &bez, 0); calchandles_fcurve(fcu); } + +void AnimationImporter::extra_data_importer(std::string elementName ) +{ + +} diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 944e3ba5be5..9aec7df1099 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -152,8 +152,8 @@ public: AnimMix* get_animation_type( const COLLADAFW::Node * node , std::map FW_object_map ) ; - void apply_matrix_curves_to_bone( Object * ob, std::vector& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node, - COLLADAFW::Transformation * tm , char * joint_path, bool is_joint,const char * bone_name); + void apply_matrix_curves( Object * ob, std::vector& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node, + COLLADAFW::Transformation * tm ); void Assign_transform_animations(COLLADAFW::Transformation* transform , const COLLADAFW::AnimationList::AnimationBinding * binding, @@ -203,6 +203,8 @@ public: void add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurve *fcu); void add_bezt(FCurve *fcu, float fra, float value); + + void extra_data_importer(std::string elementName); }; #endif -- cgit v1.2.3 From cc3b9aa467bd9a43a28eccf990e00fddd5ed9564 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 14 Aug 2011 16:15:41 +0000 Subject: blender extra parameter animation import ( on hold ); --- source/blender/collada/DocumentImporter.cpp | 2 +- source/blender/collada/ExtraHandler.cpp | 4 +++- source/blender/collada/ExtraHandler.h | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 27442420f90..a4d1c1b451f 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -116,7 +116,7 @@ bool DocumentImporter::import() /** TODO Add error handler (implement COLLADASaxFWL::IErrorHandler */ COLLADASaxFWL::Loader loader; COLLADAFW::Root root(&loader, this); - ExtraHandler *ehandler = new ExtraHandler(this); + ExtraHandler *ehandler = new ExtraHandler(this, &(this->anim_importer)); loader.registerExtraDataCallbackHandler(ehandler); diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp index 9999a61a470..a60ef8b2ea5 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -31,9 +31,10 @@ #include "ExtraHandler.h" -ExtraHandler::ExtraHandler(DocumentImporter *dimp) : currentExtraTags(0) +ExtraHandler::ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp) : currentExtraTags(0) { this->dimp = dimp; + this->aimp = aimp; } ExtraHandler::~ExtraHandler() {} @@ -42,6 +43,7 @@ bool ExtraHandler::elementBegin( const char* elementName, const char** attribute { // \todo attribute handling for profile tags currentElement = std::string(elementName); + //addToSidTree(attributes[0], attributes[1]); return true; } diff --git a/source/blender/collada/ExtraHandler.h b/source/blender/collada/ExtraHandler.h index de3b063290d..7296aaf1eb4 100644 --- a/source/blender/collada/ExtraHandler.h +++ b/source/blender/collada/ExtraHandler.h @@ -32,8 +32,10 @@ #include // sort() #include "COLLADASaxFWLIExtraDataCallbackHandler.h" +#include "COLLADASaxFWLFilePartLoader.h" #include "DocumentImporter.h" +#include "AnimationImporter.h" /** \brief Handler class for data, through which different * profiles can be handled @@ -42,7 +44,7 @@ class ExtraHandler : public COLLADASaxFWL::IExtraDataCallbackHandler { public: /** Constructor. */ - ExtraHandler(DocumentImporter *dimp); + ExtraHandler(DocumentImporter *dimp, AnimationImporter *aimp); /** Destructor. */ virtual ~ExtraHandler(); @@ -69,6 +71,7 @@ private: /** Handle to DocumentImporter for interface to extra element data saving. */ DocumentImporter* dimp; + AnimationImporter* aimp; /** Holds Id of element for which XML elements are handled. */ COLLADAFW::UniqueId currentUid; ExtraTags* currentExtraTags; -- cgit v1.2.3 From 674d1b8d68330113967fd0bb6b34edaf9c619cae Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 15 Aug 2011 10:37:26 +0000 Subject: Select by Keying Set... * Split off code to refresh relative/builtin KeyingSets for the current context before they get used to a separate function. * Hooked this up to a new PyAPI/RNA function: KeyingSet.refresh(). Call this before checking the paths that a Keying Set has, especially if it is not "absolute" * Added option for "Select Grouped" operator (for Objects), which will select all objects affected by the active Keying Set. This is probably more useful for absolute KeyingSets, where changing the selection is less likely to affect the result. - The equivalent for bones is currently still in development, but is likely to be more useful for animators, where rigs are the primary animation entities they deal with --- source/blender/editors/animation/keyingsets.c | 69 +++++++++++++++------- source/blender/editors/include/ED_keyframing.h | 3 + source/blender/editors/object/object_select.c | 40 +++++++++++++ source/blender/makesrna/intern/rna_animation_api.c | 33 ++++++++++- 4 files changed, 120 insertions(+), 25 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 69abd1cb5a4..dcd1c3abbde 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -875,33 +875,19 @@ void ANIM_relative_keyingset_add_source (ListBase *dsources, ID *id, StructRNA * /* KeyingSet Operations (Insert/Delete Keyframes) ------------ */ -/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified - * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets. - * Returns the number of channels that keyframes were added to +/* Given a KeyingSet and context info, validate Keying Set's paths. + * This is only really necessary with relative/built-in KeyingSets + * where their list of paths is dynamically generated based on the + * current context info. + * + * Returns 0 if succeeded, otherwise an error code: eModifyKey_Returns */ -int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) +short ANIM_validate_keyingset (bContext *C, ListBase *dsources, KeyingSet *ks) { - Scene *scene= CTX_data_scene(C); - ReportList *reports = CTX_wm_reports(C); - KS_Path *ksp; - int kflag=0, success= 0; - char *groupname= NULL; - - /* sanity checks */ + /* sanity check */ if (ks == NULL) return 0; - /* get flags to use */ - if (mode == MODIFYKEY_MODE_INSERT) { - /* use KeyingSet's flags as base */ - kflag= ks->keyingflag; - - /* suppliment with info from the context */ - kflag |= ANIM_get_keyframing_flags(scene, 1); - } - else if (mode == MODIFYKEY_MODE_DELETE) - kflag= 0; - /* if relative Keying Sets, poll and build up the paths */ if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo); @@ -936,6 +922,45 @@ int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingS } } + /* succeeded; return 0 to tag error free */ + return 0; +} + +/* Given a KeyingSet and context info (if required), modify keyframes for the channels specified + * by the KeyingSet. This takes into account many of the different combinations of using KeyingSets. + * Returns the number of channels that keyframes were added to + */ +int ANIM_apply_keyingset (bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) +{ + Scene *scene= CTX_data_scene(C); + ReportList *reports = CTX_wm_reports(C); + KS_Path *ksp; + int kflag=0, success= 0; + char *groupname= NULL; + + /* sanity checks */ + if (ks == NULL) + return 0; + + /* get flags to use */ + if (mode == MODIFYKEY_MODE_INSERT) { + /* use KeyingSet's flags as base */ + kflag= ks->keyingflag; + + /* suppliment with info from the context */ + kflag |= ANIM_get_keyframing_flags(scene, 1); + } + else if (mode == MODIFYKEY_MODE_DELETE) + kflag= 0; + + /* if relative Keying Sets, poll and build up the paths */ + success = ANIM_validate_keyingset(C, dsources, ks); + + if (success != 0) { + /* return error code if failed */ + return success; + } + /* apply the paths as specified in the KeyingSet now */ for (ksp= ks->paths.first; ksp; ksp= ksp->next) { int arraylen, i; diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 9dbe86bc5ac..cda3c4f3e71 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -176,6 +176,9 @@ typedef enum eModifyKey_Returns { MODIFYKEY_MISSING_TYPEINFO = -2, } eModifyKey_Returns; +/* poll the current KeyingSet, updating it's set of paths (if "builtin"/"relative") for context changes */ +short ANIM_validate_keyingset(struct bContext *C, ListBase *dsources, struct KeyingSet *ks); + /* use the specified KeyingSet to add/remove various Keyframes on the specified frame */ int ANIM_apply_keyingset(struct bContext *C, ListBase *dsources, struct bAction *act, struct KeyingSet *ks, short mode, float cfra); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index a3bd399a60c..b3c4ffc0ac9 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -37,6 +37,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_group_types.h" #include "DNA_material_types.h" #include "DNA_modifier_types.h" @@ -65,6 +66,7 @@ #include "ED_object.h" #include "ED_screen.h" +#include "ED_keyframing.h" #include "UI_interface.h" #include "UI_resources.h" @@ -363,6 +365,7 @@ static EnumPropertyItem prop_select_grouped_types[] = { {9, "PASS", 0, "Pass", "Render pass Index"}, {10, "COLOR", 0, "Color", "Object Color"}, {11, "PROPERTIES", 0, "Properties", "Game Properties"}, + {12, "KEYINGSET", 0, "Keying Set", "Objects included in active Keying Set"}, {0, NULL, 0, NULL, NULL} }; @@ -574,6 +577,42 @@ static short select_grouped_gameprops(bContext *C, Object *ob) return changed; } +static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob)) +{ + KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); + short changed = 0; + + /* firstly, validate KeyingSet */ + if ((ks == NULL) || (ANIM_validate_keyingset(C, NULL, ks) != 0)) + return 0; + + /* select each object that Keying Set refers to */ + // TODO: perhaps to be more in line with the rest of these, we should only take objects + // if the passed in object is included in this too + CTX_DATA_BEGIN(C, Base*, base, selectable_bases) + { + /* only check for this object if it isn't selected already, to limit time wasted */ + if ((base->flag & SELECT) == 0) { + KS_Path *ksp; + + /* this is the slow way... we could end up with > 500 items here, + * with none matching, but end up doing this on 1000 objects... + */ + for (ksp = ks->paths.first; ksp; ksp = ksp->next) { + /* if id matches, select then stop looping (match found) */ + if (ksp->id == base->object) { + ED_base_object_select(base, BA_SELECT); + changed = 1; + break; + } + } + } + } + CTX_DATA_END; + + return changed; +} + static int object_select_grouped_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); @@ -608,6 +647,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) else if(nr==9) changed |= select_grouped_index_object(C, ob); else if(nr==10) changed |= select_grouped_color(C, ob); else if(nr==11) changed |= select_grouped_gameprops(C, ob); + else if(nr==12) changed |= select_grouped_keyingset(C, ob); if (changed) { WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c index b3d2c02d0e4..714a74ec424 100644 --- a/source/blender/makesrna/intern/rna_animation_api.c +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -39,16 +39,43 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" + #ifdef RNA_RUNTIME -#include "BKE_animsys.h" +#include "BKE_context.h" +#include "BKE_report.h" + +#include "ED_keyframing.h" + +static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList *reports) +{ + // TODO: enable access to providing a list of overrides (dsources)? + int success = ANIM_validate_keyingset(C, NULL, ks); + + if (success != 0) { + switch (success) { + case MODIFYKEY_INVALID_CONTEXT: + BKE_report(reports, RPT_ERROR, "Invalid context for Keying Set"); + break; + + case MODIFYKEY_MISSING_TYPEINFO: + BKE_report(reports, RPT_ERROR, "Incomplete built-in Keying Set. Appears to be missing type info"); + break; + } + } +} #else void RNA_api_keyingset(StructRNA *srna) { -// FunctionRNA *func; -// PropertyRNA *parm; + FunctionRNA *func; + //PropertyRNA *parm; + + /* validate relative Keying Set (used to ensure paths are ok for context) */ + func= RNA_def_function(srna, "refresh", "rna_KeyingSet_context_refresh"); + RNA_def_function_ui_description(func, "Refresh Keying Set to ensure that it is valid for the current context. Call before each use of one"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); } #endif -- cgit v1.2.3 From 0745f31306ce8954a2fc019b94bd301a39674d10 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 15 Aug 2011 11:34:29 +0000 Subject: "Select Grouped" by Keying Set for Bones --- source/blender/editors/armature/poseobject.c | 63 +++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 48d349ce837..be9641c10a3 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -603,6 +603,63 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend) return changed; } +static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) +{ + KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); + KS_Path *ksp; + + bArmature *arm = (ob)? ob->data : NULL; + bPose *pose= (ob)? ob->pose : NULL; + short changed= 0; + + /* sanity checks: validate Keying Set and object */ + if ((ks == NULL) || (ANIM_validate_keyingset(C, NULL, ks) != 0)) + return 0; + + if (ELEM3(NULL, ob, pose, arm)) + return 0; + + /* if not extending selection, deselect all selected first */ + if (extend == 0) { + CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) + { + if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) + pchan->bone->flag &= ~BONE_SELECTED; + } + CTX_DATA_END; + } + + /* iterate over elements in the Keying Set, setting selection depending on whether + * that bone is visible or not... + */ + for (ksp = ks->paths.first; ksp; ksp = ksp->next) { + /* only items related to this object will be relevant */ + if ((ksp->id == ob) && (ksp->rna_path != NULL)) { + if (strstr(ksp->rna_path, "bones")) { + char *boneName = BLI_getQuotedStr(ksp->rna_path, "bones["); + + if (boneName) { + bPoseChannel *pchan = get_pose_channel(pose, boneName); + + if (pchan) { + /* select if bone is visible and can be affected */ + if ((PBONE_VISIBLE(arm, pchan->bone)) && + (pchan->bone->flag & BONE_UNSELECTABLE)==0) + { + pchan->bone->flag |= BONE_SELECTED; + changed = 1; + } + } + + /* free temp memory */ + MEM_freeN(boneName); + } + } + } + } + + return changed; +} static int pose_select_grouped_exec (bContext *C, wmOperator *op) { @@ -621,6 +678,9 @@ static int pose_select_grouped_exec (bContext *C, wmOperator *op) case 1: /* group */ changed= pose_select_same_group(C, ob, extend); break; + case 2: /* Keying Set */ + changed= pose_select_same_keyingset(C, ob, extend); + break; default: /* layer */ changed= pose_select_same_layer(C, ob, extend); break; @@ -641,6 +701,7 @@ void POSE_OT_select_grouped (wmOperatorType *ot) static EnumPropertyItem prop_select_grouped_types[] = { {0, "LAYER", 0, "Layer", "Shared layers"}, {1, "GROUP", 0, "Group", "Shared group"}, + {2, "KEYINGSET", 0, "Keying Set", "All bones affected by active Keying Set"}, {0, NULL, 0, NULL, NULL} }; @@ -2139,7 +2200,7 @@ static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op)) if (pchan->rotmode == ROT_MODE_QUAT) { /* quaternions have 720 degree range */ negate_v4(pchan->quat); - + /* tagging */ if (autokeyframe_cfra_can_key(scene, &ob->id)) { ListBase dsources = {NULL, NULL}; -- cgit v1.2.3 From 87e8b853a64ea14d7d038ac2c9c16b469d6e0228 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 15 Aug 2011 11:51:42 +0000 Subject: Remove some unused code + warning fix --- source/blender/editors/armature/poseobject.c | 75 ++++++++-------------------- 1 file changed, 21 insertions(+), 54 deletions(-) (limited to 'source') diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index be9641c10a3..961c556b246 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -107,24 +107,6 @@ Object *ED_object_pose_armature(Object *ob) return NULL; } - -/* This function is used to indicate that a bone is selected and needs keyframes inserted */ -static void set_pose_keys (Object *ob) -{ - bArmature *arm= ob->data; - bPoseChannel *chan; - - if (ob->pose){ - for (chan=ob->pose->chanbase.first; chan; chan=chan->next){ - Bone *bone= chan->bone; - if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) - chan->flag |= POSE_KEY; - else - chan->flag &= ~POSE_KEY; - } - } -} - /* This function is used to process the necessary updates for */ void ED_armature_enter_posemode(bContext *C, Base *base) { @@ -634,7 +616,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) */ for (ksp = ks->paths.first; ksp; ksp = ksp->next) { /* only items related to this object will be relevant */ - if ((ksp->id == ob) && (ksp->rna_path != NULL)) { + if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) { if (strstr(ksp->rna_path, "bones")) { char *boneName = BLI_getQuotedStr(ksp->rna_path, "bones["); @@ -1005,6 +987,25 @@ void free_posebuf(void) g_posebuf=NULL; } +/* This function is used to indicate that a bone is selected + * and needs to be included in copy buffer (used to be for inserting keys) + */ +static void set_pose_keys (Object *ob) +{ + bArmature *arm= ob->data; + bPoseChannel *chan; + + if (ob->pose){ + for (chan=ob->pose->chanbase.first; chan; chan=chan->next){ + Bone *bone= chan->bone; + if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) + chan->flag |= POSE_KEY; + else + chan->flag &= ~POSE_KEY; + } + } +} + /* ---- */ static int pose_copy_exec (bContext *C, wmOperator *op) @@ -1239,7 +1240,7 @@ void POSE_OT_paste (wmOperatorType *ot) } /* ********************************************** */ - +/* Bone Groups */ static int pose_group_add_exec (bContext *C, wmOperator *UNUSED(op)) { @@ -2253,40 +2254,6 @@ void POSE_OT_quaternions_flip (wmOperatorType *ot) /* context: active channel */ #if 0 -void pose_special_editmenu(Scene *scene) -{ - Object *obedit= scene->obedit; // XXX context - Object *ob= OBACT; - short nr; - - /* paranoia checks */ - if(!ob && !ob->pose) return; - if(ob==obedit || (ob->mode & OB_MODE_POSE)==0) return; - - nr= pupmenu("Specials%t|Select Constraint Target%x1|Flip Left-Right Names%x2|Calculate Paths%x3|Clear Paths%x4|Clear User Transform %x5|Relax Pose %x6|%l|AutoName Left-Right%x7|AutoName Front-Back%x8|AutoName Top-Bottom%x9"); - if(nr==1) { - pose_select_constraint_target(scene); - } - else if(nr==2) { - pose_flip_names(); - } - else if(nr==3) { - pose_calculate_path(C, ob); - } - else if(nr==4) { - pose_clear_paths(ob); - } - else if(nr==5) { - pose_clear_user_transforms(ob); - } - else if(nr==6) { - pose_relax(); - } - else if(ELEM3(nr, 7, 8, 9)) { - pose_autoside_names(nr-7); - } -} - /* Restore selected pose-bones to 'action'-defined pose */ static void pose_clear_user_transforms(Object *ob) -- cgit v1.2.3 From cbbbf31315bf57aed5ccfec02f29495b2e3767ec Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 15 Aug 2011 13:24:53 +0000 Subject: Restoring "Clear User Transforms" operator This can now be found as Pose -> Clear Transforms -> Reset Unkeyed, or via the operator search (known by its old name there) --- source/blender/editors/armature/armature_intern.h | 1 + source/blender/editors/armature/armature_ops.c | 1 + source/blender/editors/armature/poseobject.c | 329 +++++++++++++--------- 3 files changed, 196 insertions(+), 135 deletions(-) (limited to 'source') diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index cc654f6d2bc..47123b7fb4d 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -93,6 +93,7 @@ void POSE_OT_rot_clear(struct wmOperatorType *ot); void POSE_OT_loc_clear(struct wmOperatorType *ot); void POSE_OT_scale_clear(struct wmOperatorType *ot); void POSE_OT_transforms_clear(struct wmOperatorType *ot); +void POSE_OT_user_transforms_clear(struct wmOperatorType *ot); void POSE_OT_copy(struct wmOperatorType *ot); void POSE_OT_paste(struct wmOperatorType *ot); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 28454fa0fa9..81ece9ddc9a 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -108,6 +108,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_loc_clear); WM_operatortype_append(POSE_OT_scale_clear); WM_operatortype_append(POSE_OT_transforms_clear); + WM_operatortype_append(POSE_OT_user_transforms_clear); WM_operatortype_append(POSE_OT_copy); WM_operatortype_append(POSE_OT_paste); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 961c556b246..d2f32837d6d 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -47,6 +47,7 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "BKE_animsys.h" #include "BKE_anim.h" #include "BKE_idprop.h" #include "BKE_action.h" @@ -1006,6 +1007,130 @@ static void set_pose_keys (Object *ob) } } +/* perform paste pose, for a single bone + * < ob: object where bone to paste to lives + * < chan: bone that pose to paste comes from + * < selOnly: only paste on selected bones + * < flip: flip on x-axis + * + * > returns: whether the bone that we pasted to if we succeeded + */ +static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short selOnly, short flip) +{ + bPoseChannel *pchan; + char name[32]; + short paste_ok; + + /* get the name - if flipping, we must flip this first */ + if (flip) + flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */ + else + BLI_strncpy(name, chan->name, sizeof(name)); + + /* only copy when: + * 1) channel exists - poses are not meant to add random channels to anymore + * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical + */ + pchan= get_pose_channel(ob->pose, name); + + if (selOnly) + paste_ok= ((pchan) && (pchan->bone->flag & BONE_SELECTED)); + else + paste_ok= ((pchan != NULL)); + + /* continue? */ + if (paste_ok) { + /* only loc rot size + * - only copies transform info for the pose + */ + VECCOPY(pchan->loc, chan->loc); + VECCOPY(pchan->size, chan->size); + pchan->flag= chan->flag; + + /* check if rotation modes are compatible (i.e. do they need any conversions) */ + if (pchan->rotmode == chan->rotmode) { + /* copy the type of rotation in use */ + if (pchan->rotmode > 0) { + VECCOPY(pchan->eul, chan->eul); + } + else if (pchan->rotmode == ROT_MODE_AXISANGLE) { + VECCOPY(pchan->rotAxis, chan->rotAxis); + pchan->rotAngle = chan->rotAngle; + } + else { + QUATCOPY(pchan->quat, chan->quat); + } + } + else if (pchan->rotmode > 0) { + /* quat/axis-angle to euler */ + if (chan->rotmode == ROT_MODE_AXISANGLE) + axis_angle_to_eulO( pchan->eul, pchan->rotmode,chan->rotAxis, chan->rotAngle); + else + quat_to_eulO( pchan->eul, pchan->rotmode,chan->quat); + } + else if (pchan->rotmode == ROT_MODE_AXISANGLE) { + /* quat/euler to axis angle */ + if (chan->rotmode > 0) + eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->eul, chan->rotmode); + else + quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->quat); + } + else { + /* euler/axis-angle to quat */ + if (chan->rotmode > 0) + eulO_to_quat(pchan->quat, chan->eul, chan->rotmode); + else + axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle); + } + + /* paste flipped pose? */ + if (flip) { + pchan->loc[0]*= -1; + + /* has to be done as eulers... */ + if (pchan->rotmode > 0) { + pchan->eul[1] *= -1; + pchan->eul[2] *= -1; + } + else if (pchan->rotmode == ROT_MODE_AXISANGLE) { + float eul[3]; + + axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle); + eul[1]*= -1; + eul[2]*= -1; + eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT); + } + else { + float eul[3]; + + normalize_qt(pchan->quat); + quat_to_eul(eul, pchan->quat); + eul[1]*= -1; + eul[2]*= -1; + eul_to_quat(pchan->quat, eul); + } + } + + /* ID properties */ + if (chan->prop) { + if (pchan->prop) { + /* if we have existing properties on a bone, just copy over the values of + * matching properties (i.e. ones which will have some impact) on to the + * target instead of just blinding replacing all [ + */ + IDP_SyncGroupValues(pchan->prop, chan->prop); + } + else { + /* no existing properties, so assume that we want copies too? */ + pchan->prop= IDP_CopyProperty(chan->prop); + } + } + } + + /* return whether paste went ahead */ + return pchan; +} + /* ---- */ static int pose_copy_exec (bContext *C, wmOperator *op) @@ -1048,9 +1173,9 @@ void POSE_OT_copy (wmOperatorType *ot) static int pose_paste_exec (bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); Object *ob= ED_object_pose_armature(CTX_data_active_object(C)); - bPoseChannel *chan, *pchan; + Scene *scene= CTX_data_scene(C); + bPoseChannel *chan; int flip= RNA_boolean_get(op->ptr, "flipped"); int selOnly= RNA_boolean_get(op->ptr, "selected_mask"); @@ -1074,115 +1199,11 @@ static int pose_paste_exec (bContext *C, wmOperator *op) /* Safely merge all of the channels in the buffer pose into any existing pose */ for (chan= g_posebuf->chanbase.first; chan; chan=chan->next) { if (chan->flag & POSE_KEY) { - char name[32]; - short paste_ok; + /* try to perform paste on this bone */ + bPoseChannel *pchan = pose_bone_do_paste(ob, chan, selOnly, flip); - /* get the name - if flipping, we must flip this first */ - if (flip) - flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */ - else - BLI_strncpy(name, chan->name, sizeof(name)); - - /* only copy when: - * 1) channel exists - poses are not meant to add random channels to anymore - * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical - */ - pchan= get_pose_channel(ob->pose, name); - - if (selOnly) - paste_ok= ((pchan) && (pchan->bone->flag & BONE_SELECTED)); - else - paste_ok= ((pchan != NULL)); - - /* continue? */ - if (paste_ok) { - /* only loc rot size - * - only copies transform info for the pose - */ - VECCOPY(pchan->loc, chan->loc); - VECCOPY(pchan->size, chan->size); - pchan->flag= chan->flag; - - /* check if rotation modes are compatible (i.e. do they need any conversions) */ - if (pchan->rotmode == chan->rotmode) { - /* copy the type of rotation in use */ - if (pchan->rotmode > 0) { - VECCOPY(pchan->eul, chan->eul); - } - else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - VECCOPY(pchan->rotAxis, chan->rotAxis); - pchan->rotAngle = chan->rotAngle; - } - else { - QUATCOPY(pchan->quat, chan->quat); - } - } - else if (pchan->rotmode > 0) { - /* quat/axis-angle to euler */ - if (chan->rotmode == ROT_MODE_AXISANGLE) - axis_angle_to_eulO( pchan->eul, pchan->rotmode,chan->rotAxis, chan->rotAngle); - else - quat_to_eulO( pchan->eul, pchan->rotmode,chan->quat); - } - else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - /* quat/euler to axis angle */ - if (chan->rotmode > 0) - eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->eul, chan->rotmode); - else - quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, chan->quat); - } - else { - /* euler/axis-angle to quat */ - if (chan->rotmode > 0) - eulO_to_quat(pchan->quat, chan->eul, chan->rotmode); - else - axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle); - } - - /* paste flipped pose? */ - if (flip) { - pchan->loc[0]*= -1; - - /* has to be done as eulers... */ - if (pchan->rotmode > 0) { - pchan->eul[1] *= -1; - pchan->eul[2] *= -1; - } - else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - float eul[3]; - - axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle); - eul[1]*= -1; - eul[2]*= -1; - eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT); - } - else { - float eul[3]; - - normalize_qt(pchan->quat); - quat_to_eul(eul, pchan->quat); - eul[1]*= -1; - eul[2]*= -1; - eul_to_quat(pchan->quat, eul); - } - } - - /* ID properties */ - if (chan->prop) { - if (pchan->prop) { - /* if we have existing properties on a bone, just copy over the values of - * matching properties (i.e. ones which will have some impact) on to the - * target instead of just blinding replacing all [ - */ - IDP_SyncGroupValues(pchan->prop, chan->prop); - } - else { - /* no existing properties, so assume that we want copies too? */ - pchan->prop= IDP_CopyProperty(chan->prop); - } - } - - /* keyframing tagging */ + if (pchan) { + /* keyframing tagging for successful paste */ if (autokeyframe_cfra_can_key(scene, &ob->id)) { ListBase dsources = {NULL, NULL}; @@ -2187,6 +2208,7 @@ void ARMATURE_OT_bone_layers (wmOperatorType *ot) } /* ********************************************** */ +/* Flip Quats */ static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op)) { @@ -2251,41 +2273,78 @@ void POSE_OT_quaternions_flip (wmOperatorType *ot) } /* ********************************************** */ +/* Clear User Transforms */ -/* context: active channel */ -#if 0 - -/* Restore selected pose-bones to 'action'-defined pose */ -static void pose_clear_user_transforms(Object *ob) +static int pose_clear_user_transforms_exec (bContext *C, wmOperator *op) { - bArmature *arm= ob->data; - bPoseChannel *pchan; - - if (ob->pose == NULL) - return; + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + float cframe = (float)CFRA; - /* if the object has an action, restore pose to the pose defined by the action by clearing pose on selected bones */ - if (ob->action) { - /* find selected bones */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - if (pchan->bone && (pchan->bone->flag & BONE_SELECTED) && (pchan->bone->layer & arm->layer)) { - /* just clear the BONE_UNKEYED flag, allowing this bone to get overwritten by actions again */ - pchan->bone->flag &= ~BONE_UNKEYED; - } + if ((ob->adt) && (ob->adt->action)) { + /* XXX: this is just like this to avoid contaminating anything else; + * just pose values should change, so this should be fine + */ + bPose *dummyPose = NULL; + Object workob = {{0}}; + bPoseChannel *pchan; + + /* execute animation step for current frame using a dummy copy of the pose */ + copy_pose(&dummyPose, ob->pose, 0); + + BLI_strncpy(workob.id.name, "OB", sizeof(workob.id.name)); + workob.type = OB_ARMATURE; + workob.data = ob->data; + workob.adt = ob->adt; + workob.pose = dummyPose; + + BKE_animsys_evaluate_animdata(scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM); + + /* copy back values, but on selected bones only */ + for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { + pose_bone_do_paste(ob, pchan, 1, 0); } - /* clear pose locking flag - * - this will only clear the user-defined pose in the selected bones, where BONE_UNKEYED has been cleared - */ - ob->pose->flag |= POSE_DO_UNLOCK; + /* free temp data - free manually as was copied without constraints */ + if (dummyPose) { + for (pchan= dummyPose->chanbase.first; pchan; pchan= pchan->next) { + if (pchan->prop) { + IDP_FreeProperty(pchan->prop); + MEM_freeN(pchan->prop); + } + } + + /* was copied without constraints */ + BLI_freelistN(&dummyPose->chanbase); + MEM_freeN(dummyPose); + } } else { - /* no action, so restore entire pose to rest pose (cannot restore only selected bones) */ + /* no animation, so just reset whole pose to rest pose + * (cannot just restore for selected though) + */ rest_pose(ob->pose); } + /* notifiers and updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - BIF_undo_push("Clear User Transform"); + WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + + return OPERATOR_FINISHED; +} + +void POSE_OT_user_transforms_clear (wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Clear User Transforms"; + ot->idname= "POSE_OT_user_transforms_clear"; + ot->description= "Reset pose on selected bones to keyframed state"; + + /* callbacks */ + ot->exec= pose_clear_user_transforms_exec; + ot->poll= ED_operator_posemode; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } -#endif -- cgit v1.2.3 From a458de88b65c5fcb0f11c005c040163d3cf76cec Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Mon, 15 Aug 2011 21:50:09 +0000 Subject: 3D Audio GSoC: High quality resampling on mixdown, linear for playback. * Lots of improvements and fixes for the JOS resampler, now it works fine! * High quality filter coefficients for the JOS resampler (sorry for the 5 MB source file). * Fix for GE orientation bug. Note: moto uses x,y,z,w quaternion storage, while rest of blender uses w,x,y,z. * Minor changes/fixes. --- source/blender/blenkernel/intern/sound.c | 9 +-------- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 6 +++--- source/gameengine/Ketsji/KX_SoundActuator.cpp | 6 +++--- 3 files changed, 7 insertions(+), 14 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 9c62b92a924..d7385a86105 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -372,14 +372,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume) { - AUD_Device* mixdown = AUD_openReadDevice(specs); - - AUD_setDeviceVolume(mixdown, volume); - - AUD_setSequencerSpecs(scene->sound_scene, specs.specs); - AUD_freeHandle(AUD_playDevice(mixdown, scene->sound_scene, start / FPS)); - - return mixdown; + return AUD_openMixdownDevice(specs, scene->sound_scene, volume, start / FPS); } void sound_create_scene(struct Scene *scene) diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 0b83e3247ff..a51105e0c16 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1016,15 +1016,15 @@ void KX_KetsjiEngine::DoSound(KX_Scene* scene) if(dev) { AUD_Vector3 v; - AUD_Quaternion q; + float q[4]; cam->NodeGetWorldPosition().getValue(v.get()); dev->setListenerLocation(v); cam->GetLinearVelocity().getValue(v.get()); dev->setListenerVelocity(v); - cam->NodeGetWorldOrientation().getRotation().getValue(q.get()); - dev->setListenerOrientation(q); + cam->NodeGetWorldOrientation().getRotation().getValue(q); + dev->setListenerOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2])); } } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index eb1a13f672d..eb75e4944a7 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -224,14 +224,14 @@ bool KX_SoundActuator::Update(double curtime, bool frame) { KX_GameObject* obj = (KX_GameObject*)this->GetParent(); AUD_Vector3 v; - AUD_Quaternion q; + float q[4]; obj->NodeGetWorldPosition().getValue(v.get()); handle3d->setSourceLocation(v); obj->GetLinearVelocity().getValue(v.get()); handle3d->setSourceVelocity(v); - obj->NodeGetWorldOrientation().getRotation().getValue(q.get()); - handle3d->setSourceOrientation(q); + obj->NodeGetWorldOrientation().getRotation().getValue(q); + handle3d->setSourceOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2])); } result = true; } -- cgit v1.2.3 From a67562e73cbc2f4a9641fbc4d1147b4b2cc935c4 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 16 Aug 2011 01:02:26 +0000 Subject: Bugfix [#28267] keyframed values for shapekeys of copied objects are linked Shapekey actions weren't getting copied when their owner data was. This was due to the IMO totally convoluted way in which the duplicate action flags have been set up: - the function to copy animdata takes a param to specify whether actions are copied or not, but this is never touched (i.e. this always just gets FALSE passed in) - instead, we jump around in hoops later figuring out whether the userpref wants copying to occur, then fixing up the links IIRC, part of this may be due to a desire/need to not duplicate actions when dealing with NodeTree copies for multi-threaded rendering, but at the expense of complicating everything else. --- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/fmodifier.c | 2 +- source/blender/editors/object/object_add.c | 27 +++++---------------------- 3 files changed, 7 insertions(+), 24 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 1c4746b1828..3c6daf8b39d 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -287,7 +287,7 @@ int BKE_copy_animdata_id (ID *id_to, ID *id_from, const short do_action) return 1; } -void BKE_copy_animdata_id_action(struct ID *id) +void BKE_copy_animdata_id_action(ID *id) { AnimData *adt= BKE_animdata_from_id(id); if (adt) { diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 64e51023816..42554679795 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -604,7 +604,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), /* calculate the 'number' of the cycle */ cycle= ((float)side * (evaltime - ofs) / cycdx); - + /* calculate the time inside the cycle */ cyct= fmod(evaltime - ofs, cycdx); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 09ce2562e3b..6bc4c30a898 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -39,6 +39,7 @@ #include "DNA_curve_types.h" #include "DNA_group_types.h" #include "DNA_lamp_types.h" +#include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_meta_types.h" @@ -65,6 +66,7 @@ #include "BKE_group.h" #include "BKE_lattice.h" #include "BKE_library.h" +#include "BKE_key.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mball.h" @@ -1496,28 +1498,6 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } /* duplicates using userflags */ -#if 0 // XXX old animation system - if(dupflag & USER_DUP_IPO) { - bConstraintChannel *chan; - id= (ID *)obn->ipo; - - if(id) { - ID_NEW_US( obn->ipo) - else obn->ipo= copy_ipo(obn->ipo); - id->us--; - } - /* Handle constraint ipos */ - for (chan=obn->constraintChannels.first; chan; chan=chan->next){ - id= (ID *)chan->ipo; - if(id) { - ID_NEW_US( chan->ipo) - else chan->ipo= copy_ipo(chan->ipo); - id->us--; - } - } - } -#endif // XXX old animation system - if(dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&obn->id); } @@ -1674,8 +1654,11 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base /* check if obdata is copied */ if(didit) { + Key *key = ob_get_key(obn); + if(dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action((ID *)obn->data); + if(key) BKE_copy_animdata_id_action((ID*)key); } if(dupflag & USER_DUP_MAT) { -- cgit v1.2.3 From 02d2472baacd8ac091a29392a2bc9ac8693fb5e7 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 16 Aug 2011 13:00:55 +0000 Subject: 3D Audio GSoC: Code documentation. Also: * Fix: rlint for MSVC. * Minor other small fixes/changes. --- source/blender/makesrna/intern/rna_scene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 7f8aeb65209..2a558da1cb0 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -46,7 +46,7 @@ #ifdef WITH_QUICKTIME #include "quicktime_export.h" # ifdef WITH_AUDASPACE -# include "AUD_C-API.h" +# include "AUD_Space.h" # endif #endif -- cgit v1.2.3 From f04fb5b6eaed0877ddeb66e1099ed930fc439812 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Tue, 16 Aug 2011 16:03:37 +0000 Subject: Finalizing. --- source/blender/collada/AnimationExporter.cpp | 130 +++++++++++++++++++-------- source/blender/collada/AnimationExporter.h | 2 +- source/blender/collada/AnimationImporter.cpp | 2 +- source/blender/collada/AnimationImporter.h | 2 +- source/blender/collada/ArmatureExporter.cpp | 2 +- source/blender/collada/ArmatureImporter.cpp | 28 +++--- source/blender/collada/DocumentImporter.cpp | 9 +- 7 files changed, 115 insertions(+), 60 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index a777f4ae984..d2ff369c613 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -61,13 +61,14 @@ void AnimationExporter::exportAnimations(Scene *sce) bool isMatAnim = false; if(ob->adt && ob->adt->action) { - if ( ob->type == OB_ARMATURE ) + //transform matrix export for bones are temporarily disabled here. + /*if ( ob->type == OB_ARMATURE ) { bArmature *arm = (bArmature*)ob->data; for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) bake_bone_animation(ob, bone); - } + }*/ fcu = (FCurve*)ob->adt->action->curves.first; while (fcu) { transformName = extract_transform_name( fcu->rna_path ); @@ -988,8 +989,7 @@ void AnimationExporter::exportAnimations(Scene *sce) std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) { std::string tm_name; - bool is_rotation =false; - // when given rna_path, determine tm_type from it + // when given rna_path, determine tm_type from it if (rna_path) { char *name = extract_transform_name(rna_path); @@ -1033,6 +1033,57 @@ void AnimationExporter::exportAnimations(Scene *sce) return std::string(""); } + + std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) + { + std::string tm_name; + // when given rna_path, determine tm_type from it + if (rna_path) { + char *name = extract_transform_name(rna_path); + + if (!strcmp(name, "lens")) + tm_type = 0; + else if (!strcmp(name, "ortho_scale")) + tm_type = 1; + else if (!strcmp(name, "clip_end")) + tm_type = 2; + else if (!strcmp(name, "clip_start")) + tm_type = 3; + + else + tm_type = -1; + } + + switch (tm_type) { + case 0: + tm_name = "xfov"; + break; + case 1: + tm_name = "xmag"; + break; + case 2: + tm_name = "zfar"; + break; + case 3: + tm_name = "znear"; + break; + + default: + tm_name = ""; + break; + } + + if (tm_name.size()) { + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; + } + + return std::string(""); + } + + // Assign sid of the animated parameter or transform // for rotation, axis name is always appended and the value of append_axis is ignored std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) { @@ -1137,6 +1188,7 @@ void AnimationExporter::exportAnimations(Scene *sce) return dot ? (dot + 1) : rna_path; } + //find keyframes of all the objects animations void AnimationExporter::find_frames(Object *ob, std::vector &fra) { FCurve *fcu= (FCurve*)ob->adt->action->curves.first; @@ -1154,38 +1206,7 @@ void AnimationExporter::exportAnimations(Scene *sce) std::sort(fra.begin(), fra.end()); } - - void AnimationExporter::find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name) - { - FCurve *fcu= (FCurve*)ob->adt->action->curves.first; - - for (; fcu; fcu = fcu->next) { - if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix))) - continue; - - char *name = extract_transform_name(fcu->rna_path); - if (!strcmp(name, tm_name)) { - for (unsigned int i = 0; i < fcu->totvert; i++) { - float f = fcu->bezt[i].vec[1][0]; // - if (std::find(fra.begin(), fra.end(), f) == fra.end()) - fra.push_back(f); - } - } - } - - // keep the keys in ascending order - std::sort(fra.begin(), fra.end()); - } - - void AnimationExporter::find_rotation_frames(Object *ob, std::vector &fra, const char *prefix, int rotmode) - { - if (rotmode > 0) - find_frames(ob, fra, prefix, "rotation_euler"); - else if (rotmode == ROT_MODE_QUAT) - find_frames(ob, fra, prefix, "rotation_quaternion"); - /*else if (rotmode == ROT_MODE_AXISANGLE) - ;*/ - } + // enable fcurves driving a specific bone, disable all the rest // if bone_name = NULL enable all fcurves @@ -1218,13 +1239,17 @@ void AnimationExporter::exportAnimations(Scene *sce) Object *ob = base->object; FCurve *fcu = 0; + //Check for object transform animations if(ob->adt && ob->adt->action) fcu = (FCurve*)ob->adt->action->curves.first; + //Check for Lamp parameter animations else if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); + //Check for Camera parameter animations else if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); + //Check Material Effect parameter animations. for(int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); @@ -1240,3 +1265,36 @@ void AnimationExporter::exportAnimations(Scene *sce) } return false; } + + //------------------------------- Not used in the new system.-------------------------------------------------------- + void AnimationExporter::find_rotation_frames(Object *ob, std::vector &fra, const char *prefix, int rotmode) + { + if (rotmode > 0) + find_frames(ob, fra, prefix, "rotation_euler"); + else if (rotmode == ROT_MODE_QUAT) + find_frames(ob, fra, prefix, "rotation_quaternion"); + /*else if (rotmode == ROT_MODE_AXISANGLE) + ;*/ + } + + void AnimationExporter::find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name) + { + FCurve *fcu= (FCurve*)ob->adt->action->curves.first; + + for (; fcu; fcu = fcu->next) { + if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix))) + continue; + + char *name = extract_transform_name(fcu->rna_path); + if (!strcmp(name, tm_name)) { + for (unsigned int i = 0; i < fcu->totvert; i++) { + float f = fcu->bezt[i].vec[1][0]; // + if (std::find(fra.begin(), fra.end(), f) == fra.end()) + fra.push_back(f); + } + } + } + + // keep the keys in ascending order + std::sort(fra.begin(), fra.end()); + } diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 6cf3207b8a0..e1b03b969dc 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -143,7 +143,7 @@ protected: // for rotation, axis name is always appended and the value of append_axis is ignored std::string get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); std::string get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); - + std::string get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis); void find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name); void find_frames(Object *ob, std::vector &fra); diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 0549f133031..29bd0bd93b7 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory. + * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory, Sukhitha Jayathilake. * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 9aec7df1099..fbb53ceedb6 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory. + * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory , Sukhitha Jayathilake. * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 6849e4de7dd..b033c780530 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -224,7 +224,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: mul_m4_m4m4(mat, pchan->pose_mat, ob_arm->obmat); } - TransformWriter::add_node_transform(node, mat, NULL); + TransformWriter::add_node_transform(node, mat,NULL ); } std::string ArmatureExporter::get_controller_id(Object *ob_arm, Object *ob) diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 7a3c6a0644f..7acae995396 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory. + * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory, Sukhitha jayathilake. * * ***** END GPL LICENSE BLOCK ***** */ @@ -37,6 +37,7 @@ #include "BKE_action.h" #include "BKE_depsgraph.h" #include "BKE_object.h" +#include "BKE_armature.h" #include "BLI_string.h" #include "ED_armature.h" @@ -97,28 +98,21 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p if (parent) bone->parent = parent; float ax[3]; - float angle = NULL; + float angle = 0; // get world-space if (parent){ mul_m4_m4m4(mat, obmat, parent_mat); - bPoseChannel *parchan = get_pose_channel(ob_arm->pose, parent->name); - if ( parchan && pchan) - mul_m4_m4m4(pchan->pose_mat, mat , parchan->pose_mat); - mat4_to_axis_angle(ax,&angle,mat); - bone->roll = angle; + } else { copy_m4_m4(mat, obmat); - float invObmat[4][4]; - invert_m4_m4(invObmat, ob_arm->obmat); - if(pchan) - mul_m4_m4m4(pchan->pose_mat, mat, invObmat); - mat4_to_axis_angle(ax,&angle,mat); - bone->roll = angle; - } - + } + float loc[3], size[3], rot[3][3]; + mat4_to_loc_rot_size( loc, rot, size, obmat); + mat3_to_vec_roll(rot, NULL, &angle ); + bone->roll=angle; // set head copy_v3_v3(bone->head, mat[3]); @@ -130,10 +124,10 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p // set parent tail if (parent && totchild == 1) { copy_v3_v3(parent->tail, bone->head); - + // not setting BONE_CONNECTED because this would lock child bone location with respect to parent // bone->flag |= BONE_CONNECTED; - + // XXX increase this to prevent "very" small bones? const float epsilon = 0.000001f; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index a4d1c1b451f..f6c985626db 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -410,15 +410,18 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren while (geom_done < geom.getCount()) { ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map, material_texture_mapping_map); - ++geom_done; + if ( ob != NULL ) + ++geom_done; } while (camera_done < camera.getCount()) { ob = create_camera_object(camera[camera_done], sce); - ++camera_done; + if ( ob != NULL ) + ++camera_done; } while (lamp_done < lamp.getCount()) { ob = create_lamp_object(lamp[lamp_done], sce); - ++lamp_done; + if ( ob != NULL ) + ++lamp_done; } while (controller_done < controller.getCount()) { COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry*)controller[controller_done]; -- cgit v1.2.3 From d79967e164c1a093df955787329da490f4878c01 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Tue, 16 Aug 2011 17:17:13 +0000 Subject: Animation Exporter clean up. --- source/blender/collada/AnimationExporter.cpp | 383 +++++++++++++-------------- source/blender/collada/AnimationExporter.h | 4 +- 2 files changed, 193 insertions(+), 194 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index d2ff369c613..e76d7c0cfa6 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -59,6 +59,8 @@ void AnimationExporter::exportAnimations(Scene *sce) FCurve *fcu; char * transformName ; bool isMatAnim = false; + + //Export transform animations if(ob->adt && ob->adt->action) { //transform matrix export for bones are temporarily disabled here. @@ -66,7 +68,7 @@ void AnimationExporter::exportAnimations(Scene *sce) { bArmature *arm = (bArmature*)ob->data; for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) - bake_bone_animation(ob, bone); + write_bone_animation_matrix(ob, bone); }*/ fcu = (FCurve*)ob->adt->action->curves.first; @@ -80,6 +82,8 @@ void AnimationExporter::exportAnimations(Scene *sce) fcu = fcu->next; } } + + //Export Lamp parameter animations if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) { fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); @@ -93,6 +97,7 @@ void AnimationExporter::exportAnimations(Scene *sce) } } + //Export Camera parameter animations if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) { fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); @@ -107,6 +112,7 @@ void AnimationExporter::exportAnimations(Scene *sce) } } + //Export Material parameter animations. for(int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); @@ -127,28 +133,30 @@ void AnimationExporter::exportAnimations(Scene *sce) } } - //if (!ob->adt || !ob->adt->action) - // fcu = (FCurve*)((Lamp*)ob->data)->adt->action->curves.first; //this is already checked in hasAnimations() - //else - // fcu = (FCurve*)ob->adt->action->curves.first; + /* Old System + if (!ob->adt || !ob->adt->action) + fcu = (FCurve*)((Lamp*)ob->data)->adt->action->curves.first; //this is already checked in hasAnimations() + else + fcu = (FCurve*)ob->adt->action->curves.first; - //if (ob->type == OB_ARMATURE) { - // if (!ob->data) return; - // bArmature *arm = (bArmature*)ob->data; - // while(fcu) - // { - // transformName = extract_transform_name( fcu->rna_path ); - // // std::string ob_name = getObjectBoneName( ob , fcu); - // // for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) - // // write_bone_animation(ob, bone); - // dae_animation(ob, fcu, ob_name, transformName); - // fcu = fcu->next; - // } - //} - //else { + if (ob->type == OB_ARMATURE) { + if (!ob->data) return; + bArmature *arm = (bArmature*)ob->data; + while(fcu) + { + transformName = extract_transform_name( fcu->rna_path ); + // std::string ob_name = getObjectBoneName( ob , fcu); + // for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) + // write_bone_animation(ob, bone); + dae_animation(ob, fcu, ob_name, transformName); + fcu = fcu->next; + } + } + else {*/ } + //euler sources from quternion sources float * AnimationExporter::get_eul_source_for_quat(Object *ob ) { FCurve *fcu = (FCurve*)ob->adt->action->curves.first; @@ -183,6 +191,8 @@ void AnimationExporter::exportAnimations(Scene *sce) return eul; } + + //Get proper name for bones std::string AnimationExporter::getObjectBoneName( Object* ob,const FCurve* fcu ) { //hard-way to derive the bone name from rna_path. Must find more compact method @@ -197,9 +207,9 @@ void AnimationExporter::exportAnimations(Scene *sce) return id_name(ob); } + //convert f-curves to animation curves and write void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, Material * ma ) { - const char *axis_name = NULL; char anim_id[200]; @@ -210,12 +220,10 @@ void AnimationExporter::exportAnimations(Scene *sce) { fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n"); quatRotation = true; - /*const char *axis_names[] = {"", "X", "Y", "Z"}; - if (fcu->array_index < 4) - axis_name = axis_names[fcu->array_index];*/ return; } - //maybe a list or a vector of float animations + + //axis names for colors else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")|| (!strcmp(transformName, "alpha"))) { @@ -223,18 +231,24 @@ void AnimationExporter::exportAnimations(Scene *sce) if (fcu->array_index < 3) axis_name = axis_names[fcu->array_index]; } + + //axis names for transforms else if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || - (!strcmp(transformName, "rotation_euler"))) + (!strcmp(transformName, "rotation_euler"))||(!strcmp(transformName, "rotation_quaternion"))) { const char *axis_names[] = {"X", "Y", "Z"}; if (fcu->array_index < 3) axis_name = axis_names[fcu->array_index]; } + + //no axis name. single parameter. else{ axis_name = ""; } std::string ob_name = std::string("null"); + + //Create anim Id if (ob->type == OB_ARMATURE) { ob_name = getObjectBoneName( ob , fcu); @@ -251,8 +265,6 @@ void AnimationExporter::exportAnimations(Scene *sce) fcu->rna_path, axis_name); } - // check rna_path is one of: rotation, scale, location - openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); // create input source @@ -261,6 +273,7 @@ void AnimationExporter::exportAnimations(Scene *sce) // create output source std::string output_id ; + //quat rotations are skipped for now, because of complications with determining axis. if(quatRotation) { float * eul = get_eul_source_for_quat(ob); @@ -269,7 +282,7 @@ void AnimationExporter::exportAnimations(Scene *sce) eul_axis[i] = eul[i*3 + fcu->array_index]; output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name); } - else + else { output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name); } @@ -288,7 +301,6 @@ void AnimationExporter::exportAnimations(Scene *sce) outtangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUT_TANGENT, fcu, anim_id, axis_name); } - std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); std::string empty; @@ -318,7 +330,7 @@ void AnimationExporter::exportAnimations(Scene *sce) if ( ob->type == OB_CAMERA ) target = get_camera_id(ob) - + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); + + "/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true); if( ma ) target = translate_id(id_name(ma)) + "-effect" @@ -329,34 +341,22 @@ void AnimationExporter::exportAnimations(Scene *sce) closeAnimation(); } - void AnimationExporter::bake_bone_animation(Object *ob_arm, Bone *bone) + + + //write bone animations in transform matrix sources + void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone) { if (!ob_arm->adt) return; - sample_and_bake_bone_animation(ob_arm, bone); + sample_and_write_bone_animation_matrix(ob_arm, bone); for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) - bake_bone_animation(ob_arm, child); + write_bone_animation_matrix(ob_arm, child); } - void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone) - { - if (!ob_arm->adt) - return; - - //write bone animations for 3 transform types - //i=0 --> rotations - //i=1 --> scale - //i=2 --> location - for (int i = 0; i < 3; i++) - sample_and_write_bone_animation(ob_arm, bone, i); - - for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) - write_bone_animation(ob_arm, child); - } - - void AnimationExporter::sample_and_bake_bone_animation(Object *ob_arm, Bone *bone) + + void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone) { bArmature *arm = (bArmature*)ob_arm->data; int flag = arm->flag; @@ -377,7 +377,6 @@ void AnimationExporter::exportAnimations(Scene *sce) } if (fra.size()) { - //int total = fra.back() - fra.front(); float *values = (float*)MEM_callocN(sizeof(float) * 16 * fra.size(), "temp. anim frames"); sample_animation(values, fra, bone, ob_arm, pchan); @@ -390,68 +389,6 @@ void AnimationExporter::exportAnimations(Scene *sce) where_is_pose(scene, ob_arm); } - void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) - { - bArmature *arm = (bArmature*)ob_arm->data; - int flag = arm->flag; - std::vector fra; - char prefix[256]; - - BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); - - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); - if (!pchan) - return; - //Fill frame array with key frame values framed at @param:transform_type - switch (transform_type) { - case 0: - find_rotation_frames(ob_arm, fra, prefix, pchan->rotmode); - break; - case 1: - find_frames(ob_arm, fra, prefix, "scale"); - break; - case 2: - find_frames(ob_arm, fra, prefix, "location"); - break; - default: - return; - } - - // exit rest position - if (flag & ARM_RESTPOS) { - arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); - } - //v array will hold all values which will be exported. - if (fra.size()) { - float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames"); - sample_animation(values, fra, transform_type, bone, ob_arm, pchan); - - if (transform_type == 0) { - // write x, y, z curves separately if it is rotation - float *axisValues = (float*)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames"); - - for (int i = 0; i < 3; i++) { - for (unsigned int j = 0; j < fra.size(); j++) - axisValues[j] = values[j * 3 + i]; - - dae_bone_animation(fra, axisValues, transform_type, i, id_name(ob_arm), bone->name); - } - MEM_freeN(axisValues); - } - else { - // write xyz at once if it is location or scale - dae_bone_animation(fra, values, transform_type, -1, id_name(ob_arm), bone->name); - } - - MEM_freeN(values); - } - - // restore restpos - if (flag & ARM_RESTPOS) - arm->flag = flag; - where_is_pose(scene, ob_arm); - } void AnimationExporter::sample_animation(float *v, std::vector &frames, Bone *bone, Object *ob_arm, bPoseChannel *pchan) { @@ -503,56 +440,7 @@ void AnimationExporter::exportAnimations(Scene *sce) } - void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) - { - bPoseChannel *parchan = NULL; - bPose *pose = ob_arm->pose; - - pchan = get_pose_channel(pose, bone->name); - - if (!pchan) - return; - - parchan = pchan->parent; - - enable_fcurves(ob_arm->adt->action, bone->name); - - std::vector::iterator it; - for (it = frames.begin(); it != frames.end(); it++) { - float mat[4][4], ipar[4][4]; - - float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); - - //BKE_animsys_evaluate_animdata(&ob_arm->id, ob_arm->adt, *it, ADT_RECALC_ANIM); - //BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); - - // compute bone local mat - if (bone->parent) { - invert_m4_m4(ipar, parchan->pose_mat); - mul_m4_m4m4(mat, pchan->pose_mat, ipar); - } - else - copy_m4_m4(mat, pchan->pose_mat); - - switch (type) { - case 0: - mat4_to_eul(v, mat); - break; - case 1: - mat4_to_size(v, mat); - break; - case 2: - copy_v3_v3(v, mat[3]); - break; - } - - v += 3; - } - - enable_fcurves(ob_arm->adt->action, NULL); - } - + void AnimationExporter::dae_baked_animation(std::vector &fra, float *values, std::string ob_name, std::string bone_name) { char anim_id[200]; @@ -1101,24 +989,16 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_type = 2; else if (!strcmp(name, "location")) tm_type = 3; - else if (!strcmp(name, "lens")) - tm_type = 4; - else if (!strcmp(name, "ortho_scale")) - tm_type = 5; - else if (!strcmp(name, "clip_end")) - tm_type = 6; - else if (!strcmp(name, "clip_start")) - tm_type = 7; else if (!strcmp(name, "specular_hardness")) - tm_type = 8; + tm_type = 4; else if (!strcmp(name, "specular_color")) - tm_type = 9; + tm_type = 5; else if (!strcmp(name, "diffuse_color")) - tm_type = 10; + tm_type = 6; else if (!strcmp(name, "alpha")) - tm_type = 11; + tm_type = 7; else if (!strcmp(name, "ior")) - tm_type = 12; + tm_type = 8; else tm_type = -1; @@ -1137,30 +1017,18 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_name = "location"; break; case 4: - tm_name = "xfov"; - break; - case 5: - tm_name = "xmag"; - break; - case 6: - tm_name = "zfar"; - break; - case 7: - tm_name = "znear"; - break; - case 8: tm_name = "shininess"; break; - case 9: + case 5: tm_name = "specular"; break; - case 10: + case 6: tm_name = "diffuse"; break; - case 11: + case 7: tm_name = "transparency"; break; - case 12: + case 8: tm_name = "index_of_refraction"; break; @@ -1298,3 +1166,134 @@ void AnimationExporter::exportAnimations(Scene *sce) // keep the keys in ascending order std::sort(fra.begin(), fra.end()); } + + void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone) + { + if (!ob_arm->adt) + return; + + //write bone animations for 3 transform types + //i=0 --> rotations + //i=1 --> scale + //i=2 --> location + for (int i = 0; i < 3; i++) + sample_and_write_bone_animation(ob_arm, bone, i); + + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) + write_bone_animation(ob_arm, child); + } + + void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) + { + bArmature *arm = (bArmature*)ob_arm->data; + int flag = arm->flag; + std::vector fra; + char prefix[256]; + + BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); + + bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + if (!pchan) + return; + //Fill frame array with key frame values framed at @param:transform_type + switch (transform_type) { + case 0: + find_rotation_frames(ob_arm, fra, prefix, pchan->rotmode); + break; + case 1: + find_frames(ob_arm, fra, prefix, "scale"); + break; + case 2: + find_frames(ob_arm, fra, prefix, "location"); + break; + default: + return; + } + + // exit rest position + if (flag & ARM_RESTPOS) { + arm->flag &= ~ARM_RESTPOS; + where_is_pose(scene, ob_arm); + } + //v array will hold all values which will be exported. + if (fra.size()) { + float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames"); + sample_animation(values, fra, transform_type, bone, ob_arm, pchan); + + if (transform_type == 0) { + // write x, y, z curves separately if it is rotation + float *axisValues = (float*)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames"); + + for (int i = 0; i < 3; i++) { + for (unsigned int j = 0; j < fra.size(); j++) + axisValues[j] = values[j * 3 + i]; + + dae_bone_animation(fra, axisValues, transform_type, i, id_name(ob_arm), bone->name); + } + MEM_freeN(axisValues); + } + else { + // write xyz at once if it is location or scale + dae_bone_animation(fra, values, transform_type, -1, id_name(ob_arm), bone->name); + } + + MEM_freeN(values); + } + + // restore restpos + if (flag & ARM_RESTPOS) + arm->flag = flag; + where_is_pose(scene, ob_arm); + } + + void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) + { + bPoseChannel *parchan = NULL; + bPose *pose = ob_arm->pose; + + pchan = get_pose_channel(pose, bone->name); + + if (!pchan) + return; + + parchan = pchan->parent; + + enable_fcurves(ob_arm->adt->action, bone->name); + + std::vector::iterator it; + for (it = frames.begin(); it != frames.end(); it++) { + float mat[4][4], ipar[4][4]; + + float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + + //BKE_animsys_evaluate_animdata(&ob_arm->id, ob_arm->adt, *it, ADT_RECALC_ANIM); + //BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + + // compute bone local mat + if (bone->parent) { + invert_m4_m4(ipar, parchan->pose_mat); + mul_m4_m4m4(mat, pchan->pose_mat, ipar); + } + else + copy_m4_m4(mat, pchan->pose_mat); + + switch (type) { + case 0: + mat4_to_eul(v, mat); + break; + case 1: + mat4_to_size(v, mat); + break; + case 2: + copy_v3_v3(v, mat[3]); + break; + } + + v += 3; + } + + enable_fcurves(ob_arm->adt->action, NULL); + } + + diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index e1b03b969dc..6786206ee6f 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -96,13 +96,13 @@ protected: void dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, Material *ma = NULL); - void bake_bone_animation(Object *ob_arm, Bone *bone); + void write_bone_animation_matrix(Object *ob_arm, Bone *bone); void write_bone_animation(Object *ob_arm, Bone *bone); void sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type); - void sample_and_bake_bone_animation(Object *ob_arm, Bone *bone); + void sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone); void sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pChan); -- cgit v1.2.3 From 9b5c0f65aa6ef942709ea7156ee5a20e9b5f94e9 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 16 Aug 2011 19:59:08 +0000 Subject: BGE Animations: Increasing the max layer count to 8 as per a user request. Also, layer checks were checking for values between 0 and MAX_ACTION_LAYERS when they should have been checking for values between 0 and MAX_ACTION_LAYERS - 1. --- source/blender/makesrna/intern/rna_actuator.c | 2 +- source/gameengine/Ketsji/BL_ActionManager.h | 2 +- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 3c44720d469..5eccba16c3d 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -627,7 +627,7 @@ static void rna_def_action_actuator(BlenderRNA *brna) RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "layer", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0, 4); /* This should match BL_ActionManager::MAX_ACTION_LAYERS */ + RNA_def_property_range(prop, 0, 7); /* This should match BL_ActionManager::MAX_ACTION_LAYERS - 1 */ RNA_def_property_ui_text(prop, "Layer", "The animation layer to play the action on"); RNA_def_property_update(prop, NC_LOGIC, NULL); diff --git a/source/gameengine/Ketsji/BL_ActionManager.h b/source/gameengine/Ketsji/BL_ActionManager.h index c310e231ed7..a3c8379981e 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.h +++ b/source/gameengine/Ketsji/BL_ActionManager.h @@ -31,7 +31,7 @@ #include "BL_Action.h" -#define MAX_ACTION_LAYERS 4 +#define MAX_ACTION_LAYERS 8 /** * BL_ActionManager is responsible for handling a KX_GameObject's actions. diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 4f8860f4767..0864fc84a28 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -3055,7 +3055,7 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_GameObject, sendMessage, static void layer_check(short &layer, const char *method_name) { - if (layer < 0 || layer > MAX_ACTION_LAYERS) + if (layer < 0 || layer >= MAX_ACTION_LAYERS) { printf("KX_GameObject.%s(): given layer (%d) is out of range (0 - %d), setting to 0.\n", method_name, layer, MAX_ACTION_LAYERS-1); layer = 0; -- cgit v1.2.3 From 750e754604eac5048dbb0ec6ee436d6a12156808 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Tue, 16 Aug 2011 22:14:55 +0000 Subject: Adding ANIM_validate_keyingset to stubs.c so the Blenderplayer builds again. --- source/blenderplayer/bad_level_call_stubs/stubs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source') diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 45e0f526708..fdf45293e9a 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -229,6 +229,7 @@ int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks){re struct ListBase builtin_keyingsets; void ANIM_keyingset_info_register (struct KeyingSetInfo *ksi){} void ANIM_keyingset_info_unregister (const struct bContext *C, struct KeyingSetInfo *ksi){} +short ANIM_validate_keyingset (struct bContext *C, struct ListBase *dsources, struct KeyingSet *ks){return 0;} short ANIM_add_driver(struct ID *id, const char rna_path[], int array_index, short flag, int type){return 0;} short ANIM_remove_driver (struct ID *id, const char rna_path[], int array_index, short flag){return 0;} void ED_space_image_release_buffer(struct SpaceImage *sima, void *lock){} -- cgit v1.2.3 From db4071d2b6b727857521bd05529fe8141e8bb0a2 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 17 Aug 2011 09:38:50 +0000 Subject: BGE Animations: Lamp and Camera IPOs are now handled like object IPOs, which means lamps and cameras are no longer stuck to just their active action. However, the Blender UI seems a little restrictive in this area. --- .../Converter/BL_BlenderDataConversion.cpp | 10 +- source/gameengine/Converter/KX_IpoConvert.cpp | 137 ++++++++++++--------- source/gameengine/Converter/KX_IpoConvert.h | 8 ++ source/gameengine/Ketsji/BL_Action.cpp | 62 +++++++--- source/gameengine/Ketsji/BL_Action.h | 3 +- 5 files changed, 135 insertions(+), 85 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 9bea3f492c9..aa11e78077a 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1682,8 +1682,6 @@ static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int l gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj, glslmat); - - BL_ConvertLampIpos(la, gamelight, converter); return gamelight; } @@ -1696,8 +1694,6 @@ static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_Blen gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata); gamecamera->SetName(ca->id.name + 2); - BL_ConvertCameraIpos(ca, gamecamera, converter); - return gamecamera; } @@ -2092,8 +2088,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz)); gameobj->NodeSetLocalScale(scale); gameobj->NodeUpdateGS(0); - - BL_ConvertIpos(blenderobject,gameobj,converter); + BL_ConvertMaterialIpos(blenderobject, gameobj, converter); sumolist->Add(gameobj->AddRef()); @@ -2282,8 +2277,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz)); gameobj->NodeSetLocalScale(scale); gameobj->NodeUpdateGS(0); - - BL_ConvertIpos(blenderobject,gameobj,converter); + BL_ConvertMaterialIpos(blenderobject,gameobj, converter); sumolist->Add(gameobj->AddRef()); diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 0e526bc818d..2793b8e9fdf 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -207,93 +207,108 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend } } -void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_BlenderSceneConverter *converter) +SG_Controller *BL_CreateLampIPO(struct bAction *action, KX_GameObject* lightobj, KX_BlenderSceneConverter *converter) { + KX_LightIpoSGController* ipocontr = new KX_LightIpoSGController(); - if (blenderlamp->adt) { + Lamp *blenderlamp = (Lamp*)lightobj->GetBlenderObject()->data; - KX_LightIpoSGController* ipocontr = new KX_LightIpoSGController(); - lightobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(lightobj->GetSGNode()); - - ipocontr->m_energy = blenderlamp->energy; - ipocontr->m_col_rgb[0] = blenderlamp->r; - ipocontr->m_col_rgb[1] = blenderlamp->g; - ipocontr->m_col_rgb[2] = blenderlamp->b; - ipocontr->m_dist = blenderlamp->dist; + ipocontr->m_energy = blenderlamp->energy; + ipocontr->m_col_rgb[0] = blenderlamp->r; + ipocontr->m_col_rgb[1] = blenderlamp->g; + ipocontr->m_col_rgb[2] = blenderlamp->b; + ipocontr->m_dist = blenderlamp->dist; - BL_InterpolatorList *adtList= GetAdtList(blenderlamp->adt->action, converter); + BL_InterpolatorList *adtList= GetAdtList(action, converter); - // For each active channel in the adtList add an - // interpolator to the game object. + // For each active channel in the adtList add an + // interpolator to the game object. - KX_IInterpolator *interpolator; - KX_IScalarInterpolator *interp; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - if ((interp= adtList->GetScalarInterpolator("energy", 0))) { - interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyEnergy(true); - } + if ((interp= adtList->GetScalarInterpolator("energy", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_energy, interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyEnergy(true); + } - if ((interp = adtList->GetScalarInterpolator("distance", 0))) { - interpolator= new KX_ScalarInterpolator(&ipocontr->m_dist, interp); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyDist(true); - } + if ((interp = adtList->GetScalarInterpolator("distance", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_dist, interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyDist(true); + } - for(int i=0; i<3; i++) { - if ((interp = adtList->GetScalarInterpolator("color", i))) { - interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyColor(true); - } + for(int i=0; i<3; i++) { + if ((interp = adtList->GetScalarInterpolator("color", i))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_col_rgb[i], interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyColor(true); } } + + return ipocontr; } +void BL_ConvertLampIpos(struct Lamp* blenderlamp, KX_GameObject *lightobj,KX_BlenderSceneConverter *converter) +{ + if (blenderlamp->adt) { + SG_Controller* ipocontr = BL_CreateLampIPO(blenderlamp->adt->action, lightobj, converter); + lightobj->GetSGNode()->AddSGController(ipocontr); + ipocontr->SetObject(lightobj->GetSGNode()); + + + } +} -void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj,KX_BlenderSceneConverter *converter) +SG_Controller *BL_CreateCameraIPO(struct bAction *action, KX_GameObject* cameraobj, KX_BlenderSceneConverter *converter) { + KX_CameraIpoSGController* ipocontr = new KX_CameraIpoSGController(); - if (blendercamera->adt) { + Camera *blendercamera = (Camera*)cameraobj->GetBlenderObject()->data; - KX_CameraIpoSGController* ipocontr = new KX_CameraIpoSGController(); - cameraobj->GetSGNode()->AddSGController(ipocontr); - ipocontr->SetObject(cameraobj->GetSGNode()); - - ipocontr->m_lens = blendercamera->lens; - ipocontr->m_clipstart = blendercamera->clipsta; - ipocontr->m_clipend = blendercamera->clipend; + ipocontr->m_lens = blendercamera->lens; + ipocontr->m_clipstart = blendercamera->clipsta; + ipocontr->m_clipend = blendercamera->clipend; - BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt->action, converter); + BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt->action, converter); - // For each active channel in the adtList add an - // interpolator to the game object. + // For each active channel in the adtList add an + // interpolator to the game object. - KX_IInterpolator *interpolator; - KX_IScalarInterpolator *interp; + KX_IInterpolator *interpolator; + KX_IScalarInterpolator *interp; - if ((interp = adtList->GetScalarInterpolator("lens", 0))) { - interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyLens(true); - } + if ((interp = adtList->GetScalarInterpolator("lens", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_lens, interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyLens(true); + } - if ((interp = adtList->GetScalarInterpolator("clip_start", 0))) { - interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipstart, interp); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyClipStart(true); - } + if ((interp = adtList->GetScalarInterpolator("clip_start", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipstart, interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyClipStart(true); + } - if ((interp = adtList->GetScalarInterpolator("clip_end", 0))) { - interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipend, interp); - ipocontr->AddInterpolator(interpolator); - ipocontr->SetModifyClipEnd(true); - } + if ((interp = adtList->GetScalarInterpolator("clip_end", 0))) { + interpolator= new KX_ScalarInterpolator(&ipocontr->m_clipend, interp); + ipocontr->AddInterpolator(interpolator); + ipocontr->SetModifyClipEnd(true); + } + return ipocontr; +} + +void BL_ConvertCameraIpos(struct Camera* blendercamera, KX_GameObject *cameraobj,KX_BlenderSceneConverter *converter) +{ + + if (blendercamera->adt) { + SG_Controller* ipocontr = BL_CreateCameraIPO(blendercamera->adt->action, cameraobj, converter); + cameraobj->GetSGNode()->AddSGController(ipocontr); + ipocontr->SetObject(cameraobj->GetSGNode()); } } diff --git a/source/gameengine/Converter/KX_IpoConvert.h b/source/gameengine/Converter/KX_IpoConvert.h index 914422ba83f..60e695c68a7 100644 --- a/source/gameengine/Converter/KX_IpoConvert.h +++ b/source/gameengine/Converter/KX_IpoConvert.h @@ -44,6 +44,10 @@ void BL_ConvertIpos(struct Object* blenderobject, class KX_GameObject* gameobj, class KX_BlenderSceneConverter *converter); +class SG_Controller *BL_CreateLampIPO(struct bAction *action, + class KX_GameObject* lightobj, + class KX_BlenderSceneConverter *converter); + void BL_ConvertLampIpos(struct Lamp* blenderlight, class KX_GameObject* lightobj, class KX_BlenderSceneConverter *converter); @@ -51,6 +55,10 @@ void BL_ConvertLampIpos(struct Lamp* blenderlight, void BL_ConvertWorldIpos(struct World* blenderworld, class KX_BlenderSceneConverter *converter); +class SG_Controller *BL_CreateCameraIPO(struct bAction *action, + class KX_GameObject* cameraobj, + class KX_BlenderSceneConverter *converter); + void BL_ConvertCameraIpos(struct Camera* blendercamera, class KX_GameObject* cameraobj, class KX_BlenderSceneConverter *converter); diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index 6682b0cea41..08794042e37 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -54,7 +54,6 @@ BL_Action::BL_Action(class KX_GameObject* gameobj) m_blendpose(NULL), m_blendinpose(NULL), m_ptrrna(NULL), - m_sg_contr(NULL), m_obj(gameobj), m_startframe(0.f), m_endframe(0.f), @@ -98,13 +97,22 @@ BL_Action::~BL_Action() game_free_pose(m_blendpose); if (m_blendinpose) game_free_pose(m_blendinpose); - if (m_sg_contr) - { - m_obj->GetSGNode()->RemoveSGController(m_sg_contr); - delete m_sg_contr; - } if (m_ptrrna) delete m_ptrrna; + ClearControllerList(); +} + +void BL_Action::ClearControllerList() +{ + // Clear out the controller list + std::vector::iterator it; + for (it = m_sg_contr_list.begin(); it != m_sg_contr_list.end(); it++) + { + m_obj->GetSGNode()->RemoveSGController((*it)); + delete *it; + } + + m_sg_contr_list.clear(); } bool BL_Action::Play(const char* name, @@ -136,10 +144,30 @@ bool BL_Action::Play(const char* name, if (prev_action != m_action) { + // First get rid of any old controllers + ClearControllerList(); + // Create an SG_Controller - m_sg_contr = BL_CreateIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter()); - m_obj->GetSGNode()->AddSGController(m_sg_contr); - m_sg_contr->SetObject(m_obj->GetSGNode()); + SG_Controller *sg_contr = BL_CreateIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter()); + m_sg_contr_list.push_back(sg_contr); + m_obj->GetSGNode()->AddSGController(sg_contr); + sg_contr->SetObject(m_obj->GetSGNode()); + + // Extra controllers + if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_LIGHT) + { + sg_contr = BL_CreateLampIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter()); + m_sg_contr_list.push_back(sg_contr); + m_obj->GetSGNode()->AddSGController(sg_contr); + sg_contr->SetObject(m_obj->GetSGNode()); + } + else if (m_obj->GetGameObjectType() == SCA_IObject::OBJ_CAMERA) + { + sg_contr = BL_CreateCameraIPO(m_action, m_obj, KX_GetActiveScene()->GetSceneConverter()); + m_sg_contr_list.push_back(sg_contr); + m_obj->GetSGNode()->AddSGController(sg_contr); + sg_contr->SetObject(m_obj->GetSGNode()); + } } m_ipo_flags = ipo_flags; @@ -197,11 +225,15 @@ bool BL_Action::IsDone() void BL_Action::InitIPO() { - // Initialize the IPO - m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true); - m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, m_ipo_flags & ACT_IPOFLAG_FORCE); - m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, m_ipo_flags & ACT_IPOFLAG_ADD); - m_sg_contr->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, m_ipo_flags & ACT_IPOFLAG_LOCAL); + // Initialize the IPOs + std::vector::iterator it; + for (it = m_sg_contr_list.begin(); it != m_sg_contr_list.end(); it++) + { + (*it)->SetOption(SG_Controller::SG_CONTR_IPO_RESET, true); + (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, m_ipo_flags & ACT_IPOFLAG_FORCE); + (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_ADD, m_ipo_flags & ACT_IPOFLAG_ADD); + (*it)->SetOption(SG_Controller::SG_CONTR_IPO_LOCAL, m_ipo_flags & ACT_IPOFLAG_LOCAL); + } } bAction *BL_Action::GetAction() @@ -330,7 +362,7 @@ void BL_Action::Update(float curtime) break; } - if (!m_done && m_sg_contr) + if (!m_done) InitIPO(); } diff --git a/source/gameengine/Ketsji/BL_Action.h b/source/gameengine/Ketsji/BL_Action.h index 75bda56419a..92fbe95fd54 100644 --- a/source/gameengine/Ketsji/BL_Action.h +++ b/source/gameengine/Ketsji/BL_Action.h @@ -45,7 +45,7 @@ private: struct bPose* m_blendpose; struct bPose* m_blendinpose; struct PointerRNA *m_ptrrna; - class SG_Controller *m_sg_contr; + std::vector m_sg_contr_list; class KX_GameObject* m_obj; std::vector m_blendshape; std::vector m_blendinshape; @@ -73,6 +73,7 @@ private: bool m_done; bool m_calc_localtime; + void ClearControllerList(); void InitIPO(); void SetLocalTime(float curtime); void ResetStartTime(float curtime); -- cgit v1.2.3 From f3c05e8eb267b3c005cf7255b222ed7bf8972744 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Wed, 17 Aug 2011 18:28:01 +0000 Subject: armature animation export fix. --- source/blender/collada/AnimationExporter.cpp | 192 +++++++++++++-------------- source/blender/collada/AnimationExporter.h | 14 +- source/blender/collada/TransformWriter.cpp | 11 +- 3 files changed, 102 insertions(+), 115 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index e76d7c0cfa6..b39e9bb39d5 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -61,18 +61,19 @@ void AnimationExporter::exportAnimations(Scene *sce) bool isMatAnim = false; //Export transform animations - if(ob->adt && ob->adt->action) + if(ob->adt && ob->adt->action) { //transform matrix export for bones are temporarily disabled here. - /*if ( ob->type == OB_ARMATURE ) + if ( ob->type == OB_ARMATURE ) { bArmature *arm = (bArmature*)ob->data; for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) write_bone_animation_matrix(ob, bone); - - }*/ + + } + else { fcu = (FCurve*)ob->adt->action->curves.first; - while (fcu) { + while (fcu) { transformName = extract_transform_name( fcu->rna_path ); if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || @@ -81,6 +82,7 @@ void AnimationExporter::exportAnimations(Scene *sce) dae_animation(ob ,fcu, transformName, false); fcu = fcu->next; } + } } //Export Lamp parameter animations @@ -117,7 +119,7 @@ void AnimationExporter::exportAnimations(Scene *sce) { Material *ma = give_current_material(ob, a+1); if (!ma) continue; - if(ma->adt && ma->adt->action) + if(ma->adt && ma->adt->action) { isMatAnim = true; fcu = (FCurve*)ma->adt->action->curves.first; @@ -137,8 +139,8 @@ void AnimationExporter::exportAnimations(Scene *sce) if (!ob->adt || !ob->adt->action) fcu = (FCurve*)((Lamp*)ob->data)->adt->action->curves.first; //this is already checked in hasAnimations() else - fcu = (FCurve*)ob->adt->action->curves.first; - + fcu = (FCurve*)ob->adt->action->curves.first; + if (ob->type == OB_ARMATURE) { if (!ob->data) return; bArmature *arm = (bArmature*)ob->data; @@ -225,7 +227,7 @@ void AnimationExporter::exportAnimations(Scene *sce) //axis names for colors else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")|| - (!strcmp(transformName, "alpha"))) + (!strcmp(transformName, "alpha"))) { const char *axis_names[] = {"R", "G", "B"}; if (fcu->array_index < 3) @@ -248,10 +250,10 @@ void AnimationExporter::exportAnimations(Scene *sce) std::string ob_name = std::string("null"); - //Create anim Id + //Create anim Id if (ob->type == OB_ARMATURE) { - ob_name = getObjectBoneName( ob , fcu); + ob_name = getObjectBoneName( ob , fcu); BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(), transformName, axis_name); } @@ -272,11 +274,11 @@ void AnimationExporter::exportAnimations(Scene *sce) // create output source std::string output_id ; - + //quat rotations are skipped for now, because of complications with determining axis. if(quatRotation) { - float * eul = get_eul_source_for_quat(ob); + float * eul = get_eul_source_for_quat(ob); float * eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values"); for ( int i = 0 ; i< fcu->totvert ; i++) eul_axis[i] = eul[i*3 + fcu->array_index]; @@ -348,10 +350,10 @@ void AnimationExporter::exportAnimations(Scene *sce) { if (!ob_arm->adt) return; - + sample_and_write_bone_animation_matrix(ob_arm, bone); - for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) write_bone_animation_matrix(ob_arm, child); } @@ -368,7 +370,7 @@ void AnimationExporter::exportAnimations(Scene *sce) bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); if (!pchan) return; - + find_frames(ob_arm, fra); if (flag & ARM_RESTPOS) { @@ -377,11 +379,7 @@ void AnimationExporter::exportAnimations(Scene *sce) } if (fra.size()) { - float *values = (float*)MEM_callocN(sizeof(float) * 16 * fra.size(), "temp. anim frames"); - sample_animation(values, fra, bone, ob_arm, pchan); - - dae_baked_animation(fra ,values, id_name(ob_arm), bone->name ); - + dae_baked_animation(fra ,ob_arm, bone ); } if (flag & ARM_RESTPOS) @@ -389,60 +387,10 @@ void AnimationExporter::exportAnimations(Scene *sce) where_is_pose(scene, ob_arm); } - - void AnimationExporter::sample_animation(float *v, std::vector &frames, Bone *bone, Object *ob_arm, bPoseChannel *pchan) - { - bPoseChannel *parchan = NULL; - bPose *pose = ob_arm->pose; - - pchan = get_pose_channel(pose, bone->name); - - if (!pchan) - return; - - parchan = pchan->parent; - - enable_fcurves(ob_arm->adt->action, bone->name); - - std::vector::iterator it; - int j = 0; - for (it = frames.begin(); it != frames.end(); it++) { - float mat[4][4], ipar[4][4]; - - float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); - - //BKE_animsys_evaluate_animdata(&ob_arm->id, ob_arm->adt, *it, ADT_RECALC_ANIM); - BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); - - // compute bone local mat - if (bone->parent) { - invert_m4_m4(ipar, parchan->pose_mat); - mul_m4_m4m4(mat, pchan->pose_mat, ipar); - } - else - copy_m4_m4(mat, pchan->pose_mat); - - for ( int i = 0; i < 4 ; i++) - { - for ( int k = 0; k<4 ; k++ ) - { - v[j*16 + 4*i + k] = mat[i][k]; - } - - } - // copy_m4_m4(v[j*16 + i], mat ) ; - - j++; - } - - enable_fcurves(ob_arm->adt->action, NULL); - - - } - - void AnimationExporter::dae_baked_animation(std::vector &fra, float *values, std::string ob_name, std::string bone_name) + void AnimationExporter::dae_baked_animation(std::vector &fra, Object *ob_arm , Bone *bone) { + std::string ob_name = id_name(ob_arm); + std::string bone_name = bone->name; char anim_id[200]; if (!fra.size()) @@ -458,7 +406,7 @@ void AnimationExporter::exportAnimations(Scene *sce) // create output source std::string output_id; - output_id = create_4x4_source( values, fra.size(), anim_id); + output_id = create_4x4_source( fra, ob_arm , bone , anim_id); // create interpolations source std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, ""); @@ -629,8 +577,8 @@ void AnimationExporter::exportAnimations(Scene *sce) // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data values[0] = 0; values[1] = 0; - } - else if (rotation) { + } + else if (rotation) { values[1] = (bezt->vec[0][1]) * 180.0f/M_PI; } else { values[1] = bezt->vec[0][1]; @@ -702,7 +650,7 @@ void AnimationExporter::exportAnimations(Scene *sce) return source_id; } - //Currently called only to get OUTPUT source values ( if rotation and hence the axis is also specified ) + //Currently called only to get OUTPUT source values ( if rotation and hence the axis is also specified ) std::string AnimationExporter::create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name) { std::string source_id = anim_id + get_semantic_suffix(semantic); @@ -763,7 +711,7 @@ void AnimationExporter::exportAnimations(Scene *sce) return source_id; } - std::string AnimationExporter::create_4x4_source(float *v, int tot, const std::string& anim_id) + std::string AnimationExporter::create_4x4_source(std::vector &frames , Object * ob_arm, Bone *bone , const std::string& anim_id) { COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; std::string source_id = anim_id + get_semantic_suffix(semantic); @@ -771,20 +719,58 @@ void AnimationExporter::exportAnimations(Scene *sce) COLLADASW::Float4x4Source source(mSW); source.setId(source_id); source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(tot); + source.setAccessorCount(frames.size()); source.setAccessorStride(16); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); add_source_parameters(param, semantic, false, NULL, false); source.prepareToAppendValues(); + + bPoseChannel *parchan = NULL; + bPoseChannel *pchan = NULL; + bPose *pose = ob_arm->pose; - for (int i = 0; i < tot; i++) { - for ( int j = 0 ; j < 4 ; j++ ) - source.appendValues(*(v+j*4), *(v + 4*j +1), *(v + 2 + 4*j), *(v+3 + 4*j)); - v += 16; + pchan = get_pose_channel(pose, bone->name); + + if (!pchan) + return ""; + + parchan = pchan->parent; + + enable_fcurves(ob_arm->adt->action, bone->name); + + std::vector::iterator it; + int j = 0; + for (it = frames.begin(); it != frames.end(); it++) { + float mat[4][4], ipar[4][4]; + + float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + + BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + + // compute bone local mat + if (bone->parent) { + invert_m4_m4(ipar, parchan->pose_mat); + mul_m4_m4m4(mat, pchan->pose_mat, ipar); + } + else + copy_m4_m4(mat, pchan->pose_mat); + UnitConverter converter; + + float outmat[4][4]; + converter.mat4_to_dae(outmat,mat); + + + source.appendValues(outmat); + + + j++; } + enable_fcurves(ob_arm->adt->action, NULL); + source.finish(); return source_id; @@ -877,7 +863,7 @@ void AnimationExporter::exportAnimations(Scene *sce) std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) { std::string tm_name; - // when given rna_path, determine tm_type from it + // when given rna_path, determine tm_type from it if (rna_path) { char *name = extract_transform_name(rna_path); @@ -911,7 +897,7 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_name = ""; break; } - + if (tm_name.size()) { if (axis_name != "") return tm_name + "." + std::string(axis_name); @@ -925,13 +911,13 @@ void AnimationExporter::exportAnimations(Scene *sce) std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) { std::string tm_name; - // when given rna_path, determine tm_type from it + // when given rna_path, determine tm_type from it if (rna_path) { char *name = extract_transform_name(rna_path); - if (!strcmp(name, "lens")) + if (!strcmp(name, "lens")) tm_type = 0; - else if (!strcmp(name, "ortho_scale")) + else if (!strcmp(name, "ortho_scale")) tm_type = 1; else if (!strcmp(name, "clip_end")) tm_type = 2; @@ -960,7 +946,7 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_name = ""; break; } - + if (tm_name.size()) { if (axis_name != "") return tm_name + "." + std::string(axis_name); @@ -971,12 +957,12 @@ void AnimationExporter::exportAnimations(Scene *sce) return std::string(""); } - // Assign sid of the animated parameter or transform + // Assign sid of the animated parameter or transform // for rotation, axis name is always appended and the value of append_axis is ignored std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) { std::string tm_name; - bool is_rotation =false; + bool is_rotation =false; // when given rna_path, determine tm_type from it if (rna_path) { char *name = extract_transform_name(rna_path); @@ -1010,7 +996,7 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_name = "rotation"; is_rotation = true; break; - case 2: + case 2: tm_name = "scale"; break; case 3: @@ -1036,7 +1022,7 @@ void AnimationExporter::exportAnimations(Scene *sce) tm_name = ""; break; } - + if (tm_name.size()) { if (is_rotation) return tm_name + std::string(axis_name) + ".ANGLE"; @@ -1074,7 +1060,7 @@ void AnimationExporter::exportAnimations(Scene *sce) std::sort(fra.begin(), fra.end()); } - + // enable fcurves driving a specific bone, disable all the rest // if bone_name = NULL enable all fcurves @@ -1118,11 +1104,11 @@ void AnimationExporter::exportAnimations(Scene *sce) fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); //Check Material Effect parameter animations. - for(int a = 0; a < ob->totcol; a++) + for(int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); if (!ma) continue; - if(ma->adt && ma->adt->action) + if(ma->adt && ma->adt->action) { fcu = (FCurve*)ma->adt->action->curves.first; } @@ -1171,14 +1157,14 @@ void AnimationExporter::exportAnimations(Scene *sce) { if (!ob_arm->adt) return; - + //write bone animations for 3 transform types //i=0 --> rotations //i=1 --> scale //i=2 --> location for (int i = 0; i < 3; i++) sample_and_write_bone_animation(ob_arm, bone, i); - + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) write_bone_animation(ob_arm, child); } @@ -1195,7 +1181,7 @@ void AnimationExporter::exportAnimations(Scene *sce) bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); if (!pchan) return; - //Fill frame array with key frame values framed at @param:transform_type + //Fill frame array with key frame values framed at @param:transform_type switch (transform_type) { case 0: find_rotation_frames(ob_arm, fra, prefix, pchan->rotmode); @@ -1215,7 +1201,7 @@ void AnimationExporter::exportAnimations(Scene *sce) arm->flag &= ~ARM_RESTPOS; where_is_pose(scene, ob_arm); } - //v array will hold all values which will be exported. + //v array will hold all values which will be exported. if (fra.size()) { float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames"); sample_animation(values, fra, transform_type, bone, ob_arm, pchan); @@ -1266,8 +1252,8 @@ void AnimationExporter::exportAnimations(Scene *sce) float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); - //BKE_animsys_evaluate_animdata(&ob_arm->id, ob_arm->adt, *it, ADT_RECALC_ANIM); - //BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + + BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); // compute bone local mat diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 6786206ee6f..c628e5633b7 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -85,7 +85,7 @@ private: public: AnimationExporter(COLLADASW::StreamWriter *sw): COLLADASW::LibraryAnimations(sw) { this->sw = sw; } - + void exportAnimations(Scene *sce); @@ -106,13 +106,13 @@ protected: void sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pChan); - void sample_animation(float *v, std::vector &frames, Bone *bone, Object *ob_arm, bPoseChannel *pChan); + void sample_animation(std::vector &mats, std::vector &frames, Bone *bone, Object *ob_arm, bPoseChannel *pChan); // dae_bone_animation -> add_bone_animation // (blend this into dae_bone_animation) void dae_bone_animation(std::vector &fra, float *v, int tm_type, int axis, std::string ob_name, std::string bone_name); - - void dae_baked_animation(std::vector &fra, float *values, std::string ob_name, std::string bone_name); + + void dae_baked_animation(std::vector &fra, Object *ob_arm , Bone *bone); float convert_time(float frame); @@ -123,9 +123,9 @@ protected: void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis , bool transform); - void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length); + void get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length); - float * get_eul_source_for_quat(Object *ob ); + float * get_eul_source_for_quat(Object *ob ); std::string create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name); @@ -135,7 +135,7 @@ protected: std::string create_xyz_source(float *v, int tot, const std::string& anim_id); - std::string create_4x4_source(float *v, int tot, const std::string& anim_id); + std::string create_4x4_source(std::vector &frames , Object * ob_arm, Bone *bone , const std::string& anim_id); std::string create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents); diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index 3ac0654c866..7bad9bdeba7 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -49,13 +49,14 @@ void TransformWriter::add_node_transform(COLLADASW::Node& node, float mat[][4], } double dmat[4][4]; - for ( int i = 0 ; i< 4 ; i ++ ) - for ( int j =0 ; j < 4 ; j++) - dmat[i][j] = (double)local[i][j]; + UnitConverter* converter = new UnitConverter(); + converter->mat4_to_dae_double(dmat,local); TransformBase::decompose(local, loc, rot, NULL, scale); - node.addMatrix("transform",dmat); - add_transform(node, loc, rot, scale); + if ( node.getType() == COLLADASW::Node::JOINT) + node.addMatrix("transform",dmat); + else + add_transform(node, loc, rot, scale); } void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob) -- cgit v1.2.3 From e86e922f5b6d7c3784bb6ffb840e08336ff42027 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Wed, 17 Aug 2011 18:29:01 +0000 Subject: Armature importer code cleanup. --- source/blender/collada/AnimationImporter.cpp | 161 ++++----------------------- source/blender/collada/AnimationImporter.h | 4 +- source/blender/collada/DocumentImporter.cpp | 2 +- 3 files changed, 23 insertions(+), 144 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 29bd0bd93b7..a0202fdcb1b 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -183,6 +183,7 @@ void AnimationImporter::fcurve_deg_to_rad(FCurve *cu) } } + void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector& curves, char *rna_path, int array_index, Animation *animated) { bAction *act; @@ -318,120 +319,7 @@ bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList* ani // for bones rna_path is like: pose.bones["bone-name"].rotation - // what does this AnimationList animate? - Animation& animated = uid_animated_map[animlist_id]; - Object *ob = animated.ob; - - char rna_path[100]; - char joint_path[100]; - bool is_joint = false; - - // if ob is NULL, it should be a JOINT - if (!ob) { - - ob = armature_importer->get_armature_for_joint(animated.node); - - if (!ob) { -// fprintf(stderr, "Cannot find armature for node %s\n", get_joint_name(animated.node)); - return true; - } - - armature_importer->get_rna_path_for_joint(animated.node, joint_path, sizeof(joint_path)); - - is_joint = true; - } - printf("object for animlist: %s found\n", animlist->getUniqueId().toAscii().c_str()); - const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); - - switch (animated.tm->getTransformationType()) { - case COLLADAFW::Transformation::TRANSLATE: - case COLLADAFW::Transformation::SCALE: - { - bool loc = animated.tm->getTransformationType() == COLLADAFW::Transformation::TRANSLATE; - if (is_joint) - BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, loc ? "location" : "scale"); - else - BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path)); - - for (int i = 0; i < bindings.getCount(); i++) { - const COLLADAFW::AnimationList::AnimationBinding& binding = bindings[i]; - COLLADAFW::UniqueId anim_uid = binding.animation; - - if (curve_map.find(anim_uid) == curve_map.end()) { - fprintf(stderr, "Cannot find FCurve by animation UID.\n"); - continue; - } - std::vector& fcurves = curve_map[anim_uid]; - - switch (binding.animationClass) { - case COLLADAFW::AnimationList::POSITION_X: - add_fcurves_to_object(ob, fcurves, rna_path, 0, &animated); - break; - case COLLADAFW::AnimationList::POSITION_Y: - add_fcurves_to_object(ob, fcurves, rna_path, 1, &animated); - break; - case COLLADAFW::AnimationList::POSITION_Z: - add_fcurves_to_object(ob, fcurves, rna_path, 2, &animated); - break; - case COLLADAFW::AnimationList::POSITION_XYZ: - add_fcurves_to_object(ob, fcurves, rna_path, -1, &animated); - break; - default: - fprintf(stderr, "AnimationClass %d is not supported for %s.\n", - binding.animationClass, loc ? "TRANSLATE" : "SCALE"); - } - } - } - break; - case COLLADAFW::Transformation::ROTATE: - { - if (is_joint) - BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path); - else - BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path)); - - COLLADAFW::Rotate* rot = (COLLADAFW::Rotate*)animated.tm; - COLLADABU::Math::Vector3& axis = rot->getRotationAxis(); - - for (int i = 0; i < bindings.getCount(); i++) { - const COLLADAFW::AnimationList::AnimationBinding& binding = bindings[i]; - COLLADAFW::UniqueId anim_uid = binding.animation; - - if (curve_map.find(anim_uid) == curve_map.end()) { - fprintf(stderr, "Cannot find FCurve by animation UID.\n"); - continue; - } - - std::vector& fcurves = curve_map[anim_uid]; - - switch (binding.animationClass) { - case COLLADAFW::AnimationList::ANGLE: - if (COLLADABU::Math::Vector3::UNIT_X == axis) { - add_fcurves_to_object(ob, fcurves, rna_path, 0, &animated); - } - else if (COLLADABU::Math::Vector3::UNIT_Y == axis) { - add_fcurves_to_object(ob, fcurves, rna_path, 1, &animated); - } - else if (COLLADABU::Math::Vector3::UNIT_Z == axis) { - add_fcurves_to_object(ob, fcurves, rna_path, 2, &animated); - } - break; - case COLLADAFW::AnimationList::AXISANGLE: - // TODO convert axis-angle to quat? or XYZ? - default: - fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n", - binding.animationClass); - } - } - } - break; - case COLLADAFW::Transformation::MATRIX: - case COLLADAFW::Transformation::SKEW: - case COLLADAFW::Transformation::LOOKAT: - fprintf(stderr, "Animation of MATRIX, SKEW and LOOKAT transformations is not supported yet.\n"); - break; - } #endif return true; @@ -675,14 +563,16 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * } }*/ + break; case COLLADAFW::Transformation::SKEW: case COLLADAFW::Transformation::LOOKAT: - fprintf(stderr, "Animation of MATRIX, SKEW and LOOKAT transformations is not supported yet.\n"); + fprintf(stderr, "Animation of SKEW and LOOKAT transformations is not supported yet.\n"); break; } } +//creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation. void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves ,char * anim_type) { char rna_path[100]; @@ -694,8 +584,6 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { animcurves = curve_map[bindings[j].animation]; - //calculate rnapaths and array index of fcurves according to transformation and animation class - //Assign_color_animations( &bindings[j], &animcurves); switch (bindings[j].animationClass) { case COLLADAFW::AnimationList::COLOR_R: @@ -708,7 +596,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list modify_fcurve(&animcurves, rna_path, 2 ); break; case COLLADAFW::AnimationList::COLOR_RGB: - case COLLADAFW::AnimationList::COLOR_RGBA: + case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity modify_fcurve(&animcurves, rna_path, -1 ); break; @@ -734,14 +622,14 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list if (animlist_map.find(listid) == animlist_map.end()) return ; else { - //transformation has animations + //anim_type has animations const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); //all the curves belonging to the current binding std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { animcurves = curve_map[bindings[j].animation]; - //calculate rnapaths and array index of fcurves according to transformation and animation class + BLI_strncpy(rna_path, anim_type , sizeof(rna_path)); modify_fcurve(&animcurves, rna_path, 0 ); std::vector::iterator iter; @@ -815,16 +703,11 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& newcu[i]->totvert = frames.size(); } -// Object *job = NULL; - - if (frames.size() == 0) + if (frames.size() == 0) return; std::sort(frames.begin(), frames.end()); - //if (is_joint) - // armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); - - + std::vector::iterator it; // sample values at each frame @@ -863,10 +746,10 @@ std::sort(frames.begin(), frames.end()); float rot[4], loc[3], scale[3]; mat4_to_quat(rot, mat); - for ( int i = 0 ; i < 4 ; i ++ ) + /*for ( int i = 0 ; i < 4 ; i ++ ) { rot[i] = rot[i] * (180 / M_PI); - } + }*/ copy_v3_v3(loc, mat[3]); mat4_to_size(scale, mat); @@ -904,7 +787,7 @@ std::sort(frames.begin(), frames.end()); } -void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , +void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , std::map& root_map, std::map& object_map, std::map FW_object_map) @@ -923,7 +806,6 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , bAction * act; bActionGroup *grp = NULL; - //if ( (animType & NODE_TRANSFORM) != 0 ) if ( (animType->transform) != 0 ) { const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; @@ -934,10 +816,10 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1); - else act = ob->adt->action; - //Get the list of animation curves of the object - - ListBase *AnimCurves = &(act->curves); + else act = ob->adt->action; + + //Get the list of animation curves of the object + ListBase *AnimCurves = &(act->curves); const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations(); @@ -1197,7 +1079,7 @@ int AnimationImporter::setAnimType ( const COLLADAFW::Animatable * prop , int ty else return types; } -//XXX Is not used anymore. +// Is not used anymore. void AnimationImporter::find_frames_old(std::vector * frames, COLLADAFW::Node * node , COLLADAFW::Transformation::TransformationType tm_type) { bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX; @@ -1257,10 +1139,11 @@ void AnimationImporter::find_frames_old(std::vector * frames, COLLADAFW:: } + // prerequisites: // animlist_map - map animlist id -> animlist // curve_map - map anim id -> curve(s) -Object *AnimationImporter::translate_animation(COLLADAFW::Node *node, +Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node, std::map& object_map, std::map& root_map, COLLADAFW::Transformation::TransformationType tm_type, @@ -1513,7 +1396,7 @@ Object *AnimationImporter::translate_animation(COLLADAFW::Node *node, } // internal, better make it private -// warning: evaluates only rotation +// warning: evaluates only rotation and only assigns matrix transforms now // prerequisites: animlist_map, curve_map void AnimationImporter::evaluate_transform_at_frame(float mat[4][4], COLLADAFW::Node *node, float fra) { @@ -1867,7 +1750,3 @@ void AnimationImporter::add_bezt(FCurve *fcu, float fra, float value) calchandles_fcurve(fcu); } -void AnimationImporter::extra_data_importer(std::string elementName ) -{ - -} diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index fbb53ceedb6..18303eb2f0b 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -145,7 +145,7 @@ public: virtual void change_eul_to_quat(Object *ob, bAction *act); #endif - void translate_Animations_NEW ( COLLADAFW::Node * Node , + void translate_Animations( COLLADAFW::Node * Node , std::map& root_map, std::map& object_map , std::map FW_object_map); @@ -168,7 +168,7 @@ public: // prerequisites: // animlist_map - map animlist id -> animlist // curve_map - map anim id -> curve(s) - Object * translate_animation(COLLADAFW::Node *node, + Object * translate_animation_OLD(COLLADAFW::Node *node, std::map& object_map, std::map& root_map, COLLADAFW::Transformation::TransformationType tm_type, diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index f6c985626db..3a92c95e7ee 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -252,7 +252,7 @@ void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW //for (i = 0; i < 4; i++) //ob = - anim_importer.translate_Animations_NEW(node, root_map, object_map, FW_object_map); + anim_importer.translate_Animations(node, root_map, object_map, FW_object_map); COLLADAFW::NodePointerArray &children = node->getChildNodes(); for (i = 0; i < children.getCount(); i++) { -- cgit v1.2.3 From a46f36c9b6c22d0082f820847c1b60acdf17c08b Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Wed, 17 Aug 2011 20:15:40 +0000 Subject: Animation export id bone animation + armature importer cleanup. --- source/blender/collada/AnimationExporter.cpp | 13 ++++++- source/blender/collada/ArmatureImporter.cpp | 55 +++++++++++++++------------- 2 files changed, 41 insertions(+), 27 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index b39e9bb39d5..7bcb225e3c2 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -66,6 +66,7 @@ void AnimationExporter::exportAnimations(Scene *sce) //transform matrix export for bones are temporarily disabled here. if ( ob->type == OB_ARMATURE ) { + if (!ob->data) return; bArmature *arm = (bArmature*)ob->data; for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) write_bone_animation_matrix(ob, bone); @@ -363,10 +364,18 @@ void AnimationExporter::exportAnimations(Scene *sce) bArmature *arm = (bArmature*)ob_arm->data; int flag = arm->flag; std::vector fra; - char prefix[256]; + //char prefix[256]; - BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); + FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first; + while(fcu) + { + std::string bone_name = getObjectBoneName(ob_arm,fcu); + int val = BLI_strcasecmp((char*)bone_name.c_str(),bone->name); + if(val==0) break; + fcu = fcu->next; + } + if(!(fcu)) return; bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); if (!pchan) return; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 7acae995396..81d785371df 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -93,16 +93,16 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p EditBone *bone = ED_armature_edit_bone_add((bArmature*)ob_arm->data, (char*)bc_get_joint_name(node)); totbone++; - + bPoseChannel *pchan = get_pose_channel(ob_arm->pose, (char*)bc_get_joint_name(node)); if (parent) bone->parent = parent; - float ax[3]; + float angle = 0; // get world-space if (parent){ - mul_m4_m4m4(mat, obmat, parent_mat); + mul_m4_m4m4(mat, obmat, parent_mat); } else { @@ -116,7 +116,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p // set head copy_v3_v3(bone->head, mat[3]); - + // set tail, don't set it to head because 0-length bones are not allowed float vec[3] = {0.0f, 0.5f, 0.0f}; add_v3_v3v3(bone->tail, bone->head, vec); @@ -127,7 +127,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p // not setting BONE_CONNECTED because this would lock child bone location with respect to parent // bone->flag |= BONE_CONNECTED; - + // XXX increase this to prevent "very" small bones? const float epsilon = 0.000001f; @@ -166,6 +166,10 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo float mat[4][4]; + // TODO rename from Node "name" attrs later + EditBone *bone = ED_armature_edit_bone_add(arm, (char*)bc_get_joint_name(node)); + totbone++; + if (skin.get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) { // get original world-space matrix invert_m4_m4(mat, joint_inv_bind_mat); @@ -182,12 +186,14 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo mul_m4_m4m4(mat, obmat, parent_mat); else copy_m4_m4(mat, obmat); - } - // TODO rename from Node "name" attrs later - EditBone *bone = ED_armature_edit_bone_add(arm, (char*)bc_get_joint_name(node)); - totbone++; + float loc[3], size[3], rot[3][3] , angle; + mat4_to_loc_rot_size( loc, rot, size, obmat); + mat3_to_vec_roll(rot, NULL, &angle ); + bone->roll=angle; + } + if (parent) bone->parent = parent; // set head @@ -264,8 +270,8 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: leaf.bone = bone; copy_m4_m4(leaf.mat, mat); BLI_strncpy(leaf.name, bone->name, sizeof(leaf.name)); - - TagsMap::iterator etit; + + TagsMap::iterator etit; ExtraTags *et = 0; etit = uid_tags_map.find(node->getUniqueId().toAscii()); if(etit != uid_tags_map.end()) @@ -277,7 +283,7 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: et->setData("tip_y",&y); et->setData("tip_z",&z); float vec[3] = {x,y,z}; - copy_v3_v3(leaf.bone->tail, leaf.bone->head); + copy_v3_v3(leaf.bone->tail, leaf.bone->head); add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); leaf_bones.push_back(leaf); } @@ -292,7 +298,7 @@ void ArmatureImporter::fix_leaf_bones( ) // pointing up float vec[3] = {0.0f, 0.0f, 1.0f}; - + mul_v3_fl(vec, leaf_bone_length); copy_v3_v3(leaf.bone->tail, leaf.bone->head); @@ -396,10 +402,10 @@ void ArmatureImporter::create_armature_bones( ) { std::vector::iterator ri; //if there is an armature created for root_joint next root_joint - for (ri = root_joints.begin(); ri != root_joints.end(); ri++) { + for (ri = root_joints.begin(); ri != root_joints.end(); ri++) { if ( get_armature_for_joint(*ri) != NULL ) continue; - - //add armature object for current joint + + //add armature object for current joint //Object *ob_arm = add_object(scene, OB_ARMATURE); Object *ob_arm = joint_parent_map[(*ri)->getUniqueId()]; @@ -413,7 +419,7 @@ void ArmatureImporter::create_armature_bones( ) TODO: check if bones have already been created for a given joint */ - leaf_bone_length = FLT_MAX; + leaf_bone_length = FLT_MAX; create_unskinned_bone(*ri, NULL, (*ri)->getChildNodes().getCount(), NULL, ob_arm); //fix_leaf_bones(); @@ -545,7 +551,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin) DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB|OB_RECALC_DATA); // set_leaf_bone_shapes(ob_arm); - // set_euler_rotmode(); + // set_euler_rotmode(); } @@ -572,7 +578,7 @@ void ArmatureImporter::set_pose ( Object * ob_arm , COLLADAFW::Node * root_node // get world-space if (parentname){ - mul_m4_m4m4(mat, obmat, parent_mat); + mul_m4_m4m4(mat, obmat, parent_mat); bPoseChannel *parchan = get_pose_channel(ob_arm->pose, parentname); mul_m4_m4m4(pchan->pose_mat, mat , parchan->pose_mat); @@ -581,12 +587,12 @@ void ArmatureImporter::set_pose ( Object * ob_arm , COLLADAFW::Node * root_node else { copy_m4_m4(mat, obmat); float invObmat[4][4]; - invert_m4_m4(invObmat, ob_arm->obmat); - mul_m4_m4m4(pchan->pose_mat, mat, invObmat); + invert_m4_m4(invObmat, ob_arm->obmat); + mul_m4_m4m4(pchan->pose_mat, mat, invObmat); } - mat4_to_axis_angle(ax,&angle,mat); + mat4_to_axis_angle(ax,&angle,mat); pchan->bone->roll = angle; @@ -651,10 +657,9 @@ void ArmatureImporter::make_armatures(bContext *C) // free memory stolen from SkinControllerData skin.free(); } - + //for bones without skins create_armature_bones(); - } #if 0 @@ -761,7 +766,7 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node) void ArmatureImporter::set_tags_map(TagsMap & tagsMap) { - this->uid_tags_map = tagsMap; + this->uid_tags_map = tagsMap; } void ArmatureImporter::get_rna_path_for_joint(COLLADAFW::Node *node, char *joint_path, size_t count) -- cgit v1.2.3 From 475e0b8c0288e6f55d89d19489534884335744c4 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 18 Aug 2011 09:14:27 +0000 Subject: Apply [#28287] COLLADA fix for inverse bind matrix of skin controller Patch by Pelle Johnsen --- source/blender/collada/ArmatureExporter.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index b033c780530..1c81c0b6e76 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -368,17 +368,12 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase bPoseChannel *pchan = get_pose_channel(pose, def->name); - float pose_mat[4][4]; float mat[4][4]; float world[4][4]; float inv_bind_mat[4][4]; - // pose_mat is the same as pchan->pose_mat, but without the rotation - unit_m4(pose_mat); - translate_m4(pose_mat, pchan->pose_head[0], pchan->pose_head[1], pchan->pose_head[2]); - - // make world-space matrix, pose_mat is armature-space - mul_m4_m4m4(world, pose_mat, ob_arm->obmat); + // make world-space matrix, arm_mat is armature-space + mul_m4_m4m4(world, pchan->bone->arm_mat, ob_arm->obmat); invert_m4_m4(mat, world); converter.mat4_to_dae(inv_bind_mat, mat); -- cgit v1.2.3 From 2ee74be88cb045d403bc5145647da4262f131077 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Thu, 18 Aug 2011 19:16:36 +0000 Subject: Blender tip profile for bones with 2 or more children. --- source/blender/collada/ArmatureExporter.cpp | 5 ++++- source/blender/collada/ArmatureImporter.cpp | 8 ++------ 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 1c81c0b6e76..753d57b5af8 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -177,7 +177,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) node.setNodeName(node_name); node.setNodeSid(node_sid); - if ( bone->childbase.first == NULL ) + if ( bone->childbase.first == NULL || BLI_countlist(&(bone->childbase))>=2) add_blender_leaf_bone( bone, ob_arm , node ); else{ node.start(); @@ -202,6 +202,9 @@ void ArmatureExporter::add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADA node.addExtraTechniqueParameter("blender", "tip_y", bone->tail[1] ); node.addExtraTechniqueParameter("blender", "tip_z", bone->tail[2] ); + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) { + add_bone_node(child, ob_arm); + } node.end(); } diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 81d785371df..381a6cc06a9 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -83,14 +83,11 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p float parent_mat[][4], Object * ob_arm) { float mat[4][4]; - float obmat[4][4]; + float obmat[4][4]; // object-space get_node_mat(obmat, node, NULL, NULL); - // get world-space - - EditBone *bone = ED_armature_edit_bone_add((bArmature*)ob_arm->data, (char*)bc_get_joint_name(node)); totbone++; @@ -151,7 +148,6 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p // in second case it's not a leaf bone, but we handle it the same way if (!children.getCount() || children.getCount() > 1) { - add_leaf_bone(mat, bone, node); } @@ -659,7 +655,7 @@ void ArmatureImporter::make_armatures(bContext *C) } //for bones without skins - create_armature_bones(); + //create_armature_bones(); } #if 0 -- cgit v1.2.3 From c6465197763d9110361a795fcc6a2292790a7fc7 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 18 Aug 2011 22:56:41 +0000 Subject: Export only objects on visible layers. This ensures we can hide for instance bone shapes. --- source/blender/collada/DocumentExporter.cpp | 2 ++ source/blender/collada/GeometryExporter.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 0a30365658e..32956921f5b 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -195,6 +195,7 @@ public: Object *ob = base->object; if (!ob->parent) { + if(sce->lay & ob->lay) { switch(ob->type) { case OB_MESH: case OB_CAMERA: @@ -208,6 +209,7 @@ public: writeNodes(ob, sce); break; } + } } base= base->next; diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h index 7f3426a1915..d9d265a66fc 100644 --- a/source/blender/collada/GeometryExporter.h +++ b/source/blender/collada/GeometryExporter.h @@ -110,7 +110,8 @@ struct GeometryFunctor { Object *ob = base->object; if (ob->type == OB_MESH && ob->data - && !(export_selected && !(ob->flag && SELECT))) { + && !(export_selected && !(ob->flag && SELECT)) + && ((sce->lay & ob->lay)!=0)) { f(ob); } base= base->next; -- cgit v1.2.3 From ac3d785caaf272304738ecc0799c1dc9c11c3c82 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Fri, 19 Aug 2011 14:29:33 +0000 Subject: Animation exporter matrix source param fix. --- source/blender/collada/AnimationExporter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 7bcb225e3c2..8a7d285abcb 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -732,7 +732,7 @@ void AnimationExporter::exportAnimations(Scene *sce) source.setAccessorStride(16); COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, false, NULL, false); + add_source_parameters(param, semantic, false, NULL, true); source.prepareToAppendValues(); @@ -1123,7 +1123,8 @@ void AnimationExporter::exportAnimations(Scene *sce) } } - if ( fcu) return true; + if ( fcu) + return true; base= base->next; } return false; -- cgit v1.2.3 From bcadb6b93986b230fb6e70489e7221b3f9972aec Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sat, 20 Aug 2011 16:48:53 +0000 Subject: small fixes and refactoring. --- source/blender/collada/AnimationImporter.cpp | 19 +++++++++------- source/blender/collada/ArmatureExporter.cpp | 11 +++++---- source/blender/collada/ArmatureImporter.cpp | 34 ++++++++++++++++------------ 3 files changed, 36 insertions(+), 28 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index a0202fdcb1b..ee04c270843 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -454,14 +454,14 @@ void AnimationImporter::find_frames( std::vector* frames , std::vectorbegin(); iter != curves->end(); iter++) { FCurve *fcu = *iter; - 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()) - frames->push_back(fra); - - } + 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()) + frames->push_back(fra); + + } } } @@ -1568,10 +1568,13 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float i++; j = 0; } + unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), *it), unused_curves.end()); } COLLADAFW::Matrix tm(matrix); dae_matrix_to_mat4(&tm, mat); + + std::vector::iterator it; return true; } diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 753d57b5af8..082105baaba 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -39,6 +39,7 @@ #include "BKE_action.h" #include "BKE_armature.h" +#include "ED_armature.h" #include "BLI_listbase.h" @@ -177,9 +178,9 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) node.setNodeName(node_name); node.setNodeSid(node_sid); - if ( bone->childbase.first == NULL || BLI_countlist(&(bone->childbase))>=2) + /*if ( bone->childbase.first == NULL || BLI_countlist(&(bone->childbase))>=2) add_blender_leaf_bone( bone, ob_arm , node ); - else{ + else{*/ node.start(); add_bone_transform(ob_arm, bone, node); @@ -189,15 +190,15 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) } node.end(); - } + //} } void ArmatureExporter::add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADASW::Node& node) { node.start(); - + add_bone_transform(ob_arm, bone, node); - + node.addExtraTechniqueParameter("blender", "tip_x", bone->tail[0] ); node.addExtraTechniqueParameter("blender", "tip_y", bone->tail[1] ); node.addExtraTechniqueParameter("blender", "tip_z", bone->tail[2] ); diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 381a6cc06a9..67828fb967d 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -183,10 +183,10 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo else copy_m4_m4(mat, obmat); - float loc[3], size[3], rot[3][3] , angle; + /*float loc[3], size[3], rot[3][3] , angle; mat4_to_loc_rot_size( loc, rot, size, obmat); mat3_to_vec_roll(rot, NULL, &angle ); - bone->roll=angle; + bone->roll=angle;*/ } @@ -267,21 +267,25 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: copy_m4_m4(leaf.mat, mat); BLI_strncpy(leaf.name, bone->name, sizeof(leaf.name)); + float vec[3]; + TagsMap::iterator etit; ExtraTags *et = 0; etit = uid_tags_map.find(node->getUniqueId().toAscii()); if(etit != uid_tags_map.end()) - et = etit->second; - else return; - - float x,y,z; - et->setData("tip_x",&x); - et->setData("tip_y",&y); - et->setData("tip_z",&z); - float vec[3] = {x,y,z}; - copy_v3_v3(leaf.bone->tail, leaf.bone->head); - add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); - leaf_bones.push_back(leaf); + { + et = etit->second; + //else return; + + float x,y,z; + et->setData("tip_x",&x); + et->setData("tip_y",&y); + et->setData("tip_z",&z); + float vec[3] = {x,y,z}; + copy_v3_v3(leaf.bone->tail, leaf.bone->head); + add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); + }else + leaf_bones.push_back(leaf); } void ArmatureImporter::fix_leaf_bones( ) @@ -295,7 +299,7 @@ void ArmatureImporter::fix_leaf_bones( ) // pointing up float vec[3] = {0.0f, 0.0f, 1.0f}; - mul_v3_fl(vec, leaf_bone_length); + //mul_v3_fl(vec, leaf_bone_length); copy_v3_v3(leaf.bone->tail, leaf.bone->head); add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); @@ -418,7 +422,7 @@ void ArmatureImporter::create_armature_bones( ) leaf_bone_length = FLT_MAX; create_unskinned_bone(*ri, NULL, (*ri)->getChildNodes().getCount(), NULL, ob_arm); - //fix_leaf_bones(); + fix_leaf_bones(); // exit armature edit mode -- cgit v1.2.3 From be25346da68be9027757bef101562987483afd1c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 21 Aug 2011 07:08:15 +0000 Subject: Bugfix [#28308] Crashes when individual channels are moved in Action Editor --- .../blender/editors/animation/anim_channels_edit.c | 73 +++++++++++----------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index ffa0b2d5ff5..e993faa71aa 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1042,11 +1042,6 @@ static void rearrange_action_channels (bAnimContext *ac, bAction *act, short mod static int animchannels_rearrange_exec(bContext *C, wmOperator *op) { bAnimContext ac; - - ListBase anim_data = {NULL, NULL}; - bAnimListElem *ale; - int filter; - short mode; /* get editor data */ @@ -1056,43 +1051,51 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) /* get mode */ mode= RNA_enum_get(op->ptr, "direction"); - /* get animdata blocks */ - // XXX: hierarchy visibility is provisional atm... might be wrong decision! - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - - for (ale = anim_data.first; ale; ale = ale->next) { - AnimData *adt= ale->data; + /* method to move channels depends on the editor */ + if (ac.datatype == ANIMCONT_GPENCIL) { + /* Grease Pencil channels */ + printf("Grease Pencil not supported for moving yet\n"); + } + else if (ac.datatype == ANIMCONT_ACTION) { + /* Directly rearrange action's channels */ + rearrange_action_channels(&ac, ac.data, mode); + } + else { + ListBase anim_data = {NULL, NULL}; + bAnimListElem *ale; + int filter; - switch (ac.datatype) { - case ANIMCONT_NLA: /* NLA-tracks only */ - rearrange_nla_channels(&ac, adt, mode); - break; + /* get animdata blocks */ + filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt= ale->data; - case ANIMCONT_DRIVERS: /* Drivers list only */ - rearrange_driver_channels(&ac, adt, mode); - break; - - case ANIMCONT_GPENCIL: /* Grease Pencil channels */ - // FIXME: this case probably needs to get moved out of here or treated specially... - printf("grease pencil not supported for moving yet\n"); - break; + switch (ac.datatype) { + case ANIMCONT_NLA: /* NLA-tracks only */ + rearrange_nla_channels(&ac, adt, mode); + break; - case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME... + case ANIMCONT_DRIVERS: /* Drivers list only */ + rearrange_driver_channels(&ac, adt, mode); + break; - default: /* some collection of actions */ - // FIXME: actions should only be considered once! - if (adt->action) - rearrange_action_channels(&ac, adt->action, mode); - else if (G.f & G_DEBUG) - printf("animdata has no action\n"); - break; + case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME... + + default: /* some collection of actions */ + if (adt->action) + rearrange_action_channels(&ac, adt->action, mode); + else if (G.f & G_DEBUG) + printf("Animdata has no action\n"); + break; + } } + + /* free temp data */ + BLI_freelistN(&anim_data); } - /* free temp data */ - BLI_freelistN(&anim_data); - /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); -- cgit v1.2.3 From ee938c3be861d55ceea217ff09c5f42c89b956c6 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 21 Aug 2011 13:25:56 +0000 Subject: Bugfix [#28309] pose lib too many keyframes in automatic keyframing mode Pose Library was checking in wrong place for what was selected and what wasn't when determining what should get autokeyed. --- source/blender/editors/armature/poselib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index ff6deb6a836..864eaa3bdbd 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -906,11 +906,11 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData /* start tagging/keying */ for (agrp= act->groups.first; agrp; agrp= agrp->next) { - /* only for selected action channels */ - if (agrp->flag & AGRP_SELECTED) { - pchan= get_pose_channel(pose, agrp->name); - - if (pchan) { + /* only for selected bones unless there aren't any selected, in which case all are included */ + pchan= get_pose_channel(pose, agrp->name); + + if (pchan) { + if ( (pld->selcount == 0) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) ) { if (autokey) { /* add datasource override for the PoseChannel, to be used later */ ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan); -- cgit v1.2.3 From 4f75566672b06931556888b0b300533c110d6e3d Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 21 Aug 2011 13:51:04 +0000 Subject: export animations if a bone is in a deform group. ( on hold ) --- source/blender/collada/AnimationExporter.cpp | 23 ++++++++++++++++++++++- source/blender/collada/AnimationExporter.h | 2 ++ source/blender/collada/ArmatureExporter.cpp | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 8a7d285abcb..014c13d8986 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -352,13 +352,34 @@ void AnimationExporter::exportAnimations(Scene *sce) if (!ob_arm->adt) return; + //This will only export animations of bones in deform group. + /*if(!is_bone_deform_group(bone)) + return;*/ + sample_and_write_bone_animation_matrix(ob_arm, bone); for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) write_bone_animation_matrix(ob_arm, child); } - + bool AnimationExporter::is_bone_deform_group(Bone * bone) + { + bool is_def; + //Check if current bone is deform + if((bone->flag & BONE_NO_DEFORM) == 0 ) return true; + //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) return true; + } + } + //no deform bone found in children also + return false; + } + void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone) { bArmature *arm = (bArmature*)ob_arm->data; diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index c628e5633b7..495cdefc9a2 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -102,6 +102,8 @@ protected: void sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type); + bool is_bone_deform_group(Bone * bone); + void sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone); void sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pChan); diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 082105baaba..bd7aea16b29 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -167,6 +167,7 @@ std::string ArmatureExporter::get_joint_sid(Bone *bone, Object *ob_arm) // parent_mat is armature-space void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) { + /*if((bone->flag & BONE_NO_DEFORM) == 0 ){*/ std::string node_id = get_joint_id(bone, ob_arm); std::string node_name = std::string(bone->name); std::string node_sid = get_joint_sid(bone, ob_arm); -- cgit v1.2.3 From 6b99cd05aa5528a931e391c5d78278aeaa6dd861 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 21 Aug 2011 15:47:21 +0000 Subject: Armature object animations export. --- source/blender/collada/AnimationExporter.cpp | 13 ++++++++----- source/blender/collada/ArmatureExporter.cpp | 4 +--- source/blender/collada/ArmatureImporter.cpp | 19 ++++++++++++++++--- source/blender/collada/ArmatureImporter.h | 1 + 4 files changed, 26 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 014c13d8986..2f074992076 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -63,6 +63,8 @@ void AnimationExporter::exportAnimations(Scene *sce) //Export transform animations if(ob->adt && ob->adt->action) { + fcu = (FCurve*)ob->adt->action->curves.first; + //transform matrix export for bones are temporarily disabled here. if ( ob->type == OB_ARMATURE ) { @@ -71,19 +73,20 @@ void AnimationExporter::exportAnimations(Scene *sce) for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) write_bone_animation_matrix(ob, bone); + transformName = fcu->rna_path; } - else { - fcu = (FCurve*)ob->adt->action->curves.first; + else + transformName = extract_transform_name( fcu->rna_path ); + while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); - + transformName = extract_transform_name( fcu->rna_path ); if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)|| (!strcmp(transformName, "rotation_quaternion"))) dae_animation(ob ,fcu, transformName, false); fcu = fcu->next; } - } + } //Export Lamp parameter animations diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index bd7aea16b29..92d06bb639f 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -167,7 +167,6 @@ std::string ArmatureExporter::get_joint_sid(Bone *bone, Object *ob_arm) // parent_mat is armature-space void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) { - /*if((bone->flag & BONE_NO_DEFORM) == 0 ){*/ std::string node_id = get_joint_id(bone, ob_arm); std::string node_name = std::string(bone->name); std::string node_sid = get_joint_sid(bone, ob_arm); @@ -189,8 +188,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) { add_bone_node(child, ob_arm); } - - node.end(); + node.end(); //} } diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 67828fb967d..1e7879b352f 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -82,6 +82,10 @@ JointData *ArmatureImporter::get_joint_data(COLLADAFW::Node *node); void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *parent, int totchild, float parent_mat[][4], Object * ob_arm) { + std::vector::iterator it; + it = std::find(finished_joints.begin(),finished_joints.end(),node); + if ( it != finished_joints.end()) return; + float mat[4][4]; float obmat[4][4]; @@ -151,11 +155,18 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p add_leaf_bone(mat, bone, node); } + finished_joints.push_back(node); + } void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBone *parent, int totchild, float parent_mat[][4], bArmature *arm) { + //Checking if bone is already made. + std::vector::iterator it; + it = std::find(finished_joints.begin(),finished_joints.end(),node); + if ( it != finished_joints.end()) return; + float joint_inv_bind_mat[4][4]; // JointData* jd = get_joint_data(node); @@ -183,10 +194,10 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo else copy_m4_m4(mat, obmat); - /*float loc[3], size[3], rot[3][3] , angle; + float loc[3], size[3], rot[3][3] , angle; mat4_to_loc_rot_size( loc, rot, size, obmat); mat3_to_vec_roll(rot, NULL, &angle ); - bone->roll=angle;*/ + bone->roll=angle; } @@ -257,6 +268,8 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo if (!children.getCount() || children.getCount() > 1) { add_leaf_bone(mat, bone , node); } + + finished_joints.push_back(node); } void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW::Node * node) @@ -659,7 +672,7 @@ void ArmatureImporter::make_armatures(bContext *C) } //for bones without skins - //create_armature_bones(); + create_armature_bones(); } #if 0 diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h index 92d070ef575..4f4aed210f2 100644 --- a/source/blender/collada/ArmatureImporter.h +++ b/source/blender/collada/ArmatureImporter.h @@ -89,6 +89,7 @@ private: std::map geom_uid_by_controller_uid; std::map joint_by_uid; // contains all joints std::vector root_joints; + std::vector finished_joints; std::map joint_parent_map; std::map unskinned_armature_map; -- cgit v1.2.3 From cb05e405408d7dd8bd82589453df81b955dd0322 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 22 Aug 2011 01:22:14 +0000 Subject: Improved hotkeys for frame/keyframe/jumping Thanks pepeland and 3duan for the suggestions. I've been looking at improving these for a while... * Left/Right Arrow = Single Frame stepping as before * Up/Down Arrow = Jumps to next/previous keyframe (used to be the uncomfortable Shift PageUp/Down) * Shift Up/Down Arrow = Jumps forward/back in 10 frame increments (used to be Up/Down Arrows). 10 frame increment should get customisable again as in 2.4, but need to find some UI space to put that! * Ctrl Shift Up/Down/Left/Right = Jump to start/end frame (used to be Shift ) --- source/blender/editors/screen/screen_ops.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source') diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 1410331700f..b9b82dad6ca 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3471,21 +3471,21 @@ void ED_keymap_screen(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Frames", 0, 0); /* frame offsets */ - RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 10); - RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -10); + RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", 10); + RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", -10); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELUPMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 1); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 1); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "end", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "end", 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "end", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "end", 0); - WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", PAGEUPKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", PAGEDOWNKEY, KM_PRESS, KM_CTRL, 0)->ptr, "next", 0); + WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", UPARROWKEY, KM_PRESS, 0, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "next", 0); WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIALAST, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIAFIRST, KM_PRESS, 0, 0)->ptr, "next", 0); -- cgit v1.2.3 From 2b0127a0c5a7c8eaea12af4c662d2b237a2d45e6 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 22 Aug 2011 02:01:22 +0000 Subject: Rearrange anim channels - quick hotkey tweak Use PageUp/Down for moving up/down, and Shift PageUp/Down for moving to top/bottom. This is more comfortable than the old combinations involving shift+ctrl. --- source/blender/editors/animation/anim_channels_edit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index e993faa71aa..c9d6f9a6420 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2458,10 +2458,10 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, KM_CTRL, 0)->ptr, "all", 0); /* rearranging */ - RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_UP); - RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_DOWN); - RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_TOP); - RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_BOTTOM); + RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "direction", REARRANGE_ANIMCHAN_UP); + RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "direction", REARRANGE_ANIMCHAN_DOWN); + RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_TOP); + RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_BOTTOM); /* Graph Editor only */ WM_keymap_add_item(keymap, "ANIM_OT_channels_visibility_set", VKEY, KM_PRESS, 0, 0); -- cgit v1.2.3 From 06ae5e48258dacc5598b23286d46891be32a08e5 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 22 Aug 2011 02:14:39 +0000 Subject: Reshuffling DopeSheet filter icons so that they appear more obviously related to each other --- source/blender/blenkernel/intern/fmodifier.c | 4 ++-- source/blender/makesrna/intern/rna_action.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 42554679795..95c0aa60991 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -629,11 +629,11 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), cycyofs = (float)ceil((evaltime - ofs) / cycdx); cycyofs *= cycdy; } - + /* special case for cycle start/end */ if(cyct == 0.0f) { evaltime = (side == 1 ? lastkey[0] : prevkey[0]); - + if((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2)) evaltime = (side == 1 ? prevkey[0] : lastkey[0]); } diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index f24e0a92f78..815a9c92968 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -265,6 +265,7 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop= RNA_def_property(srna, "show_datablock_filters", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ADS_FLAG_SHOW_DBFILTERS); RNA_def_property_ui_text(prop, "Show Datablock Filters", "Show options for whether channels related to certain types of data are included"); + RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, -1); RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN, NULL); /* General Filtering Settings */ -- cgit v1.2.3 From ee40894c05b1d5f07eda671bad74f18605cde0b6 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 22 Aug 2011 11:51:23 +0000 Subject: Bugfix [#28217] Moving multiple selected action strips causes strips to scale towards zero This is an attempted bugfix for a bug which seems to be very fickle to reproduce (it only happens sporadically after quickly jerking the strips around in a certain way). So far when testing, I haven't had any more problems after applying this fix, though it may just be unreliable testing. --- source/blender/blenkernel/intern/nla.c | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 0235724c69c..25f824bba19 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -851,34 +851,35 @@ void BKE_nlameta_flush_transforms (NlaStrip *mstrip) /* for each child-strip, calculate new start/end points based on this new info */ for (strip= mstrip->strips.first; strip; strip= strip->next) { if (scaleChanged) { - PointerRNA ptr; - float p1, p2, nStart, nEnd; + float p1, p2; /* compute positions of endpoints relative to old extents of strip */ p1= (strip->start - oStart) / oLen; p2= (strip->end - oStart) / oLen; - /* compute the new strip endpoints using the proportions */ - nStart= (p1 * nLen) + mstrip->start; - nEnd= (p2 * nLen) + mstrip->start; - - /* firstly, apply the new positions manually, then apply using RNA - * - first time is to make sure no truncation errors from one endpoint not being - * set yet occur - * - second time is to make sure scale is computed properly... - */ - strip->start= nStart; - strip->end= nEnd; - - RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &ptr); - RNA_float_set(&ptr, "frame_start", nStart); - RNA_float_set(&ptr, "frame_end", nEnd); + /* apply new strip endpoints using the proportions, then wait for second pass to flush scale properly */ + strip->start= (p1 * nLen) + mstrip->start; + strip->end= (p2 * nLen) + mstrip->start; } else { /* just apply the changes in offset to both ends of the strip */ strip->start += offset; strip->end += offset; } + } + + /* apply a second pass over child strips, to finish up unfinished business */ + for (strip= mstrip->strips.first; strip; strip= strip->next) { + /* only if scale changed, need to perform RNA updates */ + if (scaleChanged) { + PointerRNA ptr; + + /* use RNA updates to compute scale properly */ + RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &ptr); + + RNA_float_set(&ptr, "frame_start", strip->start); + RNA_float_set(&ptr, "frame_end", strip->end); + } /* finally, make sure the strip's children (if it is a meta-itself), get updated */ BKE_nlameta_flush_transforms(strip); -- cgit v1.2.3 From a71c215f228173070d41faef1321db25b40d723e Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Mon, 22 Aug 2011 18:59:56 +0000 Subject: 3D Audio GSoC: Final GSoC commit. * Bugfix: Negative frames crashed * Bugfix: JOS sample buffer size prediction error (wasted memory) * Optimisation: for JOS upsampling (around 12 % difference measured here) * Optimisation: Better filter for JOS resampling * Bugfix: Error in relative 3D audio code. * Removed Attenuation * Bugfix: Multiple scenes in BGE lead to errors, BGE audio now all relative, to support multiple scenes. --- source/blender/makesrna/intern/rna_sequencer.c | 30 ---------------------- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 16 ++++++------ source/gameengine/Ketsji/KX_SoundActuator.cpp | 35 ++++++++++++++++++-------- 3 files changed, 33 insertions(+), 48 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 38575242fd6..d433d494068 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -52,16 +52,6 @@ #ifdef RNA_RUNTIME -static float to_dB(float x) -{ - return logf(x * x + 1e-30f) * 4.34294480f; -} - -static float from_dB(float x) -{ - return expf(x * 0.11512925f); -} - /* build a temp referene to the parent */ static void meta_tmp_ref(Sequence *seq_par, Sequence *seq) { @@ -514,20 +504,6 @@ static int rna_Sequence_proxy_filepath_length(PointerRNA *ptr) return strlen(path)+1; } -static float rna_Sequence_attenuation_get(PointerRNA *ptr) -{ - Sequence *seq= (Sequence*)(ptr->data); - - return to_dB(seq->volume); -} - -static void rna_Sequence_attenuation_set(PointerRNA *ptr, float value) -{ - Sequence *seq= (Sequence*)(ptr->data); - - seq->volume = from_dB(value); -} - static void rna_Sequence_volume_set(PointerRNA *ptr, float value) { Sequence *seq= (Sequence*)(ptr->data); @@ -1401,12 +1377,6 @@ static void rna_def_sound(BlenderRNA *brna) RNA_def_property_float_funcs(prop, NULL, "rna_Sequence_volume_set", NULL); RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); - prop= RNA_def_property(srna, "attenuation", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, -100.0f, +40.0f); - RNA_def_property_ui_text(prop, "Attenuation/dB", "Attenuation in decibel"); - RNA_def_property_float_funcs(prop, "rna_Sequence_attenuation_get", "rna_Sequence_attenuation_set", NULL); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); - prop= RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pitch"); RNA_def_property_range(prop, 0.1f, 10.0f); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index a51105e0c16..dd1cc09cdc6 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -1008,7 +1008,8 @@ void KX_KetsjiEngine::DoSound(KX_Scene* scene) { m_logger->StartLog(tc_sound, m_kxsystem->GetTimeInSeconds(), true); - KX_Camera* cam = scene->GetActiveCamera(); + // nothing to do here, everything relative now... + /*KX_Camera* cam = scene->GetActiveCamera(); if (!cam) return; @@ -1016,16 +1017,17 @@ void KX_KetsjiEngine::DoSound(KX_Scene* scene) if(dev) { AUD_Vector3 v; - float q[4]; - cam->NodeGetWorldPosition().getValue(v.get()); + //float q[4]; + //cam->NodeGetWorldPosition().getValue(v.get()); dev->setListenerLocation(v); - cam->GetLinearVelocity().getValue(v.get()); + //cam->GetLinearVelocity().getValue(v.get()); dev->setListenerVelocity(v); - cam->NodeGetWorldOrientation().getRotation().getValue(q); - dev->setListenerOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2])); - } + //cam->NodeGetWorldOrientation().getRotation().getValue(q); + //dev->setListenerOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2])); + dev->setListenerOrientation(AUD_Quaternion()); + }*/ } diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index eb75e4944a7..6c7b515c095 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -46,6 +46,8 @@ #include "KX_GameObject.h" #include "KX_PyMath.h" // needed for PyObjectFrom() +#include "KX_PythonInit.h" +#include "KX_Camera.h" #include /* ------------------------------------------------------------------------- */ @@ -112,7 +114,7 @@ void KX_SoundActuator::play() if(m_is3d && !handle3d.isNull()) { - handle3d->setRelative(false); + handle3d->setRelative(true); handle3d->setVolumeMaximum(m_3d.max_gain); handle3d->setVolumeMinimum(m_3d.min_gain); handle3d->setDistanceReference(m_3d.reference_distance); @@ -222,16 +224,27 @@ bool KX_SoundActuator::Update(double curtime, bool frame) if(m_is3d && !handle3d.isNull()) { - KX_GameObject* obj = (KX_GameObject*)this->GetParent(); - AUD_Vector3 v; - float q[4]; - - obj->NodeGetWorldPosition().getValue(v.get()); - handle3d->setSourceLocation(v); - obj->GetLinearVelocity().getValue(v.get()); - handle3d->setSourceVelocity(v); - obj->NodeGetWorldOrientation().getRotation().getValue(q); - handle3d->setSourceOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2])); + KX_Camera* cam = KX_GetActiveScene()->GetActiveCamera(); + if (cam) + { + KX_GameObject* obj = (KX_GameObject*)this->GetParent(); + MT_Point3 p; + MT_Matrix3x3 Mo; + AUD_Vector3 v; + float q[4]; + + Mo = cam->NodeGetWorldOrientation().inverse(); + p = (obj->NodeGetWorldPosition() - cam->NodeGetWorldPosition()); + p = Mo * p; + p.getValue(v.get()); + handle3d->setSourceLocation(v); + p = (obj->GetLinearVelocity() - cam->GetLinearVelocity()); + p = Mo * p; + p.getValue(v.get()); + handle3d->setSourceVelocity(v); + (Mo * obj->NodeGetWorldOrientation()).getRotation().getValue(q); + handle3d->setSourceOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2])); + } } result = true; } -- cgit v1.2.3 From ff8daca1f117b34c92462f4ab3bbe2aa50f95166 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 23 Aug 2011 11:44:24 +0000 Subject: Bugfix: Removing a sound from a speaker resulted in a crash. --- source/blender/blenkernel/intern/sound.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index d7385a86105..a364f860255 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -676,11 +676,17 @@ void sound_update_scene(struct Main* bmain, struct Scene* scene) if(AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) { - AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0); + if(speaker->sound) + AUD_moveSequence(strip->speaker_handle, strip->start / FPS, -1, 0); + else + { + AUD_removeSequence(scene->sound_scene, strip->speaker_handle); + strip->speaker_handle = NULL; + } } else { - if(speaker && speaker->sound) + if(speaker->sound) { strip->speaker_handle = AUD_addSequence(scene->sound_scene, speaker->sound->playback_handle, strip->start / FPS, -1, 0); AUD_setRelativeSequence(strip->speaker_handle, 0); -- cgit v1.2.3 From cdbb904b32a859a1b3a65dbe79057248f4425832 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Fri, 26 Aug 2011 15:16:27 +0000 Subject: code review fixes --- source/blender/collada/AnimationExporter.cpp | 176 ++++++++++++--------------- source/blender/collada/AnimationImporter.cpp | 3 +- 2 files changed, 79 insertions(+), 100 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 2f074992076..bbd6fef803f 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -41,126 +41,104 @@ void forEachObjectInScene(Scene *sce, Functor &f) } void AnimationExporter::exportAnimations(Scene *sce) - { - if(hasAnimations(sce)) { - this->scene = sce; +{ + if(hasAnimations(sce)) { + this->scene = sce; - openLibrary(); + openLibrary(); - forEachObjectInScene(sce, *this); + forEachObjectInScene(sce, *this); - closeLibrary(); - } + closeLibrary(); } +} - // called for each exported object - void AnimationExporter::operator() (Object *ob) +// called for each exported object +void AnimationExporter::operator() (Object *ob) +{ + FCurve *fcu; + char * transformName ; + bool isMatAnim = false; + + //Export transform animations + if(ob->adt && ob->adt->action) { - FCurve *fcu; - char * transformName ; - bool isMatAnim = false; + fcu = (FCurve*)ob->adt->action->curves.first; - //Export transform animations - if(ob->adt && ob->adt->action) + //transform matrix export for bones are temporarily disabled here. + if ( ob->type == OB_ARMATURE ) { - fcu = (FCurve*)ob->adt->action->curves.first; - - //transform matrix export for bones are temporarily disabled here. - if ( ob->type == OB_ARMATURE ) - { - if (!ob->data) return; - bArmature *arm = (bArmature*)ob->data; - for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) - write_bone_animation_matrix(ob, bone); - - transformName = fcu->rna_path; - } - else - transformName = extract_transform_name( fcu->rna_path ); + bArmature *arm = (bArmature*)ob->data; + for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) + write_bone_animation_matrix(ob, bone); - while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); - if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || - (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)|| - (!strcmp(transformName, "rotation_quaternion"))) - dae_animation(ob ,fcu, transformName, false); - fcu = fcu->next; - } - + transformName = fcu->rna_path; } - - //Export Lamp parameter animations - if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) - { - fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); - while (fcu) { + else transformName = extract_transform_name( fcu->rna_path ); - - if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))|| - (!strcmp(transformName, "distance")) ) - dae_animation(ob , fcu, transformName, true ); - fcu = fcu->next; - } + + while (fcu) { + transformName = extract_transform_name( fcu->rna_path ); + if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || + (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)|| + (!strcmp(transformName, "rotation_quaternion"))) + dae_animation(ob ,fcu, transformName, false); + fcu = fcu->next; } + + } - //Export Camera parameter animations - if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) - { - fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); - while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); - - if ((!strcmp(transformName, "lens"))|| - (!strcmp(transformName, "ortho_scale"))|| - (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start"))) - dae_animation(ob , fcu, transformName, true ); - fcu = fcu->next; - } + //Export Lamp parameter animations + if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) + { + fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); + while (fcu) { + transformName = extract_transform_name( fcu->rna_path ); + + if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))|| + (!strcmp(transformName, "distance")) ) + dae_animation(ob , fcu, transformName, true ); + fcu = fcu->next; } + } - //Export Material parameter animations. - for(int a = 0; a < ob->totcol; a++) - { - Material *ma = give_current_material(ob, a+1); - if (!ma) continue; - if(ma->adt && ma->adt->action) - { - isMatAnim = true; - fcu = (FCurve*)ma->adt->action->curves.first; - while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); - - if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) - ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))|| - (!strcmp(transformName, "ior"))) - dae_animation(ob ,fcu, transformName, true, ma ); - fcu = fcu->next; - } - } + //Export Camera parameter animations + if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) + { + fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); + while (fcu) { + transformName = extract_transform_name( fcu->rna_path ); + if ((!strcmp(transformName, "lens"))|| + (!strcmp(transformName, "ortho_scale"))|| + (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start"))) + dae_animation(ob , fcu, transformName, true ); + fcu = fcu->next; } - /* Old System - if (!ob->adt || !ob->adt->action) - fcu = (FCurve*)((Lamp*)ob->data)->adt->action->curves.first; //this is already checked in hasAnimations() - else - fcu = (FCurve*)ob->adt->action->curves.first; - - if (ob->type == OB_ARMATURE) { - if (!ob->data) return; - bArmature *arm = (bArmature*)ob->data; - while(fcu) - { + } + + //Export Material parameter animations. + for(int a = 0; a < ob->totcol; a++) + { + Material *ma = give_current_material(ob, a+1); + if (!ma) continue; + if(ma->adt && ma->adt->action) + { + isMatAnim = true; + fcu = (FCurve*)ma->adt->action->curves.first; + while (fcu) { transformName = extract_transform_name( fcu->rna_path ); - // std::string ob_name = getObjectBoneName( ob , fcu); - // for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) - // write_bone_animation(ob, bone); - dae_animation(ob, fcu, ob_name, transformName); + + if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) + ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))|| + (!strcmp(transformName, "ior"))) + dae_animation(ob ,fcu, transformName, true, ma ); fcu = fcu->next; } } - else {*/ } +} //euler sources from quternion sources float * AnimationExporter::get_eul_source_for_quat(Object *ob ) @@ -193,7 +171,7 @@ void AnimationExporter::exportAnimations(Scene *sce) eul[i*3 + k] = temp_eul[k]; } - + MEM_freeN(quat); return eul; } @@ -287,6 +265,8 @@ void AnimationExporter::exportAnimations(Scene *sce) for ( int i = 0 ; i< fcu->totvert ; i++) eul_axis[i] = eul[i*3 + fcu->array_index]; output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name); + MEM_freeN(eul); + MEM_freeN(eul_axis); } else { diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index ee04c270843..4a3cd5eeb06 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -179,7 +179,6 @@ void AnimationImporter::fcurve_deg_to_rad(FCurve *cu) cu->bezt[i].vec[1][1] *= M_PI / 180.0f; cu->bezt[i].vec[0][1] *= M_PI / 180.0f; cu->bezt[i].vec[2][1] *= M_PI / 180.0f; - cu->bezt[i].vec[1][0]; } } @@ -439,7 +438,7 @@ void AnimationImporter::modify_fcurve(std::vector* curves , char* rna_p int i; for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) { FCurve *fcu = *it; - fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); + fcu->rna_path = BLI_strdup(rna_path); if (array_index == -1) fcu->array_index = i; else fcu->array_index = array_index; -- cgit v1.2.3 From 94b3e83b6c564a66788624e824a2548d6c8b8650 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 27 Aug 2011 03:13:54 +0000 Subject: fix for bug with all rotation modes being treated as euler by the BGE, this bug is in trunk too but fixing here because this code will replace whats in trunk. also make initializers less verbose for ipo transform assignment. --- source/gameengine/Converter/KX_IpoConvert.cpp | 30 +++++++-------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 2793b8e9fdf..0ee99f5335b 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -91,41 +91,25 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_B Object* blenderobject = gameobj->GetBlenderObject(); - ipocontr->GetIPOTransform().SetPosition( - MT_Point3( - blenderobject->loc[0]/*+blenderobject->dloc[0]*/, - blenderobject->loc[1]/*+blenderobject->dloc[1]*/, - blenderobject->loc[2]/*+blenderobject->dloc[2]*/ - ) - ); - ipocontr->GetIPOTransform().SetEulerAngles( - MT_Vector3( - blenderobject->rot[0], - blenderobject->rot[1], - blenderobject->rot[2] - ) - ); - ipocontr->GetIPOTransform().SetScaling( - MT_Vector3( - blenderobject->size[0], - blenderobject->size[1], - blenderobject->size[2] - ) - ); + ipocontr->GetIPOTransform().SetPosition(MT_Point3(blenderobject->loc)); + ipocontr->GetIPOTransform().SetEulerAngles(MT_Vector3(blenderobject->rot)); + ipocontr->GetIPOTransform().SetScaling(MT_Vector3(blenderobject->size)); const char *rotmode, *drotmode; - switch(blenderobject->rotmode) - { + switch(blenderobject->rotmode) { case ROT_MODE_AXISANGLE: rotmode = "rotation_axis_angle"; drotmode = "delta_rotation_axis_angle"; + break; case ROT_MODE_QUAT: rotmode = "rotation_quaternion"; drotmode = "delta_rotation_quaternion"; + break; default: rotmode = "rotation_euler"; drotmode = "delta_rotation_euler"; + break; } BL_InterpolatorList *adtList= GetAdtList(action, converter); -- cgit v1.2.3 From 8e12b7b054c3c4e95a23f26db232d99ff18e2b90 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 28 Aug 2011 11:39:18 +0000 Subject: Assorted comment clarification in response to code review notes --- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 13 ++++++++++++- source/blender/editors/animation/drivers.c | 1 - source/blender/editors/space_nla/nla_draw.c | 5 +---- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 3c6daf8b39d..b690c9b4a91 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1168,7 +1168,7 @@ static short animsys_write_rna_setting (PointerRNA *ptr, char *path, int array_i * for we know that which the updates in RNA were really just for * flushing property editing via UI/Py */ - if (RNA_struct_is_a(new_ptr.type, &RNA_PoseBone)) { + if (new_ptr.type == &RNA_PoseBone) { /* bone transforms - update pose (i.e. tag depsgraph) */ skip_updates_hack = 1; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 4802601307a..6f27a104144 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2062,8 +2062,19 @@ static short animdata_use_time(AnimData *adt) return 1; } - /* experimental check: if we have drivers, more likely than not, on a frame change + /* If we have drivers, more likely than not, on a frame change * they'll need updating because their owner changed + * + * This is kindof a hack to get around a whole host of problems + * involving drivers using non-object datablock data (which the + * depsgraph currently has no way of representing let alone correctly + * dependency sort+tagging). By doing this, at least we ensure that + * some commonly attempted drivers (such as scene -> current frame; + * see "Driver updates fail" thread on Bf-committers dated July 2) + * will work correctly, and that other non-object datablocks will have + * their drivers update at least on frame change. + * + * -- Aligorith, July 4 2011 */ if (adt->drivers.first) return 1; diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 28195be943c..6ebe488d2c8 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -383,7 +383,6 @@ short ANIM_paste_driver (ReportList *reports, ID *id, const char rna_path[], int /* modifiers */ copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers); - /* flags - on a per-relevant-flag basis */ /* extrapolation mode */ fcu->extend= channeldriver_copypaste_buf->extend; diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 9ce5aafd48a..0583f328371 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -471,10 +471,7 @@ static void nla_draw_strip_text (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, sprintf(str, "%d) Temp-Meta", index); } else { - if (strip->flag & NLASTRIP_FLAG_REVERSE) - sprintf(str, "%s", strip->name); - else - sprintf(str, "%s", strip->name); + sprintf(str, strip->name); } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ -- cgit v1.2.3 From b4b046995b21d59e315eb71ed08fc1ae066c891b Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sun, 28 Aug 2011 14:21:44 +0000 Subject: * Removing mocap GSoC (is an addon already). * Fixing ffmpeg-0.8 errors. * Fixing Ketsji paths. * Removing DoSound from BGE. * Fixing audio scene update to use only current scene objects. --- source/blender/blenkernel/BKE_sound.h | 2 +- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 15 ++++-------- source/blender/blenkernel/intern/sound.c | 7 ++++-- source/gameengine/Ketsji/CMakeLists.txt | 25 +------------------- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 34 ---------------------------- source/gameengine/Ketsji/KX_KetsjiEngine.h | 2 -- 7 files changed, 13 insertions(+), 74 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index ecf0d7e459a..e1b6ff02bc4 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -136,7 +136,7 @@ void sound_read_waveform(struct bSound* sound); int sound_get_channels(struct bSound* sound); -void sound_update_scene(struct Main* bmain, struct Scene* scene); +void sound_update_scene(struct Scene* scene); void* sound_get_factory(void* sound); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 12e81e8296e..d6003a44a7d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -968,7 +968,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen scene_update_drivers(bmain, scene); /* update sound system animation */ - sound_update_scene(bmain, scene); + sound_update_scene(scene); } /* this is called in main loop, doing tagged updates before redraw */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4cec086aad4..bfbaa223a99 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3150,18 +3150,14 @@ void seq_update_sound_bounds_all(Scene *scene) { Editing *ed = scene->ed; - if(ed) - { + if(ed) { Sequence *seq; - for(seq = ed->seqbase.first; seq; seq = seq->next) - { - if(seq->type == SEQ_META) - { + for(seq = ed->seqbase.first; seq; seq = seq->next) { + if(seq->type == SEQ_META) { seq_update_sound_bounds_recursive(scene, seq); } - else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) - { + else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) { seq_update_sound_bounds(scene, seq); } } @@ -3170,8 +3166,7 @@ void seq_update_sound_bounds_all(Scene *scene) void seq_update_sound_bounds(Scene* scene, Sequence *seq) { - if(seq->scene_sound) - { + if(seq->scene_sound) { sound_move_scene_sound(scene, seq->scene_sound, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); /* mute is set in seq_update_muting_recursive */ } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index a364f860255..842923e63d0 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -24,6 +24,7 @@ #include "DNA_sound_types.h" #include "DNA_speaker_types.h" +#define WITH_AUDASPACE #ifdef WITH_AUDASPACE # include "AUD_C-API.h" #endif @@ -649,9 +650,10 @@ int sound_get_channels(struct bSound* sound) return info.specs.channels; } -void sound_update_scene(struct Main* bmain, struct Scene* scene) +void sound_update_scene(struct Scene* scene) { Object* ob; + Base* base; NlaTrack* track; NlaStrip* strip; Speaker* speaker; @@ -660,8 +662,9 @@ void sound_update_scene(struct Main* bmain, struct Scene* scene) void* handle; float quat[4]; - for(ob = bmain->object.first; ob; ob = ob->id.next) + for(base = FIRSTBASE; base; base=base->next) { + ob = base->object; if(ob->type == OB_SPEAKER) { if(ob->adt) diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt index 73365860fce..99c9fb25a65 100644 --- a/source/gameengine/Ketsji/CMakeLists.txt +++ b/source/gameengine/Ketsji/CMakeLists.txt @@ -45,37 +45,14 @@ set(INC ../../blender/gpu ../../blender/imbuf ../../blender/makesdna + ../../blender/makesrna ../../blender/python ../../blender/python/generic ../../blender/python/mathutils ../../../intern/container ../../../intern/guardedalloc - ../../../intern/container - ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer - ../../../source/gameengine/Converter - ../../../source/gameengine/BlenderRoutines - ../../../source/blender/imbuf ../../../intern/moto/include ../../../intern/string - ../../../source/gameengine/Ketsji - ../../../source/blender/blenlib - ../../../source/blender/blenfont - ../../../source/blender/blenkernel - ../../../source/blender/python - ../../../source/blender/python/generic - ../../../source/blender - ../../../source/blender/makesdna - ../../../source/blender/makesrna - ../../../source/gameengine/Rasterizer - ../../../source/gameengine/GameLogic - ../../../source/gameengine/Expressions - ../../../source/gameengine/Ketsji/KXNetwork - ../../../source/gameengine/Network - ../../../source/gameengine/SceneGraph - ../../../source/gameengine/Physics/common - ../../../source/gameengine/Network/LoopBackNetwork - ../../../source/blender/blenloader - ../../../source/blender/gpu ) set(INC_SYS diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index dd1cc09cdc6..620f46e743e 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -96,7 +96,6 @@ const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = { "Animations:", // tc_animations "Network:", // tc_network "Scenegraph:", // tc_scenegraph - "Sound:", // tc_sound "Rasterizer:", // tc_rasterizer "Services:", // tc_services "Overhead:", // tc_overhead @@ -692,8 +691,6 @@ else else if(scene->getSuspendedTime()==0.0) scene->setSuspendedTime(m_clockTime); - - DoSound(scene); m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true); } @@ -769,8 +766,6 @@ else if(scene->getSuspendedTime()==0.0) scene->setSuspendedTime(m_clockTime); - DoSound(scene); - m_logger->StartLog(tc_services, m_kxsystem->GetTimeInSeconds(), true); } } @@ -1003,35 +998,6 @@ const STR_String& KX_KetsjiEngine::GetExitString() } - -void KX_KetsjiEngine::DoSound(KX_Scene* scene) -{ - m_logger->StartLog(tc_sound, m_kxsystem->GetTimeInSeconds(), true); - - // nothing to do here, everything relative now... - /*KX_Camera* cam = scene->GetActiveCamera(); - if (!cam) - return; - - AUD_I3DDevice* dev = AUD_get3DDevice(); - if(dev) - { - AUD_Vector3 v; - //float q[4]; - //cam->NodeGetWorldPosition().getValue(v.get()); - dev->setListenerLocation(v); - - //cam->GetLinearVelocity().getValue(v.get()); - dev->setListenerVelocity(v); - - //cam->NodeGetWorldOrientation().getRotation().getValue(q); - //dev->setListenerOrientation(AUD_Quaternion(q[3], q[0], q[1], q[2])); - dev->setListenerOrientation(AUD_Quaternion()); - }*/ -} - - - void KX_KetsjiEngine::SetBackGround(KX_WorldInfo* wi) { if (wi->hasWorld()) diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 95a6b3401a7..b1009c7d8f0 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -153,7 +153,6 @@ private: tc_animations, tc_network, tc_scenegraph, - tc_sound, tc_rasterizer, tc_services, // time spend in miscelaneous activities tc_overhead, // profile info drawing overhead @@ -199,7 +198,6 @@ private: void RenderDebugProperties(); void RenderShadowBuffers(KX_Scene *scene); void SetBackGround(KX_WorldInfo* worldinfo); - void DoSound(KX_Scene* scene); void RenderFonts(KX_Scene* scene); public: -- cgit v1.2.3 From ca79dee61f11227be0ed4cc5b1241fa748124da0 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 28 Aug 2011 18:30:18 +0000 Subject: armature object animation bug fix. --- source/blender/collada/AnimationExporter.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index bbd6fef803f..c6f108306be 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -71,14 +71,15 @@ void AnimationExporter::operator() (Object *ob) bArmature *arm = (bArmature*)ob->data; for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) write_bone_animation_matrix(ob, bone); - - transformName = fcu->rna_path; } - else - transformName = extract_transform_name( fcu->rna_path ); while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); + //for armature animations as objects + if ( ob->type == OB_ARMATURE ) + transformName = fcu->rna_path; + else + transformName = extract_transform_name( fcu->rna_path ); + if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)|| (!strcmp(transformName, "rotation_quaternion"))) -- cgit v1.2.3 From 28feca36d7e0a5f15d9c03f3781ba34cca8c4670 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 28 Aug 2011 18:54:02 +0000 Subject: Missed notifier was found when looking at #28393 --- source/blender/editors/space_buttons/space_buttons.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source') diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index e2d80e9e775..ef927fd69fc 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -269,6 +269,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */ break; case ND_POSE: + buttons_area_redraw(sa, BCONTEXT_DATA); case ND_BONE_ACTIVE: case ND_BONE_SELECT: buttons_area_redraw(sa, BCONTEXT_BONE); -- cgit v1.2.3 From 80459d97c7b50cfe8f630e2e20f5ccc55f854c23 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 28 Aug 2011 19:58:33 +0000 Subject: == Sequencer / proxies == fixed crash pointed out by blendervse: 100%-proxy could lead to a segfault under certain conditions. --- source/blender/imbuf/intern/indexer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index f624694b324..5a819cef652 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -573,11 +573,15 @@ static int add_to_proxy_output_ffmpeg( ctx->frame->data, ctx->frame->linesize); } - ctx->frame->pts = ctx->cfra++; + frame = ctx->sws_ctx ? (frame ? ctx->frame : 0) : frame; + + if (frame) { + frame->pts = ctx->cfra++; + } outsize = avcodec_encode_video( ctx->c, ctx->video_buffer, ctx->video_buffersize, - ctx->sws_ctx ? (frame ? ctx->frame : 0) : frame); + frame); if (outsize < 0) { fprintf(stderr, "Error encoding proxy frame %d for '%s'\n", -- cgit v1.2.3 From 3dc817840b21a06f161b8c672e61e0a0000adc8f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 28 Aug 2011 21:13:03 +0000 Subject: fix [#28401] OpenGL render option disables border clipping --- source/blender/editors/space_view3d/view3d_draw.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source') diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 80da75bc603..98768e369cb 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2272,6 +2272,7 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[][4], float winmat[][4]) { + RegionView3D *rv3d= ar->regiondata; Base *base; float backcol[3]; int bwinx, bwiny; @@ -2320,6 +2321,9 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, /* setup view matrices */ view3d_main_area_setup_view(scene, v3d, ar, viewmat, winmat); + if(rv3d->rflag & RV3D_CLIPPING) + view3d_draw_clipping(rv3d); + /* set zbuffer */ if(v3d->drawtype > OB_WIRE) { v3d->zbuf= TRUE; @@ -2328,6 +2332,9 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, else v3d->zbuf= FALSE; + if(rv3d->rflag & RV3D_CLIPPING) + view3d_set_clipping(rv3d); + /* draw set first */ if(scene->set) { Scene *sce_iter; @@ -2363,6 +2370,9 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, if(v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! if(v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); + if(rv3d->rflag & RV3D_CLIPPING) + view3d_clr_clipping(); + /* cleanup */ if(v3d->zbuf) { v3d->zbuf= FALSE; -- cgit v1.2.3 From c31b776dc9a914f0fcf1b988edb448f12ed4eb64 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Sun, 28 Aug 2011 21:48:52 +0000 Subject: SVN maintenance. --- source/blender/imbuf/intern/IMB_indexer.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index ae3b48f76c7..f55420fd106 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -1,7 +1,5 @@ /** - * IMB_indexer.h - * - * $Id: IMB_indexer.h + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From 0e01fa4863a301f9776b8a6b5459493fc8830008 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 28 Aug 2011 23:24:34 +0000 Subject: patch [#28355] Better Environment Map scripting from Tom Edwards (artfunkel), with minor edits. This patch makes the following improvements to environment map scripting: * Adds a "is_valid" RNA property to envmaps. True if the map is ready for use, False if it needs rendering. * Adds a "clear" RNA function to envmaps. Deletes any envmap image data. * Adds a "save" RNA function to envmaps. Writes the envmap to disc with a configurable layout. (Defaults to the current hard-coded layout.) * Updates bpy.ops.texture.envmap_save with configurable layout support as above. These changes, particularly configurable layouts, make exporting envmaps to other software much easier. --- source/blender/editors/render/render_shading.c | 69 ++++------------ source/blender/makesrna/intern/CMakeLists.txt | 1 + source/blender/makesrna/intern/makesrna.c | 2 +- source/blender/makesrna/intern/rna_internal.h | 1 + source/blender/makesrna/intern/rna_texture.c | 7 ++ source/blender/makesrna/intern/rna_texture_api.c | 95 ++++++++++++++++++++++ source/blender/render/extern/include/RE_pipeline.h | 4 + source/blender/render/intern/source/pipeline.c | 57 +++++++++++++ 8 files changed, 183 insertions(+), 53 deletions(-) create mode 100644 source/blender/makesrna/intern/rna_texture_api.c (limited to 'source') diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index fbdcf7ba9b3..1b24d660411 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -85,6 +85,8 @@ #include "UI_interface.h" +#include "RE_pipeline.h" + #include "render_intern.h" // own include /********************** material slot operators *********************/ @@ -661,60 +663,21 @@ void TEXTURE_OT_slot_move(wmOperatorType *ot) /********************** environment map operators *********************/ -static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int imtype) +static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *path, int imtype) { - ImBuf *ibuf=NULL; - int dx; - int retval; - int relative= (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path")); - - if(env->cube[1]==NULL) { - BKE_report(op->reports, RPT_ERROR, "There is no generated environment map available to save"); - return OPERATOR_CANCELLED; - } - - dx= env->cube[1]->x; - - if (env->type == ENV_CUBE) { - ibuf = IMB_allocImBuf(3*dx, 2*dx, 24, IB_rectfloat); - - IMB_rectcpy(ibuf, env->cube[0], 0, 0, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[1], dx, 0, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[2], 2*dx, 0, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[3], 0, dx, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[4], dx, dx, 0, 0, dx, dx); - IMB_rectcpy(ibuf, env->cube[5], 2*dx, dx, 0, 0, dx, dx); - } - else if (env->type == ENV_PLANE) { - ibuf = IMB_allocImBuf(dx, dx, 24, IB_rectfloat); - IMB_rectcpy(ibuf, env->cube[1], 0, 0, 0, 0, dx, dx); + float layout[12]; + if ( RNA_struct_find_property(op->ptr, "layout") ) + RNA_float_get_array(op->ptr, "layout",layout); + else + memcpy(layout, default_envmap_layout, sizeof(layout)); + + if (RE_WriteEnvmapResult(op->reports, scene, env, path, imtype, layout)) { + return OPERATOR_FINISHED; } else { - BKE_report(op->reports, RPT_ERROR, "Invalid environment map type"); return OPERATOR_CANCELLED; } - - if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) - ibuf->profile = IB_PROFILE_LINEAR_RGB; - - /* to save, we first get absolute path */ - BLI_path_abs(str, G.main->name); - - if (BKE_write_ibuf(ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) { - retval = OPERATOR_FINISHED; - } - else { - BKE_reportf(op->reports, RPT_ERROR, "Error saving environment map to %s.", str); - retval = OPERATOR_CANCELLED; - } - /* in case we were saving with relative paths, change back again */ - if(relative) - BLI_path_rel(str, G.main->name); - - IMB_freeImBuf(ibuf); - ibuf = NULL; - - return retval; + } static int envmap_save_exec(bContext *C, wmOperator *op) @@ -753,7 +716,6 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event return envmap_save_exec(C, op); //RNA_enum_set(op->ptr, "file_type", scene->r.imtype); - RNA_string_set(op->ptr, "filepath", G.main->name); WM_event_add_fileselect(C, op); @@ -776,6 +738,7 @@ static int envmap_save_poll(bContext *C) void TEXTURE_OT_envmap_save(wmOperatorType *ot) { + PropertyRNA *prop; /* identifiers */ ot->name= "Save Environment Map"; ot->idname= "TEXTURE_OT_envmap_save"; @@ -790,8 +753,10 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER; /* no undo since this doesnt modify the env-map */ /* properties */ - //RNA_def_enum(ot->srna, "file_type", image_file_type_items, R_PNG, "File Type", "File type to save image as."); - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH); + prop= RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face. Order is [+Z -Z +Y -X -Y +X]. Use -1 to skip a face.", 0.0f, 0.0f); + RNA_def_property_flag(prop, PROP_HIDDEN); + + WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); } static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index cc7bcf04716..6b042a987e3 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -100,6 +100,7 @@ set(APISRC rna_main_api.c rna_material_api.c rna_mesh_api.c + rna_texture_api.c rna_object_api.c rna_pose_api.c rna_scene_api.c diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index b95bd2b2087..d0dea41b384 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -2417,7 +2417,7 @@ typedef struct RNAProcessItem { static RNAProcessItem PROCESS_ITEMS[]= { {"rna_rna.c", NULL, RNA_def_rna}, {"rna_ID.c", NULL, RNA_def_ID}, - {"rna_texture.c", NULL, RNA_def_texture}, + {"rna_texture.c", "rna_texture_api.c", RNA_def_texture}, {"rna_action.c", "rna_action_api.c", RNA_def_action}, {"rna_animation.c", "rna_animation_api.c", RNA_def_animation}, {"rna_animviz.c", NULL, RNA_def_animviz}, diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index c0ae7b02b1a..955e56193c6 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -260,6 +260,7 @@ void RNA_api_wm(struct StructRNA *srna); void RNA_api_sensor(struct StructRNA *srna); void RNA_api_controller(struct StructRNA *srna); void RNA_api_actuator(struct StructRNA *srna); +void RNA_api_environment_map(struct StructRNA *srna); /* main collection functions */ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 0ecc41d80d8..a1ce77b061d 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -664,6 +664,13 @@ static void rna_def_environment_map(BlenderRNA *brna) RNA_def_property_range(prop, 0, 5); RNA_def_property_ui_text(prop, "Depth", "Number of times a map will be rendered recursively (mirror effects.)"); RNA_def_property_update(prop, 0, "rna_Texture_update"); + + prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, 0); + RNA_def_property_boolean_sdna(prop, NULL, "ok", 2); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Validity", "True if this map is ready for use, False if it needs rendering."); + + RNA_api_environment_map(srna); } static EnumPropertyItem prop_noise_basis_items[] = { diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c new file mode 100644 index 00000000000..f83caca3944 --- /dev/null +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -0,0 +1,95 @@ +/* + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Tom Edwards + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_texture_api.c + * \ingroup RNA + */ + + +#include +#include +#include + + +#include "RNA_define.h" +#include "BKE_utildefines.h" + +#ifdef RNA_RUNTIME + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "DNA_scene_types.h" +#include "BKE_context.h" +#include "BKE_global.h" +#include "RE_pipeline.h" + +void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char* filepath, struct Scene *scene, float layout[12]) +{ + if (scene == NULL) { + scene = CTX_data_scene(C); + } + + RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.imtype, layout); +} + +void clear_envmap(struct EnvMap *env, bContext *C) +{ + Main *bmain = CTX_data_main(C); + Tex *tex; + + BKE_free_envmapdata(env); + + for (tex=bmain->tex.first; tex; tex=tex->id.next) + if (tex->env == env) { + WM_event_add_notifier(C, NC_TEXTURE|NA_EDITED, tex); + break; + } +} + +#else + +void RNA_api_environment_map(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + static const float default_layout[] = { 0,0, 1,0, 2,0, 0,1, 1,1, 2,1 }; + + func= RNA_def_function(srna, "clear", "clear_envmap"); + RNA_def_function_ui_description(func, "Discard the environment map and free it from memory."); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + + + func= RNA_def_function(srna,"save", "save_envmap"); + RNA_def_function_ui_description(func, "Save the environment map to disc using the scene render settings."); + RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + + parm= RNA_def_string_file_name(func,"filepath","",FILE_MAX,"File path","Location of the output file"); + RNA_def_property_flag(parm, PROP_REQUIRED); + + RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken."); + + parm = RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 0.0f, "File layout", "Flat array describing the X,Y position of each cube face in the output image, where 1 is the size of a face. Order is [+Z -Z +Y -X -Y +X]. Use -1 to skip a face.", 0.0f, 0.0f); +} + +#endif diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index d9ed83a00b2..0736bed4faf 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -51,6 +51,7 @@ struct ReportList; struct ReportList; struct Scene; struct SceneRenderLayer; +struct EnvMap; /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* this include is what is exposed of render to outside world */ @@ -230,6 +231,9 @@ void RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode); void RE_WriteRenderResult(RenderResult *rr, const char *filename, int compress); struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty); +extern const float default_envmap_layout[]; +int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, int imtype, float layout[12]); + /* do a full sample buffer compo */ void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce, struct bNodeTree *ntree); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index b9006b390ab..eff8402d8b5 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -3463,3 +3463,60 @@ static int external_render_3d(Render *re, int do_all) return 1; } +const float default_envmap_layout[] = { 0,0, 1,0, 2,0, 0,1, 1,1, 2,1 }; + +int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, const char *relpath, int imtype, float layout[12]) +{ + ImBuf *ibuf=NULL; + int ok; + int dx; + int maxX=0,maxY=0,i=0; + char filepath[FILE_MAX]; + + if(env->cube[1]==NULL) { + BKE_report(reports, RPT_ERROR, "There is no generated environment map available to save"); + return 0; + } + + dx= env->cube[1]->x; + + if (env->type == ENV_CUBE) { + for (i=0; i < 12; i+=2) { + maxX = MAX2(maxX,layout[i] + 1); + maxY = MAX2(maxY,layout[i+1] + 1); + } + + ibuf = IMB_allocImBuf(maxX*dx, maxY*dx, 24, IB_rectfloat); + + for (i=0; i < 12; i+=2) + if (layout[i] > -1 && layout[i+1] > -1) + IMB_rectcpy(ibuf, env->cube[i/2], layout[i]*dx, layout[i+1]*dx, 0, 0, dx, dx); + } + else if (env->type == ENV_PLANE) { + ibuf = IMB_allocImBuf(dx, dx, 24, IB_rectfloat); + IMB_rectcpy(ibuf, env->cube[1], 0, 0, 0, 0, dx, dx); + } + else { + BKE_report(reports, RPT_ERROR, "Invalid environment map type"); + return 0; + } + + if (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) + ibuf->profile = IB_PROFILE_LINEAR_RGB; + + /* to save, we first get absolute path */ + BLI_strncpy(filepath, relpath, sizeof(filepath)); + BLI_path_abs(filepath, G.main->name); + + ok= BKE_write_ibuf(ibuf, filepath, imtype, scene->r.subimtype, scene->r.quality); + + IMB_freeImBuf(ibuf); + + if(ok) { + return TRUE; + } + else { + BKE_report(reports, RPT_ERROR, "Error writing environment map."); + return FALSE; + } +} -- cgit v1.2.3 From f71223400929b55720251eabd46732397f34a7b1 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Sun, 28 Aug 2011 23:44:43 +0000 Subject: SVN maintenance. --- source/blender/makesrna/intern/rna_texture_api.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c index f83caca3944..8d4b73f1f0c 100644 --- a/source/blender/makesrna/intern/rna_texture_api.c +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -1,4 +1,5 @@ /* + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From c1eb0c3783a8a58b8b8f0e380cd931ef02cb69da Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 29 Aug 2011 01:00:14 +0000 Subject: clear some warnings with new proxy code. --- source/blender/imbuf/intern/indexer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 5a819cef652..3528318ba81 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -51,8 +51,11 @@ static char temp_ext [] = "_part"; static int proxy_sizes[] = { IMB_PROXY_25, IMB_PROXY_50, IMB_PROXY_75, IMB_PROXY_100 }; static float proxy_fac[] = { 0.25, 0.50, 0.75, 1.00 }; + +#ifdef WITH_FFMPEG static int tc_types[] = { IMB_TC_RECORD_RUN, IMB_TC_FREE_RUN, IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN }; +#endif #define INDEX_FILE_VERSION 1 @@ -398,7 +401,7 @@ static void get_tc_filename(struct anim * anim, IMB_Timecode_Type tc, { char index_dir[FILE_MAXDIR]; int i = IMB_timecode_to_array_index(tc); - char * index_names[] = { + const char * index_names[] = { "record_run%s.blen_tc", "free_run%s.blen_tc", "interp_free_run%s.blen_tc" }; @@ -928,7 +931,7 @@ static AviMovie * alloc_proxy_output_avi( } static void index_rebuild_fallback(struct anim * anim, - IMB_Timecode_Type tcs_in_use, + IMB_Timecode_Type UNUSED(tcs_in_use), IMB_Proxy_Size proxy_sizes_in_use, int quality, short *stop, short *do_update, -- cgit v1.2.3 From ea07e367c5e803a40ff4f0f50d28f88d9104434c Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Mon, 29 Aug 2011 03:20:15 +0000 Subject: bge bugfix: [#28362] Controllers names appear incorrectly with a python query the uniquename was never fully implemented for sensors and actuators, only for controllers. at some point we either get rid of all of them, or bring them all on. For now removing the "unique name" of controllers --- source/gameengine/Converter/KX_ConvertControllers.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 98afc3a690a..fafaaf5cef6 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -210,7 +210,11 @@ void BL_ConvertControllers( CIntValue* uniqueval = new CIntValue(uniqueint); uniquename += uniqueval->GetText(); uniqueval->Release(); - gamecontroller->SetName(uniquename); + //unique name was never implemented for sensors and actuators, only for controllers + //and it's producing difference in the keys for the lists: obj.controllers/sensors/actuators + //at some point it should either be implemented globally (and saved as a separate var) or removed. + //gamecontroller->SetName(uniquename); + gamecontroller->SetName(bcontr->name); gameobj->AddController(gamecontroller); converter->RegisterGameController(gamecontroller, bcontr); -- cgit v1.2.3 From 296cc41b03b18fbe65357aa0cfdf43f43c881922 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Mon, 29 Aug 2011 06:19:55 +0000 Subject: BGE Animations: Various changes to make code reviewers happy: * Naming/style changes * Taking advantage of switch statements * Removing unneeded NULL checks * etc --- source/gameengine/Converter/BL_ActionActuator.cpp | 105 +++++++++++---------- source/gameengine/Converter/BL_ActionActuator.h | 2 +- source/gameengine/Converter/BL_ArmatureObject.cpp | 7 +- .../Converter/BL_DeformableGameObject.cpp | 5 +- source/gameengine/Ketsji/BL_ActionManager.cpp | 21 ++--- 5 files changed, 71 insertions(+), 69 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index ec5ab423f60..50afac6992e 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -139,46 +139,51 @@ bool BL_ActionActuator::Update(double curtime, bool frame) { bool bNegativeEvent = false; bool bPositiveEvent = false; - bool use_continue = false; + bool bUseContinue = false; KX_GameObject *obj = (KX_GameObject*)GetParent(); - short play_mode = BL_Action::ACT_MODE_PLAY; - float start = m_startframe, end = m_endframe; + short playtype = BL_Action::ACT_MODE_PLAY; + float start = m_startframe; + float end = m_endframe; // If we don't have an action, we can't do anything if (!m_action) return false; - // Convert playmode - if (m_playtype == ACT_ACTION_LOOP_END) - play_mode = BL_Action::ACT_MODE_LOOP; - else if (m_playtype == ACT_ACTION_LOOP_STOP) - play_mode = BL_Action::ACT_MODE_LOOP; - else if (m_playtype == ACT_ACTION_PINGPONG) + // Convert our playtype to one that BL_Action likes + switch(m_playtype) { - // We handle ping pong ourselves to increase compabitility with the pre-Pepper actuator - play_mode = BL_Action::ACT_MODE_PLAY; + case ACT_ACTION_LOOP_END: + case ACT_ACTION_LOOP_STOP: + playtype = BL_Action::ACT_MODE_LOOP; + break; + + case ACT_ACTION_PINGPONG: + // We handle ping pong ourselves to increase compabitility + // with files made prior to animation changes from GSoC 2011. + playtype = BL_Action::ACT_MODE_PLAY; - if (m_flag & ACT_FLAG_REVERSE) - { - float tmp = start; - start = end; - end = tmp; - m_localtime = end; - } - } - else if (m_playtype == ACT_ACTION_FROM_PROP) - { - CValue* prop = GetParent()->GetProperty(m_propname); + if (m_flag & ACT_FLAG_REVERSE) + { + m_localtime = start; + start = end; + end = m_localtime; + } + + break; + case ACT_ACTION_FROM_PROP: + CValue* prop = GetParent()->GetProperty(m_propname); - play_mode = BL_Action::ACT_MODE_PLAY; - start = end = prop->GetNumber(); + playtype = BL_Action::ACT_MODE_PLAY; + start = end = prop->GetNumber(); + + break; } // Continue only really makes sense for play stop and flipper. All other modes go until they are complete. if (m_flag & ACT_FLAG_CONTINUE && (m_playtype == ACT_ACTION_LOOP_STOP || m_playtype == ACT_ACTION_FLIPPER)) - use_continue = true; + bUseContinue = true; // Handle events @@ -189,15 +194,15 @@ bool BL_ActionActuator::Update(double curtime, bool frame) RemoveAllEvents(); } - if (use_continue && m_flag & ACT_FLAG_ACTIVE) + if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE)) m_localtime = obj->GetActionFrame(m_layer); if (bPositiveEvent) { - if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, play_mode, m_layer_weight, m_ipo_flags)) + if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags)) { m_flag |= ACT_FLAG_ACTIVE; - if (use_continue) + if (bUseContinue) obj->SetActionFrame(m_layer, m_localtime); if (m_playtype == ACT_ACTION_PLAY) @@ -225,32 +230,32 @@ bool BL_ActionActuator::Update(double curtime, bool frame) if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) m_localtime = m_startframe; - if (m_playtype == ACT_ACTION_LOOP_STOP) - { - obj->StopAction(m_layer); // Stop the action after getting the frame - - // We're done - m_flag &= ~ACT_FLAG_ACTIVE; - return false; - } - else if (m_playtype == ACT_ACTION_LOOP_END || m_playtype == ACT_ACTION_PINGPONG) + switch(m_playtype) { - // Convert into a play and let it finish - obj->SetPlayMode(m_layer, BL_Action::ACT_MODE_PLAY); - - m_flag |= ACT_FLAG_PLAY_END; + case ACT_ACTION_LOOP_STOP: + obj->StopAction(m_layer); // Stop the action after getting the frame - if (m_playtype == ACT_ACTION_PINGPONG) + // We're done + m_flag &= ~ACT_FLAG_ACTIVE; + return false; + case ACT_ACTION_PINGPONG: m_flag ^= ACT_FLAG_REVERSE; - } - else if (m_playtype == ACT_ACTION_FLIPPER) - { - // Convert into a play action and play back to the beginning - end = start; - start = obj->GetActionFrame(m_layer); - obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags); + // Now fallthrough to LOOP_END code + case ACT_ACTION_LOOP_END: + // Convert into a play and let it finish + obj->SetPlayMode(m_layer, BL_Action::ACT_MODE_PLAY); - m_flag |= ACT_FLAG_PLAY_END; + m_flag |= ACT_FLAG_PLAY_END; + break; + + case ACT_ACTION_FLIPPER: + // Convert into a play action and play back to the beginning + end = start; + start = obj->GetActionFrame(m_layer); + obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags); + + m_flag |= ACT_FLAG_PLAY_END; + break; } } diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 126f2f29136..5324cb10885 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -149,7 +149,7 @@ enum { ACT_FLAG_KEYUP = 1<<2, ACT_FLAG_ACTIVE = 1<<3, ACT_FLAG_CONTINUE = 1<<4, - ACT_FLAG_PLAY_END = 1<<5 + ACT_FLAG_PLAY_END = 1<<5, }; diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 72a31566e7c..395cae4ba87 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -138,19 +138,22 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) /* Only allowed for Poses with identical channels */ void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/) -{ +{ + short mode= ACTSTRIPMODE_BLEND; + bPoseChannel *dchan; const bPoseChannel *schan; bConstraint *dcon, *scon; float dstweight; int i; - short mode = ACTSTRIPMODE_BLEND; switch (mode){ case ACTSTRIPMODE_BLEND: dstweight = 1.0F - srcweight; break; case ACTSTRIPMODE_ADD: + dstweight = 1.0F; + break; default : dstweight = 1.0F; } diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp index 58294f2940e..48392ee8dda 100644 --- a/source/gameengine/Converter/BL_DeformableGameObject.cpp +++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp @@ -92,10 +92,11 @@ bool BL_DeformableGameObject::GetShape(vector &shape) { // this check is normally superfluous: a shape deformer can only be created if the mesh // has relative keys - if (shape_deformer->GetKey() && shape_deformer->GetKey()->type==KEY_RELATIVE) + Key* key = shape_deformer->GetKey(); + if (key && key->type==KEY_RELATIVE) { KeyBlock *kb; - for (kb = (KeyBlock*)shape_deformer->GetKey()->block.first; kb; kb = (KeyBlock*)kb->next) + for (kb = (KeyBlock*)key->block.first; kb; kb = (KeyBlock*)kb->next) { shape.push_back(kb->curval); } diff --git a/source/gameengine/Ketsji/BL_ActionManager.cpp b/source/gameengine/Ketsji/BL_ActionManager.cpp index af0d4bff8f0..4e4d3bc539e 100644 --- a/source/gameengine/Ketsji/BL_ActionManager.cpp +++ b/source/gameengine/Ketsji/BL_ActionManager.cpp @@ -37,42 +37,36 @@ BL_ActionManager::BL_ActionManager(class KX_GameObject *obj) BL_ActionManager::~BL_ActionManager() { for (int i=0; iGetFrame(); + return m_layers[layer]->GetFrame(); return 0.f; } void BL_ActionManager::SetActionFrame(short layer, float frame) { - if (m_layers[layer]) - m_layers[layer]->SetFrame(frame); + m_layers[layer]->SetFrame(frame); } struct bAction *BL_ActionManager::GetCurrentAction(short layer) { - if (m_layers[layer]) - return m_layers[layer]->GetAction(); + return m_layers[layer]->GetAction(); return 0; } void BL_ActionManager::SetPlayMode(short layer, short mode) { - if (m_layers[layer]) - m_layers[layer]->SetPlayMode(mode); + m_layers[layer]->SetPlayMode(mode); } void BL_ActionManager::SetTimes(short layer, float start, float end) { - if (m_layers[layer]) - m_layers[layer]->SetTimes(start, end); + m_layers[layer]->SetTimes(start, end); } bool BL_ActionManager::PlayAction(const char* name, @@ -99,8 +93,7 @@ void BL_ActionManager::StopAction(short layer) bool BL_ActionManager::IsActionDone(short layer) { - if (m_layers[layer]) - return m_layers[layer]->IsDone(); + return m_layers[layer]->IsDone(); return true; } -- cgit v1.2.3 From 6cf447a29c0c8dbdb318e28e3c8c8f95f92f5152 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 29 Aug 2011 12:57:46 +0000 Subject: Fix player build error after envmap commit. --- source/blenderplayer/bad_level_call_stubs/stubs.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source') diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 0f7a02b766e..39129fa45d7 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -51,6 +51,7 @@ struct Curve; struct EditBone; struct EditFace; struct EditMesh; +struct EnvMap; struct ID; struct FCurve; struct ImBuf; @@ -145,6 +146,7 @@ double elbeemEstimateMemreq(int res, float sx, float sy, float sz, int refine, c struct Render *RE_NewRender(const char *name){return (struct Render*) NULL;} void RE_SwapResult(struct Render *re, struct RenderResult **rr){} void RE_BlenderFrame(struct Render *re, struct Scene *scene, int frame){} +int RE_WriteEnvmapResult(struct ReportList *reports, struct Scene *scene, struct EnvMap *env, const char *relpath, int imtype, float layout[12]) { return 0; } /* rna */ float *give_cursor(struct Scene *scene, struct View3D *v3d){return (float *) NULL;} -- cgit v1.2.3 From 5bac37f6d4d2e8d584ae0ec6bafd2808c47fbb25 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Mon, 29 Aug 2011 15:01:55 +0000 Subject: * Reverting Titlecard commit r37537 * Reverting update recent files commit r37155 * Turning reference counts into unsigned ints * Minor things --- source/blender/blenfont/BLF_api.h | 1 - source/blender/blenfont/intern/blf.c | 1 - source/blender/blenkernel/intern/seqeffects.c | 135 --------------------- source/blender/blenkernel/intern/sequencer.c | 3 +- source/blender/blenkernel/intern/sound.c | 1 - source/blender/blenloader/intern/writefile.c | 3 - source/blender/editors/interface/interface_style.c | 10 -- .../editors/space_sequencer/sequencer_draw.c | 1 - .../editors/space_sequencer/sequencer_edit.c | 3 +- source/blender/makesdna/DNA_sequence_types.h | 11 +- source/blender/makesdna/DNA_userdef_types.h | 1 - source/blender/makesrna/RNA_access.h | 1 - source/blender/makesrna/intern/rna_scene.c | 17 +-- source/blender/makesrna/intern/rna_sequencer.c | 35 ------ source/blender/makesrna/intern/rna_sound.c | 2 +- source/blender/makesrna/intern/rna_userdef.c | 6 +- source/blender/windowmanager/intern/wm_files.c | 7 +- 17 files changed, 15 insertions(+), 223 deletions(-) (limited to 'source') diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index fba09ee9826..57f8c83eda6 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -215,6 +215,5 @@ void BLF_dir_free(char **dirs, int count); // XXX, bad design extern int blf_mono_font; extern int blf_mono_font_render; // dont mess drawing with render threads. -extern int blf_default_font_render; // dont mess drawing with render threads. #endif /* BLF_API_H */ diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 3bfb7c22082..c0e62b1c0c7 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -74,7 +74,6 @@ static int global_font_dpi= 72; // XXX, should these be made into global_font_'s too? int blf_mono_font= -1; int blf_mono_font_render= -1; -int blf_default_font_render= -1; static FontBLF *BLF_get(int fontid) { diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 7e760319e70..34748c64efb 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -40,11 +40,8 @@ #include "BLI_dynlib.h" #include "BLI_math.h" /* windows needs for M_PI */ -#include "BLI_string.h" #include "BLI_utildefines.h" -#include "BLF_api.h" - #include "DNA_scene_types.h" #include "DNA_sequence_types.h" #include "DNA_anim_types.h" @@ -2807,130 +2804,6 @@ static struct ImBuf * do_solid_color( return out; } -/* ********************************************************************** - TITLE CARD - ********************************************************************** */ - -static void init_title_card(Sequence *seq) -{ - TitleCardVars *tv; - - if(seq->effectdata)MEM_freeN(seq->effectdata); - seq->effectdata = MEM_callocN(sizeof(struct TitleCardVars), "titlecard"); - - tv = (TitleCardVars *)seq->effectdata; - - BLI_strncpy(tv->titlestr, "Title goes here", sizeof(tv->titlestr)); - tv->fgcol[0] = tv->fgcol[1] = tv->fgcol[2] = 1.0f; /* white */ -} - -static int num_inputs_titlecard(void) -{ - return 0; -} - -static void free_title_card(Sequence *seq) -{ - if(seq->effectdata)MEM_freeN(seq->effectdata); - seq->effectdata = NULL; -} - -static void copy_title_card(Sequence *dst, Sequence *src) -{ - dst->effectdata = MEM_dupallocN(src->effectdata); -} - -static int early_out_titlecard(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) -{ - return -1; -} - -static struct ImBuf * do_title_card( - SeqRenderData context, Sequence *seq, float cfra, - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - TitleCardVars *tv = (TitleCardVars *)seq->effectdata; - - SolidColorVars cv = {{0}}; - struct ImBuf *out; - - int titleFontId = blf_default_font_render; // XXX: bad design! - - int width = context.rectx; - int height = context.recty; - float w, h; - int x, y; - - /* use fake solid-color vars to get backdrop (and an out buffer at the same time) */ - VECCOPY(cv.col, tv->bgcol); - seq->effectdata = &cv; - - out = do_solid_color(context, seq, cfra, - facf0, facf1, - ibuf1, ibuf2, ibuf3); - - seq->effectdata = tv; - - /* draw text */ - /* FIXME: imbuf out->rect is unsigned int NOT unsigned char, but without passing this pointer - * this drawing code doesn't work. This cast really masks some potential bugs though... - */ - BLF_buffer(titleFontId, out->rect_float, (unsigned char *)out->rect, width, height, 4); - - if (tv->titlestr[0]) { - /* automatic scale - these formulae have been derived experimentally: - * - base size is based on 40pt at 960 width - * - each 26 characters, size jumps down one step, - * but this decrease needs to be exponential to fit everything - */ - float lfac = strlen(tv->titlestr) / 26.0f; - float size = (width * 0.06f) * (1.0f - 0.1f*lfac*lfac); - - BLF_size(titleFontId, size, 72); - BLF_buffer_col(titleFontId, tv->fgcol[0], tv->fgcol[1], tv->fgcol[2], 1.0); - - BLF_width_and_height(titleFontId, tv->titlestr, &w, &h); - x = width/2.0f - w/2.0f; - if (tv->subtitle[0]) - y = height/2.0f + h; - else - y = height/2.0f; - - BLF_position(titleFontId, x, y, 0.0); - BLF_draw_buffer(titleFontId, tv->titlestr); - } - - if (tv->subtitle[0]) { - /* automatic scale - these formulae have been derived experimentally (as above): - * - base size is based on 20pt at 960 width - * - size steps aren't quite as refined here. Need a slower-growing curve! - */ - float lfac = strlen(tv->subtitle) / 36.0f; - float size = (width * 0.03f) * (1.0f - 0.1f*lfac*lfac*log(lfac)); - - BLF_size(titleFontId, size, 72); - BLF_buffer_col(titleFontId, tv->fgcol[0], tv->fgcol[1], tv->fgcol[2], 1.0); - - BLF_width_and_height(titleFontId, tv->subtitle, &w, &h); - x = width/2.0f - w/2.0f; - if (tv->titlestr[0]) - y = height/2.0f - h; - else - y = height/2.0f; - - BLF_position(titleFontId, x, y, 0.0); - BLF_draw_buffer(titleFontId, tv->subtitle); - } - - /* cleanup the buffer. */ - BLF_buffer(UIFONT_DEFAULT, NULL, NULL, 0, 0, 0); - - return out; -} - /* ********************************************************************** MULTICAM ********************************************************************** */ @@ -3470,14 +3343,6 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) rval.early_out = early_out_adjustment; rval.execute = do_adjustment; break; - case SEQ_TITLECARD: - rval.init = init_title_card; - rval.num_inputs = num_inputs_titlecard; - rval.early_out = early_out_titlecard; - rval.free = free_title_card; - rval.copy = copy_title_card; - rval.execute = do_title_card; - break; } return rval; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index bfbaa223a99..023a10b3103 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -903,7 +903,6 @@ static const char *give_seqname_by_type(int type) case SEQ_MULTICAM: return "Multicam"; case SEQ_ADJUSTMENT: return "Adjustment"; case SEQ_SPEED: return "Speed"; - case SEQ_TITLECARD: return "Title Card"; default: return NULL; } @@ -3029,7 +3028,7 @@ Sequence *seq_foreground_frame_get(Scene *scene, int frame) if(seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) continue; /* only use elements you can see - not */ - if (ELEM6(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_COLOR, SEQ_TITLECARD)) { + if (ELEM5(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_COLOR)) { if (seq->machine > best_machine) { best_seq = seq; best_machine = seq->machine; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 842923e63d0..abead8d43dd 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -24,7 +24,6 @@ #include "DNA_sound_types.h" #include "DNA_speaker_types.h" -#define WITH_AUDASPACE #ifdef WITH_AUDASPACE # include "AUD_C-API.h" #endif diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index ed18945ea86..824b0410bd4 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1919,9 +1919,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase) case SEQ_TRANSFORM: writestruct(wd, DATA, "TransformVars", 1, seq->effectdata); break; - case SEQ_TITLECARD: - writestruct(wd, DATA, "TitleCardVars", 1, seq->effectdata); - break; } } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 704b9ae3a80..8d4b4209120 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -295,7 +295,6 @@ void uiStyleInit(void) { uiFont *font= U.uifonts.first; uiStyle *style= U.uistyles.first; - int defaultFontId = -1; /* recover from uninitialized dpi */ if(U.dpi == 0) @@ -315,7 +314,6 @@ void uiStyleInit(void) if(font->uifont_id==UIFONT_DEFAULT) { font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); - defaultFontId = font->blf_id; } else { font->blf_id= BLF_load(font->filename); @@ -353,14 +351,6 @@ void uiStyleInit(void) blf_mono_font_render= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); BLF_size(blf_mono_font_render, 12, 72); - - /* also another copy of default for rendering else we get threading problems */ - if (defaultFontId != -1) { - if (blf_default_font_render == -1) - blf_default_font_render= BLF_load_mem_unique("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); - - BLF_size(blf_default_font_render, 12, 72); - } } void uiStyleFontSet(uiFontStyle *fs) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 352e9f43648..a7b2250e37d 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -127,7 +127,6 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ case SEQ_GLOW: case SEQ_MULTICAM: case SEQ_ADJUSTMENT: - case SEQ_TITLECARD: UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col); /* slightly offset hue to distinguish different effects */ diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 24f2f5e7b4a..876280d5b0f 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -94,10 +94,9 @@ EnumPropertyItem sequencer_prop_effect_types[] = { {SEQ_GLOW, "GLOW", 0, "Glow", "Glow effect strip type"}, {SEQ_TRANSFORM, "TRANSFORM", 0, "Transform", "Transform effect strip type"}, {SEQ_COLOR, "COLOR", 0, "Color", "Color effect strip type"}, - {SEQ_SPEED, "SPEED", 0, "Speed", ""}, + {SEQ_SPEED, "SPEED", 0, "Speed", "Color effect strip type"}, {SEQ_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""}, {SEQ_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""}, - {SEQ_TITLECARD, "TITLE_CARD", 0, "Title Card", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index 359ef8449e9..93cbb643334 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -227,14 +227,6 @@ typedef struct SolidColorVars { float pad; } SolidColorVars; -typedef struct TitleCardVars { - char titlestr[64]; - char subtitle[128]; - - float fgcol[3]; - float bgcol[3]; -} TitleCardVars; - typedef struct SpeedControlVars { float * frameMap; float globalSpeed; @@ -328,8 +320,7 @@ typedef struct SpeedControlVars { #define SEQ_SPEED 29 #define SEQ_MULTICAM 30 #define SEQ_ADJUSTMENT 31 -#define SEQ_TITLECARD 40 -#define SEQ_EFFECT_MAX 40 +#define SEQ_EFFECT_MAX 31 #define STRIPELEM_FAILED 0 #define STRIPELEM_OK 1 diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index e211a7c33c1..43dc532d4f6 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -442,7 +442,6 @@ extern UserDef U; /* from blenkernel blender.c */ #define USER_NONEGFRAMES (1 << 24) #define USER_TXT_TABSTOSPACES_DISABLE (1 << 25) #define USER_TOOLTIPS_PYTHON (1 << 26) -#define USER_NO_RECENTLOAD_UPDATE (1 << 27) /* helper macro for checking frame clamping */ #define FRAMENUMBER_MIN_CLAMP(cfra) \ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index b5b178c6c01..259c7de5cd4 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -536,7 +536,6 @@ extern StructRNA RNA_ThemeWidgetColors; extern StructRNA RNA_ThemeWidgetStateColors; extern StructRNA RNA_TimelineMarker; extern StructRNA RNA_Timer; -extern StructRNA RNA_TitleCardSequence; extern StructRNA RNA_ToolSettings; extern StructRNA RNA_TouchSensor; extern StructRNA RNA_TrackToConstraint; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 2a558da1cb0..8cf5e3d14ec 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2500,26 +2500,27 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bitrate", "Audio bitrate(kb/s)"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "ffmpeg_audio_mixrate", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.audio_mixrate"); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_range(prop, 8000, 192000); - RNA_def_property_ui_text(prop, "Samplerate", "Audio samplerate(samples/s)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); - prop= RNA_def_property(srna, "ffmpeg_audio_volume", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "ffcodecdata.audio_volume"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Volume", "Audio volume"); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); +#endif + + // the following two "ffmpeg" settings are general audio settings + prop= RNA_def_property(srna, "ffmpeg_audio_mixrate", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.audio_mixrate"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_range(prop, 8000, 192000); + RNA_def_property_ui_text(prop, "Samplerate", "Audio samplerate(samples/s)"); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "ffmpeg_audio_channels", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ffcodecdata.audio_channels"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, audio_channel_items); RNA_def_property_ui_text(prop, "Audio Channels", "Sets the audio channel count"); -#endif prop= RNA_def_property(srna, "fps", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "frs_sec"); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 6da4cddf1c1..c1f8bdc315d 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -409,8 +409,6 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) return &RNA_ColorSequence; case SEQ_SPEED: return &RNA_SpeedControlSequence; - case SEQ_TITLECARD: - return &RNA_TitleCardSequence; default: return &RNA_Sequence; } @@ -889,7 +887,6 @@ static void rna_def_sequence(BlenderRNA *brna) {SEQ_SPEED, "SPEED", 0, "Speed", ""}, {SEQ_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""}, {SEQ_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""}, - {SEQ_TITLECARD, "TITLE_CARD", 0, "Title Card", ""}, {0, NULL, 0, NULL, NULL}}; static const EnumPropertyItem blend_mode_items[]= { @@ -1683,37 +1680,6 @@ static void rna_def_speed_control(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); } -static void rna_def_title_card(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "TitleCardSequence", "EffectSequence"); - RNA_def_struct_ui_text(srna, "Title Card Sequence", "Sequence strip creating an image displaying some text on a plain color background"); - RNA_def_struct_sdna_from(srna, "TitleCardVars", "effectdata"); - - /* texts */ - prop= RNA_def_property(srna, "title", PROP_STRING, PROP_NONE); - RNA_def_property_string_sdna(prop, NULL, "titlestr"); - RNA_def_property_ui_text(prop, "Title", "Text for main heading"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); - - prop= RNA_def_property(srna, "subtitle", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Subtitle", "Additional text to be shown under the main heading"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); - - /* colors */ - prop= RNA_def_property(srna, "color_background", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "bgcol"); - RNA_def_property_ui_text(prop, "Background Color", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); - - prop= RNA_def_property(srna, "color_foreground", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "fgcol"); - RNA_def_property_ui_text(prop, "Text Color", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); -} - void RNA_def_sequencer(BlenderRNA *brna) { rna_def_strip_element(brna); @@ -1739,7 +1705,6 @@ void RNA_def_sequencer(BlenderRNA *brna) rna_def_transform(brna); rna_def_solid_color(brna); rna_def_speed_control(brna); - rna_def_title_card(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_sound.c b/source/blender/makesrna/intern/rna_sound.c index b224b55c20c..3a18fb0e7c0 100644 --- a/source/blender/makesrna/intern/rna_sound.c +++ b/source/blender/makesrna/intern/rna_sound.c @@ -96,7 +96,7 @@ static void rna_def_sound(BlenderRNA *brna) prop= RNA_def_property(srna, "mono", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SOUND_FLAGS_MONO); - RNA_def_property_ui_text(prop, "Mono", "If the file contains multiple audio channels they are mixdown to a signle one."); + RNA_def_property_ui_text(prop, "Mono", "If the file contains multiple audio channels they are rendered to a single one."); RNA_def_property_update(prop, 0, "rna_Sound_update"); } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index a67cd40e62a..7d0502f1be9 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2950,11 +2950,7 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) prop= RNA_def_property(srna, "recent_files", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 0, 30); RNA_def_property_ui_text(prop, "Recent Files", "Maximum number of recently opened files to remember"); - - prop= RNA_def_property(srna, "use_update_recent_files_on_load", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", USER_NO_RECENTLOAD_UPDATE); - RNA_def_property_ui_text(prop, "Update Recent on Load", "When enabled, opening files will update the recent files list. Otherwise, updates only occur when saving"); - + prop= RNA_def_property(srna, "use_save_preview_images", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", USER_SAVE_PREVIEWS); RNA_def_property_ui_text(prop, "Save Preview Images", "Enables automatic saving of preview images in the .blend file"); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index a857577fcc8..6b3a574b6b6 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -387,12 +387,7 @@ void WM_read_file(bContext *C, const char *filepath, ReportList *reports) if (retval != BKE_READ_FILE_FAIL) { G.relbase_valid = 1; - - /* dont write recent file list if: - * 1) assuming automated tasks with background - * 2) user preference to not do this is enabled (i.e. developer testing mode) - */ - if (!G.background && !(U.flag & USER_NO_RECENTLOAD_UPDATE)) + if(!G.background) /* assume automated tasks with background, dont write recent file list */ write_history(); } -- cgit v1.2.3 From 88a538048bf7671db6a51fa2791ed1c87fa88611 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 29 Aug 2011 16:07:44 +0000 Subject: Fix #28347: VBO's highlights wrong faces when Mirror modifier is in use Added callback to drawMappedFaces which checks if two faces have got equal draw options. After discussion with Brecht we found it's nicest solution for now: - Disabling VBOs in edit mode for this case wouldn't be nicer for this case - some additional flag stored in DM should be added in this case. - Adding new callback in DM isn't nicer that this solution. - Handling face selection in drawobject would lead to duplicated code which is also not nice. Hopefully, this callback could handle all cases in the future. Also, Brecht mentioned current VBO implementation isn't perfect, so maybe when we'll redesign this area dealing with edit mode wouldn't be so tricky. --- source/blender/blenkernel/BKE_DerivedMesh.h | 3 +- source/blender/blenkernel/intern/DerivedMesh.c | 6 +++- source/blender/blenkernel/intern/cdderivedmesh.c | 31 +++++++++++++---- source/blender/blenkernel/intern/subsurf_ccg.c | 6 +++- source/blender/editors/space_view3d/drawmesh.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 44 ++++++++++++++++++------ 6 files changed, 71 insertions(+), 21 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 46b533f33fd..6e17b056685 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -283,7 +283,8 @@ struct DerivedMesh { int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, - int (*setMaterial)(int, void *attribs)); + int (*setMaterial)(int, void *attribs), + int (*compareDrawOptions)(void *userData, int cur_index, int next_index)); /* Draw mapped faces using MTFace * o Drawing options too complicated to enumerate, look at code. diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c84bcaabbd3..ff7f2586767 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -637,7 +637,8 @@ static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *use } /* note, material function is ignored for now. */ -static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int UNUSED(useColors), int (*setMaterial)(int, void *attribs)) +static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int UNUSED(useColors), int (*setMaterial)(int, void *attribs), + int (*compareDrawOptions)(void *userData, int cur_index, int next_index)) { EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; EditFace *efa; @@ -645,6 +646,9 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us (void)setMaterial; /* unused */ + /* currently unused -- each original face is handled separately */ + (void)compareDrawOptions; + if (emdm->vertexCos) { EditVert *eve; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 12fb11c68b3..5eb97630e83 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -843,7 +843,8 @@ static void cdDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tfa cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL); } -static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs)) +static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs), + int (*compareDrawOptions)(void *userData, int cur_index, int next_index)) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; MVert *mv = cddm->mvert; @@ -958,6 +959,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us MFace *mface= mf + actualFace; int drawSmooth= (mface->flag & ME_SMOOTH); int draw = 1; + int flush = 0; if(i != tottri-1) next_actualFace= dm->drawObject->triangle_to_mface[i+1]; @@ -972,11 +974,28 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us /* Goal is to draw as long of a contiguous triangle array as possible, so draw when we hit either an invisible triangle or at the end of the array */ - if(!draw || i == tottri - 1 || mf[actualFace].mat_nr != mf[next_actualFace].mat_nr) { - if(prevstart != i) - /* Add one to the length (via `draw') - if we're drawing at the end of the array */ - glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3); + + /* flush buffer if current triangle isn't drawable or it's last triangle... */ + flush= !draw || i == tottri - 1; + + /* ... or when material setting is dissferent */ + flush|= mf[actualFace].mat_nr != mf[next_actualFace].mat_nr; + + if(!flush && compareDrawOptions) { + int next_orig= (index==NULL) ? next_actualFace : index[next_actualFace]; + + /* also compare draw options and flush buffer if they're different + need for face selection highlight in edit mode */ + flush|= compareDrawOptions(userData, orig, next_orig) == 0; + } + + if(flush) { + int first= prevstart*3; + int count= (i-prevstart+(draw ? 1 : 0))*3; /* Add one to the length if we're drawing at the end of the array */ + + if(count) + glDrawArrays(GL_TRIANGLES, first, count); + prevstart = i + 1; } } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 67d7e7bffd6..186a5ea1852 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1779,7 +1779,8 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm) } } -static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs)) { +static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs), + int (*compareDrawOptions)(void *userData, int cur_index, int next_index)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; MCol *mcol= NULL; @@ -1787,6 +1788,9 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u char *faceFlags = ccgdm->faceFlags; int gridFaces = gridSize - 1, totface; + /* currently unused -- each original face is handled separately */ + (void)compareDrawOptions; + if(useColors) { mcol = dm->getFaceDataArray(dm, CD_WEIGHT_MCOL); if(!mcol) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 71c85483244..6e02ecbd5a8 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -607,7 +607,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o } else if(faceselect) { if(ob->mode & OB_MODE_WEIGHT_PAINT) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me, 1, GPU_enable_material, NULL); else dm->drawMappedFacesTex(dm, me->mface ? draw_tface_mapped__set_draw : NULL, me); } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 638d197ccf7..8ca352ffe42 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2030,6 +2030,28 @@ static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *UNU return 0; } +static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int next_index) +{ + struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData; + EditFace *efa = EM_get_face_for_index(index); + EditFace *next_efa = EM_get_face_for_index(next_index); + unsigned char *col, *next_col; + + if(efa == next_efa) + return 1; + + if(efa == data->efa_act || next_efa == data->efa_act) + return 0; + + col = data->cols[(efa->f&SELECT)?1:0]; + next_col = data->cols[(next_efa->f&SELECT)?1:0]; + + if(col[3]==0 || next_col[3]==0) + return 0; + + return col == next_col; +} + /* also draws the active face */ static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act) { @@ -2039,7 +2061,7 @@ static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned data.cols[2] = actCol; data.efa_act = efa_act; - dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material); + dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions); } static int draw_dm_creases__setDrawOptions(void *UNUSED(userData), int index) @@ -2449,7 +2471,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object glEnable(GL_LIGHTING); glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW); - finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material); + finalDM->drawMappedFaces(finalDM, draw_em_fancy__setFaceOpts, NULL, 0, GPU_enable_material, NULL); glFrontFace(GL_CCW); glDisable(GL_LIGHTING); @@ -2678,7 +2700,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* weight paint in solid mode, special case. focus on making the weights clear * rather than the shading, this is also forced in wire view */ GPU_enable_material(0, NULL); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material, NULL); bglPolygonOffset(rv3d->dist, 1.0); glDepthMask(0); // disable write in zbuffer, selected edge wires show better @@ -2758,7 +2780,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D glEnable(GL_LIGHTING); glEnable(GL_COLOR_MATERIAL); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, me->mface, 1, GPU_enable_material, NULL); glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); @@ -2766,10 +2788,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_TEXTURE_PAINT)) { if(me->mcol) - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 1, GPU_enable_material, NULL); else { glColor3f(1.0f, 1.0f, 1.0f); - dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material); + dm->drawMappedFaces(dm, wpaint__setSolidDrawOptions, NULL, 0, GPU_enable_material, NULL); } } } @@ -6459,7 +6481,7 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh cpack(0); if (facecol) { - dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0, GPU_enable_material); + dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*)(intptr_t) 1, 0, GPU_enable_material, NULL); if(check_ob_drawface_dot(scene, v3d, ob->dt)) { glPointSize(UI_GetThemeValuef(TH_FACEDOT_SIZE)); @@ -6470,7 +6492,7 @@ static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh } } else { - dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*) 0, 0, GPU_enable_material); + dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*) 0, 0, GPU_enable_material, NULL); } } @@ -6499,8 +6521,8 @@ static void bbs_mesh_solid(Scene *scene, Object *ob) glColor3ub(0, 0, 0); - if((me->editflag & ME_EDIT_PAINT_MASK)) dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, me, 0, GPU_enable_material); - else dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0, GPU_enable_material); + if((me->editflag & ME_EDIT_PAINT_MASK)) dm->drawMappedFaces(dm, bbs_mesh_solid_hide__setDrawOpts, me, 0, GPU_enable_material, NULL); + else dm->drawMappedFaces(dm, bbs_mesh_solid__setDrawOpts, me, 0, GPU_enable_material, NULL); dm->release(dm); } @@ -6607,7 +6629,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r GPU_end_object_materials(); } else if(edm) - edm->drawMappedFaces(edm, NULL, NULL, 0, GPU_enable_material); + edm->drawMappedFaces(edm, NULL, NULL, 0, GPU_enable_material, NULL); glDisable(GL_LIGHTING); } -- cgit v1.2.3 From 099760cf1f7969d1cd16c6b5bd1a77d86bc62547 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 29 Aug 2011 17:46:07 +0000 Subject: Fix #28295 Outliner, mouse button on menu's pass through. It was introduced in rev33603 with not good patch -- release event was catching by outliner after clicking on menu item. Use KM_CLICK instead of KM_RELEASE to deal with icon drag/drop. This not changes drag/drop behavior, but prevents unneeded event be handled. Also make consistent behavior of activating and extending selection. --- source/blender/editors/space_outliner/outliner_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index f3e2c352172..2917aa5ffda 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -90,8 +90,8 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_DBL_CLICK, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_RELEASE, 0, 0)->ptr, "extend", 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1); + RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, 0, 0)->ptr, "extend", 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, KM_SHIFT, 0)->ptr, "extend", 1); RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, 0, 0)->ptr, "all", 0); RNA_boolean_set(WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "all", 1); -- cgit v1.2.3 From 5b5e600db6f529ad7e1af9d4bb3a193be2265342 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 30 Aug 2011 07:57:55 +0000 Subject: Last bunch of minor fixes before merge. * Use NULL in AUD_Reference.h * Use SETLOOPER in sound.c * Move flags to the end of Speaker struct. --- source/blender/blenkernel/intern/sound.c | 4 +++- source/blender/editors/sound/sound_ops.c | 7 +++++++ source/blender/makesdna/DNA_speaker_types.h | 7 ++++--- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index abead8d43dd..985fef974d3 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -37,6 +37,7 @@ #include "BKE_packedFile.h" #include "BKE_animsys.h" #include "BKE_sequencer.h" +#include "BKE_scene.h" // evil global ;-) static int sound_cfra; @@ -656,12 +657,13 @@ void sound_update_scene(struct Scene* scene) NlaTrack* track; NlaStrip* strip; Speaker* speaker; + Scene* sce_it; void* new_set = AUD_createSet(); void* handle; float quat[4]; - for(base = FIRSTBASE; base; base=base->next) + for(SETLOOPER(scene, sce_it, base)) { ob = base->object; if(ob->type == OB_SPEAKER) diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index fb4355d0df7..e66abffbfd1 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -648,6 +648,13 @@ static int update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op)) void SOUND_OT_update_animation_flags(wmOperatorType *ot) { + /* + This operator is needed to set a correct state of the sound animation + System. Unfortunately there's no really correct place to call the exec + function, that's why I made it an operator that's only visible in the + search menu. Apart from that the bake animation operator calls it too. + */ + /* identifiers */ ot->name= "Update animation"; ot->description= "Update animation flags"; diff --git a/source/blender/makesdna/DNA_speaker_types.h b/source/blender/makesdna/DNA_speaker_types.h index 50cb62c79e5..fecc65885c5 100644 --- a/source/blender/makesdna/DNA_speaker_types.h +++ b/source/blender/makesdna/DNA_speaker_types.h @@ -39,9 +39,6 @@ typedef struct Speaker { struct bSound *sound; - short flag; - short pad1[3]; - // not animatable properties float volume_max; float volume_min; @@ -55,6 +52,10 @@ typedef struct Speaker { // animatable properties float volume; float pitch; + + // flag + short flag; + short pad1[3]; } Speaker; /* **************** SPEAKER ********************* */ -- cgit v1.2.3 From 27ec8d5043f544685001aab3552b9b4b56bc1e1a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Aug 2011 09:50:31 +0000 Subject: fix for some warnings with the recent merge, also tag unused args. --- source/blender/blenlib/intern/BLI_kdopbvh.c | 8 +++--- source/blender/blenlib/intern/BLI_kdtree.c | 4 +-- source/blender/blenlib/intern/graph.c | 2 +- .../editors/animation/anim_channels_defines.c | 2 +- .../blender/editors/animation/anim_channels_edit.c | 2 +- source/blender/editors/animation/anim_filter.c | 2 +- source/blender/editors/armature/poseSlide.c | 6 ++-- source/blender/editors/armature/poseobject.c | 4 +-- source/blender/editors/object/object_select.c | 2 +- source/blender/editors/space_graph/graph_draw.c | 2 +- source/blender/editors/space_nla/nla_edit.c | 12 ++++---- .../editors/space_outliner/outliner_tools.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 33 +++++++++------------- source/blender/imbuf/CMakeLists.txt | 4 ++- source/blender/imbuf/intern/indexer_dv.c | 5 ++-- 15 files changed, 44 insertions(+), 46 deletions(-) (limited to 'source') diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 527692348e7..dcbe043f0d0 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -1494,7 +1494,7 @@ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *nod float t2z = (bv[data->index[5]] - data->ray.origin[2]) * data->idot_axis[2]; if(t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return FLT_MAX; - if(t2x < 0.0 || t2y < 0.0 || t2z < 0.0) return FLT_MAX; + if(t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return FLT_MAX; if(t1x > data->hit.dist || t1y > data->hit.dist || t1z > data->hit.dist) return FLT_MAX; dist = t1x; @@ -1599,11 +1599,11 @@ int BLI_bvhtree_ray_cast(BVHTree *tree, const float *co, const float *dir, float data.ray_dot_axis[i] = INPR( data.ray.direction, KDOP_AXES[i]); data.idot_axis[i] = 1.0f / data.ray_dot_axis[i]; - if(fabs(data.ray_dot_axis[i]) < FLT_EPSILON) + if(fabsf(data.ray_dot_axis[i]) < FLT_EPSILON) { data.ray_dot_axis[i] = 0.0; } - data.index[2*i] = data.idot_axis[i] < 0.0 ? 1 : 0; + data.index[2*i] = data.idot_axis[i] < 0.0f ? 1 : 0; data.index[2*i+1] = 1 - data.index[2*i]; data.index[2*i] += 2*i; data.index[2*i+1] += 2*i; @@ -1654,7 +1654,7 @@ float BLI_bvhtree_bb_raycast(float *bv, float *light_start, float *light_end, fl dist = ray_nearest_hit(&data, bv); - if(dist > 0.0) + if(dist > 0.0f) { VECADDFAC(pos, light_start, data.ray.direction, dist); } diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 713bfde3417..c885e8c8a9c 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -187,7 +187,7 @@ int BLI_kdtree_find_nearest(KDTree *tree, float *co, float *nor, KDTreeNearest * cur_dist = node->co[node->d] - co[node->d]; - if(cur_dist<0.0){ + if(cur_dist<0.0f){ cur_dist= -cur_dist*cur_dist; if(-cur_distco[node->d] - co[node->d]; - if(cur_dist<0.0){ + if(cur_dist<0.0f){ cur_dist= -cur_dist*cur_dist; if(foundlength - ring[i].arc->length) > limit) + if (fabsf(ring[first].arc->length - ring[i].arc->length) > limit) { dispatch = 1; } diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 806af4c0ef5..bdc654ff25a 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -1273,7 +1273,7 @@ static int acf_dstex_icon(bAnimListElem *UNUSED(ale)) /* offset for texture expanders */ // FIXME: soon to be obsolete? -static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *ale) +static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale)) { return 14; // XXX: simply include this in indention instead? } diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index c9d6f9a6420..d58d51c8e08 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2018,7 +2018,7 @@ static void rename_anim_channels (bAnimContext *ac, int channel_index) ED_region_tag_redraw(ac->ar); } -static int animchannels_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int animchannels_rename_invoke (bContext *C, wmOperator *UNUSED(op), wmEvent *evt) { bAnimContext ac; ARegion *ar; diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 0472731dd6d..8010a41ccb3 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -990,7 +990,7 @@ static size_t animfilter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve * return items; } -static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *act, bActionGroup *agrp, int filter_mode, ID *owner_id) +static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *UNUSED(act), bActionGroup *agrp, int filter_mode, ID *owner_id) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 3c15ff52a30..b0ff60455cf 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -520,7 +520,7 @@ static void pose_slide_reset (tPoseSlideOp *pso) /* ------------------------------------ */ /* draw percentage indicator in header */ -static void pose_slide_draw_status (bContext *C, tPoseSlideOp *pso) +static void pose_slide_draw_status (tPoseSlideOp *pso) { char statusStr[32]; char mode[32]; @@ -615,7 +615,7 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp * WM_cursor_modal(win, BC_EW_SCROLLCURSOR); /* header print */ - pose_slide_draw_status(C, pso); + pose_slide_draw_status(pso); /* add a modal handler for this operator */ WM_event_add_modal_handler(C, op); @@ -672,7 +672,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) RNA_float_set(op->ptr, "percentage", pso->percentage); /* update percentage indicator in header */ - pose_slide_draw_status(C, pso); + pose_slide_draw_status(pso); /* reset transforms (to avoid accumulation errors) */ pose_slide_reset(pso); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index d2f32837d6d..3911be02fe7 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -1611,7 +1611,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) return strcmp(sgrp_a->agrp->name, sgrp_b->agrp->name); } -static int group_sort_exec(bContext *C, wmOperator *op) +static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; bPose *pose= (ob) ? ob->pose : NULL; @@ -2275,7 +2275,7 @@ void POSE_OT_quaternions_flip (wmOperatorType *ot) /* ********************************************** */ /* Clear User Transforms */ -static int pose_clear_user_transforms_exec (bContext *C, wmOperator *op) +static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index b3c4ffc0ac9..cb1fc7541d0 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -600,7 +600,7 @@ static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob)) */ for (ksp = ks->paths.first; ksp; ksp = ksp->next) { /* if id matches, select then stop looping (match found) */ - if (ksp->id == base->object) { + if (ksp->id == (ID *)base->object) { ED_base_object_select(base, BA_SELECT); changed = 1; break; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index d65297e068d..dc5e71f0406 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -706,7 +706,7 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View if (fcu->driver) resol= 32; else - resol= (int)(5.0*len_v2v2(bezt->vec[1], prevbezt->vec[1])); + resol= (int)(5.0f*len_v2v2(bezt->vec[1], prevbezt->vec[1])); if (resol < 2) { /* only draw one */ diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 0f87be0f807..1894a9fd651 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -533,7 +533,7 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) if ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT)) continue; /* check if there's space between the two */ - if (IS_EQ(s1->end, s2->start)) + if (IS_EQF(s1->end, s2->start)) continue; /* make sure neither one is a transition * - although this is impossible to create with the standard tools, @@ -613,7 +613,7 @@ void NLA_OT_transition_add (wmOperatorType *ot) /* ******************** Add Sound Clip Operator ***************************** */ /* Add a new sound clip */ -static int nlaedit_add_sound_exec (bContext *C, wmOperator *op) +static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1013,14 +1013,14 @@ static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip /* strip extents */ len= strip->end - strip->start; - if (IS_EQ(len, 0.0f)) + if (IS_EQF(len, 0.0f)) return; else splitframe= strip->start + (len / 2.0f); /* action range */ len= strip->actend - strip->actstart; - if (IS_EQ(len, 0.0f)) + if (IS_EQF(len, 0.0f)) splitaframe= strip->actend; else splitaframe= strip->actstart + (len / 2.0f); @@ -1858,10 +1858,10 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) strip->start= (float)CFRA; break; case NLAEDIT_SNAP_NEAREST_FRAME: /* to nearest frame */ - strip->start= (float)(floor(start+0.5)); + strip->start= floorf(start+0.5); break; case NLAEDIT_SNAP_NEAREST_SECOND: /* to nearest second */ - strip->start= ((float)floor(start/secf + 0.5f) * secf); + strip->start= floorf(start/secf + 0.5f) * secf; break; case NLAEDIT_SNAP_NEAREST_MARKER: /* to nearest marker */ strip->start= (float)ED_markers_find_nearest_marker_time(ac.markers, start); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 4525ea9c8d9..3ae158bd275 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -822,7 +822,7 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l /* ------------------------------------------ */ -static void actionset_id_cb(TreeElement *te, TreeStoreElem *tselem, TreeStoreElem *tsep, ID *actId) +static void actionset_id_cb(TreeElement *UNUSED(te), TreeStoreElem *tselem, TreeStoreElem *tsep, ID *actId) { bAction *act = (bAction *)actId; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b4ccea71aa2..d573198aa10 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -1493,7 +1493,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob } /* flag similar to draw_object() */ -static void drawspeaker(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, int flag) +static void drawspeaker(Scene *UNUSED(scene), View3D *UNUSED(v3d), RegionView3D *UNUSED(rv3d), Object *UNUSED(ob), int UNUSED(flag)) { //Speaker *spk = ob->data; @@ -1502,34 +1502,29 @@ static void drawspeaker(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o glEnable(GL_BLEND); - for(j = 0; j < 3; j++) - { - vec[2] = .25f * j -.125f; + for(j = 0; j < 3; j++) { + vec[2] = 0.25f * j -0.125f; glBegin(GL_LINE_LOOP); - for(i = 0; i < 16; i++) - { - vec[0] = cos(M_PI * i / 8.0f) * (j == 0 ? .5f : .25f); - vec[1] = sin(M_PI * i / 8.0f) * (j == 0 ? .5f : .25f); + for(i = 0; i < 16; i++) { + vec[0] = cosf(M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f); + vec[1] = sinf(M_PI * i / 8.0f) * (j == 0 ? 0.5f : 0.25f); glVertex3fv(vec); } glEnd(); } - for(j = 0; j < 4; j++) - { - vec[0] = (((j + 1) % 2) * (j - 1)) * .5f; - vec[1] = ((j % 2) * (j - 2)) * .5f; + for(j = 0; j < 4; j++) { + vec[0] = (((j + 1) % 2) * (j - 1)) * 0.5f; + vec[1] = ((j % 2) * (j - 2)) * 0.5f; glBegin(GL_LINE_STRIP); - for(i = 0; i < 3; i++) - { - if(i == 1) - { - vec[0] *= .5f; - vec[1] *= .5f; + for(i = 0; i < 3; i++) { + if(i == 1) { + vec[0] *= 0.5f; + vec[1] *= 0.5f; } - vec[2] = .25f * i -.125f; + vec[2] = 0.25f * i -0.125f; glVertex3fv(vec); } glEnd(); diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index ff13be20d4e..1547d2ee9ce 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -55,6 +55,8 @@ set(SRC intern/filetype.c intern/filter.c intern/imageprocess.c + intern/indexer.c + intern/indexer_dv.c intern/iris.c intern/jp2.c intern/jpeg.c @@ -73,7 +75,6 @@ set(SRC intern/tiff.c intern/util.c intern/writeimage.c - intern/indexer.c IMB_imbuf.h IMB_imbuf_types.h @@ -82,6 +83,7 @@ set(SRC intern/IMB_anim.h intern/IMB_filetype.h intern/IMB_filter.h + intern/IMB_indexer.h intern/IMB_metadata.h intern/cineon/cin_debug_stuff.h intern/cineon/cineonfile.h diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c index 0961af10f69..2def0d042b7 100644 --- a/source/blender/imbuf/intern/indexer_dv.c +++ b/source/blender/imbuf/intern/indexer_dv.c @@ -26,6 +26,7 @@ #include "IMB_indexer.h" #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include typedef struct indexer_dv_bitstream { @@ -279,7 +280,7 @@ static void fill_gap(indexer_dv_context * This, int isPAL) } static void proc_frame(indexer_dv_context * This, - unsigned char* framebuffer, int isPAL) + unsigned char* UNUSED(framebuffer), int isPAL) { struct tm recDate; time_t t; @@ -329,7 +330,7 @@ static void proc_frame(indexer_dv_context * This, static void indexer_dv_proc_frame(anim_index_builder * idx, unsigned char * buffer, - int data_size, + int UNUSED(data_size), struct anim_index_entry * entry) { int isPAL; -- cgit v1.2.3 From b3704f45c4e165618e898b5b7d1a7391ad14dc50 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 30 Aug 2011 10:07:50 +0000 Subject: Fixes for snprintf usage: * replace by BLI_snprintf in various places, note _snprintf on windows does not properly null terminate the string. * fix overflow in sequencer proxy code due to buffer being smaller than specified size. * fix some usage of snprintf as strcpy, this is will go wrong if the string contains % characters. * remove BLI_dynstr_printf function in gpu module, use BLI_dynstr_appendf --- source/blender/blenkernel/intern/particle_system.c | 11 +- source/blender/blenkernel/intern/pointcache.c | 20 ++-- source/blender/blenkernel/intern/report.c | 6 -- source/blender/blenkernel/intern/sequencer.c | 13 +-- source/blender/blenkernel/intern/unit.c | 11 +- source/blender/blenkernel/intern/writeffmpeg.c | 6 +- source/blender/blenlib/intern/storage.c | 2 +- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/editors/physics/physics_fluid.c | 18 ++-- .../blender/editors/space_console/space_console.c | 4 +- source/blender/editors/space_nla/nla_draw.c | 14 +-- source/blender/gpu/intern/gpu_codegen.c | 111 ++++++++------------- source/blender/python/intern/bpy_rna.c | 2 +- 13 files changed, 84 insertions(+), 136 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f62ba2be193..e1ea6e419d3 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -69,6 +69,7 @@ #include "BLI_listbase.h" #include "BLI_threads.h" #include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */ +#include "BLI_string.h" #include "BLI_utildefines.h" #include "BKE_main.h" @@ -104,12 +105,6 @@ #include #include -#ifdef WIN32 -#ifndef snprintf -#define snprintf _snprintf -#endif -#endif - #endif // DISABLE_ELBEEM /************************************************/ @@ -3876,7 +3871,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) gzf = gzopen(filename, "rb"); if (!gzf) { - snprintf(debugStrBuffer,256,"readFsPartData::error - Unable to open file for reading '%s' \n", filename); + BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"readFsPartData::error - Unable to open file for reading '%s' \n", filename); // XXX bad level call elbeemDebugOut(debugStrBuffer); return; } @@ -3937,7 +3932,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) gzclose( gzf ); totpart = psys->totpart = activeParts; - snprintf(debugStrBuffer,256,"readFsPartData::done - particles:%d, active:%d, file:%d, mask:%d \n", psys->totpart,activeParts,fileParts,readMask); + BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"readFsPartData::done - particles:%d, active:%d, file:%d, mask:%d \n", psys->totpart,activeParts,fileParts,readMask); // bad level call // XXX elbeemDebugOut(debugStrBuffer); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 0f0afe30392..a56010a5ccf 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -917,14 +917,14 @@ static int ptcache_path(PTCacheID *pid, char *filename) if (i > 6) file[i-6] = '\0'; - snprintf(filename, MAX_PTCACHE_PATH, "//"PTCACHE_PATH"%s", file); /* add blend file name to pointcache dir */ + BLI_snprintf(filename, MAX_PTCACHE_PATH, "//"PTCACHE_PATH"%s", file); /* add blend file name to pointcache dir */ BLI_path_abs(filename, blendfilename); return BLI_add_slash(filename); /* new strlen() */ } /* use the temp path. this is weak but better then not using point cache at all */ /* btempdir is assumed to exist and ALWAYS has a trailing slash */ - snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", btempdir, abs(getpid())); + BLI_snprintf(filename, MAX_PTCACHE_PATH, "%s"PTCACHE_PATH"%d", btempdir, abs(getpid())); return BLI_add_slash(filename); /* new strlen() */ } @@ -948,7 +948,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p idname = (pid->ob->id.name+2); /* convert chars to hex so they are always a valid filename */ while('\0' != *idname) { - snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++)); + BLI_snprintf(newname, MAX_PTCACHE_FILE, "%02X", (char)(*idname++)); newname+=2; len += 2; } @@ -967,12 +967,12 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p if(pid->cache->flag & PTCACHE_EXTERNAL) { if(pid->cache->index >= 0) - snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */ + BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */ else - snprintf(newname, MAX_PTCACHE_FILE, "_%06d"PTCACHE_EXT, cfra); /* always 6 chars */ + BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d"PTCACHE_EXT, cfra); /* always 6 chars */ } else { - snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */ + BLI_snprintf(newname, MAX_PTCACHE_FILE, "_%06d_%02u"PTCACHE_EXT, cfra, pid->stack_index); /* always 6 chars */ } len += 16; } @@ -2002,7 +2002,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) if (dir==NULL) return; - snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index); + BLI_snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index); while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ @@ -2204,7 +2204,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra if (dir==NULL) return; - snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index); + BLI_snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index); while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ @@ -2904,7 +2904,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) return; } - snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index); + BLI_snprintf(ext, sizeof(ext), "_%02u"PTCACHE_EXT, pid->stack_index); /* put new name into cache */ strcpy(pid->cache->name, to); @@ -2960,7 +2960,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) return; if(cache->index >= 0) - snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, cache->index); + BLI_snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, cache->index); else strcpy(ext, PTCACHE_EXT); diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index f84d98a31b4..4926edaeec2 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -44,12 +44,6 @@ #include #include -#ifdef _WIN32 -#ifndef vsnprintf -#define vsnprintf _vsnprintf -#endif -#endif - static const char *report_type_str(int type) { switch(type) { diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 40e02d65323..9ef30bdd49b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -78,11 +78,6 @@ # include "AUD_C-API.h" #endif -#ifdef WIN32 -#define snprintf _snprintf -#endif - - static ImBuf* seq_render_strip_stack( SeqRenderData context, ListBase *seqbasep, float cfra, int chanshown); @@ -1193,7 +1188,7 @@ static void seq_open_anim_file(Sequence * seq) static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra, char * name) { int frameno; - char dir[FILE_MAXDIR]; + char dir[PROXY_MAXFILE]; int render_size = context.preview_render_size; if (!seq->strip->proxy) { @@ -1211,7 +1206,7 @@ static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra, if (seq->flag & (SEQ_USE_PROXY_CUSTOM_DIR|SEQ_USE_PROXY_CUSTOM_FILE)) { strcpy(dir, seq->strip->proxy->dir); } else if (seq->type == SEQ_IMAGE) { - snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir); + BLI_snprintf(dir, PROXY_MAXFILE, "%s/BL_proxy", seq->strip->dir); } else { return FALSE; } @@ -1232,14 +1227,14 @@ static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra, /* generate a separate proxy directory for each preview size */ if (seq->type == SEQ_IMAGE) { - snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", dir, + BLI_snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", dir, context.preview_render_size, give_stripelem(seq, cfra)->name); frameno = 1; } else { frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; - snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, + BLI_snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, context.preview_render_size); } diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index a9792bc44fa..72fe1c19884 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -34,6 +34,7 @@ #include "BKE_unit.h" #include "BLI_math.h" +#include "BLI_string.h" #include "BLI_winstuff.h" @@ -344,7 +345,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC /* Convert to a string */ { - len= snprintf(str, len_max, "%.*lf", prec, value_conv); + len= BLI_snprintf(str, len_max, "%.*lf", prec, value_conv); if(len >= len_max) len= len_max; @@ -495,7 +496,7 @@ static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pr len_name = strlen(replace_str); len_move= (len - (found_ofs+len_name)) + 1; /* 1+ to copy the string terminator */ - len_num= snprintf(str_tmp, TEMP_STR_SIZE, "*%lg"SEP_STR, unit->scalar/scale_pref); /* # removed later */ + len_num= BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%lg"SEP_STR, unit->scalar/scale_pref); /* # removed later */ if(len_num > len_max) len_num= len_max; @@ -629,12 +630,12 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre /* add the unit prefix and re-run, use brackets incase there was an expression given */ - if(snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) { + if(BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) { strncpy(str, str_tmp, len_max); return bUnit_ReplaceString(str, len_max, NULL, scale_pref, system, type); } else { - /* snprintf would not fit into str_tmp, cant do much in this case + /* BLI_snprintf would not fit into str_tmp, cant do much in this case * check for this because otherwise bUnit_ReplaceString could call its self forever */ return 0; } @@ -705,7 +706,7 @@ void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int /* print the alt_name */ if(unit->name_alt) - len_name= snprintf(str, len_max, "%s", unit->name_alt); + len_name= BLI_snprintf(str, len_max, "%s", unit->name_alt); else len_name= 0; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 24e0fe95a1f..13875ff19f7 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -39,10 +39,6 @@ #include #include -#if defined(WIN32) && (!(defined snprintf)) -#define snprintf _snprintf -#endif - #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" @@ -652,7 +648,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report fmt->audio_codec = ffmpeg_audio_codec; - snprintf(of->filename, sizeof(of->filename), "%s", name); + BLI_snprintf(of->filename, sizeof(of->filename), "%s", name); /* set the codec to the user's selection */ switch(ffmpeg_type) { case FFMPEG_AVI: diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 41eedef8835..67e27063fd0 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -338,7 +338,7 @@ void BLI_adddirstrings(void) if ( pwuser ) { BLI_strncpy(file->owner, pwuser->pw_name, sizeof(file->owner)); } else { - snprintf(file->owner, sizeof(file->owner), "%d", file->s.st_uid); + BLI_snprintf(file->owner, sizeof(file->owner), "%d", file->s.st_uid); } } #endif diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 4a86de51d9c..363e98d7a4b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -10081,7 +10081,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) { - snprintf(seq->strip->proxy->dir, + BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir); } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 37309f1e07c..bd53de20871 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -41,12 +41,6 @@ #include #include -#ifdef WIN32 /* Windos */ -#ifndef snprintf -#define snprintf _snprintf -#endif -#endif - #include "MEM_guardedalloc.h" /* types */ @@ -155,8 +149,8 @@ static int fluid_is_animated_mesh(FluidsimSettings *fss) #if 0 /* helper function */ void fluidsimGetGeometryObjFilename(Object *ob, char *dst) { //, char *srcname) { - //snprintf(dst,FILE_MAXFILE, "%s_cfgdata_%s.bobj.gz", srcname, ob->id.name); - snprintf(dst,FILE_MAXFILE, "fluidcfgdata_%s.bobj.gz", ob->id.name); + //BLI_snprintf(dst,FILE_MAXFILE, "%s_cfgdata_%s.bobj.gz", srcname, ob->id.name); + BLI_snprintf(dst,FILE_MAXFILE, "fluidcfgdata_%s.bobj.gz", ob->id.name); } #endif @@ -888,7 +882,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) if(getenv(strEnvName)) { int dlevel = atoi(getenv(strEnvName)); elbeemSetDebugLevel(dlevel); - snprintf(debugStrBuffer,256,"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName); + BLI_snprintf(debugStrBuffer,256,"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName); elbeemDebugOut(debugStrBuffer); } @@ -925,7 +919,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) /* rough check of settings... */ if(domainSettings->previewresxyz > domainSettings->resolutionxyz) { - snprintf(debugStrBuffer,256,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz , domainSettings->resolutionxyz); + BLI_snprintf(debugStrBuffer,256,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz , domainSettings->resolutionxyz); elbeemDebugOut(debugStrBuffer); domainSettings->previewresxyz = domainSettings->resolutionxyz; } @@ -945,7 +939,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) } else { gridlevels = domainSettings->maxRefine; } - snprintf(debugStrBuffer,256,"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels ); + BLI_snprintf(debugStrBuffer,256,"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels ); elbeemDebugOut(debugStrBuffer); @@ -997,7 +991,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain) /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); if(!invert_m4_m4(invDomMat, domainMat)) { - snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n"); + BLI_snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n"); elbeemDebugOut(debugStrBuffer); BKE_report(reports, RPT_ERROR, "Invalid object matrix."); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 52c5100900d..c8fa049f5eb 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -169,7 +169,7 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop) BLI_strescape(id_esc, id->name+2, sizeof(id_esc)); - snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc); + BLI_snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc); /* copy drag path to properties */ RNA_string_set(drop->ptr, "text", text); @@ -186,7 +186,7 @@ static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve static void path_drop_copy(wmDrag *drag, wmDropBox *drop) { char pathname[FILE_MAXDIR+FILE_MAXFILE+2]; - snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path); + BLI_snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path); RNA_string_set(drop->ptr, "text", pathname); } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 0583f328371..0c9c7877ddc 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -468,10 +468,10 @@ static void nla_draw_strip_text (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, /* just print the name and the range */ if (strip->flag & NLASTRIP_FLAG_TEMP_META) { - sprintf(str, "%d) Temp-Meta", index); + BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index); } else { - sprintf(str, strip->name); + BLI_strncpy(str, strip->name, sizeof(str)); } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ @@ -514,7 +514,7 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V { const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */ const char col[4] = {220, 220, 220, 255}; /* light grey */ - char str[16] = ""; + char str[32] = ""; /* Always draw times above the strip, whereas sequencer drew below + above. @@ -524,11 +524,11 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V * while also preserving some accuracy, since we do use floats */ /* start frame */ - sprintf(str, "%.1f", strip->start); + BLI_snprintf(str, sizeof(str), "%.1f", strip->start); UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, str, col); /* end frame */ - sprintf(str, "%.1f", strip->end); + BLI_snprintf(str, sizeof(str), "%.1f", strip->end); UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, str, col); } @@ -730,9 +730,9 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie special = ICON_ACTION; if (act) - sprintf(name, "%s", act->id.name+2); + BLI_snprintf(name, sizeof(name), "%s", act->id.name+2); else - sprintf(name, ""); + BLI_strncpy(name, "", sizeof(name)); // draw manually still doDraw= 1; diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 77498835d57..360f3dbf63f 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -59,15 +59,6 @@ #include #include -#ifdef _WIN32 -#ifndef vsnprintf -#define vsnprintf _vsnprintf -#endif -#ifndef snprintf -#define snprintf _snprintf -#endif -#endif - extern char datatoc_gpu_shader_material_glsl[]; extern char datatoc_gpu_shader_vertex_glsl[]; @@ -168,24 +159,6 @@ struct GPUPass { struct GPUShader *shader; }; -/* Strings utility */ - -static void BLI_dynstr_printf(DynStr *dynstr, const char *format, ...) -{ - va_list args; - int retval; - char str[2048]; - - va_start(args, format); - retval = vsnprintf(str, sizeof(str), format, args); - va_end(args); - - if (retval >= sizeof(str)) - fprintf(stderr, "BLI_dynstr_printf: limit exceeded\n"); - else - BLI_dynstr_append(dynstr, str); -} - /* GLSL code parsing for finding function definitions. * These are stored in a hash for lookup when creating a material. */ @@ -318,7 +291,7 @@ static char *gpu_generate_function_prototyps(GHash *hash) name = BLI_ghashIterator_getValue(ghi); function = BLI_ghashIterator_getValue(ghi); - BLI_dynstr_printf(ds, "void %s(", name); + BLI_dynstr_appendf(ds, "void %s(", name); for(a=0; atotparam; a++) { if(function->paramqual[a] == FUNCTION_QUAL_OUT) BLI_dynstr_append(ds, "out "); @@ -334,7 +307,7 @@ static char *gpu_generate_function_prototyps(GHash *hash) else BLI_dynstr_append(ds, GPU_DATATYPE_STR[function->paramtype[a]]); - //BLI_dynstr_printf(ds, " param%d", a); + //BLI_dynstr_appendf(ds, " param%d", a); if(a != function->totparam-1) BLI_dynstr_append(ds, ", "); @@ -390,42 +363,42 @@ static void codegen_convert_datatype(DynStr *ds, int from, int to, const char *t { char name[1024]; - snprintf(name, sizeof(name), "%s%d", tmp, id); + BLI_snprintf(name, sizeof(name), "%s%d", tmp, id); if (from == to) { BLI_dynstr_append(ds, name); } else if (to == GPU_FLOAT) { if (from == GPU_VEC4) - BLI_dynstr_printf(ds, "dot(%s.rgb, vec3(0.35, 0.45, 0.2))", name); + BLI_dynstr_appendf(ds, "dot(%s.rgb, vec3(0.35, 0.45, 0.2))", name); else if (from == GPU_VEC3) - BLI_dynstr_printf(ds, "dot(%s, vec3(0.33))", name); + BLI_dynstr_appendf(ds, "dot(%s, vec3(0.33))", name); else if (from == GPU_VEC2) - BLI_dynstr_printf(ds, "%s.r", name); + BLI_dynstr_appendf(ds, "%s.r", name); } else if (to == GPU_VEC2) { if (from == GPU_VEC4) - BLI_dynstr_printf(ds, "vec2(dot(%s.rgb, vec3(0.35, 0.45, 0.2)), %s.a)", name, name); + BLI_dynstr_appendf(ds, "vec2(dot(%s.rgb, vec3(0.35, 0.45, 0.2)), %s.a)", name, name); else if (from == GPU_VEC3) - BLI_dynstr_printf(ds, "vec2(dot(%s.rgb, vec3(0.33)), 1.0)", name); + BLI_dynstr_appendf(ds, "vec2(dot(%s.rgb, vec3(0.33)), 1.0)", name); else if (from == GPU_FLOAT) - BLI_dynstr_printf(ds, "vec2(%s, 1.0)", name); + BLI_dynstr_appendf(ds, "vec2(%s, 1.0)", name); } else if (to == GPU_VEC3) { if (from == GPU_VEC4) - BLI_dynstr_printf(ds, "%s.rgb", name); + BLI_dynstr_appendf(ds, "%s.rgb", name); else if (from == GPU_VEC2) - BLI_dynstr_printf(ds, "vec3(%s.r, %s.r, %s.r)", name, name, name); + BLI_dynstr_appendf(ds, "vec3(%s.r, %s.r, %s.r)", name, name, name); else if (from == GPU_FLOAT) - BLI_dynstr_printf(ds, "vec3(%s, %s, %s)", name, name, name); + BLI_dynstr_appendf(ds, "vec3(%s, %s, %s)", name, name, name); } else { if (from == GPU_VEC3) - BLI_dynstr_printf(ds, "vec4(%s, 1.0)", name); + BLI_dynstr_appendf(ds, "vec4(%s, 1.0)", name); else if (from == GPU_VEC2) - BLI_dynstr_printf(ds, "vec4(%s.r, %s.r, %s.r, %s.g)", name, name, name, name); + BLI_dynstr_appendf(ds, "vec4(%s.r, %s.r, %s.r, %s.g)", name, name, name, name); else if (from == GPU_FLOAT) - BLI_dynstr_printf(ds, "vec4(%s, %s, %s, 1.0)", name, name, name); + BLI_dynstr_appendf(ds, "vec4(%s, %s, %s, 1.0)", name, name, name); } } @@ -433,10 +406,10 @@ static void codegen_print_datatype(DynStr *ds, int type, float *data) { int i; - BLI_dynstr_printf(ds, "%s(", GPU_DATATYPE_STR[type]); + BLI_dynstr_appendf(ds, "%s(", GPU_DATATYPE_STR[type]); for(i=0; isource == GPU_SOURCE_TEX) || (input->source == GPU_SOURCE_TEX_PIXEL)) { /* create exactly one sampler for each texture */ if (codegen_input_has_texture(input) && input->bindtex) - BLI_dynstr_printf(ds, "uniform %s samp%d;\n", + BLI_dynstr_appendf(ds, "uniform %s samp%d;\n", (input->textype == GPU_TEX1D)? "sampler1D": (input->textype == GPU_TEX2D)? "sampler2D": "sampler2DShadow", input->texid); @@ -580,11 +553,11 @@ static void codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes) name = GPU_builtin_name(input->builtin); if(gpu_str_prefix(name, "unf")) { - BLI_dynstr_printf(ds, "uniform %s %s;\n", + BLI_dynstr_appendf(ds, "uniform %s %s;\n", GPU_DATATYPE_STR[input->type], name); } else { - BLI_dynstr_printf(ds, "varying %s %s;\n", + BLI_dynstr_appendf(ds, "varying %s %s;\n", GPU_DATATYPE_STR[input->type], name); } } @@ -592,19 +565,19 @@ static void codegen_print_uniforms_functions(DynStr *ds, ListBase *nodes) else if (input->source == GPU_SOURCE_VEC_UNIFORM) { if(input->dynamicvec) { /* only create uniforms for dynamic vectors */ - BLI_dynstr_printf(ds, "uniform %s unf%d;\n", + BLI_dynstr_appendf(ds, "uniform %s unf%d;\n", GPU_DATATYPE_STR[input->type], input->id); } else { /* for others use const so the compiler can do folding */ - BLI_dynstr_printf(ds, "const %s cons%d = ", + BLI_dynstr_appendf(ds, "const %s cons%d = ", GPU_DATATYPE_STR[input->type], input->id); codegen_print_datatype(ds, input->type, input->vec); BLI_dynstr_append(ds, ";\n"); } } else if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { - BLI_dynstr_printf(ds, "varying %s var%d;\n", + BLI_dynstr_appendf(ds, "varying %s var%d;\n", GPU_DATATYPE_STR[input->type], input->attribid); } } @@ -624,8 +597,8 @@ static void codegen_declare_tmps(DynStr *ds, ListBase *nodes) for (input=node->inputs.first; input; input=input->next) { if (input->source == GPU_SOURCE_TEX_PIXEL) { if (codegen_input_has_texture(input) && input->definetex) { - BLI_dynstr_printf(ds, "\tvec4 tex%d = texture2D(", input->texid); - BLI_dynstr_printf(ds, "samp%d, gl_TexCoord[%d].st);\n", + BLI_dynstr_appendf(ds, "\tvec4 tex%d = texture2D(", input->texid); + BLI_dynstr_appendf(ds, "samp%d, gl_TexCoord[%d].st);\n", input->texid, input->texid); } } @@ -633,7 +606,7 @@ static void codegen_declare_tmps(DynStr *ds, ListBase *nodes) /* declare temporary variables for node output storage */ for (output=node->outputs.first; output; output=output->next) - BLI_dynstr_printf(ds, "\t%s tmp%d;\n", + BLI_dynstr_appendf(ds, "\t%s tmp%d;\n", GPU_DATATYPE_STR[output->type], output->id); } @@ -647,13 +620,13 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final GPUOutput *output; for (node=nodes->first; node; node=node->next) { - BLI_dynstr_printf(ds, "\t%s(", node->name); + BLI_dynstr_appendf(ds, "\t%s(", node->name); for (input=node->inputs.first; input; input=input->next) { if (input->source == GPU_SOURCE_TEX) { - BLI_dynstr_printf(ds, "samp%d", input->texid); + BLI_dynstr_appendf(ds, "samp%d", input->texid); if (input->link) - BLI_dynstr_printf(ds, ", gl_TexCoord[%d].st", input->texid); + BLI_dynstr_appendf(ds, ", gl_TexCoord[%d].st", input->texid); } else if (input->source == GPU_SOURCE_TEX_PIXEL) { if (input->link && input->link->output) @@ -664,21 +637,21 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final "tex", input->texid); } else if(input->source == GPU_SOURCE_BUILTIN) - BLI_dynstr_printf(ds, "%s", GPU_builtin_name(input->builtin)); + BLI_dynstr_appendf(ds, "%s", GPU_builtin_name(input->builtin)); else if(input->source == GPU_SOURCE_VEC_UNIFORM) { if(input->dynamicvec) - BLI_dynstr_printf(ds, "unf%d", input->id); + BLI_dynstr_appendf(ds, "unf%d", input->id); else - BLI_dynstr_printf(ds, "cons%d", input->id); + BLI_dynstr_appendf(ds, "cons%d", input->id); } else if (input->source == GPU_SOURCE_ATTRIB) - BLI_dynstr_printf(ds, "var%d", input->attribid); + BLI_dynstr_appendf(ds, "var%d", input->attribid); BLI_dynstr_append(ds, ", "); } for (output=node->outputs.first; output; output=output->next) { - BLI_dynstr_printf(ds, "tmp%d", output->id); + BLI_dynstr_appendf(ds, "tmp%d", output->id); if (output->next) BLI_dynstr_append(ds, ", "); } @@ -702,7 +675,7 @@ static char *code_generate_fragment(ListBase *nodes, GPUOutput *output, const ch codegen_print_uniforms_functions(ds, nodes); //if(G.f & G_DEBUG) - // BLI_dynstr_printf(ds, "/* %s */\n", name); + // BLI_dynstr_appendf(ds, "/* %s */\n", name); BLI_dynstr_append(ds, "void main(void)\n"); BLI_dynstr_append(ds, "{\n"); @@ -731,9 +704,9 @@ static char *code_generate_vertex(ListBase *nodes) for (node=nodes->first; node; node=node->next) { for (input=node->inputs.first; input; input=input->next) { if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { - BLI_dynstr_printf(ds, "attribute %s att%d;\n", + BLI_dynstr_appendf(ds, "attribute %s att%d;\n", GPU_DATATYPE_STR[input->type], input->attribid); - BLI_dynstr_printf(ds, "varying %s var%d;\n", + BLI_dynstr_appendf(ds, "varying %s var%d;\n", GPU_DATATYPE_STR[input->type], input->attribid); } } @@ -747,11 +720,11 @@ static char *code_generate_vertex(ListBase *nodes) if (input->source == GPU_SOURCE_ATTRIB && input->attribfirst) { if(input->attribtype == CD_TANGENT) /* silly exception */ { - BLI_dynstr_printf(ds, "\tvar%d.xyz = normalize((gl_ModelViewMatrix * vec4(att%d.xyz, 0)).xyz);\n", input->attribid, input->attribid); - BLI_dynstr_printf(ds, "\tvar%d.w = att%d.w;\n", input->attribid, input->attribid); + BLI_dynstr_appendf(ds, "\tvar%d.xyz = normalize((gl_ModelViewMatrix * vec4(att%d.xyz, 0)).xyz);\n", input->attribid, input->attribid); + BLI_dynstr_appendf(ds, "\tvar%d.w = att%d.w;\n", input->attribid, input->attribid); } else - BLI_dynstr_printf(ds, "\tvar%d = att%d;\n", input->attribid, input->attribid); + BLI_dynstr_appendf(ds, "\tvar%d = att%d;\n", input->attribid, input->attribid); } BLI_dynstr_append(ds, "}\n\n"); @@ -799,9 +772,9 @@ static void GPU_nodes_extract_dynamic_inputs(GPUPass *pass, ListBase *nodes) continue; if (input->ima || input->tex) - snprintf(input->shadername, sizeof(input->shadername), "samp%d", input->texid); + BLI_snprintf(input->shadername, sizeof(input->shadername), "samp%d", input->texid); else - snprintf(input->shadername, sizeof(input->shadername), "unf%d", input->id); + BLI_snprintf(input->shadername, sizeof(input->shadername), "unf%d", input->id); /* pass non-dynamic uniforms to opengl */ extract = 0; diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 4abcbc684e2..e1c38a82142 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1251,7 +1251,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) #if 0 // gives python decoding errors while generating docs :( char error_str[256]; - snprintf(error_str, sizeof(error_str), "RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop)); + BLI_snprintf(error_str, sizeof(error_str), "RNA Warning: Current value \"%d\" matches no enum in '%s', '%s', '%s'", val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop)); PyErr_Warn(PyExc_RuntimeWarning, error_str); #endif -- cgit v1.2.3 From 947d4a654b7ec3b7f413f2132a0524ab2e2e5c9e Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 30 Aug 2011 10:09:10 +0000 Subject: Fix for [#25062] Sound Actuator - Positional Audio. Now all sounds that are not mono but have 3D checked automatically get reduced to mono during BGE conversion time. Also removed the now unneeded function sound_get_channels and added a missing header file to audaspace's CMakeLists.txt. --- source/blender/blenkernel/BKE_sound.h | 2 -- source/blender/blenkernel/intern/sound.c | 10 ---------- source/gameengine/Converter/KX_ConvertActuators.cpp | 17 +++++++++++++++++ 3 files changed, 17 insertions(+), 12 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index e1b6ff02bc4..fac5bf1cfd2 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -134,8 +134,6 @@ void sound_free_waveform(struct bSound* sound); void sound_read_waveform(struct bSound* sound); -int sound_get_channels(struct bSound* sound); - void sound_update_scene(struct Scene* scene); void* sound_get_factory(void* sound); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 985fef974d3..cdb509ab8e1 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -641,15 +641,6 @@ void sound_read_waveform(struct bSound* sound) } } -int sound_get_channels(struct bSound* sound) -{ - AUD_SoundInfo info; - - info = AUD_getInfo(sound->playback_handle); - - return info.specs.channels; -} - void sound_update_scene(struct Scene* scene) { Object* ob; @@ -769,6 +760,5 @@ void sound_seek_scene(struct bContext *UNUSED(C)) {} float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; } int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; } int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; } -int sound_get_channels(struct bSound* UNUSED(sound)) { return 1; } #endif // WITH_AUDASPACE diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 7b9cba7770b..9621d05b5cc 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -46,6 +46,7 @@ #ifdef WITH_AUDASPACE # include "AUD_C-API.h" +# include "AUD_ChannelMapperFactory.h" #endif // Actuators @@ -406,7 +407,23 @@ void BL_ConvertActuators(char* maggiename, "\" has no sound datablock." << std::endl; } else + { snd_sound = *reinterpret_cast*>(sound->playback_handle); + + // if sound shall be 3D but isn't mono, we have to make it mono! + if(is3d) + { + AUD_Reference reader = snd_sound->createReader(); + if(reader->getSpecs().channels != AUD_CHANNELS_MONO) + { + AUD_DeviceSpecs specs; + specs.channels = AUD_CHANNELS_MONO; + specs.rate = AUD_RATE_INVALID; + specs.format = AUD_FORMAT_INVALID; + snd_sound = new AUD_ChannelMapperFactory(snd_sound, specs); + } + } + } KX_SoundActuator* tmpsoundact = new KX_SoundActuator(gameobj, snd_sound, -- cgit v1.2.3 From b20c9b0ba368d5685d3c996572780befe852b889 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Aug 2011 10:49:58 +0000 Subject: minor edits, pep8 - also correct float -> double promotion for blf. --- source/blender/blenfont/intern/blf.c | 30 ++++++++++++++--------------- source/blender/editors/space_nla/nla_edit.c | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'source') diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index c0e62b1c0c7..fc812d652b3 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -369,28 +369,28 @@ void BLF_position(int fontid, float x, float y, float z) za= 1.0f; } - remainder= x - floor(x); - if (remainder > 0.4 && remainder < 0.6) { - if (remainder < 0.5) - x -= 0.1 * xa; + remainder= x - floorf(x); + if (remainder > 0.4f && remainder < 0.6f) { + if (remainder < 0.5f) + x -= 0.1f * xa; else - x += 0.1 * xa; + x += 0.1f * xa; } - remainder= y - floor(y); - if (remainder > 0.4 && remainder < 0.6) { - if (remainder < 0.5) - y -= 0.1 * ya; + remainder= y - floorf(y); + if (remainder > 0.4f && remainder < 0.6f) { + if (remainder < 0.5f) + y -= 0.1f * ya; else - y += 0.1 * ya; + y += 0.1f * ya; } - remainder= z - floor(z); - if (remainder > 0.4 && remainder < 0.6) { - if (remainder < 0.5) - z -= 0.1 * za; + remainder= z - floorf(z); + if (remainder > 0.4f && remainder < 0.6f) { + if (remainder < 0.5f) + z -= 0.1f * za; else - z += 0.1 * za; + z += 0.1f * za; } font->pos[0]= x; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 1894a9fd651..08026e8a1d2 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1858,7 +1858,7 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) strip->start= (float)CFRA; break; case NLAEDIT_SNAP_NEAREST_FRAME: /* to nearest frame */ - strip->start= floorf(start+0.5); + strip->start= floorf(start+0.5f); break; case NLAEDIT_SNAP_NEAREST_SECOND: /* to nearest second */ strip->start= floorf(start/secf + 0.5f) * secf; -- cgit v1.2.3 From 131c2a3208842f36c1958d6f9ff19dde5c2bd76c Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 30 Aug 2011 14:41:23 +0000 Subject: Fix for [#28425] when user prefs -> editing -> align to == "view" newly inserted objects do not show the applied rotation in the tools panel Patch by Andrew Wiggin, thanks! :) --- source/blender/editors/object/object_add.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 5212bf32834..fa529374bf7 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -276,8 +276,10 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, floa RNA_boolean_set(op->ptr, "view_align", view_align); } - if (view_align) + if (view_align) { ED_object_rotation_from_view(C, rot); + RNA_float_set_array(op->ptr, "rotation", rot); + } else RNA_float_get_array(op->ptr, "rotation", rot); -- cgit v1.2.3 From 9eb9d9b7d2492b12cf61859597093980b565694c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 30 Aug 2011 15:30:38 +0000 Subject: Fix #28427: smooth faces flash momentarily when extruded using "extrude and move on normals" tool (E key) Update normals just after extrude -- topology is changing when extruding and normals for non-extruded faces should be recalculated after this. --- source/blender/editors/mesh/editmesh_lib.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source') diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index b7ed6ec14ca..0afa2d01702 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -1141,6 +1141,9 @@ short extrudeflag_face_indiv(EditMesh *em, short UNUSED(flag), float *UNUSED(nor EM_select_flush(em); + /* step 5; update normals after extrude */ + recalc_editnormals(em); + return 'n'; } @@ -1206,6 +1209,9 @@ short extrudeflag_edges_indiv(EditMesh *em, short flag, float *nor) if(eed->v1->f & eed->v2->f & flag) eed->f |= flag; } + /* update normals after extrude */ + recalc_editnormals(em); + if(is_zero_v3(nor)) return 'g'; // g is grab return 'n'; // n is for normal constraint } @@ -1485,6 +1491,9 @@ static short extrudeflag_edge(Object *obedit, EditMesh *em, short UNUSED(flag), EM_select_flush(em); + /* step 8; update normals after extrude */ + recalc_editnormals(em); + if(is_zero_v3(nor)) return 'g'; // grab return 'n'; // normal constraint } -- cgit v1.2.3 From c6f994062e4f871aa2f81c289b49ac7245b3056c Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 30 Aug 2011 15:43:00 +0000 Subject: Check for potential crasher. Reported and suggested in [#27687] by Dean Giberson. Couldn't redo crash myself, but better safe than sorry :) --- source/blender/collada/ExtraHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/collada/ExtraHandler.cpp b/source/blender/collada/ExtraHandler.cpp index a60ef8b2ea5..820665ad757 100644 --- a/source/blender/collada/ExtraHandler.cpp +++ b/source/blender/collada/ExtraHandler.cpp @@ -56,7 +56,7 @@ bool ExtraHandler::textData(const char* text, size_t textLength) { char buf[1024]; - if(currentElement.length() == 0) return false; + if(currentElement.length() == 0 || currentExtraTags == 0) return false; BLI_snprintf(buf, textLength+1, "%s", text); currentExtraTags->addTag(currentElement, std::string(buf)); -- cgit v1.2.3 From 5ac81bfe9c523c2ea0dcbc55bc8454c2e12239e0 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Tue, 30 Aug 2011 19:38:32 +0000 Subject: SVN maintenance. --- source/blender/collada/AnimationExporter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 267ad4be887..d277dad8e8c 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -160,4 +160,4 @@ protected: char* extract_transform_name(char *rna_path); std::string getObjectBoneName ( Object *ob,const FCurve * fcu); -}; \ No newline at end of file +}; -- cgit v1.2.3 From c58a0c5eb814db1be08c0e8a4353ad5606a23d30 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Aug 2011 23:08:38 +0000 Subject: catch exception and report an error when failing to write exr files - was crashing with debug builds. --- source/blender/editors/space_image/image_ops.c | 2 +- .../blender/imbuf/intern/openexr/openexr_api.cpp | 15 +++++++-- .../blender/imbuf/intern/openexr/openexr_multi.h | 4 +-- source/blender/imbuf/intern/writeimage.c | 1 - source/blender/render/extern/include/RE_pipeline.h | 4 +-- source/blender/render/intern/source/pipeline.c | 39 ++++++++++++++++------ 6 files changed, 46 insertions(+), 19 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index d58b78ff6a7..f96a8ea4d84 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1069,7 +1069,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI Scene *scene= CTX_data_scene(C); RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); if(rr) { - RE_WriteRenderResult(rr, simopts->filepath, simopts->quality); + RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->quality); ok= TRUE; } else { diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 7b528ed9624..88f6508d356 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -487,7 +487,7 @@ void IMB_exr_add_channel(void *handle, const char *layname, const char *passname } /* only used for writing temp. render results (not image files) */ -void IMB_exr_begin_write(void *handle, const char *filename, int width, int height, int compress) +int IMB_exr_begin_write(void *handle, const char *filename, int width, int height, int compress) { ExrHandle *data= (ExrHandle *)handle; Header header (width, height); @@ -504,8 +504,17 @@ void IMB_exr_begin_write(void *handle, const char *filename, int width, int heig /* header.lineOrder() = DECREASING_Y; this crashes in windows for file read! */ header.insert ("BlenderMultiChannel", StringAttribute ("Blender V2.55.1 and newer")); - - data->ofile = new OutputFile(filename, header); + + /* avoid crash/abort when we dont have permission to write here */ + try { + data->ofile = new OutputFile(filename, header); + } + catch (const std::exception &exc) { + std::cerr << "IMB_exr_begin_write: ERROR: " << exc.what() << std::endl; + data->ofile = NULL; + } + + return (data->ofile != NULL); } void IMB_exrtile_begin_write(void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley) diff --git a/source/blender/imbuf/intern/openexr/openexr_multi.h b/source/blender/imbuf/intern/openexr/openexr_multi.h index 3d95bb7c306..58c5e0f2a3e 100644 --- a/source/blender/imbuf/intern/openexr/openexr_multi.h +++ b/source/blender/imbuf/intern/openexr/openexr_multi.h @@ -50,7 +50,7 @@ void * IMB_exr_get_handle (void); void IMB_exr_add_channel (void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect); int IMB_exr_begin_read (void *handle, const char *filename, int *width, int *height); -void IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress); +int IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress); void IMB_exrtile_begin_write (void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley); void IMB_exr_set_channel (void *handle, const char *layname, const char *passname, int xstride, int ystride, float *rect); @@ -75,7 +75,7 @@ void * IMB_exr_get_handle (void) {return NULL;} void IMB_exr_add_channel (void *handle, const char *layname, const char *channame, int xstride, int ystride, float *rect) { (void)handle; (void)layname; (void)channame; (void)xstride; (void)ystride; (void)rect; } int IMB_exr_begin_read (void *handle, const char *filename, int *width, int *height) { (void)handle; (void)filename; (void)width; (void)height; return 0;} -void IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress) { (void)handle; (void)filename; (void)width; (void)height; (void)compress; } +int IMB_exr_begin_write (void *handle, const char *filename, int width, int height, int compress) { (void)handle; (void)filename; (void)width; (void)height; (void)compress; return 0;} void IMB_exrtile_begin_write (void *handle, const char *filename, int mipmap, int width, int height, int tilex, int tiley) { (void)handle; (void)filename; (void)mipmap; (void)width; (void)height; (void)tilex; (void)tiley; } void IMB_exr_set_channel (void *handle, char *layname, const char *channame, int xstride, int ystride, float *rect) { (void)handle; (void)layname; (void)channame; (void)xstride; (void)ystride; (void)rect; } diff --git a/source/blender/imbuf/intern/writeimage.c b/source/blender/imbuf/intern/writeimage.c index cd660e11f26..b933e6d93ee 100644 --- a/source/blender/imbuf/intern/writeimage.c +++ b/source/blender/imbuf/intern/writeimage.c @@ -55,7 +55,6 @@ short IMB_saveiff(struct ImBuf *ibuf, const char *name, int flags) if(ibuf->rect==NULL && ibuf->rect_float) IMB_rect_from_float(ibuf); } - /* TODO. have const char for image write funcs */ return type->save(ibuf, name, flags); } } diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 0736bed4faf..97ffcd95473 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -227,8 +227,8 @@ void RE_SetReports(struct Render *re, struct ReportList *reports); /* main preview render call */ void RE_PreviewRender(struct Render *re, struct Main *bmain, struct Scene *scene); -void RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode); -void RE_WriteRenderResult(RenderResult *rr, const char *filename, int compress); +int RE_ReadRenderResult(struct Scene *scene, struct Scene *scenode); +int RE_WriteRenderResult(struct ReportList *reports, RenderResult *rr, const char *filename, int compress); struct RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty); extern const float default_envmap_layout[]; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 0d5f8c77f6b..77b637b5129 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -824,11 +824,12 @@ static char *make_pass_name(RenderPass *rpass, int chan) /* filename already made absolute */ /* called from within UI, saves both rendered result as a file-read result */ -void RE_WriteRenderResult(RenderResult *rr, const char *filename, int compress) +int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *filename, int compress) { RenderLayer *rl; RenderPass *rpass; void *exrhandle= IMB_exr_get_handle(); + int success; BLI_make_existing_file(filename); @@ -864,11 +865,20 @@ void RE_WriteRenderResult(RenderResult *rr, const char *filename, int compress) } } } - - IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty, compress); - - IMB_exr_write_channels(exrhandle); + + /* when the filename has no permissions, this can fail */ + if(IMB_exr_begin_write(exrhandle, filename, rr->rectx, rr->recty, compress)) { + IMB_exr_write_channels(exrhandle); + success= TRUE; + } + else { + /* TODO, get the error from openexr's exception */ + BKE_report(reports, RPT_ERROR, "Error Writing Render Result, see console"); + success= FALSE; + } IMB_exr_close(exrhandle); + + return success; } /* callbacks for RE_MultilayerConvert */ @@ -992,9 +1002,10 @@ static int read_render_result_from_file(const char *filename, RenderResult *rr) } /* only for temp buffer files, makes exact copy of render result */ -static void read_render_result(Render *re, int sample) +static int read_render_result(Render *re, int sample) { char str[FILE_MAX]; + int success; BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); @@ -1004,10 +1015,18 @@ static void read_render_result(Render *re, int sample) render_unique_exr_name(re, str, sample); printf("read exr tmp file: %s\n", str); - if(!read_render_result_from_file(str, re->result)) + if(read_render_result_from_file(str, re->result)) { + success= TRUE; + } + else { printf("cannot read: %s\n", str); + success= FALSE; + + } BLI_rw_mutex_unlock(&re->resultmutex); + + return success; } /* *************************************************** */ @@ -2981,7 +3000,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, c if(re->r.imtype==R_MULTILAYER) { if(re->result) { - RE_WriteRenderResult(re->result, name, scene->r.quality); + RE_WriteRenderResult(re->reports, re->result, name, scene->r.quality); printf("Saved: %s", name); } } @@ -3198,7 +3217,7 @@ void RE_PreviewRender(Render *re, Main *bmain, Scene *sce) /* note; repeated win/disprect calc... solve that nicer, also in compo */ /* only the temp file! */ -void RE_ReadRenderResult(Scene *scene, Scene *scenode) +int RE_ReadRenderResult(Scene *scene, Scene *scenode) { Render *re; int winx, winy; @@ -3232,7 +3251,7 @@ void RE_ReadRenderResult(Scene *scene, Scene *scenode) RE_InitState(re, NULL, &scene->r, NULL, winx, winy, &disprect); re->scene= scene; - read_render_result(re, 0); + return read_render_result(re, 0); } void RE_set_max_threads(int threads) -- cgit v1.2.3 From 2883e035c87a4236629d9a89ea0a6e80b525e7d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Aug 2011 23:37:46 +0000 Subject: fix for error in my recent change to image save. - relative path wasn't being made absolute. - saving renders was always defaulting to multilayer exr, now use the output format set. --- source/blender/editors/space_image/image_ops.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index f96a8ea4d84..68f9e4d033e 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -960,20 +960,19 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, if(ibuf) { Image *ima= sima->image; - RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); simopts->planes= ibuf->depth; - /* cant save multilayer sequence, ima->rr isn't valid for a specific frame */ - if(rr && !(ima->source==IMA_SRC_SEQUENCE && ima->type==IMA_TYPE_MULTILAYER)) - simopts->imtype= R_MULTILAYER; - else if(ima->type==IMA_TYPE_R_RESULT) + if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { simopts->imtype= scene->r.imtype; - else if (ima->source == IMA_SRC_GENERATED) + simopts->planes= scene->r.planes; + } + else if (ima->source == IMA_SRC_GENERATED) { simopts->imtype= R_PNG; - else + } + else { simopts->imtype= BKE_ftype_to_imtype(ibuf->ftype); - + } simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ simopts->quality= ibuf->ftype & 0xff; @@ -1000,8 +999,6 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, } BLI_path_abs(simopts->filepath, G.main->name); } - /* cleanup */ - BKE_image_release_renderresult(scene, ima); } ED_space_image_release_buffer(sima, lock); @@ -1016,7 +1013,10 @@ static void save_image_options_from_op(SaveImageOptions *simopts, wmOperator *op // if (RNA_property_is_set(op->ptr, "subimtype")) simopts->subimtype= RNA_enum_get(op->ptr, "subimtype"); // XXX if (RNA_property_is_set(op->ptr, "file_quality")) simopts->quality= RNA_int_get(op->ptr, "file_quality"); - if (RNA_property_is_set(op->ptr, "filepath")) RNA_string_get(op->ptr, "filepath", simopts->filepath); + if (RNA_property_is_set(op->ptr, "filepath")) { + RNA_string_get(op->ptr, "filepath", simopts->filepath); + BLI_path_abs(simopts->filepath, G.main->name); + } } static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op) -- cgit v1.2.3 From 79249f8aede5c5481c625335b5ef7bd9b4cf28cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 31 Aug 2011 01:05:40 +0000 Subject: fix [#28430] Image with Stampinfo does not get saved correctly with alpha --- source/blender/blenfont/intern/blf_font.c | 9 ++++++++- source/blender/blenpluginapi/iff.h | 2 +- source/blender/imbuf/IMB_imbuf.h | 2 +- source/blender/imbuf/intern/rectop.c | 10 +++++++++- 4 files changed, 19 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 708b3708ab7..fb6505fe935 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -213,7 +213,7 @@ void blf_font_buffer(FontBLF *font, const char *str) { unsigned char *cbuf; unsigned int c; - unsigned char b_col_char[3]; + unsigned char b_col_char[4]; GlyphBLF *g, *g_prev; FT_Vector delta; FT_UInt glyph_index; @@ -232,6 +232,7 @@ void blf_font_buffer(FontBLF *font, const char *str) b_col_char[0]= font->b_col[0] * 255; b_col_char[1]= font->b_col[1] * 255; b_col_char[2]= font->b_col[2] * 255; + b_col_char[3]= font->b_col[3] * 255; while (str[i]) { int pen_y; @@ -296,16 +297,19 @@ void blf_font_buffer(FontBLF *font, const char *str) a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if(a > 0.0f) { + float alphatest; fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); if (a >= 1.0f) { fbuf[0]= font->b_col[0]; fbuf[1]= font->b_col[1]; fbuf[2]= font->b_col[2]; + fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]))) < 1.0f ? alphatest : 1.0f; } else { fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a)); fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a)); fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a)); + fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]*a))) < 1.0f ? alphatest : 1.0f; } } } @@ -324,16 +328,19 @@ void blf_font_buffer(FontBLF *font, const char *str) a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if(a > 0.0f) { + int alphatest; cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); if (a >= 1.0f) { cbuf[0]= b_col_char[0]; cbuf[1]= b_col_char[1]; cbuf[2]= b_col_char[2]; + cbuf[3]= (alphatest= ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255; } else { cbuf[0]= (b_col_char[0]*a) + (cbuf[0] * (1-a)); cbuf[1]= (b_col_char[1]*a) + (cbuf[1] * (1-a)); cbuf[2]= (b_col_char[2]*a) + (cbuf[2] * (1-a)); + cbuf[3]= (alphatest= ((int)cbuf[3] + (int)((font->b_col[3]*a)*255.0f))) < 255 ? alphatest : 255; } } } diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h index 77cdf889ea5..d29853f7d15 100644 --- a/source/blender/blenpluginapi/iff.h +++ b/source/blender/blenpluginapi/iff.h @@ -115,7 +115,7 @@ LIBIMPORT void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, LIBIMPORT void IMB_rectfill(struct ImBuf *drect, const float col[4]); LIBIMPORT void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); -LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); +LIBIMPORT void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2); LIBIMPORT void IMB_rectfill_alpha(struct ImBuf *drect, const float value); #endif /* IFF_H */ diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 1fbe8e01fd4..2c926f2d94b 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -499,7 +499,7 @@ void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, i void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value); /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */ -void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); +void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2); /* defined in metadata.c */ int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 844478e03cb..db2ae3a5114 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -482,7 +482,7 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4]) } -void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2) +void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2) { int i, j; float a; /* alpha */ @@ -509,6 +509,8 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, unsigned char *pixel; unsigned char chr=0, chg=0, chb=0; float fr=0, fg=0, fb=0; + + const int alphaint= FTOCHAR(a); if (a == 1.0f) { chr = FTOCHAR(col[0]); @@ -527,10 +529,13 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, pixel[0] = chr; pixel[1] = chg; pixel[2] = chb; + pixel[3] = 255; } else { + int alphatest; pixel[0] = (char)((fr + ((float)pixel[0]*aich))*255.0f); pixel[1] = (char)((fg + ((float)pixel[1]*aich))*255.0f); pixel[2] = (char)((fb + ((float)pixel[2]*aich))*255.0f); + pixel[3] = (char)((alphatest= ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255); } } } @@ -546,10 +551,13 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, pixel[0] = col[0]; pixel[1] = col[1]; pixel[2] = col[2]; + pixel[3] = 1.0f; } else { + float alphatest; pixel[0] = (col[0]*a) + (pixel[0]*ai); pixel[1] = (col[1]*a) + (pixel[1]*ai); pixel[2] = (col[2]*a) + (pixel[2]*ai); + pixel[3] = (alphatest= (pixel[3] + a)) < 1.0f ? alphatest : 1.0f; } } } -- cgit v1.2.3 From 471c005137540dd4c348c2f8e93146c0dff37a3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 31 Aug 2011 01:07:55 +0000 Subject: typo fix: end of lines ;; --> ; --- source/blender/blenkernel/intern/collision.c | 2 +- source/blender/blenlib/intern/math_matrix.c | 2 +- source/blender/editors/space_logic/logic_window.c | 2 +- source/blender/editors/space_view3d/view3d_edit.c | 2 +- source/blender/python/intern/bpy_intern_string.c | 2 +- source/gameengine/Converter/BL_BlenderDataConversion.cpp | 2 +- source/gameengine/GameLogic/SCA_ISensor.h | 2 +- source/gameengine/VideoTexture/FilterColor.h | 2 +- source/gameengine/VideoTexture/ImageMix.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index e2a1b0dfb33..a63e91cc8be 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1091,7 +1091,7 @@ static int cloth_collision_response_moving ( ClothModifierData *clmd, CollisionM VECADDMUL(cloth1->verts[collpair->ap1].impulse, pimpulse, w1*2.0); VECADDMUL(cloth1->verts[collpair->ap2].impulse, pimpulse, w2*2.0); - VECADDMUL(cloth1->verts[collpair->ap3].impulse, pimpulse, w3*2.0);; + VECADDMUL(cloth1->verts[collpair->ap3].impulse, pimpulse, w3*2.0); cloth1->verts[collpair->ap1].impulse_count++; cloth1->verts[collpair->ap2].impulse_count++; cloth1->verts[collpair->ap3].impulse_count++; diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 5edf6e28d4c..3c79a77707a 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -820,7 +820,7 @@ void normalize_m4_m4(float rmat[][4], float mat[][4]) len= normalize_v3_v3(rmat[1], mat[1]); if(len!=0.0f) rmat[1][3]= mat[1][3] / len; len= normalize_v3_v3(rmat[2], mat[2]); - if(len!=0.0f) rmat[2][3]= mat[2][3] / len;; + if(len!=0.0f) rmat[2][3]= mat[2][3] / len; } void adjoint_m3_m3(float m1[][3], float m[][3]) diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 882d89fcd33..920e93cc0fc 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -3677,7 +3677,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) { Object *ob = (Object *)ptr->id.data; PointerRNA settings_ptr; - uiLayout *row, *subrow, *col;; + uiLayout *row, *subrow, *col; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index e9ed5dac3de..19e8d42db2d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3475,7 +3475,7 @@ void ED_view3d_from_m4(float mat[][4], float ofs[3], float quat[4], float *dist) copy_m3_m4(nmat, mat); normalize_m3(nmat); - mul_m3_v3(nmat, vec);; + mul_m3_v3(nmat, vec); sub_v3_v3(ofs, vec); } } diff --git a/source/blender/python/intern/bpy_intern_string.c b/source/blender/python/intern/bpy_intern_string.c index 6fc861b2a0d..7c80653496f 100644 --- a/source/blender/python/intern/bpy_intern_string.c +++ b/source/blender/python/intern/bpy_intern_string.c @@ -40,7 +40,7 @@ PyObject *bpy_intern_str___slots__; void bpy_intern_string_init(void) { bpy_intern_str_register= PyUnicode_FromString("register"); - bpy_intern_str_unregister= PyUnicode_FromString("unregister");; + bpy_intern_str_unregister= PyUnicode_FromString("unregister"); bpy_intern_str_bl_rna= PyUnicode_FromString("bl_rna"); bpy_intern_str_order= PyUnicode_FromString("order"); bpy_intern_str_attr= PyUnicode_FromString("attr"); diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 4daed538b39..887deb1ffa3 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1483,7 +1483,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, { objprop.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT; - objprop.m_soft_linStiff = 0.5;; + objprop.m_soft_linStiff = 0.5; objprop.m_soft_angStiff = 1.f; /* angular stiffness 0..1 */ objprop.m_soft_volume= 1.f; /* volume preservation 0..1 */ diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h index 741448b1096..f90f1e19a67 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.h +++ b/source/gameengine/GameLogic/SCA_ISensor.h @@ -105,7 +105,7 @@ public: }; SCA_ISensor(SCA_IObject* gameobj, - class SCA_EventManager* eventmgr);; + class SCA_EventManager* eventmgr); ~SCA_ISensor(); virtual void ReParent(SCA_IObject* parent); diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h index 2478727a6be..d0536ed2801 100644 --- a/source/gameengine/VideoTexture/FilterColor.h +++ b/source/gameengine/VideoTexture/FilterColor.h @@ -141,7 +141,7 @@ protected: /// calculate one color component unsigned int calcColor (unsigned int val, short idx) { - unsigned int col = VT_C(val,idx);; + unsigned int col = VT_C(val,idx); if (col <= levels[idx][0]) col = 0; else if (col >= levels[idx][1]) col = 0xFF; else col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & 0xFF; diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp index 7a8226aab03..aeef5d1694f 100644 --- a/source/gameengine/VideoTexture/ImageMix.cpp +++ b/source/gameengine/VideoTexture/ImageMix.cpp @@ -135,7 +135,7 @@ PyObject * setWeight (PyImage * self, PyObject * args) if (!getImageMix(self)->setWeight(id, weight)) { // if not set, report error - PyErr_SetString(PyExc_RuntimeError, "Invalid id of source");; + PyErr_SetString(PyExc_RuntimeError, "Invalid id of source"); return NULL; } // return none -- cgit v1.2.3 From f63d049adc268bc71ac87c2b781e2f44f60da1f5 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 31 Aug 2011 05:51:51 +0000 Subject: BGE: Adding two new functions to bge.render to allow users to change the anisotropic filtering level used by textures: * setAnisotropicFiltering(level) * getAnisotropicFiltering() --- source/gameengine/Ketsji/KX_PythonInit.cpp | 26 ++++++++++++++++++++++ source/gameengine/Rasterizer/RAS_IRasterizer.h | 3 +++ .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 13 +++++++++++ .../RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h | 5 +++++ 4 files changed, 47 insertions(+) (limited to 'source') diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 06db84feb23..8557ebab0a9 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1208,6 +1208,28 @@ static PyObject* gPyGetMaterialType(PyObject*) return PyLong_FromSsize_t(flag); } +static PyObject* gPySetAnisotropicFiltering(PyObject*, PyObject* args) +{ + short level; + + if (!PyArg_ParseTuple(args, "h:setAnisotropicFiltering", &level)) + return NULL; + + if (level != 1 && level != 2 && level != 4 && level != 8 && level != 16) { + PyErr_SetString(PyExc_ValueError, "Rasterizer.setAnisotropicFiltering(level): Expected value of 1, 2, 4, 8, or 16 for value"); + return NULL; + } + + gp_Rasterizer->SetAnisotropicFiltering(level); + + Py_RETURN_NONE; +} + +static PyObject* gPyGetAnisotropicFiltering(PyObject*, PyObject* args) +{ + return PyLong_FromLong(gp_Rasterizer->GetAnisotropicFiltering()); +} + static PyObject* gPyDrawLine(PyObject*, PyObject* args) { PyObject* ob_from; @@ -1272,6 +1294,10 @@ static struct PyMethodDef rasterizer_methods[] = { METH_VARARGS, "set the state of a GLSL material setting"}, {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting, METH_VARARGS, "get the state of a GLSL material setting"}, + {"setAnisotropicFiltering", (PyCFunction) gPySetAnisotropicFiltering, + METH_VARARGS, "set the anisotropic filtering level (must be one of 1, 2, 4, 8, 16)"}, + {"getAnisotropicFiltering", (PyCFunction) gPyGetAnisotropicFiltering, + METH_VARARGS, "get the anisotropic filtering level"}, {"drawLine", (PyCFunction) gPyDrawLine, METH_VARARGS, "draw a line on the screen"}, { NULL, (PyCFunction) NULL, 0, NULL } diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h index 305e2bca756..c46ebf742a0 100644 --- a/source/gameengine/Rasterizer/RAS_IRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h @@ -417,6 +417,9 @@ public: virtual void SetBlendingMode(int blendmode)=0; virtual void SetFrontFace(bool ccw)=0; + + virtual void SetAnisotropicFiltering(short level)=0; + virtual short GetAnisotropicFiltering()=0; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 23e0a50ed6f..50d034a5a5a 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -99,12 +99,16 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas) hinterlace_mask[i] = (i&1)*0xFFFFFFFF; } hinterlace_mask[32] = 0; + + m_prevafvalue = GPU_get_anisotropic(); } RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer() { + // Restore the previous AF value + GPU_set_anisotropic(m_prevafvalue); } bool RAS_OpenGLRasterizer::Init() @@ -1204,3 +1208,12 @@ void RAS_OpenGLRasterizer::SetFrontFace(bool ccw) m_last_frontface = ccw; } +void RAS_OpenGLRasterizer::SetAnisotropicFiltering(short level) +{ + GPU_set_anisotropic((float)level); +} + +short RAS_OpenGLRasterizer::GetAnisotropicFiltering() +{ + return (short)GPU_get_anisotropic(); +} diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h index 54fab906049..61568df91eb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h @@ -94,6 +94,8 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer bool m_setfocallength; int m_noOfScanlines; + short m_prevafvalue; + //motion blur int m_motionblur; float m_motionblurvalue; @@ -294,6 +296,9 @@ public: virtual void SetBlendingMode(int blendmode); virtual void SetFrontFace(bool ccw); + virtual void SetAnisotropicFiltering(short level); + virtual short GetAnisotropicFiltering(); + #ifdef WITH_CXX_GUARDEDALLOC public: -- cgit v1.2.3 From d0d82c69e96e96845a59ad625900a94187dac621 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 31 Aug 2011 09:37:14 +0000 Subject: COLLADA: Take parent bone length and direction instead of using bone pointing up with length 1. Looks much nicer and less confusing on larger armatures now. --- source/blender/collada/ArmatureImporter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 1e7879b352f..2ec8ae540d2 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -310,9 +310,10 @@ void ArmatureImporter::fix_leaf_bones( ) LeafBone& leaf = *it; // pointing up - float vec[3] = {0.0f, 0.0f, 1.0f}; + float vec[3] = {0.0f, 0.0f, 0.1f}; - //mul_v3_fl(vec, leaf_bone_length); + // if parent: take parent length and direction + if(leaf.bone->parent) sub_v3_v3v3(vec, leaf.bone->parent->tail, leaf.bone->parent->head); copy_v3_v3(leaf.bone->tail, leaf.bone->head); add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); -- cgit v1.2.3 From fde215025eff7f3581435bfdb90fb9d354538d07 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 31 Aug 2011 10:43:22 +0000 Subject: patch [#28218] During-render callback functionality from Jesse Kaukonen (gekko) --- text from the patch. Recently Campbell Barton added callback functionality for Python's usage, but this only includes pre- and post-render callbacks. There are no callbacks for the duration of the render. This patch adds the few lines required for executing a callback while Blender Render is working. The callback resides in the rendering pipeline stats function, so whenever statistics are printed, the callback is executed. This functionality is required if one wants to: 1) Observe what is happening while Blender is rendering via the command line 2) Add custom statistics that Blender prints while the renderer works 3) The user wants to continue executing his Python script without the code halting at bpy.ops.render.render() Personally I'm currently using this for printing out more detailed progress reports at Renderfarm.fi (such as CPU time, time spent rendering, total progress in regards to the entire rendering process). Tested on Windows, Linux and OS X. Example on how to use the callback: def statscall(context): print("Thanks for calling!") bpy.app.handlers.render_stats.append(statscall) bpy.ops.render.render(animation=False, write_still=True) --- source/blender/blenlib/BLI_callbacks.h | 1 + source/blender/python/intern/bpy_app_handlers.c | 5 +++-- source/blender/render/intern/source/pipeline.c | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenlib/BLI_callbacks.h b/source/blender/blenlib/BLI_callbacks.h index 1735848e774..f20cef9c3ea 100644 --- a/source/blender/blenlib/BLI_callbacks.h +++ b/source/blender/blenlib/BLI_callbacks.h @@ -42,6 +42,7 @@ struct ID; typedef enum { BLI_CB_EVT_RENDER_PRE, BLI_CB_EVT_RENDER_POST, + BLI_CB_EVT_RENDER_STATS, BLI_CB_EVT_LOAD_PRE, BLI_CB_EVT_LOAD_POST, BLI_CB_EVT_SAVE_PRE, diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index 26d9ca76e3f..e7e46160199 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -42,9 +42,10 @@ static PyTypeObject BlenderAppCbType; static PyStructSequence_Field app_cb_info_fields[]= { {(char *)"render_pre", NULL}, {(char *)"render_post", NULL}, - {(char *)"load_pre", NULL}, + {(char *)"render_stats", NULL}, + {(char *)"load_pre", NULL}, {(char *)"load_post", NULL}, - {(char *)"save_pre", NULL}, + {(char *)"save_pre", NULL}, {(char *)"save_post", NULL}, {NULL} }; diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 77b637b5129..24c55332bff 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -173,6 +173,9 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) else fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp); } + + BLI_exec_cb(rs, (ID *)rs, BLI_CB_EVT_RENDER_STATS); + fputc('\n', stdout); fflush(stdout); } -- cgit v1.2.3 From 812d5d2e5c4be0f646a29c436be68bcf4149bd13 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Wed, 31 Aug 2011 22:32:14 +0000 Subject: BGE Animations: The return type for KX_GameObject.getActionFrame() was an integer when it should have been a float. I've fixed this and converted the tabs in the new BGE animation docs to space. I have also added more info on return types for KX_GameObject.getActionFrame() and KX_GameObject.isPlayingAction(). --- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index d51e2aa5386..7ced0c0c4d7 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -3124,7 +3124,7 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getActionFrame, layer_check(layer, "getActionFrame"); - return PyLong_FromLong(GetActionFrame(layer)); + return PyFloat_FromDouble(GetActionFrame(layer)); } KX_PYMETHODDEF_DOC(KX_GameObject, setActionFrame, -- cgit v1.2.3 From a22dc764bbb68bf05ddfd567c27229fbf1a63271 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Sep 2011 01:13:50 +0000 Subject: fix for error in patch from r39821. --- source/blender/render/intern/source/pipeline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 24c55332bff..68190014041 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -174,7 +174,7 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs) fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp); } - BLI_exec_cb(rs, (ID *)rs, BLI_CB_EVT_RENDER_STATS); + BLI_exec_cb(G.main, NULL, BLI_CB_EVT_RENDER_STATS); fputc('\n', stdout); fflush(stdout); -- cgit v1.2.3 From 00143a3d557d87dda2bb7074dfe2b1a3acf5f28f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Sep 2011 01:48:50 +0000 Subject: spaces -> tabs (configure you're editors right!) --- source/blender/blenkernel/intern/collision.c | 4 +- source/blender/blenlib/intern/math_geom.c | 2 +- source/blender/editors/object/object_bake.c | 2 +- source/blender/editors/space_node/drawnode.c | 2 +- source/blender/editors/space_view3d/view3d_view.c | 4 +- source/blender/imbuf/intern/anim_movie.c | 2 +- source/blender/imbuf/intern/indexer_dv.c | 256 +++++++++++----------- source/blender/python/generic/bgl.c | 6 +- source/blender/render/intern/source/pipeline.c | 6 +- source/blender/render/intern/source/zbuf.c | 14 +- 10 files changed, 148 insertions(+), 150 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index a63e91cc8be..ed073f03270 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1487,8 +1487,8 @@ static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, sdis = clmd->coll_parms->distance_repel + epsilon2 + FLT_EPSILON; - /*apply a repulsion force, to help the solver along. - this is kindof crude, it only tests one vert of the triangle*/ + /* apply a repulsion force, to help the solver along. + * this is kindof crude, it only tests one vert of the triangle */ if (isect_ray_plane_v3(cloth->verts[collpair->ap1].tx, n2, collmd->current_xnew[collpair->bp1].co, collmd->current_xnew[collpair->bp2].co, collmd->current_xnew[collpair->bp3].co, &l, 0)) diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 5b5de3ab3b6..8f025880a86 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -1968,7 +1968,7 @@ void resolve_tri_uv(float uv[2], const float st[2], const float st0[2], const fl void resolve_quad_uv(float uv[2], const float st[2], const float st0[2], const float st1[2], const float st2[2], const float st3[2]) { const double signed_area= (st0[0]*st1[1] - st0[1]*st1[0]) + (st1[0]*st2[1] - st1[1]*st2[0]) + - (st2[0]*st3[1] - st2[1]*st3[0]) + (st3[0]*st0[1] - st3[1]*st0[0]); + (st2[0]*st3[1] - st2[1]*st3[0]) + (st3[0]*st0[1] - st3[1]*st0[0]); /* X is 2D cross product (determinant) A= (p0-p) X (p0-p3)*/ diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index ee162464c70..07c006a7995 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -159,7 +159,7 @@ typedef struct { static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], const int face_num, const int vert_index) { unsigned int indices[]= {data->mface[face_num].v1, data->mface[face_num].v2, - data->mface[face_num].v3, data->mface[face_num].v4}; + data->mface[face_num].v3, data->mface[face_num].v4}; const int smoothnormal= (data->mface[face_num].flag & ME_SMOOTH); if(!smoothnormal) { /* flat */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index c32d05e9c30..0474d1f3bb1 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1385,7 +1385,7 @@ static void node_texture_set_butfunc(bNodeType *ntype) default: ntype->uifunc= NULL; } - if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc; + if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc; } /* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c48459108eb..44ae6837aa2 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -625,8 +625,8 @@ void ED_view3d_win_to_3d(ARegion *ar, const float depth_pt[3], const float mval[ } } else { - const float dx= (2.0f * mval[0] / (float)ar->winx) - 1.0f; - const float dy= (2.0f * mval[1] / (float)ar->winy) - 1.0f; + const float dx= (2.0f * mval[0] / (float)ar->winx) - 1.0f; + const float dy= (2.0f * mval[1] / (float)ar->winy) - 1.0f; line_sta[0]= (rv3d->persinv[0][0] * dx) + (rv3d->persinv[1][0] * dy) + rv3d->viewinv[3][0]; line_sta[1]= (rv3d->persinv[0][1] * dx) + (rv3d->persinv[1][1] * dy) + rv3d->viewinv[3][1]; line_sta[2]= (rv3d->persinv[0][2] * dx) + (rv3d->persinv[1][2] * dy) + rv3d->viewinv[3][2]; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 7b172008bee..c4fe1523e90 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -922,7 +922,7 @@ static int ffmpeg_decode_video_frame(struct anim * anim) static void ffmpeg_decode_video_frame_scan( struct anim * anim, int64_t pts_to_search) { - /* there seem to exist *very* silly GOP lengths out in the wild... */ + /* there seem to exist *very* silly GOP lengths out in the wild... */ int count = 1000; av_log(anim->pFormatCtx, diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c index 2def0d042b7..d1202136d56 100644 --- a/source/blender/imbuf/intern/indexer_dv.c +++ b/source/blender/imbuf/intern/indexer_dv.c @@ -30,8 +30,8 @@ #include typedef struct indexer_dv_bitstream { - unsigned char* buffer; - int bit_pos; + unsigned char* buffer; + int bit_pos; } indexer_dv_bitstream; static indexer_dv_bitstream bitstream_new(unsigned char* buffer_) @@ -57,41 +57,41 @@ static unsigned long bitstream_get_bits(indexer_dv_bitstream * This, int num) } static int parse_num(indexer_dv_bitstream * b, int numbits) { - return bitstream_get_bits(b, numbits); + return bitstream_get_bits(b, numbits); } static int parse_bcd(indexer_dv_bitstream * b, int n) { - char s[256]; + char s[256]; char * p = s + (n+3)/4; *p-- = 0; - while (n > 4) { - char a; - int v = bitstream_get_bits(b, 4); + while (n > 4) { + char a; + int v = bitstream_get_bits(b, 4); - n -= 4; + n -= 4; a = '0' + v; - if (a > '9') { - bitstream_get_bits(b, n); + if (a > '9') { + bitstream_get_bits(b, n); return -1; - } + } *p-- = a; - } - if (n) { - char a; - int v = bitstream_get_bits(b, n); - a = '0' + v; - if (a > '9') { + } + if (n) { + char a; + int v = bitstream_get_bits(b, n); + a = '0' + v; + if (a > '9') { return -1; - } - *p-- = a; - } + } + *p-- = a; + } - return atol(s); + return atol(s); } typedef struct indexer_dv_context @@ -125,124 +125,124 @@ typedef struct indexer_dv_context static void parse_packet(indexer_dv_context * This, unsigned char * p) { - indexer_dv_bitstream b; - int type = p[0]; + indexer_dv_bitstream b; + int type = p[0]; b = bitstream_new(p + 1); - switch (type) { - case 0x62: // Record date - parse_num(&b, 8); - This->rec_curr_day = parse_bcd(&b, 6); - parse_num(&b, 2); - This->rec_curr_month = parse_bcd(&b, 5); - parse_num(&b, 3); - This->rec_curr_year = parse_bcd(&b, 8); - if (This->rec_curr_year < 25) { - This->rec_curr_year += 2000; - } else { - This->rec_curr_year += 1900; - } - This->got_record_date = 1; - break; - case 0x63: // Record time - This->rec_curr_frame = parse_bcd(&b, 6); - parse_num(&b, 2); - This->rec_curr_second = parse_bcd(&b, 7); - parse_num(&b, 1); - This->rec_curr_minute = parse_bcd(&b, 7); - parse_num(&b, 1); - This->rec_curr_hour = parse_bcd(&b, 6); - This->got_record_time = 1; - break; - } + switch (type) { + case 0x62: // Record date + parse_num(&b, 8); + This->rec_curr_day = parse_bcd(&b, 6); + parse_num(&b, 2); + This->rec_curr_month = parse_bcd(&b, 5); + parse_num(&b, 3); + This->rec_curr_year = parse_bcd(&b, 8); + if (This->rec_curr_year < 25) { + This->rec_curr_year += 2000; + } else { + This->rec_curr_year += 1900; + } + This->got_record_date = 1; + break; + case 0x63: // Record time + This->rec_curr_frame = parse_bcd(&b, 6); + parse_num(&b, 2); + This->rec_curr_second = parse_bcd(&b, 7); + parse_num(&b, 1); + This->rec_curr_minute = parse_bcd(&b, 7); + parse_num(&b, 1); + This->rec_curr_hour = parse_bcd(&b, 6); + This->got_record_time = 1; + break; + } } static void parse_header_block(indexer_dv_context * This, unsigned char* target) { int i; - for (i = 3; i < 80; i += 5) { - if (target[i] != 0xff) { - parse_packet(This, target + i); - } - } + for (i = 3; i < 80; i += 5) { + if (target[i] != 0xff) { + parse_packet(This, target + i); + } + } } static void parse_subcode_blocks( - indexer_dv_context * This, unsigned char* target) + indexer_dv_context * This, unsigned char* target) { int i,j; - for (j = 0; j < 2; j++) { - for (i = 3; i < 80; i += 5) { - if (target[i] != 0xff) { - parse_packet(This, target + i); - } - } - } + for (j = 0; j < 2; j++) { + for (i = 3; i < 80; i += 5) { + if (target[i] != 0xff) { + parse_packet(This, target + i); + } + } + } } static void parse_vaux_blocks( - indexer_dv_context * This, unsigned char* target) + indexer_dv_context * This, unsigned char* target) { int i,j; - for (j = 0; j < 3; j++) { - for (i = 3; i < 80; i += 5) { - if (target[i] != 0xff) { - parse_packet(This, target + i); - } - } - target += 80; - } + for (j = 0; j < 3; j++) { + for (i = 3; i < 80; i += 5) { + if (target[i] != 0xff) { + parse_packet(This, target + i); + } + } + target += 80; + } } static void parse_audio_headers( - indexer_dv_context * This, unsigned char* target) + indexer_dv_context * This, unsigned char* target) { int i; - for(i = 0; i < 9; i++) { - if (target[3] != 0xff) { - parse_packet(This, target + 3); - } - target += 16 * 80; - } + for(i = 0; i < 9; i++) { + if (target[3] != 0xff) { + parse_packet(This, target + 3); + } + target += 16 * 80; + } } static void parse_frame(indexer_dv_context * This, - unsigned char * framebuffer, int isPAL) + unsigned char * framebuffer, int isPAL) { - int numDIFseq = isPAL ? 12 : 10; - unsigned char* target = framebuffer; + int numDIFseq = isPAL ? 12 : 10; + unsigned char* target = framebuffer; int ds; - for (ds = 0; ds < numDIFseq; ds++) { - parse_header_block(This, target); - target += 1 * 80; - parse_subcode_blocks(This, target); - target += 2 * 80; - parse_vaux_blocks(This, target); - target += 3 * 80; - parse_audio_headers(This, target); - target += 144 * 80; - } + for (ds = 0; ds < numDIFseq; ds++) { + parse_header_block(This, target); + target += 1 * 80; + parse_subcode_blocks(This, target); + target += 2 * 80; + parse_vaux_blocks(This, target); + target += 3 * 80; + parse_audio_headers(This, target); + target += 144 * 80; + } } static void inc_frame(int * frame, time_t * t, int isPAL) { - if ((isPAL && *frame >= 25) || (!isPAL && *frame >= 30)) { - fprintf(stderr, "Ouchie: inc_frame: invalid_frameno: %d\n", - *frame); - } - (*frame)++; - if (isPAL && *frame >= 25) { - (*t)++; - *frame = 0; - } else if (!isPAL && *frame >= 30) { - (*t)++; - *frame = 0; - } + if ((isPAL && *frame >= 25) || (!isPAL && *frame >= 30)) { + fprintf(stderr, "Ouchie: inc_frame: invalid_frameno: %d\n", + *frame); + } + (*frame)++; + if (isPAL && *frame >= 25) { + (*t)++; + *frame = 0; + } else if (!isPAL && *frame >= 30) { + (*t)++; + *frame = 0; + } } static void write_index(indexer_dv_context * This, anim_index_entry * entry) @@ -256,36 +256,36 @@ static void fill_gap(indexer_dv_context * This, int isPAL) { int i; - for (i = 0; i < This->fsize; i++) { - if (This->gap_start == This->ref_time_read && - This->gap_frame == This->curr_frame) { - fprintf(stderr, - "indexer_dv::fill_gap: " - "can't seek backwards !\n"); - break; - } - inc_frame(&This->gap_frame, &This->gap_start, isPAL); - } - - while (This->gap_start != This->ref_time_read || + for (i = 0; i < This->fsize; i++) { + if (This->gap_start == This->ref_time_read && + This->gap_frame == This->curr_frame) { + fprintf(stderr, + "indexer_dv::fill_gap: " + "can't seek backwards !\n"); + break; + } + inc_frame(&This->gap_frame, &This->gap_start, isPAL); + } + + while (This->gap_start != This->ref_time_read || This->gap_frame != This->curr_frame) { - inc_frame(&This->gap_frame, &This->gap_start, isPAL); + inc_frame(&This->gap_frame, &This->gap_start, isPAL); This->frameno_offset++; - } + } - for (i = 0; i < This->fsize; i++) { + for (i = 0; i < This->fsize; i++) { write_index(This, This->backbuffer + i); - } - This->fsize = 0; + } + This->fsize = 0; } static void proc_frame(indexer_dv_context * This, - unsigned char* UNUSED(framebuffer), int isPAL) + unsigned char* UNUSED(framebuffer), int isPAL) { struct tm recDate; time_t t; - if (!This->got_record_date || !This->got_record_time) { + if (!This->got_record_date || !This->got_record_time) { return; } @@ -329,9 +329,9 @@ static void proc_frame(indexer_dv_context * This, } static void indexer_dv_proc_frame(anim_index_builder * idx, - unsigned char * buffer, - int UNUSED(data_size), - struct anim_index_entry * entry) + unsigned char * buffer, + int UNUSED(data_size), + struct anim_index_entry * entry) { int isPAL; @@ -354,7 +354,7 @@ static void indexer_dv_proc_frame(anim_index_builder * idx, int i; fprintf(stderr, "indexer_dv::indexer_dv_proc_frame: " - "backbuffer overrun, emergency flush"); + "backbuffer overrun, emergency flush"); for (i = 0; i < This->fsize; i++) { write_index(This, This->backbuffer+i); @@ -378,8 +378,8 @@ static void indexer_dv_delete(anim_index_builder * idx) void IMB_indexer_dv_new(anim_index_builder * idx) { - indexer_dv_context * rv = MEM_callocN( - sizeof(indexer_dv_context), "index_dv builder context"); + indexer_dv_context * rv = MEM_callocN( + sizeof(indexer_dv_context), "index_dv builder context"); rv->ref_time_read = -1; rv->curr_frame = -1; diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 09432e0b316..ae8069cf3c5 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -52,11 +52,9 @@ static int Buffer_len(Buffer *self); static PyObject *Buffer_item(Buffer *self, int i); static PyObject *Buffer_slice(Buffer *self, int begin, int end); static int Buffer_ass_item(Buffer *self, int i, PyObject *v); -static int Buffer_ass_slice(Buffer *self, int begin, int end, - PyObject *seq); +static int Buffer_ass_slice(Buffer *self, int begin, int end, PyObject *seq); static PyObject *Buffer_subscript(Buffer *self, PyObject *item); -static int Buffer_ass_subscript(Buffer *self, PyObject *item, - PyObject *value); +static int Buffer_ass_subscript(Buffer *self, PyObject *item, PyObject *value); static PySequenceMethods Buffer_SeqMethods = { (lenfunc) Buffer_len, /*sq_length */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 68190014041..49e5e7b989d 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -641,9 +641,9 @@ static RenderResult *new_render_result(Render *re, rcti *partrct, int crop, int render_layer_add_pass(rr, rl, 3, SCE_PASS_REFRACT); if(srl->passflag & SCE_PASS_INDEXOB) render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXOB); - if(srl->passflag & SCE_PASS_INDEXMA) - render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXMA); - if(srl->passflag & SCE_PASS_MIST) + if(srl->passflag & SCE_PASS_INDEXMA) + render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXMA); + if(srl->passflag & SCE_PASS_MIST) render_layer_add_pass(rr, rl, 1, SCE_PASS_MIST); if(rl->passflag & SCE_PASS_RAYHITS) render_layer_add_pass(rr, rl, 4, SCE_PASS_RAYHITS); diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 04e4ce2c647..925f8529dfa 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -4115,13 +4115,13 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas add_transp_obindex(rlpp[a], od, obr->ob); } } - if(addpassflag & SCE_PASS_INDEXMA) { - ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr; - if(obr->ob) { - for(a= 0; aob); - } - } + if(addpassflag & SCE_PASS_INDEXMA) { + ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr; + if(obr->ob) { + for(a= 0; aob); + } + } /* for each mask-sample we alpha-under colors. then in end it's added using filter */ memset(samp_shr, 0, sizeof(ShadeResult)*osa); -- cgit v1.2.3 From 2365c64014b3e067bb212b2061f1d14c1f944090 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Sep 2011 02:12:53 +0000 Subject: whitespace bge edits --- .../Converter/BL_BlenderDataConversion.cpp | 18 +- source/gameengine/Converter/BL_ShapeDeformer.cpp | 12 +- source/gameengine/Converter/BlenderWorldInfo.cpp | 6 +- .../gameengine/Converter/KX_ConvertActuators.cpp | 6 +- source/gameengine/Converter/KX_ConvertSensors.cpp | 2 +- source/gameengine/Expressions/InputParser.cpp | 210 ++++---- .../gameengine/GameLogic/SCA_2DFilterActuator.cpp | 32 +- source/gameengine/GameLogic/SCA_ISensor.cpp | 4 +- source/gameengine/GameLogic/SCA_KeyboardSensor.cpp | 4 +- source/gameengine/GameLogic/SCA_MouseSensor.cpp | 12 +- .../GameLogic/SCA_RandomNumberGenerator.cpp | 78 +-- source/gameengine/GameLogic/SCA_RandomSensor.cpp | 30 +- source/gameengine/GameLogic/SCA_XORController.cpp | 8 +- source/gameengine/GamePlayer/common/bmfont.cpp | 2 +- .../GamePlayer/ghost/GPG_Application.cpp | 2 +- source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 16 +- source/gameengine/Ketsji/BL_BlenderShader.cpp | 2 +- .../Ketsji/KXNetwork/KX_NetworkEventManager.cpp | 4 +- .../Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp | 3 +- .../Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp | 12 +- source/gameengine/Ketsji/KX_BlenderMaterial.cpp | 37 +- .../Ketsji/KX_BulletPhysicsController.cpp | 18 +- source/gameengine/Ketsji/KX_Camera.cpp | 24 +- source/gameengine/Ketsji/KX_Dome.cpp | 60 +-- source/gameengine/Ketsji/KX_GameObject.cpp | 48 +- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 2 +- source/gameengine/Ketsji/KX_Light.cpp | 10 +- source/gameengine/Ketsji/KX_MeshProxy.cpp | 14 +- source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 8 +- source/gameengine/Ketsji/KX_PythonInit.cpp | 82 +-- source/gameengine/Ketsji/KX_RaySensor.cpp | 20 +- .../gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp | 8 +- source/gameengine/Ketsji/KX_TrackToActuator.cpp | 18 +- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 2 +- source/gameengine/SceneGraph/SG_BBox.cpp | 4 +- source/gameengine/SceneGraph/SG_Spatial.cpp | 15 +- source/gameengine/VideoTexture/Exception.cpp | 30 +- source/gameengine/VideoTexture/ImageBase.cpp | 26 +- source/gameengine/VideoTexture/ImageRender.cpp | 584 ++++++++++----------- source/gameengine/VideoTexture/ImageViewport.cpp | 42 +- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 6 +- source/gameengine/VideoTexture/blendVideoTex.cpp | 4 +- 42 files changed, 760 insertions(+), 765 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 887deb1ffa3..fcfc07e631e 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1911,11 +1911,11 @@ void RBJconstraints(Object *ob)//not used KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc){//not used - for (int j=0;jGetCount();j++) + for (int j=0;jGetCount();j++) { - KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); - if (gameobje->GetName()==busc) - return gameobje->GetPhysicsController(); + KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); + if (gameobje->GetName()==busc) + return gameobje->GetPhysicsController(); } return 0; @@ -1924,11 +1924,11 @@ KX_IPhysicsController* getPhId(CListValue* sumolist,STR_String busc){//not used KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist){ - for (int j=0;jGetCount();j++) + for (int j=0;jGetCount();j++) { - KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); - if (gameobje->GetName()==busc) - return gameobje; + KX_GameObject* gameobje = (KX_GameObject*) sumolist->GetValue(j); + if (gameobje->GetName()==busc) + return gameobje; } return 0; @@ -2629,7 +2629,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); //we need to pass a full constraint frame, not just axis - + //localConstraintFrameBasis MT_Matrix3x3 localCFrame(MT_Vector3(dat->axX,dat->axY,dat->axZ)); MT_Vector3 axis0 = localCFrame.getColumn(0); diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index befe0f6e784..f4c683f60ba 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -69,12 +69,12 @@ extern "C"{ //#undef __NLA_DEFNORMALS BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, - Object *bmeshobj, - RAS_MeshObject *mesh) - : - BL_SkinDeformer(gameobj,bmeshobj, mesh), - m_useShapeDrivers(false), - m_lastShapeUpdate(-1) + Object *bmeshobj, + RAS_MeshObject *mesh) + : + BL_SkinDeformer(gameobj,bmeshobj, mesh), + m_useShapeDrivers(false), + m_lastShapeUpdate(-1) { m_key = m_bmesh->key; m_bmesh->key = copy_key(m_key); diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index 8fc01032de7..f003a0049e5 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -170,10 +170,10 @@ float BlenderWorldInfo::getMistStart() float BlenderWorldInfo::getMistDistance() { return m_mistdistance; -} - +} + + - float BlenderWorldInfo::getMistColorRed() { return m_mistcolor[0]; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index 9621d05b5cc..a84a1419d0d 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -996,7 +996,7 @@ void BL_ConvertActuators(char* maggiename, filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER; break; } - + tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag, _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),scene); @@ -1012,8 +1012,8 @@ void BL_ConvertActuators(char* maggiename, } } - baseact = tmp; - + baseact = tmp; + } break; case ACT_PARENT: diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index ad6941dcdc7..a250bc6064b 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -276,7 +276,7 @@ void BL_ConvertSensors(struct Object* blenderobject, gReverseKeyTranslateTable[ENDKEY ] = SCA_IInputDevice::KX_ENDKEY; } - int executePriority = 0; + int executePriority = 0; int uniqueint = 0; int count = 0; bSensor* sens = (bSensor*)blenderobject->sensors.first; diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp index 7957c82e7f9..27f4f0b10cb 100644 --- a/source/gameengine/Expressions/InputParser.cpp +++ b/source/gameengine/Expressions/InputParser.cpp @@ -192,89 +192,89 @@ void CParser::NextSym() switch(ch) { - case '(': - sym = lbracksym; NextCh(); - break; - case ')': - sym = rbracksym; NextCh(); - break; - case ',': - sym = commasym; NextCh(); - break; - case '%' : - sym = opsym; opkind = OPmodulus; NextCh(); - break; - case '+' : - sym = opsym; opkind = OPplus; NextCh(); - break; - case '-' : - sym = opsym; opkind = OPminus; NextCh(); - break; - case '*' : - sym = opsym; opkind = OPtimes; NextCh(); - break; - case '/' : - sym = opsym; opkind = OPdivide; NextCh(); - break; - case '&' : - sym = opsym; opkind = OPand; NextCh(); TermChar('&'); - break; - case '|' : - sym = opsym; opkind = OPor; NextCh(); TermChar('|'); - break; - case '=' : - sym = opsym; opkind = OPequal; NextCh(); TermChar('='); - break; - case '!' : - sym = opsym; - NextCh(); - if (ch == '=') - { - opkind = OPunequal; + case '(': + sym = lbracksym; NextCh(); + break; + case ')': + sym = rbracksym; NextCh(); + break; + case ',': + sym = commasym; NextCh(); + break; + case '%' : + sym = opsym; opkind = OPmodulus; NextCh(); + break; + case '+' : + sym = opsym; opkind = OPplus; NextCh(); + break; + case '-' : + sym = opsym; opkind = OPminus; NextCh(); + break; + case '*' : + sym = opsym; opkind = OPtimes; NextCh(); + break; + case '/' : + sym = opsym; opkind = OPdivide; NextCh(); + break; + case '&' : + sym = opsym; opkind = OPand; NextCh(); TermChar('&'); + break; + case '|' : + sym = opsym; opkind = OPor; NextCh(); TermChar('|'); + break; + case '=' : + sym = opsym; opkind = OPequal; NextCh(); TermChar('='); + break; + case '!' : + sym = opsym; NextCh(); - } - else - { - opkind = OPnot; - } - break; - case '>': - sym = opsym; - NextCh(); - if (ch == '=') - { - opkind = OPgreaterequal; + if (ch == '=') + { + opkind = OPunequal; + NextCh(); + } + else + { + opkind = OPnot; + } + break; + case '>': + sym = opsym; NextCh(); - } - else - { - opkind = OPgreater; - } - break; - case '<': - sym = opsym; - NextCh(); - if (ch == '=') { - opkind = OPlessequal; + if (ch == '=') + { + opkind = OPgreaterequal; + NextCh(); + } + else + { + opkind = OPgreater; + } + break; + case '<': + sym = opsym; NextCh(); - } else { - opkind = OPless; - } - break; - case '\"' : { - int start; - sym = constsym; - constkind = stringtype; - NextCh(); - start = chcount; - while ((ch != '\"') && (ch != 0x0)) + if (ch == '=') { + opkind = OPlessequal; + NextCh(); + } else { + opkind = OPless; + } + break; + case '\"' : { + int start; + sym = constsym; + constkind = stringtype; NextCh(); - GrabRealString(start); - TermChar('\"'); // check for eol before '\"' - break; - } - case 0x0: sym = eolsym; break; - default: + start = chcount; + while ((ch != '\"') && (ch != 0x0)) + NextCh(); + GrabRealString(start); + TermChar('\"'); // check for eol before '\"' + break; + } + case 0x0: sym = eolsym; break; + default: { int start; start = chcount; @@ -301,7 +301,7 @@ void CParser::NextSym() } GrabString(start); } else if (((ch >= 'a') && (ch <= 'z')) - || ((ch >= 'A') && (ch <= 'Z'))) + || ((ch >= 'A') && (ch <= 'Z'))) { // reserved word? start = chcount; @@ -358,18 +358,18 @@ STR_String CParser::Symbol2Str(int s) { // returns a string representation of of symbol s, // for use in Term when generating an error switch(s) { - case errorsym: return "error"; - case lbracksym: return "("; - case rbracksym: return ")"; - case commasym: return ","; - case opsym: return "operator"; - case constsym: return "constant"; - case sumsym: return "SUM"; - case ifsym: return "IF"; - case whocodedsym: return "WHOMADE"; - case eolsym: return "end of line"; - case idsym: return "identifier"; - default: return "unknown"; // should not happen + case errorsym: return "error"; + case lbracksym: return "("; + case rbracksym: return ")"; + case commasym: return ","; + case opsym: return "operator"; + case constsym: return "constant"; + case sumsym: return "SUM"; + case ifsym: return "IF"; + case whocodedsym: return "WHOMADE"; + case eolsym: return "end of line"; + case idsym: return "identifier"; + default: return "unknown"; // should not happen } } @@ -391,19 +391,19 @@ int CParser::Priority(int optorkind) { // returns the priority of an operator // higher number means higher priority switch(optorkind) { - case OPor: return 1; - case OPand: return 2; - case OPgreater: - case OPless: - case OPgreaterequal: - case OPlessequal: - case OPequal: - case OPunequal: return 3; - case OPplus: - case OPminus: return 4; - case OPmodulus: - case OPtimes: - case OPdivide: return 5; + case OPor: return 1; + case OPand: return 2; + case OPgreater: + case OPless: + case OPgreaterequal: + case OPlessequal: + case OPequal: + case OPunequal: return 3; + case OPplus: + case OPminus: return 4; + case OPmodulus: + case OPtimes: + case OPdivide: return 5; } MT_assert(false); return 0; // should not happen diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp index c270d9a312b..7c1824cd4eb 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp @@ -40,20 +40,20 @@ SCA_2DFilterActuator::~SCA_2DFilterActuator() } SCA_2DFilterActuator::SCA_2DFilterActuator( - SCA_IObject *gameobj, + SCA_IObject *gameobj, RAS_2DFilterManager::RAS_2DFILTER_MODE type, - short flag, - float float_arg, - int int_arg, - RAS_IRasterizer* rasterizer, - SCA_IScene* scene) + short flag, + float float_arg, + int int_arg, + RAS_IRasterizer* rasterizer, + SCA_IScene* scene) : SCA_IActuator(gameobj, KX_ACT_2DFILTER), - m_type(type), - m_disableMotionBlur(flag), - m_float_arg(float_arg), - m_int_arg(int_arg), - m_rasterizer(rasterizer), - m_scene(scene) + m_type(type), + m_disableMotionBlur(flag), + m_float_arg(float_arg), + m_int_arg(int_arg), + m_rasterizer(rasterizer), + m_scene(scene) { m_gameobj = NULL; if(gameobj){ @@ -65,9 +65,9 @@ SCA_2DFilterActuator::SCA_2DFilterActuator( CValue* SCA_2DFilterActuator::GetReplica() { - SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this); - replica->ProcessReplica(); - return replica; + SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this); + replica->ProcessReplica(); + return replica; } @@ -94,7 +94,7 @@ bool SCA_2DFilterActuator::Update() m_scene->Update2DFilter(m_propNames, m_gameobj, m_type, m_int_arg, m_shaderText); } // once the filter is in place, no need to update it again => disable the actuator - return false; + return false; } diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 0d09e33a81b..85982bd3c0f 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -216,8 +216,8 @@ void SCA_ISensor::UnregisterToManager() void SCA_ISensor::ActivateControllers(class SCA_LogicManager* logicmgr) { - for(vector::const_iterator c= m_linkedcontrollers.begin(); - c!=m_linkedcontrollers.end();++c) + for(vector::const_iterator c= m_linkedcontrollers.begin(); + c!=m_linkedcontrollers.end();++c) { SCA_IController* contr = *c; if (contr->IsActive()) diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 513be43ec28..a2374ccb9da 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -132,7 +132,7 @@ bool SCA_KeyboardSensor::Evaluate() // cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n"; /* See if we need to do logging: togPropState exists and is - * different from 0 */ + * different from 0 */ CValue* myparent = GetParent(); CValue* togPropState = myparent->GetProperty(m_toggleprop); if (togPropState && @@ -400,7 +400,7 @@ void SCA_KeyboardSensor::LogKeystrokes(void) int index = 0; /* Check on all keys whether they were pushed. This does not - * untangle the ordering, so don't type too fast :) */ + * untangle the ordering, so don't type too fast :) */ for (int i=SCA_IInputDevice::KX_BEGINKEY ; i<= SCA_IInputDevice::KX_ENDKEY;i++) { const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i); diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp index a1836163e9c..93d2ae2c1c5 100644 --- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp +++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp @@ -50,12 +50,12 @@ /* ------------------------------------------------------------------------- */ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr, - int startx,int starty, - short int mousemode, - SCA_IObject* gameobj) + int startx,int starty, + short int mousemode, + SCA_IObject* gameobj) : SCA_ISensor(gameobj,eventmgr), - m_x(startx), - m_y(starty) + m_x(startx), + m_y(starty) { m_mousemode = mousemode; m_triggermode = true; @@ -72,7 +72,7 @@ void SCA_MouseSensor::Init() SCA_MouseSensor::~SCA_MouseSensor() { - /* Nothing to be done here. */ + /* Nothing to be done here. */ } void SCA_MouseSensor::UpdateHotkey(void *self) diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp index 06c24c8211b..67af6237a8d 100644 --- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.cpp @@ -68,12 +68,12 @@ SCA_RandomNumberGenerator::~SCA_RandomNumberGenerator() { void SCA_RandomNumberGenerator::SetStartVector(void) { /* setting initial seeds to mt[N] using */ - /* the generator Line 25 of Table 1 in */ - /* [KNUTH 1981, The Art of Computer Programming */ - /* Vol. 2 (2nd Ed.), pp102] */ - mt[0] = m_seed & 0xffffffff; - for (mti = 1; mti < N; mti++) - mt[mti] = (69069 * mt[mti-1]) & 0xffffffff; + /* the generator Line 25 of Table 1 in */ + /* [KNUTH 1981, The Art of Computer Programming */ + /* Vol. 2 (2nd Ed.), pp102] */ + mt[0] = m_seed & 0xffffffff; + for (mti = 1; mti < N; mti++) + mt[mti] = (69069 * mt[mti-1]) & 0xffffffff; } long SCA_RandomNumberGenerator::GetSeed() { return m_seed; } @@ -87,39 +87,39 @@ void SCA_RandomNumberGenerator::SetSeed(long newseed) * This is the important part: copied verbatim :) */ unsigned long SCA_RandomNumberGenerator::Draw() { - static unsigned long mag01[2] = { 0x0, MATRIX_A }; - /* mag01[x] = x * MATRIX_A for x=0,1 */ - - unsigned long y; - - if (mti >= N) { /* generate N words at one time */ - int kk; - - /* I set this in the constructor, so it is always satisfied ! */ -// if (mti == N+1) /* if sgenrand() has not been called, */ -// GEN_srand(4357); /* a default initial seed is used */ - - for (kk = 0; kk < N - M; kk++) { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1]; - } - for (; kk < N-1; kk++) { - y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); - mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1]; - } - y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1]; - - mti = 0; - } - - y = mt[mti++]; - y ^= TEMPERING_SHIFT_U(y); - y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; - y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; - y ^= TEMPERING_SHIFT_L(y); - - return y; + static unsigned long mag01[2] = { 0x0, MATRIX_A }; + /* mag01[x] = x * MATRIX_A for x=0,1 */ + + unsigned long y; + + if (mti >= N) { /* generate N words at one time */ + int kk; + + /* I set this in the constructor, so it is always satisfied ! */ + // if (mti == N+1) /* if sgenrand() has not been called, */ + // GEN_srand(4357); /* a default initial seed is used */ + + for (kk = 0; kk < N - M; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); + mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1]; + } + for (; kk < N-1; kk++) { + y = (mt[kk] & UPPER_MASK) | (mt[kk+1] & LOWER_MASK); + mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1]; + } + y = (mt[N-1] & UPPER_MASK) | (mt[0] & LOWER_MASK); + mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= TEMPERING_SHIFT_U(y); + y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; + y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; + y ^= TEMPERING_SHIFT_L(y); + + return y; } float SCA_RandomNumberGenerator::DrawFloat() { diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 99e25042582..c23722d2d3c 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -48,8 +48,8 @@ /* ------------------------------------------------------------------------- */ SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr, - SCA_IObject* gameobj, - int startseed) + SCA_IObject* gameobj, + int startseed) : SCA_ISensor(gameobj,eventmgr) { m_basegenerator = new SCA_RandomNumberGenerator(startseed); @@ -65,10 +65,10 @@ SCA_RandomSensor::~SCA_RandomSensor() void SCA_RandomSensor::Init() { - m_iteration = 0; + m_iteration = 0; m_interval = 0; m_lastdraw = false; - m_currentDraw = m_basegenerator->Draw(); + m_currentDraw = m_basegenerator->Draw(); } @@ -97,19 +97,19 @@ bool SCA_RandomSensor::IsPositiveTrigger() bool SCA_RandomSensor::Evaluate() { - /* Random generator is the generator from Line 25 of Table 1 in */ - /* [KNUTH 1981, The Art of Computer Programming Vol. 2 */ - /* (2nd Ed.), pp102] */ - /* It's a very simple max. length sequence generator. We can */ - /* draw 32 bool values before having to generate the next */ - /* sequence value. There are some theorems that will tell you */ - /* this is a reasonable way of generating bools. Check Knuth. */ - /* Furthermore, we only draw each -eth frame. */ + /* Random generator is the generator from Line 25 of Table 1 in */ + /* [KNUTH 1981, The Art of Computer Programming Vol. 2 */ + /* (2nd Ed.), pp102] */ + /* It's a very simple max. length sequence generator. We can */ + /* draw 32 bool values before having to generate the next */ + /* sequence value. There are some theorems that will tell you */ + /* this is a reasonable way of generating bools. Check Knuth. */ + /* Furthermore, we only draw each -eth frame. */ bool evaluateResult = false; if (++m_interval > m_pulse_frequency) { - bool drawResult = false; + bool drawResult = false; m_interval = 0; if (m_iteration > 31) { m_currentDraw = m_basegenerator->Draw(); @@ -122,8 +122,8 @@ bool SCA_RandomSensor::Evaluate() evaluateResult = drawResult != m_lastdraw; m_lastdraw = drawResult; } - - /* now pass this result to some controller */ + + /* now pass this result to some controller */ return evaluateResult; } diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp index f5eefd5cc08..4a03062b6ad 100644 --- a/source/gameengine/GameLogic/SCA_XORController.cpp +++ b/source/gameengine/GameLogic/SCA_XORController.cpp @@ -63,22 +63,22 @@ void SCA_XORController::Trigger(SCA_LogicManager* logicmgr) bool sensorresult = false; for (vector::const_iterator is=m_linkedsensors.begin(); - !(is==m_linkedsensors.end());is++) + !(is==m_linkedsensors.end());is++) { SCA_ISensor* sensor = *is; if (sensor->GetState()) { if (sensorresult == true) { - sensorresult = false; + sensorresult = false; break; } - sensorresult = true; + sensorresult = true; } } for (vector::const_iterator i=m_linkedactuators.begin(); - !(i==m_linkedactuators.end());i++) + !(i==m_linkedactuators.end());i++) { SCA_IActuator* actua = *i; logicmgr->AddActiveActuator(actua,sensorresult); diff --git a/source/gameengine/GamePlayer/common/bmfont.cpp b/source/gameengine/GamePlayer/common/bmfont.cpp index e3b900173d9..ecb2c4f3bd1 100644 --- a/source/gameengine/GamePlayer/common/bmfont.cpp +++ b/source/gameengine/GamePlayer/common/bmfont.cpp @@ -190,7 +190,7 @@ void detectBitmapFont(ImBuf *ibuf) long i; if (ibuf != NULL) { - // bitmap must have an x size that is a power of two + // bitmap must have an x size that is a power of two if (is_power_of_two(ibuf->x)) { rect = (unsigned char *) (ibuf->rect + (ibuf->x * (ibuf->y - 1))); // printf ("starts with: %s %c %c %c %c\n", rect, rect[0], rect[1], rect[2], rect[3]); diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 546ec69bf29..c5daae9c963 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -139,7 +139,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) GPG_Application::~GPG_Application(void) { - if(m_pyGlobalDictString) { + if(m_pyGlobalDictString) { delete [] m_pyGlobalDictString; m_pyGlobalDictString = 0; m_pyGlobalDictString_Length = 0; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index cbbeb9419d1..3f8bcf9e2ad 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -380,12 +380,12 @@ int main(int argc, char** argv) #endif /* __linux__ */ BLI_where_am_i(bprogname, sizeof(bprogname), argv[0]); #ifdef __APPLE__ - // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) - /* - IBNibRef nibRef; - WindowRef window; - OSStatus err; - + // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh) + /* + IBNibRef nibRef; + WindowRef window; + OSStatus err; + // Create a Nib reference passing the name of the nib file (without the .nib extension) // CreateNibReference only searches into the application bundle. err = ::CreateNibReference(CFSTR("main"), &nibRef); @@ -398,7 +398,7 @@ int main(int argc, char** argv) // We don't need the nib reference anymore. ::DisposeNibReference(nibRef); - */ + */ #endif // __APPLE__ // We don't use threads directly in the BGE, but we need to call this so things like @@ -421,7 +421,7 @@ int main(int argc, char** argv) BLF_init(11, U.dpi); BLF_lang_init(); BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); - + // Parse command line options #if defined(DEBUG) printf("argv[0] = '%s'\n", argv[0]); diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 91982a424c7..4ae937cdcd6 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -63,7 +63,7 @@ int BL_BlenderShader::GetAttribNum() GPU_material_vertex_attributes(mGPUMat, &attribs); - for(i = 0; i < attribs.totlayer; i++) + for(i = 0; i < attribs.totlayer; i++) if(attribs.layer[i].glindex+1 > enabled) enabled= attribs.layer[i].glindex+1; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp index e8e65371d3a..72f1cee8855 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp @@ -66,8 +66,8 @@ void KX_NetworkEventManager::NextFrame() for (it.begin();!it.end();++it) { // printf("KX_NetworkEventManager::proceed sensor %.2f\n", curtime); - // process queue - (*it)->Activate(m_logicmgr); + // process queue + (*it)->Activate(m_logicmgr); } // now a list of triggerer sensors has been built diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp index 2e0abc0290c..9fd09506c0d 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp @@ -91,8 +91,7 @@ bool KX_NetworkMessageActuator::Update() CValue* KX_NetworkMessageActuator::GetReplica() { - KX_NetworkMessageActuator* replica = - new KX_NetworkMessageActuator(*this); + KX_NetworkMessageActuator* replica = new KX_NetworkMessageActuator(*this); replica->ProcessReplica(); return replica; diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp index 6dcf50fa18f..a795a4eddc6 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp @@ -50,11 +50,11 @@ #endif KX_NetworkMessageSensor::KX_NetworkMessageSensor( - class KX_NetworkEventManager* eventmgr, // our eventmanager - class NG_NetworkScene *NetworkScene, // our scene - SCA_IObject* gameobj, // the sensor controlling object - const STR_String &subject -) : + class KX_NetworkEventManager* eventmgr, // our eventmanager + class NG_NetworkScene *NetworkScene, // our scene + SCA_IObject* gameobj, // the sensor controlling object + const STR_String &subject + ) : SCA_ISensor(gameobj,eventmgr), m_NetworkScene(NetworkScene), m_subject(subject), @@ -67,7 +67,7 @@ KX_NetworkMessageSensor::KX_NetworkMessageSensor( void KX_NetworkMessageSensor::Init() { - m_IsUp = false; + m_IsUp = false; } KX_NetworkMessageSensor::~KX_NetworkMessageSensor() diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 4226896aec0..33da17cc505 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -56,21 +56,21 @@ KX_BlenderMaterial::KX_BlenderMaterial() } void KX_BlenderMaterial::Initialize( - KX_Scene *scene, - BL_Material *data) + KX_Scene *scene, + BL_Material *data) { RAS_IPolyMaterial::Initialize( - data->texname[0], - data->matname, - data->materialindex, - data->tile, - data->tilexrep[0], - data->tileyrep[0], - data->mode, - data->transp, - ((data->ras_mode &ALPHA)!=0), - ((data->ras_mode &ZSORT)!=0) - ); + data->texname[0], + data->matname, + data->materialindex, + data->tile, + data->tilexrep[0], + data->tileyrep[0], + data->mode, + data->transp, + ((data->ras_mode &ALPHA)!=0), + ((data->ras_mode &ZSORT)!=0) + ); mMaterial = data; mShader = 0; mBlenderShader = 0; @@ -80,7 +80,7 @@ void KX_BlenderMaterial::Initialize( mConstructed = false; mPass = 0; // -------------------------------- - // RAS_IPolyMaterial variables... + // RAS_IPolyMaterial variables... m_flag |= RAS_BLENDERMAT; m_flag |= (mMaterial->IdMode>=ONETEX)? RAS_MULTITEX: 0; m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0; @@ -93,14 +93,11 @@ void KX_BlenderMaterial::Initialize( mMaterial->num_enabled = enabled>=max?max:enabled; // test the sum of the various modes for equality - // so we can ether accept or reject this material - // as being equal, this is rather important to + // so we can ether accept or reject this material + // as being equal, this is rather important to // prevent material bleeding for(int i=0; inum_enabled; i++) { - m_multimode += - ( mMaterial->flag[i] + - mMaterial->blend_mode[i] - ); + m_multimode += (mMaterial->flag[i] + mMaterial->blend_mode[i]); } m_multimode += mMaterial->IdMode+ (mMaterial->ras_mode & ~(COLLIDER|USE_LIGHT)); } diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp index fde01961fd5..6e5513991f9 100644 --- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp +++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp @@ -213,16 +213,16 @@ MT_Scalar KX_BulletPhysicsController::GetMass() MT_Vector3 KX_BulletPhysicsController::GetLocalInertia() { - MT_Vector3 inertia(0.f, 0.f, 0.f); - btVector3 inv_inertia; - if (GetRigidBody()) { - inv_inertia = GetRigidBody()->getInvInertiaDiagLocal(); - if (!btFuzzyZero(inv_inertia.getX()) && - !btFuzzyZero(inv_inertia.getY()) && - !btFuzzyZero(inv_inertia.getZ())) + MT_Vector3 inertia(0.f, 0.f, 0.f); + btVector3 inv_inertia; + if (GetRigidBody()) { + inv_inertia = GetRigidBody()->getInvInertiaDiagLocal(); + if (!btFuzzyZero(inv_inertia.getX()) && + !btFuzzyZero(inv_inertia.getY()) && + !btFuzzyZero(inv_inertia.getZ())) inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ()); - } - return inertia; + } + return inertia; } MT_Vector3 KX_BulletPhysicsController::getReactionForce() diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index c60c931c33b..a488d646792 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -271,18 +271,18 @@ void KX_Camera::ExtractFrustumSphere() if (m_set_frustum_center) return; - // compute sphere for the general case and not only symmetric frustum: - // the mirror code in ImageRender can use very asymmetric frustum. - // We will put the sphere center on the line that goes from origin to the center of the far clipping plane - // This is the optimal position if the frustum is symmetric or very asymmetric and probably close - // to optimal for the general case. The sphere center position is computed so that the distance to - // the near and far extreme frustum points are equal. - - // get the transformation matrix from device coordinate to camera coordinate + // compute sphere for the general case and not only symmetric frustum: + // the mirror code in ImageRender can use very asymmetric frustum. + // We will put the sphere center on the line that goes from origin to the center of the far clipping plane + // This is the optimal position if the frustum is symmetric or very asymmetric and probably close + // to optimal for the general case. The sphere center position is computed so that the distance to + // the near and far extreme frustum points are equal. + + // get the transformation matrix from device coordinate to camera coordinate MT_Matrix4x4 clip_camcs_matrix = m_projection_matrix; clip_camcs_matrix.invert(); - if (m_projection_matrix[3][3] == MT_Scalar(0.0)) + if (m_projection_matrix[3][3] == MT_Scalar(0.0)) { // frustrum projection // detect which of the corner of the far clipping plane is the farthest to the origin @@ -302,7 +302,7 @@ void KX_Camera::ExtractFrustumSphere() MT_Scalar len; for (int i=0; i<4; i++) { - hpoint = clip_camcs_matrix*npoint; + hpoint = clip_camcs_matrix*npoint; point.setValue(hpoint[0]/hpoint[3], hpoint[1]/hpoint[3], hpoint[2]/hpoint[3]); len = point.dot(point); if (len > F) @@ -321,7 +321,7 @@ void KX_Camera::ExtractFrustumSphere() farcenter *= 0.25; // the extreme near point is the opposite point on the near clipping plane nfar.setValue(-nfar[0], -nfar[1], -1., 1.); - nfar = clip_camcs_matrix*nfar; + nfar = clip_camcs_matrix*nfar; nearpoint.setValue(nfar[0]/nfar[3], nfar[1]/nfar[3], nfar[2]/nfar[3]); // this is a frustrum projection N = nearpoint.dot(nearpoint); @@ -340,7 +340,7 @@ void KX_Camera::ExtractFrustumSphere() z = (F-N)/(2.0*(e-s+c*(f-n))); m_frustum_center = MT_Point3(farcenter[0]*z/e, farcenter[1]*z/e, z); m_frustum_radius = m_frustum_center.distance(farpoint); - } + } else { // orthographic projection diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 2e1fb933ad0..00c5e5803a8 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -42,34 +42,34 @@ Developed as part of a Research and Development project for SAT - La Société d // constructor KX_Dome::KX_Dome ( - RAS_ICanvas* canvas, - /// rasterizer - RAS_IRasterizer* rasterizer, - /// render tools - RAS_IRenderTools* rendertools, - /// engine - KX_KetsjiEngine* engine, - - short res, //resolution of the mesh - short mode, //mode - fisheye, truncated, warped, panoramic, ... - short angle, - float resbuf, //size adjustment of the buffer - short tilt, - struct Text* warptext - -): - dlistSupported(false), - canvaswidth(-1), canvasheight(-1), - m_drawingmode(engine->GetDrawType()), - m_resolution(res), - m_mode(mode), - m_angle(angle), - m_resbuffer(resbuf), - m_tilt(tilt), - m_canvas(canvas), - m_rasterizer(rasterizer), - m_rendertools(rendertools), - m_engine(engine) + RAS_ICanvas* canvas, + /// rasterizer + RAS_IRasterizer* rasterizer, + /// render tools + RAS_IRenderTools* rendertools, + /// engine + KX_KetsjiEngine* engine, + + short res, //resolution of the mesh + short mode, //mode - fisheye, truncated, warped, panoramic, ... + short angle, + float resbuf, //size adjustment of the buffer + short tilt, + struct Text* warptext + + ): + dlistSupported(false), + canvaswidth(-1), canvasheight(-1), + m_drawingmode(engine->GetDrawType()), + m_resolution(res), + m_mode(mode), + m_angle(angle), + m_resbuffer(resbuf), + m_tilt(tilt), + m_canvas(canvas), + m_rasterizer(rasterizer), + m_rendertools(rendertools), + m_engine(engine) { warp.usemesh = false; fboSupported = false; @@ -1984,9 +1984,9 @@ void KX_Dome::DrawDomeWarped(void) int can_width = m_viewport.GetRight(); int can_height = m_viewport.GetTop(); - double screen_ratio = can_width/ (double) can_height; + double screen_ratio = can_width/ (double) can_height; - glOrtho(-screen_ratio,screen_ratio,-1.0,1.0,-20.0,10.0); + glOrtho(-screen_ratio,screen_ratio,-1.0,1.0,-20.0,10.0); glMatrixMode(GL_TEXTURE); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 7ced0c0c4d7..67178803457 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -87,32 +87,32 @@ typedef unsigned long uint_ptr; static MT_Point3 dummy_point= MT_Point3(0.0, 0.0, 0.0); static MT_Vector3 dummy_scaling = MT_Vector3(1.0, 1.0, 1.0); -static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3( 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0); +static MT_Matrix3x3 dummy_orientation = MT_Matrix3x3(1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0); KX_GameObject::KX_GameObject( - void* sgReplicationInfo, - SG_Callbacks callbacks) - : SCA_IObject(), - m_bDyna(false), - m_layer(0), - m_pBlenderObject(NULL), - m_pBlenderGroupObject(NULL), - m_bSuspendDynamics(false), - m_bUseObjectColor(false), - m_bIsNegativeScaling(false), - m_bVisible(true), - m_bCulled(true), - m_bOccluder(false), - m_pPhysicsController1(NULL), - m_pGraphicController(NULL), - m_xray(false), - m_pHitObject(NULL), - m_actionManager(NULL), - m_isDeformable(false) -#ifdef WITH_PYTHON - , m_attr_dict(NULL) + void* sgReplicationInfo, + SG_Callbacks callbacks) + : SCA_IObject(), + m_bDyna(false), + m_layer(0), + m_pBlenderObject(NULL), + m_pBlenderGroupObject(NULL), + m_bSuspendDynamics(false), + m_bUseObjectColor(false), + m_bIsNegativeScaling(false), + m_bVisible(true), + m_bCulled(true), + m_bOccluder(false), + m_pPhysicsController1(NULL), + m_pGraphicController(NULL), + m_xray(false), + m_pHitObject(NULL), + m_actionManager(NULL), + m_isDeformable(false) + #ifdef WITH_PYTHON + , m_attr_dict(NULL) #endif { m_ignore_activity_culling = false; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index b1a214b7c1c..878232f7a50 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -116,7 +116,7 @@ bool KX_KetsjiEngine::m_restrict_anim_fps = false; * Constructor of the Ketsji Engine */ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) - : m_canvas(NULL), + : m_canvas(NULL), m_rasterizer(NULL), m_kxsystem(system), m_rendertools(NULL), diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 3f09eee013e..2f2c45cd5cc 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -355,11 +355,11 @@ PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUT } else if (!strcmp(type, "NORMAL")) { retvalue = PyLong_FromSsize_t(RAS_LightObject::LIGHT_NORMAL); } - else { - /* should never happen */ - PyErr_SetString(PyExc_TypeError, "light.type: internal error, invalid light type"); - retvalue = NULL; - } + else { + /* should never happen */ + PyErr_SetString(PyExc_TypeError, "light.type: internal error, invalid light type"); + retvalue = NULL; + } return retvalue; } diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index ba41dc355f7..9ad09f9793b 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -119,7 +119,7 @@ CValue* KX_MeshProxy::GetReplica() { return NULL;} PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds) { - int matid= 1; + int matid= 1; STR_String matname; if (PyArg_ParseTuple(args,"i:getMaterialName",&matid)) @@ -131,13 +131,13 @@ PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* args, PyObject* kwds) } return PyUnicode_FromString(matname.Ptr()); - + } - + PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds) { - int matid= 1; + int matid= 1; STR_String matname; if (PyArg_ParseTuple(args,"i:getTextureName",&matid)) @@ -154,7 +154,7 @@ PyObject* KX_MeshProxy::PyGetTextureName(PyObject* args, PyObject* kwds) PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* args, PyObject* kwds) { - int matid= 0; + int matid= 0; int length = 0; @@ -177,7 +177,7 @@ PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* args, PyObject* kwds) PyObject* KX_MeshProxy::PyGetVertex(PyObject* args, PyObject* kwds) { - int vertexindex; + int vertexindex; int matindex; if (!PyArg_ParseTuple(args,"ii:getVertex",&matindex,&vertexindex)) @@ -195,7 +195,7 @@ PyObject* KX_MeshProxy::PyGetVertex(PyObject* args, PyObject* kwds) PyObject* KX_MeshProxy::PyGetPolygon(PyObject* args, PyObject* kwds) { - int polyindex= 1; + int polyindex= 1; PyObject* polyob = NULL; if (!PyArg_ParseTuple(args,"i:getPolygon",&polyindex)) diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index 6cb80028858..34f5c26415d 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -121,14 +121,14 @@ bool KX_MouseFocusSensor::Evaluate() } } if (reset) { - // force an event + // force an event result = true; } } else { /* No focus behaviour required: revert to the basic mode. This - * mode is never used, because the converter never makes this - * sensor for a mouse-key event. It is here for - * completeness. */ + * mode is never used, because the converter never makes this + * sensor for a mouse-key event. It is here for + * completeness. */ result = SCA_MouseSensor::Evaluate(); m_positive_event = (m_val!=0); } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 8557ebab0a9..395e2048cb7 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -389,10 +389,10 @@ static PyObject* gPyGetSpectrum(PyObject*) { PyObject* resultlist = PyList_New(512); - for (int index = 0; index < 512; index++) - { - PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0)); - } + for (int index = 0; index < 512; index++) + { + PyList_SET_ITEM(resultlist, index, PyFloat_FromDouble(0.0)); + } return resultlist; } @@ -479,13 +479,13 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) char cpath[sizeof(gp_GamePythonPath)]; char *searchpath = NULL; PyObject* list, *value; - - DIR *dp; - struct dirent *dirp; - + + DIR *dp; + struct dirent *dirp; + if (!PyArg_ParseTuple(args, "|s:getBlendFileList", &searchpath)) return NULL; - + list = PyList_New(0); if (searchpath) { @@ -495,23 +495,23 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) /* Get the dir only */ BLI_split_dirfile(gp_GamePythonPath, cpath, NULL); } - - if((dp = opendir(cpath)) == NULL) { + + if((dp = opendir(cpath)) == NULL) { /* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */ fprintf(stderr, "Could not read directoty (%s) failed, code %d (%s)\n", cpath, errno, strerror(errno)); return list; - } + } - while ((dirp = readdir(dp)) != NULL) { + while ((dirp = readdir(dp)) != NULL) { if (BLI_testextensie(dirp->d_name, ".blend")) { value= PyUnicode_DecodeFSDefault(dirp->d_name); PyList_Append(list, value); Py_DECREF(value); } - } + } - closedir(dp); - return list; + closedir(dp); + return list; } static char gPyAddScene_doc[] = @@ -1662,9 +1662,9 @@ PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack // Check for errors if (PyErr_Occurred()) - { + { Py_FatalError("can't initialize module bge.logic"); - } + } return m; } @@ -1954,12 +1954,12 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) gp_Rasterizer = rasty; - PyObject* m; - PyObject* d; - PyObject* item; + PyObject* m; + PyObject* d; + PyObject* item; /* Use existing module where possible - * be careful not to init any runtime vars after this */ + * be careful not to init any runtime vars after this */ m = PyImport_ImportModule( "Rasterizer" ); if(m) { Py_DECREF(m); @@ -1967,32 +1967,32 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas) } else { PyErr_Clear(); - + // Create the module and add the functions m = PyModule_Create(&Rasterizer_module_def); PyDict_SetItemString(PySys_GetObject("modules"), Rasterizer_module_def.m_name, m); } - // Add some symbolic constants to the module - d = PyModule_GetDict(m); - ErrorObject = PyUnicode_FromString("Rasterizer.error"); - PyDict_SetItemString(d, "error", ErrorObject); - Py_DECREF(ErrorObject); + // Add some symbolic constants to the module + d = PyModule_GetDict(m); + ErrorObject = PyUnicode_FromString("Rasterizer.error"); + PyDict_SetItemString(d, "error", ErrorObject); + Py_DECREF(ErrorObject); - /* needed for get/setMaterialType */ - KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL); - KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL); - KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL); + /* needed for get/setMaterialType */ + KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL); + KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL); + KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL); - // XXXX Add constants here + // XXXX Add constants here - // Check for errors - if (PyErr_Occurred()) - { - Py_FatalError("can't initialize module Rasterizer"); - } + // Check for errors + if (PyErr_Occurred()) + { + Py_FatalError("can't initialize module Rasterizer"); + } - return d; + return d; } @@ -2231,9 +2231,9 @@ PyObject* initGameKeys() // Check for errors if (PyErr_Occurred()) - { + { Py_FatalError("can't initialize module GameKeys"); - } + } return d; } diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp index a683c9857aa..aecf2ab3598 100644 --- a/source/gameengine/Ketsji/KX_RaySensor.cpp +++ b/source/gameengine/Ketsji/KX_RaySensor.cpp @@ -83,7 +83,7 @@ void KX_RaySensor::Init() KX_RaySensor::~KX_RaySensor() { - /* Nothing to be done here. */ + /* Nothing to be done here. */ } @@ -279,7 +279,7 @@ bool KX_RaySensor::Evaluate() /* now pass this result to some controller */ - if (m_rayHit) + if (m_rayHit) { if (!m_bTriggered) { @@ -288,14 +288,14 @@ bool KX_RaySensor::Evaluate() m_bTriggered = true; } else - { + { // notify logicsystem that ray is STILL hitting ... result = false; - - } + + } } - else - { + else + { if (m_bTriggered) { m_bTriggered = false; @@ -306,9 +306,9 @@ bool KX_RaySensor::Evaluate() { result = false; } - - } - if (reset) + + } + if (reset) // force an event result = true; diff --git a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp index 076669e325a..c5f3fefd4d3 100644 --- a/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_EndObjectActuator.cpp @@ -44,11 +44,11 @@ #include "SCA_IScene.h" KX_SCA_EndObjectActuator::KX_SCA_EndObjectActuator(SCA_IObject *gameobj, - SCA_IScene* scene): - SCA_IActuator(gameobj, KX_ACT_END_OBJECT), - m_scene(scene) + SCA_IScene* scene): + SCA_IActuator(gameobj, KX_ACT_END_OBJECT), + m_scene(scene) { - // intentionally empty + // intentionally empty } /* End of constructor */ diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index edcba969811..f13f152c5d5 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -54,16 +54,16 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj, - SCA_IObject *ob, - int time, - bool allow3D, - int trackflag, - int upflag) - : SCA_IActuator(gameobj, KX_ACT_TRACKTO) + SCA_IObject *ob, + int time, + bool allow3D, + int trackflag, + int upflag) + : SCA_IActuator(gameobj, KX_ACT_TRACKTO) { - m_time = time; - m_allow3D = allow3D; - m_object = ob; + m_time = time; + m_allow3D = allow3D; + m_object = ob; m_trackflag = trackflag; m_upflag = upflag; m_parentobj = 0; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 3f0c4cb95a1..526176481ed 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1200,7 +1200,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallbac // Bullet returns the normal from "outside". // If the user requests the real normal, compute it now - if (filterCallback.m_faceNormal) + if (filterCallback.m_faceNormal) { if (shape->isSoftBody()) { diff --git a/source/gameengine/SceneGraph/SG_BBox.cpp b/source/gameengine/SceneGraph/SG_BBox.cpp index b5618ebbf03..01107557481 100644 --- a/source/gameengine/SceneGraph/SG_BBox.cpp +++ b/source/gameengine/SceneGraph/SG_BBox.cpp @@ -142,8 +142,8 @@ SG_BBox SG_BBox::transform(const MT_Transform &world) const bool SG_BBox::inside(const MT_Point3 &point) const { return point[0] >= m_min[0] && point[0] <= m_max[0] && - point[1] >= m_min[1] && point[1] <= m_max[1] && - point[2] >= m_min[2] && point[2] <= m_max[2]; + point[1] >= m_min[1] && point[1] <= m_max[1] && + point[2] >= m_min[2] && point[2] <= m_max[2]; } bool SG_BBox::inside(const SG_BBox& other) const diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index ca778d164c8..94b8584051e 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -109,18 +109,17 @@ SetParentRelation( */ - bool + bool SG_Spatial:: UpdateSpatialData( - const SG_Spatial *parent, - double time, - bool& parentUpdated + const SG_Spatial *parent, + double time, + bool& parentUpdated ){ - - bool bComputesWorldTransform = false; + bool bComputesWorldTransform = false; // update spatial controllers - + SGControllerList::iterator cit = GetSGControllerList().begin(); SGControllerList::const_iterator c_end = GetSGControllerList().end(); @@ -131,7 +130,7 @@ UpdateSpatialData( } // If none of the objects updated our values then we ask the - // parent_relation object owned by this class to update + // parent_relation object owned by this class to update // our world coordinates. if (!bComputesWorldTransform) diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp index fc316f1c3f0..30a8af4b125 100644 --- a/source/gameengine/VideoTexture/Exception.cpp +++ b/source/gameengine/VideoTexture/Exception.cpp @@ -201,20 +201,20 @@ void Exception::copy (const Exception & xpt) void registerAllExceptions(void) { - errGenerDesc.registerDesc(); - errNFoundDesc.registerDesc(); - MaterialNotAvailDesc.registerDesc(); - ImageSizesNotMatchDesc.registerDesc(); - ImageHasExportsDesc.registerDesc(); + errGenerDesc.registerDesc(); + errNFoundDesc.registerDesc(); + MaterialNotAvailDesc.registerDesc(); + ImageSizesNotMatchDesc.registerDesc(); + ImageHasExportsDesc.registerDesc(); InvalidColorChannelDesc.registerDesc(); - SceneInvalidDesc.registerDesc(); - CameraInvalidDesc.registerDesc(); - ObserverInvalidDesc.registerDesc(); - MirrorInvalidDesc.registerDesc(); - MirrorSizeInvalidDesc.registerDesc(); - MirrorNormalInvalidDesc.registerDesc(); - MirrorHorizontalDesc.registerDesc(); - MirrorTooSmallDesc.registerDesc(); - SourceVideoEmptyDesc.registerDesc(); - SourceVideoCreationDesc.registerDesc(); + SceneInvalidDesc.registerDesc(); + CameraInvalidDesc.registerDesc(); + ObserverInvalidDesc.registerDesc(); + MirrorInvalidDesc.registerDesc(); + MirrorSizeInvalidDesc.registerDesc(); + MirrorNormalInvalidDesc.registerDesc(); + MirrorHorizontalDesc.registerDesc(); + MirrorTooSmallDesc.registerDesc(); + SourceVideoEmptyDesc.registerDesc(); + SourceVideoCreationDesc.registerDesc(); } diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index a70c56a070c..86de214e2d3 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -645,7 +645,7 @@ PyObject * Image_valid(PyImage * self, void * closure) int Image_getbuffer(PyImage *self, Py_buffer *view, int flags) { unsigned int * image; - int ret; + int ret; try { @@ -667,25 +667,25 @@ int Image_getbuffer(PyImage *self, Py_buffer *view, int flags) //return -1; goto error; } - if (view == NULL) + if (view == NULL) { - self->m_image->m_exports++; - return 0; - } - ret = PyBuffer_FillInfo(view, (PyObject*)self, image, self->m_image->getBuffSize(), 0, flags); - if (ret >= 0) - self->m_image->m_exports++; - return ret; + self->m_image->m_exports++; + return 0; + } + ret = PyBuffer_FillInfo(view, (PyObject*)self, image, self->m_image->getBuffSize(), 0, flags); + if (ret >= 0) + self->m_image->m_exports++; + return ret; error: // Return a empty buffer to avoid a crash in Python 3.1 // The bug is fixed in Python SVN 77916, as soon as the python revision used by Blender is // updated, you can simply return -1 and set the error static char* buf = (char *)""; - ret = PyBuffer_FillInfo(view, (PyObject*)self, buf, 0, 0, flags); - if (ret >= 0) - self->m_image->m_exports++; - return ret; + ret = PyBuffer_FillInfo(view, (PyObject*)self, buf, 0, 0, flags); + if (ret >= 0) + self->m_image->m_exports++; + return ret; } diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 6038416ba68..24833ace08f 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -65,29 +65,29 @@ ImageRender::ImageRender (KX_Scene * scene, KX_Camera * camera) : m_owncamera(false), m_observer(NULL), m_mirror(NULL), - m_clip(100.f) + m_clip(100.f) { // initialize background color setBackground(0, 0, 255, 255); - // retrieve rendering objects - m_engine = KX_GetActiveEngine(); - m_rasterizer = m_engine->GetRasterizer(); - m_canvas = m_engine->GetCanvas(); - m_rendertools = m_engine->GetRenderTools(); + // retrieve rendering objects + m_engine = KX_GetActiveEngine(); + m_rasterizer = m_engine->GetRasterizer(); + m_canvas = m_engine->GetCanvas(); + m_rendertools = m_engine->GetRenderTools(); } // destructor ImageRender::~ImageRender (void) { - if (m_owncamera) - m_camera->Release(); + if (m_owncamera) + m_camera->Release(); } // set background color void ImageRender::setBackground (int red, int green, int blue, int alpha) { - m_background[0] = (red < 0) ? 0.f : (red > 255) ? 1.f : float(red)/255.f; + m_background[0] = (red < 0) ? 0.f : (red > 255) ? 1.f : float(red)/255.f; m_background[1] = (green < 0) ? 0.f : (green > 255) ? 1.f : float(green)/255.f; m_background[2] = (blue < 0) ? 0.f : (blue > 255) ? 1.f : float(blue)/255.f; m_background[3] = (alpha < 0) ? 0.f : (alpha > 255) ? 1.f : float(alpha)/255.f; @@ -97,157 +97,157 @@ void ImageRender::setBackground (int red, int green, int blue, int alpha) // capture image from viewport void ImageRender::calcImage (unsigned int texId, double ts) { - if (m_rasterizer->GetDrawingMode() != RAS_IRasterizer::KX_TEXTURED || // no need for texture - m_camera->GetViewport() || // camera must be inactive - m_camera == m_scene->GetActiveCamera()) - { - // no need to compute texture in non texture rendering - m_avail = false; - return; - } - // render the scene from the camera - Render(); + if (m_rasterizer->GetDrawingMode() != RAS_IRasterizer::KX_TEXTURED || // no need for texture + m_camera->GetViewport() || // camera must be inactive + m_camera == m_scene->GetActiveCamera()) + { + // no need to compute texture in non texture rendering + m_avail = false; + return; + } + // render the scene from the camera + Render(); // get image from viewport ImageViewport::calcImage(texId, ts); - // restore OpenGL state - m_canvas->EndFrame(); + // restore OpenGL state + m_canvas->EndFrame(); } void ImageRender::Render() { RAS_FrameFrustum frustrum; - if (!m_render) - return; - - if (m_mirror) - { - // mirror mode, compute camera frustrum, position and orientation - // convert mirror position and normal in world space - const MT_Matrix3x3 & mirrorObjWorldOri = m_mirror->GetSGNode()->GetWorldOrientation(); - const MT_Point3 & mirrorObjWorldPos = m_mirror->GetSGNode()->GetWorldPosition(); - const MT_Vector3 & mirrorObjWorldScale = m_mirror->GetSGNode()->GetWorldScaling(); - MT_Point3 mirrorWorldPos = - mirrorObjWorldPos + mirrorObjWorldScale * (mirrorObjWorldOri * m_mirrorPos); - MT_Vector3 mirrorWorldZ = mirrorObjWorldOri * m_mirrorZ; - // get observer world position - const MT_Point3 & observerWorldPos = m_observer->GetSGNode()->GetWorldPosition(); - // get plane D term = mirrorPos . normal - MT_Scalar mirrorPlaneDTerm = mirrorWorldPos.dot(mirrorWorldZ); - // compute distance of observer to mirror = D - observerPos . normal - MT_Scalar observerDistance = mirrorPlaneDTerm - observerWorldPos.dot(mirrorWorldZ); - // if distance < 0.01 => observer is on wrong side of mirror, don't render - if (observerDistance < 0.01f) - return; - // set camera world position = observerPos + normal * 2 * distance - MT_Point3 cameraWorldPos = observerWorldPos + (MT_Scalar(2.0)*observerDistance)*mirrorWorldZ; - m_camera->GetSGNode()->SetLocalPosition(cameraWorldPos); - // set camera orientation: z=normal, y=mirror_up in world space, x= y x z - MT_Vector3 mirrorWorldY = mirrorObjWorldOri * m_mirrorY; - MT_Vector3 mirrorWorldX = mirrorObjWorldOri * m_mirrorX; - MT_Matrix3x3 cameraWorldOri( - mirrorWorldX[0], mirrorWorldY[0], mirrorWorldZ[0], - mirrorWorldX[1], mirrorWorldY[1], mirrorWorldZ[1], - mirrorWorldX[2], mirrorWorldY[2], mirrorWorldZ[2]); - m_camera->GetSGNode()->SetLocalOrientation(cameraWorldOri); - m_camera->GetSGNode()->UpdateWorldData(0.0); - // compute camera frustrum: - // get position of mirror relative to camera: offset = mirrorPos-cameraPos - MT_Vector3 mirrorOffset = mirrorWorldPos - cameraWorldPos; - // convert to camera orientation - mirrorOffset = mirrorOffset * cameraWorldOri; - // scale mirror size to world scale: - // get closest local axis for mirror Y and X axis and scale height and width by local axis scale - MT_Scalar x, y; - x = fabs(m_mirrorY[0]); - y = fabs(m_mirrorY[1]); - float height = (x > y) ? - ((x > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]): - ((y > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]); - x = fabs(m_mirrorX[0]); - y = fabs(m_mirrorX[1]); - float width = (x > y) ? - ((x > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]): - ((y > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]); - width *= m_mirrorHalfWidth; - height *= m_mirrorHalfHeight; - // left = offsetx-width - // right = offsetx+width - // top = offsety+height - // bottom = offsety-height - // near = -offsetz - // far = near+100 - frustrum.x1 = mirrorOffset[0]-width; - frustrum.x2 = mirrorOffset[0]+width; - frustrum.y1 = mirrorOffset[1]-height; - frustrum.y2 = mirrorOffset[1]+height; - frustrum.camnear = -mirrorOffset[2]; - frustrum.camfar = -mirrorOffset[2]+m_clip; - } + if (!m_render) + return; + + if (m_mirror) + { + // mirror mode, compute camera frustrum, position and orientation + // convert mirror position and normal in world space + const MT_Matrix3x3 & mirrorObjWorldOri = m_mirror->GetSGNode()->GetWorldOrientation(); + const MT_Point3 & mirrorObjWorldPos = m_mirror->GetSGNode()->GetWorldPosition(); + const MT_Vector3 & mirrorObjWorldScale = m_mirror->GetSGNode()->GetWorldScaling(); + MT_Point3 mirrorWorldPos = + mirrorObjWorldPos + mirrorObjWorldScale * (mirrorObjWorldOri * m_mirrorPos); + MT_Vector3 mirrorWorldZ = mirrorObjWorldOri * m_mirrorZ; + // get observer world position + const MT_Point3 & observerWorldPos = m_observer->GetSGNode()->GetWorldPosition(); + // get plane D term = mirrorPos . normal + MT_Scalar mirrorPlaneDTerm = mirrorWorldPos.dot(mirrorWorldZ); + // compute distance of observer to mirror = D - observerPos . normal + MT_Scalar observerDistance = mirrorPlaneDTerm - observerWorldPos.dot(mirrorWorldZ); + // if distance < 0.01 => observer is on wrong side of mirror, don't render + if (observerDistance < 0.01f) + return; + // set camera world position = observerPos + normal * 2 * distance + MT_Point3 cameraWorldPos = observerWorldPos + (MT_Scalar(2.0)*observerDistance)*mirrorWorldZ; + m_camera->GetSGNode()->SetLocalPosition(cameraWorldPos); + // set camera orientation: z=normal, y=mirror_up in world space, x= y x z + MT_Vector3 mirrorWorldY = mirrorObjWorldOri * m_mirrorY; + MT_Vector3 mirrorWorldX = mirrorObjWorldOri * m_mirrorX; + MT_Matrix3x3 cameraWorldOri( + mirrorWorldX[0], mirrorWorldY[0], mirrorWorldZ[0], + mirrorWorldX[1], mirrorWorldY[1], mirrorWorldZ[1], + mirrorWorldX[2], mirrorWorldY[2], mirrorWorldZ[2]); + m_camera->GetSGNode()->SetLocalOrientation(cameraWorldOri); + m_camera->GetSGNode()->UpdateWorldData(0.0); + // compute camera frustrum: + // get position of mirror relative to camera: offset = mirrorPos-cameraPos + MT_Vector3 mirrorOffset = mirrorWorldPos - cameraWorldPos; + // convert to camera orientation + mirrorOffset = mirrorOffset * cameraWorldOri; + // scale mirror size to world scale: + // get closest local axis for mirror Y and X axis and scale height and width by local axis scale + MT_Scalar x, y; + x = fabs(m_mirrorY[0]); + y = fabs(m_mirrorY[1]); + float height = (x > y) ? + ((x > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]): + ((y > fabs(m_mirrorY[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]); + x = fabs(m_mirrorX[0]); + y = fabs(m_mirrorX[1]); + float width = (x > y) ? + ((x > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[0] : mirrorObjWorldScale[2]): + ((y > fabs(m_mirrorX[2])) ? mirrorObjWorldScale[1] : mirrorObjWorldScale[2]); + width *= m_mirrorHalfWidth; + height *= m_mirrorHalfHeight; + // left = offsetx-width + // right = offsetx+width + // top = offsety+height + // bottom = offsety-height + // near = -offsetz + // far = near+100 + frustrum.x1 = mirrorOffset[0]-width; + frustrum.x2 = mirrorOffset[0]+width; + frustrum.y1 = mirrorOffset[1]-height; + frustrum.y2 = mirrorOffset[1]+height; + frustrum.camnear = -mirrorOffset[2]; + frustrum.camfar = -mirrorOffset[2]+m_clip; + } // Store settings to be restored later - const RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode(); + const RAS_IRasterizer::StereoMode stereomode = m_rasterizer->GetStereoMode(); RAS_Rect area = m_canvas->GetWindowArea(); - // The screen area that ImageViewport will copy is also the rendering zone - m_canvas->SetViewPort(m_position[0], m_position[1], m_position[0]+m_capSize[0]-1, m_position[1]+m_capSize[1]-1); - m_canvas->ClearColor(m_background[0], m_background[1], m_background[2], m_background[3]); - m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); - m_rasterizer->BeginFrame(RAS_IRasterizer::KX_TEXTURED,m_engine->GetClockTime()); - m_rendertools->BeginFrame(m_rasterizer); - m_engine->SetWorldSettings(m_scene->GetWorldInfo()); - m_rendertools->SetAuxilaryClientInfo(m_scene); - m_rasterizer->DisplayFog(); - // matrix calculation, don't apply any of the stereo mode - m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO); - if (m_mirror) - { - // frustrum was computed above - // get frustrum matrix and set projection matrix + // The screen area that ImageViewport will copy is also the rendering zone + m_canvas->SetViewPort(m_position[0], m_position[1], m_position[0]+m_capSize[0]-1, m_position[1]+m_capSize[1]-1); + m_canvas->ClearColor(m_background[0], m_background[1], m_background[2], m_background[3]); + m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); + m_rasterizer->BeginFrame(RAS_IRasterizer::KX_TEXTURED,m_engine->GetClockTime()); + m_rendertools->BeginFrame(m_rasterizer); + m_engine->SetWorldSettings(m_scene->GetWorldInfo()); + m_rendertools->SetAuxilaryClientInfo(m_scene); + m_rasterizer->DisplayFog(); + // matrix calculation, don't apply any of the stereo mode + m_rasterizer->SetStereoMode(RAS_IRasterizer::RAS_STEREO_NOSTEREO); + if (m_mirror) + { + // frustrum was computed above + // get frustrum matrix and set projection matrix MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix( - frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); + frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); m_camera->SetProjectionMatrix(projmat); - } else if (m_camera->hasValidProjectionMatrix()) + } else if (m_camera->hasValidProjectionMatrix()) { m_rasterizer->SetProjectionMatrix(m_camera->GetProjectionMatrix()); - } else - { + } else + { float lens = m_camera->GetLens(); bool orthographic = !m_camera->GetCameraData()->m_perspective; float nearfrust = m_camera->GetCameraNear(); float farfrust = m_camera->GetCameraFar(); - float aspect_ratio = 1.0f; - Scene *blenderScene = m_scene->GetBlenderScene(); + float aspect_ratio = 1.0f; + Scene *blenderScene = m_scene->GetBlenderScene(); MT_Matrix4x4 projmat; // compute the aspect ratio from frame blender scene settings so that render to texture - // works the same in Blender and in Blender player - if (blenderScene->r.ysch != 0) - aspect_ratio = float(blenderScene->r.xsch*blenderScene->r.xasp) / float(blenderScene->r.ysch*blenderScene->r.yasp); + // works the same in Blender and in Blender player + if (blenderScene->r.ysch != 0) + aspect_ratio = float(blenderScene->r.xsch*blenderScene->r.xasp) / float(blenderScene->r.ysch*blenderScene->r.yasp); if (orthographic) { RAS_FramingManager::ComputeDefaultOrtho( - nearfrust, - farfrust, - m_camera->GetScale(), - aspect_ratio, - frustrum - ); + nearfrust, + farfrust, + m_camera->GetScale(), + aspect_ratio, + frustrum + ); projmat = m_rasterizer->GetOrthoMatrix( - frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); - } else + frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); + } else { RAS_FramingManager::ComputeDefaultFrustum( - nearfrust, - farfrust, - lens, - aspect_ratio, - frustrum); + nearfrust, + farfrust, + lens, + aspect_ratio, + frustrum); projmat = m_rasterizer->GetFrustumMatrix( - frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); + frustrum.x1, frustrum.x2, frustrum.y1, frustrum.y2, frustrum.camnear, frustrum.camfar); } m_camera->SetProjectionMatrix(projmat); } @@ -257,8 +257,8 @@ void ImageRender::Render() m_rasterizer->SetViewMatrix(viewmat, m_camera->NodeGetWorldOrientation(), m_camera->NodeGetWorldPosition(), m_camera->GetCameraData()->m_perspective); m_camera->SetModelviewMatrix(viewmat); - // restore the stereo mode now that the matrix is computed - m_rasterizer->SetStereoMode(stereomode); + // restore the stereo mode now that the matrix is computed + m_rasterizer->SetStereoMode(stereomode); m_scene->CalculateVisibleMeshes(m_rasterizer,m_camera); @@ -433,24 +433,24 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds PyObject * scene; // reference object for mirror PyObject * observer; - // object holding the mirror - PyObject * mirror; - // material of the mirror - short materialID = 0; + // object holding the mirror + PyObject * mirror; + // material of the mirror + short materialID = 0; // parameter keywords static const char *kwlist[] = {"scene", "observer", "mirror", "material", NULL}; // get parameters if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOO|h", - const_cast(kwlist), &scene, &observer, &mirror, &materialID)) + const_cast(kwlist), &scene, &observer, &mirror, &materialID)) return -1; try { // get scene pointer KX_Scene * scenePtr (NULL); - if (scene != NULL && PyObject_TypeCheck(scene, &KX_Scene::Type)) - scenePtr = static_castBGE_PROXY_REF(scene); + if (scene != NULL && PyObject_TypeCheck(scene, &KX_Scene::Type)) + scenePtr = static_castBGE_PROXY_REF(scene); else - THRWEXCP(SceneInvalid, S_OK); + THRWEXCP(SceneInvalid, S_OK); if(scenePtr==NULL) /* incase the python proxy reference is invalid */ THRWEXCP(SceneInvalid, S_OK); @@ -458,11 +458,11 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds // get observer pointer KX_GameObject * observerPtr (NULL); if (observer != NULL && PyObject_TypeCheck(observer, &KX_GameObject::Type)) - observerPtr = static_castBGE_PROXY_REF(observer); - else if (observer != NULL && PyObject_TypeCheck(observer, &KX_Camera::Type)) - observerPtr = static_castBGE_PROXY_REF(observer); + observerPtr = static_castBGE_PROXY_REF(observer); + else if (observer != NULL && PyObject_TypeCheck(observer, &KX_Camera::Type)) + observerPtr = static_castBGE_PROXY_REF(observer); else - THRWEXCP(ObserverInvalid, S_OK); + THRWEXCP(ObserverInvalid, S_OK); if(observerPtr==NULL) /* incase the python proxy reference is invalid */ THRWEXCP(ObserverInvalid, S_OK); @@ -470,27 +470,27 @@ static int ImageMirror_init (PyObject * pySelf, PyObject * args, PyObject * kwds // get mirror pointer KX_GameObject * mirrorPtr (NULL); if (mirror != NULL && PyObject_TypeCheck(mirror, &KX_GameObject::Type)) - mirrorPtr = static_castBGE_PROXY_REF(mirror); + mirrorPtr = static_castBGE_PROXY_REF(mirror); else - THRWEXCP(MirrorInvalid, S_OK); + THRWEXCP(MirrorInvalid, S_OK); if(mirrorPtr==NULL) /* incase the python proxy reference is invalid */ THRWEXCP(MirrorInvalid, S_OK); - // locate the material in the mirror + // locate the material in the mirror RAS_IPolyMaterial * material = getMaterial(mirror, materialID); if (material == NULL) - THRWEXCP(MaterialNotAvail, S_OK); + THRWEXCP(MaterialNotAvail, S_OK); // get pointer to image structure PyImage * self = reinterpret_cast(pySelf); // create source object - if (self->m_image != NULL) - { - delete self->m_image; - self->m_image = NULL; - } + if (self->m_image != NULL) + { + delete self->m_image; + self->m_image = NULL; + } self->m_image = new ImageRender(scenePtr, observerPtr, mirrorPtr, material); } catch (Exception & exp) @@ -530,7 +530,7 @@ static PyGetSetDef imageMirrorGetSets[] = {(char*)"clip", (getter)getClip, (setter)setClip, (char*)"clipping distance", NULL}, // attribute from ImageRender {(char*)"background", (getter)getBackground, (setter)setBackground, (char*)"background color", NULL}, - // attribute from ImageViewport + // attribute from ImageViewport {(char*)"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, (char*)"size of render area", NULL}, {(char*)"alpha", (getter)ImageViewport_getAlpha, (setter)ImageViewport_setAlpha, (char*)"use alpha in texture", NULL}, {(char*)"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, (char*)"use whole viewport to render", NULL}, @@ -552,164 +552,164 @@ ImageRender::ImageRender (KX_Scene * scene, KX_GameObject * observer, KX_GameObj m_scene(scene), m_observer(observer), m_mirror(mirror), - m_clip(100.f) + m_clip(100.f) { - // this constructor is used for automatic planar mirror - // create a camera, take all data by default, in any case we will recompute the frustrum on each frame + // this constructor is used for automatic planar mirror + // create a camera, take all data by default, in any case we will recompute the frustrum on each frame RAS_CameraData camdata; - vector mirrorVerts; - vector::iterator it; - float mirrorArea = 0.f; - float mirrorNormal[3] = {0.f, 0.f, 0.f}; - float mirrorUp[3]; - float dist, vec[3], axis[3]; - float zaxis[3] = {0.f, 0.f, 1.f}; - float yaxis[3] = {0.f, 1.f, 0.f}; - float mirrorMat[3][3]; - float left, right, top, bottom, back; + vector mirrorVerts; + vector::iterator it; + float mirrorArea = 0.f; + float mirrorNormal[3] = {0.f, 0.f, 0.f}; + float mirrorUp[3]; + float dist, vec[3], axis[3]; + float zaxis[3] = {0.f, 0.f, 1.f}; + float yaxis[3] = {0.f, 1.f, 0.f}; + float mirrorMat[3][3]; + float left, right, top, bottom, back; // make sure this camera will delete its node m_camera= new KX_Camera(scene, KX_Scene::m_callbacks, camdata, true, true); m_camera->SetName("__mirror__cam__"); - // don't add the camera to the scene object list, it doesn't need to be accessible - m_owncamera = true; - // retrieve rendering objects - m_engine = KX_GetActiveEngine(); - m_rasterizer = m_engine->GetRasterizer(); - m_canvas = m_engine->GetCanvas(); - m_rendertools = m_engine->GetRenderTools(); - // locate the vertex assigned to mat and do following calculation in mesh coordinates - for (int meshIndex = 0; meshIndex < mirror->GetMeshCount(); meshIndex++) - { - RAS_MeshObject* mesh = mirror->GetMesh(meshIndex); - int numPolygons = mesh->NumPolygons(); - for (int polygonIndex=0; polygonIndex < numPolygons; polygonIndex++) - { - RAS_Polygon* polygon = mesh->GetPolygon(polygonIndex); - if (polygon->GetMaterial()->GetPolyMaterial() == mat) - { - RAS_TexVert *v1, *v2, *v3, *v4; - float normal[3]; - float area; - // this polygon is part of the mirror, - v1 = polygon->GetVertex(0); - v2 = polygon->GetVertex(1); - v3 = polygon->GetVertex(2); - mirrorVerts.push_back(v1); - mirrorVerts.push_back(v2); - mirrorVerts.push_back(v3); - if (polygon->VertexCount() == 4) - { - v4 = polygon->GetVertex(3); - mirrorVerts.push_back(v4); - area = normal_quad_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ(), (float*)v4->getXYZ()); - } else - { - area = normal_tri_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ()); - } - area = fabs(area); - mirrorArea += area; - mul_v3_fl(normal, area); - add_v3_v3v3(mirrorNormal, mirrorNormal, normal); - } - } - } - if (mirrorVerts.size() == 0 || mirrorArea < FLT_EPSILON) - { - // no vertex or zero size mirror - THRWEXCP(MirrorSizeInvalid, S_OK); - } - // compute average normal of mirror faces - mul_v3_fl(mirrorNormal, 1.0f/mirrorArea); - if (normalize_v3(mirrorNormal) == 0.f) - { - // no normal - THRWEXCP(MirrorNormalInvalid, S_OK); - } - // the mirror plane has an equation of the type ax+by+cz = d where (a,b,c) is the normal vector + // don't add the camera to the scene object list, it doesn't need to be accessible + m_owncamera = true; + // retrieve rendering objects + m_engine = KX_GetActiveEngine(); + m_rasterizer = m_engine->GetRasterizer(); + m_canvas = m_engine->GetCanvas(); + m_rendertools = m_engine->GetRenderTools(); + // locate the vertex assigned to mat and do following calculation in mesh coordinates + for (int meshIndex = 0; meshIndex < mirror->GetMeshCount(); meshIndex++) + { + RAS_MeshObject* mesh = mirror->GetMesh(meshIndex); + int numPolygons = mesh->NumPolygons(); + for (int polygonIndex=0; polygonIndex < numPolygons; polygonIndex++) + { + RAS_Polygon* polygon = mesh->GetPolygon(polygonIndex); + if (polygon->GetMaterial()->GetPolyMaterial() == mat) + { + RAS_TexVert *v1, *v2, *v3, *v4; + float normal[3]; + float area; + // this polygon is part of the mirror, + v1 = polygon->GetVertex(0); + v2 = polygon->GetVertex(1); + v3 = polygon->GetVertex(2); + mirrorVerts.push_back(v1); + mirrorVerts.push_back(v2); + mirrorVerts.push_back(v3); + if (polygon->VertexCount() == 4) + { + v4 = polygon->GetVertex(3); + mirrorVerts.push_back(v4); + area = normal_quad_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ(), (float*)v4->getXYZ()); + } else + { + area = normal_tri_v3( normal,(float*)v1->getXYZ(), (float*)v2->getXYZ(), (float*)v3->getXYZ()); + } + area = fabs(area); + mirrorArea += area; + mul_v3_fl(normal, area); + add_v3_v3v3(mirrorNormal, mirrorNormal, normal); + } + } + } + if (mirrorVerts.size() == 0 || mirrorArea < FLT_EPSILON) + { + // no vertex or zero size mirror + THRWEXCP(MirrorSizeInvalid, S_OK); + } + // compute average normal of mirror faces + mul_v3_fl(mirrorNormal, 1.0f/mirrorArea); + if (normalize_v3(mirrorNormal) == 0.f) + { + // no normal + THRWEXCP(MirrorNormalInvalid, S_OK); + } + // the mirror plane has an equation of the type ax+by+cz = d where (a,b,c) is the normal vector // if the mirror is more vertical then horizontal, the Z axis is the up direction. // otherwise the Y axis is the up direction. // If the mirror is not perfectly vertical(horizontal), the Z(Y) axis projection on the mirror // plan by the normal will be the up direction. if (fabs(mirrorNormal[2]) > fabs(mirrorNormal[1]) && - fabs(mirrorNormal[2]) > fabs(mirrorNormal[0])) + fabs(mirrorNormal[2]) > fabs(mirrorNormal[0])) { // the mirror is more horizontal than vertical - copy_v3_v3(axis, yaxis); + copy_v3_v3(axis, yaxis); } else { // the mirror is more vertical than horizontal - copy_v3_v3(axis, zaxis); + copy_v3_v3(axis, zaxis); + } + dist = dot_v3v3(mirrorNormal, axis); + if (fabs(dist) < FLT_EPSILON) + { + // the mirror is already fully aligned with up axis + copy_v3_v3(mirrorUp, axis); + } + else + { + // projection of axis to mirror plane through normal + copy_v3_v3(vec, mirrorNormal); + mul_v3_fl(vec, dist); + sub_v3_v3v3(mirrorUp, axis, vec); + if (normalize_v3(mirrorUp) == 0.f) + { + // should not happen + THRWEXCP(MirrorHorizontal, S_OK); + return; + } + } + // compute rotation matrix between local coord and mirror coord + // to match camera orientation, we select mirror z = -normal, y = up, x = y x z + negate_v3_v3(mirrorMat[2], mirrorNormal); + copy_v3_v3(mirrorMat[1], mirrorUp); + cross_v3_v3v3(mirrorMat[0], mirrorMat[1], mirrorMat[2]); + // transpose to make it a orientation matrix from local space to mirror space + transpose_m3(mirrorMat); + // transform all vertex to plane coordinates and determine mirror position + left = FLT_MAX; + right = -FLT_MAX; + bottom = FLT_MAX; + top = -FLT_MAX; + back = -FLT_MAX; // most backward vertex (=highest Z coord in mirror space) + for (it = mirrorVerts.begin(); it != mirrorVerts.end(); it++) + { + copy_v3_v3(vec, (float*)(*it)->getXYZ()); + mul_m3_v3(mirrorMat, vec); + if (vec[0] < left) + left = vec[0]; + if (vec[0] > right) + right = vec[0]; + if (vec[1] < bottom) + bottom = vec[1]; + if (vec[1] > top) + top = vec[1]; + if (vec[2] > back) + back = vec[2]; + } + // now store this information in the object for later rendering + m_mirrorHalfWidth = (right-left)*0.5f; + m_mirrorHalfHeight = (top-bottom)*0.5f; + if (m_mirrorHalfWidth < 0.01f || m_mirrorHalfHeight < 0.01f) + { + // mirror too small + THRWEXCP(MirrorTooSmall, S_OK); } - dist = dot_v3v3(mirrorNormal, axis); - if (fabs(dist) < FLT_EPSILON) - { - // the mirror is already fully aligned with up axis - copy_v3_v3(mirrorUp, axis); - } - else - { - // projection of axis to mirror plane through normal - copy_v3_v3(vec, mirrorNormal); - mul_v3_fl(vec, dist); - sub_v3_v3v3(mirrorUp, axis, vec); - if (normalize_v3(mirrorUp) == 0.f) - { - // should not happen - THRWEXCP(MirrorHorizontal, S_OK); - return; - } - } - // compute rotation matrix between local coord and mirror coord - // to match camera orientation, we select mirror z = -normal, y = up, x = y x z - negate_v3_v3(mirrorMat[2], mirrorNormal); - copy_v3_v3(mirrorMat[1], mirrorUp); - cross_v3_v3v3(mirrorMat[0], mirrorMat[1], mirrorMat[2]); - // transpose to make it a orientation matrix from local space to mirror space - transpose_m3(mirrorMat); - // transform all vertex to plane coordinates and determine mirror position - left = FLT_MAX; - right = -FLT_MAX; - bottom = FLT_MAX; - top = -FLT_MAX; - back = -FLT_MAX; // most backward vertex (=highest Z coord in mirror space) - for (it = mirrorVerts.begin(); it != mirrorVerts.end(); it++) - { - copy_v3_v3(vec, (float*)(*it)->getXYZ()); - mul_m3_v3(mirrorMat, vec); - if (vec[0] < left) - left = vec[0]; - if (vec[0] > right) - right = vec[0]; - if (vec[1] < bottom) - bottom = vec[1]; - if (vec[1] > top) - top = vec[1]; - if (vec[2] > back) - back = vec[2]; - } - // now store this information in the object for later rendering - m_mirrorHalfWidth = (right-left)*0.5f; - m_mirrorHalfHeight = (top-bottom)*0.5f; - if (m_mirrorHalfWidth < 0.01f || m_mirrorHalfHeight < 0.01f) - { - // mirror too small - THRWEXCP(MirrorTooSmall, S_OK); - } - // mirror position in mirror coord - vec[0] = (left+right)*0.5f; - vec[1] = (top+bottom)*0.5f; - vec[2] = back; - // convert it in local space: transpose again the matrix to get back to mirror to local transform - transpose_m3(mirrorMat); - mul_m3_v3(mirrorMat, vec); - // mirror position in local space - m_mirrorPos.setValue(vec[0], vec[1], vec[2]); - // mirror normal vector (pointed towards the back of the mirror) in local space - m_mirrorZ.setValue(-mirrorNormal[0], -mirrorNormal[1], -mirrorNormal[2]); - m_mirrorY.setValue(mirrorUp[0], mirrorUp[1], mirrorUp[2]); - m_mirrorX = m_mirrorY.cross(m_mirrorZ); - m_render = true; + // mirror position in mirror coord + vec[0] = (left+right)*0.5f; + vec[1] = (top+bottom)*0.5f; + vec[2] = back; + // convert it in local space: transpose again the matrix to get back to mirror to local transform + transpose_m3(mirrorMat); + mul_m3_v3(mirrorMat, vec); + // mirror position in local space + m_mirrorPos.setValue(vec[0], vec[1], vec[2]); + // mirror normal vector (pointed towards the back of the mirror) in local space + m_mirrorZ.setValue(-mirrorNormal[0], -mirrorNormal[1], -mirrorNormal[2]); + m_mirrorY.setValue(mirrorUp[0], mirrorUp[1], mirrorUp[2]); + m_mirrorX = m_mirrorY.cross(m_mirrorZ); + m_render = true; setBackground(0, 0, 255, 255); } diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index d0e5ee74f6e..0276ad6fd6b 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -123,34 +123,34 @@ void ImageViewport::calcImage (unsigned int texId, double ts) } // if texture can be directly created if (texId != 0 && m_pyfilter == NULL && m_capSize[0] == calcSize(m_capSize[0]) - && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip) + && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip) { // just copy current viewport to texture - glBindTexture(GL_TEXTURE_2D, texId); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1]); - // image is not available - m_avail = false; + glBindTexture(GL_TEXTURE_2D, texId); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1]); + // image is not available + m_avail = false; } // otherwise copy viewport to buffer, if image is not available else if (!m_avail) { // get frame buffer data - if (m_alpha) - { - glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGBA, - GL_UNSIGNED_BYTE, m_viewportImage); - // filter loaded data - FilterRGBA32 filt; - filterImage(filt, m_viewportImage, m_capSize); - } - else - { - glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB, - GL_UNSIGNED_BYTE, m_viewportImage); - // filter loaded data - FilterRGB24 filt; - filterImage(filt, m_viewportImage, m_capSize); - } + if (m_alpha) + { + glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGBA, + GL_UNSIGNED_BYTE, m_viewportImage); + // filter loaded data + FilterRGBA32 filt; + filterImage(filt, m_viewportImage, m_capSize); + } + else + { + glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB, + GL_UNSIGNED_BYTE, m_viewportImage); + // filter loaded data + FilterRGB24 filt; + filterImage(filt, m_viewportImage, m_capSize); + } } } diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index f8274756c8b..8a76b0c004d 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -544,11 +544,11 @@ void VideoFFmpeg::openFile (char * filename) // It would be good to find this information from the context but there are no simple indication !strncmp(filename, "http://", 7) || #ifdef FFMPEG_PB_IS_POINTER - (m_formatCtx->pb && m_formatCtx->pb->is_streamed) + (m_formatCtx->pb && m_formatCtx->pb->is_streamed) #else - m_formatCtx->pb.is_streamed + m_formatCtx->pb.is_streamed #endif - ) + ) { // the file is in fact a streaming source, treat as cam to prevent seeking m_isFile = false; diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp index c1258bbb6e4..2cb3831de52 100644 --- a/source/gameengine/VideoTexture/blendVideoTex.cpp +++ b/source/gameengine/VideoTexture/blendVideoTex.cpp @@ -175,9 +175,9 @@ PyObject* initVideoTexture(void) // prepare classes registerAllTypes(); - registerAllExceptions(); + registerAllExceptions(); - if (!pyImageTypes.ready()) + if (!pyImageTypes.ready()) return NULL; if (!pyFilterTypes.ready()) return NULL; -- cgit v1.2.3 From 473292dcd7f0f51b91316fc59cdf7d97d11435a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Sep 2011 09:46:07 +0000 Subject: fix for building without audaspace, since pepper merge --- source/blender/blenkernel/intern/sound.c | 12 ++++++++++++ source/blender/editors/sound/sound_ops.c | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index cdb509ab8e1..50a7b4a7a73 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -760,5 +760,17 @@ void sound_seek_scene(struct bContext *UNUSED(C)) {} float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; } int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; } int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; } +void sound_read_waveform(struct bSound* sound) { (void)sound; } +void sound_init_main(struct Main *bmain) { (void)bmain; } +void sound_set_cfra(int cfra) { (void)cfra; } +void sound_update_sequencer(struct Main* main, struct bSound* sound) { (void)main; (void)sound; } +void sound_update_scene(struct Scene* scene) { (void)scene; } +void sound_update_scene_sound(void* handle, struct bSound* sound) { (void)handle; (void)sound; } +void sound_update_scene_listener(struct Scene *scene) { (void)scene; } +void sound_update_fps(struct Scene *scene) { (void)scene; } +void sound_set_scene_sound_volume(void* handle, float volume, char animated) { (void)handle; (void)volume; (void)animated; } +void sound_set_scene_sound_pan(void* handle, float pan, char animated) { (void)handle; (void)pan; (void)animated; } +void sound_set_scene_volume(struct Scene *scene, float volume) { (void)scene; (void)volume; } +void sound_set_scene_sound_pitch(void* handle, float pitch, char animated) { (void)handle; (void)pitch; (void)animated; } #endif // WITH_AUDASPACE diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index e66abffbfd1..70884d47c23 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -221,6 +221,7 @@ void SOUND_OT_open_mono(wmOperatorType *ot) static int mixdown_exec(bContext *C, wmOperator *op) { +#ifdef WITH_AUDASPACE char path[FILE_MAX]; char filename[FILE_MAX]; Scene *scene; @@ -254,7 +255,10 @@ static int mixdown_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, result); return OPERATOR_CANCELLED; } - +#else // WITH_AUDASPACE + (void)C; + (void)op; +#endif // WITH_AUDASPACE return OPERATOR_FINISHED; } @@ -278,6 +282,7 @@ static int mixdown_draw_check_prop(PropertyRNA *prop) ); } +#ifdef WITH_AUDASPACE static void mixdown_draw(bContext *C, wmOperator *op) { static EnumPropertyItem pcm_format_items[] = { @@ -429,9 +434,11 @@ static void mixdown_draw(bContext *C, wmOperator *op) /* main draw call */ uiDefAutoButsRNA(layout, &ptr, mixdown_draw_check_prop, '\0'); } +#endif // WITH_AUDASPACE void SOUND_OT_mixdown(wmOperatorType *ot) { +#ifdef WITH_AUDASPACE static EnumPropertyItem format_items[] = { {AUD_FORMAT_U8, "U8", 0, "U8", "8 bit unsigned"}, {AUD_FORMAT_S16, "S16", 0, "S16", "16 bit signed"}, @@ -469,6 +476,8 @@ void SOUND_OT_mixdown(wmOperatorType *ot) {AUD_CODEC_VORBIS, "VORBIS", 0, "Vorbis", "Xiph.Org Vorbis Codec"}, {0, NULL, 0, NULL, NULL}}; +#endif // WITH_AUDASPACE + /* identifiers */ ot->name= "Mixdown"; ot->description= "Mixes the scene's audio to a sound file"; @@ -477,18 +486,22 @@ void SOUND_OT_mixdown(wmOperatorType *ot) /* api callbacks */ ot->exec= mixdown_exec; ot->invoke= mixdown_invoke; - ot->ui= mixdown_draw; +#ifdef WITH_AUDASPACE + ot->ui= mixdown_draw; +#endif /* flags */ ot->flag= OPTYPE_REGISTER; /* properties */ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH); +#ifdef WITH_AUDASPACE RNA_def_int(ot->srna, "accuracy", 1024, 1, 16777216, "Accuracy", "Sample accuracy. Important for animation data. The lower the value, the more accurate.", 1, 16777216); RNA_def_enum(ot->srna, "container", container_items, AUD_CONTAINER_FLAC, "Container", "File format"); RNA_def_enum(ot->srna, "codec", codec_items, AUD_CODEC_FLAC, "Codec", "Audio Codec"); RNA_def_enum(ot->srna, "format", format_items, AUD_FORMAT_S16, "Format", "Sample format"); RNA_def_int(ot->srna, "bitrate", 192, 32, 512, "Bitrate", "Bitrate in kbit/s", 32, 512); +#endif // WITH_AUDASPACE } /* ******************************************************* */ -- cgit v1.2.3 From a8e49cd55a9cb5ca43dfb3d97c4ad0968a469b45 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 1 Sep 2011 09:47:21 +0000 Subject: use a fixed 32byte buffer for getting an rna string from python. gives a slight speedup when drawing heavy UI's --- source/blender/python/intern/bpy_rna.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index e1c38a82142..6de3c040c18 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1298,7 +1298,9 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) { int subtype= RNA_property_subtype(prop); const char *buf; - buf= RNA_property_string_get_alloc(ptr, prop, NULL, -1); + char buf_fixed[32]; + + buf= RNA_property_string_get_alloc(ptr, prop, buf_fixed, sizeof(buf_fixed)); #ifdef USE_STRING_COERCE /* only file paths get special treatment, they may contain non utf-8 chars */ if(ELEM3(subtype, PROP_FILEPATH, PROP_DIRPATH, PROP_FILENAME)) { @@ -1310,7 +1312,9 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) #else // USE_STRING_COERCE ret= PyUnicode_FromString(buf); #endif // USE_STRING_COERCE - MEM_freeN((void *)buf); + if(buf_fixed != buf) { + MEM_freeN((void *)buf); + } break; } case PROP_ENUM: -- cgit v1.2.3 From 0f2be67bbfb03748e5bb3a02475afa8d7ec9aaa3 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Thu, 1 Sep 2011 19:53:14 +0000 Subject: BGE: Undoing r39729 and applying a simpler fix (ensuring that the viewport is correct for PostRenderScene()). This way both 2d filters and post_draw callbacks with with multiple viewports. --- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'source') diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 878232f7a50..ca67333166c 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -886,8 +886,6 @@ void KX_KetsjiEngine::Render() { if((*it)->GetViewport()) { - // Change the active camera so Python scripts can figure out what viewport they're in - scene->SetActiveCamera(*it); if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); @@ -899,10 +897,6 @@ void KX_KetsjiEngine::Render() it++; } - - // Now change the camera back - scene->SetActiveCamera(cam); - PostRenderScene(scene); } @@ -1322,10 +1316,6 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam) if (scene->GetPhysicsEnvironment()) scene->GetPhysicsEnvironment()->debugDrawWorld(); - -#ifdef WITH_PYTHON - scene->RunDrawingCallbacks(scene->GetPostDrawCB()); -#endif } void KX_KetsjiEngine::RenderFonts(KX_Scene* scene) @@ -1345,8 +1335,14 @@ To run once per scene */ void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene) { + // We need to first make sure our viewport is correct (enabling multiple viewports can mess this up) + m_canvas->SetViewPort(0, 0, m_canvas->GetWidth(), m_canvas->GetHeight()); + m_rendertools->MotionBlur(m_rasterizer); scene->Render2DFilters(m_canvas); +#ifdef WITH_PYTHON + scene->RunDrawingCallbacks(scene->GetPostDrawCB()); +#endif m_rasterizer->FlushDebugLines(); } -- cgit v1.2.3 From 99d5fa70de605f1541aa035389a3c701c48a33c8 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Thu, 1 Sep 2011 21:47:46 +0000 Subject: BGE animations: This is an attempt to help smooth out some more compatibility issues with the new action actuator. It now has a similar pulse behavior to the old actuator. This has worked well in most of my tests, but YoFrankie still has problems, and it appears to have gotten a little worse. --- source/gameengine/Converter/BL_ActionActuator.cpp | 106 +++++++++++++++++----- source/gameengine/Converter/BL_ActionActuator.h | 4 +- 2 files changed, 85 insertions(+), 25 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 50afac6992e..50e887a21a8 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -129,6 +129,50 @@ void BL_ActionActuator::SetBlendTime (float newtime){ m_blendframe = newtime; } +void BL_ActionActuator::SetLocalTime(float curtime) +{ + float dt = (curtime-m_starttime)*KX_KetsjiEngine::GetAnimFrameRate(); + + if (m_endframe < m_startframe) + dt = -dt; + + m_localtime = m_startframe + dt; + + // Handle wrap around + if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) + { + switch(m_playtype) + { + case ACT_ACTION_PLAY: + // Clamp + m_localtime = m_endframe; + break; + case ACT_ACTION_LOOP_END: + // Put the time back to the beginning + m_localtime = m_startframe; + m_starttime = curtime; + break; + case ACT_ACTION_PINGPONG: + // Swap the start and end frames + float temp = m_startframe; + m_startframe = m_endframe; + m_endframe = temp; + + m_starttime = curtime; + + break; + } + } +} + +void BL_ActionActuator::ResetStartTime(float curtime) +{ + float dt = m_localtime - m_startframe; + + m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate()); + //SetLocalTime(curtime); +} + CValue* BL_ActionActuator::GetReplica() { BL_ActionActuator* replica = new BL_ActionActuator(*this);//m_float,GetName()); replica->ProcessReplica(); @@ -194,11 +238,46 @@ bool BL_ActionActuator::Update(double curtime, bool frame) RemoveAllEvents(); } + if (m_flag & ACT_FLAG_ATTEMPT_PLAY) + SetLocalTime(curtime); + if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE)) + { m_localtime = obj->GetActionFrame(m_layer); + ResetStartTime(curtime); + } + + // Handle a frame property if it's defined + if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0) + { + CValue* oldprop = obj->GetProperty(m_framepropname); + CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer)); + if (oldprop) + oldprop->SetValue(newval); + else + obj->SetProperty(m_framepropname, newval); + + newval->Release(); + } + + // Handle a finished animation + if ((m_flag & ACT_FLAG_PLAY_END) && obj->IsActionDone(m_layer)) + { + m_flag &= ~ACT_FLAG_ACTIVE; + m_flag &= ~ACT_FLAG_ATTEMPT_PLAY; + obj->StopAction(m_layer); + return false; + } - if (bPositiveEvent) + // If a different action is playing, we've been overruled and are no longer active + if (obj->GetCurrentAction(m_layer) != m_action) + m_flag &= ~ACT_FLAG_ACTIVE; + + if (bPositiveEvent || (m_flag & ACT_FLAG_ATTEMPT_PLAY && !(m_flag & ACT_FLAG_ACTIVE))) { + if (bPositiveEvent) + ResetStartTime(curtime); + if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags)) { m_flag |= ACT_FLAG_ACTIVE; @@ -210,11 +289,11 @@ bool BL_ActionActuator::Update(double curtime, bool frame) else m_flag &= ~ACT_FLAG_PLAY_END; } - else - return false; + m_flag |= ACT_FLAG_ATTEMPT_PLAY; } else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent) { + m_flag &= ~ACT_FLAG_ATTEMPT_PLAY; bAction *curr_action = obj->GetCurrentAction(m_layer); if (curr_action && curr_action != m_action) { @@ -259,27 +338,6 @@ bool BL_ActionActuator::Update(double curtime, bool frame) } } - // Handle a frame property if it's defined - if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0) - { - CValue* oldprop = obj->GetProperty(m_framepropname); - CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer)); - if (oldprop) - oldprop->SetValue(newval); - else - obj->SetProperty(m_framepropname, newval); - - newval->Release(); - } - - // Handle a finished animation - if ((m_flag & ACT_FLAG_PLAY_END) && obj->IsActionDone(m_layer)) - { - m_flag &= ~ACT_FLAG_ACTIVE; - obj->StopAction(m_layer); - return false; - } - return true; } diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h index 5324cb10885..357c2b4a05e 100644 --- a/source/gameengine/Converter/BL_ActionActuator.h +++ b/source/gameengine/Converter/BL_ActionActuator.h @@ -64,6 +64,8 @@ public: virtual void ProcessReplica(); void SetBlendTime (float newtime); + void SetLocalTime (float curtime); + void ResetStartTime (float curtime); bAction* GetAction() { return m_action; } void SetAction(bAction* act) { m_action= act; } @@ -150,7 +152,7 @@ enum { ACT_FLAG_ACTIVE = 1<<3, ACT_FLAG_CONTINUE = 1<<4, ACT_FLAG_PLAY_END = 1<<5, - + ACT_FLAG_ATTEMPT_PLAY = 1<<6, }; #endif -- cgit v1.2.3 From 1f7b41775bcc8832355c13785c299156a870c749 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Sep 2011 03:32:57 +0000 Subject: minor warning fixes, also correct some float -> double promotions in shadeoutput.c --- source/blender/blenkernel/intern/nla.c | 4 +++- source/blender/blenkernel/intern/sound.c | 2 ++ source/blender/render/intern/source/shadeoutput.c | 28 +++++++++++------------ source/tests/check_deprecated.py | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 25f824bba19..53ccd55bde8 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -341,7 +341,7 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act) } /* Add a NLA Strip referencing the given speaker's sound */ -NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker) +NlaStrip *add_nla_soundstrip (Scene *UNUSED(scene), Speaker *speaker) { NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip"); @@ -359,6 +359,8 @@ NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker) #endif { strip->end = 10.0f; + /* quiet compiler warnings */ + (void)speaker; } /* general settings */ diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 50a7b4a7a73..74f4830b86c 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -39,8 +39,10 @@ #include "BKE_sequencer.h" #include "BKE_scene.h" +#ifdef WITH_AUDASPACE // evil global ;-) static int sound_cfra; +#endif struct bSound* sound_new_file(struct Main *bmain, const char *filename) { diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 7f921d21041..30632586b04 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -282,10 +282,10 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) else if(ok1==0 || ok2==0) return; /* at least 1 visible interesction point */ - if(t1<0.0f && t2<0.0f) return; + if(t1<0.0 && t2<0.0) return; - if(t1<0.0f) t1= 0.0f; - if(t2<0.0f) t2= 0.0f; + if(t1<0.0) t1= 0.0; + if(t2<0.0) t2= 0.0; if(t1==t2) return; @@ -423,8 +423,8 @@ float fresnel_fac(float *view, float *vn, float grad, float fac) static double saacos_d(double fac) { - if(fac<= -1.0f) return M_PI; - else if(fac>=1.0f) return 0.0; + if(fac<= -1.0) return M_PI; + else if(fac>=1.0) return 0.0; else return acos(fac); } @@ -590,7 +590,7 @@ static float CookTorr_Spec(float *n, float *l, float *v, int hard, int tangent) i= spec(nh, hard); - i= i/(0.1+nv); + i= i/(0.1f+nv); return i; } @@ -896,7 +896,7 @@ static void ramp_diffuse_result(float *diff, ShadeInput *shi) if(ma->ramp_col) { if(ma->rampin_col==MA_RAMP_IN_RESULT) { - fac= 0.3*diff[0] + 0.58*diff[1] + 0.12*diff[2]; + fac= 0.3f*diff[0] + 0.58f*diff[1] + 0.12f*diff[2]; do_colorband(ma->ramp_col, fac, col); /* blending method */ @@ -926,7 +926,7 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa /* input */ switch(ma->rampin_col) { case MA_RAMP_IN_ENERGY: - fac= 0.3*r + 0.58*g + 0.12*b; + fac= 0.3f*r + 0.58f*g + 0.12f*b; break; case MA_RAMP_IN_SHADER: fac= is; @@ -966,7 +966,7 @@ static void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInpu float fac; if(ma->ramp_spec && (ma->rampin_spec==MA_RAMP_IN_RESULT)) { - fac= 0.3*(*specr) + 0.58*(*specg) + 0.12*(*specb); + fac= 0.3f*(*specr) + 0.58f*(*specg) + 0.12f*(*specb); do_colorband(ma->ramp_spec, fac, col); /* blending method */ @@ -1213,7 +1213,7 @@ float lamp_get_visibility(LampRen *lar, float *co, float *lv, float *dist) } } } - if (visifac <= 0.001) visifac = 0.0f; + if (visifac <= 0.001f) visifac = 0.0f; return visifac; } } @@ -1231,7 +1231,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int view= shi->view; - if (lar->energy == 0.0) return; + if (lar->energy == 0.0f) return; /* only shadow lamps shouldn't affect shadow-less materials at all */ if ((lar->mode & LA_ONLYSHADOW) && (!(ma->mode & MA_SHADOW) || !(R.r.mode & R_SHADOW))) return; @@ -1359,7 +1359,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* 'is' is diffuse */ if((ma->shade_flag & MA_CUBIC) && is>0.0f && is<1.0f) - is= 3.0*is*is - 2.0*is*is*is; // nicer termination of shades + is= 3.0f*is*is - 2.0f*is*is*is; // nicer termination of shades i= is*phongcorr; @@ -1388,7 +1388,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int lamp_get_shadow(lar, shi, inp, shadfac, shi->depth); /* warning, here it skips the loop */ - if((lar->mode & LA_ONLYSHADOW) && i>0.0) { + if((lar->mode & LA_ONLYSHADOW) && i>0.0f) { shadfac[3]= i*lar->energy*(1.0f-shadfac[3]); shr->shad[0] -= shadfac[3]*shi->r*(1.0f-lashdw[0]); @@ -1448,7 +1448,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int t= vn[0]*lv[0]+vn[1]*lv[1]+vn[2]*lv[2]; if(lar->type==LA_HEMI) { - t= 0.5*t+0.5; + t= 0.5f*t+0.5f; } t= shadfac[3]*shi->spec*spec(t, shi->har); diff --git a/source/tests/check_deprecated.py b/source/tests/check_deprecated.py index 856e1f6d272..34b07518162 100644 --- a/source/tests/check_deprecated.py +++ b/source/tests/check_deprecated.py @@ -130,7 +130,7 @@ def deprecations(): def main(): import datetime - now = datetime.datetime.now()\ + now = datetime.datetime.now() deps = deprecations() -- cgit v1.2.3 From dc463db6c27242af464140582bc6708802d601e8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Sep 2011 03:42:16 +0000 Subject: Credits generator which cross references with the patch tracker to credit the original authors. the script has a unix-name <> real-name mapping which is not totally complete since I couldn't find everyones real names. In this case the commit name is credited. Also added a link to the credits page in the splash. --- source/blender/windowmanager/intern/wm_operators.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index a4efa8fff84..c053022681b 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1259,11 +1259,12 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); uiItemL(col, "Links", ICON_NONE); - uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment/"); - uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-259/"); + uiItemStringO(col, "Donations", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/blenderorg/blender-foundation/donation-payment"); + uiItemStringO(col, "Credits", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/credits"); + uiItemStringO(col, "Release Log", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/development/release-logs/blender-259"); uiItemStringO(col, "Manual", ICON_URL, "WM_OT_url_open", "url", "http://wiki.blender.org/index.php/Doc:2.5/Manual"); - uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/"); - uiItemStringO(col, "User Community", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community/"); // + uiItemStringO(col, "Blender Website", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org"); + uiItemStringO(col, "User Community", ICON_URL, "WM_OT_url_open", "url", "http://www.blender.org/community/user-community"); if(strcmp(STRINGIFY(BLENDER_VERSION_CYCLE), "release")==0) { BLI_snprintf(url, sizeof(url), "http://www.blender.org/documentation/blender_python_api_%d_%d" STRINGIFY(BLENDER_VERSION_CHAR) "_release", BLENDER_VERSION/100, BLENDER_VERSION%100); } -- cgit v1.2.3 From dc7f56455c8a6e045a7a8ab683376ccc91ab8b93 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Sep 2011 04:34:58 +0000 Subject: fix for error in recent commit, when audaspace is enabled --- source/blender/blenkernel/intern/nla.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 53ccd55bde8..6ce80342dd6 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -341,7 +341,7 @@ NlaStrip *add_nlastrip_to_stack (AnimData *adt, bAction *act) } /* Add a NLA Strip referencing the given speaker's sound */ -NlaStrip *add_nla_soundstrip (Scene *UNUSED(scene), Speaker *speaker) +NlaStrip *add_nla_soundstrip (Scene *scene, Speaker *speaker) { NlaStrip *strip = MEM_callocN(sizeof(NlaStrip), "NlaSoundStrip"); @@ -360,6 +360,7 @@ NlaStrip *add_nla_soundstrip (Scene *UNUSED(scene), Speaker *speaker) { strip->end = 10.0f; /* quiet compiler warnings */ + (void)scene; (void)speaker; } -- cgit v1.2.3 From e6ff3df5b980ebda24f14d0d211bb0739aa64f12 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Sep 2011 07:51:19 +0000 Subject: fix for keymap search, was using uninitialized memory when the keymaps operator couldn't be found. --- source/blender/makesrna/intern/rna_wm.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 93adf808f83..4c07a89a42f 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -680,20 +680,14 @@ static void rna_wmKeyMapItem_name_get(PointerRNA *ptr, char *value) { wmKeyMapItem *kmi= ptr->data; wmOperatorType *ot= WM_operatortype_find(kmi->idname, 1); - - if (ot) - strcpy(value, ot->name); + strcpy(value, ot ? ot->name : kmi->idname); } static int rna_wmKeyMapItem_name_length(PointerRNA *ptr) { wmKeyMapItem *kmi= ptr->data; wmOperatorType *ot= WM_operatortype_find(kmi->idname, 1); - - if (ot) - return strlen(ot->name); - else - return 0; + return strlen(ot ? ot->name : kmi->idname); } static int rna_KeyMapItem_userdefined_get(PointerRNA *ptr) @@ -1652,7 +1646,9 @@ static void rna_def_keyconfig(BlenderRNA *brna) RNA_def_property_string_funcs(prop, "rna_wmKeyMapItem_idname_get", "rna_wmKeyMapItem_idname_length", "rna_wmKeyMapItem_idname_set"); RNA_def_struct_name_property(srna, prop); RNA_def_property_update(prop, 0, "rna_KeyMapItem_update"); - + + /* this is infact the operator name, but if the operator can't be found we + * fallback on the operator ID */ prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Name", "Name of operator to call on input event"); -- cgit v1.2.3 From 1d9ddcd319908f6442b02623f7782413ecefa40a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Sep 2011 08:01:01 +0000 Subject: tweak to WM_operatortype_find to perform better when called with empty strings (as the keymap editor does a lot) --- source/blender/windowmanager/intern/wm_operators.c | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index c053022681b..0e0203543a4 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -108,21 +108,28 @@ static GHash *global_ops_hash= NULL; wmOperatorType *WM_operatortype_find(const char *idname, int quiet) { - wmOperatorType *ot; - - char idname_bl[OP_MAX_TYPENAME]; // XXX, needed to support python style names without the _OT_ syntax - WM_operator_bl_idname(idname_bl, idname); + if(idname[0]) { + wmOperatorType *ot; + + /* needed to support python style names without the _OT_ syntax */ + char idname_bl[OP_MAX_TYPENAME]; + WM_operator_bl_idname(idname_bl, idname); - if (idname_bl[0]) { ot= BLI_ghash_lookup(global_ops_hash, idname_bl); if(ot) { return ot; } + + if(!quiet) { + printf("search for unknown operator '%s', '%s'\n", idname_bl, idname); + } } - - if(!quiet) - printf("search for unknown operator %s, %s\n", idname_bl, idname); - + else { + if(!quiet) { + printf("search for empty operator\n"); + } + } + return NULL; } -- cgit v1.2.3 From 8276989f63267c906fcf933dcf557bc35fa1cb8c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Sep 2011 08:20:30 +0000 Subject: fix [#28460] SEGFAULT when trying to make empty display as image --- source/blender/editors/animation/anim_filter.c | 47 ++++++++++++++------------ 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 8010a41ccb3..bb710a32794 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1177,29 +1177,34 @@ static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDo /* determine what animation data from AnimData block should get displayed */ static size_t animfilter_block_data (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *id, int filter_mode) { - IdAdtTemplate *iat = (IdAdtTemplate*)id; AnimData *adt = BKE_animdata_from_id(id); size_t items = 0; - - /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed - * in a few places in he rest of the code still - notably for the few cases where special mode-based - * different types of data expanders are required. - */ - ANIMDATA_FILTER_CASES(iat, - { /* AnimData */ - /* specifically filter animdata block */ - ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_ANIMDATA, id); - }, - { /* NLA */ - items += animfilter_nla(ac, anim_data, ads, adt, filter_mode, id); - }, - { /* Drivers */ - items += animfilter_fcurves(anim_data, ads, adt->drivers.first, NULL, filter_mode, id); - }, - { /* Keyframes */ - items += animfilter_action(ac, anim_data, ads, adt->action, filter_mode, id); - }); - + + /* image object datablocks have no anim-data so check for NULL */ + if(adt) { + IdAdtTemplate *iat = (IdAdtTemplate*)id; + + /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed + * in a few places in he rest of the code still - notably for the few cases where special mode-based + * different types of data expanders are required. + */ + ANIMDATA_FILTER_CASES(iat, + { /* AnimData */ + /* specifically filter animdata block */ + ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_ANIMDATA, id); + }, + { /* NLA */ + items += animfilter_nla(ac, anim_data, ads, adt, filter_mode, id); + }, + { /* Drivers */ + items += animfilter_fcurves(anim_data, ads, adt->drivers.first, NULL, filter_mode, id); + }, + { /* Keyframes */ + items += animfilter_action(ac, anim_data, ads, adt->action, filter_mode, id); + } + ); + } + return items; } -- cgit v1.2.3 From 612e2d4dbe0e8dfe5b4d4fee49040ec38107ada3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Sep 2011 08:35:46 +0000 Subject: patch [#28473] Outliner Simple Todo from Julien DUROURE (julien) --- * right click --> rename, as proposed on http://wiki.blender.org/index.php/Dev:2.5/Source/Development/Todo/Simple_Todos * implementation of Toggle visibility/rendarability/selectability on right click on Groups ( was in menu, but not implemented ) --- .../blender/editors/space_outliner/outliner_draw.c | 2 +- .../blender/editors/space_outliner/outliner_edit.c | 64 ++++++++++++++++------ .../editors/space_outliner/outliner_intern.h | 8 +++ .../editors/space_outliner/outliner_tools.c | 42 ++++++++++++-- 4 files changed, 94 insertions(+), 22 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 0cb05fa2115..95a315272b9 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -236,7 +236,7 @@ static int group_select_flag(Group *gr) return 0; } -static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) +void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) { Scene *scene = (Scene *)poin; GroupObject *gob; diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index fbd5281b1d9..2b451a48748 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -218,6 +218,34 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) /* Rename --------------------------------------------------- */ +void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports) +{ + /* can't rename rna datablocks entries */ + if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) + ; + else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); + else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) + BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); + else if(tselem->id->lib) { + // XXX error_libdata(); + } + else if(te->idcode == ID_LI && te->parent) { + BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library"); + } + else { + tselem->flag |= TSE_TEXTBUT; + ED_region_tag_redraw(ar); + } +} + +void item_rename_cb(bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + ARegion *ar= CTX_wm_region(C); + ReportList *reports= CTX_wm_reports(C); // XXX + do_item_rename(ar, te, tselem, reports) ; +} + static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) { ReportList *reports= CTX_wm_reports(C); // XXX @@ -228,23 +256,7 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T /* name and first icon */ if(mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { - /* can't rename rna datablocks entries */ - if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) - ; - else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) - BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); - else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) - BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); - else if(tselem->id->lib) { - // XXX error_libdata(); - } - else if(te->idcode == ID_LI && te->parent) { - BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library"); - } - else { - tselem->flag |= TSE_TEXTBUT; - ED_region_tag_redraw(ar); - } + do_item_rename(ar, te, tselem, reports) ; } return 1; } @@ -377,6 +389,12 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre } } +void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Group *group= (Group *)tselem->id; + restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_VIEW); +} + static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); @@ -417,6 +435,12 @@ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme } } +void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Group *group= (Group *)tselem->id; + restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_SELECT); +} + static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); @@ -457,6 +481,12 @@ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme } } +void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) +{ + Group *group= (Group *)tselem->id; + restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_RENDER); +} + static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops= CTX_wm_space_outliner(C); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 9da09144125..2ddb5707623 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -139,6 +139,7 @@ void outliner_build_tree(struct Main *mainvar, struct Scene *scene, struct Space /* outliner_draw.c ---------------------------------------------- */ void draw_outliner(const struct bContext *C); +void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag); /* outliner_select.c -------------------------------------------- */ int tree_element_type_active(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set); @@ -158,6 +159,13 @@ void object_toggle_visibility_cb(struct bContext *C, struct Scene *scene, TreeEl void object_toggle_selectability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); void object_toggle_renderability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); + +void group_toggle_visibility_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); +void group_toggle_selectability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); +void group_toggle_renderability_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); + +void item_rename_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); + /* ...................................................... */ void OUTLINER_OT_item_activate(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 3ae158bd275..70dfbfe3830 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -510,6 +510,7 @@ static EnumPropertyItem prop_object_op_types[] = { {6, "TOGVIS", 0, "Toggle Visible", ""}, {7, "TOGSEL", 0, "Toggle Selectable", ""}, {8, "TOGREN", 0, "Toggle Renderable", ""}, + {9, "RENAME", 0, "Rename", ""}, {0, NULL, 0, NULL, NULL} }; @@ -567,6 +568,10 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) str= "Toggle Renderability"; WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); } + else if(event==9) { + outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb); + str= "Rename Object"; + } ED_undo_push(C, str); @@ -600,6 +605,7 @@ static EnumPropertyItem prop_group_op_types[] = { {4, "TOGVIS", 0, "Toggle Visible", ""}, {5, "TOGSEL", 0, "Toggle Selectable", ""}, {6, "TOGREN", 0, "Toggle Renderable", ""}, + {7, "RENAME", 0, "Rename", ""}, {0, NULL, 0, NULL, NULL} }; @@ -608,6 +614,7 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); SpaceOops *soops= CTX_wm_space_outliner(C); int event; + const char *str= NULL; /* check for invalid states */ if (soops == NULL) @@ -617,18 +624,35 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) if(event==1) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); - ED_undo_push(C, "Unlink group"); + str= "Unlink group"; } else if(event==2) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); - ED_undo_push(C, "Localized Data"); + str= "Localized Data"; } else if(event==3) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); - ED_undo_push(C, "Link Group Objects to Scene"); + str= "Link Group Objects to Scene"; + } + else if(event==4) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); + str= "Toggle Visibility"; + } + else if(event==5) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); + str= "Toggle Selectability"; + } + else if(event==6) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); + str= "Toggle Renderability"; + } + else if(event==7) { + outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); + str= "Rename"; } + ED_undo_push(C, str); WM_event_add_notifier(C, NC_GROUP, NULL); return OPERATOR_FINISHED; @@ -662,7 +686,8 @@ typedef enum eOutlinerIdOpTypes { OUTLINER_IDOP_SINGLE, OUTLINER_IDOP_FAKE_ADD, - OUTLINER_IDOP_FAKE_CLEAR + OUTLINER_IDOP_FAKE_CLEAR, + OUTLINER_IDOP_RENAME } eOutlinerIdOpTypes; // TODO: implement support for changing the ID-block used @@ -672,6 +697,7 @@ static EnumPropertyItem prop_id_op_types[] = { {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""}, {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User", "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"}, {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""}, + {OUTLINER_IDOP_RENAME, "RENAME", 0, "Rename", ""}, {0, NULL, 0, NULL, NULL} }; @@ -765,6 +791,14 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) ED_undo_push(C, "Clear Fake User"); } break; + case OUTLINER_IDOP_RENAME: + /* rename */ + outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); + + WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + ED_undo_push(C, "Rename"); + + break; default: // invalid - unhandled -- cgit v1.2.3 From 7a496bfbcf3c5a25d4101cf427ca980327ed3e8a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 2 Sep 2011 09:39:21 +0000 Subject: Partial fix for #28441: Tab width in texteditor ignored if used tabs as spaces Scroll to cursor when displaying text datablock was changed. This behavior was lost in 2.5x. --- source/blender/editors/space_text/space_text.c | 5 +++++ source/blender/editors/space_text/text_draw.c | 19 +++++++++++++------ source/blender/editors/space_text/text_intern.h | 1 + source/blender/makesrna/intern/rna_space.c | 3 ++- 4 files changed, 21 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index c7d4d78422e..47f051e1ec4 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -154,6 +154,11 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) case NA_REMOVED: ED_area_tag_redraw(sa); break; + case NA_SELECTED: + if(st->text && st->text == wmn->reference) + text_scroll_to_cursor(st, sa); + + break; } break; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 28230b7a48b..066404f23ba 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1821,12 +1821,10 @@ void text_update_character_width(SpaceText *st) /* Moves the view to the cursor location, also used to make sure the view isnt outside the file */ -void text_update_cursor_moved(bContext *C) +void text_scroll_to_cursor(SpaceText *st, ScrArea *sa) { - ScrArea *sa= CTX_wm_area(C); - SpaceText *st= CTX_wm_space_text(C); Text *text; - ARegion *ar; + ARegion *ar= NULL; int i, x, winx= 0; if(ELEM3(NULL, st, st->text, st->text->curl)) return; @@ -1834,8 +1832,10 @@ void text_update_cursor_moved(bContext *C) text= st->text; for(ar=sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_WINDOW) + if(ar->regiontype==RGN_TYPE_WINDOW) { winx= ar->winx; + break; + } winx -= TXT_SCROLL_WIDTH; @@ -1844,7 +1844,7 @@ void text_update_cursor_moved(bContext *C) i= txt_get_span(text->lines.first, text->sell); if(st->wordwrap) { int offl, offc; - wrap_offset(st, CTX_wm_region(C), text->sell, text->selc, &offl, &offc); + wrap_offset(st, ar, text->sell, text->selc, &offl, &offc); i+= offl; } @@ -1865,3 +1865,10 @@ void text_update_cursor_moved(bContext *C) if(st->left <0) st->left= 0; } +void text_update_cursor_moved(bContext *C) +{ + ScrArea *sa= CTX_wm_area(C); + SpaceText *st= CTX_wm_space_text(C); + + text_scroll_to_cursor(st, sa); +} diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index cb55f41acb5..b34c7815f35 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -55,6 +55,7 @@ int text_font_width(struct SpaceText *st, const char *str); void text_update_line_edited(struct TextLine *line); void text_update_edited(struct Text *text); void text_update_character_width(struct SpaceText *st); +void text_scroll_to_cursor(struct SpaceText *st, struct ScrArea *sa); void text_update_cursor_moved(struct bContext *C); /* TXT_OFFSET used to be 35 when the scrollbar was on the left... */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 8f3097e5589..7a7debe1bf5 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -591,7 +591,8 @@ static void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value) SpaceText *st= (SpaceText*)(ptr->data); st->text= value.data; - st->top= 0; + + WM_main_add_notifier(NC_TEXT|NA_SELECTED, st->text); } static void rna_SpaceTextEditor_updateEdited(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -- cgit v1.2.3 From 15afd240e04ef3f220b6133cc920d964dbcfcf85 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Sep 2011 10:43:51 +0000 Subject: paranoid check that RNA string functions set the string, would have helped solve keymap search bug. disabled in release mode. --- source/blender/makesrna/intern/rna_access.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 0d4e31cdaf2..ad79771416d 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2216,8 +2216,17 @@ char *RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fi else buf= MEM_mallocN(sizeof(char)*(length+1), "RNA_string_get_alloc"); +#ifndef NDEBUG + /* safety check to ensure the string is actually set */ + buf[length]= 255; +#endif + RNA_property_string_get(ptr, prop, buf); +#ifndef NDEBUG + BLI_assert(buf[length] == '\0'); +#endif + return buf; } -- cgit v1.2.3 From 3386563368f1e489a40e86671933af385e4073f9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 2 Sep 2011 12:26:57 +0000 Subject: Bugfix [#28435] Key Visual transform and Parenting not working After reviewing this code, it seems that this case can work after all. However, several things needed to be tweaked: 1) Removed check which stopped parented objects from getting the visual keying coordinates determined. This actually wasn't doing anything, given that this case would never occur as... 2) Tweaked the visualkey_can_use() function to also consider parenting as a cause for visual-keying to be necessary. --- source/blender/editors/animation/keyframing.c | 73 ++++++++++++++------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 4e87409b7fd..53c9fc4d82c 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -530,6 +530,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) { bConstraint *con= NULL; short searchtype= VISUALKEY_NONE; + short has_parent = FALSE; char *identifier= NULL; /* validate data */ @@ -548,6 +549,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) con= ob->constraints.first; identifier= (char *)RNA_property_identifier(prop); + has_parent= (ob->parent != NULL); } else if (ptr->type == &RNA_PoseBone) { /* Pose Channel */ @@ -555,10 +557,11 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) con= pchan->constraints.first; identifier= (char *)RNA_property_identifier(prop); + has_parent= (pchan->parent != NULL); } /* check if any data to search using */ - if (ELEM(NULL, con, identifier)) + if (ELEM(NULL, con, identifier) && (has_parent == FALSE)) return 0; /* location or rotation identifiers only... */ @@ -573,7 +576,12 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) /* only search if a searchtype and initial constraint are available */ - if (searchtype && con) { + if (searchtype) { + /* parent is always matching */ + if (has_parent) + return 1; + + /* constraints */ for (; con; con= con->next) { /* only consider constraint if it is not disabled, and has influence */ if (con->flag & CONSTRAINT_DISABLE) continue; @@ -645,39 +653,34 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ if (ptr->type == &RNA_Object) { Object *ob= (Object *)ptr->data; - /* parented objects are not supported, as the effects of the parent - * are included in the matrix, which kindof beats the point - */ - if (ob->parent == NULL) { - /* only Location or Rotation keyframes are supported now */ - if (strstr(identifier, "location")) { - return ob->obmat[3][array_index]; - } - else if (strstr(identifier, "rotation_euler")) { - float eul[3]; - - mat4_to_eulO(eul, ob->rotmode, ob->obmat); - return eul[array_index]; - } - else if (strstr(identifier, "rotation_quaternion")) { - float trimat[3][3], quat[4]; - - copy_m3_m4(trimat, ob->obmat); - mat3_to_quat_is_ok(quat, trimat); - - return quat[array_index]; - } - else if (strstr(identifier, "rotation_axis_angle")) { - float axis[3], angle; - - mat4_to_axis_angle(axis, &angle, ob->obmat); - - /* w = 0, x,y,z = 1,2,3 */ - if (array_index == 0) - return angle; - else - return axis[array_index - 1]; - } + /* only Location or Rotation keyframes are supported now */ + if (strstr(identifier, "location")) { + return ob->obmat[3][array_index]; + } + else if (strstr(identifier, "rotation_euler")) { + float eul[3]; + + mat4_to_eulO(eul, ob->rotmode, ob->obmat); + return eul[array_index]; + } + else if (strstr(identifier, "rotation_quaternion")) { + float trimat[3][3], quat[4]; + + copy_m3_m4(trimat, ob->obmat); + mat3_to_quat_is_ok(quat, trimat); + + return quat[array_index]; + } + else if (strstr(identifier, "rotation_axis_angle")) { + float axis[3], angle; + + mat4_to_axis_angle(axis, &angle, ob->obmat); + + /* w = 0, x,y,z = 1,2,3 */ + if (array_index == 0) + return angle; + else + return axis[array_index - 1]; } } else if (ptr->type == &RNA_PoseBone) { -- cgit v1.2.3 From 6b4bdf621f2830ceff2c44f871523a312422a338 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 2 Sep 2011 13:23:44 +0000 Subject: Fix #28467: Crash while deleting objects in outliner too fast Cleanup tree when handling object delete from outliner. Prevents handling the same tree item twice when clicking fast. --- source/blender/editors/space_outliner/outliner_intern.h | 1 + source/blender/editors/space_outliner/outliner_tools.c | 9 +++++++++ source/blender/editors/space_outliner/outliner_tree.c | 6 ++++++ 3 files changed, 16 insertions(+) (limited to 'source') diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 2ddb5707623..61507d1ffe5 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -129,6 +129,7 @@ typedef struct TreeElement { /* outliner_tree.c ----------------------------------------------- */ void outliner_free_tree(ListBase *lb); +void outliner_cleanup_tree(struct SpaceOops *soops); TreeElement *outliner_find_tse(struct SpaceOops *soops, TreeStoreElem *tse); TreeElement *outliner_find_id(struct SpaceOops *soops, ListBase *lb, struct ID *id); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 70dfbfe3830..b3170f9cd1e 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -287,6 +287,8 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); if(base) { + SpaceOops *soops= CTX_wm_space_outliner(C); + // check also library later if(scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); @@ -294,6 +296,13 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); te->directdata= NULL; tselem->id= NULL; + + /* XXX: tree management normally happens from draw_outliner(), but when + you're clicking to fast on Delete object from context menu in + outliner several mouse events can be handled in one cycle without + handling notifiers/redraw which leads to deleting the same object twice. + cleanup tree here to prevent such cases. */ + outliner_cleanup_tree(soops); } } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 0b07c824f3e..8904dcc360f 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -222,6 +222,12 @@ void outliner_free_tree(ListBase *lb) } } +void outliner_cleanup_tree(SpaceOops *soops) +{ + outliner_free_tree(&soops->tree); + outliner_storage_cleanup(soops); +} + /* Find ith item from the treestore */ static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) { -- cgit v1.2.3 From 2fb2075c5b3495fede6980b4f9247f9e89c39d39 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 2 Sep 2011 15:19:30 +0000 Subject: Fix #28280: Insert Hook wrong index Use quite easy and stupid approach like it used for shape keys: re-make editmesh (editcurve or editlattice) before creating index array for hook or storing vertex index in parenting object. Even if hook was added in "current" edit mode, it should be re-mapped on loading edit data because topology could be changed after it was created. Such kind of re-loading edit structures is the easiest way for now to update keyindexes to relevant state. Also, fixed bug with not re-mapping indices for vertex-parented objects. Really old error, not sure why it wasn't noticed yet. --- source/blender/editors/mesh/editmesh.c | 2 +- source/blender/editors/object/object_hook.c | 21 ++++++++++++++++---- source/blender/editors/object/object_relations.c | 25 ++++++++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) (limited to 'source') diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 4377fb03632..e371c346f36 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1099,7 +1099,7 @@ void load_editMesh(Scene *scene, Object *obedit) int j; for (ob=G.main->object.first; ob; ob=ob->id.next) { - if (ob->parent==ob && ELEM(ob->partype, PARVERT1,PARVERT3)) { + if (ob->parent==obedit && ELEM(ob->partype, PARVERT1,PARVERT3)) { /* duplicate code from below, make it function later...? */ if (!vertMap) { diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index bb32869469a..266556773f0 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -64,6 +64,7 @@ #include "ED_curve.h" #include "ED_mesh.h" +#include "ED_lattice.h" #include "ED_screen.h" #include "WM_types.h" @@ -292,7 +293,7 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo return totvert; } -static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r) +static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int **indexar, char *name, float *cent_r) { *indexar= NULL; *tot= 0; @@ -302,7 +303,12 @@ static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char case OB_MESH: { Mesh *me= obedit->data; - EditMesh *em = BKE_mesh_get_editmesh(me); + EditMesh *em; + + load_editMesh(scene, obedit); + make_editMesh(scene, obedit); + + em = BKE_mesh_get_editmesh(me); /* check selected vertices first */ if( return_editmesh_indexar(em, tot, indexar, cent_r)) { @@ -316,10 +322,17 @@ static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char } case OB_CURVE: case OB_SURF: + load_editNurb(obedit); + make_editNurb(obedit); + return return_editcurve_indexar(obedit, tot, indexar, cent_r); case OB_LATTICE: { Lattice *lt= obedit->data; + + load_editLatt(obedit); + make_editLatt(obedit); + return return_editlattice_indexar(lt->editlatt->latt, tot, indexar, cent_r); } default: @@ -427,7 +440,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o int tot, ok, *indexar; char name[32]; - ok = object_hook_index_array(obedit, &tot, &indexar, name, cent); + ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); if (!ok) return; // XXX error("Requires selected vertices or active Vertex Group"); @@ -760,7 +773,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) /* assign functionality */ - if(!object_hook_index_array(ob, &tot, &indexar, name, cent)) { + if(!object_hook_index_array(CTX_data_scene(C), ob, &tot, &indexar, name, cent)) { BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index e9418ca9f9f..b9208e778c7 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -91,6 +91,8 @@ #include "ED_armature.h" #include "ED_curve.h" +#include "ED_lattice.h" +#include "ED_mesh.h" #include "ED_keyframing.h" #include "ED_object.h" #include "ED_screen.h" @@ -122,7 +124,12 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) if(obedit->type==OB_MESH) { Mesh *me= obedit->data; - EditMesh *em = BKE_mesh_get_editmesh(me); + EditMesh *em; + + load_editMesh(scene, obedit); + make_editMesh(scene, obedit); + + em = BKE_mesh_get_editmesh(me); eve= em->verts.first; while(eve) { @@ -140,7 +147,12 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(me, em); } else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) { - ListBase *editnurb= curve_get_editcurve(obedit); + ListBase *editnurb; + + load_editNurb(obedit); + make_editNurb(obedit); + + editnurb= curve_get_editcurve(obedit); cu= obedit->data; @@ -180,8 +192,13 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } } else if(obedit->type==OB_LATTICE) { - Lattice *lt= obedit->data; - + Lattice *lt; + + load_editLatt(obedit); + make_editLatt(obedit); + + lt= obedit->data; + a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; bp= lt->editlatt->latt->def; while(a--) { -- cgit v1.2.3 From 87cb3f8519c942e19b20ac2b6bbe82fd28b95b3c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 2 Sep 2011 17:58:09 +0000 Subject: Fix crash caused by recently added assert about if string was set properly. Memory Estimate is actually 31 characters length, str[31] is a null-terminator. Return length of 31 for memory estimate property. Returning proper length would lead to slowdown because of 2x iteration through vertices. --- source/blender/makesrna/intern/rna_fluidsim.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 1ba2e32502f..ccb24d7dd9b 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -184,7 +184,11 @@ static void rna_DomainFluidSettings_memory_estimate_get(PointerRNA *ptr, char *v static int rna_DomainFluidSettings_memory_estimate_length(PointerRNA *ptr) { - return 32; +#ifdef DISABLE_ELBEEM + return 0; +#else + return 31; +#endif } static char *rna_FluidSettings_path(PointerRNA *ptr) -- cgit v1.2.3 From 5193526aebccceb5fb6420e6a703f9b974247078 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 2 Sep 2011 18:05:07 +0000 Subject: Add missed notifier when toggling object's force field. --- source/blender/editors/object/object_edit.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source') diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 61734bc51a2..79cbfb6574b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1411,6 +1411,8 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) else ob->pd->forcefield = 0; + WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, NULL); + return OPERATOR_FINISHED; } -- cgit v1.2.3 From 8e3d1084b2a73aaa308ceda7a2e777e3d1990690 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 2 Sep 2011 19:25:32 +0000 Subject: Fix for grid lines drawing outside of histogram widget. --- source/blender/editors/interface/interface_draw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 76ed9891b8e..2267f04aab4 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -770,7 +770,11 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(15); uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); - + + /* need scissor test, histogram can draw outside of boundary */ + glGetIntegerv(GL_VIEWPORT, scissor); + glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); + glColor4f(1.f, 1.f, 1.f, 0.08f); /* draw grid lines here */ for (i=1; i<4; i++) { @@ -778,10 +782,6 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) fdrawline(rect.xmin+(i/4.f)*w, rect.ymin, rect.xmin+(i/4.f)*w, rect.ymax); } - /* need scissor test, histogram can draw outside of boundary */ - glGetIntegerv(GL_VIEWPORT, scissor); - glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); - if (hist->mode == HISTO_MODE_LUMA) histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_luma, res); else { -- cgit v1.2.3 From 0cd5dce245762b3fb3fd195dde3bd9ddaeb48970 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 3 Sep 2011 02:15:49 +0000 Subject: whitespace edits --- source/blender/python/intern/bpy_rna.c | 300 +++++++++--------- .../BlenderRoutines/KX_BlenderInputDevice.h | 334 ++++++++++----------- source/gameengine/Converter/BL_MeshDeformer.h | 2 +- source/gameengine/Converter/BL_ShapeDeformer.h | 4 +- .../Converter/KX_BlenderSceneConverter.cpp | 2 +- .../gameengine/Converter/KX_ConvertActuators.cpp | 2 +- source/gameengine/GameLogic/SCA_2DFilterActuator.h | 22 +- source/gameengine/GameLogic/SCA_PythonController.h | 2 +- source/gameengine/GameLogic/SCA_RandomActuator.cpp | 4 +- .../GamePlayer/ghost/GPG_Application.cpp | 2 +- .../Ketsji/KXNetwork/KX_NetworkEventManager.h | 4 +- source/gameengine/Ketsji/KX_GameObject.cpp | 2 +- source/gameengine/Ketsji/KX_ObjectActuator.cpp | 6 +- .../Ketsji/KX_OrientationInterpolator.cpp | 4 +- source/gameengine/Ketsji/KX_PolygonMaterial.cpp | 2 +- source/gameengine/Ketsji/KX_TrackToActuator.h | 2 +- .../NG_LoopBackNetworkDeviceInterface.h | 4 +- .../gameengine/Network/NG_NetworkDeviceInterface.h | 2 +- .../Physics/Bullet/CcdPhysicsController.h | 12 +- .../Physics/Bullet/CcdPhysicsEnvironment.cpp | 4 +- .../Physics/Bullet/CcdPhysicsEnvironment.h | 2 +- .../gameengine/Rasterizer/RAS_2DFilterManager.cpp | 4 +- source/gameengine/Rasterizer/RAS_CameraData.h | 26 +- .../RAS_OpenGLFilters/RAS_Blur2DFilter.h | 18 +- .../RAS_OpenGLFilters/RAS_Dilation2DFilter.h | 18 +- .../RAS_OpenGLFilters/RAS_Erosion2DFilter.h | 22 +- .../RAS_OpenGLFilters/RAS_Laplacian2DFilter.h | 20 +- .../RAS_OpenGLFilters/RAS_Prewitt2DFilter.h | 26 +- .../RAS_OpenGLFilters/RAS_Sharpen2DFilter.h | 20 +- .../RAS_OpenGLFilters/RAS_Sobel2DFilter.h | 26 +- source/gameengine/SceneGraph/SG_DList.h | 130 ++++---- source/gameengine/SceneGraph/SG_IObject.h | 2 +- source/gameengine/SceneGraph/SG_QList.h | 100 +++--- source/gameengine/SceneGraph/SG_Spatial.cpp | 2 +- source/gameengine/VideoTexture/Exception.h | 10 +- source/gameengine/VideoTexture/ImageBase.cpp | 2 +- source/gameengine/VideoTexture/ImageRender.cpp | 10 +- 37 files changed, 576 insertions(+), 578 deletions(-) (limited to 'source') diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 6de3c040c18..d10c8c843e8 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4631,28 +4631,28 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject /* note: tp_base member is set to &PyType_Type on init */ PyTypeObject pyrna_struct_meta_idprop_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_struct_meta_idprop", /* tp_name */ - sizeof(PyHeapTypeObject), /* tp_basicsize */ // XXX, would be PyTypeObject, but subtypes of Type must be PyHeapTypeObject's - 0, /* tp_itemsize */ + "bpy_struct_meta_idprop", /* tp_name */ + sizeof(PyHeapTypeObject), /* tp_basicsize */ // XXX, would be PyTypeObject, but subtypes of Type must be PyHeapTypeObject's + 0, /* tp_itemsize */ /* methods */ - NULL, /* tp_dealloc */ + NULL, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ - NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* deprecated in python 3.0! */ - NULL, /* tp_repr */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ /* deprecated in python 3.0! */ + NULL, /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ - NULL, /* reprfunc tp_str; */ - NULL /*(getattrofunc) pyrna_struct_meta_idprop_getattro*/, /* getattrofunc tp_getattro; */ - (setattrofunc) pyrna_struct_meta_idprop_setattro, /* setattrofunc tp_setattro; */ + NULL, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ + NULL /*(getattrofunc) pyrna_struct_meta_idprop_getattro*/, /* getattrofunc tp_getattro; */ + (setattrofunc) pyrna_struct_meta_idprop_setattro, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -4660,7 +4660,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -4670,7 +4670,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* richcmpfunc tp_richcompare; */ + NULL, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ 0, /* long tp_weaklistoffset; */ @@ -4681,9 +4681,9 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -4691,7 +4691,7 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ @@ -4709,45 +4709,45 @@ PyTypeObject pyrna_struct_meta_idprop_Type= { /*-----------------------BPy_StructRNA method def------------------------------*/ PyTypeObject pyrna_struct_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_struct", /* tp_name */ - sizeof(BPy_StructRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_struct", /* tp_name */ + sizeof(BPy_StructRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor) pyrna_struct_dealloc,/* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ - NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - (reprfunc) pyrna_struct_repr, /* tp_repr */ + NULL, /* getattrfunc tp_getattr; */ + NULL, /* setattrfunc tp_setattr; */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + (reprfunc) pyrna_struct_repr, /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - &pyrna_struct_as_sequence, /* PySequenceMethods *tp_as_sequence; */ - &pyrna_struct_as_mapping, /* PyMappingMethods *tp_as_mapping; */ + &pyrna_struct_as_sequence, /* PySequenceMethods *tp_as_sequence; */ + &pyrna_struct_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - (hashfunc) pyrna_struct_hash, /* hashfunc tp_hash; */ - NULL, /* ternaryfunc tp_call; */ + (hashfunc) pyrna_struct_hash, /* hashfunc tp_hash; */ + NULL, /* ternaryfunc tp_call; */ (reprfunc) pyrna_struct_str, /* reprfunc tp_str; */ - (getattrofunc) pyrna_struct_getattro, /* getattrofunc tp_getattro; */ - (setattrofunc) pyrna_struct_setattro, /* setattrofunc tp_setattro; */ + (getattrofunc) pyrna_struct_getattro, /* getattrofunc tp_getattro; */ + (setattrofunc) pyrna_struct_setattro, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ /*** Flags to define presence of optional/expanded features ***/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* long tp_flags; */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ #ifdef USE_PYRNA_STRUCT_REFERENCE - (traverseproc) pyrna_struct_traverse, /* traverseproc tp_traverse; */ + (traverseproc) pyrna_struct_traverse, /* traverseproc tp_traverse; */ /* delete references to contained objects */ - (inquiry)pyrna_struct_clear, /* inquiry tp_clear; */ + (inquiry)pyrna_struct_clear, /* inquiry tp_clear; */ #else NULL, /* traverseproc tp_traverse; */ @@ -4757,11 +4757,11 @@ PyTypeObject pyrna_struct_Type= { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - (richcmpfunc)pyrna_struct_richcmp, /* richcmpfunc tp_richcompare; */ + (richcmpfunc)pyrna_struct_richcmp, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS - offsetof(BPy_StructRNA, in_weakreflist), /* long tp_weaklistoffset; */ + offsetof(BPy_StructRNA, in_weakreflist), /* long tp_weaklistoffset; */ #else 0, #endif @@ -4771,9 +4771,9 @@ PyTypeObject pyrna_struct_Type= { NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - pyrna_struct_methods, /* struct PyMethodDef *tp_methods; */ + pyrna_struct_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - pyrna_struct_getseters, /* struct PyGetSetDef *tp_getset; */ + pyrna_struct_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -4781,7 +4781,7 @@ PyTypeObject pyrna_struct_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - pyrna_struct_new, /* newfunc tp_new; */ + pyrna_struct_new, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ @@ -4798,32 +4798,32 @@ PyTypeObject pyrna_struct_Type= { /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_prop_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_prop", /* tp_name */ - sizeof(BPy_PropertyRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_prop", /* tp_name */ + sizeof(BPy_PropertyRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor) pyrna_prop_dealloc, /* tp_dealloc */ - NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - (reprfunc) pyrna_prop_repr, /* tp_repr */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + (reprfunc) pyrna_prop_repr, /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - (hashfunc) pyrna_prop_hash, /* hashfunc tp_hash; */ + (hashfunc) pyrna_prop_hash, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ (reprfunc) pyrna_prop_str, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - NULL, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -4831,7 +4831,7 @@ PyTypeObject pyrna_prop_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -4852,11 +4852,11 @@ PyTypeObject pyrna_prop_Type= { /*** Added in release 2.2 ***/ /* Iterators */ - NULL, /* getiterfunc tp_iter; */ + NULL, /* getiterfunc tp_iter; */ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - pyrna_prop_methods, /* struct PyMethodDef *tp_methods; */ + pyrna_prop_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ pyrna_prop_getseters, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ @@ -4866,7 +4866,7 @@ PyTypeObject pyrna_prop_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - pyrna_prop_new, /* newfunc tp_new; */ + pyrna_prop_new, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ @@ -4888,34 +4888,34 @@ PyTypeObject pyrna_prop_array_Type= { /* methods */ (destructor)pyrna_prop_array_dealloc, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ NULL,/* subclassed */ /* tp_repr */ /* Method suites for standard classes */ - &pyrna_prop_array_as_number, /* PyNumberMethods *tp_as_number; */ - &pyrna_prop_array_as_sequence, /* PySequenceMethods *tp_as_sequence; */ - &pyrna_prop_array_as_mapping, /* PyMappingMethods *tp_as_mapping; */ + &pyrna_prop_array_as_number, /* PyNumberMethods *tp_as_number; */ + &pyrna_prop_array_as_sequence, /* PySequenceMethods *tp_as_sequence; */ + &pyrna_prop_array_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + NULL, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - (getattrofunc) pyrna_prop_array_getattro, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + (getattrofunc) pyrna_prop_array_getattro, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ /*** Flags to define presence of optional/expanded features ***/ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -4925,7 +4925,7 @@ PyTypeObject pyrna_prop_array_Type= { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ + NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS @@ -4939,22 +4939,22 @@ PyTypeObject pyrna_prop_array_Type= { NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - pyrna_prop_array_methods, /* struct PyMethodDef *tp_methods; */ + pyrna_prop_array_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ - &pyrna_prop_Type, /* struct _typeobject *tp_base; */ + NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ + &pyrna_prop_Type, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrsetfunc tp_descr_set; */ 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ NULL, /* inquiry tp_is_gc; */ - NULL, /* PyObject *tp_bases; */ + NULL, /* PyObject *tp_bases; */ /* method resolution order */ NULL, /* PyObject *tp_mro; */ NULL, /* PyObject *tp_cache; */ @@ -4965,32 +4965,32 @@ PyTypeObject pyrna_prop_array_Type= { PyTypeObject pyrna_prop_collection_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_prop_collection", /* tp_name */ - sizeof(BPy_PropertyRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_prop_collection", /* tp_name */ + sizeof(BPy_PropertyRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)pyrna_prop_dealloc, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ NULL, /* subclassed */ /* tp_repr */ /* Method suites for standard classes */ &pyrna_prop_collection_as_number, /* PyNumberMethods *tp_as_number; */ - &pyrna_prop_collection_as_sequence, /* PySequenceMethods *tp_as_sequence; */ - &pyrna_prop_collection_as_mapping, /* PyMappingMethods *tp_as_mapping; */ + &pyrna_prop_collection_as_sequence, /* PySequenceMethods *tp_as_sequence; */ + &pyrna_prop_collection_as_mapping, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + NULL, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - (getattrofunc) pyrna_prop_collection_getattro, /* getattrofunc tp_getattro; */ - (setattrofunc) pyrna_prop_collection_setattro, /* setattrofunc tp_setattro; */ + (getattrofunc) pyrna_prop_collection_getattro, /* getattrofunc tp_getattro; */ + (setattrofunc) pyrna_prop_collection_setattro, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -4998,7 +4998,7 @@ PyTypeObject pyrna_prop_collection_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -5012,33 +5012,33 @@ PyTypeObject pyrna_prop_collection_Type= { /*** weak reference enabler ***/ #ifdef USE_WEAKREFS - offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */ + offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */ #else 0, #endif /*** Added in release 2.2 ***/ /* Iterators */ - (getiterfunc)pyrna_prop_collection_iter, /* getiterfunc tp_iter; */ + (getiterfunc)pyrna_prop_collection_iter, /* getiterfunc tp_iter; */ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - pyrna_prop_collection_methods, /* struct PyMethodDef *tp_methods; */ + pyrna_prop_collection_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ - &pyrna_prop_Type, /* struct _typeobject *tp_base; */ + NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ + &pyrna_prop_Type, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrsetfunc tp_descr_set; */ 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ NULL, /* inquiry tp_is_gc; */ - NULL, /* PyObject *tp_bases; */ + NULL, /* PyObject *tp_bases; */ /* method resolution order */ NULL, /* PyObject *tp_mro; */ NULL, /* PyObject *tp_cache; */ @@ -5050,32 +5050,32 @@ PyTypeObject pyrna_prop_collection_Type= { /* only for add/remove/move methods */ static PyTypeObject pyrna_prop_collection_idprop_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_prop_collection_idprop", /* tp_name */ - sizeof(BPy_PropertyRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_prop_collection_idprop", /* tp_name */ + sizeof(BPy_PropertyRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)pyrna_prop_dealloc, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - NULL, /* subclassed */ /* tp_repr */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* subclassed */ /* tp_repr */ /* Method suites for standard classes */ - NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PyNumberMethods *tp_as_number; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + NULL, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - NULL, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -5083,7 +5083,7 @@ static PyTypeObject pyrna_prop_collection_idprop_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -5097,33 +5097,33 @@ static PyTypeObject pyrna_prop_collection_idprop_Type= { /*** weak reference enabler ***/ #ifdef USE_WEAKREFS - offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */ + offsetof(BPy_PropertyRNA, in_weakreflist), /* long tp_weaklistoffset; */ #else 0, #endif /*** Added in release 2.2 ***/ /* Iterators */ - NULL, /* getiterfunc tp_iter; */ + NULL, /* getiterfunc tp_iter; */ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ pyrna_prop_collection_idprop_methods, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ - &pyrna_prop_collection_Type, /* struct _typeobject *tp_base; */ + NULL /*pyrna_prop_getseters*/, /* struct PyGetSetDef *tp_getset; */ + &pyrna_prop_collection_Type,/* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ NULL, /* descrsetfunc tp_descr_set; */ 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ NULL, /* inquiry tp_is_gc; */ - NULL, /* PyObject *tp_bases; */ + NULL, /* PyObject *tp_bases; */ /* method resolution order */ NULL, /* PyObject *tp_mro; */ NULL, /* PyObject *tp_cache; */ @@ -5135,32 +5135,32 @@ static PyTypeObject pyrna_prop_collection_idprop_Type= { /*-----------------------BPy_PropertyRNA method def------------------------------*/ PyTypeObject pyrna_func_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_func", /* tp_name */ - sizeof(BPy_FunctionRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_func", /* tp_name */ + sizeof(BPy_FunctionRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ - NULL, /* tp_dealloc */ - NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* tp_dealloc */ + NULL, /* printfunc tp_print; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - (reprfunc) pyrna_func_repr, /* tp_repr */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + (reprfunc) pyrna_func_repr, /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ - (ternaryfunc)pyrna_func_call, /* ternaryfunc tp_call; */ - NULL, /* reprfunc tp_str; */ + NULL, /* hashfunc tp_hash; */ + (ternaryfunc)pyrna_func_call, /* ternaryfunc tp_call; */ + NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - NULL, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + NULL, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -5168,7 +5168,7 @@ PyTypeObject pyrna_func_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -5178,7 +5178,7 @@ PyTypeObject pyrna_func_Type= { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* richcmpfunc tp_richcompare; */ + NULL, /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS @@ -5189,13 +5189,13 @@ PyTypeObject pyrna_func_Type= { /*** Added in release 2.2 ***/ /* Iterators */ - NULL, /* getiterfunc tp_iter; */ + NULL, /* getiterfunc tp_iter; */ NULL, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -5203,7 +5203,7 @@ PyTypeObject pyrna_func_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ @@ -5231,32 +5231,32 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA * PyTypeObject pyrna_prop_collection_iter_Type= { PyVarObject_HEAD_INIT(NULL, 0) - "bpy_prop_collection_iter", /* tp_name */ - sizeof(BPy_PropertyCollectionIterRNA), /* tp_basicsize */ - 0, /* tp_itemsize */ + "bpy_prop_collection_iter", /* tp_name */ + sizeof(BPy_PropertyCollectionIterRNA), /* tp_basicsize */ + 0, /* tp_itemsize */ /* methods */ (destructor)pyrna_prop_collection_iter_dealloc, /* tp_dealloc */ NULL, /* printfunc tp_print; */ - NULL, /* getattrfunc tp_getattr; */ + NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ - NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ + NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ NULL,/* subclassed */ /* tp_repr */ /* Method suites for standard classes */ NULL, /* PyNumberMethods *tp_as_number; */ - NULL, /* PySequenceMethods *tp_as_sequence; */ - NULL, /* PyMappingMethods *tp_as_mapping; */ + NULL, /* PySequenceMethods *tp_as_sequence; */ + NULL, /* PyMappingMethods *tp_as_mapping; */ /* More standard operations (here for binary compatibility) */ - NULL, /* hashfunc tp_hash; */ + NULL, /* hashfunc tp_hash; */ NULL, /* ternaryfunc tp_call; */ NULL, /* reprfunc tp_str; */ /* will only use these if this is a subtype of a py class */ - PyObject_GenericGetAttr, /* getattrofunc tp_getattro; */ - NULL, /* setattrofunc tp_setattro; */ + PyObject_GenericGetAttr, /* getattrofunc tp_getattro; */ + NULL, /* setattrofunc tp_setattro; */ /* Functions to access object as input/output buffer */ NULL, /* PyBufferProcs *tp_as_buffer; */ @@ -5264,7 +5264,7 @@ PyTypeObject pyrna_prop_collection_iter_Type= { /*** Flags to define presence of optional/expanded features ***/ Py_TPFLAGS_DEFAULT, /* long tp_flags; */ - NULL, /* char *tp_doc; Documentation string */ + NULL, /* char *tp_doc; Documentation string */ /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ NULL, /* traverseproc tp_traverse; */ @@ -5278,19 +5278,19 @@ PyTypeObject pyrna_prop_collection_iter_Type= { /*** weak reference enabler ***/ #ifdef USE_WEAKREFS - offsetof(BPy_PropertyCollectionIterRNA, in_weakreflist), /* long tp_weaklistoffset; */ + offsetof(BPy_PropertyCollectionIterRNA, in_weakreflist), /* long tp_weaklistoffset; */ #else 0, #endif /*** Added in release 2.2 ***/ /* Iterators */ - PyObject_SelfIter, /* getiterfunc tp_iter; */ - (iternextfunc) pyrna_prop_collection_iter_next, /* iternextfunc tp_iternext; */ + PyObject_SelfIter, /* getiterfunc tp_iter; */ + (iternextfunc) pyrna_prop_collection_iter_next, /* iternextfunc tp_iternext; */ /*** Attribute descriptor and subclassing stuff ***/ - NULL, /* struct PyMethodDef *tp_methods; */ + NULL, /* struct PyMethodDef *tp_methods; */ NULL, /* struct PyMemberDef *tp_members; */ - NULL, /* struct PyGetSetDef *tp_getset; */ + NULL, /* struct PyGetSetDef *tp_getset; */ NULL, /* struct _typeobject *tp_base; */ NULL, /* PyObject *tp_dict; */ NULL, /* descrgetfunc tp_descr_get; */ @@ -5298,12 +5298,12 @@ PyTypeObject pyrna_prop_collection_iter_Type= { 0, /* long tp_dictoffset; */ NULL, /* initproc tp_init; */ NULL, /* allocfunc tp_alloc; */ - NULL, /* newfunc tp_new; */ + NULL, /* newfunc tp_new; */ /* Low-level free-memory routine */ NULL, /* freefunc tp_free; */ /* For PyObject_IS_GC */ NULL, /* inquiry tp_is_gc; */ - NULL, /* PyObject *tp_bases; */ + NULL, /* PyObject *tp_bases; */ /* method resolution order */ NULL, /* PyObject *tp_mro; */ NULL, /* PyObject *tp_cache; */ diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h index 67a2279d824..7e9a57a0fe7 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h @@ -51,197 +51,195 @@ /** Base Class for Blender specific inputdevices. Blender specific inputdevices are used when the gameengine is running in embedded mode instead of standalone mode. */ -class BL_BlenderInputDevice : public SCA_IInputDevice +class BL_BlenderInputDevice : public SCA_IInputDevice { // this map is Blender specific: a conversion between blender and ketsji enums std::map m_reverseKeyTranslateTable; public: - BL_BlenderInputDevice() - { - - /* The reverse table. In order to not confuse ourselves, we */ - /* immediately convert all events that come in to KX codes. */ - m_reverseKeyTranslateTable[LEFTMOUSE ] = KX_LEFTMOUSE ; - m_reverseKeyTranslateTable[MIDDLEMOUSE ] = KX_MIDDLEMOUSE ; - m_reverseKeyTranslateTable[RIGHTMOUSE ] = KX_RIGHTMOUSE ; - m_reverseKeyTranslateTable[WHEELUPMOUSE ] = KX_WHEELUPMOUSE ; - m_reverseKeyTranslateTable[WHEELDOWNMOUSE ] = KX_WHEELDOWNMOUSE ; - m_reverseKeyTranslateTable[MOUSEX ] = KX_MOUSEX ; - m_reverseKeyTranslateTable[MOUSEY ] = KX_MOUSEY ; - - // TIMERS - - m_reverseKeyTranslateTable[TIMER0 ] = KX_TIMER0 ; - m_reverseKeyTranslateTable[TIMER1 ] = KX_TIMER1 ; - m_reverseKeyTranslateTable[TIMER2 ] = KX_TIMER2 ; - - // SYSTEM -#if 0 - /* **** XXX **** */ - m_reverseKeyTranslateTable[KEYBD ] = KX_KEYBD ; - m_reverseKeyTranslateTable[RAWKEYBD ] = KX_RAWKEYBD ; - m_reverseKeyTranslateTable[REDRAW ] = KX_REDRAW ; - m_reverseKeyTranslateTable[INPUTCHANGE ] = KX_INPUTCHANGE ; - m_reverseKeyTranslateTable[QFULL ] = KX_QFULL ; - m_reverseKeyTranslateTable[WINFREEZE ] = KX_WINFREEZE ; - m_reverseKeyTranslateTable[WINTHAW ] = KX_WINTHAW ; - m_reverseKeyTranslateTable[WINCLOSE ] = KX_WINCLOSE ; - m_reverseKeyTranslateTable[WINQUIT ] = KX_WINQUIT ; - m_reverseKeyTranslateTable[Q_FIRSTTIME ] = KX_Q_FIRSTTIME ; - /* **** XXX **** */ -#endif - // standard keyboard - - m_reverseKeyTranslateTable[AKEY ] = KX_AKEY ; - m_reverseKeyTranslateTable[BKEY ] = KX_BKEY ; - m_reverseKeyTranslateTable[CKEY ] = KX_CKEY ; - m_reverseKeyTranslateTable[DKEY ] = KX_DKEY ; - m_reverseKeyTranslateTable[EKEY ] = KX_EKEY ; - m_reverseKeyTranslateTable[FKEY ] = KX_FKEY ; - m_reverseKeyTranslateTable[GKEY ] = KX_GKEY ; -//XXX clean up + BL_BlenderInputDevice() + { + + /* The reverse table. In order to not confuse ourselves, we */ + /* immediately convert all events that come in to KX codes. */ + m_reverseKeyTranslateTable[LEFTMOUSE ] = KX_LEFTMOUSE; + m_reverseKeyTranslateTable[MIDDLEMOUSE ] = KX_MIDDLEMOUSE; + m_reverseKeyTranslateTable[RIGHTMOUSE ] = KX_RIGHTMOUSE; + m_reverseKeyTranslateTable[WHEELUPMOUSE ] = KX_WHEELUPMOUSE; + m_reverseKeyTranslateTable[WHEELDOWNMOUSE ] = KX_WHEELDOWNMOUSE; + m_reverseKeyTranslateTable[MOUSEX ] = KX_MOUSEX; + m_reverseKeyTranslateTable[MOUSEY ] = KX_MOUSEY; + + // TIMERS + + m_reverseKeyTranslateTable[TIMER0 ] = KX_TIMER0; + m_reverseKeyTranslateTable[TIMER1 ] = KX_TIMER1; + m_reverseKeyTranslateTable[TIMER2 ] = KX_TIMER2; + + // SYSTEM +#if 0 + /* **** XXX **** */ + m_reverseKeyTranslateTable[KEYBD ] = KX_KEYBD; + m_reverseKeyTranslateTable[RAWKEYBD ] = KX_RAWKEYBD; + m_reverseKeyTranslateTable[REDRAW ] = KX_REDRAW; + m_reverseKeyTranslateTable[INPUTCHANGE ] = KX_INPUTCHANGE; + m_reverseKeyTranslateTable[QFULL ] = KX_QFULL; + m_reverseKeyTranslateTable[WINFREEZE ] = KX_WINFREEZE; + m_reverseKeyTranslateTable[WINTHAW ] = KX_WINTHAW; + m_reverseKeyTranslateTable[WINCLOSE ] = KX_WINCLOSE; + m_reverseKeyTranslateTable[WINQUIT ] = KX_WINQUIT; + m_reverseKeyTranslateTable[Q_FIRSTTIME ] = KX_Q_FIRSTTIME; + /* **** XXX **** */ +#endif + // standard keyboard + + m_reverseKeyTranslateTable[AKEY ] = KX_AKEY; + m_reverseKeyTranslateTable[BKEY ] = KX_BKEY; + m_reverseKeyTranslateTable[CKEY ] = KX_CKEY; + m_reverseKeyTranslateTable[DKEY ] = KX_DKEY; + m_reverseKeyTranslateTable[EKEY ] = KX_EKEY; + m_reverseKeyTranslateTable[FKEY ] = KX_FKEY; + m_reverseKeyTranslateTable[GKEY ] = KX_GKEY; + //XXX clean up #ifdef WIN32 #define HKEY 'h' #endif - m_reverseKeyTranslateTable[HKEY ] = KX_HKEY ; -//XXX clean up + m_reverseKeyTranslateTable[HKEY ] = KX_HKEY; + //XXX clean up #ifdef WIN32 #undef HKEY #endif - m_reverseKeyTranslateTable[IKEY ] = KX_IKEY ; - m_reverseKeyTranslateTable[JKEY ] = KX_JKEY ; - m_reverseKeyTranslateTable[KKEY ] = KX_KKEY ; - m_reverseKeyTranslateTable[LKEY ] = KX_LKEY ; - m_reverseKeyTranslateTable[MKEY ] = KX_MKEY ; - m_reverseKeyTranslateTable[NKEY ] = KX_NKEY ; - m_reverseKeyTranslateTable[OKEY ] = KX_OKEY ; - m_reverseKeyTranslateTable[PKEY ] = KX_PKEY ; - m_reverseKeyTranslateTable[QKEY ] = KX_QKEY ; - m_reverseKeyTranslateTable[RKEY ] = KX_RKEY ; - m_reverseKeyTranslateTable[SKEY ] = KX_SKEY ; - m_reverseKeyTranslateTable[TKEY ] = KX_TKEY ; - m_reverseKeyTranslateTable[UKEY ] = KX_UKEY ; - m_reverseKeyTranslateTable[VKEY ] = KX_VKEY ; - m_reverseKeyTranslateTable[WKEY ] = KX_WKEY ; - m_reverseKeyTranslateTable[XKEY ] = KX_XKEY ; - m_reverseKeyTranslateTable[YKEY ] = KX_YKEY ; - m_reverseKeyTranslateTable[ZKEY ] = KX_ZKEY ; - - m_reverseKeyTranslateTable[ZEROKEY ] = KX_ZEROKEY ; - m_reverseKeyTranslateTable[ONEKEY ] = KX_ONEKEY ; - m_reverseKeyTranslateTable[TWOKEY ] = KX_TWOKEY ; - m_reverseKeyTranslateTable[THREEKEY ] = KX_THREEKEY ; - m_reverseKeyTranslateTable[FOURKEY ] = KX_FOURKEY ; - m_reverseKeyTranslateTable[FIVEKEY ] = KX_FIVEKEY ; - m_reverseKeyTranslateTable[SIXKEY ] = KX_SIXKEY ; - m_reverseKeyTranslateTable[SEVENKEY ] = KX_SEVENKEY ; - m_reverseKeyTranslateTable[EIGHTKEY ] = KX_EIGHTKEY ; - m_reverseKeyTranslateTable[NINEKEY ] = KX_NINEKEY ; - - m_reverseKeyTranslateTable[CAPSLOCKKEY ] = KX_CAPSLOCKKEY ; - - m_reverseKeyTranslateTable[LEFTCTRLKEY ] = KX_LEFTCTRLKEY ; - m_reverseKeyTranslateTable[LEFTALTKEY ] = KX_LEFTALTKEY ; - m_reverseKeyTranslateTable[RIGHTALTKEY ] = KX_RIGHTALTKEY ; - m_reverseKeyTranslateTable[RIGHTCTRLKEY ] = KX_RIGHTCTRLKEY ; - m_reverseKeyTranslateTable[RIGHTSHIFTKEY ] = KX_RIGHTSHIFTKEY ; - m_reverseKeyTranslateTable[LEFTSHIFTKEY ] = KX_LEFTSHIFTKEY ; - - m_reverseKeyTranslateTable[ESCKEY ] = KX_ESCKEY ; - m_reverseKeyTranslateTable[TABKEY ] = KX_TABKEY ; - m_reverseKeyTranslateTable[RETKEY ] = KX_RETKEY ; - m_reverseKeyTranslateTable[SPACEKEY ] = KX_SPACEKEY ; - m_reverseKeyTranslateTable[LINEFEEDKEY ] = KX_LINEFEEDKEY ; - m_reverseKeyTranslateTable[BACKSPACEKEY ] = KX_BACKSPACEKEY ; - m_reverseKeyTranslateTable[DELKEY ] = KX_DELKEY ; - m_reverseKeyTranslateTable[SEMICOLONKEY ] = KX_SEMICOLONKEY ; - m_reverseKeyTranslateTable[PERIODKEY ] = KX_PERIODKEY ; - m_reverseKeyTranslateTable[COMMAKEY ] = KX_COMMAKEY ; - m_reverseKeyTranslateTable[QUOTEKEY ] = KX_QUOTEKEY ; - m_reverseKeyTranslateTable[ACCENTGRAVEKEY ] = KX_ACCENTGRAVEKEY ; - m_reverseKeyTranslateTable[MINUSKEY ] = KX_MINUSKEY ; - m_reverseKeyTranslateTable[SLASHKEY ] = KX_SLASHKEY ; - m_reverseKeyTranslateTable[BACKSLASHKEY ] = KX_BACKSLASHKEY ; - m_reverseKeyTranslateTable[EQUALKEY ] = KX_EQUALKEY ; - m_reverseKeyTranslateTable[LEFTBRACKETKEY ] = KX_LEFTBRACKETKEY ; - m_reverseKeyTranslateTable[RIGHTBRACKETKEY ] = KX_RIGHTBRACKETKEY ; - - m_reverseKeyTranslateTable[LEFTARROWKEY ] = KX_LEFTARROWKEY ; - m_reverseKeyTranslateTable[DOWNARROWKEY ] = KX_DOWNARROWKEY ; - m_reverseKeyTranslateTable[RIGHTARROWKEY ] = KX_RIGHTARROWKEY ; - m_reverseKeyTranslateTable[UPARROWKEY ] = KX_UPARROWKEY ; - - m_reverseKeyTranslateTable[PAD2 ] = KX_PAD2 ; - m_reverseKeyTranslateTable[PAD4 ] = KX_PAD4 ; - m_reverseKeyTranslateTable[PAD6 ] = KX_PAD6 ; - m_reverseKeyTranslateTable[PAD8 ] = KX_PAD8 ; - - m_reverseKeyTranslateTable[PAD1 ] = KX_PAD1 ; - m_reverseKeyTranslateTable[PAD3 ] = KX_PAD3 ; - m_reverseKeyTranslateTable[PAD5 ] = KX_PAD5 ; - m_reverseKeyTranslateTable[PAD7 ] = KX_PAD7 ; - m_reverseKeyTranslateTable[PAD9 ] = KX_PAD9 ; - - m_reverseKeyTranslateTable[PADPERIOD ] = KX_PADPERIOD ; - m_reverseKeyTranslateTable[PADSLASHKEY ] = KX_PADSLASHKEY ; - m_reverseKeyTranslateTable[PADASTERKEY ] = KX_PADASTERKEY ; - - - m_reverseKeyTranslateTable[PAD0 ] = KX_PAD0 ; - m_reverseKeyTranslateTable[PADMINUS ] = KX_PADMINUS ; - m_reverseKeyTranslateTable[PADENTER ] = KX_PADENTER ; - m_reverseKeyTranslateTable[PADPLUSKEY ] = KX_PADPLUSKEY ; - - - m_reverseKeyTranslateTable[F1KEY ] = KX_F1KEY ; - m_reverseKeyTranslateTable[F2KEY ] = KX_F2KEY ; - m_reverseKeyTranslateTable[F3KEY ] = KX_F3KEY ; - m_reverseKeyTranslateTable[F4KEY ] = KX_F4KEY ; - m_reverseKeyTranslateTable[F5KEY ] = KX_F5KEY ; - m_reverseKeyTranslateTable[F6KEY ] = KX_F6KEY ; - m_reverseKeyTranslateTable[F7KEY ] = KX_F7KEY ; - m_reverseKeyTranslateTable[F8KEY ] = KX_F8KEY ; - m_reverseKeyTranslateTable[F9KEY ] = KX_F9KEY ; - m_reverseKeyTranslateTable[F10KEY ] = KX_F10KEY ; - m_reverseKeyTranslateTable[F11KEY ] = KX_F11KEY ; - m_reverseKeyTranslateTable[F12KEY ] = KX_F12KEY ; - m_reverseKeyTranslateTable[F13KEY ] = KX_F13KEY ; - m_reverseKeyTranslateTable[F14KEY ] = KX_F14KEY ; - m_reverseKeyTranslateTable[F15KEY ] = KX_F15KEY ; - m_reverseKeyTranslateTable[F16KEY ] = KX_F16KEY ; - m_reverseKeyTranslateTable[F17KEY ] = KX_F17KEY ; - m_reverseKeyTranslateTable[F18KEY ] = KX_F18KEY ; - m_reverseKeyTranslateTable[F19KEY ] = KX_F19KEY ; - - m_reverseKeyTranslateTable[PAUSEKEY ] = KX_PAUSEKEY ; - m_reverseKeyTranslateTable[INSERTKEY ] = KX_INSERTKEY ; - m_reverseKeyTranslateTable[HOMEKEY ] = KX_HOMEKEY ; - m_reverseKeyTranslateTable[PAGEUPKEY ] = KX_PAGEUPKEY ; - m_reverseKeyTranslateTable[PAGEDOWNKEY ] = KX_PAGEDOWNKEY ; - m_reverseKeyTranslateTable[ENDKEY ] = KX_ENDKEY ; - - - } + m_reverseKeyTranslateTable[IKEY ] = KX_IKEY; + m_reverseKeyTranslateTable[JKEY ] = KX_JKEY; + m_reverseKeyTranslateTable[KKEY ] = KX_KKEY; + m_reverseKeyTranslateTable[LKEY ] = KX_LKEY; + m_reverseKeyTranslateTable[MKEY ] = KX_MKEY; + m_reverseKeyTranslateTable[NKEY ] = KX_NKEY; + m_reverseKeyTranslateTable[OKEY ] = KX_OKEY; + m_reverseKeyTranslateTable[PKEY ] = KX_PKEY; + m_reverseKeyTranslateTable[QKEY ] = KX_QKEY; + m_reverseKeyTranslateTable[RKEY ] = KX_RKEY; + m_reverseKeyTranslateTable[SKEY ] = KX_SKEY; + m_reverseKeyTranslateTable[TKEY ] = KX_TKEY; + m_reverseKeyTranslateTable[UKEY ] = KX_UKEY; + m_reverseKeyTranslateTable[VKEY ] = KX_VKEY; + m_reverseKeyTranslateTable[WKEY ] = KX_WKEY; + m_reverseKeyTranslateTable[XKEY ] = KX_XKEY; + m_reverseKeyTranslateTable[YKEY ] = KX_YKEY; + m_reverseKeyTranslateTable[ZKEY ] = KX_ZKEY; + + m_reverseKeyTranslateTable[ZEROKEY ] = KX_ZEROKEY; + m_reverseKeyTranslateTable[ONEKEY ] = KX_ONEKEY; + m_reverseKeyTranslateTable[TWOKEY ] = KX_TWOKEY; + m_reverseKeyTranslateTable[THREEKEY ] = KX_THREEKEY; + m_reverseKeyTranslateTable[FOURKEY ] = KX_FOURKEY; + m_reverseKeyTranslateTable[FIVEKEY ] = KX_FIVEKEY; + m_reverseKeyTranslateTable[SIXKEY ] = KX_SIXKEY; + m_reverseKeyTranslateTable[SEVENKEY ] = KX_SEVENKEY; + m_reverseKeyTranslateTable[EIGHTKEY ] = KX_EIGHTKEY; + m_reverseKeyTranslateTable[NINEKEY ] = KX_NINEKEY; + + m_reverseKeyTranslateTable[CAPSLOCKKEY ] = KX_CAPSLOCKKEY; + + m_reverseKeyTranslateTable[LEFTCTRLKEY ] = KX_LEFTCTRLKEY; + m_reverseKeyTranslateTable[LEFTALTKEY ] = KX_LEFTALTKEY; + m_reverseKeyTranslateTable[RIGHTALTKEY ] = KX_RIGHTALTKEY; + m_reverseKeyTranslateTable[RIGHTCTRLKEY ] = KX_RIGHTCTRLKEY; + m_reverseKeyTranslateTable[RIGHTSHIFTKEY ] = KX_RIGHTSHIFTKEY; + m_reverseKeyTranslateTable[LEFTSHIFTKEY ] = KX_LEFTSHIFTKEY; + + m_reverseKeyTranslateTable[ESCKEY ] = KX_ESCKEY; + m_reverseKeyTranslateTable[TABKEY ] = KX_TABKEY; + m_reverseKeyTranslateTable[RETKEY ] = KX_RETKEY; + m_reverseKeyTranslateTable[SPACEKEY ] = KX_SPACEKEY; + m_reverseKeyTranslateTable[LINEFEEDKEY ] = KX_LINEFEEDKEY; + m_reverseKeyTranslateTable[BACKSPACEKEY ] = KX_BACKSPACEKEY; + m_reverseKeyTranslateTable[DELKEY ] = KX_DELKEY; + m_reverseKeyTranslateTable[SEMICOLONKEY ] = KX_SEMICOLONKEY; + m_reverseKeyTranslateTable[PERIODKEY ] = KX_PERIODKEY; + m_reverseKeyTranslateTable[COMMAKEY ] = KX_COMMAKEY; + m_reverseKeyTranslateTable[QUOTEKEY ] = KX_QUOTEKEY; + m_reverseKeyTranslateTable[ACCENTGRAVEKEY ] = KX_ACCENTGRAVEKEY; + m_reverseKeyTranslateTable[MINUSKEY ] = KX_MINUSKEY; + m_reverseKeyTranslateTable[SLASHKEY ] = KX_SLASHKEY; + m_reverseKeyTranslateTable[BACKSLASHKEY ] = KX_BACKSLASHKEY; + m_reverseKeyTranslateTable[EQUALKEY ] = KX_EQUALKEY; + m_reverseKeyTranslateTable[LEFTBRACKETKEY ] = KX_LEFTBRACKETKEY; + m_reverseKeyTranslateTable[RIGHTBRACKETKEY ] = KX_RIGHTBRACKETKEY; + + m_reverseKeyTranslateTable[LEFTARROWKEY ] = KX_LEFTARROWKEY; + m_reverseKeyTranslateTable[DOWNARROWKEY ] = KX_DOWNARROWKEY; + m_reverseKeyTranslateTable[RIGHTARROWKEY ] = KX_RIGHTARROWKEY; + m_reverseKeyTranslateTable[UPARROWKEY ] = KX_UPARROWKEY; + + m_reverseKeyTranslateTable[PAD2 ] = KX_PAD2; + m_reverseKeyTranslateTable[PAD4 ] = KX_PAD4; + m_reverseKeyTranslateTable[PAD6 ] = KX_PAD6; + m_reverseKeyTranslateTable[PAD8 ] = KX_PAD8; + + m_reverseKeyTranslateTable[PAD1 ] = KX_PAD1; + m_reverseKeyTranslateTable[PAD3 ] = KX_PAD3; + m_reverseKeyTranslateTable[PAD5 ] = KX_PAD5; + m_reverseKeyTranslateTable[PAD7 ] = KX_PAD7; + m_reverseKeyTranslateTable[PAD9 ] = KX_PAD9; + + m_reverseKeyTranslateTable[PADPERIOD ] = KX_PADPERIOD; + m_reverseKeyTranslateTable[PADSLASHKEY ] = KX_PADSLASHKEY; + m_reverseKeyTranslateTable[PADASTERKEY ] = KX_PADASTERKEY; + + + m_reverseKeyTranslateTable[PAD0 ] = KX_PAD0; + m_reverseKeyTranslateTable[PADMINUS ] = KX_PADMINUS; + m_reverseKeyTranslateTable[PADENTER ] = KX_PADENTER; + m_reverseKeyTranslateTable[PADPLUSKEY ] = KX_PADPLUSKEY; + + + m_reverseKeyTranslateTable[F1KEY ] = KX_F1KEY; + m_reverseKeyTranslateTable[F2KEY ] = KX_F2KEY; + m_reverseKeyTranslateTable[F3KEY ] = KX_F3KEY; + m_reverseKeyTranslateTable[F4KEY ] = KX_F4KEY; + m_reverseKeyTranslateTable[F5KEY ] = KX_F5KEY; + m_reverseKeyTranslateTable[F6KEY ] = KX_F6KEY; + m_reverseKeyTranslateTable[F7KEY ] = KX_F7KEY; + m_reverseKeyTranslateTable[F8KEY ] = KX_F8KEY; + m_reverseKeyTranslateTable[F9KEY ] = KX_F9KEY; + m_reverseKeyTranslateTable[F10KEY ] = KX_F10KEY; + m_reverseKeyTranslateTable[F11KEY ] = KX_F11KEY; + m_reverseKeyTranslateTable[F12KEY ] = KX_F12KEY; + m_reverseKeyTranslateTable[F13KEY ] = KX_F13KEY; + m_reverseKeyTranslateTable[F14KEY ] = KX_F14KEY; + m_reverseKeyTranslateTable[F15KEY ] = KX_F15KEY; + m_reverseKeyTranslateTable[F16KEY ] = KX_F16KEY; + m_reverseKeyTranslateTable[F17KEY ] = KX_F17KEY; + m_reverseKeyTranslateTable[F18KEY ] = KX_F18KEY; + m_reverseKeyTranslateTable[F19KEY ] = KX_F19KEY; + + m_reverseKeyTranslateTable[PAUSEKEY ] = KX_PAUSEKEY; + m_reverseKeyTranslateTable[INSERTKEY ] = KX_INSERTKEY; + m_reverseKeyTranslateTable[HOMEKEY ] = KX_HOMEKEY; + m_reverseKeyTranslateTable[PAGEUPKEY ] = KX_PAGEUPKEY; + m_reverseKeyTranslateTable[PAGEDOWNKEY ] = KX_PAGEDOWNKEY; + m_reverseKeyTranslateTable[ENDKEY ] = KX_ENDKEY; + } virtual ~BL_BlenderInputDevice() - { + { - } - - KX_EnumInputs ToNative(unsigned short incode) { + } + + KX_EnumInputs ToNative(unsigned short incode) { return m_reverseKeyTranslateTable[incode]; } virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0; -// virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0; + // virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0; virtual bool ConvertBlenderEvent(unsigned short incode,short val)=0; - + #ifdef WITH_CXX_GUARDEDALLOC public: void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:BL_BlenderInputDevice"); } void operator delete(void *mem) { MEM_freeN(mem); } #endif -}; +}; #endif //__KX_BLENDERINPUTDEVICE diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h index 90466e930fb..0968478ce7e 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.h +++ b/source/gameengine/Converter/BL_MeshDeformer.h @@ -88,7 +88,7 @@ protected: // -- int m_tvtot; BL_DeformableGameObject* m_gameobj; - double m_lastDeformUpdate; + double m_lastDeformUpdate; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h index 655cc9d7aeb..609603ae52b 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.h +++ b/source/gameengine/Converter/BL_ShapeDeformer.h @@ -46,8 +46,8 @@ class BL_ShapeDeformer : public BL_SkinDeformer { public: BL_ShapeDeformer(BL_DeformableGameObject *gameobj, - Object *bmeshobj, - RAS_MeshObject *mesh); + Object *bmeshobj, + RAS_MeshObject *mesh); /* this second constructor is needed for making a mesh deformable on the fly. */ BL_ShapeDeformer(BL_DeformableGameObject *gameobj, diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index ffb9a8ce691..7191730187c 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -679,7 +679,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo) MEM_freeN( tmpicu ); localDel_ipoCurve( tmpicu ); } - } + } } else { ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB); blenderObject->ipo = ipo; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index a84a1419d0d..8fc224fba6f 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -942,7 +942,7 @@ void BL_ConvertActuators(char* maggiename, case ACT_2DFILTER: { bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data; - SCA_2DFilterActuator *tmp = NULL; + SCA_2DFilterActuator *tmp = NULL; RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode; switch(_2dfilter->type) diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h index 7f31c1713f4..82c82ac3be5 100644 --- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h +++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h @@ -52,19 +52,19 @@ private: public: - SCA_2DFilterActuator( - class SCA_IObject* gameobj, - RAS_2DFilterManager::RAS_2DFILTER_MODE type, - short flag, - float float_arg, - int int_arg, - RAS_IRasterizer* rasterizer, - SCA_IScene* scene); + SCA_2DFilterActuator( + class SCA_IObject* gameobj, + RAS_2DFilterManager::RAS_2DFILTER_MODE type, + short flag, + float float_arg, + int int_arg, + RAS_IRasterizer* rasterizer, + SCA_IScene* scene); void SetShaderText(const char *text); - virtual ~SCA_2DFilterActuator(); - virtual bool Update(); + virtual ~SCA_2DFilterActuator(); + virtual bool Update(); - virtual CValue* GetReplica(); + virtual CValue* GetReplica(); }; #endif diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h index 3ccbfea7ed5..739e566237b 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.h +++ b/source/gameengine/GameLogic/SCA_PythonController.h @@ -34,7 +34,7 @@ #ifndef KX_PYTHONCONTROLLER_H #define KX_PYTHONCONTROLLER_H - + #include "SCA_IController.h" #include "SCA_LogicManager.h" #include "BoolValue.h" diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp index d76f3f775a5..c9d11a27c76 100644 --- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp +++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp @@ -207,10 +207,10 @@ bool SCA_RandomActuator::Update() sensible values. The termination condition states two things: 1. s >= 0 is not allowed: to prevent the distro from - getting a bias towards high values. This is a small + getting a bias towards high values. This is a small correction, really, and might also be left out. 2. s == 0 is not allowed: to prevent a division by zero - when renormalising the drawn value to the desired + when renormalising the drawn value to the desired distribution shape. As a side effect, the distro will never yield the exact mean. I am not sure whether this is consistent, since the error diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index c5daae9c963..5bc6093a9ff 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -192,7 +192,7 @@ static LRESULT CALLBACK screenSaverWindowProc(HWND hwnd, UINT uMsg, WPARAM wPara LONG dx = scr_save_mouse_pos.x - pt.x; LONG dy = scr_save_mouse_pos.y - pt.y; if (abs(dx) > SCR_SAVE_MOUSE_MOVE_THRESHOLD - || abs(dy) > SCR_SAVE_MOUSE_MOVE_THRESHOLD) + || abs(dy) > SCR_SAVE_MOUSE_MOVE_THRESHOLD) { close = TRUE; } diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h index ff9131f464e..405e2d52989 100644 --- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h +++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h @@ -43,7 +43,7 @@ class KX_NetworkEventManager : public SCA_EventManager public: KX_NetworkEventManager(class SCA_LogicManager* logicmgr, - class NG_NetworkDeviceInterface *ndi); + class NG_NetworkDeviceInterface *ndi); virtual ~KX_NetworkEventManager (); virtual void NextFrame(); @@ -51,7 +51,7 @@ public: SCA_LogicManager* GetLogicManager() { return m_logicmgr; } class NG_NetworkDeviceInterface* GetNetworkDevice() { - return m_ndi; } + return m_ndi; } }; #endif //KX_NETWORK_EVENTMANAGER_H diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 67178803457..3f6f4bb9099 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -111,7 +111,7 @@ KX_GameObject::KX_GameObject( m_pHitObject(NULL), m_actionManager(NULL), m_isDeformable(false) - #ifdef WITH_PYTHON +#ifdef WITH_PYTHON , m_attr_dict(NULL) #endif { diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index 7289ffc6e29..cb59ef42699 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -237,9 +237,9 @@ bool KX_ObjectActuator::Update() if (m_current_linear_factor > 1.0) m_current_linear_factor = 1.0; linV = m_current_linear_factor * m_linear_velocity; - parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); + parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0); } else { - parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); + parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0); } } } @@ -260,7 +260,7 @@ bool KX_ObjectActuator::Update() if (m_current_angular_factor > 1.0) m_current_angular_factor = 1.0; angV = m_current_angular_factor * m_angular_velocity; - parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); + parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0); } else { parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0); } diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp index d9483083aa1..bd743159950 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp @@ -51,6 +51,6 @@ void KX_OrientationInterpolator::Execute(float currentTime) const { MT_Scalar ss = si*sh; m_target.setValue(cj*ch, sj*sc-cs, sj*cc+ss, - cj*sh, sj*ss+cc, sj*cs-sc, - -sj, cj*si, cj*ci); + cj*sh, sj*ss+cc, sj*cs-sc, + -sj, cj*si, cj*ci); } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 9d0597051ad..d32f267f0e0 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -187,7 +187,7 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c rasty->SetCullFace(true); if ((m_drawingmode & RAS_IRasterizer::KX_LINES) || - (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) + (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME)) rasty->SetLines(true); else rasty->SetLines(false); diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h index c5e96bd7454..bbf0134a859 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.h +++ b/source/gameengine/Ketsji/KX_TrackToActuator.h @@ -57,7 +57,7 @@ class KX_TrackToActuator : public SCA_IActuator public: KX_TrackToActuator(SCA_IObject* gameobj, SCA_IObject *ob, int time, - bool threedee,int trackflag,int upflag); + bool threedee,int trackflag,int upflag); virtual ~KX_TrackToActuator(); virtual CValue* GetReplica() { KX_TrackToActuator* replica = new KX_TrackToActuator(*this); diff --git a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h index 67d0e741507..cb7807a86a6 100644 --- a/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h +++ b/source/gameengine/Network/LoopBackNetwork/NG_LoopBackNetworkDeviceInterface.h @@ -52,8 +52,8 @@ public: virtual void NextFrame(); bool Connect(char *address, unsigned int port, char *password, - unsigned int localport, unsigned int timeout) { - return true;} + unsigned int localport, unsigned int timeout) { + return true;} bool Disconnect(void) {return true;} virtual void SendNetworkMessage(class NG_NetworkMessage* msg); diff --git a/source/gameengine/Network/NG_NetworkDeviceInterface.h b/source/gameengine/Network/NG_NetworkDeviceInterface.h index 6df228680ec..857b4660327 100644 --- a/source/gameengine/Network/NG_NetworkDeviceInterface.h +++ b/source/gameengine/Network/NG_NetworkDeviceInterface.h @@ -64,7 +64,7 @@ public: bool IsOnline(void) { return m_online; } virtual bool Connect(char *address, unsigned int port, char *password, - unsigned int localport, unsigned int timeout)=0; + unsigned int localport, unsigned int timeout)=0; virtual bool Disconnect(void)=0; virtual void SendNetworkMessage(NG_NetworkMessage* msg)=0; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index 08445654916..82acd64161f 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -216,12 +216,12 @@ struct CcdConstructionInfo ///more advanced collision filtering should be done in btCollisionDispatcher::NeedsCollision enum CollisionFilterGroups { - DefaultFilter = 1, - StaticFilter = 2, - KinematicFilter = 4, - DebrisFilter = 8, - SensorFilter = 16, - AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter, + DefaultFilter = 1, + StaticFilter = 2, + KinematicFilter = 4, + DebrisFilter = 8, + SensorFilter = 16, + AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter, }; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 526176481ed..39b2022a1f4 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -2564,8 +2564,8 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl btPlaneSpace1( axisInA, axis1, axis2 ); frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(), - axisInA.y(), axis1.y(), axis2.y(), - axisInA.z(), axis1.z(), axis2.z() ); + axisInA.y(), axis1.y(), axis2.y(), + axisInA.z(), axis1.z(), axis2.z() ); frameInA.setOrigin( pivotInA ); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 18e1282b111..c34a00513bf 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -164,7 +164,7 @@ protected: virtual float getConstraintParam(int constraintId,int param); - virtual void removeConstraint(int constraintid); + virtual void removeConstraint(int constraintid); virtual float getAppliedImpulse(int constraintid); diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index ed18ff0329e..d9a9fbb0d31 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -306,8 +306,8 @@ void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance) if(depth){ glGenTextures(1, (GLuint*)&texname[1]); glBindTexture(GL_TEXTURE_2D, texname[1]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight, - 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight, + 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h index e6254f72511..5657fda4f3c 100644 --- a/source/gameengine/Rasterizer/RAS_CameraData.h +++ b/source/gameengine/Rasterizer/RAS_CameraData.h @@ -49,19 +49,19 @@ struct RAS_CameraData float m_focallength; RAS_CameraData(float lens = 35.0, float scale = 6.0, float clipstart = 0.1, float clipend = 5000.0, bool perspective = true, - float focallength = 3.0, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, - int viewportright = 0, int viewporttop = 0) : - m_lens(lens), - m_scale(scale), - m_clipstart(clipstart), - m_clipend(clipend), - m_perspective(perspective), - m_viewport(viewport), - m_viewportleft(viewportleft), - m_viewportbottom(viewportbottom), - m_viewportright(viewportright), - m_viewporttop(viewporttop), - m_focallength(focallength) + float focallength = 3.0, bool viewport = false, int viewportleft = 0, int viewportbottom = 0, + int viewportright = 0, int viewporttop = 0) : + m_lens(lens), + m_scale(scale), + m_clipstart(clipstart), + m_clipend(clipend), + m_perspective(perspective), + m_viewport(viewport), + m_viewportleft(viewportleft), + m_viewportbottom(viewportbottom), + m_viewportright(viewportright), + m_viewporttop(viewporttop), + m_focallength(focallength) { } }; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h index a277d9835d8..3a3ea57d67b 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h @@ -38,17 +38,17 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + - (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + - sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; + gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] + + (2.0*sample[3]) + sample[4] + (2.0*sample[5]) + + sample[6] + (2.0*sample[7]) + sample[8]) / 13.0; } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h index 6aeff254f77..f486be47f9f 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h @@ -38,17 +38,17 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; - vec4 maxValue = vec4(0.0); + vec4 sample[9]; + vec4 maxValue = vec4(0.0); - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - maxValue = max(sample[i], maxValue); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + maxValue = max(sample[i], maxValue); + } - gl_FragColor = maxValue; + gl_FragColor = maxValue; } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h index 1e9dccaec87..a1755dc0eeb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h @@ -33,22 +33,22 @@ #define __RAS_EROSION2DFILTER const char * ErosionFragmentShader=STRINGIFY( -uniform sampler2D bgl_RenderedTexture; -uniform vec2 bgl_TextureCoordinateOffset[9]; + uniform sampler2D bgl_RenderedTexture; + uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; - vec4 minValue = vec4(1.0); + vec4 sample[9]; + vec4 minValue = vec4(1.0); - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - minValue = min(sample[i], minValue); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + minValue = min(sample[i], minValue); + } - gl_FragColor = minValue; + gl_FragColor = minValue; } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h index c7cfa83a11f..45c94d358ba 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h @@ -38,18 +38,18 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - gl_FragColor = (sample[4] * 8.0) - - (sample[0] + sample[1] + sample[2] + - sample[3] + sample[5] + - sample[6] + sample[7] + sample[8]); + gl_FragColor = (sample[4] * 8.0) - + (sample[0] + sample[1] + sample[2] + + sample[3] + sample[5] + + sample[6] + sample[7] + sample[8]); gl_FragColor = vec4(gl_FragColor.rgb, 1.0); } ); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h index ada53cd751d..8d08d9077cb 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h @@ -38,23 +38,23 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - vec4 horizEdge = sample[2] + sample[5] + sample[8] - - (sample[0] + sample[3] + sample[6]); + vec4 horizEdge = sample[2] + sample[5] + sample[8] - + (sample[0] + sample[3] + sample[6]); - vec4 vertEdge = sample[0] + sample[1] + sample[2] - - (sample[6] + sample[7] + sample[8]); + vec4 vertEdge = sample[0] + sample[1] + sample[2] - + (sample[6] + sample[7] + sample[8]); - gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + - (vertEdge.rgb * vertEdge.rgb)); - gl_FragColor.a = 1.0; + gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + + (vertEdge.rgb * vertEdge.rgb)); + gl_FragColor.a = 1.0; } ); diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h index 0d68bc09c70..a9c827fa9e1 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h @@ -38,18 +38,18 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - gl_FragColor = (sample[4] * 9.0) - - (sample[0] + sample[1] + sample[2] + - sample[3] + sample[5] + - sample[6] + sample[7] + sample[8]); + gl_FragColor = (sample[4] * 9.0) - + (sample[0] + sample[1] + sample[2] + + sample[3] + sample[5] + + sample[6] + sample[7] + sample[8]); } ); #endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h index 0f80f0f22b4..350ce19fafd 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h +++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h @@ -38,23 +38,23 @@ uniform vec2 bgl_TextureCoordinateOffset[9]; void main(void) { - vec4 sample[9]; + vec4 sample[9]; - for (int i = 0; i < 9; i++) - { - sample[i] = texture2D(bgl_RenderedTexture, - gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); - } + for (int i = 0; i < 9; i++) + { + sample[i] = texture2D(bgl_RenderedTexture, + gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]); + } - vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - - (sample[0] + (2.0*sample[3]) + sample[6]); + vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] - + (sample[0] + (2.0*sample[3]) + sample[6]); - vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] - - (sample[6] + (2.0*sample[7]) + sample[8]); + vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] - + (sample[6] + (2.0*sample[7]) + sample[8]); - gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + - (vertEdge.rgb * vertEdge.rgb)); - gl_FragColor.a = 1.0; + gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) + + (vertEdge.rgb * vertEdge.rgb)); + gl_FragColor.a = 1.0; } ); #endif diff --git a/source/gameengine/SceneGraph/SG_DList.h b/source/gameengine/SceneGraph/SG_DList.h index b82e51e0d2f..9e7e514b27a 100644 --- a/source/gameengine/SceneGraph/SG_DList.h +++ b/source/gameengine/SceneGraph/SG_DList.h @@ -134,88 +134,88 @@ public: } }; - SG_DList() - { - m_flink = m_blink = this; - } + SG_DList() + { + m_flink = m_blink = this; + } SG_DList(const SG_DList& other) { - m_flink = m_blink = this; + m_flink = m_blink = this; } - virtual ~SG_DList() - { + virtual ~SG_DList() + { Delink(); - } + } - inline bool Empty() // Check for empty queue - { - return ( m_flink == this ); - } - bool AddBack( SG_DList *item ) // Add to the back - { + inline bool Empty() // Check for empty queue + { + return ( m_flink == this ); + } + bool AddBack( SG_DList *item ) // Add to the back + { if (!item->Empty()) return false; - item->m_blink = m_blink; - item->m_flink = this; - m_blink->m_flink = item; - m_blink = item; + item->m_blink = m_blink; + item->m_flink = this; + m_blink->m_flink = item; + m_blink = item; return true; - } - bool AddFront( SG_DList *item ) // Add to the back - { + } + bool AddFront( SG_DList *item ) // Add to the back + { if (!item->Empty()) return false; - item->m_flink = m_flink; - item->m_blink = this; - m_flink->m_blink = item; - m_flink = item; + item->m_flink = m_flink; + item->m_blink = this; + m_flink->m_blink = item; + m_flink = item; return true; - } - SG_DList *Remove() // Remove from the front - { - if (Empty()) - { - return NULL; - } - SG_DList* item = m_flink; - m_flink = item->m_flink; - m_flink->m_blink = this; - item->m_flink = item->m_blink = item; - return item; - } - bool Delink() // Remove from the middle - { + } + SG_DList *Remove() // Remove from the front + { + if (Empty()) + { + return NULL; + } + SG_DList* item = m_flink; + m_flink = item->m_flink; + m_flink->m_blink = this; + item->m_flink = item->m_blink = item; + return item; + } + bool Delink() // Remove from the middle + { if (Empty()) return false; m_blink->m_flink = m_flink; m_flink->m_blink = m_blink; m_flink = m_blink = this; return true; - } - inline SG_DList *Peek() // Look at front without removing - { - return m_flink; - } - inline SG_DList *Back() // Look at front without removing - { - return m_blink; - } - inline SG_DList *Self() - { - return this; - } - inline const SG_DList *Peek() const // Look at front without removing - { - return (const SG_DList*)m_flink; - } - inline const SG_DList *Back() const // Look at front without removing - { - return (const SG_DList*)m_blink; - } - inline const SG_DList *Self() const - { - return this; - } + } + inline SG_DList *Peek() // Look at front without removing + { + return m_flink; + } + inline SG_DList *Back() // Look at front without removing + { + return m_blink; + } + inline SG_DList *Self() + { + return this; + } + inline const SG_DList *Peek() const // Look at front without removing + { + return (const SG_DList*)m_flink; + } + inline const SG_DList *Back() const // Look at front without removing + { + return (const SG_DList*)m_blink; + } + inline const SG_DList *Self() const + { + return this; + } #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h index c42935bc487..8c0159fe8d4 100644 --- a/source/gameengine/SceneGraph/SG_IObject.h +++ b/source/gameengine/SceneGraph/SG_IObject.h @@ -194,7 +194,7 @@ public: /** * Clear the array of pointers to controllers associated with * this node. This does not delete the controllers themselves! - * This should be used very carefully to avoid memory + * This should be used very carefully to avoid memory * leaks. */ diff --git a/source/gameengine/SceneGraph/SG_QList.h b/source/gameengine/SceneGraph/SG_QList.h index de79c35821e..eb404b1a5a5 100644 --- a/source/gameengine/SceneGraph/SG_QList.h +++ b/source/gameengine/SceneGraph/SG_QList.h @@ -91,73 +91,73 @@ public: }; SG_QList() : SG_DList() - { - m_fqlink = m_bqlink = this; - } + { + m_fqlink = m_bqlink = this; + } SG_QList(const SG_QList& other) : SG_DList() { - m_fqlink = m_bqlink = this; + m_fqlink = m_bqlink = this; } - virtual ~SG_QList() - { + virtual ~SG_QList() + { QDelink(); - } + } - inline bool QEmpty() // Check for empty queue - { - return ( m_fqlink == this ); - } - bool QAddBack( SG_QList *item ) // Add to the back - { + inline bool QEmpty() // Check for empty queue + { + return ( m_fqlink == this ); + } + bool QAddBack( SG_QList *item ) // Add to the back + { if (!item->QEmpty()) return false; - item->m_bqlink = m_bqlink; - item->m_fqlink = this; - m_bqlink->m_fqlink = item; - m_bqlink = item; + item->m_bqlink = m_bqlink; + item->m_fqlink = this; + m_bqlink->m_fqlink = item; + m_bqlink = item; return true; - } - bool QAddFront( SG_QList *item ) // Add to the back - { + } + bool QAddFront( SG_QList *item ) // Add to the back + { if (!item->Empty()) return false; - item->m_fqlink = m_fqlink; - item->m_bqlink = this; - m_fqlink->m_bqlink = item; - m_fqlink = item; + item->m_fqlink = m_fqlink; + item->m_bqlink = this; + m_fqlink->m_bqlink = item; + m_fqlink = item; return true; - } - SG_QList *QRemove() // Remove from the front - { - if (QEmpty()) - { - return NULL; - } - SG_QList* item = m_fqlink; - m_fqlink = item->m_fqlink; - m_fqlink->m_bqlink = this; - item->m_fqlink = item->m_bqlink = item; - return item; - } - bool QDelink() // Remove from the middle - { + } + SG_QList *QRemove() // Remove from the front + { + if (QEmpty()) + { + return NULL; + } + SG_QList* item = m_fqlink; + m_fqlink = item->m_fqlink; + m_fqlink->m_bqlink = this; + item->m_fqlink = item->m_bqlink = item; + return item; + } + bool QDelink() // Remove from the middle + { if (QEmpty()) return false; m_bqlink->m_fqlink = m_fqlink; m_fqlink->m_bqlink = m_bqlink; m_fqlink = m_bqlink = this; return true; - } - inline SG_QList *QPeek() // Look at front without removing - { - return m_fqlink; - } - inline SG_QList *QBack() // Look at front without removing - { - return m_bqlink; - } - - + } + inline SG_QList *QPeek() // Look at front without removing + { + return m_fqlink; + } + inline SG_QList *QBack() // Look at front without removing + { + return m_bqlink; + } + + #ifdef WITH_CXX_GUARDEDALLOC public: void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SG_QList"); } diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index 94b8584051e..09fb7278bfa 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -115,7 +115,7 @@ UpdateSpatialData( const SG_Spatial *parent, double time, bool& parentUpdated -){ + ){ bool bComputesWorldTransform = false; // update spatial controllers diff --git a/source/gameengine/VideoTexture/Exception.h b/source/gameengine/VideoTexture/Exception.h index 16248186108..11e617cf4ce 100644 --- a/source/gameengine/VideoTexture/Exception.h +++ b/source/gameengine/VideoTexture/Exception.h @@ -122,11 +122,11 @@ public: desc = m_description; } - void registerDesc(void) - { - if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == m_expDescs.end()) - m_expDescs.push_back(this); - } + void registerDesc(void) + { + if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == m_expDescs.end()) + m_expDescs.push_back(this); + } // list of exception descriptions static std::vector m_expDescs; diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index 86de214e2d3..65509ab9424 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -375,7 +375,7 @@ void Image_dealloc (PyImage * self) if (self->m_image->m_exports > 0) { PyErr_SetString(PyExc_SystemError, - "deallocated Image object has exported buffers"); + "deallocated Image object has exported buffers"); PyErr_Print(); } // if release requires deleting of object, do it diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 24833ace08f..f7546d876b2 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -328,11 +328,11 @@ static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds // get background color PyObject * getBackground (PyImage * self, void * closure) { - return Py_BuildValue("[BBBB]", - getImageRender(self)->getBackground(0), - getImageRender(self)->getBackground(1), - getImageRender(self)->getBackground(2), - getImageRender(self)->getBackground(3)); + return Py_BuildValue("[BBBB]", + getImageRender(self)->getBackground(0), + getImageRender(self)->getBackground(1), + getImageRender(self)->getBackground(2), + getImageRender(self)->getBackground(3)); } // set color -- cgit v1.2.3 From 60dcfe25269ff9709c784f6f44c9b0273e73c786 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 3 Sep 2011 04:44:18 +0000 Subject: =?UTF-8?q?fix=20[#28462]=20Tiled=20textures=20and=202D=20filters?= =?UTF-8?q?=20don't=20mix=20patch=20by=20Juha=20M=C3=A4ki-Kanto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/gameengine/Rasterizer/RAS_2DFilterManager.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source') diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index d9a9fbb0d31..725d00aa5cd 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -433,6 +433,9 @@ void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas) glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, 0, 0, texturewidth,textureheight, 0); } + // reverting to texunit 0, without this we get bug [#28462] + glActiveTextureARB(GL_TEXTURE0); + glViewport(0,0, texturewidth, textureheight); glDisable(GL_DEPTH_TEST); -- cgit v1.2.3 From 8cc307b4f2d2e1321ab8ec1baee6697ae3b0a967 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 3 Sep 2011 06:46:31 +0000 Subject: PyC_ExceptionBuffer is now threadsafe, used for converting exceptions into reports. --- source/blender/python/generic/py_capi_utils.c | 79 ++++++--------------------- 1 file changed, 18 insertions(+), 61 deletions(-) (limited to 'source') diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 81aea8571f8..b7e67ec5a93 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -208,77 +208,34 @@ PyObject *PyC_Object_GetAttrStringArgs(PyObject *o, Py_ssize_t n, ...) return item; } -/* returns the exception string as a new PyUnicode object, depends on external StringIO module */ +/* returns the exception string as a new PyUnicode object, depends on external traceback module */ PyObject *PyC_ExceptionBuffer(void) { - PyObject *stdout_backup = PySys_GetObject("stdout"); /* borrowed */ - PyObject *stderr_backup = PySys_GetObject("stderr"); /* borrowed */ - PyObject *string_io = NULL; - PyObject *string_io_buf = NULL; - PyObject *string_io_mod= NULL; - PyObject *string_io_getvalue= NULL; - - PyObject *error_type, *error_value, *error_traceback; - - if (!PyErr_Occurred()) - return NULL; - - PyErr_Fetch(&error_type, &error_value, &error_traceback); - - PyErr_Clear(); - - /* import io - * string_io = io.StringIO() - */ - - if(! (string_io_mod= PyImport_ImportModule("io")) ) { + PyObject *traceback_mod= NULL; + PyObject *format_tb_func= NULL; + PyObject *ret= NULL; + + if(! (traceback_mod= PyImport_ImportModule("traceback")) ) { goto error_cleanup; } - else if (! (string_io = PyObject_CallMethod(string_io_mod, (char *)"StringIO", NULL))) { + else if (! (format_tb_func= PyObject_GetAttrString(traceback_mod, "format_exc"))) { goto error_cleanup; } - else if (! (string_io_getvalue= PyObject_GetAttrString(string_io, "getvalue"))) { - goto error_cleanup; + + ret= PyObject_CallObject(format_tb_func, NULL); + + if(ret == Py_None) { + Py_DECREF(ret); + ret= NULL; } - - Py_INCREF(stdout_backup); // since these were borrowed we dont want them freed when replaced. - Py_INCREF(stderr_backup); - - PySys_SetObject("stdout", string_io); // both of these are free'd when restoring - PySys_SetObject("stderr", string_io); - - PyErr_Restore(error_type, error_value, error_traceback); - PyErr_Print(); /* print the error */ - PyErr_Clear(); - - string_io_buf = PyObject_CallObject(string_io_getvalue, NULL); - - PySys_SetObject("stdout", stdout_backup); - PySys_SetObject("stderr", stderr_backup); - - Py_DECREF(stdout_backup); /* now sys owns the ref again */ - Py_DECREF(stderr_backup); - - Py_DECREF(string_io_mod); - Py_DECREF(string_io_getvalue); - Py_DECREF(string_io); /* free the original reference */ - - PyErr_Clear(); - return string_io_buf; - - + error_cleanup: /* could not import the module so print the error and close */ - Py_XDECREF(string_io_mod); - Py_XDECREF(string_io); - - PyErr_Restore(error_type, error_value, error_traceback); - PyErr_Print(); /* print the error */ - PyErr_Clear(); - - return NULL; -} + Py_XDECREF(traceback_mod); + Py_XDECREF(format_tb_func); + return ret; +} /* string conversion, escape non-unicode chars, coerce must be set to NULL */ const char *PyC_UnicodeAsByte(PyObject *py_str, PyObject **coerce) -- cgit v1.2.3 From a6a14d0a1e2dcc1aa5535a96339245bb645fba58 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 3 Sep 2011 08:18:43 +0000 Subject: == CustomData == * Added comments for each entry in the LAYERTYPEINFO array noting the number and name of the layer type; was hard to tell before which entry was what --- source/blender/blenkernel/intern/customdata.c | 28 +++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 8d19322c0db..c342bbc917f 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -808,41 +808,65 @@ static void layerDefault_mcol(void *data, int count) static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { + /* 0: CD_MVERT */ {sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 1: CD_MSTICKY */ {sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL, NULL}, + /* 2: CD_MDEFORMVERT */ {sizeof(MDeformVert), "MDeformVert", 1, NULL, layerCopy_mdeformvert, layerFree_mdeformvert, layerInterp_mdeformvert, NULL, NULL}, + /* 3: CD_MEDGE */ {sizeof(MEdge), "MEdge", 1, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 4: CD_MFACE */ {sizeof(MFace), "MFace", 1, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 5: CD_MTFACE */ {sizeof(MTFace), "MTFace", 1, "UVTex", layerCopy_tface, NULL, layerInterp_tface, layerSwap_tface, layerDefault_tface}, + /* 6: CD_MCOL */ /* 4 MCol structs per face */ {sizeof(MCol)*4, "MCol", 4, "Col", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, + /* 7: CD_ORIGINDEX */ {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 8: CD_NORMAL */ /* 3 floats per normal vector */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 9: CD_FLAGS */ {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 10: CD_PROP_FLT */ {sizeof(MFloatProperty), "MFloatProperty",1,"Float",NULL,NULL,NULL,NULL}, + /* 11: CD_PROP_INT */ {sizeof(MIntProperty), "MIntProperty",1,"Int",NULL,NULL,NULL,NULL}, + /* 12: CD_PROP_STR */ {sizeof(MStringProperty), "MStringProperty",1,"String",NULL,NULL,NULL,NULL}, + /* 13: CD_ORIGSPACE */ {sizeof(OrigSpaceFace), "OrigSpaceFace", 1, "UVTex", layerCopy_origspace_face, NULL, layerInterp_origspace_face, layerSwap_origspace_face, layerDefault_origspace_face}, + /* 14: CD_ORCO */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 15: CD_MTEXPOLY */ {sizeof(MTexPoly), "MTexPoly", 1, "Face Texture", NULL, NULL, NULL, NULL, NULL}, + /* 16: CD_MLOOPUV */ {sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL}, + /* 17: CD_MLOOPCOL */ {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, layerDefault_mloopcol}, + /* 18: CD_TANGENT */ {sizeof(float)*4*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 19: CD_MDISPS */ {sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps, layerFree_mdisps, layerInterp_mdisps, layerSwap_mdisps, NULL, layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps, layerValidate_mdisps}, + /* 20: CD_WEIGHT_MCOL */ {sizeof(MCol)*4, "MCol", 4, "WeightCol", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, - {sizeof(MCol)*4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol, + /* 21: CD_ID_MCOL */ + {sizeof(MCol)*4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, - {sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol, + /* 22: CD_TEXTURE_MCOL */ + {sizeof(MCol)*4, "MCol", 4, "TexturedCol", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, + /* 23: CD_CLOTH_ORCO */ {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL} }; -- cgit v1.2.3 From a01ffbbddb40c8f14f10aa5edf0cd1ba5dcc6942 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 3 Sep 2011 09:43:20 +0000 Subject: minor edits to build on openbsd --- source/blender/blenloader/BLO_sys_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/blenloader/BLO_sys_types.h b/source/blender/blenloader/BLO_sys_types.h index d56723ec1c5..2114fc34bf1 100644 --- a/source/blender/blenloader/BLO_sys_types.h +++ b/source/blender/blenloader/BLO_sys_types.h @@ -83,7 +83,7 @@ typedef unsigned long uintptr_t; #define _UINTPTR_T_DEFINED #endif -#elif defined(__linux__) || defined(__NetBSD__) +#elif defined(__linux__) || defined(__NetBSD__) || defined(__OpenBSD__) /* Linux-i386, Linux-Alpha, Linux-ppc */ #include -- cgit v1.2.3 From 451136e7c0860b5240d4fcec50c95cd4790b8e2b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 3 Sep 2011 15:36:36 +0000 Subject: warning fixes --- source/blender/blenkernel/intern/mesh_validate.c | 2 +- source/blender/collada/DocumentExporter.cpp | 7 ++----- source/blender/collada/ExtraTags.cpp | 12 ++++-------- source/blender/makesrna/intern/rna_scene_api.c | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 9c916d517c5..70398594872 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -166,7 +166,7 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), unsigned int totve } if(BLI_edgehash_haskey(edge_hash, med->v1, med->v2)) { - PRINT(" edge %u: is a duplicate of, %u\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); + PRINT(" edge %u: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); remove= do_fixes; } diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 285ab283b37..6e780889d16 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -328,9 +328,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool //scale = RNA_struct_find_property(&unit_settings, "scale_length"); std::string unitname = "meter"; - float linearmeasure = 1.0f; - - linearmeasure = RNA_float_get(&unit_settings, "scale_length"); + float linearmeasure = RNA_float_get(&unit_settings, "scale_length"); switch(RNA_property_enum_get(&unit_settings, system)) { case USER_UNIT_NONE: @@ -368,8 +366,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce, const char* filename, bool asset.setUnit(unitname, linearmeasure); asset.setUpAxisType(COLLADASW::Asset::Z_UP); - // TODO: need an Author field in userpref - if(strlen(U.author) > 0) { + if(U.author[0] != '\0') { asset.getContributor().mAuthor = U.author; } else { diff --git a/source/blender/collada/ExtraTags.cpp b/source/blender/collada/ExtraTags.cpp index 653d4a377cd..f0c6d2228b1 100644 --- a/source/blender/collada/ExtraTags.cpp +++ b/source/blender/collada/ExtraTags.cpp @@ -90,32 +90,28 @@ std::string ExtraTags::asString( std::string tag, bool *ok) void ExtraTags::setData(std::string tag, short *data) { bool ok = false; - int tmp = 0; - tmp = asInt(tag, &ok); + int tmp = asInt(tag, &ok); if(ok) *data = (short)tmp; } void ExtraTags::setData(std::string tag, int *data) { bool ok = false; - int tmp = 0; - tmp = asInt(tag, &ok); + int tmp = asInt(tag, &ok); if(ok) *data = tmp; } void ExtraTags::setData(std::string tag, float *data) { bool ok = false; - float tmp = 0.0f; - tmp = asFloat(tag, &ok); + float tmp = asFloat(tag, &ok); if(ok) *data = tmp; } void ExtraTags::setData(std::string tag, char *data) { bool ok = false; - int tmp = 0; - tmp = asInt(tag, &ok); + int tmp = asInt(tag, &ok); if(ok) *data = (char)tmp; } diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index 1220c4f34a1..fd7987c18a2 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -111,7 +111,7 @@ void RNA_api_scene(StructRNA *srna) #ifdef WITH_COLLADA /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ func= RNA_def_function(srna, "collada_export", "rna_Scene_collada_export"); - parm= RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file."); + RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file."); parm= RNA_def_boolean(func, "selected", 0, "Export only selected", "Export only selected elements."); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ -- cgit v1.2.3 From 8295480bbeee2aafa0ea70d19836b3ab094ee08e Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 3 Sep 2011 19:33:07 +0000 Subject: BGE animations: Fixing a crash that would happen if the property for a property mode action actuator was invalid. --- source/gameengine/Converter/BL_ActionActuator.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 50e887a21a8..063544932de 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -217,6 +217,9 @@ bool BL_ActionActuator::Update(double curtime, bool frame) case ACT_ACTION_FROM_PROP: CValue* prop = GetParent()->GetProperty(m_propname); + // If we don't have a property, we can't do anything, so just bail + if (!prop) return false; + playtype = BL_Action::ACT_MODE_PLAY; start = end = prop->GetNumber(); -- cgit v1.2.3 From 1f8291f78d6eb3e02414cc7801fe5ba9ad524e4b Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 3 Sep 2011 20:48:47 +0000 Subject: BGE animations: Adding a separate list to KX_Scene for animated objects. This makes scenes with a lot of non-animated objects faster. In my test scene with 8000 static, non-animated cubes my time spent on animations went from 1.5~1.7ms to 0.001ms. --- source/gameengine/Ketsji/KX_GameObject.cpp | 5 +++-- source/gameengine/Ketsji/KX_Scene.cpp | 16 +++++++++++++++- source/gameengine/Ketsji/KX_Scene.h | 5 +++++ 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 3f6f4bb9099..6adaea2d6ad 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -159,6 +159,7 @@ KX_GameObject::~KX_GameObject() } if (m_actionManager) { + KX_GetActiveScene()->RemoveAnimatedObject(this); delete m_actionManager; } #ifdef WITH_PYTHON @@ -355,8 +356,8 @@ BL_ActionManager* KX_GameObject::GetActionManager() { // We only want to create an action manager if we need it if (!m_actionManager) - m_actionManager = new BL_ActionManager(this); - + { KX_GetActiveScene()->AddAnimatedObject(this); m_actionManager = new BL_ActionManager(this); + } return m_actionManager; } diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index a49c1bf4b4c..06e343cedb2 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -168,6 +168,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, m_lightlist= new CListValue(); m_inactivelist = new CListValue(); m_euthanasyobjects = new CListValue(); + m_animatedlist = new CListValue(); m_logicmgr = new SCA_LogicManager(); @@ -253,6 +254,9 @@ KX_Scene::~KX_Scene() if (m_euthanasyobjects) m_euthanasyobjects->Release(); + if (m_animatedlist) + m_animatedlist->Release(); + if (m_logicmgr) delete m_logicmgr; @@ -1502,10 +1506,20 @@ void KX_Scene::LogicBeginFrame(double curtime) m_logicmgr->BeginFrame(curtime, 1.0/KX_KetsjiEngine::GetTicRate()); } +void KX_Scene::AddAnimatedObject(CValue* gameobj) +{ + m_animatedlist->Add(gameobj); +} + +void KX_Scene::RemoveAnimatedObject(CValue* gameobj) +{ + m_animatedlist->RemoveValue(gameobj); +} + void KX_Scene::UpdateAnimations(double curtime) { // Update any animations - for (int i=0; iGetCount(); ++i) + for (int i=0; iGetCount(); ++i) ((KX_GameObject*)GetObjectList()->GetValue(i))->UpdateActionManager(curtime); } diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h index da9cc12c76a..499861bce50 100644 --- a/source/gameengine/Ketsji/KX_Scene.h +++ b/source/gameengine/Ketsji/KX_Scene.h @@ -130,6 +130,7 @@ protected: CListValue* m_parentlist; // all 'root' parents CListValue* m_lightlist; CListValue* m_inactivelist; // all objects that are not in the active layer + CListValue* m_animatedlist; // all animated objects SG_QList m_sghead; // list of nodes that needs scenegraph update // the Dlist is not object that must be updated @@ -334,6 +335,10 @@ public: int NewRemoveObject(CValue* gameobj); void ReplaceMesh(CValue* gameobj, void* meshob, bool use_gfx, bool use_phys); + + void AddAnimatedObject(CValue* gameobj); + void RemoveAnimatedObject(CValue* gameobj); + /** * @section Logic stuff * Initiate an update of the logic system. -- cgit v1.2.3 From 1764f2135d3c1780c4ead12fae3eb97ac2de5a7d Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 4 Sep 2011 00:15:59 +0000 Subject: Some whitespace changes --- source/blender/collada/AnimationExporter.cpp | 1694 +++++++++++++------------- source/blender/collada/AnimationImporter.cpp | 388 +++--- source/blender/collada/AnimationImporter.h | 10 +- source/blender/collada/ArmatureExporter.cpp | 2 +- source/blender/collada/ArmatureImporter.cpp | 4 +- source/blender/collada/ArmatureImporter.h | 4 +- source/blender/collada/MeshImporter.cpp | 2 +- source/blender/collada/SkinInfo.cpp | 6 +- source/blender/collada/TransformWriter.cpp | 2 +- 9 files changed, 1055 insertions(+), 1057 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 8a0a39da558..4c20d1cf6c1 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -1,26 +1,26 @@ /* - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed. - * - * ***** END GPL LICENSE BLOCK ***** - */ +* $Id$ +* +* ***** BEGIN GPL LICENSE BLOCK ***** +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed. +* +* ***** END GPL LICENSE BLOCK ***** +*/ #include "GeometryExporter.h" #include "AnimationExporter.h" @@ -30,10 +30,10 @@ template void forEachObjectInScene(Scene *sce, Functor &f) { Base *base= (Base*) sce->base.first; - + while(base) { Object *ob = base->object; - + f(ob); base= base->next; @@ -61,7 +61,7 @@ void AnimationExporter::operator() (Object *ob) bool isMatAnim = false; //Export transform animations - if(ob->adt && ob->adt->action) + if(ob->adt && ob->adt->action) { fcu = (FCurve*)ob->adt->action->curves.first; @@ -72,21 +72,21 @@ void AnimationExporter::operator() (Object *ob) for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) write_bone_animation_matrix(ob, bone); } - + while (fcu) { //for armature animations as objects if ( ob->type == OB_ARMATURE ) transformName = fcu->rna_path; else transformName = extract_transform_name( fcu->rna_path ); - + if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)|| (!strcmp(transformName, "rotation_quaternion"))) dae_animation(ob ,fcu, transformName, false); fcu = fcu->next; } - + } //Export Lamp parameter animations @@ -94,8 +94,8 @@ void AnimationExporter::operator() (Object *ob) { fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); - + transformName = extract_transform_name( fcu->rna_path ); + if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))|| (!strcmp(transformName, "distance")) ) dae_animation(ob , fcu, transformName, true ); @@ -108,8 +108,8 @@ void AnimationExporter::operator() (Object *ob) { fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); while (fcu) { - transformName = extract_transform_name( fcu->rna_path ); - + transformName = extract_transform_name( fcu->rna_path ); + if ((!strcmp(transformName, "lens"))|| (!strcmp(transformName, "ortho_scale"))|| (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start"))) @@ -129,7 +129,7 @@ void AnimationExporter::operator() (Object *ob) fcu = (FCurve*)ma->adt->action->curves.first; while (fcu) { transformName = extract_transform_name( fcu->rna_path ); - + if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))|| (!strcmp(transformName, "ior"))) @@ -137,384 +137,384 @@ void AnimationExporter::operator() (Object *ob) fcu = fcu->next; } } - + } } - //euler sources from quternion sources - float * AnimationExporter::get_eul_source_for_quat(Object *ob ) +//euler sources from quternion sources +float * AnimationExporter::get_eul_source_for_quat(Object *ob ) +{ + FCurve *fcu = (FCurve*)ob->adt->action->curves.first; + const int keys = fcu->totvert; + float *quat = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values"); + float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values"); + float temp_quat[4]; + float temp_eul[3]; + while(fcu) { - FCurve *fcu = (FCurve*)ob->adt->action->curves.first; - const int keys = fcu->totvert; - float *quat = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 4, "quat output source values"); - float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values"); - float temp_quat[4]; - float temp_eul[3]; - while(fcu) - { - char * transformName = extract_transform_name( fcu->rna_path ); - - if( !strcmp(transformName, "rotation_quaternion") ) { - for ( int i = 0 ; i < fcu->totvert ; i++){ - *(quat + ( i * 4 ) + fcu->array_index) = fcu->bezt[i].vec[1][1]; - } - } - fcu = fcu->next; + char * transformName = extract_transform_name( fcu->rna_path ); + + if( !strcmp(transformName, "rotation_quaternion") ) { + for ( int i = 0 ; i < fcu->totvert ; i++){ + *(quat + ( i * 4 ) + fcu->array_index) = fcu->bezt[i].vec[1][1]; } + } + fcu = fcu->next; + } - for ( int i = 0 ; i < keys ; i++){ - for ( int j = 0;j<4;j++) - temp_quat[j] = quat[(i*4)+j]; + for ( int i = 0 ; i < keys ; i++){ + for ( int j = 0;j<4;j++) + temp_quat[j] = quat[(i*4)+j]; - quat_to_eul(temp_eul,temp_quat); + quat_to_eul(temp_eul,temp_quat); - for (int k = 0;k<3;k++) - eul[i*3 + k] = temp_eul[k]; - - } - MEM_freeN(quat); - return eul; + for (int k = 0;k<3;k++) + eul[i*3 + k] = temp_eul[k]; } + MEM_freeN(quat); + return eul; + +} + +//Get proper name for bones +std::string AnimationExporter::getObjectBoneName( Object* ob,const FCurve* fcu ) +{ + //hard-way to derive the bone name from rna_path. Must find more compact method + std::string rna_path = std::string(fcu->rna_path); - //Get proper name for bones - std::string AnimationExporter::getObjectBoneName( Object* ob,const FCurve* fcu ) + char* boneName = strtok((char *)rna_path.c_str(), "\""); + boneName = strtok(NULL,"\""); + + if( boneName != NULL ) + return /*id_name(ob) + "_" +*/ std::string(boneName); + else + return id_name(ob); +} + +//convert f-curves to animation curves and write +void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, Material * ma ) +{ + const char *axis_name = NULL; + char anim_id[200]; + + bool has_tangents = false; + bool quatRotation = false; + + if ( !strcmp(transformName, "rotation_quaternion") ) { - //hard-way to derive the bone name from rna_path. Must find more compact method - std::string rna_path = std::string(fcu->rna_path); - - char* boneName = strtok((char *)rna_path.c_str(), "\""); - boneName = strtok(NULL,"\""); - - if( boneName != NULL ) - return /*id_name(ob) + "_" +*/ std::string(boneName); - else - return id_name(ob); + fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n"); + quatRotation = true; + return; } - //convert f-curves to animation curves and write - void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, Material * ma ) + //axis names for colors + else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")|| + (!strcmp(transformName, "alpha"))) { - const char *axis_name = NULL; - char anim_id[200]; - - bool has_tangents = false; - bool quatRotation = false; - - if ( !strcmp(transformName, "rotation_quaternion") ) - { - fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n"); - quatRotation = true; - return; - } - - //axis names for colors - else if ( !strcmp(transformName, "color")||!strcmp(transformName, "specular_color")||!strcmp(transformName, "diffuse_color")|| - (!strcmp(transformName, "alpha"))) - { - const char *axis_names[] = {"R", "G", "B"}; - if (fcu->array_index < 3) + const char *axis_names[] = {"R", "G", "B"}; + if (fcu->array_index < 3) axis_name = axis_names[fcu->array_index]; - } + } - //axis names for transforms - else if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || - (!strcmp(transformName, "rotation_euler"))||(!strcmp(transformName, "rotation_quaternion"))) - { - const char *axis_names[] = {"X", "Y", "Z"}; - if (fcu->array_index < 3) + //axis names for transforms + else if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || + (!strcmp(transformName, "rotation_euler"))||(!strcmp(transformName, "rotation_quaternion"))) + { + const char *axis_names[] = {"X", "Y", "Z"}; + if (fcu->array_index < 3) axis_name = axis_names[fcu->array_index]; - } + } - //no axis name. single parameter. - else{ - axis_name = ""; - } - - std::string ob_name = std::string("null"); - - //Create anim Id - if (ob->type == OB_ARMATURE) - { - ob_name = getObjectBoneName( ob , fcu); - BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(), - transformName, axis_name); - } - else - { - if (ma) - ob_name = id_name(ob) + "_material"; - else - ob_name = id_name(ob); - BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), - fcu->rna_path, axis_name); - } - - openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); + //no axis name. single parameter. + else{ + axis_name = ""; + } - // create input source - std::string input_id = create_source_from_fcurve(COLLADASW::InputSemantic::INPUT, fcu, anim_id, axis_name); + std::string ob_name = std::string("null"); - // create output source - std::string output_id ; - - //quat rotations are skipped for now, because of complications with determining axis. - if(quatRotation) - { - float * eul = get_eul_source_for_quat(ob); - float * eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values"); - for ( int i = 0 ; i< fcu->totvert ; i++) - eul_axis[i] = eul[i*3 + fcu->array_index]; - output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name); - MEM_freeN(eul); - MEM_freeN(eul_axis); - } - else - { - output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name); - } - // create interpolations source - std::string interpolation_id = create_interpolation_source(fcu, anim_id, axis_name, &has_tangents); - - // handle tangents (if required) - std::string intangent_id; - std::string outtangent_id; - - if (has_tangents) { - // create in_tangent source - intangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::IN_TANGENT, fcu, anim_id, axis_name); - - // create out_tangent source - outtangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUT_TANGENT, fcu, anim_id, axis_name); - } + //Create anim Id + if (ob->type == OB_ARMATURE) + { + ob_name = getObjectBoneName( ob , fcu); + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(), + transformName, axis_name); + } + else + { + if (ma) + ob_name = id_name(ob) + "_material"; + else + ob_name = id_name(ob); + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), + fcu->rna_path, axis_name); + } - std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; - COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); - std::string empty; - sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); - sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); - // this input is required - sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); + // create input source + std::string input_id = create_source_from_fcurve(COLLADASW::InputSemantic::INPUT, fcu, anim_id, axis_name); - if (has_tangents) { - sampler.addInput(COLLADASW::InputSemantic::IN_TANGENT, COLLADABU::URI(empty, intangent_id)); - sampler.addInput(COLLADASW::InputSemantic::OUT_TANGENT, COLLADABU::URI(empty, outtangent_id)); - } + // create output source + std::string output_id ; - addSampler(sampler); + //quat rotations are skipped for now, because of complications with determining axis. + if(quatRotation) + { + float * eul = get_eul_source_for_quat(ob); + float * eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values"); + for ( int i = 0 ; i< fcu->totvert ; i++) + eul_axis[i] = eul[i*3 + fcu->array_index]; + output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name); + MEM_freeN(eul); + MEM_freeN(eul_axis); + } + else + { + output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name); + } + // create interpolations source + std::string interpolation_id = create_interpolation_source(fcu, anim_id, axis_name, &has_tangents); - std::string target ; + // handle tangents (if required) + std::string intangent_id; + std::string outtangent_id; - if ( !is_param ) - target = translate_id(ob_name) - + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); - else - { - if ( ob->type == OB_LAMP ) - target = get_light_id(ob) - + "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true); + if (has_tangents) { + // create in_tangent source + intangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::IN_TANGENT, fcu, anim_id, axis_name); - if ( ob->type == OB_CAMERA ) - target = get_camera_id(ob) - + "/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true); + // create out_tangent source + outtangent_id = create_source_from_fcurve(COLLADASW::InputSemantic::OUT_TANGENT, fcu, anim_id, axis_name); + } - if( ma ) - target = translate_id(id_name(ma)) + "-effect" - +"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); - } - addChannel(COLLADABU::URI(empty, sampler_id), target); + std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; + COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); + std::string empty; + sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); + sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); + + // this input is required + sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); - closeAnimation(); + if (has_tangents) { + sampler.addInput(COLLADASW::InputSemantic::IN_TANGENT, COLLADABU::URI(empty, intangent_id)); + sampler.addInput(COLLADASW::InputSemantic::OUT_TANGENT, COLLADABU::URI(empty, outtangent_id)); } + addSampler(sampler); + + std::string target ; - - //write bone animations in transform matrix sources - void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone) + if ( !is_param ) + target = translate_id(ob_name) + + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); + else { - if (!ob_arm->adt) - return; - - //This will only export animations of bones in deform group. - /*if(!is_bone_deform_group(bone)) - return;*/ - - sample_and_write_bone_animation_matrix(ob_arm, bone); - - for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) - write_bone_animation_matrix(ob_arm, child); + if ( ob->type == OB_LAMP ) + target = get_light_id(ob) + + "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true); + + if ( ob->type == OB_CAMERA ) + target = get_camera_id(ob) + + "/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true); + + if( ma ) + target = translate_id(id_name(ma)) + "-effect" + +"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); } + addChannel(COLLADABU::URI(empty, sampler_id), target); - bool AnimationExporter::is_bone_deform_group(Bone * bone) + closeAnimation(); +} + + + +//write bone animations in transform matrix sources +void AnimationExporter::write_bone_animation_matrix(Object *ob_arm, Bone *bone) +{ + if (!ob_arm->adt) + return; + + //This will only export animations of bones in deform group. + /*if(!is_bone_deform_group(bone)) + return;*/ + + sample_and_write_bone_animation_matrix(ob_arm, bone); + + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) + write_bone_animation_matrix(ob_arm, child); +} + +bool AnimationExporter::is_bone_deform_group(Bone * bone) +{ + bool is_def; + //Check if current bone is deform + if((bone->flag & BONE_NO_DEFORM) == 0 ) return true; + //Check child bones + else { - bool is_def; - //Check if current bone is deform - if((bone->flag & BONE_NO_DEFORM) == 0 ) return true; - //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) return true; - } + 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) return true; } - //no deform bone found in children also - return false; } + //no deform bone found in children also + return false; +} - void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone) - { - bArmature *arm = (bArmature*)ob_arm->data; - int flag = arm->flag; - std::vector fra; - //char prefix[256]; - - FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first; - while(fcu) - { - std::string bone_name = getObjectBoneName(ob_arm,fcu); - int val = BLI_strcasecmp((char*)bone_name.c_str(),bone->name); - if(val==0) break; - fcu = fcu->next; - } +void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, Bone *bone) +{ + bArmature *arm = (bArmature*)ob_arm->data; + int flag = arm->flag; + std::vector fra; + //char prefix[256]; - if(!(fcu)) return; - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); - if (!pchan) - return; - - find_frames(ob_arm, fra); + FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first; + while(fcu) + { + std::string bone_name = getObjectBoneName(ob_arm,fcu); + int val = BLI_strcasecmp((char*)bone_name.c_str(),bone->name); + if(val==0) break; + fcu = fcu->next; + } - if (flag & ARM_RESTPOS) { - arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); - } + if(!(fcu)) return; + bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + if (!pchan) + return; - if (fra.size()) { - dae_baked_animation(fra ,ob_arm, bone ); - } + find_frames(ob_arm, fra); - if (flag & ARM_RESTPOS) - arm->flag = flag; + if (flag & ARM_RESTPOS) { + arm->flag &= ~ARM_RESTPOS; where_is_pose(scene, ob_arm); } - void AnimationExporter::dae_baked_animation(std::vector &fra, Object *ob_arm , Bone *bone) - { - std::string ob_name = id_name(ob_arm); - std::string bone_name = bone->name; - char anim_id[200]; - - if (!fra.size()) - return; + if (fra.size()) { + dae_baked_animation(fra ,ob_arm, bone ); + } - BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), - (char*)translate_id(bone_name).c_str(), "pose_matrix"); + if (flag & ARM_RESTPOS) + arm->flag = flag; + where_is_pose(scene, ob_arm); +} - openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); +void AnimationExporter::dae_baked_animation(std::vector &fra, Object *ob_arm , Bone *bone) +{ + std::string ob_name = id_name(ob_arm); + std::string bone_name = bone->name; + char anim_id[200]; - // create input source - std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, false, anim_id, ""); + if (!fra.size()) + return; - // create output source - std::string output_id; - output_id = create_4x4_source( fra, ob_arm , bone , anim_id); + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), + (char*)translate_id(bone_name).c_str(), "pose_matrix"); - // create interpolations source - std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, ""); + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); - std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; - COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); - std::string empty; - sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); - sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); + // create input source + std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, false, anim_id, ""); - // TODO create in/out tangents source + // create output source + std::string output_id; + output_id = create_4x4_source( fra, ob_arm , bone , anim_id); - // this input is required - sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); + // create interpolations source + std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, ""); - addSampler(sampler); + std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; + COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); + std::string empty; + sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); + sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); - std::string target = translate_id(bone_name) + "/transform"; - addChannel(COLLADABU::URI(empty, sampler_id), target); + // TODO create in/out tangents source - closeAnimation(); - } + // this input is required + sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); - // dae_bone_animation -> add_bone_animation - // (blend this into dae_bone_animation) - void AnimationExporter::dae_bone_animation(std::vector &fra, float *values, int tm_type, int axis, std::string ob_name, std::string bone_name) - { - const char *axis_names[] = {"X", "Y", "Z"}; - const char *axis_name = NULL; - char anim_id[200]; - bool is_rot = tm_type == 0; - - if (!fra.size()) - return; + addSampler(sampler); - char rna_path[200]; - BLI_snprintf(rna_path, sizeof(rna_path), "pose.bones[\"%s\"].%s", bone_name.c_str(), - tm_type == 0 ? "rotation_quaternion" : (tm_type == 1 ? "scale" : "location")); + std::string target = translate_id(bone_name) + "/transform"; + addChannel(COLLADABU::URI(empty, sampler_id), target); - if (axis > -1) - axis_name = axis_names[axis]; - - std::string transform_sid = get_transform_sid(NULL, tm_type, axis_name, false); - - BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), - (char*)translate_id(bone_name).c_str(), (char*)transform_sid.c_str()); + closeAnimation(); +} - openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); +// dae_bone_animation -> add_bone_animation +// (blend this into dae_bone_animation) +void AnimationExporter::dae_bone_animation(std::vector &fra, float *values, int tm_type, int axis, std::string ob_name, std::string bone_name) +{ + const char *axis_names[] = {"X", "Y", "Z"}; + const char *axis_name = NULL; + char anim_id[200]; + bool is_rot = tm_type == 0; - // create input source - std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, is_rot, anim_id, axis_name); + if (!fra.size()) + return; - // create output source - std::string output_id; - if (axis == -1) - output_id = create_xyz_source(values, fra.size(), anim_id); - else - output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, values, fra.size(), is_rot, anim_id, axis_name); + char rna_path[200]; + BLI_snprintf(rna_path, sizeof(rna_path), "pose.bones[\"%s\"].%s", bone_name.c_str(), + tm_type == 0 ? "rotation_quaternion" : (tm_type == 1 ? "scale" : "location")); - // create interpolations source - std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, axis_name); + if (axis > -1) + axis_name = axis_names[axis]; - std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; - COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); - std::string empty; - sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); - sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); + std::string transform_sid = get_transform_sid(NULL, tm_type, axis_name, false); - // TODO create in/out tangents source + BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char*)translate_id(ob_name).c_str(), + (char*)translate_id(bone_name).c_str(), (char*)transform_sid.c_str()); - // this input is required - sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); + openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING); - addSampler(sampler); + // create input source + std::string input_id = create_source_from_vector(COLLADASW::InputSemantic::INPUT, fra, is_rot, anim_id, axis_name); - std::string target = translate_id(ob_name + "_" + bone_name) + "/" + transform_sid; - addChannel(COLLADABU::URI(empty, sampler_id), target); + // create output source + std::string output_id; + if (axis == -1) + output_id = create_xyz_source(values, fra.size(), anim_id); + else + output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, values, fra.size(), is_rot, anim_id, axis_name); - closeAnimation(); - } + // create interpolations source + std::string interpolation_id = fake_interpolation_source(fra.size(), anim_id, axis_name); - float AnimationExporter::convert_time(float frame) - { - return FRA2TIME(frame); - } + std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX; + COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id); + std::string empty; + sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id)); + sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id)); - float AnimationExporter::convert_angle(float angle) - { - return COLLADABU::Math::Utils::radToDegF(angle); - } + // TODO create in/out tangents source - std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic) - { - switch(semantic) { + // this input is required + sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION, COLLADABU::URI(empty, interpolation_id)); + + addSampler(sampler); + + std::string target = translate_id(ob_name + "_" + bone_name) + "/" + transform_sid; + addChannel(COLLADABU::URI(empty, sampler_id), target); + + closeAnimation(); +} + +float AnimationExporter::convert_time(float frame) +{ + return FRA2TIME(frame); +} + +float AnimationExporter::convert_angle(float angle) +{ + return COLLADABU::Math::Utils::radToDegF(angle); +} + +std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic) +{ + switch(semantic) { case COLLADASW::InputSemantic::INPUT: return INPUT_SOURCE_ID_SUFFIX; case COLLADASW::InputSemantic::OUTPUT: @@ -527,14 +527,14 @@ void AnimationExporter::operator() (Object *ob) return OUTTANGENT_SOURCE_ID_SUFFIX; default: break; - } - return ""; } + return ""; +} - void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, - COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform) - { - switch(semantic) { +void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, + COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform) +{ + switch(semantic) { case COLLADASW::InputSemantic::INPUT: param.push_back("TIME"); break; @@ -547,14 +547,14 @@ void AnimationExporter::operator() (Object *ob) param.push_back(axis); } else - if ( transform ) - { - param.push_back("TRANSFORM"); - }else{ //assumes if axis isn't specified all axises are added - param.push_back("X"); - param.push_back("Y"); - param.push_back("Z"); - } + if ( transform ) + { + param.push_back("TRANSFORM"); + }else{ //assumes if axis isn't specified all axises are added + param.push_back("X"); + param.push_back("Y"); + param.push_back("Z"); + } } break; case COLLADASW::InputSemantic::IN_TANGENT: @@ -564,12 +564,12 @@ void AnimationExporter::operator() (Object *ob) break; default: break; - } } +} - void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length) - { - switch (semantic) { +void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSemantic::Semantics semantic, bool rotation, float *values, int *length) +{ + switch (semantic) { case COLLADASW::InputSemantic::INPUT: *length = 1; values[0] = convert_time(bezt->vec[1][0]); @@ -583,9 +583,9 @@ void AnimationExporter::operator() (Object *ob) values[0] = bezt->vec[1][1]; } break; - + case COLLADASW::InputSemantic::IN_TANGENT: - *length = 2; + *length = 2; values[0] = convert_time(bezt->vec[0][0]); if (bezt->ipo != BEZT_IPO_BEZ) { // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data @@ -598,7 +598,7 @@ void AnimationExporter::operator() (Object *ob) values[1] = bezt->vec[0][1]; } break; - + case COLLADASW::InputSemantic::OUT_TANGENT: *length = 2; values[0] = convert_time(bezt->vec[2][0]); @@ -617,283 +617,283 @@ void AnimationExporter::operator() (Object *ob) default: *length = 0; break; - } } +} - std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name) - { - std::string source_id = anim_id + get_semantic_suffix(semantic); - - //bool is_rotation = !strcmp(fcu->rna_path, "rotation"); - bool is_angle = false; - - if (strstr(fcu->rna_path, "rotation")) is_angle = true; - - COLLADASW::FloatSourceF source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(fcu->totvert); - - switch (semantic) { +std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemantic::Semantics semantic, FCurve *fcu, const std::string& anim_id, const char *axis_name) +{ + std::string source_id = anim_id + get_semantic_suffix(semantic); + + //bool is_rotation = !strcmp(fcu->rna_path, "rotation"); + bool is_angle = false; + + if (strstr(fcu->rna_path, "rotation")) is_angle = true; + + COLLADASW::FloatSourceF source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(fcu->totvert); + + switch (semantic) { case COLLADASW::InputSemantic::INPUT: case COLLADASW::InputSemantic::OUTPUT: - source.setAccessorStride(1); + source.setAccessorStride(1); break; case COLLADASW::InputSemantic::IN_TANGENT: case COLLADASW::InputSemantic::OUT_TANGENT: - source.setAccessorStride(2); + source.setAccessorStride(2); break; - } - - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_angle, axis_name, false); + } - source.prepareToAppendValues(); - for (unsigned int i = 0; i < fcu->totvert; i++) { - float values[3]; // be careful! - int length = 0; - get_source_values(&fcu->bezt[i], semantic, is_angle, values, &length); - for (int j = 0; j < length; j++) - source.appendValues(values[j]); - } + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, is_angle, axis_name, false); - source.finish(); + source.prepareToAppendValues(); - return source_id; + for (unsigned int i = 0; i < fcu->totvert; i++) { + float values[3]; // be careful! + int length = 0; + get_source_values(&fcu->bezt[i], semantic, is_angle, values, &length); + for (int j = 0; j < length; j++) + source.appendValues(values[j]); } - //Currently called only to get OUTPUT source values ( if rotation and hence the axis is also specified ) - std::string AnimationExporter::create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name) - { - std::string source_id = anim_id + get_semantic_suffix(semantic); - - COLLADASW::FloatSourceF source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(tot); - source.setAccessorStride(1); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_rot, axis_name, false); - - source.prepareToAppendValues(); - - for (int i = 0; i < tot; i++) { - float val = v[i]; - ////if (semantic == COLLADASW::InputSemantic::INPUT) - // val = convert_time(val); - //else - if (is_rot) - val *= 180.0f / M_PI; - source.appendValues(val); - } + source.finish(); - source.finish(); + return source_id; +} - return source_id; +//Currently called only to get OUTPUT source values ( if rotation and hence the axis is also specified ) +std::string AnimationExporter::create_source_from_array(COLLADASW::InputSemantic::Semantics semantic, float *v, int tot, bool is_rot, const std::string& anim_id, const char *axis_name) +{ + std::string source_id = anim_id + get_semantic_suffix(semantic); + + COLLADASW::FloatSourceF source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(tot); + source.setAccessorStride(1); + + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, is_rot, axis_name, false); + + source.prepareToAppendValues(); + + for (int i = 0; i < tot; i++) { + float val = v[i]; + ////if (semantic == COLLADASW::InputSemantic::INPUT) + // val = convert_time(val); + //else + if (is_rot) + val *= 180.0f / M_PI; + source.appendValues(val); } -// only used for sources with INPUT semantic - std::string AnimationExporter::create_source_from_vector(COLLADASW::InputSemantic::Semantics semantic, std::vector &fra, bool is_rot, const std::string& anim_id, const char *axis_name) - { - std::string source_id = anim_id + get_semantic_suffix(semantic); - - COLLADASW::FloatSourceF source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(fra.size()); - source.setAccessorStride(1); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, is_rot, axis_name, false); - - source.prepareToAppendValues(); - - std::vector::iterator it; - for (it = fra.begin(); it != fra.end(); it++) { - float val = *it; - //if (semantic == COLLADASW::InputSemantic::INPUT) - val = convert_time(val); - /*else if (is_rot) - val = convert_angle(val);*/ - source.appendValues(val); - } - source.finish(); + source.finish(); - return source_id; + return source_id; +} +// only used for sources with INPUT semantic +std::string AnimationExporter::create_source_from_vector(COLLADASW::InputSemantic::Semantics semantic, std::vector &fra, bool is_rot, const std::string& anim_id, const char *axis_name) +{ + std::string source_id = anim_id + get_semantic_suffix(semantic); + + COLLADASW::FloatSourceF source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(fra.size()); + source.setAccessorStride(1); + + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, is_rot, axis_name, false); + + source.prepareToAppendValues(); + + std::vector::iterator it; + for (it = fra.begin(); it != fra.end(); it++) { + float val = *it; + //if (semantic == COLLADASW::InputSemantic::INPUT) + val = convert_time(val); + /*else if (is_rot) + val = convert_angle(val);*/ + source.appendValues(val); } - std::string AnimationExporter::create_4x4_source(std::vector &frames , Object * ob_arm, Bone *bone , const std::string& anim_id) - { - COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; - std::string source_id = anim_id + get_semantic_suffix(semantic); + source.finish(); - COLLADASW::Float4x4Source source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(frames.size()); - source.setAccessorStride(16); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, false, NULL, true); + return source_id; +} - source.prepareToAppendValues(); - - bPoseChannel *parchan = NULL; - bPoseChannel *pchan = NULL; - bPose *pose = ob_arm->pose; +std::string AnimationExporter::create_4x4_source(std::vector &frames , Object * ob_arm, Bone *bone , const std::string& anim_id) +{ + COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; + std::string source_id = anim_id + get_semantic_suffix(semantic); - pchan = get_pose_channel(pose, bone->name); + COLLADASW::Float4x4Source source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(frames.size()); + source.setAccessorStride(16); - if (!pchan) - return ""; + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, false, NULL, true); - parchan = pchan->parent; + source.prepareToAppendValues(); - enable_fcurves(ob_arm->adt->action, bone->name); + bPoseChannel *parchan = NULL; + bPoseChannel *pchan = NULL; + bPose *pose = ob_arm->pose; - std::vector::iterator it; - int j = 0; - for (it = frames.begin(); it != frames.end(); it++) { - float mat[4][4], ipar[4][4]; + pchan = get_pose_channel(pose, bone->name); - float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + if (!pchan) + return ""; - BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + parchan = pchan->parent; - // compute bone local mat - if (bone->parent) { - invert_m4_m4(ipar, parchan->pose_mat); - mul_m4_m4m4(mat, pchan->pose_mat, ipar); - } - else - copy_m4_m4(mat, pchan->pose_mat); - UnitConverter converter; + enable_fcurves(ob_arm->adt->action, bone->name); - float outmat[4][4]; - converter.mat4_to_dae(outmat,mat); + std::vector::iterator it; + int j = 0; + for (it = frames.begin(); it != frames.end(); it++) { + float mat[4][4], ipar[4][4]; + float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); - source.appendValues(outmat); - + BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); - j++; + // compute bone local mat + if (bone->parent) { + invert_m4_m4(ipar, parchan->pose_mat); + mul_m4_m4m4(mat, pchan->pose_mat, ipar); } + else + copy_m4_m4(mat, pchan->pose_mat); + UnitConverter converter; - enable_fcurves(ob_arm->adt->action, NULL); + float outmat[4][4]; + converter.mat4_to_dae(outmat,mat); - source.finish(); - return source_id; - } - // only used for sources with OUTPUT semantic ( locations and scale) - std::string AnimationExporter::create_xyz_source(float *v, int tot, const std::string& anim_id) - { - COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; - std::string source_id = anim_id + get_semantic_suffix(semantic); - - COLLADASW::FloatSourceF source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(tot); - source.setAccessorStride(3); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - add_source_parameters(param, semantic, false, NULL, false); - - source.prepareToAppendValues(); - - for (int i = 0; i < tot; i++) { - source.appendValues(*v, *(v + 1), *(v + 2)); - v += 3; - } + source.appendValues(outmat); - source.finish(); - return source_id; + j++; } - std::string AnimationExporter::create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents) - { - std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION); + enable_fcurves(ob_arm->adt->action, NULL); - COLLADASW::NameSource source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(fcu->totvert); - source.setAccessorStride(1); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("INTERPOLATION"); + source.finish(); - source.prepareToAppendValues(); + return source_id; +} +// only used for sources with OUTPUT semantic ( locations and scale) +std::string AnimationExporter::create_xyz_source(float *v, int tot, const std::string& anim_id) +{ + COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT; + std::string source_id = anim_id + get_semantic_suffix(semantic); - *has_tangents = false; + COLLADASW::FloatSourceF source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(tot); + source.setAccessorStride(3); - for (unsigned int i = 0; i < fcu->totvert; i++) { - if (fcu->bezt[i].ipo==BEZT_IPO_BEZ) { - source.appendValues(BEZIER_NAME); - *has_tangents = true; - } else if (fcu->bezt[i].ipo==BEZT_IPO_CONST) { - source.appendValues(STEP_NAME); - } else { // BEZT_IPO_LIN - source.appendValues(LINEAR_NAME); - } - } - // unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + add_source_parameters(param, semantic, false, NULL, false); - source.finish(); + source.prepareToAppendValues(); - return source_id; + for (int i = 0; i < tot; i++) { + source.appendValues(*v, *(v + 1), *(v + 2)); + v += 3; } - std::string AnimationExporter::fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name) - { - std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION); + source.finish(); + + return source_id; +} + +std::string AnimationExporter::create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents) +{ + std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION); + + COLLADASW::NameSource source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(fcu->totvert); + source.setAccessorStride(1); + + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + param.push_back("INTERPOLATION"); - COLLADASW::NameSource source(mSW); - source.setId(source_id); - source.setArrayId(source_id + ARRAY_ID_SUFFIX); - source.setAccessorCount(tot); - source.setAccessorStride(1); - - COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); - param.push_back("INTERPOLATION"); + source.prepareToAppendValues(); - source.prepareToAppendValues(); + *has_tangents = false; - for (int i = 0; i < tot; i++) { + for (unsigned int i = 0; i < fcu->totvert; i++) { + if (fcu->bezt[i].ipo==BEZT_IPO_BEZ) { + source.appendValues(BEZIER_NAME); + *has_tangents = true; + } else if (fcu->bezt[i].ipo==BEZT_IPO_CONST) { + source.appendValues(STEP_NAME); + } else { // BEZT_IPO_LIN source.appendValues(LINEAR_NAME); } + } + // unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS + + source.finish(); + + return source_id; +} + +std::string AnimationExporter::fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name) +{ + std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION); + + COLLADASW::NameSource source(mSW); + source.setId(source_id); + source.setArrayId(source_id + ARRAY_ID_SUFFIX); + source.setAccessorCount(tot); + source.setAccessorStride(1); + + COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList(); + param.push_back("INTERPOLATION"); - source.finish(); + source.prepareToAppendValues(); - return source_id; + for (int i = 0; i < tot; i++) { + source.appendValues(LINEAR_NAME); } - std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) - { - std::string tm_name; - // when given rna_path, determine tm_type from it - if (rna_path) { - char *name = extract_transform_name(rna_path); - - if (!strcmp(name, "color")) - tm_type = 1; - else if (!strcmp(name, "spot_size")) - tm_type = 2; - else if (!strcmp(name, "spot_blend")) - tm_type = 3; - else if (!strcmp(name, "distance")) - tm_type = 4; - else - tm_type = -1; - } + source.finish(); - switch (tm_type) { + return source_id; +} + +std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) +{ + std::string tm_name; + // when given rna_path, determine tm_type from it + if (rna_path) { + char *name = extract_transform_name(rna_path); + + if (!strcmp(name, "color")) + tm_type = 1; + else if (!strcmp(name, "spot_size")) + tm_type = 2; + else if (!strcmp(name, "spot_blend")) + tm_type = 3; + else if (!strcmp(name, "distance")) + tm_type = 4; + else + tm_type = -1; + } + + switch (tm_type) { case 1: tm_name = "color"; break; @@ -906,43 +906,43 @@ void AnimationExporter::operator() (Object *ob) case 4: tm_name = "blender/blender_dist"; break; - + default: tm_name = ""; break; - } - - if (tm_name.size()) { - if (axis_name != "") - return tm_name + "." + std::string(axis_name); - else - return tm_name; - } + } - return std::string(""); + if (tm_name.size()) { + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; } - - std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) - { - std::string tm_name; - // when given rna_path, determine tm_type from it - if (rna_path) { - char *name = extract_transform_name(rna_path); - - if (!strcmp(name, "lens")) - tm_type = 0; - else if (!strcmp(name, "ortho_scale")) - tm_type = 1; - else if (!strcmp(name, "clip_end")) - tm_type = 2; - else if (!strcmp(name, "clip_start")) - tm_type = 3; - - else - tm_type = -1; - } - switch (tm_type) { + return std::string(""); +} + +std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) +{ + std::string tm_name; + // when given rna_path, determine tm_type from it + if (rna_path) { + char *name = extract_transform_name(rna_path); + + if (!strcmp(name, "lens")) + tm_type = 0; + else if (!strcmp(name, "ortho_scale")) + tm_type = 1; + else if (!strcmp(name, "clip_end")) + tm_type = 2; + else if (!strcmp(name, "clip_start")) + tm_type = 3; + + else + tm_type = -1; + } + + switch (tm_type) { case 0: tm_name = "xfov"; break; @@ -955,56 +955,56 @@ void AnimationExporter::operator() (Object *ob) case 3: tm_name = "znear"; break; - + default: tm_name = ""; break; - } - - if (tm_name.size()) { - if (axis_name != "") - return tm_name + "." + std::string(axis_name); - else - return tm_name; - } + } - return std::string(""); + if (tm_name.size()) { + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; } - // Assign sid of the animated parameter or transform - // for rotation, axis name is always appended and the value of append_axis is ignored - std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) - { - std::string tm_name; - bool is_rotation =false; - // when given rna_path, determine tm_type from it - if (rna_path) { - char *name = extract_transform_name(rna_path); - - if (!strcmp(name, "rotation_euler")) - tm_type = 0; - else if (!strcmp(name, "rotation_quaternion")) - tm_type = 1; - else if (!strcmp(name, "scale")) - tm_type = 2; - else if (!strcmp(name, "location")) - tm_type = 3; - else if (!strcmp(name, "specular_hardness")) - tm_type = 4; - else if (!strcmp(name, "specular_color")) - tm_type = 5; - else if (!strcmp(name, "diffuse_color")) - tm_type = 6; - else if (!strcmp(name, "alpha")) - tm_type = 7; - else if (!strcmp(name, "ior")) - tm_type = 8; - - else - tm_type = -1; - } + return std::string(""); +} + +// Assign sid of the animated parameter or transform +// for rotation, axis name is always appended and the value of append_axis is ignored +std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis) +{ + std::string tm_name; + bool is_rotation =false; + // when given rna_path, determine tm_type from it + if (rna_path) { + char *name = extract_transform_name(rna_path); + + if (!strcmp(name, "rotation_euler")) + tm_type = 0; + else if (!strcmp(name, "rotation_quaternion")) + tm_type = 1; + else if (!strcmp(name, "scale")) + tm_type = 2; + else if (!strcmp(name, "location")) + tm_type = 3; + else if (!strcmp(name, "specular_hardness")) + tm_type = 4; + else if (!strcmp(name, "specular_color")) + tm_type = 5; + else if (!strcmp(name, "diffuse_color")) + tm_type = 6; + else if (!strcmp(name, "alpha")) + tm_type = 7; + else if (!strcmp(name, "ior")) + tm_type = 8; - switch (tm_type) { + else + tm_type = -1; + } + + switch (tm_type) { case 0: case 1: tm_name = "rotation"; @@ -1031,173 +1031,173 @@ void AnimationExporter::operator() (Object *ob) case 8: tm_name = "index_of_refraction"; break; - + default: tm_name = ""; break; - } - - if (tm_name.size()) { - if (is_rotation) - return tm_name + std::string(axis_name) + ".ANGLE"; - else - if (axis_name != "") - return tm_name + "." + std::string(axis_name); - else - return tm_name; - } - - return std::string(""); } - char* AnimationExporter::extract_transform_name(char *rna_path) - { - char *dot = strrchr(rna_path, '.'); - return dot ? (dot + 1) : rna_path; + if (tm_name.size()) { + if (is_rotation) + return tm_name + std::string(axis_name) + ".ANGLE"; + else + if (axis_name != "") + return tm_name + "." + std::string(axis_name); + else + return tm_name; } - //find keyframes of all the objects animations - void AnimationExporter::find_frames(Object *ob, std::vector &fra) - { - FCurve *fcu= (FCurve*)ob->adt->action->curves.first; + return std::string(""); +} - for (; fcu; fcu = fcu->next) { - - for (unsigned int i = 0; i < fcu->totvert; i++) { - float f = fcu->bezt[i].vec[1][0]; // - if (std::find(fra.begin(), fra.end(), f) == fra.end()) - fra.push_back(f); - } - } +char* AnimationExporter::extract_transform_name(char *rna_path) +{ + char *dot = strrchr(rna_path, '.'); + return dot ? (dot + 1) : rna_path; +} - // keep the keys in ascending order - std::sort(fra.begin(), fra.end()); - } +//find keyframes of all the objects animations +void AnimationExporter::find_frames(Object *ob, std::vector &fra) +{ + FCurve *fcu= (FCurve*)ob->adt->action->curves.first; - + for (; fcu; fcu = fcu->next) { - // enable fcurves driving a specific bone, disable all the rest - // if bone_name = NULL enable all fcurves - void AnimationExporter::enable_fcurves(bAction *act, char *bone_name) - { - FCurve *fcu; - char prefix[200]; - - 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 (!strncmp(fcu->rna_path, prefix, strlen(prefix))) - fcu->flag &= ~FCURVE_DISABLED; - else - fcu->flag |= FCURVE_DISABLED; - } - else { - fcu->flag &= ~FCURVE_DISABLED; - } + for (unsigned int i = 0; i < fcu->totvert; i++) { + float f = fcu->bezt[i].vec[1][0]; + if (std::find(fra.begin(), fra.end(), f) == fra.end()) + fra.push_back(f); } } - - bool AnimationExporter::hasAnimations(Scene *sce) - { - Base *base= (Base*) sce->base.first; - - while(base) { - Object *ob = base->object; - - FCurve *fcu = 0; - //Check for object transform animations - if(ob->adt && ob->adt->action) - fcu = (FCurve*)ob->adt->action->curves.first; - //Check for Lamp parameter animations - else if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) - fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); - //Check for Camera parameter animations - else if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) - fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); - - //Check Material Effect parameter animations. - for(int a = 0; a < ob->totcol; a++) - { - Material *ma = give_current_material(ob, a+1); - if (!ma) continue; - if(ma->adt && ma->adt->action) - { - fcu = (FCurve*)ma->adt->action->curves.first; - } - } - if ( fcu) - return true; - base= base->next; + // keep the keys in ascending order + std::sort(fra.begin(), fra.end()); +} + + + +// enable fcurves driving a specific bone, disable all the rest +// if bone_name = NULL enable all fcurves +void AnimationExporter::enable_fcurves(bAction *act, char *bone_name) +{ + FCurve *fcu; + char prefix[200]; + + 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 (!strncmp(fcu->rna_path, prefix, strlen(prefix))) + fcu->flag &= ~FCURVE_DISABLED; + else + fcu->flag |= FCURVE_DISABLED; + } + else { + fcu->flag &= ~FCURVE_DISABLED; } - return false; } +} - //------------------------------- Not used in the new system.-------------------------------------------------------- - void AnimationExporter::find_rotation_frames(Object *ob, std::vector &fra, const char *prefix, int rotmode) - { - if (rotmode > 0) - find_frames(ob, fra, prefix, "rotation_euler"); - else if (rotmode == ROT_MODE_QUAT) - find_frames(ob, fra, prefix, "rotation_quaternion"); - /*else if (rotmode == ROT_MODE_AXISANGLE) - ;*/ - } +bool AnimationExporter::hasAnimations(Scene *sce) +{ + Base *base= (Base*) sce->base.first; - void AnimationExporter::find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name) - { - FCurve *fcu= (FCurve*)ob->adt->action->curves.first; - - for (; fcu; fcu = fcu->next) { - if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix))) - continue; - - char *name = extract_transform_name(fcu->rna_path); - if (!strcmp(name, tm_name)) { - for (unsigned int i = 0; i < fcu->totvert; i++) { - float f = fcu->bezt[i].vec[1][0]; // - if (std::find(fra.begin(), fra.end(), f) == fra.end()) - fra.push_back(f); - } + while(base) { + Object *ob = base->object; + + FCurve *fcu = 0; + //Check for object transform animations + if(ob->adt && ob->adt->action) + fcu = (FCurve*)ob->adt->action->curves.first; + //Check for Lamp parameter animations + else if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) + fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); + //Check for Camera parameter animations + else if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) + fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); + + //Check Material Effect parameter animations. + for(int a = 0; a < ob->totcol; a++) + { + Material *ma = give_current_material(ob, a+1); + if (!ma) continue; + if(ma->adt && ma->adt->action) + { + fcu = (FCurve*)ma->adt->action->curves.first; } } - // keep the keys in ascending order - std::sort(fra.begin(), fra.end()); + if ( fcu) + return true; + base= base->next; } + return false; +} - void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone) - { - if (!ob_arm->adt) - return; - - //write bone animations for 3 transform types - //i=0 --> rotations - //i=1 --> scale - //i=2 --> location - for (int i = 0; i < 3; i++) - sample_and_write_bone_animation(ob_arm, bone, i); - - for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) - write_bone_animation(ob_arm, child); +//------------------------------- Not used in the new system.-------------------------------------------------------- +void AnimationExporter::find_rotation_frames(Object *ob, std::vector &fra, const char *prefix, int rotmode) +{ + if (rotmode > 0) + find_frames(ob, fra, prefix, "rotation_euler"); + else if (rotmode == ROT_MODE_QUAT) + find_frames(ob, fra, prefix, "rotation_quaternion"); + /*else if (rotmode == ROT_MODE_AXISANGLE) + ;*/ +} + +void AnimationExporter::find_frames(Object *ob, std::vector &fra, const char *prefix, const char *tm_name) +{ + FCurve *fcu= (FCurve*)ob->adt->action->curves.first; + + for (; fcu; fcu = fcu->next) { + if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix))) + continue; + + char *name = extract_transform_name(fcu->rna_path); + if (!strcmp(name, tm_name)) { + for (unsigned int i = 0; i < fcu->totvert; i++) { + float f = fcu->bezt[i].vec[1][0]; + if (std::find(fra.begin(), fra.end(), f) == fra.end()) + fra.push_back(f); + } + } } - void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) - { - bArmature *arm = (bArmature*)ob_arm->data; - int flag = arm->flag; - std::vector fra; - char prefix[256]; + // keep the keys in ascending order + std::sort(fra.begin(), fra.end()); +} - BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); +void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone) +{ + if (!ob_arm->adt) + return; + + //write bone animations for 3 transform types + //i=0 --> rotations + //i=1 --> scale + //i=2 --> location + for (int i = 0; i < 3; i++) + sample_and_write_bone_animation(ob_arm, bone, i); + + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) + write_bone_animation(ob_arm, child); +} - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); - if (!pchan) - return; - //Fill frame array with key frame values framed at @param:transform_type - switch (transform_type) { +void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type) +{ + bArmature *arm = (bArmature*)ob_arm->data; + int flag = arm->flag; + std::vector fra; + char prefix[256]; + + BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); + + bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + if (!pchan) + return; + //Fill frame array with key frame values framed at @param:transform_type + switch (transform_type) { case 0: find_rotation_frames(ob_arm, fra, prefix, pchan->rotmode); break; @@ -1209,77 +1209,77 @@ void AnimationExporter::operator() (Object *ob) break; default: return; - } + } - // exit rest position - if (flag & ARM_RESTPOS) { - arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); - } - //v array will hold all values which will be exported. - if (fra.size()) { - float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames"); - sample_animation(values, fra, transform_type, bone, ob_arm, pchan); - - if (transform_type == 0) { - // write x, y, z curves separately if it is rotation - float *axisValues = (float*)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames"); - - for (int i = 0; i < 3; i++) { - for (unsigned int j = 0; j < fra.size(); j++) - axisValues[j] = values[j * 3 + i]; - - dae_bone_animation(fra, axisValues, transform_type, i, id_name(ob_arm), bone->name); - } - MEM_freeN(axisValues); - } - else { - // write xyz at once if it is location or scale - dae_bone_animation(fra, values, transform_type, -1, id_name(ob_arm), bone->name); - } + // exit rest position + if (flag & ARM_RESTPOS) { + arm->flag &= ~ARM_RESTPOS; + where_is_pose(scene, ob_arm); + } + //v array will hold all values which will be exported. + if (fra.size()) { + float *values = (float*)MEM_callocN(sizeof(float) * 3 * fra.size(), "temp. anim frames"); + sample_animation(values, fra, transform_type, bone, ob_arm, pchan); - MEM_freeN(values); + if (transform_type == 0) { + // write x, y, z curves separately if it is rotation + float *axisValues = (float*)MEM_callocN(sizeof(float) * fra.size(), "temp. anim frames"); + + for (int i = 0; i < 3; i++) { + for (unsigned int j = 0; j < fra.size(); j++) + axisValues[j] = values[j * 3 + i]; + + dae_bone_animation(fra, axisValues, transform_type, i, id_name(ob_arm), bone->name); + } + MEM_freeN(axisValues); + } + else { + // write xyz at once if it is location or scale + dae_bone_animation(fra, values, transform_type, -1, id_name(ob_arm), bone->name); } - // restore restpos - if (flag & ARM_RESTPOS) - arm->flag = flag; - where_is_pose(scene, ob_arm); + MEM_freeN(values); } - void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) - { - bPoseChannel *parchan = NULL; - bPose *pose = ob_arm->pose; + // restore restpos + if (flag & ARM_RESTPOS) + arm->flag = flag; + where_is_pose(scene, ob_arm); +} - pchan = get_pose_channel(pose, bone->name); +void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) +{ + bPoseChannel *parchan = NULL; + bPose *pose = ob_arm->pose; - if (!pchan) - return; + pchan = get_pose_channel(pose, bone->name); - parchan = pchan->parent; + if (!pchan) + return; - enable_fcurves(ob_arm->adt->action, bone->name); + parchan = pchan->parent; - std::vector::iterator it; - for (it = frames.begin(); it != frames.end(); it++) { - float mat[4][4], ipar[4][4]; + enable_fcurves(ob_arm->adt->action, bone->name); - float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); + std::vector::iterator it; + for (it = frames.begin(); it != frames.end(); it++) { + float mat[4][4], ipar[4][4]; + float ctime = bsystem_time(scene, ob_arm, *it, 0.0f); - BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); - // compute bone local mat - if (bone->parent) { - invert_m4_m4(ipar, parchan->pose_mat); - mul_m4_m4m4(mat, pchan->pose_mat, ipar); - } - else - copy_m4_m4(mat, pchan->pose_mat); + BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); + where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + + // compute bone local mat + if (bone->parent) { + invert_m4_m4(ipar, parchan->pose_mat); + mul_m4_m4m4(mat, pchan->pose_mat, ipar); + } + else + copy_m4_m4(mat, pchan->pose_mat); - switch (type) { + switch (type) { case 0: mat4_to_eul(v, mat); break; @@ -1289,12 +1289,10 @@ void AnimationExporter::operator() (Object *ob) case 2: copy_v3_v3(v, mat[3]); break; - } - - v += 3; } - enable_fcurves(ob_arm->adt->action, NULL); + v += 3; } - + enable_fcurves(ob_arm->adt->action, NULL); +} diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 4a3cd5eeb06..db32664f736 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -89,17 +89,17 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) { COLLADAFW::FloatOrDoubleArray& input = curve->getInputValues(); COLLADAFW::FloatOrDoubleArray& output = curve->getOutputValues(); - + if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER || curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP ) { - COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); - COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); + COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); + COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); } float fps = (float)FPS; size_t dim = curve->getOutDimension(); unsigned int i; - + std::vector& fcurves = curve_map[curve->getUniqueId()]; switch (dim) { @@ -110,18 +110,18 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) { for (i = 0; i < dim; i++ ) { FCurve *fcu = (FCurve*)MEM_callocN(sizeof(FCurve), "FCurve"); - + fcu->flag = (FCURVE_VISIBLE|FCURVE_AUTO_HANDLES|FCURVE_SELECTED); // fcu->rna_path = BLI_strdupn(path, strlen(path)); fcu->array_index = 0; fcu->totvert = curve->getKeyCount(); - + // create beztriple for each key for (unsigned int j = 0; j < curve->getKeyCount(); j++) { BezTriple bez; memset(&bez, 0, sizeof(BezTriple)); - + // input, output bez.vec[1][0] = bc_get_float_value(input, j) * fps; bez.vec[1][1] = bc_get_float_value(output, j * dim + i); @@ -131,20 +131,20 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP) { COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues(); - COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); + COLLADAFW::FloatOrDoubleArray& outtan = curve->getOutTangentValues(); // intangent - bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim ) + (2 * i)) * fps; - bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim )+ (2 * i) + 1); + bez.vec[0][0] = bc_get_float_value(intan, (j * 2 * dim ) + (2 * i)) * fps; + bez.vec[0][1] = bc_get_float_value(intan, (j * 2 * dim )+ (2 * i) + 1); - // outtangent - bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps; - bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1); - if(curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) + // outtangent + bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps; + bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1); + if(curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) bez.ipo = BEZT_IPO_BEZ; - else - bez.ipo = BEZT_IPO_CONST; - //bez.h1 = bez.h2 = HD_AUTO; + else + bez.ipo = BEZT_IPO_CONST; + //bez.h1 = bez.h2 = HD_AUTO; } else { @@ -153,7 +153,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) } // bez.ipo = U.ipo_new; /* use default interpolation mode here... */ bez.f1 = bez.f2 = bez.f3 = SELECT; - + insert_bezt_fcurve(fcu, &bez, 0); } @@ -306,9 +306,9 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim) bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList* animlist) { const COLLADAFW::UniqueId& animlist_id = animlist->getUniqueId(); - + animlist_map[animlist_id] = animlist; - + #if 0 // should not happen @@ -317,10 +317,10 @@ bool AnimationImporter::write_animation_list(const COLLADAFW::AnimationList* ani } // for bones rna_path is like: pose.bones["bone-name"].rotation - + #endif - + return true; } @@ -433,7 +433,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act) //sets the rna_path and array index to curve void AnimationImporter::modify_fcurve(std::vector* curves , char* rna_path , int array_index ) -{ +{ std::vector::iterator it; int i; for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) { @@ -450,18 +450,18 @@ void AnimationImporter::modify_fcurve(std::vector* curves , char* rna_p void AnimationImporter::find_frames( std::vector* frames , std::vector* curves) { std::vector::iterator iter; - for (iter = curves->begin(); iter != curves->end(); iter++) { - FCurve *fcu = *iter; - - 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()) - frames->push_back(fra); - - } + for (iter = curves->begin(); iter != curves->end(); iter++) { + FCurve *fcu = *iter; + + 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()) + frames->push_back(fra); + } + } } //creates the rna_paths and array indices of fcurves from animations using transformation and bound animation class of each animation. @@ -472,18 +472,18 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType(); bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX; bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; - + //to check if the no of curves are valid bool xyz = ((tm_type == COLLADAFW::Transformation::TRANSLATE ||tm_type == COLLADAFW::Transformation::SCALE) && binding->animationClass == COLLADAFW::AnimationList::POSITION_XYZ); - - + + if (!((!xyz && curves->size() == 1) || (xyz && curves->size() == 3) || is_matrix)) { fprintf(stderr, "expected %d curves, got %d\n", xyz ? 3 : 1, (int)curves->size()); return; } - + char rna_path[100]; - + switch (tm_type) { case COLLADAFW::Transformation::TRANSLATE: case COLLADAFW::Transformation::SCALE: @@ -495,80 +495,80 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path)); switch (binding->animationClass) { - case COLLADAFW::AnimationList::POSITION_X: - modify_fcurve(curves, rna_path, 0 ); - break; - case COLLADAFW::AnimationList::POSITION_Y: - modify_fcurve(curves, rna_path, 1 ); - break; - case COLLADAFW::AnimationList::POSITION_Z: - modify_fcurve(curves, rna_path, 2 ); - break; - case COLLADAFW::AnimationList::POSITION_XYZ: - modify_fcurve(curves, rna_path, -1 ); - break; - default: - fprintf(stderr, "AnimationClass %d is not supported for %s.\n", - binding->animationClass, loc ? "TRANSLATE" : "SCALE"); - } - break; + case COLLADAFW::AnimationList::POSITION_X: + modify_fcurve(curves, rna_path, 0 ); + break; + case COLLADAFW::AnimationList::POSITION_Y: + modify_fcurve(curves, rna_path, 1 ); + break; + case COLLADAFW::AnimationList::POSITION_Z: + modify_fcurve(curves, rna_path, 2 ); + break; + case COLLADAFW::AnimationList::POSITION_XYZ: + modify_fcurve(curves, rna_path, -1 ); + break; + default: + fprintf(stderr, "AnimationClass %d is not supported for %s.\n", + binding->animationClass, loc ? "TRANSLATE" : "SCALE"); + } + break; } - - + + case COLLADAFW::Transformation::ROTATE: { if (is_joint) BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path); else BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path)); - std::vector::iterator iter; + std::vector::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) fcurve_deg_to_rad(fcu); } COLLADAFW::Rotate* rot = (COLLADAFW::Rotate*)transform; COLLADABU::Math::Vector3& axis = rot->getRotationAxis(); - + switch (binding->animationClass) { - case COLLADAFW::AnimationList::ANGLE: - if (COLLADABU::Math::Vector3::UNIT_X == axis) { - modify_fcurve(curves, rna_path, 0 ); - } - else if (COLLADABU::Math::Vector3::UNIT_Y == axis) { - modify_fcurve(curves, rna_path, 1 ); - } - else if (COLLADABU::Math::Vector3::UNIT_Z == axis) { - modify_fcurve(curves, rna_path, 2 ); - } - break; - case COLLADAFW::AnimationList::AXISANGLE: - // TODO convert axis-angle to quat? or XYZ? - default: - fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n", - binding->animationClass); - } + case COLLADAFW::AnimationList::ANGLE: + if (COLLADABU::Math::Vector3::UNIT_X == axis) { + modify_fcurve(curves, rna_path, 0 ); + } + else if (COLLADABU::Math::Vector3::UNIT_Y == axis) { + modify_fcurve(curves, rna_path, 1 ); + } + else if (COLLADABU::Math::Vector3::UNIT_Z == axis) { + modify_fcurve(curves, rna_path, 2 ); + } break; + case COLLADAFW::AnimationList::AXISANGLE: + // TODO convert axis-angle to quat? or XYZ? + default: + fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n", + binding->animationClass); + } + break; } - + case COLLADAFW::Transformation::MATRIX: /*{ - COLLADAFW::Matrix* mat = (COLLADAFW::Matrix*)transform; - COLLADABU::Math::Matrix4 mat4 = mat->getMatrix(); - switch (binding->animationClass) { - case COLLADAFW::AnimationList::TRANSFORM: - - } + COLLADAFW::Matrix* mat = (COLLADAFW::Matrix*)transform; + COLLADABU::Math::Matrix4 mat4 = mat->getMatrix(); + switch (binding->animationClass) { + case COLLADAFW::AnimationList::TRANSFORM: + + } }*/ break; case COLLADAFW::Transformation::SKEW: case COLLADAFW::Transformation::LOOKAT: fprintf(stderr, "Animation of SKEW and LOOKAT transformations is not supported yet.\n"); break; - } - + } + } //creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation. @@ -576,15 +576,15 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list { char rna_path[100]; BLI_strncpy(rna_path,anim_type, sizeof(rna_path)); - + const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); - //all the curves belonging to the current binding - std::vector animcurves; + //all the curves belonging to the current binding + std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { - animcurves = curve_map[bindings[j].animation]; - - switch (bindings[j].animationClass) { + animcurves = curve_map[bindings[j].animation]; + + switch (bindings[j].animationClass) { case COLLADAFW::AnimationList::COLOR_R: modify_fcurve(&animcurves, rna_path, 0 ); break; @@ -598,13 +598,13 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list case COLLADAFW::AnimationList::COLOR_RGBA: // to do-> set intensity modify_fcurve(&animcurves, rna_path, -1 ); break; - + default: fprintf(stderr, "AnimationClass %d is not supported for %s.\n", - bindings[j].animationClass, "COLOR" ); + bindings[j].animationClass, "COLOR" ); } - std::vector::iterator iter; + std::vector::iterator iter; //Add the curves of the current animation to the object for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve * fcu = *iter; @@ -612,7 +612,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list } } - + } void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, char * anim_type) @@ -625,7 +625,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); //all the curves belonging to the current binding - std::vector animcurves; + std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { animcurves = curve_map[bindings[j].animation]; @@ -671,28 +671,28 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& copy_m4_m4(rest, bone->arm_mat); invert_m4_m4(irest, rest); } - // new curves to assign matrix transform animation + // new curves to assign matrix transform animation FCurve *newcu[10]; // if tm_type is matrix, then create 10 curves: 4 rot, 3 loc, 3 scale unsigned int totcu = 10 ; - const char *tm_str = NULL; + const char *tm_str = NULL; char rna_path[200]; for (int i = 0; i < totcu; i++) { int axis = i; - if (i < 4) { - tm_str = "rotation_quaternion"; - axis = i; - } - else if (i < 7) { - tm_str = "location"; - axis = i - 4; - } - else { - tm_str = "scale"; - axis = i - 7; - } - + if (i < 4) { + tm_str = "rotation_quaternion"; + axis = i; + } + else if (i < 7) { + tm_str = "location"; + axis = i - 4; + } + else { + tm_str = "scale"; + axis = i - 7; + } + if (is_joint) BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str); @@ -702,11 +702,11 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& newcu[i]->totvert = frames.size(); } - if (frames.size() == 0) + if (frames.size() == 0) return; -std::sort(frames.begin(), frames.end()); - + std::sort(frames.begin(), frames.end()); + std::vector::iterator it; // sample values at each frame @@ -717,7 +717,7 @@ std::sort(frames.begin(), frames.end()); float matfra[4][4]; unit_m4(matfra); - + // calc object-space mat evaluate_transform_at_frame(matfra, node, fra); @@ -743,23 +743,23 @@ std::sort(frames.begin(), frames.end()); } float rot[4], loc[3], scale[3]; - - mat4_to_quat(rot, mat); - /*for ( int i = 0 ; i < 4 ; i ++ ) - { - rot[i] = rot[i] * (180 / M_PI); - }*/ - copy_v3_v3(loc, mat[3]); - mat4_to_size(scale, mat); - + + mat4_to_quat(rot, mat); + /*for ( int i = 0 ; i < 4 ; i ++ ) + { + rot[i] = rot[i] * (180 / M_PI); + }*/ + copy_v3_v3(loc, mat[3]); + mat4_to_size(scale, mat); + // add keys for (int i = 0; i < totcu; i++) { - if (i < 4) - add_bezt(newcu[i], fra, rot[i]); - else if (i < 7) - add_bezt(newcu[i], fra, loc[i - 4]); - else - add_bezt(newcu[i], fra, scale[i - 7]); + if (i < 4) + add_bezt(newcu[i], fra, rot[i]); + else if (i < 7) + add_bezt(newcu[i], fra, loc[i - 4]); + else + add_bezt(newcu[i], fra, scale[i - 7]); } } verify_adt_action((ID*)&ob->id, 1); @@ -774,13 +774,13 @@ std::sort(frames.begin(), frames.end()); BLI_addtail(curves, newcu[i]); } - if (is_joint) { - bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); - chan->rotmode = ROT_MODE_QUAT; - } - else { - ob->rotmode = ROT_MODE_QUAT; - } + if (is_joint) { + bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + chan->rotmode = ROT_MODE_QUAT; + } + else { + ob->rotmode = ROT_MODE_QUAT; + } return; @@ -804,24 +804,24 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , bAction * act; bActionGroup *grp = NULL; - + if ( (animType->transform) != 0 ) { - const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; - char joint_path[200]; + const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; + char joint_path[200]; if ( is_joint ) - armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); - - + armature_importer->get_rna_path_for_joint(node, joint_path, sizeof(joint_path)); + + if (!ob->adt || !ob->adt->action) act = verify_adt_action((ID*)&ob->id, 1); else act = ob->adt->action; - - //Get the list of animation curves of the object - ListBase *AnimCurves = &(act->curves); + + //Get the list of animation curves of the object + ListBase *AnimCurves = &(act->curves); const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations(); - + //for each transformation in node for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) { COLLADAFW::Transformation *transform = nodeTransforms[i]; @@ -829,10 +829,10 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE; bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX; - + const COLLADAFW::UniqueId& listid = transform->getAnimationList(); - - //check if transformation has animations + + //check if transformation has animations if (animlist_map.find(listid) == animlist_map.end()) continue ; else { @@ -840,25 +840,25 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); //all the curves belonging to the current binding - std::vector animcurves; + std::vector animcurves; for (unsigned int j = 0; j < bindings.getCount(); j++) { - animcurves = curve_map[bindings[j].animation]; - if ( is_matrix ) - apply_matrix_curves(ob, animcurves, root , node, transform ); - else { + animcurves = curve_map[bindings[j].animation]; + if ( is_matrix ) + apply_matrix_curves(ob, animcurves, root , node, transform ); + else { //calculate rnapaths and array index of fcurves according to transformation and animation class - Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path ); - - std::vector::iterator iter; - //Add the curves of the current animation to the object - for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { - FCurve * fcu = *iter; - if ((ob->type == OB_ARMATURE)) - add_bone_fcurve( ob, node , fcu ); - else - BLI_addtail(AnimCurves, fcu); - } + Assign_transform_animations(transform, &bindings[j], &animcurves, is_joint, joint_path ); + + std::vector::iterator iter; + //Add the curves of the current animation to the object + for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { + FCurve * fcu = *iter; + if ((ob->type == OB_ARMATURE)) + add_bone_fcurve( ob, node , fcu ); + else + BLI_addtail(AnimCurves, fcu); } + } } } if (is_rotation) { @@ -880,7 +880,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , Lamp * lamp = (Lamp*) ob->data; if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID*)&lamp->id, 1); - else act = lamp->adt->action; + else act = lamp->adt->action; ListBase *AnimCurves = &(act->curves); const COLLADAFW::InstanceLightPointerArray& nodeLights = node->getInstanceLights(); @@ -892,23 +892,23 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , { const COLLADAFW::Color *col = &(light->getColor()); const COLLADAFW::UniqueId& listid = col->getAnimationList(); - + Assign_color_animations(listid, AnimCurves, "color"); } if ((animType->light & LIGHT_FOA) != 0 ) { const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle()); const COLLADAFW::UniqueId& listid = foa->getAnimationList(); - + Assign_float_animations( listid ,AnimCurves, "spot_size"); } if ( (animType->light & LIGHT_FOE) != 0 ) { const COLLADAFW::AnimatableFloat *foe = &(light->getFallOffExponent()); const COLLADAFW::UniqueId& listid = foe->getAnimationList(); - + Assign_float_animations( listid ,AnimCurves, "spot_blend"); - + } } } @@ -918,7 +918,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , Camera * camera = (Camera*) ob->data; if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID*)&camera->id, 1); - else act = camera->adt->action; + else act = camera->adt->action; ListBase *AnimCurves = &(act->curves); const COLLADAFW::InstanceCameraPointerArray& nodeCameras= node->getInstanceCameras(); @@ -957,12 +957,12 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , } } if ( animType->material != 0){ - Material *ma = give_current_material(ob, 1); - if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1); - else act = ma->adt->action; + Material *ma = give_current_material(ob, 1); + if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1); + else act = ma->adt->action; ListBase *AnimCurves = &(act->curves); - + const COLLADAFW::InstanceGeometryPointerArray& nodeGeoms = node->getInstanceGeometries(); for (unsigned int i = 0; i < nodeGeoms.getCount(); i++) { const COLLADAFW::MaterialBindingArray& matBinds = nodeGeoms[i]->getMaterialBindings(); @@ -988,7 +988,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList(); Assign_color_animations( listid, AnimCurves , "specular_color" ); } - + if((animType->material & MATERIAL_DIFF_COLOR) != 0){ const COLLADAFW::ColorOrTexture *cot = &(efc->getDiffuse()); const COLLADAFW::UniqueId& listid = cot->getColor().getAnimationList(); @@ -1005,15 +1005,15 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD std::map FW_object_map) { AnimMix *types = new AnimMix(); - + const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations(); - + //for each transformation in node for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) { COLLADAFW::Transformation *transform = nodeTransforms[i]; const COLLADAFW::UniqueId& listid = transform->getAnimationList(); - - //check if transformation has animations + + //check if transformation has animations if (animlist_map.find(listid) == animlist_map.end()) continue ; else { @@ -1028,9 +1028,9 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD types->light = setAnimType(&(light->getColor()),(types->light), LIGHT_COLOR); types->light = setAnimType(&(light->getFallOffAngle()),(types->light), LIGHT_FOA); types->light = setAnimType(&(light->getFallOffExponent()),(types->light), LIGHT_FOE); - + if ( types->light != 0) break; - + } const COLLADAFW::InstanceCameraPointerArray& nodeCameras = node->getInstanceCameras(); @@ -1039,9 +1039,9 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) { - types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV); + types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV); } - else + else { types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XMAG); } @@ -1063,7 +1063,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD types->material = setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS); types->material = setAnimType(&(efc->getSpecular().getColor()),(types->material), MATERIAL_SPEC_COLOR); types->material = setAnimType(&(efc->getDiffuse().getColor()),(types->material), MATERIAL_DIFF_COLOR); - // types->material = setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY); + // types->material = setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY); types->material = setAnimType(&(efc->getIndexOfRefraction()),(types->material), MATERIAL_IOR); } } @@ -1101,7 +1101,7 @@ void AnimationImporter::find_frames_old(std::vector * frames, COLLADAFW:: const COLLADAFW::AnimationList *animlist = animlist_map[listid]; const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings(); - + if (bindings.getCount()) { //for each AnimationBinding get the fcurves which animate the transform for (unsigned int j = 0; j < bindings.getCount(); j++) { @@ -1113,7 +1113,7 @@ void AnimationImporter::find_frames_old(std::vector * frames, COLLADAFW:: 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) fcurve_deg_to_rad(fcu); @@ -1448,9 +1448,9 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float COLLADAFW::Transformation::TransformationType type = tm->getTransformationType(); if (type != COLLADAFW::Transformation::ROTATE && - type != COLLADAFW::Transformation::SCALE && - type != COLLADAFW::Transformation::TRANSLATE && - type != COLLADAFW::Transformation::MATRIX) { + type != COLLADAFW::Transformation::SCALE && + type != COLLADAFW::Transformation::TRANSLATE && + type != COLLADAFW::Transformation::MATRIX) { fprintf(stderr, "animation of transformation %d is not supported yet\n", type); return false; } @@ -1572,7 +1572,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float COLLADAFW::Matrix tm(matrix); dae_matrix_to_mat4(&tm, mat); - + std::vector::iterator it; return true; diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 18303eb2f0b..ed9a2171c87 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -88,7 +88,7 @@ private: void add_fcurves_to_object(Object *ob, std::vector& curves, char *rna_path, int array_index, Animation *animated); int typeFlag; - + enum lightAnim { // INANIMATE = 0, @@ -144,7 +144,7 @@ public: #if 0 virtual void change_eul_to_quat(Object *ob, bAction *act); #endif - + void translate_Animations( COLLADAFW::Node * Node , std::map& root_map, std::map& object_map , @@ -161,7 +161,7 @@ public: void Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves ,char * anim_type); void Assign_float_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves, char * anim_type); - + int setAnimType ( const COLLADAFW::Animatable * prop , int type, int addition); void modify_fcurve(std::vector* curves , char* rna_path , int array_index ); @@ -206,5 +206,5 @@ public: void extra_data_importer(std::string elementName); }; - - #endif + +#endif diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 92d06bb639f..de01c000373 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -188,7 +188,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) { add_bone_node(child, ob_arm); } - node.end(); + node.end(); //} } diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 2ec8ae540d2..27aee133557 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -87,7 +87,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p if ( it != finished_joints.end()) return; float mat[4][4]; - float obmat[4][4]; + float obmat[4][4]; // object-space get_node_mat(obmat, node, NULL, NULL); @@ -296,7 +296,7 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: et->setData("tip_z",&z); float vec[3] = {x,y,z}; copy_v3_v3(leaf.bone->tail, leaf.bone->head); - add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); + add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec); }else leaf_bones.push_back(leaf); } diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h index 4f4aed210f2..a197e612a87 100644 --- a/source/blender/collada/ArmatureImporter.h +++ b/source/blender/collada/ArmatureImporter.h @@ -115,7 +115,7 @@ private: void fix_leaf_bones(); - void set_pose ( Object * ob_arm , COLLADAFW::Node * root_node ,char * parentname, float parent_mat[][4]); + void set_pose ( Object * ob_arm , COLLADAFW::Node * root_node ,char * parentname, float parent_mat[][4]); #if 0 @@ -171,7 +171,7 @@ public: // gives a world-space mat bool get_joint_bind_mat(float m[][4], COLLADAFW::Node *joint); - + void set_tags_map( TagsMap& tags_map); }; diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 760fb2359a4..6032109b809 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -411,7 +411,7 @@ int MeshImporter::count_new_tris(COLLADAFW::Mesh *mesh, Mesh *me) } // TODO: import uv set names -void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //TODO:: Refactor. Possibly replace by iterators +void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //TODO:: Refactor. Possibly replace by iterators { unsigned int i; diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index ce0d561c524..1d890415ebe 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -266,9 +266,9 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapmat4_to_dae_double(dmat,local); + converter->mat4_to_dae_double(dmat,local); TransformBase::decompose(local, loc, rot, NULL, scale); if ( node.getType() == COLLADASW::Node::JOINT) -- cgit v1.2.3 From cbc812b757068c65effd90bdd4b08d7f4e25c342 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 4 Sep 2011 01:13:44 +0000 Subject: Fix [#28322] COLLADA imports messed up UVs Reported by Chad Gleason Imported index order could put mface->v4==0. We already know amount of verts, so use that instead. --- source/blender/collada/MeshImporter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source') diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 6032109b809..e9086f05628 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -220,8 +220,8 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs, if (quad) uvs.getUV(indices[index + 3], mtface->uv[3]); -#ifdef COLLADA_DEBUG - /*if (quad) { +#if 1 // #ifdef COLLADA_DEBUG + if (quad) { fprintf(stderr, "face uv:\n" "((%d, %d, %d, %d))\n" "((%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f), (%.1f, %.1f))\n", @@ -248,7 +248,7 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs, mtface->uv[0][0], mtface->uv[0][1], mtface->uv[1][0], mtface->uv[1][1], mtface->uv[2][0], mtface->uv[2][1]); - }*/ + } #endif } @@ -587,7 +587,7 @@ void MeshImporter::read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris) //T for (k = 0; k < index_list_array.getCount(); k++) { // get mtface by face index and uv set index MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k); - set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, mface->v4 != 0); + set_face_uv(&mtface[face_index], uvs, *index_list_array[k], index, vcount == 4); } #endif -- cgit v1.2.3 From 70e3541f3a4327db0fd3fd4070091ddfda313cfe Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 4 Sep 2011 01:27:16 +0000 Subject: BGE animations: Fixing a potential crash when using camera IPOs. The IPOs were being created off of blendercamera->adt->action when they should have been using the supplied action. Thanks to z0r for pointing out the problem and a potential fix. --- source/gameengine/Converter/KX_IpoConvert.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 0ee99f5335b..b13dbe324f5 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -257,7 +257,7 @@ SG_Controller *BL_CreateCameraIPO(struct bAction *action, KX_GameObject* camera ipocontr->m_clipstart = blendercamera->clipsta; ipocontr->m_clipend = blendercamera->clipend; - BL_InterpolatorList *adtList= GetAdtList(blendercamera->adt->action, converter); + BL_InterpolatorList *adtList= GetAdtList(action, converter); // For each active channel in the adtList add an // interpolator to the game object. -- cgit v1.2.3 From 103b06d4dfe0c5cda0eed2dad8d077e32aa056df Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sun, 4 Sep 2011 01:42:47 +0000 Subject: BGE animations: fixing initialization order issues for BL_ActionActuator and BL_ArmatureObject. Thanks to z0r for pointing them out and providing a fix. --- source/gameengine/Converter/BL_ActionActuator.cpp | 2 +- source/gameengine/Converter/BL_ArmatureObject.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 063544932de..895def17e8e 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -88,10 +88,10 @@ BL_ActionActuator::BL_ActionActuator(SCA_IObject* gameobj, m_blendin(blendin), m_blendstart(0), m_stridelength(stride), + m_layer_weight(layer_weight), m_playtype(playtype), m_priority(priority), m_layer(layer), - m_layer_weight(layer_weight), m_ipo_flags(ipo_flags), m_pose(NULL), m_blendpose(NULL), diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 395cae4ba87..684bd3f341e 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -231,10 +231,10 @@ BL_ArmatureObject::BL_ArmatureObject( m_timestep(0.040), m_activeAct(NULL), m_activePriority(999), + m_vert_deform_type(vert_deform_type), m_constraintNumber(0), m_channelNumber(0), - m_lastapplyframe(0.0), - m_vert_deform_type(vert_deform_type) + m_lastapplyframe(0.0) { m_armature = (bArmature *)armature->data; -- cgit v1.2.3 From caa1acb6b1d6b908e34be31c4b9bd026066b820f Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 4 Sep 2011 02:12:03 +0000 Subject: Prevent potential crasher, commonEffects could be empty. --- source/blender/collada/AnimationImporter.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index db32664f736..29c356ed8f0 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -1059,12 +1059,14 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD const COLLADAFW::UniqueId & matuid = matBinds[j].getReferencedMaterial(); const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) (FW_object_map[matuid]); const COLLADAFW::CommonEffectPointerArray& commonEffects = ef->getCommonEffects(); - COLLADAFW::EffectCommon *efc = commonEffects[0]; - types->material = setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS); - types->material = setAnimType(&(efc->getSpecular().getColor()),(types->material), MATERIAL_SPEC_COLOR); - types->material = setAnimType(&(efc->getDiffuse().getColor()),(types->material), MATERIAL_DIFF_COLOR); - // types->material = setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY); - types->material = setAnimType(&(efc->getIndexOfRefraction()),(types->material), MATERIAL_IOR); + if(!commonEffects.empty()) { + COLLADAFW::EffectCommon *efc = commonEffects[0]; + types->material = setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS); + types->material = setAnimType(&(efc->getSpecular().getColor()),(types->material), MATERIAL_SPEC_COLOR); + types->material = setAnimType(&(efc->getDiffuse().getColor()),(types->material), MATERIAL_DIFF_COLOR); + // types->material = setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY); + types->material = setAnimType(&(efc->getIndexOfRefraction()),(types->material), MATERIAL_IOR); + } } } return types; -- cgit v1.2.3 From 317908a330184799eecfe34ed47648d5323b43de Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 4 Sep 2011 11:13:41 +0000 Subject: Fix #28423: Screw-modifier crash in cunjunction with subsurf modifier Problems was caused by angle=2*pi and steps=2 in screw modifier. Such configuration produced duplicated geometry to close object and it was confusing for subsurf cache. Restrict steps=2 for screw modifier now, so now 3<=steps<=512. --- source/blender/makesrna/intern/rna_modifier.c | 2 +- source/blender/modifiers/intern/MOD_screw.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 37a629f46d0..22fdfcea29c 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2366,7 +2366,7 @@ static void rna_def_modifier_screw(BlenderRNA *brna) prop= RNA_def_property(srna, "steps", PROP_INT, PROP_UNSIGNED); RNA_def_property_range(prop, 2, 10000); - RNA_def_property_ui_range(prop, 2, 512, 1, 0); + RNA_def_property_ui_range(prop, 3, 512, 1, 0); RNA_def_property_ui_text(prop, "Steps", "Number of steps in the revolution"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index c5fdf465a0a..486c98f82a0 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -275,7 +275,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (fabsf(screw_ofs) <= (FLT_EPSILON*100.0f) && fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON*100.0f)) { close= 1; step_tot--; - if(step_tot < 2) step_tot= 2; + if(step_tot < 3) step_tot= 3; maxVerts = totvert * step_tot; /* -1 because we're joining back up */ maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ @@ -286,7 +286,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } else { close= 0; - if(step_tot < 2) step_tot= 2; + if(step_tot < 3) step_tot= 3; maxVerts = totvert * step_tot; /* -1 because we're joining back up */ maxEdges = (totvert * (step_tot-1)) + /* these are the edges between new verts */ -- cgit v1.2.3 From 7f5c5f8ecaf6d366293cadbd8db08d4516a9499f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 4 Sep 2011 11:38:53 +0000 Subject: Fix #28500: Reshape in multires modifier makes blender crash Multires doesn't store displacement for base mesh and reshaping when multires subdivision level is set to zero is crappy. Add report that reshape can't work with base level and cancel reshape operator. --- source/blender/editors/object/object_modifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index c96d7c1fd10..8813b0027cd 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1066,7 +1066,12 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) if (!mmd) return OPERATOR_CANCELLED; - + + if(mmd->lvl==0) { + BKE_report(op->reports, RPT_ERROR, "Reshape can work only with higher levels of subdivisions."); + return OPERATOR_CANCELLED; + } + CTX_DATA_BEGIN(C, Object*, selob, selected_editable_objects) { if(selob->type == OB_MESH && selob != ob) { secondob= selob; -- cgit v1.2.3 From 1cada203bcae3a65f34e5631f8e8e1ae22ce4415 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 4 Sep 2011 14:31:23 +0000 Subject: [#27884] Collada import: materials mismatch when 2 instance_geometry reference the same material Reported by David Roy Multi-materials used on different meshes would get ignored (resulting in white faces in textured view). --- source/blender/collada/MeshImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index e9086f05628..01eff8069c1 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -796,7 +796,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri std::multimap::iterator it; it=materials_mapped_to_geom.find(*geom_uid); while(it!=materials_mapped_to_geom.end()) { - if(it->second == ma_uid) return NULL; // do nothing if already found + if(it->second == ma_uid && it->first == *geom_uid) return NULL; // do nothing if already found it++; } // first time we get geom_uid, ma_uid pair. Save for later check. -- cgit v1.2.3 From f1eab8e85365a91592bf0f369d173e4b9854619d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 4 Sep 2011 15:53:12 +0000 Subject: Fix #28503: Selecting a Grease Pencil from the Properties panel does not update 3D View Added missing notifiers. --- source/blender/makesrna/intern/rna_nodetree.c | 1 + source/blender/makesrna/intern/rna_object.c | 1 + source/blender/makesrna/intern/rna_scene.c | 1 + source/blender/makesrna/intern/rna_space.c | 1 + 4 files changed, 4 insertions(+) (limited to 'source') diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 56492a52da9..d6e475fdbad 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2736,6 +2736,7 @@ static void rna_def_nodetree(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); + RNA_def_property_update(prop, NC_NODE, NULL); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index ad323b0aba4..4e2be7682f8 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -2297,6 +2297,7 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); /* pose */ prop= RNA_def_property(srna, "pose_library", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index cc1e7d9390b..3c60a3b4cd7 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3517,6 +3517,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); + RNA_def_property_update(prop, NC_SCENE, NULL); /* Transform Orientations */ prop= RNA_def_property(srna, "orientations", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 7a7debe1bf5..35360910015 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1622,6 +1622,7 @@ static void rna_def_space_image(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this space"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); prop= RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DISPGP); -- cgit v1.2.3 From 5c5b9cf4d793e4169147201dae701ab7aef36c86 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 4 Sep 2011 22:14:28 +0000 Subject: Remove NULL-checks, as they might cause infinite loops while reading a DAE containing unsupported data, i.e. geometry. --- source/blender/collada/DocumentImporter.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 3a92c95e7ee..1a91e185bac 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -410,18 +410,15 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren while (geom_done < geom.getCount()) { ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map, material_texture_mapping_map); - if ( ob != NULL ) - ++geom_done; + ++geom_done; } while (camera_done < camera.getCount()) { ob = create_camera_object(camera[camera_done], sce); - if ( ob != NULL ) - ++camera_done; + ++camera_done; } while (lamp_done < lamp.getCount()) { ob = create_lamp_object(lamp[lamp_done], sce); - if ( ob != NULL ) - ++lamp_done; + ++lamp_done; } while (controller_done < controller.getCount()) { COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry*)controller[controller_done]; -- cgit v1.2.3 From 3b09c331faae4406d619bfb1fab28a01c77097b4 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Mon, 5 Sep 2011 05:42:49 +0000 Subject: Adding noise module by default in driver_namespace http://www.pasteall.org/blend/8677 --- source/blender/python/intern/bpy_driver.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source') diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index d68fd9a9111..f3ef55d29c4 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -76,6 +76,13 @@ int bpy_pydriver_create_dict(void) Py_DECREF(mod); } + /* add noise to global namespace */ + mod= PyImport_ImportModuleLevel((char *)"noise", NULL, NULL, NULL, 0); + if (mod) { + PyDict_SetItemString(bpy_pydriver_Dict, "noise", mod); + Py_DECREF(mod); + } + return 0; } -- cgit v1.2.3 From 919bd181b764b0cf76b7e0fee76a07cc8126fc9a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 5 Sep 2011 08:20:11 +0000 Subject: Partial revert commit 39878 "Fix #28280: Insert Hook wrong index" Such load/make edit structures introduced regression into iterators via object's geometry (vertices, edges, control points and so) when adding hooks in the body of this iterator. Fix for wrong index should be non-destructable for geometry. This will fix #28506: Unusual behavior in curves. --- source/blender/editors/object/object_hook.c | 21 ++++---------------- source/blender/editors/object/object_relations.c | 25 ++++-------------------- 2 files changed, 8 insertions(+), 38 deletions(-) (limited to 'source') diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 266556773f0..bb32869469a 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -64,7 +64,6 @@ #include "ED_curve.h" #include "ED_mesh.h" -#include "ED_lattice.h" #include "ED_screen.h" #include "WM_types.h" @@ -293,7 +292,7 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo return totvert; } -static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int **indexar, char *name, float *cent_r) +static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r) { *indexar= NULL; *tot= 0; @@ -303,12 +302,7 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int * case OB_MESH: { Mesh *me= obedit->data; - EditMesh *em; - - load_editMesh(scene, obedit); - make_editMesh(scene, obedit); - - em = BKE_mesh_get_editmesh(me); + EditMesh *em = BKE_mesh_get_editmesh(me); /* check selected vertices first */ if( return_editmesh_indexar(em, tot, indexar, cent_r)) { @@ -322,17 +316,10 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int * } case OB_CURVE: case OB_SURF: - load_editNurb(obedit); - make_editNurb(obedit); - return return_editcurve_indexar(obedit, tot, indexar, cent_r); case OB_LATTICE: { Lattice *lt= obedit->data; - - load_editLatt(obedit); - make_editLatt(obedit); - return return_editlattice_indexar(lt->editlatt->latt, tot, indexar, cent_r); } default: @@ -440,7 +427,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o int tot, ok, *indexar; char name[32]; - ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); + ok = object_hook_index_array(obedit, &tot, &indexar, name, cent); if (!ok) return; // XXX error("Requires selected vertices or active Vertex Group"); @@ -773,7 +760,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) /* assign functionality */ - if(!object_hook_index_array(CTX_data_scene(C), ob, &tot, &indexar, name, cent)) { + if(!object_hook_index_array(ob, &tot, &indexar, name, cent)) { BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index b9208e778c7..e9418ca9f9f 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -91,8 +91,6 @@ #include "ED_armature.h" #include "ED_curve.h" -#include "ED_lattice.h" -#include "ED_mesh.h" #include "ED_keyframing.h" #include "ED_object.h" #include "ED_screen.h" @@ -124,12 +122,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) if(obedit->type==OB_MESH) { Mesh *me= obedit->data; - EditMesh *em; - - load_editMesh(scene, obedit); - make_editMesh(scene, obedit); - - em = BKE_mesh_get_editmesh(me); + EditMesh *em = BKE_mesh_get_editmesh(me); eve= em->verts.first; while(eve) { @@ -147,12 +140,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) BKE_mesh_end_editmesh(me, em); } else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) { - ListBase *editnurb; - - load_editNurb(obedit); - make_editNurb(obedit); - - editnurb= curve_get_editcurve(obedit); + ListBase *editnurb= curve_get_editcurve(obedit); cu= obedit->data; @@ -192,13 +180,8 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } } else if(obedit->type==OB_LATTICE) { - Lattice *lt; - - load_editLatt(obedit); - make_editLatt(obedit); - - lt= obedit->data; - + Lattice *lt= obedit->data; + a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; bp= lt->editlatt->latt->def; while(a--) { -- cgit v1.2.3 From d91587752c1a27e0569dec4ea24a682e7ea51007 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Sep 2011 13:19:19 +0000 Subject: Fix #28504: lib linking errors were not shown when opening a file from the splash screen. --- source/blender/windowmanager/intern/wm_event_system.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 27586525253..5711ec899bf 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -437,9 +437,18 @@ static void wm_operator_print(bContext *C, wmOperator *op) static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int popup) { - if(popup) - if(op->reports->list.first) + if(popup) { + if(op->reports->list.first) { + /* FIXME, temp setting window, see other call to uiPupMenuReports for why */ + wmWindow *win_prev= CTX_wm_window(C); + if(win_prev==NULL) + CTX_wm_window_set(C, CTX_wm_manager(C)->windows.first); + uiPupMenuReports(C, op->reports); + + CTX_wm_window_set(C, win_prev); + } + } if(retval & OPERATOR_FINISHED) { if(G.f & G_DEBUG) -- cgit v1.2.3 From cc1c8268f755adfcf02085251e095b0589548719 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Mon, 5 Sep 2011 15:03:31 +0000 Subject: Left debug print accidently enabled. --- source/blender/collada/MeshImporter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 01eff8069c1..15bd9c48f12 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -220,7 +220,7 @@ void MeshImporter::set_face_uv(MTFace *mtface, UVDataWrapper &uvs, if (quad) uvs.getUV(indices[index + 3], mtface->uv[3]); -#if 1 // #ifdef COLLADA_DEBUG +#ifdef COLLADA_DEBUG if (quad) { fprintf(stderr, "face uv:\n" "((%d, %d, %d, %d))\n" -- cgit v1.2.3 From 59dbd53e72ae25edf247e49ea1e291af277fecc4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 Sep 2011 15:55:53 +0000 Subject: Fix #28389: UILayout.menu function didn't emboss menu button correct in the 3d view tools region. --- source/blender/editors/interface/interface_layout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index ef88bb0bbb6..a2e65f5e4ec 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1404,7 +1404,7 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre if(layout->root->type == UI_LAYOUT_HEADER) uiBlockSetEmboss(block, UI_EMBOSS); - else if(layout->root->type == UI_LAYOUT_PANEL) { + else if(ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR)) { but->type= MENU; but->flag |= UI_TEXT_LEFT; } -- cgit v1.2.3