14 Commits

Author SHA1 Message Date
Jan Engelhardt
a7398dd65e Replace Zero_vector by vector{}
As far as the set of .cpp files which are using vecmat.h are
concerned, `Zero_vector` is out of reach for the compiler optimizer,
because it is extern / lives in a separate translation unit. An
expression like `x == Zero_vector` or `v = Zero_vector` thus has to
perform memory loads (for Zero_vector's x,y,z parts) before
comparison or copying, respectively. By using an immediate zero
vector `vector{}` instead, the unnecessary extra loads should go
away.

I present exhibit A:

```
void copyxx(vector *x) { *x = Zero_vector; }

4905e0: 48 8b 05 41 c0 56 00  movq 0x56c041(%rip),%rax  # 9fc628 <Zero_vector>
4905e7: 48 89 07              movq %rax,(%rdi)
4905ea: 8b 05 40 c0 56 00     movl 0x56c040(%rip),%eax  # 9fc630 <Zero_vector+0x8>
4905f0: 89 47 08              movl %eax,0x8(%rdi)
4905f3: c3                    ret
```

vs.

```
void copyxx(vector *x) { *x = vector{}; }

4905c0: 48 c7 07 00 00 00 00  movq $0x0,(%rdi)
4905c7: c7 47 08 00 00 00 00  movl $0x0,0x8(%rdi)
4905ce: c3                    ret
```
2025-06-03 12:01:17 +02:00
Jon Daniel
adda1c1f15 adaptive aligned std::array based vector types (#686) 2025-05-08 21:36:35 +02:00
Jan Engelhardt
48953868df build: resolve 101 instances of -Wunused-variable 2024-11-04 22:20:18 +01:00
Louis Gombert
705c67a1be Merge pull request #546 from winterheart/logging
Enhance logging facility
2024-09-10 09:27:13 +02:00
Azamat H. Hackimov
c32c2d3db3 Convert physics to use new logging facility 2024-09-10 03:00:25 +03:00
Jan Engelhardt
b7e3652c42 Rework fvi_room patch
In Retribution level 15, the cinematic animation would not start
playing when entering Dravis's room (after defating Hellion).

Fixes: cb5c2913b2
2024-09-08 17:57:06 +02:00
Jan Engelhardt
5f0bdf8184 Fix spello "it's" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
4d9ff9cdc6 Fix some one-off spellos 2024-09-03 13:26:51 +02:00
Jan Engelhardt
96c787bfb2 Fix spello "interative why" 2024-09-03 13:26:51 +02:00
Jan Engelhardt
b14470bbff Fix spello "independan.." 2024-09-03 13:26:51 +02:00
Louis Gombert
dd6e684712 Merge pull request #555 from jengelh/collide
Resolve out-of-bounds in PolyCollideObject [ASAN]
2024-09-02 21:03:32 +02:00
Jan Engelhardt
cb5c2913b2 Resolve out-of-bounds access in fvi_room
Possibly fixes #530.

physics/findintersection.cpp:4711:64: runtime error: index -1 out of bounds for type 'fvi_face_room_list [200]'
=================================================================
SIGNAL 11 caught, aborting
2024-08-31 11:21:09 +02:00
Jan Engelhardt
201b88c9aa Resolve out-of-bounds access in AIDoMemFrame
As level 1's in-engine cutscene runs, an OOB happens after about 3s.

x=0 object[x].type=4
x=1 object[x].type=18
x=2 object[x].type=255
$GIT/physics/findintersection.cpp:2196:80: runtime error: index 255 out of bounds for type 'unsigned char [26]'
$GIT/physics/findintersection.cpp:2196:80: runtime error: load of address 0x00000475a97f with insufficient space for an object of type 'uint8_t'
==28871==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000475a97f at pc 0x000001242275 bp 0x7fffc1ced720 sp 0x7fffc1ced718
READ of size 1 at 0x00000475a97f thread T0
    f0 fvi_QuickDistObjectList(vector*, int, float, short*, int, bool, bool, bool, bool) $GIT/physics/findintersection.cpp:2196
    f1 AIDoMemFrame $GIT/Descent3/AImain.cpp:6066
    f2 AIDoFrame(object*) $GIT/Descent3/AImain.cpp:6187
    f3 ObjDoFrame(object*) $GIT/Descent3/object.cpp:2674
    f4 ObjDoFrameAll() $GIT/Descent3/object.cpp:2988
    f5 GameFrame() $GIT/Descent3/GameLoop.cpp:2980
    f6 GameSequencer() $GIT/Descent3/gamesequence.cpp:1221
    f7 PlayGame() $GIT/Descent3/game.cpp:834
    f8 MainLoop() $GIT/Descent3/descent.cpp:555
    f9 Descent3() $GIT/Descent3/descent.cpp:508
    f10 oeD3LnxApp::run() $GIT/Descent3/sdlmain.cpp:151

0x00000475a97f is located 30 bytes after global variable 'FVI_always_check_ceiling' defined in '$GIT/physics/findintersection.cpp:888:6' (0x475a960) of size 1
  'FVI_always_check_ceiling' is ascii string ''
0x00000475a97f is located 33 bytes before global variable 'fvi_visit_list' defined in '$GIT/physics/findintersection.cpp:895:5' (0x475a9a0) of size 51
2024-08-30 02:37:15 +02:00
Azamat H. Hackimov
b9da6b59ff Isolate physics module
Update physics module, minor cleanups, remove unused code.
2024-07-28 16:50:42 +03:00