Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/source/bake_api.c
| Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
| * - ``primitive_id``, ``object_id``, ``uv``, ``du_dx``, ``du_dy``, ``next`` | * - ``primitive_id``, ``object_id``, ``uv``, ``du_dx``, ``du_dy``, ``next`` | ||||
| * - ``next()`` is a function that returns the next #BakePixel in the array. | * - ``next()`` is a function that returns the next #BakePixel in the array. | ||||
| * | * | ||||
| * \note Pixels that should not be baked have ``primitive_id == -1`` | * \note Pixels that should not be baked have ``primitive_id == -1`` | ||||
| * | * | ||||
| * For a complete implementation example look at the Cycles Bake commit. | * For a complete implementation example look at the Cycles Bake commit. | ||||
| */ | */ | ||||
| #include <CLG_log.h> | |||||
| #include <limits.h> | #include <limits.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "DNA_mesh_types.h" | #include "DNA_mesh_types.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| Show All 11 Lines | |||||
| #include "IMB_imbuf_types.h" | #include "IMB_imbuf_types.h" | ||||
| #include "RE_bake.h" | #include "RE_bake.h" | ||||
| /* local include */ | /* local include */ | ||||
| #include "render_types.h" | #include "render_types.h" | ||||
| #include "zbuf.h" | #include "zbuf.h" | ||||
| CLG_LOGREF_DECLARE_GLOBAL(RENDER_LOG_BAKE, "render.bake"); | |||||
| typedef struct BakeDataZSpan { | typedef struct BakeDataZSpan { | ||||
| BakePixel *pixel_array; | BakePixel *pixel_array; | ||||
| int primitive_id; | int primitive_id; | ||||
| BakeImage *bk_image; | BakeImage *bk_image; | ||||
| ZSpan *zspan; | ZSpan *zspan; | ||||
| float du_dx, du_dy; | float du_dx, du_dy; | ||||
| float dv_dx, dv_dy; | float dv_dx, dv_dy; | ||||
| } BakeDataZSpan; | } BakeDataZSpan; | ||||
| ▲ Show 20 Lines • Show All 474 Lines • ▼ Show 20 Lines | for (i = 0; i < tot_highpoly; i++) { | ||||
| me_highpoly[i] = highpoly[i].me; | me_highpoly[i] = highpoly[i].me; | ||||
| BKE_mesh_runtime_looptri_ensure(me_highpoly[i]); | BKE_mesh_runtime_looptri_ensure(me_highpoly[i]); | ||||
| if (me_highpoly[i]->runtime.looptris.len != 0) { | if (me_highpoly[i]->runtime.looptris.len != 0) { | ||||
| /* Create a bvh-tree for each highpoly object */ | /* Create a bvh-tree for each highpoly object */ | ||||
| BKE_bvhtree_from_mesh_get(&treeData[i], me_highpoly[i], BVHTREE_FROM_LOOPTRI, 2); | BKE_bvhtree_from_mesh_get(&treeData[i], me_highpoly[i], BVHTREE_FROM_LOOPTRI, 2); | ||||
| if (treeData[i].tree == NULL) { | if (treeData[i].tree == NULL) { | ||||
| printf("Baking: out of memory while creating BHVTree for object \"%s\"\n", | CLOG_ERROR(RENDER_LOG_BAKE, | ||||
| "Baking: out of memory while creating BHVTree for object \"%s\"", | |||||
| highpoly[i].ob->id.name + 2); | highpoly[i].ob->id.name + 2); | ||||
| result = false; | result = false; | ||||
| goto cleanup; | goto cleanup; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| for (i = 0; i < num_pixels; i++) { | for (i = 0; i < num_pixels; i++) { | ||||
| float co[3]; | float co[3]; | ||||
| ▲ Show 20 Lines • Show All 480 Lines • Show Last 20 Lines | |||||