Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2016-01-09 06:48:31 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2016-01-09 06:48:31 +0300
commit14de8361f97c64b3d99b6e009fc8e9d19f90a328 (patch)
treedba055bfafa306a055958f4a8d2a2fb3bd54fbdc /source/blender/editors/space_view3d/drawvolume.c
parentd7da51b7277252d887cd93b1ac26bfe4ee25ad44 (diff)
Smoke (fire): Move spectrum code from C++ (intern/) to C code (BLI)
This change is for a few reasons: - it works with color, and (therefore) will need to be color managed, at some point. This will be much easier to do if the code is closer to the actual color management code (in Blender's core, so to speak). - it has nothing to do with the actual fire simulation, as it is just used to create a lookup table - it can be reused for other purposes (i.e. in Blender internal renderer, if people are interrested in a blackbody node à la Cycles) - cleanup: some functions (`contrain_rgb`, `xyz_to_rgb`) already exist in BLI Reviewers: brecht Reviewed By: brecht Subscribers: brecht Differential Revision: https://developer.blender.org/D1719
Diffstat (limited to 'source/blender/editors/space_view3d/drawvolume.c')
-rw-r--r--source/blender/editors/space_view3d/drawvolume.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c
index 102bfc55a2c..72d84b4be04 100644
--- a/source/blender/editors/space_view3d/drawvolume.c
+++ b/source/blender/editors/space_view3d/drawvolume.c
@@ -98,19 +98,19 @@ static GPUTexture *create_flame_spectrum_texture(void)
GPUTexture *tex;
int i, j, k;
- unsigned char *spec_data = malloc(SPEC_WIDTH * 4 * sizeof(unsigned char));
- float *spec_pixels = malloc(SPEC_WIDTH * 4 * 16 * 16 * sizeof(float));
+ float *spec_data = MEM_mallocN(SPEC_WIDTH * 4 * sizeof(float), "spec_data");
+ float *spec_pixels = MEM_mallocN(SPEC_WIDTH * 4 * 16 * 16 * sizeof(float), "spec_pixels");
- flame_get_spectrum(spec_data, SPEC_WIDTH, 1500, 3000);
+ blackbody_temperature_to_rgb_table(spec_data, SPEC_WIDTH, 1500, 3000);
for (i = 0; i < 16; i++) {
for (j = 0; j < 16; j++) {
for (k = 0; k < SPEC_WIDTH; k++) {
int index = (j * SPEC_WIDTH * 16 + i * SPEC_WIDTH + k) * 4;
if (k >= FIRE_THRESH) {
- spec_pixels[index] = ((float)spec_data[k * 4]) / 255.0f;
- spec_pixels[index + 1] = ((float)spec_data[k * 4 + 1]) / 255.0f;
- spec_pixels[index + 2] = ((float)spec_data[k * 4 + 2]) / 255.0f;
+ spec_pixels[index] = (spec_data[k * 4]);
+ spec_pixels[index + 1] = (spec_data[k * 4 + 1]);
+ spec_pixels[index + 2] = (spec_data[k * 4 + 2]);
spec_pixels[index + 3] = MAX_FIRE_ALPHA * (
(k > FULL_ON_FIRE) ? 1.0f : (k - FIRE_THRESH) / ((float)FULL_ON_FIRE - FIRE_THRESH));
}
@@ -123,8 +123,8 @@ static GPUTexture *create_flame_spectrum_texture(void)
tex = GPU_texture_create_1D(SPEC_WIDTH, spec_pixels, NULL);
- free(spec_data);
- free(spec_pixels);
+ MEM_freeN(spec_data);
+ MEM_freeN(spec_pixels);
#undef SPEC_WIDTH
#undef FIRE_THRESH