Gets the dynamic light value for this position
| 3031 | } |
| 3032 | // Gets the dynamic light value for this position |
| 3033 | void GetRoomDynamicScalar(vector *pos, room *rp, float *r, float *g, float *b) { |
| 3034 | float front_values_r[10]; |
| 3035 | float back_values_r[10]; |
| 3036 | float front_values_g[10]; |
| 3037 | float back_values_g[10]; |
| 3038 | float front_values_b[10]; |
| 3039 | float back_values_b[10]; |
| 3040 | if (!rp->volume_lights) { |
| 3041 | *r = 1; |
| 3042 | *g = 1; |
| 3043 | *b = 1; |
| 3044 | return; |
| 3045 | } |
| 3046 | float fl_x = (pos->x - rp->min_xyz.x) / VOLUME_SPACING; |
| 3047 | float fl_y = (pos->y - rp->min_xyz.y) / VOLUME_SPACING; |
| 3048 | float fl_z = (pos->z - rp->min_xyz.z) / VOLUME_SPACING; |
| 3049 | fl_x = std::max<float>(fl_x, 0); |
| 3050 | fl_y = std::max<float>(fl_y, 0); |
| 3051 | fl_z = std::max<float>(fl_z, 0); |
| 3052 | fl_x = std::min<float>(fl_x, rp->volume_width - 1); |
| 3053 | fl_y = std::min<float>(fl_y, rp->volume_height - 1); |
| 3054 | fl_z = std::min<float>(fl_z, rp->volume_depth - 1); |
| 3055 | int int_x = fl_x; |
| 3056 | int int_y = fl_y; |
| 3057 | int int_z = fl_z; |
| 3058 | fl_x -= int_x; |
| 3059 | fl_y -= int_y; |
| 3060 | fl_z -= int_z; |
| 3061 | int next_x = int_x + 1; |
| 3062 | int next_y = int_y + 1; |
| 3063 | int next_z = int_z + 1; |
| 3064 | next_x = std::min(rp->volume_width - 1, next_x); |
| 3065 | next_y = std::min(rp->volume_height - 1, next_y); |
| 3066 | next_z = std::min(rp->volume_depth - 1, next_z); |
| 3067 | |
| 3068 | float left_norm_r, left_norm_g, left_norm_b; |
| 3069 | float right_norm_r, right_norm_g, right_norm_b; |
| 3070 | float front_norm_r, front_norm_g, front_norm_b; |
| 3071 | float back_norm_r, back_norm_g, back_norm_b; |
| 3072 | |
| 3073 | IsRoomDynamicValid(rp, int_x, int_y, int_z, &front_values_r[0], &front_values_g[0], &front_values_b[0]); |
| 3074 | IsRoomDynamicValid(rp, int_x, next_y, int_z, &front_values_r[1], &front_values_g[1], &front_values_b[1]); |
| 3075 | IsRoomDynamicValid(rp, next_x, next_y, int_z, &front_values_r[2], &front_values_g[2], &front_values_b[2]); |
| 3076 | IsRoomDynamicValid(rp, next_x, int_y, int_z, &front_values_r[3], &front_values_g[3], &front_values_b[3]); |
| 3077 | IsRoomDynamicValid(rp, int_x, int_y, next_z, &back_values_r[0], &back_values_g[0], &back_values_b[0]); |
| 3078 | IsRoomDynamicValid(rp, int_x, next_y, next_z, &back_values_r[1], &back_values_g[1], &back_values_b[1]); |
| 3079 | IsRoomDynamicValid(rp, next_x, next_y, next_z, &back_values_r[2], &back_values_g[2], &back_values_b[2]); |
| 3080 | IsRoomDynamicValid(rp, next_x, int_y, next_z, &back_values_r[3], &back_values_g[3], &back_values_b[3]); |
| 3081 | // Do front edge |
| 3082 | int left_out = 0; |
| 3083 | int right_out = 0; |
| 3084 | // Left edge |
| 3085 | left_norm_r = ((1 - fl_y) * front_values_r[0]) + (fl_y * front_values_r[1]); |
| 3086 | left_norm_g = ((1 - fl_y) * front_values_g[0]) + (fl_y * front_values_g[1]); |
| 3087 | left_norm_b = ((1 - fl_y) * front_values_b[0]) + (fl_y * front_values_b[1]); |
| 3088 | |
| 3089 | // Right edge |
| 3090 | right_norm_r = ((1 - fl_y) * front_values_r[3]) + (fl_y * front_values_r[2]); |
no test coverage detected