moving more internal times from millisecs to microsecs

This commit is contained in:
Eric 2023-09-28 09:59:36 -07:00
parent 1d54e322ca
commit b826d045f0
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
14 changed files with 385 additions and 399 deletions

56
.efrocachemap generated
View File

@ -4056,26 +4056,26 @@
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "e0024dec8c31eb2d8fc95fbb0d4b47cd",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "e1dfb19f2053264fa045d7696c6b7ef8",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "e1cf045115903985e1c8b8e6d59edd2d",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "1c2a5985b68a94694d376a0670051f07",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "0674acbd2e095cdff7422fdd7479d557",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "76fa53a12c76b35100ed11ffeb5bff15",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "ebd75bcd5e6348574056ec959defb869",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "6c3f0158e6e44d07d7f2f67522f0dfc2",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "eef003a1e798496d906e28a0b97b9f1c",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "e5aa46e6ae5e8bcfad8865a419db9282",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "418f7a4363f8af90b0406f7742bf5d4d",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "f4eab84579e9e3d61bc5d43b22444b20",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "4d36fd6a3aa5fd896cf041e42004af6a",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "2453cd5c7fbf4897680616b465f4327c",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "9796c56ac684edfc0e94487940fd2170",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "d28dcfe794efa95fb7a32cbca77513aa",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "fa26ee4b0826d1273fe8cb8efb9026c5",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "950a618f5f10d5eb2f0de0bcbda24e3b",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "74f0c85552c377d751ad2238ccbbf6ae",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "ac4501fb1918202e1e3a8be75bde217b",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "ffaf93fda978f8d8855b1478215d083f",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "eb15777efa005cd1918dfe72bd251a2e",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "b0f9fa5d756729406cd033f408a5ba55",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "a323d1f530b6f84df1f3124cb9d7088b",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "e07abf32475dc72cc60bb29796dbc306",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "3d4a6f06eb9a714c9fe6d55cbe42262d",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "b74e814b14e38ab22bea0e5854086636",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "dc8de989859d88a10f138d512173292d",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "047a4ea01c6431dc49a761d2d06e9d90",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "9a5cd21b636ee436d5c05321a9a99f2b",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "4e9c476e0796d54dac0bc6571bdb1cae",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "64f23ab5c54d8eaaa0f2cc03dc3107ad",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "91bf11303d5c1d1369f98a1b972ee932",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "6629cb52ad1bbf62e25bf7f872788542",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "66dde4d3bec81f59344a4acef80ec465",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "75e7e50b7b35ab91d46c3692cb7e62d3",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "0f78c8a79e099e65b14dad33287ce513",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "dd62b63f16f7e3b0a0df24a0553ea993",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "e6932e574050c81926b7d78b6a8c30e9",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "e8383e509d1827e796af581eb6920458",
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "f3d305e647a7f77dd70a48f615cfd750",
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "931ce8eab9859d20ad86c47d196ba62c",
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "f3d305e647a7f77dd70a48f615cfd750",
@ -4092,14 +4092,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "097e17c460bf798edf61303789860596",
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "14df40bc07bdde8184843d16d5ba7798",
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "097e17c460bf798edf61303789860596",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "72c03bbb9007b347430bb2b8811cc258",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "e1507e2630f191c970f972a39c167fb8",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "b5008266d94788e17ca01722ce4a5515",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "d5df3b94bc7bf8cc50f75e587e03d308",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "ec7073a212061ba663a50222fd0d2fba",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "210f6d639f2820241f7d86168b82ddf8",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "8d57e179388d27c77b0b6d3276d0ced5",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "f3dc84fd4772d0107ec297852f17ef33",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "044195de59694aa90afb2db2a500c383",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "5669f2204fa5bf0bfac57c249dafc1d6",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "820b134e62b814066c40c9439587c945",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "76406fb75d1bc422accf3b8ad69d48e5",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "6b25bae7fd9eabaad90a2c3103bb6948",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "55bd741c876af2a7d9633dbc6a1bff45",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "188433602c168f76f83183b052852e43",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "1bf745b621bae741df16d9b604342e4b",
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
"src/assets/ba_data/python/babase/_mgen/enums.py": "f8cd3af311ac63147882590123b78318",
"src/ballistica/base/mgen/pyembed/binding_base.inc": "c81b2b1f3a14b4cd20a7b93416fe893a",

View File

@ -1,4 +1,4 @@
### 1.7.28 (build 21387, api 8, 2023-09-27)
### 1.7.28 (build 21391, api 8, 2023-09-28)
- Massively cleaned up code related to rendering and window systems (OpenGL,
SDL, etc). This code had been growing into a nasty tangle for 15 years

View File

@ -52,7 +52,7 @@ if TYPE_CHECKING:
# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 21387
TARGET_BALLISTICA_BUILD = 21391
TARGET_BALLISTICA_VERSION = '1.7.28'

View File

