Paste will expire never.
- vec2 land_quad_size(
- math::aabbox_width( m_land_bbox ) / ( land_width - 1 ) ,
- math::aabbox_depth( m_land_bbox ) / ( land_height - 1 ) );
- for( unsigned int g = 0 ; g < grass_count ; g++ ) {
- vec3 & grass_pos = positions[ g ];
- vec2 offset_pos( grass_pos.x - m_land_bbox.min.x, grass_pos.z - m_land_bbox.min.z );
- unsigned int quad_offset_x = ( unsigned int )floor( offset_pos.x / land_quad_size.x );
- unsigned int quad_offset_y = ( unsigned int )floor( offset_pos.y / land_quad_size.y );
- unsigned int quad_index = ( quad_offset_y * ( land_width - 1 ) + quad_offset_x ) * 3 * 2;
- assert( quad_index < m_land_indices->size() );
- bool intersection;
- intersection = math::triangle_intersect_ray(
- vertices[ indices[ quad_index + 0 ] ],
- vertices[ indices[ quad_index + 1 ] ],
- vertices[ indices[ quad_index + 2 ] ],
- grass_pos,
- vec3( 0.f, 1.f, 0.f ),
- grass_pos );
- if( !intersection ) {
- intersection = math::triangle_intersect_ray(
- vertices[ indices[ quad_index + 3 ] ],
- vertices[ indices[ quad_index + 4 ] ],
- vertices[ indices[ quad_index + 5 ] ],
- grass_pos,
- vec3( 0.f, 1.f, 0.f ),
- grass_pos );
- assert( intersection );
- }
- }
Editing is locked.