MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / GetFormFactorForElementSuperDetail

Function GetFormFactorForElementSuperDetail

editor/rad_cast.cpp:692–796  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

690}
691
692float GetFormFactorForElementSuperDetail(rad_surface *dest_surf, rad_element *dest_element) {
693 int touched = 0;
694 vector dest_center;
695 float ray_area;
696 int ignored = 0;
697 vector light_center;
698 vector patch_center;
699 float form_factor = 0.0;
700 int multiple_shoots = 0;
701
702 ray_area = rad_MaxElement->area;
703
704 if (rad_MaxElement->flags & EF_IGNORE)
705 return 0;
706
707 float rmax = GetMaxColor(&rad_MaxElement->exitance);
708
709 float temp_factor = 0.0;
710
711 GetCenterOfSurface(rad_MaxSurface, &patch_center);
712 GetCenterOfElement(rad_MaxElement, &light_center);
713 light_center += (rad_MaxSurface->normal / 16.0);
714
715 GetCenterOfElement(dest_element, &dest_center);
716 dest_center += (dest_surf->normal / 16.0);
717
718 int hit = 0;
719 vector ray = light_center - dest_center;
720 vector revray = dest_center - light_center;
721
722 if ((vm_DotProduct(&ray, &dest_surf->normal)) < 0)
723 return 0;
724 if ((vm_DotProduct(&revray, &rad_MaxSurface->normal)) < 0)
725 return 0;
726
727 // Check to see if this ray even matters
728 float ray_length = vm_GetMagnitudeFast(&ray);
729 vector dest_norm_ray = ray / ray_length;
730 vector src_norm_ray = -dest_norm_ray;
731 vector dest_normal = dest_surf->normal;
732 float ff;
733 vector src_normal = rad_MaxSurface->normal;
734 ff = (vm_DotProduct(&src_norm_ray, &src_normal) * vm_DotProduct(&dest_normal, &dest_norm_ray)) /
735 ((3.14 * ray_length * ray_length) + ray_area);
736 ff *= ray_area;
737 ff *= rmax;
738
739 // If shooting from elements, scale the test up
740 ff *= rad_MaxSurface->area / rad_MaxElement->area;
741
742 if (ff < Ignore_limit) {
743 Rays_ignored++;
744 return 0;
745 }
746
747 hit = ShootRayFromPoint(&light_center, &dest_center, rad_MaxSurface, dest_surf);
748
749 if (hit) {

Callers 1

Calls 7

GetMaxColorFunction · 0.85
GetCenterOfSurfaceFunction · 0.85
GetCenterOfElementFunction · 0.85
ShootRayFromPointFunction · 0.85
vm_DotProductFunction · 0.50
vm_GetMagnitudeFastFunction · 0.50
vm_GetMagnitudeFunction · 0.50

Tested by

no test coverage detected