Debian Codegraph @

src/physics/kraft/castlekraft.inc

raw
1 { Pascal defines that configure Kraft compilation. }
2
3 { -----------------------------------------------------------------------
4 Hide Kraft compilation messages we don't plan to fix }
5
6 {$ifdef FPC}
7 { CGE: Avoid FPC note: "nested procedures" not yet supported inside inline procedure/function
8 TODO: submit to Kraft. }
9 {$notes off}
10 {$else}
11 {$hints off}
12 {$warn SYMBOL_PLATFORM off}
13 {$endif}
14
15 { Tweak caninline ----------------------------------------------------------- }
16
17 { Workaround FPC 3.3.1 errors:
18
19 - Reproduced with revision 47824 compilation error, on Darwin (not recorded CPU).
20 - Reproduced also with FPC 3.3.1 revision 48998 with Android/Arm and Android/Aarrch64.
21
22 The errors mention invalid assembler syntax.
23 E.g. Android/Aarrch64 output:
24
25 kraft.s: Assembler messages:
26 kraft.s:86936: Error: operand mismatch -- `fadd d0,s0,s1'
27 kraft.s:86936: Info: did you mean this?
28 kraft.s:86936: Info: fadd s0,s0,s1
29 kraft.s:86936: Info: other valid variant(s):
30 kraft.s:86936: Info: fadd d0,d0,d1
31 kraft.s:86938: Error: operand mismatch -- `fadd d0,d0,s1'
32 kraft.s:86938: Info: did you mean this?
33 kraft.s:86938: Info: fadd d0,d0,d1
34 kraft.s:86938: Info: other valid variant(s):
35 kraft.s:86938: Info: fadd s0,s0,s1
36 kraft.pas(33101) Error: Error while assembling exitcode 1
37 }
38 {$if defined(FPC) and defined(VER3_3) and (defined(DARWIN) or defined(CPUARM) or defined(CPUAARCH64))}
39 {$undef caninline}
40 {$ifend}
41
42 { Tweak NonSIMD ----------------------------------------------------------- }
43
44 { CGE: Define NonSIMD. Without this symbol, Kraft uses some i386-only assembler,
45 that causes crashes (access violation at TRigidBody.SynchronizeFromKraft
46 when doing "FLinearVelocity := VectorFromKraft(FKraftBody.LinearVelocity)").
47 Testcase:
48
49 castle-engine --os=win32 --cpu=i386 compile --mode=debug
50 wine ./*.exe
51
52 on all physics examples it seems,
53
54 examples/physics/physics_2d_game_sopwith
55 examples/physics/physics_3d_game
56 examples/platformer
57
58 With at least FPC 3.2.0 (but did not check other FPC versions).
59 As this is an i386-specific optimization only (and our focus is on 64-bit platforms
60 as these are, and will be, majority) so disabling it is not a problem in practice
61 anyway. }
62 {$define NonSIMD}
63
64 { C++ Builder specifics ----------------------------------------------------------- }
65
66 { CGE: Make C++ Builder generated header of castletransform.hpp useful.
67
68 Otherwise, since Kraft is used in CastleTransform interface in Pascal,
69 and kraft.hpp is used in castletransform.hpp in C++,
70 and in effect we get "ambiguous symbol" warnings when trying to use Vector3
71 in CGE examples.
72
73 When using CGE, Kraft should not be accessed directly.
74 We use Kraft in CastleTransform interface to make it easy to define
75 CGE classes based on Kraft, though all their Kraft usage is private/internal. }
76 {$ifndef FPC}
77 {$NODEFINE Vector2}
78 {$NODEFINE Vector3}
79 {$NODEFINE Quaternion}
80 {$endif}