This file is indexed.

/usr/src/castle-game-engine-4.1.1/3d/castletriangles_istrianglespherecollision.inc is in castle-game-engine-src 4.1.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
  Copyright 2003-2013 Michalis Kamburelis.

  This file is part of "Castle Game Engine".

  "Castle Game Engine" is free software; see the file COPYING.txt,
  included in this distribution, for details about the copyright.

  "Castle Game Engine" is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  ----------------------------------------------------------------------------
}

{ w zaleznosci od tego czy zdefiniowales HAS_PRECALC_PLANE
  to makro wygeneruje inna implementacje funkcji IsTriangleSphereCollision }
var intersection: TVector3;
    SphereRadiusSqr: TScalar;
    i: integer;
    {$ifndef HAS_PRECALC_PLANE} TriPlane: TVector4; {$endif}
    { pamietaj ze TriDir dla ifndef HAS_PRECALC_PLANE jest dobre dopiero
      po obliczeniu TriPlane }
    TriDir: TVector3 absolute TriPlane;
begin
 SphereRadiusSqr := Sqr(SphereRadius);
 if (PointsDistanceSqr(Tri[0], SphereCenter) <= SphereRadiusSqr) or
    (PointsDistanceSqr(Tri[1], SphereCenter) <= SphereRadiusSqr) or
    (PointsDistanceSqr(Tri[2], SphereCenter) <= SphereRadiusSqr) then exit(true);

 {$ifndef HAS_PRECALC_PLANE} TriPlane := TrianglePlane(Tri);{$endif}
 intersection := PointOnPlaneClosestToPoint(TriPlane, SphereCenter);
 if (PointsDistanceSqr(SphereCenter, intersection) <= SphereRadiusSqr) and
    IsPointOnTrianglePlaneWithinTriangle(intersection, Tri, TriDir) then
  exit(true);

 (* pozostaje nam sprawdzic czy moze punkt SphereCenter jest blisko jednego
    z bokow trojkata (ale nie musimy juz sprawdzac czy jest blisko jakiegos rogu;
    dzieki temu wystarczy ze obliczymy na kazdym boku trojkata punkt najblizszy
    SphereCenter i obliczymy odleglosc tego punktu od SphereCenter (powinna byc
    mniejsza niz SphereRadius)) *)
 for i := 0 to 2 do
 begin
  intersection := PointOnLineClosestToPoint(Tri[i],
    VectorSubtract(Tri[(i+1)mod 3], Tri[i]), SphereCenter);
  if IsPointOnSegmentLineWithinSegment(intersection, Tri[i], Tri[(i+1)mod 3]) and
     (PointsDistanceSqr(SphereCenter, intersection) <= SphereRadiusSqr) then
   exit(true);
 end;

 result := false;
end;