Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/BKE_lamp.h51
-rw-r--r--source/blender/blenkernel/BKE_object.h6
-rw-r--r--source/blender/blenkernel/CMakeLists.txt2
-rw-r--r--source/blender/blenkernel/intern/camera.c2
-rw-r--r--source/blender/blenkernel/intern/lamp.c233
-rw-r--r--source/blender/blenkernel/intern/library.c1
-rw-r--r--source/blender/blenkernel/intern/object.c182
-rw-r--r--source/blender/collada/DocumentImporter.cpp1
-rw-r--r--source/blender/editors/object/object_add.c1
-rw-r--r--source/blender/editors/object/object_relations.c1
-rw-r--r--source/blender/editors/render/render_preview.c1
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c1
12 files changed, 295 insertions, 187 deletions
diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h
new file mode 100644
index 00000000000..cc9452ae155
--- /dev/null
+++ b/source/blender/blenkernel/BKE_lamp.h
@@ -0,0 +1,51 @@
+/*
+ * ***** 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): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BKE_LAMP_H
+#define BKE_LAMP_H
+
+/** \file BKE_lamp.h
+ * \ingroup bke
+ * \brief General operations, lookup, etc. for blender lamps.
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct Lamp;
+
+void *add_lamp(const char *name);
+struct Lamp *copy_lamp(struct Lamp *la);
+struct Lamp *localize_lamp(struct Lamp *la);
+void make_local_lamp(struct Lamp *la);
+void free_lamp(struct Lamp *la);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index f9cd7045e13..d6139a680ec 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -75,12 +75,6 @@ void object_copy_proxy_drivers(struct Object *ob, struct Object *target);
void unlink_object(struct Object *ob);
int exist_object(struct Object *obtest);
-void *add_lamp(const char *name);
-struct Lamp *copy_lamp(struct Lamp *la);
-struct Lamp *localize_lamp(struct Lamp *la);
-void make_local_lamp(struct Lamp *la);
-void free_lamp(struct Lamp *la);
-
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/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index ba6776e1864..78b1b52e52c 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -104,6 +104,7 @@ set(SRC
intern/implicit.c
intern/ipo.c
intern/key.c
+ intern/lamp.c
intern/lattice.c
intern/library.c
intern/material.c
@@ -187,6 +188,7 @@ set(SRC
BKE_image.h
BKE_ipo.h
BKE_key.h
+ BKE_lamp.h
BKE_lattice.h
BKE_library.h
BKE_main.h
diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c
index 74cc5a76a75..eeec82c3beb 100644
--- a/source/blender/blenkernel/intern/camera.c
+++ b/source/blender/blenkernel/intern/camera.c
@@ -29,6 +29,8 @@
* \ingroup bke
*/
+#include <stdlib.h>
+
#include "DNA_camera_types.h"
#include "DNA_lamp_types.h"
#include "DNA_object_types.h"
diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c
new file mode 100644
index 00000000000..974aa660e9f
--- /dev/null
+++ b/source/blender/blenkernel/intern/lamp.c
@@ -0,0 +1,233 @@
+/*
+ * ***** 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): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenkernel/intern/lamp.c
+ * \ingroup bke
+ */
+
+#include <stdlib.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_lamp_types.h"
+#include "DNA_material_types.h"
+#include "DNA_object_types.h"
+#include "DNA_texture_types.h"
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_animsys.h"
+#include "BKE_colortools.h"
+#include "BKE_icons.h"
+#include "BKE_global.h"
+#include "BKE_lamp.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_node.h"
+
+void *add_lamp(const char *name)
+{
+ Lamp *la;
+
+ la= alloc_libblock(&G.main->lamp, ID_LA, name);
+
+ la->r= la->g= la->b= la->k= 1.0f;
+ la->haint= la->energy= 1.0f;
+ la->dist= 25.0f;
+ la->spotsize= 45.0f;
+ la->spotblend= 0.15f;
+ la->att2= 1.0f;
+ la->mode= LA_SHAD_BUF;
+ la->bufsize= 512;
+ la->clipsta= 0.5f;
+ la->clipend= 40.0f;
+ la->shadspotsize= 45.0f;
+ la->samp= 3;
+ la->bias= 1.0f;
+ la->soft= 3.0f;
+ la->compressthresh= 0.05f;
+ la->ray_samp= la->ray_sampy= la->ray_sampz= 1;
+ la->area_size=la->area_sizey=la->area_sizez= 1.0f;
+ la->buffers= 1;
+ la->buftype= LA_SHADBUF_HALFWAY;
+ la->ray_samp_method = LA_SAMP_HALTON;
+ la->adapt_thresh = 0.001f;
+ la->preview=NULL;
+ la->falloff_type = LA_FALLOFF_INVSQUARE;
+ la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
+ la->sun_effect_type = 0;
+ la->horizon_brightness = 1.0;
+ la->spread = 1.0;
+ la->sun_brightness = 1.0;
+ la->sun_size = 1.0;
+ la->backscattered_light = 1.0f;
+ la->atm_turbidity = 2.0f;
+ la->atm_inscattering_factor = 1.0f;
+ la->atm_extinction_factor = 1.0f;
+ la->atm_distance_factor = 1.0f;
+ la->sun_intensity = 1.0f;
+ la->skyblendtype= MA_RAMP_ADD;
+ la->skyblendfac= 1.0f;
+ la->sky_colorspace= BLI_XYZ_CIE;
+ la->sky_exposure= 1.0f;
+
+ curvemapping_initialize(la->curfalloff);
+ return la;
+}
+
+Lamp *copy_lamp(Lamp *la)
+{
+ Lamp *lan;
+ int a;
+
+ lan= copy_libblock(la);
+
+ for(a=0; a<MAX_MTEX; a++) {
+ if(lan->mtex[a]) {
+ lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex");
+ memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
+ id_us_plus((ID *)lan->mtex[a]->tex);
+ }
+ }
+
+ lan->curfalloff = curvemapping_copy(la->curfalloff);
+
+ if(la->nodetree)
+ lan->nodetree= ntreeCopyTree(la->nodetree);
+
+ if(la->preview)
+ lan->preview = BKE_previewimg_copy(la->preview);
+
+ return lan;
+}
+
+Lamp *localize_lamp(Lamp *la)
+{
+ Lamp *lan;
+ int a;
+
+ lan= copy_libblock(la);
+ BLI_remlink(&G.main->lamp, lan);
+
+ for(a=0; a<MAX_MTEX; a++) {
+ if(lan->mtex[a]) {
+ lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
+ memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
+ /* free lamp decrements */
+ id_us_plus((ID *)lan->mtex[a]->tex);
+ }
+ }
+
+ lan->curfalloff = curvemapping_copy(la->curfalloff);
+
+ if(la->nodetree)
+ lan->nodetree= ntreeLocalize(la->nodetree);
+
+ lan->preview= NULL;
+
+ return lan;
+}
+
+void make_local_lamp(Lamp *la)
+{
+ Main *bmain= G.main;
+ Object *ob;
+ int is_local= FALSE, is_lib= FALSE;
+
+ /* - only lib users: do nothing
+ * - only local users: set flag
+ * - mixed: make copy
+ */
+
+ if(la->id.lib==NULL) return;
+ if(la->id.us==1) {
+ id_clear_lib_data(bmain, &la->id);
+ return;
+ }
+
+ ob= bmain->object.first;
+ while(ob) {
+ if(ob->data==la) {
+ if(ob->id.lib) is_lib= TRUE;
+ else is_local= TRUE;
+ }
+ ob= ob->id.next;
+ }
+
+ if(is_local && is_lib == FALSE) {
+ id_clear_lib_data(bmain, &la->id);
+ }
+ else if(is_local && is_lib) {
+ Lamp *lan= copy_lamp(la);
+ lan->id.us= 0;
+
+ /* Remap paths of new ID using old library as base. */
+ BKE_id_lib_local_paths(bmain, &lan->id);
+
+ ob= bmain->object.first;
+ while(ob) {
+ if(ob->data==la) {
+
+ if(ob->id.lib==NULL) {
+ ob->data= lan;
+ lan->id.us++;
+ la->id.us--;
+ }
+ }
+ ob= ob->id.next;
+ }
+ }
+}
+
+void free_lamp(Lamp *la)
+{
+ MTex *mtex;
+ int a;
+
+ for(a=0; a<MAX_MTEX; a++) {
+ mtex= la->mtex[a];
+ if(mtex && mtex->tex) mtex->tex->id.us--;
+ if(mtex) MEM_freeN(mtex);
+ }
+
+ BKE_free_animdata((ID *)la);
+
+ curvemapping_free(la->curfalloff);
+
+ /* is no lib link block, but lamp extension */
+ if(la->nodetree) {
+ ntreeFreeTree(la->nodetree);
+ MEM_freeN(la->nodetree);
+ }
+
+ BKE_previewimg_free(&la->preview);
+ BKE_icon_delete(&la->id);
+ la->id.icon_id = 0;
+}
+
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 36e2428ce24..0b01c3d6dd1 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -79,6 +79,7 @@
#include "BKE_animsys.h"
#include "BKE_camera.h"
#include "BKE_context.h"
+#include "BKE_lamp.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_global.h"
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 1ba06c02976..a78b010392e 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -42,7 +42,6 @@
#include "DNA_constraint_types.h"
#include "DNA_group_types.h"
#include "DNA_key_types.h"
-#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
@@ -81,6 +80,7 @@
#include "BKE_group.h"
#include "BKE_icons.h"
#include "BKE_key.h"
+#include "BKE_lamp.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_mesh.h"
@@ -716,186 +716,6 @@ int exist_object(Object *obtest)
return 0;
}
-void *add_lamp(const char *name)
-{
- Lamp *la;
-
- la= alloc_libblock(&G.main->lamp, ID_LA, name);
-
- la->r= la->g= la->b= la->k= 1.0f;
- la->haint= la->energy= 1.0f;
- la->dist= 25.0f;
- la->spotsize= 45.0f;
- la->spotblend= 0.15f;
- la->att2= 1.0f;
- la->mode= LA_SHAD_BUF;
- la->bufsize= 512;
- la->clipsta= 0.5f;
- la->clipend= 40.0f;
- la->shadspotsize= 45.0f;
- la->samp= 3;
- la->bias= 1.0f;
- la->soft= 3.0f;
- la->compressthresh= 0.05f;
- la->ray_samp= la->ray_sampy= la->ray_sampz= 1;
- la->area_size=la->area_sizey=la->area_sizez= 1.0f;
- la->buffers= 1;
- la->buftype= LA_SHADBUF_HALFWAY;
- la->ray_samp_method = LA_SAMP_HALTON;
- la->adapt_thresh = 0.001f;
- la->preview=NULL;
- la->falloff_type = LA_FALLOFF_INVSQUARE;
- la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f);
- la->sun_effect_type = 0;
- la->horizon_brightness = 1.0;
- la->spread = 1.0;
- la->sun_brightness = 1.0;
- la->sun_size = 1.0;
- la->backscattered_light = 1.0f;
- la->atm_turbidity = 2.0f;
- la->atm_inscattering_factor = 1.0f;
- la->atm_extinction_factor = 1.0f;
- la->atm_distance_factor = 1.0f;
- la->sun_intensity = 1.0f;
- la->skyblendtype= MA_RAMP_ADD;
- la->skyblendfac= 1.0f;
- la->sky_colorspace= BLI_XYZ_CIE;
- la->sky_exposure= 1.0f;
-
- curvemapping_initialize(la->curfalloff);
- return la;
-}
-
-Lamp *copy_lamp(Lamp *la)
-{
- Lamp *lan;
- int a;
-
- lan= copy_libblock(la);
-
- for(a=0; a<MAX_MTEX; a++) {
- if(lan->mtex[a]) {
- lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex");
- memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
- id_us_plus((ID *)lan->mtex[a]->tex);
- }
- }
-
- lan->curfalloff = curvemapping_copy(la->curfalloff);
-
- if(la->nodetree)
- lan->nodetree= ntreeCopyTree(la->nodetree);
-
- if(la->preview)
- lan->preview = BKE_previewimg_copy(la->preview);
-
- return lan;
-}
-
-Lamp *localize_lamp(Lamp *la)
-{
- Lamp *lan;
- int a;
-
- lan= copy_libblock(la);
- BLI_remlink(&G.main->lamp, lan);
-
- for(a=0; a<MAX_MTEX; a++) {
- if(lan->mtex[a]) {
- lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp");
- memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex));
- /* free lamp decrements */
- id_us_plus((ID *)lan->mtex[a]->tex);
- }
- }
-
- lan->curfalloff = curvemapping_copy(la->curfalloff);
-
- if(la->nodetree)
- lan->nodetree= ntreeLocalize(la->nodetree);
-
- lan->preview= NULL;
-
- return lan;
-}
-
-void make_local_lamp(Lamp *la)
-{
- Main *bmain= G.main;
- Object *ob;
- int is_local= FALSE, is_lib= FALSE;
-
- /* - only lib users: do nothing
- * - only local users: set flag
- * - mixed: make copy
- */
-
- if(la->id.lib==NULL) return;
- if(la->id.us==1) {
- id_clear_lib_data(bmain, &la->id);
- return;
- }
-
- ob= bmain->object.first;
- while(ob) {
- if(ob->data==la) {
- if(ob->id.lib) is_lib= TRUE;
- else is_local= TRUE;
- }
- ob= ob->id.next;
- }
-
- if(is_local && is_lib == FALSE) {
- id_clear_lib_data(bmain, &la->id);
- }
- else if(is_local && is_lib) {
- Lamp *lan= copy_lamp(la);
- lan->id.us= 0;
-
- /* Remap paths of new ID using old library as base. */
- BKE_id_lib_local_paths(bmain, &lan->id);
-
- ob= bmain->object.first;
- while(ob) {
- if(ob->data==la) {
-
- if(ob->id.lib==NULL) {
- ob->data= lan;
- lan->id.us++;
- la->id.us--;
- }
- }
- ob= ob->id.next;
- }
- }
-}
-
-void free_lamp(Lamp *la)
-{
- MTex *mtex;
- int a;
-
- for(a=0; a<MAX_MTEX; a++) {
- mtex= la->mtex[a];
- if(mtex && mtex->tex) mtex->tex->id.us--;
- if(mtex) MEM_freeN(mtex);
- }
-
- BKE_free_animdata((ID *)la);
-
- curvemapping_free(la->curfalloff);
-
- /* is no lib link block, but lamp extension */
- if(la->nodetree) {
- ntreeFreeTree(la->nodetree);
- MEM_freeN(la->nodetree);
- }
-
- BKE_previewimg_free(&la->preview);
- BKE_icon_delete(&la->id);
- la->id.icon_id = 0;
-}
-
/* *************************************************** */
static void *add_obdata_from_type(int type)
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index ec22dfae7ba..267aa925c74 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -56,6 +56,7 @@
#include "BKE_camera.h"
#include "BKE_main.h"
+#include "BKE_lamp.h"
#include "BKE_library.h"
#include "BKE_texture.h"
#include "BKE_fcurve.h"
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 1cafa9c0693..a929144ed2e 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -63,6 +63,7 @@
#include "BKE_displist.h"
#include "BKE_effect.h"
#include "BKE_group.h"
+#include "BKE_lamp.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_key.h"
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 0a0eadd58d3..e9575c85c5f 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -64,6 +64,7 @@
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_fcurve.h"
+#include "BKE_lamp.h"
#include "BKE_lattice.h"
#include "BKE_library.h"
#include "BKE_main.h"
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 9da160948cc..feff1e05d60 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -70,6 +70,7 @@
#include "BKE_idprop.h"
#include "BKE_image.h"
#include "BKE_icons.h"
+#include "BKE_lamp.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_material.h"
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index 83ce4d2da06..dfa368d6b94 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -47,6 +47,7 @@
#include "BKE_curve.h"
#include "BKE_mesh.h"
#include "BKE_armature.h"
+#include "BKE_lamp.h"
#include "BKE_library.h"
#include "BKE_object.h"
#include "BKE_material.h"