Changeset View
Changeset View
Standalone View
Standalone View
source/blender/render/intern/source/initrender.c
| Show All 25 Lines | |||||
| #include <math.h> | #include <math.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_ghash.h" | |||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "DNA_camera_types.h" | #include "DNA_camera_types.h" | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| /* this module */ | /* this module */ | ||||
| ▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| BKE_camera_multiview_model_matrix(&re->r, camera, re->viewname, r_mat); | BKE_camera_multiview_model_matrix(&re->r, camera, re->viewname, r_mat); | ||||
| } | } | ||||
| /* ~~~~~~~~~~~~~~~~ part (tile) calculus ~~~~~~~~~~~~~~~~~~~~~~ */ | /* ~~~~~~~~~~~~~~~~ part (tile) calculus ~~~~~~~~~~~~~~~~~~~~~~ */ | ||||
| void RE_parts_free(Render *re) | void RE_parts_free(Render *re) | ||||
| { | { | ||||
| BLI_freelistN(&re->parts); | if (re->parts) { | ||||
| BLI_ghash_free(re->parts, NULL, MEM_freeN); | |||||
| re->parts = NULL; | |||||
| } | |||||
| } | } | ||||
| void RE_parts_clamp(Render *re) | void RE_parts_clamp(Render *re) | ||||
| { | { | ||||
| /* part size */ | /* part size */ | ||||
| re->partx = max_ii(1, min_ii(re->r.tilex, re->rectx)); | re->partx = max_ii(1, min_ii(re->r.tilex, re->rectx)); | ||||
| re->party = max_ii(1, min_ii(re->r.tiley, re->recty)); | re->party = max_ii(1, min_ii(re->r.tiley, re->recty)); | ||||
| } | } | ||||
| void RE_parts_init(Render *re) | void RE_parts_init(Render *re) | ||||
| { | { | ||||
| int nr, xd, yd, partx, party, xparts, yparts; | int nr, xd, yd, partx, party, xparts, yparts; | ||||
| int xminb, xmaxb, yminb, ymaxb; | int xminb, xmaxb, yminb, ymaxb; | ||||
| RE_parts_free(re); | RE_parts_free(re); | ||||
| re->parts = BLI_ghash_new( | |||||
| BLI_ghashutil_inthash_v4_p, BLI_ghashutil_inthash_v4_cmp, "render parts"); | |||||
| /* this is render info for caller, is not reset when parts are freed! */ | /* this is render info for caller, is not reset when parts are freed! */ | ||||
| re->i.totpart = 0; | re->i.totpart = 0; | ||||
| re->i.curpart = 0; | re->i.curpart = 0; | ||||
| re->i.partsdone = 0; | re->i.partsdone = 0; | ||||
| /* just for readable code.. */ | /* just for readable code.. */ | ||||
| xminb = re->disprect.xmin; | xminb = re->disprect.xmin; | ||||
| yminb = re->disprect.ymin; | yminb = re->disprect.ymin; | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | for (nr = 0; nr < xparts * yparts; nr++) { | ||||
| /* so, now can we add this part? */ | /* so, now can we add this part? */ | ||||
| if (rectx > 0 && recty > 0) { | if (rectx > 0 && recty > 0) { | ||||
| RenderPart *pa = MEM_callocN(sizeof(RenderPart), "new part"); | RenderPart *pa = MEM_callocN(sizeof(RenderPart), "new part"); | ||||
| pa->disprect = disprect; | pa->disprect = disprect; | ||||
| pa->rectx = rectx; | pa->rectx = rectx; | ||||
| pa->recty = recty; | pa->recty = recty; | ||||
| BLI_addtail(&re->parts, pa); | BLI_ghash_insert(re->parts, &pa->disprect, pa); | ||||
| re->i.totpart++; | re->i.totpart++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||