@ -206,7 +206,7 @@ auto Graphics::GraphicsQualityFromAppConfig() -> GraphicsQualityRequest {
void Graphics::SetGyroEnabled(bool enable) {
// If we're turning back on, suppress gyro updates for a bit.
if (enable && !gyro_enabled_) {
last_suppress_gyro_time_ = g_core->GetAppTimeMillisecs();
last_suppress_gyro_time_ = g_core->GetAppTimeMicrosecs();
}
gyro_enabled_ = enable;
}
@ -1013,9 +1013,12 @@ void Graphics::DrawLoadDot(RenderPass* pass) {
c.Submit();
}
void Graphics::UpdateGyro(millisecs_t real_time, millisecs_t elapsed) {
void Graphics::UpdateGyro(microsecs_t time_microsecs,
microsecs_t elapsed_microsecs) {
Vector3f tilt = gyro_vals_;
millisecs_t elapsed_millisecs = elapsed_microsecs / 1000;
// Our gyro vals get set from another thread and we don't use a lock,
// so perhaps there's a chance we get corrupted float values here?..
// Let's watch out for crazy vals just in case.
@ -1031,12 +1034,12 @@ void Graphics::UpdateGyro(millisecs_t real_time, millisecs_t elapsed) {
// Our math was calibrated for 60hz (16ms per frame);
// adjust for other framerates...
float timescale = static_cast<float>(elapsed) / 16.0f;
float timescale = static_cast<float>(elapsed_millisecs) / 16.0f;
// If we've recently been told to suppress the gyro, zero these.
// (prevents hitches when being restored, etc)
if (!gyro_enabled_ || camera_gyro_explicitly_disabled_
|| (real_time - last_suppress_gyro_time_ < 1000)) {
|| (time_microsecs - last_suppress_gyro_time_ < 1000000)) {
tilt = Vector3f{0.0, 0.0, 0.0};
}
@ -1114,25 +1117,25 @@ void Graphics::BuildAndPushFrameDef() {
// layer is fully bootstrapped.
BA_PRECONDITION_FATAL(g_base->logic->app_bootstrapping_complete());
millisecs_t app_time_millisecs = g_core->GetAppTimeMillisecs();
microsecs_t app_time_microsecs = g_core->GetAppTimeMicrosecs();
// Store how much time this frame_def represents.
auto display_time_millisecs =
static_cast<millisecs_t>(g_base->logic->display_time() * 1000.0);
millisecs_t elapsed = std::min(
millisecs_t{50}, display_time_millisecs - last_create_frame_def_time_);
last_create_frame_def_time_ = display_time_millisecs;
auto display_time_microsecs = g_base->logic->display_time_microsecs();
millisecs_t elapsed_microsecs = std::min(
millisecs_t{50000}, display_time_microsecs - last_create_frame_def_time_);
last_create_frame_def_time_ = display_time_microsecs;
// This probably should not be here. Though I guess we get the most
// up-to-date values possible this way. But it should probably live in
// g_input.
UpdateGyro(app_time_millisecs, elapsed);
UpdateGyro(app_time_microsecs, elapsed_microsecs);
FrameDef* frame_def = GetEmptyFrameDef();
frame_def->set_app_time_millisecs(app_time_millisecs);
frame_def->set_display_time_millisecs(
static_cast<millisecs_t>(g_base->logic->display_time() * 1000.0));
frame_def->set_display_time_elapsed_millisecs(elapsed);
frame_def->set_app_time_microsecs(app_time_microsecs);
frame_def->set_display_time_microsecs(
g_base->logic->display_time_microsecs());
frame_def->set_display_time_elapsed_microsecs(elapsed_microsecs);
frame_def->set_frame_number(frame_def_count_++);
if (!internal_components_inited_) {
@ -1151,7 +1154,7 @@ void Graphics::BuildAndPushFrameDef() {
if (progress_bar_) {
frame_def->set_needs_clear(true);
UpdateAndDrawProgressBar(frame_def, app_time_millisecs);
UpdateAndDrawProgressBar(frame_def);
} else {
// Ok, we're drawing a real frame.
@ -1183,7 +1186,7 @@ void Graphics::BuildAndPushFrameDef() {
c.Submit();
}
DrawFades(frame_def, app_time_millisecs);
DrawFades(frame_def);
// Sanity test: If we're in VR, the only reason we should have stuff in
// the flat overlay pass is if there's windows present (we want to avoid
@ -1313,8 +1316,7 @@ void Graphics::DrawDebugBuffers(RenderPass* pass) {
}
}
void Graphics::UpdateAndDrawProgressBar(FrameDef* frame_def,
millisecs_t real_time) {
void Graphics::UpdateAndDrawProgressBar(FrameDef* frame_def) {
RenderPass* pass = frame_def->overlay_pass();
UpdateProgressBarProgress(
1.0f
@ -1327,16 +1329,18 @@ void Graphics::UpdateAndDrawProgressBar(FrameDef* frame_def,
int count = g_base->assets->GetGraphicalPendingLoadCount();
if (count <= 0) {
progress_bar_ = false;
progress_bar_end_time_ = real_time;
progress_bar_end_time_ = frame_def->app_time_millisecs();
}
if (g_base->assets->GetPendingLoadCount() > 0) {
DrawLoadDot(pass);
}
}
void Graphics::DrawFades(FrameDef* frame_def, millisecs_t real_time) {
void Graphics::DrawFades(FrameDef* frame_def) {
RenderPass* overlay_pass = frame_def->overlay_pass();
millisecs_t real_time = frame_def->app_time_millisecs();
// Guard against accidental fades that never fade back in.
if (fade_ <= 0.0f && fade_out_) {
millisecs_t faded_time = real_time - (fade_start_ + fade_time_);
@ -1417,7 +1421,7 @@ void Graphics::DoDrawFade(FrameDef* frame_def, float amt) {
void Graphics::DrawCursor(FrameDef* frame_def) {
assert(g_base->InLogicThread());
millisecs_t real_time = frame_def->real_time();
millisecs_t app_time_millisecs = frame_def->app_time_millisecs();
bool can_show_cursor = g_core->platform->IsRunningOnDesktop();
bool should_show_cursor =
@ -1434,9 +1438,9 @@ void Graphics::DrawCursor(FrameDef* frame_def) {
// Ship this state when it changes and also every now and then just in
// case things go wonky.
if (new_cursor_visibility != hardware_cursor_visible_
|| real_time - last_cursor_visibility_event_time_ > 2000) {
|| app_time_millisecs - last_cursor_visibility_event_time_ > 2000) {
hardware_cursor_visible_ = new_cursor_visibility;
last_cursor_visibility_event_time_ = real_time;
last_cursor_visibility_event_time_ = app_time_millisecs;
g_base->app_adapter->PushMainThreadCall([this] {
assert(g_core && g_core->InMainThread());
g_base->platform->SetHardwareCursorVisible(hardware_cursor_visible_);

View File

@ -12,6 +12,7 @@
#include "ballistica/base/base.h"
#include "ballistica/shared/foundation/object.h"
#include "ballistica/shared/foundation/types.h"
#include "ballistica/shared/math/matrix44f.h"
#include "ballistica/shared/math/rect.h"
#include "ballistica/shared/math/vector2f.h"
@ -96,13 +97,13 @@ class Graphics {
// Called when the GraphicsServer has sent us a frame-def for deletion.
void ReturnCompletedFrameDef(FrameDef* frame_def);
auto screen_pixel_width() const -> float { return res_x_; }
auto screen_pixel_height() const -> float { return res_y_; }
auto screen_pixel_width() const { return res_x_; }
auto screen_pixel_height() const { return res_y_; }
// Return the size of the virtual screen. This value should always
// be used for interface positioning, etc.
auto screen_virtual_width() const -> float { return res_x_virtual_; }
auto screen_virtual_height() const -> float { return res_y_virtual_; }
auto screen_virtual_width() const { return res_x_virtual_; }
auto screen_virtual_height() const { return res_y_virtual_; }
void ClearScreenMessageTranslations();
@ -115,11 +116,11 @@ class Graphics {
// Print a message to the on-screen list.
void AddScreenMessage(const std::string& msg,
const Vector3f& color = Vector3f{1, 1, 1},
bool top = false, TextureAsset* texture = nullptr,
const Vector3f& color = {1, 1, 1}, bool top = false,
TextureAsset* texture = nullptr,
TextureAsset* tint_texture = nullptr,
const Vector3f& tint = Vector3f{1, 1, 1},
const Vector3f& tint2 = Vector3f{1, 1, 1});
const Vector3f& tint = {1, 1, 1},
const Vector3f& tint2 = {1, 1, 1});
// Fade the local screen in or out over the given time period.
void FadeScreen(bool to, millisecs_t time, PyObject* endcall);
@ -149,16 +150,16 @@ class Graphics {
// Enable progress bar drawing locally.
void EnableProgressBar(bool fade_in);
auto camera() -> Camera* { return camera_.Get(); }
auto* camera() { return camera_.Get(); }
void ToggleManualCamera();
void LocalCameraShake(float intensity);
void ToggleDebugDraw();
auto network_debug_info_display_enabled() const -> bool {
auto network_debug_info_display_enabled() const {
return network_debug_display_enabled_;
}
void ToggleNetworkDebugDisplay();
void SetGyroEnabled(bool enable);
auto floor_reflection() const -> bool {
auto floor_reflection() const {
assert(g_base->InLogicThread());
return floor_reflection_;
}
@ -179,7 +180,7 @@ class Graphics {
assert(g_base->InLogicThread());
shadow_ortho_ = o;
}
auto tint() -> const Vector3f& { return tint_; }
auto tint() const { return tint_; }
void set_tint(const Vector3f& val) {
assert(g_base->InLogicThread());
tint_ = val;
@ -197,31 +198,27 @@ class Graphics {
assert(g_base->InLogicThread());
vignette_inner_ = val;
}
auto shadow_offset() const -> const Vector3f& {
auto shadow_offset() const {
assert(g_base->InLogicThread());
return shadow_offset_;
}
auto shadow_scale() const -> const Vector2f& {
auto shadow_scale() const {
assert(g_base->InLogicThread());
return shadow_scale_;
}
auto tint() const -> const Vector3f& {
assert(g_base->InLogicThread());
return tint_;
}
auto ambient_color() const -> const Vector3f& {
auto ambient_color() {
assert(g_base->InLogicThread());
return ambient_color_;
}
auto vignette_outer() const -> const Vector3f& {
auto vignette_outer() const {
assert(g_base->InLogicThread());
return vignette_outer_;
}
auto vignette_inner() const -> const Vector3f& {
auto vignette_inner() const {
assert(g_base->InLogicThread());
return vignette_inner_;
}
auto shadow_ortho() const -> bool {
auto shadow_ortho() const {
assert(g_base->InLogicThread());
return shadow_ortho_;
}
@ -229,14 +226,14 @@ class Graphics {
float upper_top);
void ReleaseFadeEndCommand();
auto tv_border() const -> bool {
auto tv_border() const {
assert(g_base->InLogicThread());
return tv_border_;
}
// Nodes that draw flat stuff into the overlay pass should query this z value
// for where to draw in z.
auto overlay_node_z_depth() -> float {
auto overlay_node_z_depth() {
fetched_overlay_node_z_depth_ = true;
return overlay_node_z_depth_;
}
@ -250,8 +247,8 @@ class Graphics {
}
}
auto accel() const -> const Vector3f& { return accel_pos_; }
auto tilt() const -> const Vector3f& { return tilt_pos_; }
auto accel() const { return accel_pos_; }
auto tilt() const { return tilt_pos_; }
auto PixelToVirtualX(float x) const -> float {
if (tv_border_) {
@ -262,6 +259,7 @@ class Graphics {
}
return x * (res_x_virtual_ / res_x_);
}
auto PixelToVirtualY(float y) const -> float {
if (tv_border_) {
// In this case, 0 to 1 in physical coords maps to -0.05f to 1.05f in
@ -274,12 +272,12 @@ class Graphics {
// FIXME: This should probably move to Renderer or AppAdapter once we
// support switching renderers.
auto supports_high_quality_graphics() const -> bool {
auto supports_high_quality_graphics() const {
assert(has_supports_high_quality_graphics_value_);
return supports_high_quality_graphics_;
}
void SetSupportsHighQualityGraphics(bool s);
auto has_supports_high_quality_graphics_value() const -> bool {
auto has_supports_high_quality_graphics_value() const {
return has_supports_high_quality_graphics_value_;
}
@ -287,7 +285,7 @@ class Graphics {
internal_components_inited_ = val;
}
void set_gyro_vals(const Vector3f& vals) { gyro_vals_ = vals; }
auto show_net_info() const -> bool { return show_net_info_; }
auto show_net_info() const { return show_net_info_; }
void set_show_net_info(bool val) { show_net_info_ = val; }
auto GetDebugGraph(const std::string& name, bool smoothed) -> NetGraph*;
@ -297,9 +295,7 @@ class Graphics {
// For debugging: ensures that only transparent or opaque components
// are submitted while enabled.
auto drawing_transparent_only() const -> bool {
return drawing_transparent_only_;
}
auto drawing_transparent_only() const { return drawing_transparent_only_; }
void set_drawing_transparent_only(bool val) {
drawing_transparent_only_ = val;
}
@ -310,7 +306,7 @@ class Graphics {
/// Draw dev console or whatever else on top of normal stuff.
virtual void DrawDevUI(FrameDef* frame_def);
auto drawing_opaque_only() const -> bool { return drawing_opaque_only_; }
auto drawing_opaque_only() const { return drawing_opaque_only_; }
void set_drawing_opaque_only(bool val) { drawing_opaque_only_ = val; }
// Handle testing values from _baclassic.value_test()
@ -336,10 +332,10 @@ class Graphics {
void DrawBoxingGlovesTest(FrameDef* frame_def);
void DrawBlotches(FrameDef* frame_def);
void DrawCursor(FrameDef* frame_def);
void DrawFades(FrameDef* frame_def, millisecs_t real_time);
void DrawFades(FrameDef* frame_def);
void DrawDebugBuffers(RenderPass* pass);
void UpdateAndDrawProgressBar(FrameDef* frame_def, millisecs_t real_time);
void UpdateAndDrawProgressBar(FrameDef* frame_def);
void DoDrawBlotch(std::vector<uint16_t>* indices,
std::vector<VertexSprite>* verts, const Vector3f& pos,
float size, float r, float g, float b, float a);
@ -350,40 +346,55 @@ class Graphics {
void ClearFrameDefDeleteList();
void DrawProgressBar(RenderPass* pass, float opacity);
void UpdateProgressBarProgress(float target);
void UpdateGyro(millisecs_t real_time, millisecs_t elapsed);
void UpdateGyro(microsecs_t time, microsecs_t elapsed);
GraphicsQuality last_frame_def_graphics_quality_{GraphicsQuality::kUnset};
bool drawing_transparent_only_{};
bool drawing_opaque_only_{};
bool has_supports_high_quality_graphics_value_{};
bool supports_high_quality_graphics_{};
bool internal_components_inited_{};
bool fade_out_{true};
bool progress_bar_{};
bool progress_bar_fade_in_{};
bool debug_draw_{};
bool network_debug_display_enabled_{};
bool hardware_cursor_visible_{};
bool camera_shake_disabled_{};
bool camera_gyro_explicitly_disabled_{};
bool gyro_enabled_{true};
bool show_fps_{};
bool show_ping_{};
bool show_net_info_{};
bool tv_border_{};
bool floor_reflection_{};
bool building_frame_def_{};
bool shadow_ortho_{};
bool fetched_overlay_node_z_depth_{};
bool gyro_broken_{};
GraphicsQuality last_frame_def_graphics_quality_{GraphicsQuality::kUnset};
std::list<Object::Ref<PythonContextCall>> clean_frame_commands_;
std::vector<MeshData*> mesh_data_creates_;
std::vector<MeshData*> mesh_data_destroys_;
bool has_supports_high_quality_graphics_value_{};
bool supports_high_quality_graphics_{};
millisecs_t last_create_frame_def_time_{};
Vector3f shadow_offset_{0.0f, 0.0f, 0.0f};
Vector2f shadow_scale_{1.0f, 1.0f};
bool shadow_ortho_ = false;
Vector3f tint_{1.0f, 1.0f, 1.0f};
Vector3f ambient_color_{1.0f, 1.0f, 1.0f};
Vector3f vignette_outer_{0.0f, 0.0f, 0.0f};
Vector3f vignette_inner_{1.0f, 1.0f, 1.0f};
std::vector<FrameDef*> recycle_frame_defs_;
millisecs_t last_jitter_update_time_ = 0;
millisecs_t last_jitter_update_time_{};
Vector3f jitter_{0.0f, 0.0f, 0.0f};
Vector3f accel_smoothed_{0.0f, 0.0f, 0.0f};
Vector3f accel_smoothed2_{0.0f, 0.0f, 0.0f};
Vector3f accel_hi_pass_{0.0f, 0.0f, 0.0f};
Vector3f accel_vel_{0.0f, 0.0f, 0.0f};
Vector3f accel_pos_{0.0f, 0.0f, 0.0f};
Vector3f tilt_smoothed_ = {0.0f, 0.0f, 0.0f};
Vector3f tilt_smoothed_{0.0f, 0.0f, 0.0f};
Vector3f tilt_vel_{0.0f, 0.0f, 0.0f};
Vector3f tilt_pos_{0.0f, 0.0f, 0.0f};
bool gyro_broken_{};
float gyro_mag_test_{};
bool fetched_overlay_node_z_depth_{};
float overlay_node_z_depth_{};
bool internal_components_inited_{};
Object::Ref<ImageMesh> screen_mesh_;
Object::Ref<ImageMesh> progress_bar_bottom_mesh_;
Object::Ref<ImageMesh> progress_bar_top_mesh_;
@ -403,16 +414,9 @@ class Graphics {
std::vector<VertexSprite> blotch_soft_verts_;
std::vector<uint16_t> blotch_soft_obj_indices_;
std::vector<VertexSprite> blotch_soft_obj_verts_;
bool show_fps_{};
bool show_ping_{};
bool show_net_info_{};
bool tv_border_{};
bool floor_reflection_{};
std::map<std::string, Object::Ref<NetGraph>> debug_graphs_;
std::mutex frame_def_delete_list_mutex_;
std::vector<FrameDef*> frame_def_delete_list_;
bool debug_draw_{};
bool network_debug_display_enabled_{};
Object::Ref<Camera> camera_;
millisecs_t next_stat_update_time_{};
int last_total_frames_rendered_{};
@ -422,8 +426,6 @@ class Graphics {
bool set_fade_start_on_next_draw_{};
millisecs_t fade_start_{};
millisecs_t fade_time_{};
bool fade_out_{true};
Object::Ref<PythonContextCall> fade_end_call_;
float fade_{};
Vector3f gyro_vals_{0.0f, 0.0, 0.0f};
float res_x_{100};
@ -431,25 +433,19 @@ class Graphics {
float res_x_virtual_{100};
float res_y_virtual_{100};
int progress_bar_loads_{};
bool progress_bar_{};
bool progress_bar_fade_in_{};
millisecs_t progress_bar_end_time_{-9999};
float progress_bar_progress_{};
millisecs_t last_progress_bar_draw_time_{};
millisecs_t last_progress_bar_start_time_{};
float progress_bar_progress_{};
float screen_gamma_{1.0f};
float shadow_lower_bottom_{-4.0f};
float shadow_lower_top_{4.0f};
float shadow_upper_bottom_{30.0f};
float shadow_upper_top_{40.0f};
bool hardware_cursor_visible_{};
bool camera_shake_disabled_{};
bool camera_gyro_explicitly_disabled_{};
millisecs_t last_cursor_visibility_event_time_{};
int64_t frame_def_count_{1};
bool gyro_enabled_{true};
millisecs_t last_suppress_gyro_time_{};
int building_frame_def_{};
microsecs_t last_suppress_gyro_time_{};
Object::Ref<PythonContextCall> fade_end_call_;
};
} // namespace ballistica::base

View File

@ -742,11 +742,11 @@ void Renderer::UpdateDOFParams(FrameDef* frame_def) {
min_z = max_z = 0;
}
if ((frame_def->real_time() - dof_update_time_ > 100)) {
dof_update_time_ = frame_def->real_time() - 100;
if ((frame_def->app_time_millisecs() - dof_update_time_ > 100)) {
dof_update_time_ = frame_def->app_time_millisecs() - 100;
}
float smoothing = 0.995f;
while (dof_update_time_ < frame_def->real_time()) {
while (dof_update_time_ < frame_def->app_time_millisecs()) {
dof_update_time_++;
dof_near_smoothed_ =
smoothing * dof_near_smoothed_ + (1.0f - smoothing) * min_z;

View File

@ -49,9 +49,9 @@ auto FrameDef::GetOverlayFlatPass() -> RenderPass* {
void FrameDef::Reset() {
assert(g_base->InLogicThread());
app_time_millisecs_ = 0;
display_time_millisecs_ = 0;
display_time_elapsed_millisecs_ = 0;
app_time_microsecs_ = 0;
display_time_microsecs_ = 0;
display_time_elapsed_microsecs_ = 0;
frame_number_ = 0;
#if BA_DEBUG_BUILD

View File

@ -37,22 +37,37 @@ class FrameDef {
auto blit_pass() -> RenderPass* { return blit_pass_.get(); }
auto vr_cover_pass() -> RenderPass* { return vr_cover_pass_.get(); }
// Returns the real-time this frame_def originated at.
// For a more smoothly-incrementing value,
// use getbasetime()
auto real_time() const -> millisecs_t { return app_time_millisecs_; }
auto frame_number() const -> int64_t { return frame_number_; }
// Returns the bsGame master-net-time when this was made
// (tries to match real time but is incremented more smoothly
// so is better for drawing purposes)
auto display_time_millisecs() const -> millisecs_t {
return display_time_millisecs_;
// The app-time this frame_def originated at. For a more
// smoothly-incrementing value, use the frame-def's display_time.
auto app_time_millisecs() const -> millisecs_t {
return app_time_microsecs_ / 1000;
}
auto app_time_microsecs() const -> microsecs_t { return app_time_microsecs_; }
auto app_time() const -> double {
return static_cast<double>(app_time_microsecs_) / 1000000.0;
}
// How much base time does this frame-def represent.
// A number incremented for each frame renderered. Try to avoid using this
// for drawing flashes/etc. since framerates can vary a lot these days; a
// 30hz flash will look a lot different than a 240hz one.
auto frame_number() const -> int64_t { return frame_number_; }
// Returns the display-time this frame-def was created at (tries to match
// real time but is incremented more smoothly so is better for drawing
// purposes).
auto display_time_millisecs() const -> millisecs_t {
return display_time_microsecs_ / 1000;
}
auto display_time_microsecs() const -> microsecs_t {
return display_time_microsecs_;
}
auto display_time() const -> double {
return static_cast<double>(display_time_microsecs_) / 1000000.0;
}
// How much display time does this frame-def represent.
auto display_time_elapsed_millisecs() const -> millisecs_t {
return display_time_elapsed_millisecs_;
return display_time_elapsed_microsecs_ / 1000;
}
auto quality() const -> GraphicsQuality { return quality_; }
@ -109,12 +124,14 @@ class FrameDef {
void Reset();
void Finalize();
void set_display_time_elapsed_millisecs(millisecs_t val) {
display_time_elapsed_millisecs_ = val;
void set_display_time_elapsed_microsecs(microsecs_t val) {
display_time_elapsed_microsecs_ = val;
}
void set_app_time_millisecs(millisecs_t val) { app_time_millisecs_ = val; }
void set_display_time_millisecs(millisecs_t val) {
display_time_millisecs_ = val;
// void set_app_time_millisecs(millisecs_t val) { app_time_millisecs_ = val; }
void set_app_time_microsecs(microsecs_t val) { app_time_microsecs_ = val; }
void set_display_time_microsecs(microsecs_t val) {
display_time_microsecs_ = val;
}
void set_frame_number(int64_t val) { frame_number_ = val; }
@ -173,8 +190,11 @@ class FrameDef {
private:
bool needs_clear_{};
BenchmarkType benchmark_type_{BenchmarkType::kNone};
bool rendering_{};
bool orbiting_{};
bool tv_border_{};
bool shadow_ortho_{};
BenchmarkType benchmark_type_{BenchmarkType::kNone};
CameraMode camera_mode_{CameraMode::kFollow};
Vector3f cam_original_{0.0f, 0.0f, 0.0f};
Vector3f cam_target_original_{0.0f, 0.0f, 0.0f};
@ -210,15 +230,12 @@ class FrameDef {
std::unique_ptr<RenderPass> overlay_3d_pass_;
std::unique_ptr<RenderPass> blit_pass_;
GraphicsQuality quality_{GraphicsQuality::kLow};
bool orbiting_{};
bool tv_border_{};
millisecs_t app_time_millisecs_{};
millisecs_t display_time_millisecs_{};
millisecs_t display_time_elapsed_millisecs_{};
microsecs_t app_time_microsecs_{};
microsecs_t display_time_microsecs_{};
microsecs_t display_time_elapsed_microsecs_{};
int64_t frame_number_{};
Vector3f shadow_offset_{0.0f, 0.0f, 0.0f};
Vector2f shadow_scale_{1.0f, 1.0f};
bool shadow_ortho_{};
Vector3f tint_{1.0f, 1.0f, 1.0f};
Vector3f ambient_color_{1.0f, 1.0f, 1.0f};
Vector3f vignette_outer_{1.0f, 1.0f, 1.0f};

View File

@ -351,7 +351,7 @@ void TouchInput::UpdateDPad() {
void TouchInput::Draw(FrameDef* frame_def) {
assert(g_base->InLogicThread());
bool active = (!g_base->ui->MainMenuVisible());
millisecs_t real_time = frame_def->real_time();
millisecs_t real_time = frame_def->app_time_millisecs();
// Update our action center whenever possible in case screen is resized.
if (!buttons_touch_) {

View File

@ -755,7 +755,7 @@ void DevConsole::Draw(FrameDef* frame_def) {
if (input_text_dirty_) {
input_text_group_.SetText(input_string_);
input_text_dirty_ = false;
last_input_text_change_time_ = pass->frame_def()->real_time();
last_input_text_change_time_ = pass->frame_def()->app_time_millisecs();
}
{
SimpleComponent c(pass);
@ -808,7 +808,7 @@ void DevConsole::Draw(FrameDef* frame_def) {
}
// Carat.
millisecs_t real_time = pass->frame_def()->real_time();
millisecs_t real_time = pass->frame_def()->app_time_millisecs();
if (real_time % 200 < 100
|| (real_time - last_input_text_change_time_ < 100)) {
SimpleComponent c(pass);

View File

@ -30,7 +30,7 @@
namespace ballistica::scene_v1 {
// pull a random pointer from a ref-vector
// Pull a random pointer from a ref-vector.
template <class T>
auto GetRandomMedia(const std::vector<Object::Ref<T> >& list) -> T* {
if (list.empty()) return nullptr;
@ -223,7 +223,7 @@ struct JointFixedEF : public dxJoint {
bool angularEnabled;
};
static void _fixedInit(JointFixedEF* j) {
static void FixedInit_(JointFixedEF* j) {
dSetZero(j->qrel, 4);
dSetZero(j->anchor1, 3);
dSetZero(j->anchor2, 3);
@ -373,7 +373,7 @@ static void _fixedGetInfo2(JointFixedEF* joint, dxJoint::Info2* info) {
}
dxJoint::Vtable fixed_vtable_ = {
sizeof(JointFixedEF), (dxJoint::init_fn*)_fixedInit,
sizeof(JointFixedEF), (dxJoint::init_fn*)FixedInit_,
(dxJoint::getInfo1_fn*)_fixedGetInfo1,
(dxJoint::getInfo2_fn*)_fixedGetInfo2, dJointTypeNone};
@ -586,6 +586,7 @@ class SpazNodeType : public NodeType {
demo_mode(this),
behavior_version(this) {}
};
static NodeType* node_type{};
auto SpazNode::InitType() -> NodeType* {
@ -728,9 +729,8 @@ SpazNode::SpazNode(Scene* scene)
Stand(0, 0, 0, 0);
// Attach head to torso.
neck_joint_ = CreateFixedJoint(body_head_.Get(), body_torso_.Get(), 1000,
1, // linear stiff/damp
20.0f, 0.3f); // angular stiff/damp
neck_joint_ = CreateFixedJoint(body_head_.Get(), body_torso_.Get(), 1000, 1,
20.0f, 0.3f);
// Drop the y angular stiffness/damping on our neck so our head can whip
// left/right a bit easier move connection point up away from torso a bit.
@ -750,10 +750,8 @@ SpazNode::SpazNode(Scene* scene)
pelvis_joint_->anchor2[2] += 0.05f;
// Attach upper right arm to torso.
upper_right_arm_joint_ =
CreateFixedJoint(body_torso_.Get(), upper_right_arm_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
upper_right_arm_joint_ = CreateFixedJoint(
body_torso_.Get(), upper_right_arm_body_.Get(), 0, 0, 0, 0);
// Move anchor to top of arm.
upper_right_arm_joint_->anchor2[2] = -0.1f;
@ -762,17 +760,14 @@ SpazNode::SpazNode(Scene* scene)
upper_right_arm_joint_->anchor2[0] += 0.02f;
// Attach lower right arm to upper right arm.
lower_right_arm_joint_ = CreateFixedJoint(upper_right_arm_body_.Get(),
lower_right_arm_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
lower_right_arm_joint_ = CreateFixedJoint(
upper_right_arm_body_.Get(), lower_right_arm_body_.Get(), 0, 0, 0, 0);
lower_right_arm_joint_->anchor2[2] = -0.08f;
// Attach upper left arm to torso.
upper_left_arm_joint_ = CreateFixedJoint(
body_torso_.Get(), upper_left_arm_body_.Get(), 0, 0, // linear stiff/damp
0, 0); // Angular stiff/damp.
body_torso_.Get(), upper_left_arm_body_.Get(), 0, 0, 0, 0);
// Move anchor to top of arm.
upper_left_arm_joint_->anchor2[2] = -0.1f;
@ -781,34 +776,26 @@ SpazNode::SpazNode(Scene* scene)
upper_left_arm_joint_->anchor2[0] += -0.02f;
// Attach lower arm to upper arm.
lower_left_arm_joint_ = CreateFixedJoint(upper_left_arm_body_.Get(),
lower_left_arm_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
lower_left_arm_joint_ = CreateFixedJoint(
upper_left_arm_body_.Get(), lower_left_arm_body_.Get(), 0, 0, 0, 0);
lower_left_arm_joint_->anchor2[2] = -0.08f;
// Attach upper right leg to leg-mass.
upper_right_leg_joint_ =
CreateFixedJoint(body_pelvis_.Get(), upper_right_leg_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
upper_right_leg_joint_ = CreateFixedJoint(
body_pelvis_.Get(), upper_right_leg_body_.Get(), 0, 0, 0, 0);
upper_right_leg_joint_->anchor2[2] = -0.05f;
// Attach lower right leg to upper right leg.
lower_right_leg_joint_ = CreateFixedJoint(upper_right_leg_body_.Get(),
lower_right_leg_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
lower_right_leg_joint_ = CreateFixedJoint(
upper_right_leg_body_.Get(), lower_right_leg_body_.Get(), 0, 0, 0, 0);
lower_right_leg_joint_->anchor2[2] = -0.05f;
// Attach bottom of lower leg to pelvis.
right_leg_ik_joint_ =
CreateFixedJoint(body_pelvis_.Get(), lower_right_leg_body_.Get(), 0.3f,
0.001f, // linear stiff/damp
0, 0); // angular stiff/damp
right_leg_ik_joint_ = CreateFixedJoint(
body_pelvis_.Get(), lower_right_leg_body_.Get(), 0.3f, 0.001f, 0, 0);
dQFromAxisAndAngle(right_leg_ik_joint_->qrel, 1, 0, 0, 1.0f);
// Move the anchor to the tip of our leg.
@ -819,20 +806,16 @@ SpazNode::SpazNode(Scene* scene)
right_leg_ik_joint_->anchor1[2] = 0.0f;
// Attach toes to lower right foot.
right_toes_joint_ =
CreateFixedJoint(lower_right_leg_body_.Get(), right_toes_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
right_toes_joint_ = CreateFixedJoint(lower_right_leg_body_.Get(),
right_toes_body_.Get(), 0, 0, 0, 0);
right_toes_joint_->anchor1[1] += -0.0f;
right_toes_joint_->anchor2[1] += -0.04f;
// And an anchor off to the side to make it hinge-like.
right_toes_joint_2_ = nullptr;
right_toes_joint_2_ =
CreateFixedJoint(lower_right_leg_body_.Get(), right_toes_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
right_toes_joint_2_ = CreateFixedJoint(lower_right_leg_body_.Get(),
right_toes_body_.Get(), 0, 0, 0, 0);
right_toes_joint_2_->anchor1[1] += -0.0f;
right_toes_joint_2_->anchor2[1] += -0.04f;
@ -841,26 +824,20 @@ SpazNode::SpazNode(Scene* scene)
right_toes_joint_2_->anchor2[0] += -0.1f;
// Attach upper left leg to leg-mass.
upper_left_leg_joint_ =
CreateFixedJoint(body_pelvis_.Get(), upper_left_leg_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
upper_left_leg_joint_ = CreateFixedJoint(
body_pelvis_.Get(), upper_left_leg_body_.Get(), 0, 0, 0, 0);
upper_left_leg_joint_->anchor2[2] = -0.05f;
// Attach lower left leg to upper left leg.
lower_left_leg_joint_ = CreateFixedJoint(upper_left_leg_body_.Get(),
lower_left_leg_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
lower_left_leg_joint_ = CreateFixedJoint(
upper_left_leg_body_.Get(), lower_left_leg_body_.Get(), 0, 0, 0, 0);
lower_left_leg_joint_->anchor2[2] = -0.05f;
// Attach bottom of lower leg to pelvis.
left_leg_ik_joint_ =
CreateFixedJoint(body_pelvis_.Get(), lower_left_leg_body_.Get(), 0.3f,
0.001f, // linear stiff/damp
0, 0); // angular stiff/damp
left_leg_ik_joint_ = CreateFixedJoint(
body_pelvis_.Get(), lower_left_leg_body_.Get(), 0.3f, 0.001f, 0, 0);
dQFromAxisAndAngle(left_leg_ik_joint_->qrel, 1, 0, 0, 1.0f);
@ -872,20 +849,16 @@ SpazNode::SpazNode(Scene* scene)
left_leg_ik_joint_->anchor1[2] = 0.0f;
// Attach toes to lower left foot.
left_toes_joint_ =
CreateFixedJoint(lower_left_leg_body_.Get(), left_toes_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
left_toes_joint_ = CreateFixedJoint(lower_left_leg_body_.Get(),
left_toes_body_.Get(), 0, 0, 0, 0);
right_toes_joint_->anchor1[1] += -0.0f;
left_toes_joint_->anchor2[1] += -0.04f;
// And an anchor off to the side to make it hinge-like.
left_toes_joint_2_ = nullptr;
left_toes_joint_2_ =
CreateFixedJoint(lower_left_leg_body_.Get(), left_toes_body_.Get(), 0,
0, // linear stiff/damp
0, 0); // angular stiff/damp
left_toes_joint_2_ = CreateFixedJoint(lower_left_leg_body_.Get(),
left_toes_body_.Get(), 0, 0, 0, 0);
left_toes_joint_2_->anchor1[1] += -0.0f;
left_toes_joint_2_->anchor2[1] += -0.04f;
@ -895,19 +868,11 @@ SpazNode::SpazNode(Scene* scene)
// Attach end of right arm to torso.
right_arm_ik_joint_ =
CreateFixedJoint(body_torso_.Get(), lower_right_arm_body_.Get(), 0.0f,
0.0f, // linear stiff/damp
0, 0, // angular stiff/damp
-0.2f, -0.2f, 0.1f, // anchor1
0, 0, 0.07f, // anchor2
false);
0.0f, 0, 0, -0.2f, -0.2f, 0.1f, 0, 0, 0.07f, false);
left_arm_ik_joint_ =
CreateFixedJoint(body_torso_.Get(), lower_left_arm_body_.Get(), 0.0f,
0.0f, // linear stiff/damp
0, 0, // angular stiff/damp
0.2f, -0.2f, 0.1f, // anchor1
0.0f, 0.0f, 0.07f, // anchor2
false);
0.0f, 0, 0, 0.2f, -0.2f, 0.1f, 0.0f, 0.0f, 0.07f, false);
// Roller ball joint.
roller_ball_joint_ = CreateFixedJoint(body_torso_.Get(), body_roller_.Get(),
@ -948,16 +913,16 @@ SpazNode::SpazNode(Scene* scene)
dJointSetAMotorParam(a_motor_brakes_, dParamVel2, 0);
dJointSetAMotorParam(a_motor_brakes_, dParamVel3, 0);
// give joints initial vals
// Give joints initial vals.
UpdateJoints();
// FIXME should do this on draw
// FIXME: should do this on draw.
UpdateForGraphicsQuality(g_base->graphics_server->quality());
// we want to have an area of interest by default..
// We want to have an area of interest by default.
SetIsAreaOfInterest(true);
// we want to update each step
// We want to update each step.
BA_DEBUG_CHECK_BODIES();
}
@ -965,7 +930,7 @@ void SpazNode::SetPickupPressed(bool val) {
if (val == pickup_pressed_) return;
pickup_pressed_ = val;
// press
// Press
if (pickup_pressed_) {
if (frozen_ || knockout_) {
return;
@ -977,7 +942,7 @@ void SpazNode::SetPickupPressed(bool val) {
pickup_ = kPickupCooldown + 4;
}
} else {
// release
// Release
}
}
@ -1233,7 +1198,7 @@ void SpazNode::UpdateJoints() {
left_toes_joint_2_->angularStiffness = 0;
left_toes_joint_2_->angularDamping = 0;
// hair
// Hair
if (hair_front_right_joint_) {
hair_front_right_joint_->linearStiffness =
kHairFrontRightLinearStiffness * l_still_scale;
@ -1318,6 +1283,7 @@ static void AddObjectToList(dObject* obj, dObject** first) {
if (*first) (*first)->tome = &obj->next;
(*first) = obj;
}
static void JointInit(dxWorld* w, dxJoint* j) {
dIASSERT(w && j);
InitObject(j, w);
@ -1512,14 +1478,14 @@ void SpazNode::ApplyTorque(float x, float y, float z) {
dBodyAddTorque(body_roller_->body(), x, y, z);
}
// given coords within a (-1,-1) to (1,1) box,
// convert them such that their length is never greater than 1
// Given coords within a (-1,-1) to (1,1) box, convert them such that their
// length is never greater than 1.
static void BoxNormalizeToCircle(float* lr, float* ud) {
if (std::abs((*lr)) < 0.0001f || std::abs((*ud)) < 0.0001f) {
return; // not worth doing anything
return; // Not worth doing anything.
}
// project them out to hit the border
// Project them out to hit the border.
float s;
if (std::abs((*lr)) > std::abs((*ud))) {
s = 1.0f / std::abs((*lr));
@ -1561,8 +1527,8 @@ void SpazNode::Throw(bool with_bomb_button) {
}
}
// our throw can't actually start until we've held the thing
// for our min amount of time
// Our throw can't actually start until we've held the thing for our min
// amount of time.
float lrf = lr_smooth_;
float udf = ud_smooth_;
if (clamp_move_values_to_circle_) {
@ -1574,21 +1540,22 @@ void SpazNode::Throw(bool with_bomb_button) {
float scale = std::abs(sqrtf(lrf * lrf + udf * udf));
throw_power_ = 0.8f * (0.6f + 0.4f * scale);
// if we *just* picked it up, scale down our throw power slightly
// If we *just* picked it up, scale down our throw power slightly
// (otherwise we'll get an extra boost from the pick-up constraint and
// it'll fly farther than normal)
// it'll fly farther than normal).
auto since_pick_up = static_cast<float>(throw_start_ - last_pickup_time_);
if (since_pick_up < 500.0f) {
throw_power_ *= 0.4f + 0.6f * (since_pick_up / 500.0f);
}
// lock in our throw direction.. otherwise it smooths out
// to the axes with dpads and we lose our fuzzy in-between aiming
// Lock in our throw direction. Otherwise it smooths out to the axes
// with dpads and we lose our fuzzy in-between aiming.
throw_lr_ = lr_smooth_;
throw_ud_ = ud_smooth_;
// make ourself a note to drop the item as soon as possible with this power
// Make ourself a note to drop the item as soon as possible with this
// power.
throwing_ = true;
}
}
@ -1605,7 +1572,7 @@ void SpazNode::HandleMessage(const char* data_in) {
break;
}
case NodeMessageType::kPickedUp: {
// lets instantly lose our balance in this case...
// Let's instantly lose our balance in this case.
balance_ = 0;
break;
}
@ -1684,7 +1651,7 @@ void SpazNode::HandleMessage(const char* data_in) {
float force_dir_y = Utils::ExtractFloat16NBO(&data);
float force_dir_z = Utils::ExtractFloat16NBO(&data);
// area of affect impulses apply to everything..
// Area of affect impulses apply to everything.
if (radius > 0.0f) {
last_hit_was_punch_ = false;
float head_mag =
@ -1758,16 +1725,17 @@ void SpazNode::HandleMessage(const char* data_in) {
}
}
// store this in our damage attr so the user can know how much an impulse
// hurt us
// Store this in our damage attr so the user can know how much an impulse
// hurt us.
damage_out_ = dmg;
// also add it to our smoothed damage attr for things like body-explosions
// Also add it to our smoothed damage attr for things like
// body-explosions.
if (!calc_force_only) {
damage_smoothed_ += dmg;
}
// update knockout if we're applying this..
// Update knockout if we're applying this.
if (!calc_force_only) {
knockout_ = static_cast_check_fit<uint8_t>(
std::min(40, std::max(static_cast<int>(knockout_),
@ -1824,7 +1792,7 @@ void SpazNode::DoFlyPress() {
last_fly_time_ = scene()->time();
trying_to_fly_ = true;
// keep from doing too many sparkles..
// Keep from doing too many sparkles.
static millisecs_t last_sparkle_time = 0;
millisecs_t t = g_core->GetAppTimeMillisecs();
if (t - last_sparkle_time > 200) {
@ -1850,11 +1818,10 @@ void SpazNode::DoFlyPress() {
}
}
// void SpazNode::update(uint32_t flags) {
void SpazNode::Step() {
BA_DEBUG_CHECK_BODIES();
// update our body blending values
// Update our body blending values.
{
Object::Ref<RigidBody>* bodies[] = {&body_head_,
&body_torso_,
@ -1874,11 +1841,11 @@ void SpazNode::Step() {
&hair_front_right_body_,
&hair_front_left_body_,
&hair_ponytail_top_body_,
&hair_ponytail_bottom_body_,
nullptr};
&hair_ponytail_bottom_body_};
for (Object::Ref<RigidBody>** body = bodies; *body != nullptr; body++) {
if (RigidBody* bodyptr = (**body).Get()) {
// for (Object::Ref<RigidBody>** body = bodies; *body != nullptr; body++) {
for (auto* body : bodies) {
if (RigidBody* bodyptr = body->Get()) {
bodyptr->UpdateBlending();
}
}
@ -1891,14 +1858,16 @@ void SpazNode::Step() {
bool running_fast = false;
// if we're associated with a player, let the game know where that player is
// If we're associated with a player, let the game know where that player
// is.
// FIXME: this should simply be an attr connection established on the
// python layer...
// Python layer.
if (source_player_.Exists()) {
source_player_->SetPosition(Vector3f(p_torso));
}
// move our smoothed hurt value a short time after we get hit
// Move our smoothed hurt value a short time after we get hit.
if (scene()->time() - last_hurt_change_time_ > 400) {
if (hurt_smoothed_ < hurt_) {
hurt_smoothed_ = std::min(hurt_, hurt_smoothed_ + 0.03f);
@ -1907,12 +1876,12 @@ void SpazNode::Step() {
}
}
// update our smooth ud/lr vals
// Update our smooth ud/lr vals.
{
// lets use smoothing if all our input values are either -127, 0, or 127..
// that implies that we're getting non-analog input where smoothing is
// useful to have. (so that we can throw bombs in non-axis-aligned
// directions, etc)
// Let's use smoothing if all our input values are either -127, 0, or
// 127. That implies that we're getting non-analog input where
// smoothing is useful to have (so that we can throw bombs in
// non-axis-aligned directions, etc.).
float smoothing;
if ((ud_ == -127 || ud_ == 0 || ud_ == 127)
&& (lr_ == -127 || lr_ == 0 || lr_ == 127)) {
@ -1935,7 +1904,8 @@ void SpazNode::Step() {
* (hold_position_pressed_ ? 0.0f
: ((static_cast<float>(lr_) / 127.0f)));
}
// update our normalized values
// Update our normalized values.
{
float prev_ud = ud_norm_;
float prev_lr = lr_norm_;
@ -1953,7 +1923,7 @@ void SpazNode::Step() {
raw_lr_norm_ = this_lr_norm;
raw_ud_norm_ = this_ud_norm;
// determine if we're running..
// Determine if we're running.
running_ = ((run_ > 0.0f) && !hold_position_pressed_ && !holding_something_
&& !hockey_ && (std::abs(lr_) > 0 || std::abs(ud_) > 0)
&& (!have_thrown_ || (scene()->time() - throw_start_ > 200)));
@ -1975,14 +1945,15 @@ void SpazNode::Step() {
if (!footing_) run_gas_ = std::max(0.0f, run_gas_ - 0.05f);
// as we're running faster we simply filter our input values to prevent fast
// adjustments
// As we're running faster we simply filter our input values to prevent
// fast adjustments.
if (run_ > 0.05f) {
// strip out any component of the vector that is more than 90 degrees off
// of our current direction.. otherwise, extreme opposite directions will
// have a minimal effect on our actual run direction (a run dir blended
// with its 180-degree opposite then re-normalized won't really change)
// Strip out any component of the vector that is more than 90 degrees
// off of our current direction. Otherwise, extreme opposite
// directions will have a minimal effect on our actual run direction
// (a run dir blended with its 180-degree opposite then re-normalized
// won't really change).
{
dVector3 cur_dir = {ud_norm_, lr_norm_, 0};
dVector3 new_dir = {this_ud_norm, this_lr_norm, 0};
@ -1998,7 +1969,8 @@ void SpazNode::Step() {
float this_ud_norm_norm = this_ud_norm;
float this_lr_norm_norm = this_lr_norm;
{
// push our input towards a length of 1 if we're holding down the gas
// Push our input towards a length of 1 if we're holding down the
// gas.
orig_len = sqrtf(this_ud_norm_norm * this_ud_norm_norm
+ this_lr_norm_norm * this_lr_norm_norm);
target_len = run_gas_ * 1.0f + (1.0f - run_gas_) * orig_len;
@ -2011,37 +1983,40 @@ void SpazNode::Step() {
dVector3 v = {vel[0], vel[1], vel[2]};
float speed = dVector3Length(v);
// we use this later for looking angry and stuff..
if (speed >= 5.0f) running_fast = true;
// float smoothing = 0.97f;
// We use this later for looking angry and stuff.
if (speed >= 5.0f) {
running_fast = true;
}
float smoothing = 0.975f * (0.9f + 0.1f * run_gas_); // change for 120hz
if (speed < 2.0f) smoothing *= (speed / 2.0f);
float smoothing = 0.975f * (0.9f + 0.1f * run_gas_);
if (speed < 2.0f) {
smoothing *= (speed / 2.0f);
}
// blend it with previous results but then re-normalize
// (we want to prevent sudden direction changes but keep it
// full-speed-ahead)
// Blend it with previous results but then re-normalize (we want to
// prevent sudden direction changes but keep it full-speed-ahead).
ud_norm_ = smoothing * ud_norm_ + (1.0f - smoothing) * this_ud_norm_norm;
lr_norm_ = smoothing * lr_norm_ + (1.0f - smoothing) * this_lr_norm_norm;
// ..and renormalize
// ..and renormalize.
float new_len = sqrtf(ud_norm_ * ud_norm_ + lr_norm_ * lr_norm_);
float mult = new_len == 0.0f ? 1.0f : target_len / new_len;
ud_norm_ *= mult;
lr_norm_ *= mult;
} else {
// not running.. can save some calculations..
// Not running; can save some calculations.
ud_norm_ = this_ud_norm;
lr_norm_ = this_lr_norm;
}
// a sharper one for walking
// A sharper one for walking.
float smoothing_diff = 0.93f;
ud_diff_smooth_ = smoothing_diff * ud_diff_smooth_
+ (1.0f - smoothing_diff) * (ud_norm_ - prev_ud);
lr_diff_smooth_ = smoothing_diff * lr_diff_smooth_
+ (1.0f - smoothing_diff) * (lr_norm_ - prev_lr);
// a softer one for running
// A softer one for running.
float smoothering_diff = 0.983f;
ud_diff_smoother_ = smoothering_diff * ud_diff_smoother_
+ (1.0f - smoothering_diff) * (ud_norm_ - prev_ud);
@ -2051,7 +2026,7 @@ void SpazNode::Step() {
float vel_length;
// update smoothed avels and stuff
// Update smoothed avels and stuff.
{
float avel = dBodyGetAngularVel(body_torso_->body())[1];
float smoothing = 0.7f;
@ -2063,15 +2038,15 @@ void SpazNode::Step() {
float abs_a_vel = std::min(25.0f, std::abs(avel));
// angular punch momentum.. this goes up as we spin fast
// Angular punch momentum; this goes up as we spin fast.
punch_momentum_angular_d_ += abs_a_vel * 0.0004f;
punch_momentum_angular_d_ *=
0.965f; // so our up/down rate tops off at some point..
// so our up/down rate tops off at some point.
punch_momentum_angular_d_ *= 0.965f;
punch_momentum_angular_ += punch_momentum_angular_d_;
punch_momentum_angular_ *=
0.92f; // so our absolute val tops off at some point...
// So our absolute val tops off at some point.
punch_momentum_angular_ *= 0.92f;
// drop down fast if we're spinning slower than 10..
// Drop down fast if we're spinning slower than 10.
if (abs_a_vel < 5.0f) {
punch_momentum_angular_ *= 0.8f + 0.2f * (abs_a_vel / 5.0f);
}
@ -2080,9 +2055,9 @@ void SpazNode::Step() {
vel_length = sqrtf(vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2]);
punch_momentum_linear_d_ += vel_length * 0.004f;
punch_momentum_linear_d_ *= 0.95f; // suppress rate of upward change
punch_momentum_linear_d_ *= 0.95f; // Suppress rate of upward change.
punch_momentum_linear_ += punch_momentum_linear_d_;
punch_momentum_linear_ *= 0.96f; // suppress absolute value
punch_momentum_linear_ *= 0.96f; // Suppress absolute value.
if (vel_length < 5.0f) {
punch_momentum_linear_ *= 0.9f + 0.1f * (vel_length / 5.0f);
}
@ -3923,7 +3898,9 @@ void SpazNode::Step() {
}
}
if (flashing_ > 0) flashing_--;
if (flashing_ > 0) {
flashing_--;
}
if (jump_ > 0) {
// *always* reduce jump even if we're holding it.
@ -4895,7 +4872,8 @@ void SpazNode::Draw(base::FrameDef* frame_def) {
c.Submit();
}
}
// mini billboard 2
// Mini billboard 2.
if (scenetime < mini_billboard_2_end_time_ && !dead_) {
float amt = static_cast<float>(mini_billboard_2_end_time_ - scenetime)
/ static_cast<float>(mini_billboard_2_end_time_
@ -4905,8 +4883,6 @@ void SpazNode::Draw(base::FrameDef* frame_def) {
c.SetTransparent(true);
bool flash = (scenetime - mini_billboard_2_start_time_ < 200
&& render_frame_count % 6 < 3);
// if (!flash)
// c.SetTexture(mediaSet->GetTexture(mini_billboard_2_texture_));
if (!flash) {
c.SetTexture(mini_billboard_2_texture_.Exists()
? mini_billboard_2_texture_->texture_data()
@ -4921,7 +4897,8 @@ void SpazNode::Draw(base::FrameDef* frame_def) {
c.Submit();
}
}
// mini billboard 3
// Mini billboard 3.
if (scenetime < mini_billboard_3_end_time_ && !dead_) {
float amt = static_cast<float>(mini_billboard_3_end_time_ - scenetime)
/ static_cast<float>(mini_billboard_3_end_time_
@ -4947,9 +4924,9 @@ void SpazNode::Draw(base::FrameDef* frame_def) {
}
}
/// draw our counter
/// Draw our counter.
if (!counter_text_.empty() && !dead_) {
{ // icon
{ // Icon
base::SimpleComponent c(frame_def->overlay_3d_pass());
c.SetTransparent(true);
c.SetTexture(counter_texture_.Exists() ? counter_texture_->texture_data()
@ -4963,7 +4940,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) {
}
c.Submit();
}
{ // text
{ // Text
if (counter_mesh_text_ != counter_text_) {
counter_mesh_text_ = counter_text_;
counter_text_group_.SetText(counter_mesh_text_);
@ -4990,7 +4967,7 @@ void SpazNode::Draw(base::FrameDef* frame_def) {
}
}
// draw our name
// Draw our name.
if (!name_.empty()) {
auto age = static_cast<float>(scenetime - birth_time_);
if (explicit_bool(true)) {
@ -5459,22 +5436,22 @@ auto SpazNode::IsBrokenBodyPart(int id) -> bool {
}
auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
RigidBody* opposingbody) -> bool {
RigidBody* opposing_body) -> bool {
assert(colliding_body->part()->node() == this);
if (opposingbody->part()->node() == this) {
if (opposing_body->part()->node() == this) {
// If self-collide has gone down to zero we can just skip this completely.
// if (!frozen_ and limb_self_collide_ < 0.01f) return false;
int ourID = colliding_body->id();
int theirID = opposingbody->id();
int our_id = colliding_body->id();
int their_id = opposing_body->id();
// Special case - if we're a broken off bodypart, collide with anything.
if (shattered_ && IsBrokenBodyPart(ourID)) {
if (shattered_ && IsBrokenBodyPart(our_id)) {
return true;
}
// Get nitpicky with our self-collisions.
switch (ourID) {
switch (our_id) {
case kHeadBodyID:
case kTorsoBodyID:
// Head and torso will collide with anyone who wants to
@ -5484,7 +5461,7 @@ auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
case kLowerLeftArmBodyID:
// Lower arms collide with head, torso, and upper legs
// and upper arms if shattered.
switch (theirID) {
switch (their_id) {
case kHeadBodyID:
case kTorsoBodyID:
case kUpperLeftLegBodyID:
@ -5495,7 +5472,7 @@ auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
break;
case kLowerRightArmBodyID:
// Lower arms collide with head, torso, and upper legs.
switch (theirID) {
switch (their_id) {
case kHeadBodyID:
case kTorsoBodyID:
case kUpperRightLegBodyID:
@ -5512,7 +5489,7 @@ auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
break;
case kUpperLeftLegBodyID:
// Collide with lower arm.
switch (theirID) { // NOLINT
switch (their_id) { // NOLINT
case kLowerLeftArmBodyID:
return true;
default:
@ -5521,7 +5498,7 @@ auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
break;
case kUpperRightLegBodyID:
// collide with lower arm
switch (theirID) { // NOLINT
switch (their_id) { // NOLINT
case kLowerRightArmBodyID:
return true;
default:
@ -5530,7 +5507,7 @@ auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
break;
case kLowerLeftLegBodyID:
// collide with opposite lower leg
switch (theirID) { // NOLINT
switch (their_id) { // NOLINT
case kLowerRightLegBodyID:
return true;
default:
@ -5539,7 +5516,7 @@ auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
break;
case kLowerRightLegBodyID:
// lower right leg collides with lower left leg
switch (theirID) { // NOLINT
switch (their_id) { // NOLINT
case kLowerLeftLegBodyID:
return true;
default:
@ -5557,7 +5534,7 @@ auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
// We ignore bumpers if we're injured, frozen, or if a non-roller-ball part
// of us is hitting it.
{
uint32_t f = opposingbody->flags();
uint32_t f = opposing_body->flags();
if (f & RigidBody::kIsBumper) {
if ((knockout_) || (frozen_) || (balance_ < 50)
|| colliding_body->part() != &roller_part_)
@ -5568,14 +5545,16 @@ auto SpazNode::PreFilterCollision(RigidBody* colliding_body,
if (colliding_body->id() == kRollerBodyID) {
// Never collide against shrunken roller-ball.
if (ball_size_ <= 0.0f) return false;
if (ball_size_ <= 0.0f) {
return false;
}
}
return true;
}
auto SpazNode::CollideCallback(dContact* c, int count,
RigidBody* colliding_body,
RigidBody* opposingbody) -> bool {
RigidBody* opposing_body) -> bool {
// Keep track of whether our toes are touching something besides us
// if (colliding_body == left_toes_body_.Get() and opposingbody->getNode() !=
// this) _toesTouchingL = true; if (colliding_body == right_toes_body_.Get()
@ -5586,12 +5565,12 @@ auto SpazNode::CollideCallback(dContact* c, int count,
// hair collide with most anything but weakly..
if (colliding_body->part() == &hair_part_
|| opposingbody->part() == &hair_part_) {
|| opposing_body->part() == &hair_part_) {
// Hair doesnt collide with hair.
if (colliding_body->part() == opposingbody->part()) return false;
if (colliding_body->part() == opposing_body->part()) return false;
// ignore bumpers..
if (opposingbody->flags() & RigidBody::kIsBumper) return false;
if (opposing_body->flags() & RigidBody::kIsBumper) return false;
// drop stiffness/damping/friction pretty low..
float stiffness = 200.0f;
@ -5643,7 +5622,7 @@ auto SpazNode::CollideCallback(dContact* c, int count,
// If we're hitting ourself, drop all forces based on our self-collide
// level.
if (opposingbody->part()->node() == this && !frozen_) {
if (opposing_body->part()->node() == this && !frozen_) {
for (int i = 0; i < count; i++) {
c[i].surface.mu = 0.0f;
}
@ -5711,7 +5690,7 @@ auto SpazNode::CollideCallback(dContact* c, int count,
// For non-bumper collisions, drop collision forces on the side.
// (we want more friction on the bottom of our roller ball than on the
// sides).
uint32_t f = opposingbody->flags();
uint32_t f = opposing_body->flags();
if (!(f & RigidBody::kIsBumper)) {
for (int i = 0; i < count; i++) {
// Let's use world-down instead.
@ -5731,7 +5710,7 @@ auto SpazNode::CollideCallback(dContact* c, int count,
c[i].geom.normal[1] * 100.0f,
c[i].geom.normal[2] * 100.0f);
}
#if 1
// Override stiffness and damping on our little parts
float stiffness = 800.0f;
float damping = 0.001f;
@ -5740,7 +5719,7 @@ auto SpazNode::CollideCallback(dContact* c, int count,
c[i].surface.soft_erp = erp;
c[i].surface.soft_cfm = cfm;
c[i].surface.mu = 0.0f;
#endif
} else {
// trying to get a well-behaved floor-response...
if (!hockey_) {
@ -5764,8 +5743,9 @@ auto SpazNode::CollideCallback(dContact* c, int count,
// Keep track of when stuff is hitting our head, so we know when to calc
// damage from head whiplash.
if (colliding_body == body_head_.Get() && opposingbody->part()->node() != this
&& opposingbody->can_cause_impact_damage()) {
if (colliding_body == body_head_.Get()
&& opposing_body->part()->node() != this
&& opposing_body->can_cause_impact_damage()) {
last_head_collide_time_ = scene()->time();
}
@ -6060,12 +6040,9 @@ void SpazNode::CreateHair() {
hair_front_right_body_->AddCallback(StaticCollideCallback, this);
hair_front_right_body_->SetDimensions(0.07f, 0.13f, 0, 0, 0, 0, 0.01f);
hair_front_right_joint_ = CreateFixedJoint(
body_head_.Get(), hair_front_right_body_.Get(), 0, 0, // lin stiff/damp
0, 0, // ang stiff/damp
-0.17f, 0.19f, 0.18f, // b1 anchor
0, -0.08f, -0.12f // b2 anchor
); // NOLINT (whitespace/parens)
hair_front_right_joint_ =
CreateFixedJoint(body_head_.Get(), hair_front_right_body_.Get(), 0, 0, 0,
0, -0.17f, 0.19f, 0.18f, 0, -0.08f, -0.12f);
// Rotate it right a bit.
dQFromAxisAndAngle(hair_front_right_joint_->qrel, 0, 1, 0, -1.1f);
@ -6078,12 +6055,9 @@ void SpazNode::CreateHair() {
hair_front_left_body_->AddCallback(StaticCollideCallback, this);
hair_front_left_body_->SetDimensions(0.04f, 0.13f, 0, 0.07f, 0.13f, 0, 0.01f);
hair_front_left_joint_ = CreateFixedJoint(
body_head_.Get(), hair_front_left_body_.Get(), 0, 0, // lin stiff/damp
0, 0, // ang stiff/damp
0.13f, 0.11f, 0.13f, // b1 anchor
0, -0.08f, -0.12f // b2 anchor
); // NOLINT (whitespace/parens)
hair_front_left_joint_ =
CreateFixedJoint(body_head_.Get(), hair_front_left_body_.Get(), 0, 0, 0,
0, 0.13f, 0.11f, 0.13f, 0, -0.08f, -0.12f);
// Rotate it left a bit.
dQFromAxisAndAngle(hair_front_left_joint_->qrel, 0, 1, 0, 1.1f);
@ -6096,12 +6070,9 @@ void SpazNode::CreateHair() {
hair_ponytail_top_body_->AddCallback(StaticCollideCallback, this);
hair_ponytail_top_body_->SetDimensions(0.09f, 0.1f, 0, 0, 0, 0, 0.01f);
hair_ponytail_top_joint_ = CreateFixedJoint(
body_head_.Get(), hair_ponytail_top_body_.Get(), 0, 0, // lin stiff/damp
0, 0, // ang stiff/damp
0, 0.3f, -0.21f, // b1 anchor
0, -0.01f, 0.1f // b2 anchor
); // NOLINT (whitespace/parens)
hair_ponytail_top_joint_ =
CreateFixedJoint(body_head_.Get(), hair_ponytail_top_body_.Get(), 0, 0, 0,
0, 0, 0.3f, -0.21f, 0, -0.01f, 0.1f);
// rotate it up a bit..
dQFromAxisAndAngle(hair_ponytail_top_joint_->qrel, 1, 0, 0, 1.1f);
@ -6114,12 +6085,8 @@ void SpazNode::CreateHair() {
hair_ponytail_bottom_body_->SetDimensions(0.09f, 0.13f, 0, 0, 0, 0, 0.01f);
hair_ponytail_bottom_joint_ = CreateFixedJoint(
hair_ponytail_top_body_.Get(), hair_ponytail_bottom_body_.Get(), 0,
0, // lin stiff/damp
0, 0, // ang stiff/damp
0, 0.01f, -0.1f, // b1 anchor
0, -0.01f, 0.12f // b2 anchor
); // NOLINT (whitespace/parens)
hair_ponytail_top_body_.Get(), hair_ponytail_bottom_body_.Get(), 0, 0, 0,
0, 0, 0.01f, -0.1f, 0, -0.01f, 0.12f);
// Set joint values.
UpdateJoints();
@ -6204,8 +6171,8 @@ void SpazNode::SetColor(const std::vector<float>& vals) {
}
color_ = vals;
// If this gets changed, make sure to change shadow-color in the constructor
// to match.
// If this gets changed, make sure to change shadow-color in the
// constructor to match.
assert(shadow_color_.size() == 3);
shadow_color_[0] = color_[0] * 0.5f;
shadow_color_[1] = color_[1] * 0.5f;
@ -6228,8 +6195,8 @@ void SpazNode::SetFrozen(bool val) {
dBodyEnable(body_head_->body());
}
// Mark the time when we're newly frozen. We don't
// shatter based on impulse for a short time thereafter.
// Mark the time when we're newly frozen. We don't shatter based on
// impulse for a short time thereafter.
last_shatter_test_time_ = scene()->time();
UpdateJoints();
}
@ -6691,8 +6658,8 @@ auto SpazNode::GetPunchMomentumLinear() const -> std::vector<float> {
}
std::vector<float> vals(3);
// our linear punch momentum is our base velocity with punchmomentumlinear as
// magnitude
// Our linear punch momentum is our base velocity with punchmomentumlinear
// as magnitude.
const dReal* vel = dBodyGetLinearVel(body_torso_->body());
float vel_mag = sqrtf(vel[0] * vel[0] + vel[1] * vel[1] + vel[2] * vel[2]);
if (vel_mag < 0.01f) {
@ -6725,13 +6692,13 @@ auto SpazNode::GetPosition() const -> std::vector<float> {
}
void SpazNode::SetHoldNode(Node* val) {
// they passed a node
// They passed a node.
if (val != nullptr) {
Node* a = val;
assert(a);
RigidBody* b = a->GetRigidBody(hold_body_);
if (!b) {
// print some debugging info on the active collision..
// Print some debugging info on the active collision.
{
Dynamics* dynamics = scene()->dynamics();
assert(dynamics);
@ -6807,7 +6774,8 @@ void SpazNode::SetHoldNode(Node* val) {
hold_hand_offset_right_,
hold_hand_offset_left_);
// hand locations are relative to object pickup location.. add that in
// Hand locations are relative to object pickup location.. add that
// in.
hold_hand_offset_right_[0] += hold_handle[0];
hold_hand_offset_right_[1] += hold_handle[1];
hold_hand_offset_right_[2] += hold_handle[2];
@ -6855,11 +6823,12 @@ void SpazNode::SetHoldNode(Node* val) {
dBodySetQuaternion(b1, q1_old);
dBodySetQuaternion(b2, q2_old);
}
// inform userland objects that they're picking up or have been picked up
// Inform userland objects that they're picking up or have been picked
// up.
DispatchPickUpMessage(a);
a->DispatchPickedUpMessage(this);
} else {
// user is clearing hold-node; just drop whatever we're holding..
// User is clearing hold-node; just drop whatever we're holding.
DropHeldObject();
}
}

View File

@ -329,8 +329,6 @@ class SpazNode : public Node {
Object::WeakRef<Node> hold_node_;
std::string style_{"spaz"};
Object::WeakRef<Player> source_player_;
bool clamp_move_values_to_circle_{true};
bool demo_mode_{};
std::string curse_timer_txt_;
base::TextGroup curse_timer_text_group_;
std::string counter_mesh_text_;
@ -353,21 +351,10 @@ class SpazNode : public Node {
Part extras_part_;
Part limbs_part_upper_;
Part limbs_part_lower_;
bool dead_{};
// 1 for partially-shattered, 2 for completely.
int shattered_{};
bool invincible_{};
bool trying_to_fly_{};
bool throwing_with_bomb_button_{};
bool can_fly_{};
bool hockey_{};
bool have_boxing_gloves_{};
bool boxing_gloves_flashing_{};
bool frozen_{};
uint8_t flashing_{};
float throw_power_{};
millisecs_t throw_start_{};
bool have_thrown_{};
int hold_body_{};
millisecs_t last_head_collide_time_{};
millisecs_t last_external_impulse_time_{};
@ -391,7 +378,6 @@ class SpazNode : public Node {
std::vector<float> color_{1.0f, 1.0f, 1.0f};
std::vector<float> highlight_{0.5f, 0.5f, 0.5f};
std::vector<float> shadow_color_{0.5f, 0.5f, 0.5f};
bool wings_{};
Vector3f wing_pos_left_{0.0f, 0.0f, 0.0f};
Vector3f wing_vel_left_{0.0f, 0.0f, 0.0f};
Vector3f wing_pos_right_{0.0f, 0.0f, 0.0f};
@ -405,8 +391,6 @@ class SpazNode : public Node {
millisecs_t celebrate_until_time_right_{};
millisecs_t last_fly_time_{};
int footing_{};
int8_t lr_{};
int8_t ud_{};
float lr_norm_{};
float raw_ud_norm_{};
float raw_lr_norm_{};
@ -421,24 +405,11 @@ class SpazNode : public Node {
float accel_[3]{0.0f, 0.0f, 0.0f};
float throw_ud_{};
float throw_lr_{};
uint8_t behavior_version_{};
uint8_t balance_{};
uint8_t dizzy_{};
uint8_t knockout_{};
uint8_t jump_{};
uint8_t punch_{};
uint8_t pickup_{};
float fly_power_{};
float ball_size_{1.0f};
float run_{};
float move_left_right_{};
float move_up_down_{};
bool jump_pressed_{};
bool punch_pressed_{};
bool bomb_pressed_{};
bool fly_pressed_{};
bool pickup_pressed_{};
bool hold_position_pressed_{};
millisecs_t last_jump_time_{};
RigidBody::Joint pickup_joint_;
float eyes_lr_{};
@ -451,15 +422,9 @@ class SpazNode : public Node {
float eyelid_right_ud_smooth_{};
float blink_{};
float blink_smooth_{};
bool flap_{};
bool flapping_{};
bool holding_something_{};
millisecs_t last_pickup_time_{};
millisecs_t last_punch_time_{};
bool throwing_{};
bool head_back_{};
millisecs_t last_force_scream_time_{};
bool force_scream_{};
Object::Ref<RigidBody> body_head_;
Object::Ref<RigidBody> body_torso_;
Object::Ref<RigidBody> body_pelvis_;
@ -501,6 +466,41 @@ class SpazNode : public Node {
dJointID a_motor_brakes_{};
JointFixedEF* stand_joint_{};
dJointID a_motor_roller_{};
int8_t lr_{};
int8_t ud_{};
uint8_t flashing_{};
uint8_t behavior_version_{};
uint8_t balance_{};
uint8_t dizzy_{};
uint8_t knockout_{};
uint8_t jump_{};
uint8_t punch_{};
uint8_t pickup_{};
bool wings_{};
bool dead_{};
bool force_scream_{};
bool clamp_move_values_to_circle_{true};
bool demo_mode_{};
bool invincible_{};
bool trying_to_fly_{};
bool throwing_with_bomb_button_{};
bool can_fly_{};
bool hockey_{};
bool have_boxing_gloves_{};
bool boxing_gloves_flashing_{};
bool frozen_{};
bool have_thrown_{};
bool jump_pressed_{};
bool punch_pressed_{};
bool bomb_pressed_{};
bool fly_pressed_{};
bool pickup_pressed_{};
bool hold_position_pressed_{};
bool flap_{};
bool flapping_{};
bool holding_something_{};
bool throwing_{};
bool head_back_{};
bool female_{};
bool female_hair_{};
bool eyeless_{};
@ -511,6 +511,10 @@ class SpazNode : public Node {
bool dull_reflection_{};
bool ninja_{};
bool punch_right_{};
bool last_hit_was_punch_{};
bool has_eyelids_{true};
bool running_{};
bool billboard_cross_out_{};
Object::Ref<RigidBody> hair_front_right_body_;
JointFixedEF* hair_front_right_joint_{};
Object::Ref<RigidBody> hair_front_left_body_;
@ -535,7 +539,6 @@ class SpazNode : public Node {
float a_vel_y_smoothed_{};
float a_vel_y_smoothed_more_{};
float eye_lid_angle_{};
bool last_hit_was_punch_{};
int fly_time_{};
float eye_ball_color_red_{0.5f};
float eye_ball_color_green_{0.5f};
@ -550,7 +553,6 @@ class SpazNode : public Node {
float shoulder_offset_x_{};
float shoulder_offset_y_{};
float shoulder_offset_z_{};
bool has_eyelids_{true};
float eye_scale_{1.0f};
float reflection_scale_{0.1f};
float default_eye_lid_angle_{};
@ -559,13 +561,11 @@ class SpazNode : public Node {
float eye_offset_z_{};
millisecs_t last_got_boxing_gloves_time_{};
uint32_t shatter_damage_{};
bool running_{};
float speed_smoothed_{};
float run_gas_{};
float hurt_{};
float hurt_smoothed_{};
millisecs_t last_hurt_change_time_{};
bool billboard_cross_out_{};
millisecs_t death_time_{};
};

View File

@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
namespace ballistica {
// These are set automatically via script; don't modify them here.
const int kEngineBuildNumber = 21387;
const int kEngineBuildNumber = 21391;
const char* kEngineVersion = "1.7.28";
const int kEngineApiVersion = 8;

View File

@ -145,7 +145,7 @@ void RootUI::HandleMouseMotion(float x, float y) {
void RootUI::Draw(base::FrameDef* frame_def) {
if (explicit_bool(DO_OLD_MENU_PARTY_BUTTONS)) {
millisecs_t real_time = frame_def->real_time();
millisecs_t real_time = frame_def->app_time_millisecs();
// Menu button.
// Update time-dependent stuff to this point.