Remove game properties in image editor
The following properties were used by the Blender Game Engine and no longer need to be around: * Animated * Tiles * Clamp * Mapping
This commit is contained in:
parent
159806140f
commit
fb24813d64
@ -614,50 +614,6 @@ class IMAGE_PT_image_properties(Panel):
|
||||
layout.template_image(sima, "image", iuser, multiview=True)
|
||||
|
||||
|
||||
class IMAGE_PT_game_properties(Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
bl_label = "Game Properties"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
sima = context.space_data
|
||||
# display even when not in game mode because these settings effect the 3d view
|
||||
return (sima and sima.image and not sima.show_maskedit) # and (view_render.engine == 'BLENDER_GAME')
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
sima = context.space_data
|
||||
ima = sima.image
|
||||
|
||||
split = layout.split()
|
||||
col = split.column()
|
||||
col.prop(ima, "use_animation")
|
||||
sub = col.column(align=True)
|
||||
sub.active = ima.use_animation
|
||||
sub.prop(ima, "frame_start", text="Start")
|
||||
sub.prop(ima, "frame_end", text="End")
|
||||
sub.prop(ima, "fps", text="Speed")
|
||||
|
||||
col = split.column()
|
||||
col.prop(ima, "use_tiles")
|
||||
sub = col.column(align=True)
|
||||
sub.active = ima.use_tiles or ima.use_animation
|
||||
sub.prop(ima, "tiles_x", text="X")
|
||||
sub.prop(ima, "tiles_y", text="Y")
|
||||
|
||||
split = layout.split()
|
||||
col = split.column()
|
||||
col.label(text="Clamp:")
|
||||
col.prop(ima, "use_clamp_x", text="X")
|
||||
col.prop(ima, "use_clamp_y", text="Y")
|
||||
|
||||
col = split.column()
|
||||
col.label(text="Mapping:")
|
||||
col.prop(ima, "mapping", expand=True)
|
||||
|
||||
|
||||
class IMAGE_PT_view_properties(Panel):
|
||||
bl_space_type = 'IMAGE_EDITOR'
|
||||
bl_region_type = 'UI'
|
||||
@ -1363,7 +1319,6 @@ classes = (
|
||||
IMAGE_PT_active_mask_spline,
|
||||
IMAGE_PT_active_mask_point,
|
||||
IMAGE_PT_image_properties,
|
||||
IMAGE_PT_game_properties,
|
||||
IMAGE_PT_view_properties,
|
||||
IMAGE_PT_tools_transform_uvs,
|
||||
IMAGE_PT_tools_align_uvs,
|
||||
|
@ -370,7 +370,6 @@ static void image_init(Image *ima, short source, short type)
|
||||
|
||||
ima->ok = IMA_OK;
|
||||
|
||||
ima->xrep = ima->yrep = 1;
|
||||
ima->aspx = ima->aspy = 1.0;
|
||||
ima->gen_x = 1024; ima->gen_y = 1024;
|
||||
ima->gen_type = IMA_GENTYPE_GRID;
|
||||
@ -473,12 +472,10 @@ void BKE_image_copy_data(Main *UNUSED(bmain), Image *ima_dst, const Image *ima_s
|
||||
|
||||
BLI_listbase_clear(&ima_dst->anims);
|
||||
|
||||
ima_dst->totbind = 0;
|
||||
for (int i = 0; i < TEXTARGET_COUNT; i++) {
|
||||
ima_dst->bindcode[i] = 0;
|
||||
ima_dst->gputexture[i] = NULL;
|
||||
}
|
||||
ima_dst->repbind = NULL;
|
||||
|
||||
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) {
|
||||
BKE_previewimg_id_copy(&ima_dst->id, &ima_src->id);
|
||||
|
@ -3924,8 +3924,6 @@ static void direct_link_image(FileData *fd, Image *ima)
|
||||
}
|
||||
ima->rr = NULL;
|
||||
}
|
||||
|
||||
ima->repbind = NULL;
|
||||
|
||||
/* undo system, try to restore render buffers */
|
||||
if (fd->imamap) {
|
||||
|
@ -917,18 +917,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
|
||||
|
||||
if (main->versionfile <= 223) {
|
||||
VFont *vf;
|
||||
Image *ima;
|
||||
|
||||
for (vf = main->vfont.first; vf; vf = vf->id.next) {
|
||||
if (STREQ(vf->name + strlen(vf->name) - 6, ".Bfont")) {
|
||||
strcpy(vf->name, FO_BUILTIN_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
/* Old textures animate at 25 FPS */
|
||||
for (ima = main->image.first; ima; ima = ima->id.next) {
|
||||
ima->animspeed = 25;
|
||||
}
|
||||
}
|
||||
|
||||
if (main->versionfile <= 224) {
|
||||
|
@ -2492,8 +2492,7 @@ static bool IsectPoly2Df_twoside(const float pt[2], float uv[][2], const int tot
|
||||
static void project_paint_face_init(
|
||||
const ProjPaintState *ps,
|
||||
const int thread_index, const int bucket_index, const int tri_index, const int image_index,
|
||||
const rctf *clip_rect, const rctf *bucket_bounds, ImBuf *ibuf, ImBuf **tmpibuf,
|
||||
const bool clamp_u, const bool clamp_v)
|
||||
const rctf *clip_rect, const rctf *bucket_bounds, ImBuf *ibuf, ImBuf **tmpibuf)
|
||||
{
|
||||
/* Projection vars, to get the 3D locations into screen space */
|
||||
MemArena *arena = ps->arena_mt[thread_index];
|
||||
@ -2600,17 +2599,6 @@ static void project_paint_face_init(
|
||||
#endif
|
||||
|
||||
if (pixel_bounds_array(uv_clip, &bounds_px, ibuf->x, ibuf->y, uv_clip_tot)) {
|
||||
|
||||
if (clamp_u) {
|
||||
CLAMP(bounds_px.xmin, 0, ibuf->x);
|
||||
CLAMP(bounds_px.xmax, 0, ibuf->x);
|
||||
}
|
||||
|
||||
if (clamp_v) {
|
||||
CLAMP(bounds_px.ymin, 0, ibuf->y);
|
||||
CLAMP(bounds_px.ymax, 0, ibuf->y);
|
||||
}
|
||||
|
||||
#if 0
|
||||
project_paint_undo_tiles_init(&bounds_px, ps->projImages + image_index, tmpibuf,
|
||||
tile_width, threaded, ps->do_masking);
|
||||
@ -2927,19 +2915,16 @@ static void project_bucket_init(
|
||||
int tri_index, image_index = 0;
|
||||
ImBuf *ibuf = NULL;
|
||||
Image *tpage_last = NULL, *tpage;
|
||||
Image *ima = NULL;
|
||||
ImBuf *tmpibuf = NULL;
|
||||
|
||||
if (ps->image_tot == 1) {
|
||||
/* Simple loop, no context switching */
|
||||
ibuf = ps->projImages[0].ibuf;
|
||||
ima = ps->projImages[0].ima;
|
||||
|
||||
for (node = ps->bucketFaces[bucket_index]; node; node = node->next) {
|
||||
project_paint_face_init(
|
||||
ps, thread_index, bucket_index, GET_INT_FROM_POINTER(node->link), 0,
|
||||
clip_rect, bucket_bounds, ibuf, &tmpibuf,
|
||||
(ima->tpageflag & IMA_CLAMP_U) != 0, (ima->tpageflag & IMA_CLAMP_V) != 0);
|
||||
clip_rect, bucket_bounds, ibuf, &tmpibuf);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -2956,7 +2941,6 @@ static void project_bucket_init(
|
||||
for (image_index = 0; image_index < ps->image_tot; image_index++) {
|
||||
if (ps->projImages[image_index].ima == tpage_last) {
|
||||
ibuf = ps->projImages[image_index].ibuf;
|
||||
ima = ps->projImages[image_index].ima;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2965,8 +2949,7 @@ static void project_bucket_init(
|
||||
|
||||
project_paint_face_init(
|
||||
ps, thread_index, bucket_index, tri_index, image_index,
|
||||
clip_rect, bucket_bounds, ibuf, &tmpibuf,
|
||||
(ima->tpageflag & IMA_CLAMP_U) != 0, (ima->tpageflag & IMA_CLAMP_V) != 0);
|
||||
clip_rect, bucket_bounds, ibuf, &tmpibuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,118 +548,6 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar,
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, short startx, short starty, short endx, short endy)
|
||||
{
|
||||
unsigned int *rt, *rp, *rectmain;
|
||||
short y, heigth, len;
|
||||
|
||||
/* the right offset in rectot */
|
||||
|
||||
rt = buffer + (starty * width + startx);
|
||||
|
||||
len = (endx - startx);
|
||||
heigth = (endy - starty);
|
||||
|
||||
rp = rectmain = MEM_mallocN(heigth * len * sizeof(int), "rect");
|
||||
|
||||
for (y = 0; y < heigth; y++) {
|
||||
memcpy(rp, rt, len * 4);
|
||||
rt += width;
|
||||
rp += len;
|
||||
}
|
||||
return rectmain;
|
||||
}
|
||||
|
||||
static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float fx, float fy, float zoomx, float zoomy)
|
||||
{
|
||||
unsigned char *display_buffer;
|
||||
unsigned int *rect;
|
||||
int dx, dy, sx, sy, x, y;
|
||||
void *cache_handle;
|
||||
float shuffle[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
/* verify valid values, just leave this a while */
|
||||
if (ima->xrep < 1) return;
|
||||
if (ima->yrep < 1) return;
|
||||
|
||||
if (ima->flag & IMA_VIEW_AS_RENDER)
|
||||
display_buffer = IMB_display_buffer_acquire(ibuf, &scene->view_settings, &scene->display_settings, &cache_handle);
|
||||
else
|
||||
display_buffer = IMB_display_buffer_acquire(ibuf, NULL, &scene->display_settings, &cache_handle);
|
||||
|
||||
if (!display_buffer)
|
||||
return;
|
||||
|
||||
if (sima->curtile >= ima->xrep * ima->yrep)
|
||||
sima->curtile = ima->xrep * ima->yrep - 1;
|
||||
|
||||
/* retrieve part of image buffer */
|
||||
dx = max_ii(ibuf->x / ima->xrep, 1);
|
||||
dy = max_ii(ibuf->y / ima->yrep, 1);
|
||||
sx = (sima->curtile % ima->xrep) * dx;
|
||||
sy = (sima->curtile / ima->xrep) * dy;
|
||||
rect = get_part_from_buffer((unsigned int *)display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy);
|
||||
|
||||
/* draw repeated */
|
||||
if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B | SI_SHOW_ALPHA)) != 0) {
|
||||
if (sima->flag & SI_SHOW_R)
|
||||
shuffle[0] = 1.0f;
|
||||
else if (sima->flag & SI_SHOW_G)
|
||||
shuffle[1] = 1.0f;
|
||||
else if (sima->flag & SI_SHOW_B)
|
||||
shuffle[2] = 1.0f;
|
||||
else if (sima->flag & SI_SHOW_ALPHA)
|
||||
shuffle[3] = 1.0f;
|
||||
}
|
||||
|
||||
for (sy = 0; sy + dy <= ibuf->y; sy += dy) {
|
||||
for (sx = 0; sx + dx <= ibuf->x; sx += dx) {
|
||||
UI_view2d_view_to_region(&ar->v2d, fx + (float)sx / (float)ibuf->x, fy + (float)sy / (float)ibuf->y, &x, &y);
|
||||
|
||||
if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B | SI_SHOW_ALPHA)) == 0) {
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
|
||||
immDrawPixelsTex(&state, x, y, dx, dy, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, zoomx, zoomy, NULL);
|
||||
}
|
||||
else {
|
||||
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
|
||||
GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle);
|
||||
|
||||
immDrawPixelsTex(&state, x, y, dx, dy, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, rect, zoomx, zoomy, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IMB_display_buffer_release(cache_handle);
|
||||
|
||||
MEM_freeN(rect);
|
||||
}
|
||||
|
||||
static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, ARegion *ar, Scene *scene, Image *ima, ImBuf *ibuf, float zoomx, float zoomy)
|
||||
{
|
||||
const double time_current = PIL_check_seconds_timer();
|
||||
|
||||
const int xmax = ceil(ar->v2d.cur.xmax);
|
||||
const int ymax = ceil(ar->v2d.cur.ymax);
|
||||
const int xmin = floor(ar->v2d.cur.xmin);
|
||||
const int ymin = floor(ar->v2d.cur.ymin);
|
||||
|
||||
int x;
|
||||
|
||||
for (x = xmin; x < xmax; x++) {
|
||||
int y;
|
||||
for (y = ymin; y < ymax; y++) {
|
||||
if (ima && (ima->tpageflag & IMA_TILES))
|
||||
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy);
|
||||
else
|
||||
draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy);
|
||||
|
||||
/* only draw until running out of time */
|
||||
if ((PIL_check_seconds_timer() - time_current) > 0.25)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* draw uv edit */
|
||||
|
||||
/* draw grease pencil */
|
||||
@ -810,14 +698,8 @@ void draw_image_main(const bContext *C, ARegion *ar)
|
||||
ED_region_grid_draw(ar, zoomx, zoomy);
|
||||
}
|
||||
else {
|
||||
draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
|
||||
|
||||
if (sima->flag & SI_DRAW_TILE)
|
||||
draw_image_buffer_repeated(C, sima, ar, scene, ima, ibuf, zoomx, zoomy);
|
||||
else if (ima && (ima->tpageflag & IMA_TILES))
|
||||
draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy);
|
||||
else
|
||||
draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy);
|
||||
|
||||
if (sima->flag & SI_DRAW_METADATA) {
|
||||
int x, y;
|
||||
rctf frame;
|
||||
|
@ -671,7 +671,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char
|
||||
}
|
||||
|
||||
if (ob_alpha > 0.0f) {
|
||||
bindcode = GPU_verify_image(ima, &iuser, GL_TEXTURE_2D, 0, false, false, false);
|
||||
bindcode = GPU_verify_image(ima, &iuser, GL_TEXTURE_2D, false, false, false);
|
||||
/* don't bother drawing the image if alpha = 0 */
|
||||
}
|
||||
|
||||
|
@ -121,11 +121,9 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap);
|
||||
* - these deal with images bound as opengl textures */
|
||||
|
||||
void GPU_paint_update_image(struct Image *ima, struct ImageUser *iuser, int x, int y, int w, int h);
|
||||
void GPU_update_images_framechange(void);
|
||||
int GPU_update_image_time(struct Image *ima, double time);
|
||||
int GPU_verify_image(
|
||||
struct Image *ima, struct ImageUser *iuser,
|
||||
int textarget, int tftile, bool compare, bool mipmap, bool is_data);
|
||||
int textarget, bool compare, bool mipmap, bool is_data);
|
||||
void GPU_create_gl_tex(
|
||||
unsigned int *bind, unsigned int *rect, float *frect, int rectw, int recth,
|
||||
int textarget, bool mipmap, bool use_hight_bit_depth, struct Image *ima);
|
||||
|
@ -128,10 +128,6 @@ static int smaller_power_of_2_limit(int num)
|
||||
/* Current OpenGL state caching for GPU_set_tpage */
|
||||
|
||||
static struct GPUTextureState {
|
||||
int curtile, tile;
|
||||
int curtilemode, tilemode;
|
||||
int curtileXRep, tileXRep;
|
||||
int curtileYRep, tileYRep;
|
||||
Image *ima, *curima;
|
||||
|
||||
/* also controls min/mag filtering */
|
||||
@ -144,7 +140,7 @@ static struct GPUTextureState {
|
||||
int alphablend;
|
||||
float anisotropic;
|
||||
int gpu_mipmap;
|
||||
} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.0f, 0};
|
||||
} GTS = {NULL, NULL, 1, 0, 0, -1, 1.0f, 0};
|
||||
|
||||
/* Mipmap settings */
|
||||
|
||||
@ -232,28 +228,6 @@ float GPU_get_anisotropic(void)
|
||||
|
||||
/* Set OpenGL state for an MTFace */
|
||||
|
||||
static void gpu_make_repbind(Image *ima)
|
||||
{
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
|
||||
if (ibuf == NULL)
|
||||
return;
|
||||
|
||||
if (ima->repbind) {
|
||||
glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
|
||||
MEM_freeN(ima->repbind);
|
||||
ima->repbind = NULL;
|
||||
ima->tpageflag &= ~IMA_MIPMAP_COMPLETE;
|
||||
}
|
||||
|
||||
ima->totbind = ima->xrep * ima->yrep;
|
||||
|
||||
if (ima->totbind > 1) {
|
||||
ima->repbind = MEM_callocN(sizeof(int) * ima->totbind, "repbind");
|
||||
}
|
||||
|
||||
BKE_image_release_ibuf(ima, ibuf, NULL);
|
||||
}
|
||||
|
||||
static unsigned int *gpu_get_image_bindcode(Image *ima, GLenum textarget)
|
||||
{
|
||||
unsigned int *bind = 0;
|
||||
@ -350,7 +324,7 @@ static void gpu_verify_high_bit_srgb_buffer(float *srgb_frect,
|
||||
|
||||
int GPU_verify_image(
|
||||
Image *ima, ImageUser *iuser,
|
||||
int textarget, int tftile, bool compare, bool mipmap, bool is_data)
|
||||
int textarget, bool compare, bool mipmap, bool is_data)
|
||||
{
|
||||
unsigned int *bind = NULL;
|
||||
int tpx = 0, tpy = 0;
|
||||
@ -360,30 +334,9 @@ int GPU_verify_image(
|
||||
/* flag to determine whether deep format is used */
|
||||
bool use_high_bit_depth = false, do_color_management = false;
|
||||
|
||||
/* initialize tile mode and number of repeats */
|
||||
GTS.ima = ima;
|
||||
GTS.tilemode = (ima && (ima->tpageflag & (IMA_TILES | IMA_TWINANIM)));
|
||||
GTS.tileXRep = 0;
|
||||
GTS.tileYRep = 0;
|
||||
|
||||
/* setting current tile according to frame */
|
||||
if (ima && (ima->tpageflag & IMA_TWINANIM))
|
||||
GTS.tile = ima->lastframe;
|
||||
else
|
||||
GTS.tile = tftile;
|
||||
|
||||
GTS.tile = MAX2(0, GTS.tile);
|
||||
|
||||
if (ima) {
|
||||
GTS.tileXRep = ima->xrep;
|
||||
GTS.tileYRep = ima->yrep;
|
||||
}
|
||||
|
||||
/* if same image & tile, we're done */
|
||||
if (compare && ima == GTS.curima && GTS.curtile == GTS.tile &&
|
||||
GTS.tilemode == GTS.curtilemode && GTS.curtileXRep == GTS.tileXRep &&
|
||||
GTS.curtileYRep == GTS.tileYRep)
|
||||
{
|
||||
if (compare && ima == GTS.curima) {
|
||||
return (ima != NULL);
|
||||
}
|
||||
|
||||
@ -423,47 +376,7 @@ int GPU_verify_image(
|
||||
ima->tpageflag &= ~IMA_TPAGE_REFRESH;
|
||||
}
|
||||
|
||||
if (GTS.tilemode) {
|
||||
/* tiled mode */
|
||||
if (ima->repbind == NULL) gpu_make_repbind(ima);
|
||||
if (GTS.tile >= ima->totbind) GTS.tile = 0;
|
||||
|
||||
/* this happens when you change repeat buttons */
|
||||
if (ima->repbind && textarget == GL_TEXTURE_2D) bind = &ima->repbind[GTS.tile];
|
||||
else bind = gpu_get_image_bindcode(ima, textarget);
|
||||
|
||||
if (*bind == 0) {
|
||||
short texwindx = ibuf->x / ima->xrep;
|
||||
short texwindy = ibuf->y / ima->yrep;
|
||||
|
||||
if (GTS.tile >= ima->xrep * ima->yrep)
|
||||
GTS.tile = ima->xrep * ima->yrep - 1;
|
||||
|
||||
short texwinsy = GTS.tile / ima->xrep;
|
||||
short texwinsx = GTS.tile - texwinsy * ima->xrep;
|
||||
|
||||
texwinsx *= texwindx;
|
||||
texwinsy *= texwindy;
|
||||
|
||||
tpx = texwindx;
|
||||
tpy = texwindy;
|
||||
|
||||
if (use_high_bit_depth) {
|
||||
if (do_color_management) {
|
||||
srgb_frect = MEM_mallocN(ibuf->x * ibuf->y * sizeof(float) * 4, "floar_buf_col_cor");
|
||||
gpu_verify_high_bit_srgb_buffer(srgb_frect, ibuf);
|
||||
frect = srgb_frect + (4 * (texwinsy * ibuf->x + texwinsx));
|
||||
}
|
||||
else {
|
||||
frect = ibuf->rect_float + (ibuf->channels * (texwinsy * ibuf->x + texwinsx));
|
||||
}
|
||||
}
|
||||
else {
|
||||
rect = ibuf->rect + texwinsy * ibuf->x + texwinsx;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
{
|
||||
/* regular image mode */
|
||||
bind = gpu_get_image_bindcode(ima, textarget);
|
||||
|
||||
@ -492,37 +405,6 @@ int GPU_verify_image(
|
||||
const int rectw = tpx;
|
||||
const int recth = tpy;
|
||||
|
||||
unsigned *tilerect = NULL;
|
||||
float *ftilerect = NULL;
|
||||
|
||||
/* for tiles, copy only part of image into buffer */
|
||||
if (GTS.tilemode) {
|
||||
if (use_high_bit_depth) {
|
||||
ftilerect = MEM_mallocN(rectw * recth * sizeof(*ftilerect), "tilerect");
|
||||
|
||||
for (int y = 0; y < recth; y++) {
|
||||
const float *frectrow = &frect[y * ibuf->x];
|
||||
float *ftilerectrow = &ftilerect[y * rectw];
|
||||
|
||||
memcpy(ftilerectrow, frectrow, tpx * sizeof(*frectrow));
|
||||
}
|
||||
|
||||
frect = ftilerect;
|
||||
}
|
||||
else {
|
||||
tilerect = MEM_mallocN(rectw * recth * sizeof(*tilerect), "tilerect");
|
||||
|
||||
for (int y = 0; y < recth; y++) {
|
||||
const unsigned *rectrow = &rect[y * ibuf->x];
|
||||
unsigned *tilerectrow = &tilerect[y * rectw];
|
||||
|
||||
memcpy(tilerectrow, rectrow, tpx * sizeof(*rectrow));
|
||||
}
|
||||
|
||||
rect = tilerect;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_DDS
|
||||
if (ibuf->ftype == IMB_FTYPE_DDS)
|
||||
GPU_create_gl_tex_compressed(bind, rect, rectw, recth, textarget, mipmap, ima, ibuf);
|
||||
@ -539,10 +421,6 @@ int GPU_verify_image(
|
||||
}
|
||||
|
||||
/* clean up */
|
||||
if (tilerect)
|
||||
MEM_freeN(tilerect);
|
||||
if (ftilerect)
|
||||
MEM_freeN(ftilerect);
|
||||
if (srgb_frect)
|
||||
MEM_freeN(srgb_frect);
|
||||
|
||||
@ -965,8 +843,7 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
|
||||
{
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
|
||||
|
||||
if (ima->repbind ||
|
||||
(!GTS.gpu_mipmap && GPU_get_mipmap()) ||
|
||||
if ((!GTS.gpu_mipmap && GPU_get_mipmap()) ||
|
||||
(ima->bindcode[TEXTARGET_TEXTURE_2D] == 0) ||
|
||||
(ibuf == NULL) ||
|
||||
(w == 0) || (h == 0))
|
||||
@ -1043,61 +920,6 @@ void GPU_paint_update_image(Image *ima, ImageUser *iuser, int x, int y, int w, i
|
||||
BKE_image_release_ibuf(ima, ibuf, NULL);
|
||||
}
|
||||
|
||||
void GPU_update_images_framechange(void)
|
||||
{
|
||||
for (Image *ima = G.main->image.first; ima; ima = ima->id.next) {
|
||||
if (ima->tpageflag & IMA_TWINANIM) {
|
||||
if (ima->twend >= ima->xrep * ima->yrep)
|
||||
ima->twend = ima->xrep * ima->yrep - 1;
|
||||
|
||||
/* check: is bindcode not in the array? free. (to do) */
|
||||
|
||||
ima->lastframe++;
|
||||
if (ima->lastframe > ima->twend)
|
||||
ima->lastframe = ima->twsta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int GPU_update_image_time(Image *ima, double time)
|
||||
{
|
||||
if (!ima)
|
||||
return 0;
|
||||
|
||||
if (ima->lastupdate < 0)
|
||||
ima->lastupdate = 0;
|
||||
|
||||
if (ima->lastupdate > (float)time)
|
||||
ima->lastupdate = (float)time;
|
||||
|
||||
int inc = 0;
|
||||
|
||||
if (ima->tpageflag & IMA_TWINANIM) {
|
||||
if (ima->twend >= ima->xrep * ima->yrep) ima->twend = ima->xrep * ima->yrep - 1;
|
||||
|
||||
/* check: is the bindcode not in the array? Then free. (still to do) */
|
||||
|
||||
float diff = (float)((float)time - ima->lastupdate);
|
||||
inc = (int)(diff * (float)ima->animspeed);
|
||||
|
||||
ima->lastupdate += ((float)inc / (float)ima->animspeed);
|
||||
|
||||
int newframe = ima->lastframe + inc;
|
||||
|
||||
if (newframe > (int)ima->twend) {
|
||||
if (ima->twend - ima->twsta != 0)
|
||||
newframe = (int)ima->twsta - 1 + (newframe - ima->twend) % (ima->twend - ima->twsta);
|
||||
else
|
||||
newframe = ima->twsta;
|
||||
}
|
||||
|
||||
ima->lastframe = newframe;
|
||||
}
|
||||
|
||||
return inc;
|
||||
}
|
||||
|
||||
|
||||
void GPU_free_smoke(SmokeModifierData *smd)
|
||||
{
|
||||
if (smd->type & MOD_SMOKE_TYPE_DOMAIN && smd->domain) {
|
||||
@ -1242,14 +1064,6 @@ void GPU_free_image(Image *ima)
|
||||
}
|
||||
}
|
||||
|
||||
/* free repeated image binding */
|
||||
if (ima->repbind) {
|
||||
glDeleteTextures(ima->totbind, (GLuint *)ima->repbind);
|
||||
|
||||
MEM_freeN(ima->repbind);
|
||||
ima->repbind = NULL;
|
||||
}
|
||||
|
||||
ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE | IMA_GLBIND_IS_DATA);
|
||||
}
|
||||
|
||||
@ -1293,7 +1107,7 @@ void GPU_free_images_old(void)
|
||||
if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) {
|
||||
/* If it's in GL memory, deallocate and set time tag to current time
|
||||
* This gives textures a "second chance" to be used before dying. */
|
||||
if (BKE_image_has_bindcode(ima) || ima->repbind) {
|
||||
if (BKE_image_has_bindcode(ima)) {
|
||||
GPU_free_image(ima);
|
||||
ima->lastused = ctime;
|
||||
}
|
||||
|
@ -582,12 +582,11 @@ static GPUTexture *GPU_texture_cube_create(
|
||||
return tex;
|
||||
}
|
||||
|
||||
GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget, bool is_data, double time, int mipmap)
|
||||
GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget, bool is_data, double UNUSED(time), int mipmap)
|
||||
{
|
||||
int gputt;
|
||||
/* this binds a texture, so that's why to restore it to 0 */
|
||||
GLint bindcode = GPU_verify_image(ima, iuser, textarget, 0, 0, mipmap, is_data);
|
||||
GPU_update_image_time(ima, time);
|
||||
GLint bindcode = GPU_verify_image(ima, iuser, textarget, 0, mipmap, is_data);
|
||||
|
||||
/* see GPUInput::textarget: it can take two values - GL_TEXTURE_2D and GL_TEXTURE_CUBE_MAP
|
||||
* these values are correct for glDisable, so textarget can be safely used in
|
||||
|
@ -116,23 +116,18 @@ typedef struct Image {
|
||||
int lastframe;
|
||||
|
||||
/* texture page */
|
||||
short tpageflag, totbind;
|
||||
short xrep, yrep;
|
||||
short twsta, twend;
|
||||
short tpageflag;
|
||||
short pad2;
|
||||
unsigned int bindcode[2]; /* only for current image... 2 = TEXTARGET_COUNT */
|
||||
char pad1[4];
|
||||
unsigned int *repbind; /* for repeat of parts of images */
|
||||
|
||||
unsigned int pad3;
|
||||
|
||||
struct PackedFile *packedfile DNA_DEPRECATED; /* deprecated */
|
||||
struct ListBase packedfiles;
|
||||
struct PreviewImage *preview;
|
||||
|
||||
/* game engine tile animation */
|
||||
float lastupdate;
|
||||
int lastused;
|
||||
short animspeed;
|
||||
|
||||
short ok;
|
||||
short pad4[3];
|
||||
|
||||
/* for generated images */
|
||||
int gen_x, gen_y;
|
||||
@ -168,7 +163,7 @@ enum {
|
||||
#ifdef DNA_DEPRECATED
|
||||
IMA_DO_PREMUL = (1 << 2), /* deprecated, should not be used */
|
||||
#endif
|
||||
IMA_REFLECT = (1 << 4),
|
||||
//IMA_REFLECT = (1 << 4), /* deprecated */
|
||||
IMA_NOCOLLECT = (1 << 5),
|
||||
//IMA_DONE_TAG = (1 << 6), // UNUSED
|
||||
IMA_OLD_PREMUL = (1 << 7),
|
||||
@ -184,12 +179,12 @@ enum {
|
||||
};
|
||||
|
||||
/* Image.tpageflag */
|
||||
#define IMA_TILES 1
|
||||
#define IMA_TWINANIM 2
|
||||
#define IMA_COLCYCLE 4 /* Depreciated */
|
||||
//#define IMA_TILES 1 /* Deprecated */
|
||||
//#define IMA_TWINANIM 2 /* Deprecated */
|
||||
#define IMA_COLCYCLE 4 /* Deprecated */
|
||||
#define IMA_MIPMAP_COMPLETE 8 /* all mipmap levels in OpenGL texture set? */
|
||||
#define IMA_CLAMP_U 16
|
||||
#define IMA_CLAMP_V 32
|
||||
//#define IMA_CLAMP_U 16 /* Deprecated */
|
||||
//#define IMA_CLAMP_V 32 /* Deprecated */
|
||||
#define IMA_TPAGE_REFRESH 64
|
||||
#define IMA_GLBIND_IS_DATA 128 /* opengl image texture bound as non-color data */
|
||||
|
||||
|
@ -70,19 +70,6 @@ static const EnumPropertyItem image_source_items[] = {
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
|
||||
static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
{
|
||||
Image *ima = (Image *)ptr->data;
|
||||
int nr;
|
||||
|
||||
if (ima->flag & IMA_TWINANIM) {
|
||||
nr = ima->xrep * ima->yrep;
|
||||
if (ima->twsta >= nr) ima->twsta = 1;
|
||||
if (ima->twend >= nr) ima->twend = nr - 1;
|
||||
if (ima->twsta > ima->twend) ima->twsta = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static int rna_Image_is_stereo_3d_get(PointerRNA *ptr)
|
||||
{
|
||||
return BKE_image_is_stereo((Image *)ptr->data);
|
||||
@ -648,11 +635,6 @@ static void rna_def_image(BlenderRNA *brna)
|
||||
{IMA_TYPE_COMPOSITE, "COMPOSITING", 0, "Compositing", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
static const EnumPropertyItem prop_mapping_items[] = {
|
||||
{0, "UV", 0, "UV Coordinates", "Use UV coordinates for mapping the image"},
|
||||
{IMA_REFLECT, "REFLECTION", 0, "Reflection", "Use reflection mapping for mapping the image"},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
static const EnumPropertyItem prop_field_order_items[] = {
|
||||
{0, "EVEN", 0, "Upper First", "Upper field first"},
|
||||
{IMA_STD_FIELD, "ODD", 0, "Lower First", "Lower field first"},
|
||||
@ -803,14 +785,6 @@ static void rna_def_image(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
|
||||
/* realtime properties */
|
||||
prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
|
||||
RNA_def_property_enum_items(prop, prop_mapping_items);
|
||||
RNA_def_property_ui_text(prop, "Mapping", "Mapping type to use for this image in the game engine");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "display_aspect", PROP_FLOAT, PROP_XYZ);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_float_sdna(prop, NULL, "aspx");
|
||||
@ -820,66 +794,6 @@ static void rna_def_image(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_animation", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TWINANIM);
|
||||
RNA_def_property_ui_text(prop, "Animated", "Use as animated texture in the game engine");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
|
||||
|
||||
prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_int_sdna(prop, NULL, "twsta");
|
||||
RNA_def_property_range(prop, 0, 255);
|
||||
RNA_def_property_ui_text(prop, "Animation Start", "Start frame of an animated texture");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
|
||||
|
||||
prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_int_sdna(prop, NULL, "twend");
|
||||
RNA_def_property_range(prop, 0, 255);
|
||||
RNA_def_property_ui_text(prop, "Animation End", "End frame of an animated texture");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_animated_update");
|
||||
|
||||
prop = RNA_def_property(srna, "fps", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_int_sdna(prop, NULL, "animspeed");
|
||||
RNA_def_property_range(prop, 1, 100);
|
||||
RNA_def_property_ui_text(prop, "Animation Speed", "Speed of the animation in frames per second");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_tiles", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_TILES);
|
||||
RNA_def_property_ui_text(prop, "Tiles",
|
||||
"Use of tilemode for faces (default shift-LMB to pick the tile for selected faces)");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "tiles_x", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_int_sdna(prop, NULL, "xrep");
|
||||
RNA_def_property_range(prop, 1, 16);
|
||||
RNA_def_property_ui_text(prop, "Tiles X", "Degree of repetition in the X direction");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "tiles_y", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_int_sdna(prop, NULL, "yrep");
|
||||
RNA_def_property_range(prop, 1, 16);
|
||||
RNA_def_property_ui_text(prop, "Tiles Y", "Degree of repetition in the Y direction");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_clamp_x", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_U);
|
||||
RNA_def_property_ui_text(prop, "Clamp X", "Disable texture repeating horizontally");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "use_clamp_y", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_OVERRIDABLE_STATIC);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "tpageflag", IMA_CLAMP_V);
|
||||
RNA_def_property_ui_text(prop, "Clamp Y", "Disable texture repeating vertically");
|
||||
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, NULL, "bindcode");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
|
Loading…
Reference in New Issue
Block a user