/usr/src/castle-game-engine-4.1.1/base/castlevectors_trysimpleplanexxxintersection.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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | {
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.
----------------------------------------------------------------------------
}
{ Ray ---------------------------------------------------------------------- }
{$define TrySimplePlaneRayIntersection_IMPLEMENT:=
var MaybeT: TScalar;
begin
result := not IsLineParallelToSimplePlane(RayDirection, PlaneConstCoord);
if result then
begin
MaybeT:=(PlaneConstValue-RayOrigin[PlaneConstCoord]) / RayDirection[PlaneConstCoord];
result := MaybeT >= 0;
if result then
begin
{$ifdef HAS_T}T := MaybeT;{$endif}
{$ifdef HAS_INTR}Intersection := VectorAdd(RayOrigin, VectorScale(RayDirection, MaybeT));{$endif}
end;
end;
end;}
function TrySimplePlaneRayIntersection(out Intersection: TVector3;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const RayOrigin, RayDirection: TVector3): boolean;
{$define HAS_INTR}
TrySimplePlaneRayIntersection_IMPLEMENT
{$undef HAS_INTR}
function TrySimplePlaneRayIntersection(
out Intersection: TVector3; out T: TScalar;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const RayOrigin, RayDirection: TVector3): boolean;
{$define HAS_INTR}
{$define HAS_T}
TrySimplePlaneRayIntersection_IMPLEMENT
{$undef HAS_T}
{$undef HAS_INTR}
function TrySimplePlaneRayIntersection(out T: TScalar;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const RayOrigin, RayDirection: TVector3): boolean;
{$define HAS_T}
TrySimplePlaneRayIntersection_IMPLEMENT
{$undef HAS_T}
{$undef TrySimplePlaneRayIntersection_IMPLEMENT}
{ SegmentDir ------------------------------------------------------------ }
{$define TrySimplePlaneSegmentDirIntersection_IMPLEMENT:=
var MaybeT: TScalar;
begin
result := not IsLineParallelToSimplePlane(SegmentVector, PlaneConstCoord);
if result then
begin
MaybeT:=(PlaneConstValue-Segment0[PlaneConstCoord]) / SegmentVector[PlaneConstCoord];
result:=(MaybeT >= 0) and (MaybeT <= 1);
if result then
begin
{$ifdef HAS_T}T := MaybeT;{$endif}
{$ifdef HAS_INTR}Intersection := VectorAdd(Segment0, VectorScale(SegmentVector, MaybeT));{$endif}
end;
end;
end;}
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const Segment0, SegmentVector: TVector3): boolean;
{$define HAS_INTR}
TrySimplePlaneSegmentDirIntersection_IMPLEMENT
{$undef HAS_INTR}
function TrySimplePlaneSegmentDirIntersection(var Intersection: TVector3; var T: TScalar;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const Segment0, SegmentVector: TVector3): boolean;
{$define HAS_INTR}
{$define HAS_T}
TrySimplePlaneSegmentDirIntersection_IMPLEMENT
{$undef HAS_T}
{$undef HAS_INTR}
function TrySimplePlaneSegmentDirIntersection(var T: TScalar;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const Segment0, SegmentVector: TVector3): boolean;
{$define HAS_T}
TrySimplePlaneSegmentDirIntersection_IMPLEMENT
{$undef HAS_T}
{$undef TrySimplePlaneSegmentDirIntersection_IMPLEMENT}
{ Segment ----------------------------------------------------------------- }
{$define TrySimplePlaneSegmentIntersection_IMPLEMENT:=
var MaybeT: TScalar;
Segment0: TVector3 absolute Pos1;
SegmentVector: TVector3;
begin
SegmentVector := VectorSubtract(Pos2, Pos1);
result := not IsLineParallelToSimplePlane(SegmentVector, PlaneConstCoord);
if result then
begin
MaybeT:=(PlaneConstValue-Segment0[PlaneConstCoord]) / SegmentVector[PlaneConstCoord];
result:=(MaybeT >= 0) and (MaybeT <= 1);
if result then
begin
{$ifdef HAS_T}T := MaybeT;{$endif}
{$ifdef HAS_INTR}Intersection := VectorAdd(Segment0, VectorScale(SegmentVector, MaybeT));{$endif}
end;
end;
end;}
function TrySimplePlaneSegmentIntersection(out Intersection: TVector3;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const Pos1, Pos2: TVector3): boolean;
{$define HAS_INTR}
TrySimplePlaneSegmentIntersection_IMPLEMENT
{$undef HAS_INTR}
function TrySimplePlaneSegmentIntersection(
out Intersection: TVector3; out T: TScalar;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const Pos1, Pos2: TVector3): boolean;
{$define HAS_INTR}
{$define HAS_T}
TrySimplePlaneSegmentIntersection_IMPLEMENT
{$undef HAS_T}
{$undef HAS_INTR}
function TrySimplePlaneSegmentIntersection(out T: TScalar;
const PlaneConstCoord: integer; const PlaneConstValue: TScalar;
const Pos1, Pos2: TVector3): boolean;
{$define HAS_T}
TrySimplePlaneSegmentIntersection_IMPLEMENT
{$undef HAS_T}
{$undef TrySimplePlaneSegmentIntersection_IMPLEMENT}
{ eof ------------------------------------------------------------ }
|