just pass plane image width & height
This commit is contained in:
		
							parent
							
								
									4b26cec390
								
							
						
					
					
						commit
						47a662db44
					
				@ -32,9 +32,8 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
    plane.img_p0_x = -aspect;
 | 
					    plane.img_p0_x = -aspect;
 | 
				
			||||||
    plane.img_p0_y = -1.f;
 | 
					    plane.img_p0_y = -1.f;
 | 
				
			||||||
    plane.img_p0_z = plane.base_z;
 | 
					    plane.img_p0_z = plane.base_z;
 | 
				
			||||||
    plane.img_p1_x = aspect;
 | 
					    plane.img_w = 2.f * aspect;
 | 
				
			||||||
    plane.img_p1_y = 1.f;
 | 
					    plane.img_h = 2.f;
 | 
				
			||||||
    plane.img_p1_z = plane.base_z;
 | 
					 | 
				
			||||||
    plane.img_ax0_x = 1.f;
 | 
					    plane.img_ax0_x = 1.f;
 | 
				
			||||||
    plane.img_ax0_y = 0.f;
 | 
					    plane.img_ax0_y = 0.f;
 | 
				
			||||||
    plane.img_ax0_z = 0.f;
 | 
					    plane.img_ax0_z = 0.f;
 | 
				
			||||||
@ -49,8 +48,7 @@ int main(int argc, char **argv) {
 | 
				
			|||||||
    df_trace_rays((df_trace_rays_settings){
 | 
					    df_trace_rays((df_trace_rays_settings){
 | 
				
			||||||
            .focal_length = 1.f,
 | 
					            .focal_length = 1.f,
 | 
				
			||||||
            .image_width = image_width,
 | 
					            .image_width = image_width,
 | 
				
			||||||
            .image_height = image_height
 | 
					            .image_height = image_height,
 | 
				
			||||||
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        spheres, 0,
 | 
					        spheres, 0,
 | 
				
			||||||
        &plane, 1,
 | 
					        &plane, 1,
 | 
				
			||||||
 | 
				
			|||||||
@ -64,9 +64,8 @@ typedef struct
 | 
				
			|||||||
    float img_p0_x;
 | 
					    float img_p0_x;
 | 
				
			||||||
    float img_p0_y;
 | 
					    float img_p0_y;
 | 
				
			||||||
    float img_p0_z;
 | 
					    float img_p0_z;
 | 
				
			||||||
    float img_p1_x;
 | 
					    float img_w;
 | 
				
			||||||
    float img_p1_y;
 | 
					    float img_h;
 | 
				
			||||||
    float img_p1_z; 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* TODO(Kevin): These could be calculated from p0 and p1... */
 | 
					    /* TODO(Kevin): These could be calculated from p0 and p1... */
 | 
				
			||||||
    float img_ax0_x;
 | 
					    float img_ax0_x;
 | 
				
			||||||
 | 
				
			|||||||
@ -224,11 +224,8 @@ static df_hit plane_test(float ray_origin_x,
 | 
				
			|||||||
                float img_p3_y = py - planes[i].img_p0_y;
 | 
					                float img_p3_y = py - planes[i].img_p0_y;
 | 
				
			||||||
                float img_p3_z = pz - planes[i].img_p0_z;
 | 
					                float img_p3_z = pz - planes[i].img_p0_z;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                /* FIXME(Kevin): We would need to take plane rotation into account.
 | 
					                float w = planes[i].img_w;
 | 
				
			||||||
                 * Alternatively, just pass w & h into the plane and let the user
 | 
					                float h = planes[i].img_h;
 | 
				
			||||||
                 * (i.e. higher level code) worry about that */
 | 
					 | 
				
			||||||
                float w = planes[i].img_p1_x - planes[i].img_p0_x;
 | 
					 | 
				
			||||||
                float h = planes[i].img_p1_y - planes[i].img_p0_y;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                result.img_u =
 | 
					                result.img_u =
 | 
				
			||||||
                    img_p3_x * planes[i].img_ax0_x + img_p3_y * planes[i].img_ax0_y + img_p3_z * planes[i].img_ax0_z;
 | 
					                    img_p3_x * planes[i].img_ax0_x + img_p3_y * planes[i].img_ax0_y + img_p3_z * planes[i].img_ax0_z;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user