diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 1 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 15 | ||||
-rw-r--r-- | source/blender/gpu/CMakeLists.txt | 5 | ||||
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 3 | ||||
-rw-r--r-- | source/blender/gpu/GPU_material.h | 7 | ||||
-rw-r--r-- | source/blender/gpu/SConscript | 3 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 109 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 26 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_imbuf_types.h | 34 | ||||
-rw-r--r-- | source/blender/imbuf/intern/allocimbuf.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/DirectDrawSurface.cpp | 28 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/DirectDrawSurface.h | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/dds/dds_api.cpp | 12 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 17 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 72 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 48 |
17 files changed, 364 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3ffd8115914..5e025b986c2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -850,6 +850,7 @@ Object *add_only_object(int type, const char *name) /* ob->pad3 == Contact Processing Threshold */ ob->m_contactProcessingThreshold = 1.0f; ob->obstacleRad = 1.0f; + ob->col_group = ob->col_mask = 1; /* NT fluid sim defaults */ ob->fluidsimSettings = NULL; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 9aa87a86b3e..547da946247 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -12894,6 +12894,21 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + { + /* Initialize BGE exit key to esc key */ + Scene *scene; + for(scene= main->scene.first; scene; scene= scene->id.next) { + if (!scene->gm.exitkey) + scene->gm.exitkey = 218; //218 is the Blender key code for ESC + } + } + + { + /* Initialize default values for collision masks */ + Object *ob; + for(ob=main->object.first; ob; ob=ob->id.next) + ob->col_group = ob->col_mask = 1; + } } if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 6)) { diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 01afc0e24eb..4d28b86ae25 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -66,5 +66,10 @@ endif() add_definitions(-DGLEW_STATIC) +if(WITH_IMAGE_DDS) + add_definitions(-DWITH_DDS) +endif() + + blender_add_lib(bf_gpu "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 89976699114..4186466739c 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -119,6 +119,8 @@ void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h, int m 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 tftile, int compare, int mipmap); +void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int rectw, int recth, int mipmap, int use_hight_bit_depth, struct Image *ima); +void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, struct Image *ima, struct ImBuf *ibuf); void GPU_free_image(struct Image *ima); void GPU_free_images(void); void GPU_free_images_anim(void); @@ -135,4 +137,3 @@ void GPU_free_unused_buffers(void); #endif #endif - diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index 33c5d474932..e2746aef9a8 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -173,6 +173,11 @@ typedef enum GPUDynamicType { GPU_DYNAMIC_SAMPLER_2DBUFFER = 12, GPU_DYNAMIC_SAMPLER_2DIMAGE = 13, GPU_DYNAMIC_SAMPLER_2DSHADOW = 14, + GPU_DYNAMIC_LAMP_DISTANCE = 15, + GPU_DYNAMIC_LAMP_ATT1 = 16, + GPU_DYNAMIC_LAMP_ATT2 = 17, + GPU_DYNAMIC_LAMP_SPOTSIZE = 18, + GPU_DYNAMIC_LAMP_SPOTBLEND = 19, } GPUDynamicType; typedef enum GPUDataType { @@ -230,6 +235,8 @@ void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp); void GPU_lamp_update(GPULamp *lamp, int lay, int hide, float obmat[][4]); void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float energy); +void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2); +void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend); int GPU_lamp_shadow_layer(GPULamp *lamp); #ifdef __cplusplus diff --git a/source/blender/gpu/SConscript b/source/blender/gpu/SConscript index 11b0ee5f9fa..e6ffc172300 100644 --- a/source/blender/gpu/SConscript +++ b/source/blender/gpu/SConscript @@ -16,4 +16,7 @@ incs += ' ' + env['BF_OPENGL_INC'] if env['WITH_BF_SMOKE']: defs.append('WITH_SMOKE') +if env['WITH_BF_DDS']: + defs.append('WITH_DDS') + env.BlenderLib ( 'bf_gpu', sources, Split(incs), defines = defs, libtype=['core','player'], priority=[160,110] ) diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index c830971dcbd..b6433e11989 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -413,8 +413,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int ImBuf *ibuf = NULL; unsigned int *bind = NULL; int rectw, recth, tpx=0, tpy=0, y; - unsigned int *tilerect= NULL, *scalerect= NULL, *rect= NULL; - float *ftilerect= NULL, *fscalerect = NULL, *frect = NULL; + unsigned int *tilerect= NULL, *rect= NULL; + float *ftilerect= NULL, *frect = NULL; float *srgb_frect = NULL; short texwindx, texwindy, texwinsx, texwinsy; /* flag to determine whether high resolution format is used */ @@ -597,10 +597,37 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int rect= tilerect; } } +#ifdef WITH_DDS + if (ibuf->ftype & DDS) + GPU_create_gl_tex_compressed(bind, rect, rectw, recth, mipmap, ima, ibuf); + else +#endif + GPU_create_gl_tex(bind, rect, frect, rectw, recth, mipmap, use_high_bit_depth, ima); + + /* clean up */ + if (tilerect) + MEM_freeN(tilerect); + if (ftilerect) + MEM_freeN(ftilerect); + if (srgb_frect) + MEM_freeN(srgb_frect); + return *bind; +} + +void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float * frect, int rectw, int recth, int mipmap, int use_high_bit_depth, Image *ima) +{ + unsigned int *scalerect = NULL; + float *fscalerect = NULL; + + int tpx = rectw; + int tpy = recth; + /* scale if not a power of two. this is not strictly necessary for newer * GPUs (OpenGL version >= 2.0) since they support non-power-of-two-textures */ if (!is_pow2_limit(rectw) || !is_pow2_limit(recth)) { + int oldw= rectw; + int oldh= recth; rectw= smaller_pow2_limit(rectw); recth= smaller_pow2_limit(recth); @@ -612,9 +639,9 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int } else { scalerect= MEM_mallocN(rectw*recth*sizeof(*scalerect), "scalerect"); - gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, rect, rectw, recth, GL_UNSIGNED_BYTE, scalerect); + gluScaleImage(GL_RGBA, tpx, tpy, GL_UNSIGNED_BYTE, pix, rectw, recth, GL_UNSIGNED_BYTE, scalerect); - rect= scalerect; + pix= scalerect; } } @@ -626,7 +653,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (use_high_bit_depth) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, rectw, recth, 0, GL_RGBA, GL_FLOAT, frect); else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, rectw, recth, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); } @@ -634,7 +661,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int if (use_high_bit_depth) gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA16, rectw, recth, GL_RGBA, GL_FLOAT, frect); else - gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, rect); + gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, rectw, recth, GL_RGBA, GL_UNSIGNED_BYTE, pix); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gpu_get_mipmap_filter(0)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); @@ -645,21 +672,72 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); /* set to modulate with vertex color */ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - - /* clean up */ - if (tilerect) - MEM_freeN(tilerect); - if (ftilerect) - MEM_freeN(ftilerect); + if (scalerect) MEM_freeN(scalerect); if (fscalerect) MEM_freeN(fscalerect); - if (srgb_frect) - MEM_freeN(srgb_frect); - return *bind; } +void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, Image *ima, ImBuf *ibuf) +{ +#ifndef WITH_DDS + // Fall back to uncompressed if DDS isn't enabled + GPU_create_gl_tex(bind, pix, NULL, x, y, mipmap, 0, ima); +#else + GLint format=0; + int offset =0, i=0; + int blocksize, width, height; + int size; + GLint err; + + if (ibuf->dds_data.fourcc == FOURCC_DXT1) + format = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + else if (ibuf->dds_data.fourcc == FOURCC_DXT3) + format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + else if (ibuf->dds_data.fourcc == FOURCC_DXT5) + format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + else + { + printf("Unable to find a suitable DXT compression, falling back to uncompressed\n"); + GPU_create_gl_tex(bind, pix, NULL, x, y, mipmap, 0, ima); + return; + } + + glGenTextures(1, (GLuint *)bind); + glBindTexture(GL_TEXTURE_2D, *bind); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); + + height = ibuf->x; + width = ibuf->y; + blocksize = (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ? 8 : 16; + for (i=0; i<ibuf->dds_data.nummipmaps && (width||height); ++i) + { + if (width == 0) + width = 1; + if (height == 0) + height = 1; + + size = ((width+3)/4)*((height+3)/4)*blocksize; + + glCompressedTexImage2D(GL_TEXTURE_2D, i, format, width, height, + 0, size, ibuf->dds_data.data + offset); + + err = glGetError(); + + if (err != GL_NO_ERROR) + printf("OpenGL error: %s\nFormat: %x\n", gluErrorString(err), format); + + offset += size; + width >>= 1; + height >>= 1; + } + + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); +#endif +} static void gpu_verify_repeat(Image *ima) { /* set either clamp or repeat in X/Y */ @@ -1897,4 +1975,3 @@ void GPU_state_print(void) gpu_get_print("GL_ZOOM_X", GL_ZOOM_X); gpu_get_print("GL_ZOOM_Y", GL_ZOOM_Y); } - diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index e14e4dce405..63b336963ab 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -117,6 +117,7 @@ struct GPULamp { float dynimat[4][4]; float spotsi, spotbl, k; + float dyndist, dynatt1, dynatt2; float dist, att1, att2; float bias, d, clipend; @@ -401,13 +402,13 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode case LA_FALLOFF_CONSTANT: break; case LA_FALLOFF_INVLINEAR: - GPU_link(mat, "lamp_falloff_invlinear", GPU_uniform(&lamp->dist), *dist, &visifac); + GPU_link(mat, "lamp_falloff_invlinear", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac); break; case LA_FALLOFF_INVSQUARE: - GPU_link(mat, "lamp_falloff_invsquare", GPU_uniform(&lamp->dist), *dist, &visifac); + GPU_link(mat, "lamp_falloff_invsquare", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, &visifac); break; case LA_FALLOFF_SLIDERS: - GPU_link(mat, "lamp_falloff_sliders", GPU_uniform(&lamp->dist), GPU_uniform(&lamp->att1), GPU_uniform(&lamp->att2), *dist, &visifac); + GPU_link(mat, "lamp_falloff_sliders", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), GPU_dynamic_uniform(&lamp->att1, GPU_DYNAMIC_LAMP_ATT1, lamp->ob), GPU_dynamic_uniform(&lamp->att2, GPU_DYNAMIC_LAMP_ATT2, lamp->ob), *dist, &visifac); break; case LA_FALLOFF_CURVE: { @@ -415,13 +416,13 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode int size; curvemapping_table_RGBA(lamp->curfalloff, &array, &size); - GPU_link(mat, "lamp_falloff_curve", GPU_uniform(&lamp->dist), GPU_texture(size, array), *dist, &visifac); + GPU_link(mat, "lamp_falloff_curve", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), GPU_texture(size, array), *dist, &visifac); } break; } if (lamp->mode & LA_SPHERE) - GPU_link(mat, "lamp_visibility_sphere", GPU_uniform(&lamp->dist), *dist, visifac, &visifac); + GPU_link(mat, "lamp_visibility_sphere", GPU_dynamic_uniform(&lamp->dist, GPU_DYNAMIC_LAMP_DISTANCE, lamp->ob), *dist, visifac, &visifac); if (lamp->type == LA_SPOT) { if (lamp->mode & LA_SQUARE) { @@ -433,7 +434,7 @@ static GPUNodeLink *lamp_get_visibility(GPUMaterial *mat, GPULamp *lamp, GPUNode GPU_link(mat, "lamp_visibility_spot_circle", GPU_dynamic_uniform(lamp->dynvec, GPU_DYNAMIC_LAMP_DYNVEC, lamp->ob), *lv, &inpr); } - GPU_link(mat, "lamp_visibility_spot", GPU_uniform(&lamp->spotsi), GPU_uniform(&lamp->spotbl), inpr, visifac, &visifac); + GPU_link(mat, "lamp_visibility_spot", GPU_dynamic_uniform(&lamp->spotsi, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob), GPU_dynamic_uniform(&lamp->spotbl, GPU_DYNAMIC_LAMP_SPOTSIZE, lamp->ob), inpr, visifac, &visifac); } GPU_link(mat, "lamp_visibility_clamp", visifac, &visifac); @@ -1516,6 +1517,19 @@ void GPU_lamp_update_colors(GPULamp *lamp, float r, float g, float b, float ener lamp->col[2]= b* lamp->energy; } +void GPU_lamp_update_distance(GPULamp *lamp, float distance, float att1, float att2) +{ + lamp->dist = distance; + lamp->att1 = att1; + lamp->att2 = att2; +} + +void GPU_lamp_update_spot(GPULamp *lamp, float spotsize, float spotblend) +{ + lamp->spotsi= cos(M_PI*spotsize/360.0); + lamp->spotbl= (1.0f - lamp->spotsi)*spotblend; +} + static void gpu_lamp_from_blender(Scene *scene, Object *ob, Object *par, Lamp *la, GPULamp *lamp) { float temp, angle, pixsize, wsize; diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 076f518585b..c77c48089dd 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -52,6 +52,13 @@ struct ImMetaData; #define IB_MIPMAP_LEVELS 20 #define IB_FILENAME_SIZE 1024 +typedef struct DDSData { + unsigned int fourcc; /* DDS fourcc info */ + unsigned int nummipmaps; /* The number of mipmaps in the dds file */ + unsigned char *data; /* The compressed image data */ + unsigned int size; /* The size of the compressed data */ +} DDSData; + /** * \ingroup imbuf * This is the abstraction of an image. ImBuf is the basic type used for all @@ -126,6 +133,9 @@ typedef struct ImBuf { unsigned char *encodedbuffer; /* Compressed image only used with png currently */ unsigned int encodedsize; /* Size of data written to encodedbuffer */ unsigned int encodedbuffersize; /* Size of encodedbuffer */ + + /* information for compressed textures */ + struct DDSData dds_data; } ImBuf; /* Moved from BKE_bmfont_types.h because it is a userflag bit mask. */ @@ -222,9 +232,31 @@ typedef struct ImBuf { #define IB_PROFILE_SRGB 2 #define IB_PROFILE_CUSTOM 3 + +/* dds */ +#ifdef WITH_DDS +#ifndef MAKEFOURCC +#define MAKEFOURCC(ch0, ch1, ch2, ch3)\ + ((unsigned long)(unsigned char)(ch0) | \ + ((unsigned long)(unsigned char)(ch1) << 8) | \ + ((unsigned long)(unsigned char)(ch2) << 16) | \ + ((unsigned long)(unsigned char)(ch3) << 24)) +#endif //MAKEFOURCC + +/* + * FOURCC codes for DX compressed-texture pixel formats + */ + +#define FOURCC_DDS (MAKEFOURCC('D','D','S',' ')) +#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) +#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) +#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) +#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) +#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) + +#endif // DDS extern const char *imb_ext_image[]; extern const char *imb_ext_image_qt[]; extern const char *imb_ext_movie[]; extern const char *imb_ext_audio[]; - #endif diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 2cfdd7bc324..b9700227328 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -162,6 +162,8 @@ void IMB_freeImBuf(ImBuf *ibuf) IMB_freezbuffloatImBuf(ibuf); freeencodedbufferImBuf(ibuf); IMB_metadata_free(ibuf); + if (ibuf->dds_data.data != NULL) + free(ibuf->dds_data.data); MEM_freeN(ibuf); } } diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index 3966135ea32..b28451808ce 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -1016,6 +1016,10 @@ uint DirectDrawSurface::mipmapCount() const else return 1; } +uint DirectDrawSurface::fourCC() const +{ + return header.pf.fourcc; +} uint DirectDrawSurface::width() const { @@ -1131,6 +1135,29 @@ void DirectDrawSurface::mipmap(Image * img, uint face, uint mipmap) } } +// It was easier to copy this function from upstream than to resync. +// This should be removed if a resync ever occurs. +void* DirectDrawSurface::readData(uint &rsize) +{ + uint header_size = 128; // sizeof(DDSHeader); + if (header.hasDX10Header()) + { + header_size += 20; // sizeof(DDSHeader10); + } + + uint size = stream.size - header_size; + rsize = size; + + unsigned char *data = new unsigned char[size]; + + stream.seek(header_size); + mem_read(stream, data, size); + + // Maybe check if size == rsize? assert() isn't in this scope... + + return data; +} + void DirectDrawSurface::readLinearImage(Image * img) { @@ -1523,4 +1550,3 @@ void DirectDrawSurface::printInfo() const printf("User Version: %u\n", header.reserved[8]); } } - diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.h b/source/blender/imbuf/intern/dds/DirectDrawSurface.h index 23c8bbf2de3..28ecb948643 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.h +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.h @@ -158,6 +158,7 @@ public: bool hasAlpha() const; uint mipmapCount() const; + uint fourCC() const; uint width() const; uint height() const; uint depth() const; @@ -171,6 +172,7 @@ public: void setUserVersion(int version); void mipmap(Image * img, uint f, uint m); + void* readData(uint &size); // void mipmap(FloatImage * img, uint f, uint m); void printInfo() const; diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 071d94c2076..fba326f7865 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -123,6 +123,8 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) ibuf->ftype = DDS; ibuf->profile = IB_PROFILE_SRGB; + ibuf->dds_data.fourcc = dds.fourCC(); + ibuf->dds_data.nummipmaps = dds.mipmapCount(); if ((flags & IB_test) == 0) { if (!imb_addrectImBuf(ibuf)) return(ibuf); @@ -136,10 +138,18 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags) cp[0] = pixel.r; /* set R component of col */ cp[1] = pixel.g; /* set G component of col */ cp[2] = pixel.b; /* set B component of col */ - if (bits_per_pixel == 32) + if (dds.hasAlpha()) cp[3] = pixel.a; /* set A component of col */ rect[i] = col; } + + if (ibuf->dds_data.fourcc != FOURCC_DDS) + ibuf->dds_data.data = (unsigned char*)dds.readData(ibuf->dds_data.size); + else { + ibuf->dds_data.data = NULL; + ibuf->dds_data.size = 0; + } + IMB_flipy(ibuf); } diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 05a96ef2f35..3eead8b7b8d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -234,6 +234,9 @@ typedef struct Object { short recalc; /* dependency flag */ float anisotropicFriction[3]; + /** Collision mask settings */ + unsigned short col_group, col_mask, col_pad[2]; + ListBase constraints; /* object constraints */ ListBase nlastrips DNA_DEPRECATED; // XXX depreceated... old animation system ListBase hooks DNA_DEPRECATED; // XXX depreceated... old animation system @@ -455,6 +458,9 @@ typedef struct DupliObject { /* controller state */ #define OB_MAX_STATES 30 +/* collision masks */ +#define OB_MAX_COL_MASKS 8 + /* ob->gameflag */ #define OB_DYNAMIC 1 #define OB_CHILD 2 diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 83688e30643..5239cf2e646 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -624,7 +624,18 @@ typedef struct GameData { short exitkey, pad; short ticrate, maxlogicstep, physubstep, maxphystep; short obstacleSimulation, pad1; + short raster_storage; + short pad3; float levelHeight; + float pad2; + + /* Dynamic Lights */ + short dynpoints; + short dynspots; + short dynsuns; + short dynhemis; + short dynareas; + short light_pad[3]; } GameData; #define STEREO_NOSTEREO 1 @@ -649,6 +660,12 @@ typedef struct GameData { #define OBSTSIMULATION_TOI_rays 1 #define OBSTSIMULATION_TOI_cells 2 +/* Render storage */ +#define RAS_STORE_AUTO 0 +#define RAS_STORE_IMMEDIATE 1 +#define RAS_STORE_VA 2 +#define RAS_STORE_VBO 3 + /* GameData.flag */ #define GAME_RESTRICT_ANIM_UPDATES (1 << 0) #define GAME_ENABLE_ALL_FRAMES (1 << 1) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 140e874eb78..582a396b0b6 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1052,6 +1052,64 @@ static void rna_GameObjectSettings_state_set(PointerRNA *ptr, const int *values) } } +static void rna_GameObjectSettings_col_group_get(PointerRNA *ptr, int *values) +{ + Object *ob= (Object*)ptr->data; + int i; + + memset(values, 0, sizeof(short)*OB_MAX_COL_MASKS); + for(i=0; i<OB_MAX_COL_MASKS; i++) + values[i] = (ob->col_group & (1<<i)); +} + +static void rna_GameObjectSettings_col_group_set(PointerRNA *ptr, const int *values) +{ + Object *ob= (Object*)ptr->data; + int i, tot= 0; + + /* ensure we always have some group selected */ + for(i=0; i<OB_MAX_COL_MASKS; i++) + if(values[i]) + tot++; + + if(tot==0) + return; + + for(i=0; i<OB_MAX_COL_MASKS; i++) { + if(values[i]) ob->col_group |= (1<<i); + else ob->col_group &= ~(1<<i); + } +} + +static void rna_GameObjectSettings_col_mask_get(PointerRNA *ptr, int *values) +{ + Object *ob= (Object*)ptr->data; + int i; + + memset(values, 0, sizeof(short)*OB_MAX_COL_MASKS); + for(i=0; i<OB_MAX_COL_MASKS; i++) + values[i] = (ob->col_mask & (1<<i)); +} + +static void rna_GameObjectSettings_col_mask_set(PointerRNA *ptr, const int *values) +{ + Object *ob= (Object*)ptr->data; + int i, tot= 0; + + /* ensure we always have some mask selected */ + for(i=0; i<OB_MAX_COL_MASKS; i++) + if(values[i]) + tot++; + + if(tot==0) + return; + + for(i=0; i<OB_MAX_COL_MASKS; i++) { + if(values[i]) ob->col_mask |= (1<<i); + else ob->col_mask &= ~(1<<i); + } +} + static void rna_GameObjectSettings_used_state_get(PointerRNA *ptr, int *values) { Object *ob = (Object*)ptr->data; @@ -1412,6 +1470,8 @@ static void rna_def_object_game_settings(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; + int default_col_mask[8] = {1,0,0,0, 0,0,0,0}; + static EnumPropertyItem body_type_items[] = { {OB_BODY_TYPE_NO_COLLISION, "NO_COLLISION", 0, "No Collision", "Disable collision for this object"}, {OB_BODY_TYPE_STATIC, "STATIC", 0, "Static", "Stationary object"}, @@ -1516,6 +1576,18 @@ static void rna_def_object_game_settings(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1000.0); RNA_def_property_ui_text(prop, "Velocity Max", "Clamp velocity to this maximum speed"); + prop= RNA_def_property(srna, "collision_group", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "col_group", 1); + RNA_def_property_array(prop, OB_MAX_COL_MASKS); + RNA_def_property_ui_text(prop, "Collision Group", "The collision group of the object"); + RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_group_get", "rna_GameObjectSettings_col_group_set"); + + prop= RNA_def_property(srna, "collision_mask", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_boolean_sdna(prop, NULL, "col_mask", 1); + RNA_def_property_array(prop, OB_MAX_COL_MASKS); + RNA_def_property_ui_text(prop, "Collision Mask", "The groups this object can collide with"); + RNA_def_property_boolean_funcs(prop, "rna_GameObjectSettings_col_mask_get", "rna_GameObjectSettings_col_mask_set"); + /* lock position */ prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gameflag2", OB_LOCK_RIGID_BODY_X_AXIS); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 359b1e4ee00..b4a70866c44 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2356,6 +2356,13 @@ static void rna_def_scene_game_data(BlenderRNA *brna) {OBSTSIMULATION_TOI_cells, "RVO_CELLS", 0, "RVO (cells)", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem storage_items[] ={ + {RAS_STORE_AUTO, "AUTO", 0, "Auto Select", "Chooses the best supported mode"}, + {RAS_STORE_IMMEDIATE, "IMMEDIATE", 0, "Immediate Mode", "Slowest performance, requires OpenGL (any version)"}, + {RAS_STORE_VA, "VERTEX_ARRAY", 0, "Vertex Arrays", "Moderate performance, requires at least OpenGL 1.1"}, + {RAS_STORE_VBO, "VERTEX_BUFFER_OBJECT", 0, "Vertex Buffer Objects", "Best performance, requires at least OpenGL 1.4"}, + {0, NULL, 0, NULL, NULL}}; + srna = RNA_def_struct(brna, "SceneGameData", NULL); RNA_def_struct_sdna(srna, "GameData"); RNA_def_struct_nested(brna, srna, "Scene"); @@ -2390,6 +2397,11 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_GameSettings_exit_key_set", NULL); RNA_def_property_ui_text(prop, "Exit Key", "The key that exits the Game Engine"); RNA_def_property_update(prop, NC_SCENE, NULL); + prop= RNA_def_property(srna, "raster_storage", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "raster_storage"); + RNA_def_property_enum_items(prop, storage_items); + RNA_def_property_ui_text(prop, "Storage", "Sets the storage mode used by the rasterizer"); + RNA_def_property_update(prop, NC_SCENE, NULL); /* Do we need it here ? (since we already have it in World */ prop = RNA_def_property(srna, "frequency", PROP_INT, PROP_NONE); @@ -2408,6 +2420,42 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Desktop", "Uses the current desktop resultion in fullscreen mode"); RNA_def_property_update(prop, NC_SCENE, NULL); + /* Dynamic Lights */ + prop = RNA_def_property(srna, "dynamic_points", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "dynpoints"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_range(prop, 0, 15, 1, 1); + RNA_def_property_ui_text(prop, "Dynamic Point Lights", "Number of point lights available for dynamic use"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop = RNA_def_property(srna, "dynamic_spots", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "dynspots"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_range(prop, 0, 15, 1, 1); + RNA_def_property_ui_text(prop, "Dynamic Spot Lights", "Number of spot lights available for dynamic use"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop = RNA_def_property(srna, "dynamic_suns", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "dynsuns"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_range(prop, 0, 15, 1, 1); + RNA_def_property_ui_text(prop, "Dynamic Sun Lights", "Number of sun lights available for dynamic use"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop = RNA_def_property(srna, "dynamic_hemis", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "dynhemis"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_range(prop, 0, 15, 1, 1); + RNA_def_property_ui_text(prop, "Dynamic Hemi Lights", "Number of hemi lights available for dynamic use"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop = RNA_def_property(srna, "dynamic_areas", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "dynareas"); + RNA_def_property_range(prop, 0, 100); + RNA_def_property_ui_range(prop, 0, 15, 1, 1); + RNA_def_property_ui_text(prop, "Dynamic Area Lights", "Number of area lights available for dynamic use"); + RNA_def_property_update(prop, NC_SCENE, NULL); + /* Framing */ prop = RNA_def_property(srna, "frame_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "framing.type"); |