FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Source.Python/src/core/modules/physics/physics.cpp at master · srpg/Source.Python · GitHub
srpg
Source.Python
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Source.Python
/
src
/
core
/
modules
/
physics
/
physics.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
264 lines (190 loc) · 7.81 KB
Breadcrumbs
Source.Python
/
src
/
core
/
modules
/
physics
/
physics.cpp
Copy path
File metadata and controls
264 lines (190 loc) · 7.81 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*
*
* =============================================================================
* Source Python
* Copyright (C) 2012-2016 Source Python Development Team. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program 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. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, the Source Python Team gives you permission
* to link the code of this program (as well as its derivative works) to
* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, the Source.Python
* Development Team grants this exception to all derivative works.
*/
//
-----------------------------------------------------------------------------
//
Includes.
//
-----------------------------------------------------------------------------
//
Source.Python
#
include
"
utilities/conversions.h
"
#
include
"
physics.h
"
using
namespace
boost
::python
;
//
-----------------------------------------------------------------------------
//
IPhysicsObject
//
-----------------------------------------------------------------------------
bool
IPhysicsObjectWrapper::IsStatic
()
{
return
GetWrapped
()->
IsStatic
(); }
bool
IPhysicsObjectWrapper::IsAsleep
()
{
return
GetWrapped
()->
IsAsleep
(); }
bool
IPhysicsObjectWrapper::IsTrigger
()
{
return
GetWrapped
()->
IsTrigger
(); }
bool
IPhysicsObjectWrapper::IsFluid
()
{
return
GetWrapped
()->
IsFluid
(); }
bool
IPhysicsObjectWrapper::IsHinged
()
{
return
GetWrapped
()->
IsHinged
(); }
bool
IPhysicsObjectWrapper::IsCollisionEnabled
()
{
return
GetWrapped
()->
IsCollisionEnabled
(); }
bool
IPhysicsObjectWrapper::IsGravityEnabled
()
{
return
GetWrapped
()->
IsGravityEnabled
(); }
bool
IPhysicsObjectWrapper::IsDragEnabled
()
{
return
GetWrapped
()->
IsDragEnabled
(); }
bool
IPhysicsObjectWrapper::IsMotionEnabled
()
{
return
GetWrapped
()->
IsMotionEnabled
(); }
bool
IPhysicsObjectWrapper::IsMoveable
()
{
return
GetWrapped
()->
IsMoveable
(); }
bool
IPhysicsObjectWrapper::IsAttachedToConstraint
(
bool
external_only)
{
return
GetWrapped
()->
IsAttachedToConstraint
(external_only); }
void
IPhysicsObjectWrapper::EnableCollisions
(
bool
enable)
{
GetWrapped
()->
EnableCollisions
(enable); }
void
IPhysicsObjectWrapper::EnableGravity
(
bool
enable)
{
GetWrapped
()->
EnableGravity
(enable); }
void
IPhysicsObjectWrapper::EnableDrag
(
bool
enable)
{
GetWrapped
()->
EnableDrag
(enable); }
void
IPhysicsObjectWrapper::EnableMotion
(
bool
enable)
{
GetWrapped
()->
EnableMotion
(enable); }
void
IPhysicsObjectWrapper::EnableSleep
(
bool
enable)
{
if
(enable)
GetWrapped
()->
Sleep
();
else
GetWrapped
()->
Wake
();
}
void
*
IPhysicsObjectWrapper::GetGameData
()
{
return
GetWrapped
()->
GetGameData
(); }
void
IPhysicsObjectWrapper::SetGameData
(
void
* game_data)
{
GetWrapped
()->
SetGameData
(game_data); }
unsigned
short
IPhysicsObjectWrapper::GetGameFlags
()
{
return
GetWrapped
()->
GetGameFlags
(); }
void
IPhysicsObjectWrapper::SetGameFlags
(
unsigned
short
game_flags)
{
GetWrapped
()->
SetGameFlags
(game_flags); }
unsigned
short
IPhysicsObjectWrapper::GetGameIndex
()
{
return
GetWrapped
()->
GetGameIndex
(); }
void
IPhysicsObjectWrapper::SetGameIndex
(
unsigned
short
game_index)
{
GetWrapped
()->
SetGameIndex
(game_index); }
unsigned
short
IPhysicsObjectWrapper::GetCallbackFlags
()
{
return
GetWrapped
()->
GetCallbackFlags
(); }
void
IPhysicsObjectWrapper::SetCallbackFlags
(
unsigned
short
callback_flags)
{
GetWrapped
()->
SetCallbackFlags
(callback_flags); }
float
IPhysicsObjectWrapper::GetMass
()
{
return
GetWrapped
()->
GetMass
(); }
void
IPhysicsObjectWrapper::SetMass
(
float
mass)
{
GetWrapped
()->
SetMass
(mass); }
void
IPhysicsObjectWrapper::RecheckCollisionFilter
()
{
GetWrapped
()->
RecheckCollisionFilter
(); }
void
IPhysicsObjectWrapper::RecheckContactPoints
()
{
GetWrapped
()->
RecheckContactPoints
(); }
Vector
IPhysicsObjectWrapper::GetInertia
()
{
return
GetWrapped
()->
GetInertia
(); }
void
IPhysicsObjectWrapper::SetInertia
(Vector& inertia)
{
GetWrapped
()->
SetInertia
(inertia); }
int
IPhysicsObjectWrapper::GetMaterialIndex
()
{
return
GetWrapped
()->
GetMaterialIndex
(); }
void
IPhysicsObjectWrapper::SetMaterialIndex
(
int
index)
{
GetWrapped
()->
SetMaterialIndex
(index); }
unsigned
int
IPhysicsObjectWrapper::GetContents
()
{
return
GetWrapped
()->
GetContents
(); }
void
IPhysicsObjectWrapper::SetContents
(
unsigned
int
contents)
{
GetWrapped
()->
SetContents
(contents); }
float
IPhysicsObjectWrapper::GetSphereRadius
()
{
return
GetWrapped
()->
GetSphereRadius
(); }
float
IPhysicsObjectWrapper::GetEnergy
()
{
return
GetWrapped
()->
GetEnergy
(); }
Vector
IPhysicsObjectWrapper::GetMassCenterLocalSpace
()
{
return
GetWrapped
()->
GetMassCenterLocalSpace
(); }
tuple
IPhysicsObjectWrapper::GetPosition
()
{
Vector position;
QAngle angles;
GetWrapped
()->
GetPosition
(&position, &angles);
return
make_tuple
(position, angles);
}
void
IPhysicsObjectWrapper::SetPosition
(Vector& position, QAngle& angles,
bool
teleport)
{
GetWrapped
()->
SetPosition
(position, angles, teleport); }
tuple
IPhysicsObjectWrapper::GetVelocity
()
{
Vector velocity;
AngularImpulse angular_velocity;
GetWrapped
()->
GetVelocity
(&velocity, &angular_velocity);
return
make_tuple
(velocity, angular_velocity);
}
void
IPhysicsObjectWrapper::SetVelocity
(Vector* velocity, AngularImpulse* angular_velocity)
{
GetWrapped
()->
SetVelocity
(velocity, angular_velocity); }
void
IPhysicsObjectWrapper::SetVelocityInstantaneous
(Vector* velocity, AngularImpulse* angular_velocity)
{
GetWrapped
()->
SetVelocityInstantaneous
(velocity, angular_velocity); }
void
IPhysicsObjectWrapper::ApplyForceCenter
(Vector& vec)
{
GetWrapped
()->
ApplyForceCenter
(vec); }
const
char
*
IPhysicsObjectWrapper::GetName
()
{
return
GetWrapped
()->
GetName
(); }
void
IPhysicsObjectWrapper::OutputDebugInfo
()
{
GetWrapped
()->
OutputDebugInfo
(); }
//
-----------------------------------------------------------------------------
//
IPhysicsEnvironment
//
-----------------------------------------------------------------------------
Vector*
IPhysicsEnvironmentWrapper::GetGravity
()
{
Vector* result =
new
Vector;
GetWrapped
()->
GetGravity
(result);
return
result;
}
void
IPhysicsEnvironmentWrapper::SetGravity
(Vector& vec)
{
GetWrapped
()->
SetGravity
(vec);
}
void
IPhysicsEnvironmentWrapper::SetAirDensity
(
float
density)
{
GetWrapped
()->
SetAirDensity
(density);
}
float
IPhysicsEnvironmentWrapper::GetAirDensity
()
{
return
GetWrapped
()->
GetAirDensity
();
}
IPhysicsObjectWrapper*
IPhysicsEnvironmentWrapper::GetActiveObjectByIndex
(
int
index)
{
int
count =
GetWrapped
()->
GetActiveObjectCount
();
if
(count ==
0
)
return
NULL
;
IPhysicsObject** ppObjects =
new
IPhysicsObject*[count];
GetWrapped
()->
GetActiveObjects
(ppObjects);
for
(
int
i=
0
; i < count; ++i)
{
IPhysicsObject* current_object = ppObjects[i];
unsigned
int
current_index;
if
(!
IndexFromBaseEntity
((CBaseEntity*) current_object->
GetGameData
(), current_index))
continue
;
if
(current_index == index)
{
delete[]
ppObjects;
return
Wrap<IPhysicsObjectWrapper>(current_object);
}
}
delete[]
ppObjects;
return
NULL
;
}
//
-----------------------------------------------------------------------------
//
IPhysics
//
-----------------------------------------------------------------------------
IPhysicsEnvironmentWrapper*
IPhysicsWrapper::GetActiveEnvironmentByIndex
(
int
index)
{
return
Wrap<IPhysicsEnvironmentWrapper>(
GetWrapped
()->
GetActiveEnvironmentByIndex
(index));
}
Back
|
FazBrowse Home
|
New Git URL