Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * $Id$ | 2 * $Id$ |
3 * | 3 * |
4 * ***** BEGIN GPL LICENSE BLOCK ***** | 4 * ***** BEGIN GPL LICENSE BLOCK ***** |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or | 6 * This program is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU General Public License | 7 * modify it under the terms of the GNU General Public License |
8 * as published by the Free Software Foundation; either version 2 | 8 * as published by the Free Software Foundation; either version 2 |
9 * of the License, or (at your option) any later version. | 9 * of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 22 matching lines...) Expand all Loading... | |
33 /** \file blender/modifiers/intern/MOD_uvproject.c | 33 /** \file blender/modifiers/intern/MOD_uvproject.c |
34 * \ingroup modifiers | 34 * \ingroup modifiers |
35 */ | 35 */ |
36 | 36 |
37 | 37 |
38 /* UV Project modifier: Generates UVs projected from an object */ | 38 /* UV Project modifier: Generates UVs projected from an object */ |
39 | 39 |
40 #include "DNA_meshdata_types.h" | 40 #include "DNA_meshdata_types.h" |
41 #include "DNA_camera_types.h" | 41 #include "DNA_camera_types.h" |
42 #include "DNA_object_types.h" | 42 #include "DNA_object_types.h" |
43 #include "DNA_scene_types.h" | |
43 | 44 |
44 #include "BLI_math.h" | 45 #include "BLI_math.h" |
45 #include "BLI_string.h" | 46 #include "BLI_string.h" |
46 #include "BLI_uvproject.h" | 47 #include "BLI_uvproject.h" |
47 #include "BLI_utildefines.h" | 48 #include "BLI_utildefines.h" |
48 | 49 |
49 | 50 |
50 #include "BKE_DerivedMesh.h" | 51 #include "BKE_DerivedMesh.h" |
51 | 52 |
52 #include "MOD_modifiertypes.h" | 53 #include "MOD_modifiertypes.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 int override_image = ((umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0); | 155 int override_image = ((umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0); |
155 Projector projectors[MOD_UVPROJECT_MAXPROJECTORS]; | 156 Projector projectors[MOD_UVPROJECT_MAXPROJECTORS]; |
156 int num_projectors = 0; | 157 int num_projectors = 0; |
157 float aspect; | 158 float aspect; |
158 char uvname[32]; | 159 char uvname[32]; |
159 float aspx= umd->aspectx ? umd->aspectx : 1.0f; | 160 float aspx= umd->aspectx ? umd->aspectx : 1.0f; |
160 float aspy= umd->aspecty ? umd->aspecty : 1.0f; | 161 float aspy= umd->aspecty ? umd->aspecty : 1.0f; |
161 float scax= umd->scalex ? umd->scalex : 1.0f; | 162 float scax= umd->scalex ? umd->scalex : 1.0f; |
162 float scay= umd->scaley ? umd->scaley : 1.0f; | 163 float scay= umd->scaley ? umd->scaley : 1.0f; |
163 int free_uci= 0; | 164 int free_uci= 0; |
165 float sensor_x= 32.0f; | |
166 Scene *scene= umd->modifier.scene; | |
167 ········ | |
168 if(scene && scene->camera && scene->camera->type == OB_CAMERA) { | |
169 Camera *camera= (Camera*)scene->camera->data; | |
170 | |
171 sensor_x= camera->sensor_x; | |
ideasman42
2011/10/20 12:43:41
Dont think its correct to use the scene camera her
nazgul
2011/10/20 16:04:50
I'm not sure what "referenced from the object" mea
ideasman42
2011/10/20 21:45:13
Each projector checks if its a camera type, when i
| |
172 } | |
164 ········ | 173 ········ |
165 aspect = aspx / aspy; | 174 aspect = aspx / aspy; |
166 | 175 |
167 for(i = 0; i < umd->num_projectors; ++i) | 176 for(i = 0; i < umd->num_projectors; ++i) |
168 if(umd->projectors[i]) | 177 if(umd->projectors[i]) |
169 projectors[num_projectors++].ob = umd->projectors[i]; | 178 projectors[num_projectors++].ob = umd->projectors[i]; |
170 | 179 |
171 if(num_projectors == 0) return dm; | 180 if(num_projectors == 0) return dm; |
172 | 181 |
173 /* make sure there are UV layers available */ | 182 /* make sure there are UV layers available */ |
(...skipping 15 matching lines...) Expand all Loading... | |
189 | 198 |
190 if(projectors[i].ob->type == OB_CAMERA) { | 199 if(projectors[i].ob->type == OB_CAMERA) { |
191 ························ | 200 ························ |
192 cam = (Camera *)projectors[i].ob->data; | 201 cam = (Camera *)projectors[i].ob->data; |
193 if(cam->flag & CAM_PANORAMA) { | 202 if(cam->flag & CAM_PANORAMA) { |
194 projectors[i].uci= project_camera_info(projector s[i].ob, NULL, aspx, aspy); | 203 projectors[i].uci= project_camera_info(projector s[i].ob, NULL, aspx, aspy); |
195 project_camera_info_scale(projectors[i].uci, sca x, scay); | 204 project_camera_info_scale(projectors[i].uci, sca x, scay); |
196 free_uci= 1; | 205 free_uci= 1; |
197 } | 206 } |
198 else { | 207 else { |
199 » » » » float scale= (cam->type == CAM_PERSP) ? cam->cli psta * 32.0f / cam->lens : cam->ortho_scale; | 208 » » » » float scale= (cam->type == CAM_PERSP) ? cam->cli psta * sensor_x / cam->lens : cam->ortho_scale; |
200 float xmax, xmin, ymax, ymin; | 209 float xmax, xmin, ymax, ymin; |
201 | 210 |
202 if(aspect > 1.0f) { | 211 if(aspect > 1.0f) { |
203 xmax = 0.5f * scale; | 212 xmax = 0.5f * scale; |
204 ymax = xmax / aspect; | 213 ymax = xmax / aspect; |
205 } else { | 214 } else { |
206 ymax = 0.5f * scale; | 215 ymax = 0.5f * scale; |
207 xmax = ymax * aspect; | 216 xmax = ymax * aspect; |
208 } | 217 } |
209 xmin = -xmax; | 218 xmin = -xmax; |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 /* requiredDataMask */ requiredDataMask, | 437 /* requiredDataMask */ requiredDataMask, |
429 /* freeData */ NULL, | 438 /* freeData */ NULL, |
430 /* isDisabled */ NULL, | 439 /* isDisabled */ NULL, |
431 /* updateDepgraph */ updateDepgraph, | 440 /* updateDepgraph */ updateDepgraph, |
432 /* dependsOnTime */ NULL, | 441 /* dependsOnTime */ NULL, |
433 /* dependsOnNormals */ NULL, | 442 /* dependsOnNormals */ NULL, |
434 /* foreachObjectLink */ foreachObjectLink, | 443 /* foreachObjectLink */ foreachObjectLink, |
435 /* foreachIDLink */ foreachIDLink, | 444 /* foreachIDLink */ foreachIDLink, |
436 /* foreachTexLink */ NULL, | 445 /* foreachTexLink */ NULL, |
437 }; | 446 }; |
OLD | NEW |