Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/drawvolume.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| #define SPEC_WIDTH 256 | #define SPEC_WIDTH 256 | ||||
| #define FIRE_THRESH 7 | #define FIRE_THRESH 7 | ||||
| #define MAX_FIRE_ALPHA 0.06f | #define MAX_FIRE_ALPHA 0.06f | ||||
| #define FULL_ON_FIRE 100 | #define FULL_ON_FIRE 100 | ||||
| GPUTexture *tex; | GPUTexture *tex; | ||||
| int i, j, k; | int i, j, k; | ||||
| unsigned char *spec_data = malloc(SPEC_WIDTH * 4 * sizeof(unsigned char)); | unsigned char *spec_data = malloc(SPEC_WIDTH * 4 * sizeof(unsigned char)); | ||||
| float *spec_pixels = malloc(SPEC_WIDTH * 4 * 16 * 16 * sizeof(float)); | float *spec_pixels = malloc(SPEC_WIDTH * 4 * 16 * 16 * sizeof(float)); | ||||
brecht: Not really new code in this patch, but we should really be using `MEM_malloc` / `MEM_free` here. | |||||
| flame_get_spectrum(spec_data, SPEC_WIDTH, 1500, 3000); | generate_spectrum_table(spec_data, SPEC_WIDTH, 1500, 3000); | ||||
| for (i = 0; i < 16; i++) { | for (i = 0; i < 16; i++) { | ||||
| for (j = 0; j < 16; j++) { | for (j = 0; j < 16; j++) { | ||||
| for (k = 0; k < SPEC_WIDTH; k++) { | for (k = 0; k < SPEC_WIDTH; k++) { | ||||
| int index = (j * SPEC_WIDTH * 16 + i * SPEC_WIDTH + k) * 4; | int index = (j * SPEC_WIDTH * 16 + i * SPEC_WIDTH + k) * 4; | ||||
| if (k >= FIRE_THRESH) { | if (k >= FIRE_THRESH) { | ||||
| spec_pixels[index] = ((float)spec_data[k * 4]) / 255.0f; | 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 + 1] = ((float)spec_data[k * 4 + 1]) / 255.0f; | ||||
| spec_pixels[index + 2] = ((float)spec_data[k * 4 + 2]) / 255.0f; | spec_pixels[index + 2] = ((float)spec_data[k * 4 + 2]) / 255.0f; | ||||
brechtUnsubmitted Not Done Inline Actionsgenerate_spectrum_table() might as well output floats directly without the intermediate conversion to char, since it's being undone here immediately. brecht: `generate_spectrum_table()` might as well output floats directly without the intermediate… | |||||
| spec_pixels[index + 3] = MAX_FIRE_ALPHA * ( | spec_pixels[index + 3] = MAX_FIRE_ALPHA * ( | ||||
| (k > FULL_ON_FIRE) ? 1.0f : (k - FIRE_THRESH) / ((float)FULL_ON_FIRE - FIRE_THRESH)); | (k > FULL_ON_FIRE) ? 1.0f : (k - FIRE_THRESH) / ((float)FULL_ON_FIRE - FIRE_THRESH)); | ||||
| } | } | ||||
| else { | else { | ||||
| zero_v4(&spec_pixels[index]); | zero_v4(&spec_pixels[index]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 350 Lines • Show Last 20 Lines | |||||
Not really new code in this patch, but we should really be using MEM_malloc / MEM_free here.