summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2281a93)
raw | patch | inline | side by side (parent: 2281a93)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 20 Aug 2017 07:47:08 +0000 (10:47 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 20 Aug 2017 07:47:56 +0000 (10:47 +0300) |
src/game/g_map.pas | patch | blob | history | |
src/game/g_triggers.pas | patch | blob | history | |
src/game/z_aabbtree.pas | patch | blob | history | |
src/shared/conbuf.pas | patch | blob | history |
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index b79c972159203bd65018e370b88a54088893508e..f063f74081e5cf554b813bf9ea1a950283d4cd74 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
mapX1: Integer = -$3fffffff;
mapY1: Integer = -$3fffffff;
- procedure calcBoundingBox (var panels: TPanelArray);
+ procedure calcBoundingBox (constref panels: TPanelArray);
var
idx: Integer;
pan: TPanel;
end;
end;
- procedure addPanelsToGrid (var panels: TPanelArray; tag: Integer);
+ procedure addPanelsToGrid (constref panels: TPanelArray; tag: Integer);
var
idx: Integer;
pan: TPanel;
// old algo
procedure g_Map_DrawPanels (PanelType: Word);
- procedure DrawPanels (var panels: TPanelArray; drawDoors: Boolean=False);
+ procedure DrawPanels (constref panels: TPanelArray; drawDoors: Boolean=False);
var
idx: Integer;
begin
@@ -2101,7 +2101,7 @@ function g_Map_CollideLiquid_TextureOld(X, Y: Integer; Width, Height: Word): DWO
var
texid: DWORD;
- function checkPanels (var panels: TPanelArray): Boolean;
+ function checkPanels (constref panels: TPanelArray): Boolean;
var
a: Integer;
begin
index 29ea42ee3ddf3b1702d8a0569a4a490600ee6672..8fb459082acf0a7267aadf2e46efa42c02775478 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
dx := dx + Random(Data.ShotAccuracy) - Random(Data.ShotAccuracy);
dy := dy + Random(Data.ShotAccuracy) - Random(Data.ShotAccuracy);
-
+
tr_SpawnShot(Data.ShotType, wx, wy, dx, dy, Data.ShotSound, TargetUID);
end
else
index 996230d258244b9fed0818eca65ab2ecb3a3074a..298fa34f4775b23f2875ceb0789d261721bc37c4 100644 (file)
--- a/src/game/z_aabbtree.pas
+++ b/src/game/z_aabbtree.pas
public
constructor Create (ax, ay: Single; aangle: Single); overload;
constructor Create (ax0, ay0, ax1, ay1: Single); overload;
- constructor Create (var aray: Ray2D); overload;
+ constructor Create (constref aray: Ray2D); overload;
- procedure copyFrom (var aray: Ray2D); inline;
+ procedure copyFrom (constref aray: Ray2D); inline;
procedure normalizeDir (); inline;
public
constructor Create (x0, y0, x1, y1: TreeNumber); overload;
- constructor Create (var aabb: AABB2D); overload;
- constructor Create (var aabb0, aabb1: AABB2D); overload;
+ constructor Create (constref aabb: AABB2D); overload;
+ constructor Create (constref aabb0, aabb1: AABB2D); overload;
constructor CreateWH (ax, ay, w, h: TreeNumber);
- procedure copyFrom (var aabb: AABB2D); inline;
+ procedure copyFrom (constref aabb: AABB2D); inline;
procedure setDims (x0, y0, x1, y1: TreeNumber); inline;
- procedure setMergeTwo (var aabb0, aabb1: AABB2D); inline;
+ procedure setMergeTwo (constref aabb0, aabb1: AABB2D); inline;
function volume (): TreeNumber; inline;
- procedure merge (var aabb: AABB2D); inline;
+ procedure merge (constref aabb: AABB2D); inline;
// return true if the current AABB contains the AABB given in parameter
- function contains (var aabb: AABB2D): Boolean; inline; overload;
+ function contains (constref aabb: AABB2D): Boolean; inline; overload;
function contains (ax, ay: TreeNumber): Boolean; inline; overload;
// return true if the current AABB is overlapping with the AABB in parameter
// two AABBs overlap if they overlap in the two axes at the same time
- function overlaps (var aabb: AABB2D): Boolean; inline; overload;
+ function overlaps (constref aabb: AABB2D): Boolean; inline; overload;
// ray direction must be normalized
- function intersects (var ray: Ray2D; tmino: PSingle=nil; tmaxo: PSingle=nil): Boolean; overload;
+ function intersects (constref ray: Ray2D; tmino: PSingle=nil; tmaxo: PSingle=nil): Boolean; overload;
function intersects (ax, ay, bx, by: Single): Boolean; inline; overload;
property valid: Boolean read getvalid;
public
// return `true` to stop
- type TForEachLeafCB = function (abody: TTreeFlesh; var aabb: AABB2D): Boolean is nested; // WARNING! don't modify AABB here!
+ type TForEachLeafCB = function (abody: TTreeFlesh; constref aabb: AABB2D): Boolean is nested; // WARNING! don't modify AABB here!
public
// in the broad-phase collision detection (dynamic AABB tree), the AABBs are
procedure removeLeafNode (nodeId: Integer);
function balanceSubTreeAtNode (nodeId: Integer): Integer;
function computeHeight (nodeId: Integer): Integer;
- function insertObjectInternal (var aabb: AABB2D; staticObject: Boolean): Integer;
+ function insertObjectInternal (constref aabb: AABB2D; staticObject: Boolean): Integer;
procedure setup ();
- function visit (var caabb: AABB2D; mode: Integer; checker: TVisitCheckerCB; visitor: TQueryOverlapCB; visdg: TQueryOverlapDg; tagmask: Integer): Integer;
+ function visit (constref caabb: AABB2D; mode: Integer; checker: TVisitCheckerCB; visitor: TQueryOverlapCB; visdg: TQueryOverlapDg; tagmask: Integer): Integer;
function forEachNode (nodeId: Integer; dg: TForEachLeafCB): Boolean;
procedure reset ();
function forEachLeaf (dg: TForEachLeafCB): Boolean; // WARNING! don't modify AABB/tree here!
- procedure getRootAABB (var aabb: AABB2D);
+ procedure getRootAABB (out aabb: AABB2D);
function isValidId (id: Integer): Boolean; inline;
function getNodeObjectId (nodeid: Integer): TTreeFlesh; inline;
- procedure getNodeFatAABB (var aabb: AABB2D; nodeid: Integer); inline;
+ procedure getNodeFatAABB (out aabb: AABB2D; nodeid: Integer); inline;
// returns `false` if nodeid is not leaf
function getNodeXY (nodeid: Integer; out x, y: Integer): Boolean; inline;
function aabbQuery (ax, ay, aw, ah: TreeNumber; cb: TQueryOverlapCB; tagmask: Integer=-1): TTreeFlesh;
function pointQuery (ax, ay: TreeNumber; cb: TQueryOverlapCB; tagmask: Integer=-1): TTreeFlesh;
- function segmentQuery (var qr: TSegmentQueryResult; ax, ay, bx, by: TreeNumber; cb: TSegQueryCallback; tagmask: Integer=-1): Boolean;
+ function segmentQuery (out qr: TSegmentQueryResult; ax, ay, bx, by: TreeNumber; cb: TSegQueryCallback; tagmask: Integer=-1): Boolean;
function computeTreeHeight (): Integer; // compute the height of the tree
@@ -342,10 +342,10 @@ function dtMaxF (a, b: TreeNumber): TreeNumber; inline; begin if (a > b) then re
// ////////////////////////////////////////////////////////////////////////// //
constructor Ray2D.Create (ax, ay: Single; aangle: Single); begin setXYAngle(ax, ay, aangle); end;
constructor Ray2D.Create (ax0, ay0, ax1, ay1: Single); begin setX0Y0X1Y1(ax0, ay0, ax1, ay1); end;
-constructor Ray2D.Create (var aray: Ray2D); overload; begin copyFrom(aray); end;
+constructor Ray2D.Create (constref aray: Ray2D); overload; begin copyFrom(aray); end;
-procedure Ray2D.copyFrom (var aray: Ray2D); inline;
+procedure Ray2D.copyFrom (constref aray: Ray2D); inline;
begin
origX := aray.origX;
origY := aray.origY;
setDims(x0, y0, x1, y1);
end;
-constructor AABB2D.Create (var aabb: AABB2D); overload;
+constructor AABB2D.Create (constref aabb: AABB2D); overload;
begin
copyFrom(aabb);
end;
-constructor AABB2D.Create (var aabb0, aabb1: AABB2D); overload;
+constructor AABB2D.Create (constref aabb0, aabb1: AABB2D); overload;
begin
setMergeTwo(aabb0, aabb1);
end;
@@ -416,7 +416,7 @@ function AABB2D.getcenterY (): TreeNumber; inline; begin result := (minY+maxY) d
function AABB2D.getextentX (): TreeNumber; inline; begin result := maxX-minX+1; end;
function AABB2D.getextentY (): TreeNumber; inline; begin result := maxY-minY+1; end;
-procedure AABB2D.copyFrom (var aabb: AABB2D); inline;
+procedure AABB2D.copyFrom (constref aabb: AABB2D); inline;
begin
minX := aabb.minX;
minY := aabb.minY;
end;
-procedure AABB2D.setMergeTwo (var aabb0, aabb1: AABB2D); inline;
+procedure AABB2D.setMergeTwo (constref aabb0, aabb1: AABB2D); inline;
begin
{$IF DEFINED(D2F_DEBUG)}
if not aabb0.valid then raise Exception.Create('setMergeTwo: aabb0 is fucked');
end;
-procedure AABB2D.merge (var aabb: AABB2D); inline;
+procedure AABB2D.merge (constref aabb: AABB2D); inline;
begin
{$IF DEFINED(D2F_DEBUG)}
if not aabb.valid then raise Exception.Create('merge: aabb is fucked');
end;
-function AABB2D.contains (var aabb: AABB2D): Boolean; inline; overload;
+function AABB2D.contains (constref aabb: AABB2D): Boolean; inline; overload;
begin
result :=
(aabb.minX >= minX) and (aabb.minY >= minY) and
end;
-function AABB2D.overlaps (var aabb: AABB2D): Boolean; inline; overload;
+function AABB2D.overlaps (constref aabb: AABB2D): Boolean; inline; overload;
begin
result := false;
// exit with no intersection if found separated along any axis
// something to consider here is that 0 * inf =nan which occurs when the ray starts exactly on the edge of a box
// https://tavianator.com/fast-branchless-raybounding-box-intersections-part-2-nans/
-function AABB2D.intersects (var ray: Ray2D; tmino: PSingle=nil; tmaxo: PSingle=nil): Boolean; overload;
+function AABB2D.intersects (constref ray: Ray2D; tmino: PSingle=nil; tmaxo: PSingle=nil): Boolean; overload;
var
dinv, t1, t2, tmp: Single;
tmin, tmax: Single;
// internally add an object into the tree
-function TDynAABBTreeBase.insertObjectInternal (var aabb: AABB2D; staticObject: Boolean): Integer;
+function TDynAABBTreeBase.insertObjectInternal (constref aabb: AABB2D; staticObject: Boolean): Integer;
var
nodeId: Integer;
node: PTreeNode;
// return `true` from visitor to stop immediately
// checker should check if this node should be considered to further checking
// returns tree node if visitor says stop or -1
-function TDynAABBTreeBase.visit (var caabb: AABB2D; mode: Integer; checker: TVisitCheckerCB; visitor: TQueryOverlapCB; visdg: TQueryOverlapDg; tagmask: Integer): Integer;
+function TDynAABBTreeBase.visit (constref caabb: AABB2D; mode: Integer; checker: TVisitCheckerCB; visitor: TQueryOverlapCB; visdg: TQueryOverlapDg; tagmask: Integer): Integer;
var
stack: array [0..2048] of Integer; // stack with the nodes to visit
bigstack: array of Integer = nil;
@@ -1380,7 +1380,7 @@ function TDynAABBTreeBase.computeTreeHeight (): Integer; begin result := compute
// return the root AABB of the tree
-procedure TDynAABBTreeBase.getRootAABB (var aabb: AABB2D);
+procedure TDynAABBTreeBase.getRootAABB (out aabb: AABB2D);
begin
{$IFDEF aabbtree_many_asserts}assert((mRootNodeId >= 0) and (mRootNodeId < mAllocCount));{$ENDIF}
aabb := mNodes[mRootNodeId].aabb;
end;
// get fat object AABB by nodeid; returns random shit for invalid ids
-procedure TDynAABBTreeBase.getNodeFatAABB (var aabb: AABB2D; nodeid: Integer);
+procedure TDynAABBTreeBase.getNodeFatAABB (out aabb: AABB2D; nodeid: Integer);
begin
if (nodeid >= 0) and (nodeid < mAllocCount) and (not mNodes[nodeid].isfree) then aabb.copyFrom(mNodes[nodeid].aabb) else aabb.setDims(0, 0, 0, 0);
end;
// segment querying method
-function TDynAABBTreeBase.segmentQuery (var qr: TSegmentQueryResult; ax, ay, bx, by: TreeNumber; cb: TSegQueryCallback; tagmask: Integer=-1): Boolean;
+function TDynAABBTreeBase.segmentQuery (out qr: TSegmentQueryResult; ax, ay, bx, by: TreeNumber; cb: TSegQueryCallback; tagmask: Integer=-1): Boolean;
var
oldmaxFraction: Single;
oldcurax, oldcuray: Single;
diff --git a/src/shared/conbuf.pas b/src/shared/conbuf.pas
index 42f85a52b5ef161f9aa51edabbbd19da3f6d0055..4bb1bea0af8b0e8620f580785347a117bdb0c037 100644 (file)
--- a/src/shared/conbuf.pas
+++ b/src/shared/conbuf.pas
function cbufWalkStart (): LongWord;
function cbufWalkEnd (pos: LongWord): LongWord;
-procedure cbufPrev (var pos: LongWord);
-procedure cbufNext (var pos: LongWord);
+procedure cbufPrev (var pos: LongWord); inline;
+procedure cbufNext (var pos: LongWord); inline;
-function cbufAt (const pos: LongWord): Char;
+function cbufAt (const pos: LongWord): Char; inline;
// get last line
procedure cbufLastLine (var sp: LongWord; var ep: LongWord);
// warning! don't modify conbuf while the range is active!
function cbufWalkStart (): LongWord; begin result := cbuftail; end;
function cbufWalkEnd (pos: LongWord): LongWord; begin result := cbufhead; end;
-procedure cbufPrev (var pos: LongWord); begin pos := (pos+ConBufSize-1) mod ConBufSize; end;
-procedure cbufNext (var pos: LongWord); begin pos := (pos+1) mod ConBufSize; end;
+procedure cbufPrev (var pos: LongWord); inline; begin pos := (pos+ConBufSize-1) mod ConBufSize; end;
+procedure cbufNext (var pos: LongWord); inline; begin pos := (pos+1) mod ConBufSize; end;
-function cbufAt (const pos: LongWord): Char; begin result := cbuf[pos mod ConBufSize]; end;
+function cbufAt (const pos: LongWord): Char; inline; begin result := cbuf[pos mod ConBufSize]; end;
// ////////////////////////////////////////////////////////////////////////// //