頂点配列から重心・法線・AABB・代表長・collision grid を再構築する。
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_type), | intent(inout) | :: | mesh |
subroutine update_mesh_geometry(mesh) type(mesh_type), intent(inout) :: mesh integer(i32) :: i real(dp) :: e1(3), e2(3), nvec(3), nn real(dp) :: cx, cy, cz do i = 1, mesh%nelem cx = (mesh%v0(1, i) + mesh%v1(1, i) + mesh%v2(1, i))/3.0d0 cy = (mesh%v0(2, i) + mesh%v1(2, i) + mesh%v2(2, i))/3.0d0 cz = (mesh%v0(3, i) + mesh%v1(3, i) + mesh%v2(3, i))/3.0d0 mesh%centers(1, i) = cx mesh%centers(2, i) = cy mesh%centers(3, i) = cz mesh%center_x(i) = cx mesh%center_y(i) = cy mesh%center_z(i) = cz mesh%bb_min(:, i) = min(min(mesh%v0(:, i), mesh%v1(:, i)), mesh%v2(:, i)) mesh%bb_max(:, i) = max(max(mesh%v0(:, i), mesh%v1(:, i)), mesh%v2(:, i)) e1 = mesh%v1(:, i) - mesh%v0(:, i) e2 = mesh%v2(:, i) - mesh%v0(:, i) nvec = cross(e1, e2) nn = sqrt(sum(nvec*nvec)) if (nn > 0.0d0) then mesh%normals(:, i) = nvec/nn else mesh%normals(:, i) = 0.0d0 end if mesh%h_elem(i) = sqrt(0.5d0*nn) end do call build_collision_grid(mesh) end subroutine update_mesh_geometry