More tidying

This commit is contained in:
Eric Froemling 2020-10-14 08:57:32 -07:00
parent 8f102bcf78
commit 517abc9112
10 changed files with 145 additions and 123 deletions

View File

@ -3932,24 +3932,24 @@
"assets/build/windows/Win32/ucrtbased.dll": "https://files.ballistica.net/cache/ba1/b5/85/f8b6d0558ddb87267f34254b1450",
"assets/build/windows/Win32/vc_redist.x86.exe": "https://files.ballistica.net/cache/ba1/1c/e1/4a1a2eddda2f4aebd5f8b64ab08e",
"assets/build/windows/Win32/vcruntime140d.dll": "https://files.ballistica.net/cache/ba1/50/8d/bc2600ac9491f1b14d659709451f",
"build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/e9/48/88db5152fcd7ff38363ce35e2b5c",
"build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/83/9a/4d1f2cd9a7940d99e24d8f0719f4",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a3/58/4be1efd666668e078a7a9ca36928",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a5/5d/3ba7496fb214568d79aa36bc0fa2",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/85/4c/8ad6020c7b442306b5729ab7af5c",
"build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/bd/a6/ecf53cf19d15644fe1b072dff936",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a0/f5/a2688f382c3dc2b3763f83a40b72",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/c5/82/7313732699d4e1d86fa0c153c046",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/63/42/fc3ff5ea8c9e3b30788ae2adcb89",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/5a/b9/94c0e471b1cda37c5e8e8f92192b",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/d5/e8/df64479789b87fa7472162476d52",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/12/a1/06e3f98c545918e81520cd1154eb",
"build/prefab/lib/linux_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/2c/b1/c6394b207908dcf10702963d074b",
"build/prefab/full/linux_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/19/53/2a9c168ffd8bc53475e8c9e139ed",
"build/prefab/full/linux_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/20/79/28f2821d36d20be52eebee1475fa",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/6e/4e/1f59b95892fdd6ebf55159c0fb69",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/3c/64/8790eac167ed9cb6ced1b4e43a34",
"build/prefab/full/mac_x86_64/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/06/6c/1ffc0a07960c3272304b1b5f858a",
"build/prefab/full/mac_x86_64/release/ballisticacore": "https://files.ballistica.net/cache/ba1/6c/fd/193b81fcda6c6716e3dcaa7f7cb8",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/0f/30/8ac58a8ebc1b73dc335d82d7cecb",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/26/a7/dc477a2297d27eb7fbb14a662619",
"build/prefab/full/windows_x86/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/70/07/1e15c6fcdbf35ceda17a5d324394",
"build/prefab/full/windows_x86/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/9b/2b/59a36a36dd90410b4a94726a3e4b",
"build/prefab/full/windows_x86_server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/fc/36/6bafb410c3ad3d458545fc495cfd",
"build/prefab/full/windows_x86_server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/f3/29/0e5332b1ab93ea7c564fea7ce980",
"build/prefab/lib/linux_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4d/01/29abecb0b2bd764ad3c261f1727e",
"build/prefab/lib/linux_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/68/c6/61c27c594a5b67abb7cd0a2a0f51",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/96/61/51cb6fd93d32693f297f51bca1e5",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/79/a9/480cd7947a83b5e52359945c450e",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/53/96/32edc65468aa4546f245192238c3",
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/e2/88/4c3188f4bfa72c23902b3e4c1e56",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/bb/5f/82a7d3e039af6ad89cf42231b8b7",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/09/38/1e6625b6e8710aba4c6d1cc18e94",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/4d/ea/ebfd89fab46518a4c3bdf5e57638"
"build/prefab/lib/mac_x86_64/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/18/34/0c7bc3754d9dc5a796133484a891",
"build/prefab/lib/mac_x86_64/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/0a/69/49203680f51913705a4f6263ef01",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/08/ea/3732982a8df8b9510b9ae4bb3ace",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9c/31/60fcef7fd4e08d4ebb1859f4c9a3"
}

View File

@ -29,7 +29,7 @@
namespace ballistica {
// These are set automatically via script; don't change here.
const int kAppBuildNumber = 20207;
const int kAppBuildNumber = 20210;
const char* kAppVersion = "1.5.26";
// Our standalone globals.

View File

@ -18,18 +18,20 @@ class CollisionCache {
~CollisionCache();
// If returns true, the provided AABB *may* intersect the geoms.
void SetGeoms(const std::vector<dGeomID>& geoms);
void Draw(FrameDef* f); // For debugging.
void CollideAgainstSpace(dSpaceID space, void* data, dNearCallback* callback);
void CollideAgainstGeom(dGeomID geom, void* data, dNearCallback* callback);
auto SetGeoms(const std::vector<dGeomID>& geoms) -> void;
auto Draw(FrameDef* f) -> void; // For debugging.
auto CollideAgainstSpace(dSpaceID space, void* data, dNearCallback* callback)
-> void;
auto CollideAgainstGeom(dGeomID geom, void* data, dNearCallback* callback)
-> void;
// Call this periodically (once per cycle or so) to slowly fill in
// the cache so there's less to do during spurts of activity;
void Precalc();
private:
void TestCell(size_t cell_index, int x, int z);
void Update();
auto TestCell(size_t cell_index, int x, int z) -> void;
auto Update() -> void;
uint32_t precalc_index_{};
std::vector<dGeomID> geoms_;
struct Cell {

View File

@ -16,14 +16,15 @@ class Dynamics : public Object {
public:
explicit Dynamics(Scene* scene_in);
~Dynamics() override;
void Draw(FrameDef* frame_def); // Draw any debug stuff, etc.
auto Draw(FrameDef* frame_def) -> void; // Draw any debug stuff, etc.
auto ode_world() -> dWorldID { return ode_world_; }
auto getContactGroup() -> dJointGroupID { return ode_contact_group_; }
auto space() -> dSpaceID { return ode_space_; }
// Discontinues a collision. Used by parts when changing materials
// so that new collisions may enter effect.
void ResetCollision(int64_t node1, int part1, int64_t node2, int part2);
auto ResetCollision(int64_t node1, int part1, int64_t node2, int part2)
-> void;
// Used by collision callbacks - internal.
auto active_collision() const -> Collision* { return active_collision_; }
@ -47,25 +48,25 @@ class Dynamics : public Object {
}
// Used by collide message handlers.
void set_collide_message_state(bool inCollideMessageIn,
bool target_other_in = false) {
auto set_collide_message_state(bool inCollideMessageIn,
bool target_other_in = false) -> void {
in_collide_message_ = inCollideMessageIn;
collide_message_reverse_order_ = target_other_in;
}
auto in_collide_message() const -> bool { return in_collide_message_; }
void process();
void increment_skid_sound_count() { skid_sound_count_++; }
void decrement_skid_sound_count() { skid_sound_count_--; }
auto process() -> void;
auto increment_skid_sound_count() -> void { skid_sound_count_++; }
auto decrement_skid_sound_count() -> void { skid_sound_count_--; }
auto skid_sound_count() const -> int { return skid_sound_count_; }
void incrementRollSoundCount() { roll_sound_count_++; }
void decrement_roll_sound_count() { roll_sound_count_--; }
auto incrementRollSoundCount() -> void { roll_sound_count_++; }
auto decrement_roll_sound_count() -> void { roll_sound_count_--; }
auto getRollSoundCount() const -> int { return roll_sound_count_; }
// We do some fancy collision testing stuff for trimeshes instead
// of going through regular ODE space collision testing.. so we have
// to keep track of these ourself.
void AddTrimesh(dGeomID g);
void RemoveTrimesh(dGeomID g);
auto AddTrimesh(dGeomID g) -> void;
auto RemoveTrimesh(dGeomID g) -> void;
auto collision_count() const -> int { return collision_count_; }
auto process_real_time() const -> millisecs_t { return real_time_; }
@ -91,33 +92,33 @@ class Dynamics : public Object {
// Contains in-progress collisions for current nodes.
std::map<int64_t, SrcNodeCollideMap> node_collisions_;
std::vector<CollisionEvent> collision_events_;
void HandleDisconnect(
auto HandleDisconnect(
const std::map<int64_t,
ballistica::Dynamics::SrcNodeCollideMap>::iterator& i,
const std::map<int64_t,
ballistica::Dynamics::DstNodeCollideMap>::iterator& j,
const std::map<int, SrcPartCollideMap>::iterator& k,
const std::map<int, Object::Ref<Collision> >::iterator& l);
void ResetODE();
void ShutdownODE();
static void DoCollideCallback(void* data, dGeomID o1, dGeomID o2);
void CollideCallback(dGeomID o1, dGeomID o2);
void ProcessCollisions();
bool processing_collisions_ = false;
dWorldID ode_world_ = nullptr;
dJointGroupID ode_contact_group_ = nullptr;
dSpaceID ode_space_ = nullptr;
millisecs_t real_time_ = 0;
bool in_process_ = false;
const std::map<int, Object::Ref<Collision> >::iterator& l) -> void;
auto ResetODE() -> void;
auto ShutdownODE() -> void;
static auto DoCollideCallback(void* data, dGeomID o1, dGeomID o2) -> void;
auto CollideCallback(dGeomID o1, dGeomID o2) -> void;
auto ProcessCollisions() -> void;
bool processing_collisions_{};
dWorldID ode_world_{};
dJointGroupID ode_contact_group_{};
dSpaceID ode_space_{};
millisecs_t real_time_{};
bool in_process_{};
std::vector<dGeomID> trimeshes_;
millisecs_t last_impact_sound_time_ = 0;
int skid_sound_count_ = 0;
int roll_sound_count_ = 0;
int collision_count_ = 0;
Scene* scene_;
bool in_collide_message_ = false;
bool collide_message_reverse_order_ = false;
Collision* active_collision_ = nullptr;
millisecs_t last_impact_sound_time_{};
int skid_sound_count_{};
int roll_sound_count_{};
int collision_count_{};
Scene* scene_{};
bool in_collide_message_{};
bool collide_message_reverse_order_{};
Collision* active_collision_{};
Object::WeakRef<Node> active_collide_src_node_;
Object::WeakRef<Node> active_collide_dst_node_;
std::unique_ptr<CollisionCache> collision_cache_;

View File

@ -150,7 +150,7 @@ RigidBody::RigidBody(int id_in, Part* part_in, Type type_in, Shape shape_in,
SetDimensions(dimensions_[0], dimensions_[1], dimensions_[2]);
}
void RigidBody::Check() {
auto RigidBody::Check() -> void {
if (type_ == Type::kBody) {
const dReal* p = dBodyGetPosition(body_);
const dReal* q = dBodyGetQuaternion(body_);
@ -178,7 +178,7 @@ void RigidBody::Check() {
prev_vel_[i] = lv[i];
prev_a_vel_[i] = av[i];
}
#endif
#endif // BA_DEBUG_BUILD
}
}
@ -206,7 +206,7 @@ RigidBody::~RigidBody() {
}
}
void RigidBody::KillConstraints() {
auto RigidBody::KillConstraints() -> void {
while (joints_.begin() != joints_.end()) {
(**joints_.begin()).Kill();
}
@ -233,7 +233,7 @@ auto RigidBody::GetEmbeddedSizeFull() -> int {
// store a body to a buffer
// FIXME - theoretically we should embed birth-time
// as this can affect collisions with this object
void RigidBody::EmbedFull(char** buffer) {
auto RigidBody::EmbedFull(char** buffer) -> void {
assert(type_ == Type::kBody);
const dReal* p = dBodyGetPosition(body_);
@ -276,7 +276,7 @@ void RigidBody::EmbedFull(char** buffer) {
}
// Position a body from buffer data.
void RigidBody::ExtractFull(const char** buffer) {
auto RigidBody::ExtractFull(const char** buffer) -> void {
assert(type_ == Type::kBody);
dReal p[3], lv[3], av[3];
@ -326,7 +326,7 @@ void RigidBody::ExtractFull(const char** buffer) {
}
}
void RigidBody::Draw(RenderPass* pass, bool shaded) {
auto RigidBody::Draw(RenderPass* pass, bool shaded) -> void {
assert(pass);
RenderPass::Type pass_type = pass->type();
// only passes we draw in are light_shadow and beauty
@ -341,7 +341,8 @@ void RigidBody::Draw(RenderPass* pass, bool shaded) {
}
}
void RigidBody::AddCallback(CollideCallbackFunc callbackIn, void* data_in) {
auto RigidBody::AddCallback(CollideCallbackFunc callbackIn, void* data_in)
-> void {
CollideCallback c{};
c.callback = callbackIn;
c.data = data_in;
@ -358,8 +359,8 @@ auto RigidBody::CallCollideCallbacks(dContact* contacts, int count,
return true;
}
void RigidBody::SetDimensions(float d1, float d2, float d3, float m1, float m2,
float m3, float density_mult) {
auto RigidBody::SetDimensions(float d1, float d2, float d3, float m1, float m2,
float m3, float density_mult) -> void {
dimensions_[0] = d1;
dimensions_[1] = d2;
dimensions_[2] = d3;
@ -569,8 +570,8 @@ auto RigidBody::ApplyImpulse(float px, float py, float pz, float vx, float vy,
return total_mag;
}
void RigidBody::ApplyGlobalImpulse(float px, float py, float pz, float fx,
float fy, float fz) {
auto RigidBody::ApplyGlobalImpulse(float px, float py, float pz, float fx,
float fy, float fz) -> void {
if (type_ != Type::kBody) {
return;
}
@ -581,7 +582,7 @@ void RigidBody::ApplyGlobalImpulse(float px, float py, float pz, float fx,
RigidBody::Joint::Joint() = default;
void RigidBody::Joint::SetJoint(dxJointFixed* id_in, Scene* scene) {
auto RigidBody::Joint::SetJoint(dxJointFixed* id_in, Scene* scene) -> void {
Kill();
creation_time_ = scene->time();
id_ = id_in;
@ -589,7 +590,8 @@ void RigidBody::Joint::SetJoint(dxJointFixed* id_in, Scene* scene) {
RigidBody::Joint::~Joint() { Kill(); }
void RigidBody::Joint::AttachToBodies(RigidBody* b1_in, RigidBody* b2_in) {
auto RigidBody::Joint::AttachToBodies(RigidBody* b1_in, RigidBody* b2_in)
-> void {
assert(id_);
b1_ = b1_in;
b2_ = b2_in;
@ -608,7 +610,7 @@ void RigidBody::Joint::AttachToBodies(RigidBody* b1_in, RigidBody* b2_in) {
dJointAttach(id_, b_id_1, b_id_2);
}
void RigidBody::Joint::Kill() {
auto RigidBody::Joint::Kill() -> void {
if (id_) {
if (b1_) {
b1_->RemoveJoint(this);
@ -671,13 +673,13 @@ auto RigidBody::GetTransform() -> Matrix44f {
return matrix;
}
void RigidBody::AddBlendOffset(float x, float y, float z) {
auto RigidBody::AddBlendOffset(float x, float y, float z) -> void {
// blend_offset_.x += x;
// blend_offset_.y += y;
// blend_offset_.z += z;
}
void RigidBody::UpdateBlending() {
auto RigidBody::UpdateBlending() -> void {
// FIXME - this seems broken. We never update blend_time_ currently
// and its also set to time whereas we're comparing it with steps.
// Should revisit.

View File

@ -78,8 +78,8 @@ class RigidBody : public Object {
// these are needed for full states
auto GetEmbeddedSizeFull() -> int;
void ExtractFull(const char** buffer);
void EmbedFull(char** buffer);
auto ExtractFull(const char** buffer) -> void;
auto EmbedFull(char** buffer) -> void;
RigidBody(int id_in, Part* part_in, Type type_in, Shape shape_in,
uint32_t collide_type_in, uint32_t collide_mask_in,
CollideModel* collide_model_in = nullptr, uint32_t flags = 0);
@ -88,37 +88,39 @@ class RigidBody : public Object {
auto geom(int i = 0) const -> dGeomID { return geoms_[i]; }
// Draw a representation of the rigid body for debugging.
void Draw(RenderPass* pass, bool shaded = true);
auto Draw(RenderPass* pass, bool shaded = true) -> void;
auto part() const -> Part* {
assert(part_.exists());
return part_.get();
}
void Wake() {
auto Wake() -> void {
if (body_) {
dBodyEnable(body_);
}
}
void AddCallback(CollideCallbackFunc callback_in, void* data_in);
auto AddCallback(CollideCallbackFunc callback_in, void* data_in) -> void;
auto CallCollideCallbacks(dContact* contacts, int count,
RigidBody* opposingbody) -> bool;
void SetDimensions(
auto SetDimensions(
float d1, float d2 = 0.0f, float d3 = 0.0f, // body dimensions
float m1 = 0.0f, float m2 = 0.0f,
float m3 = 0.0f, // Mass dimensions (default to regular if zero).
float density = 1.0f);
float density = 1.0f) -> void;
// If geomWakeOnCollide is true, a GEOM_ONLY object colliding with a sleeping
// body will wake it up. Generally this should be true if the geom is moving
// or changing.
void set_geom_wake_on_collide(bool enable) { geom_wake_on_collide_ = enable; }
auto set_geom_wake_on_collide(bool enable) -> void {
geom_wake_on_collide_ = enable;
}
auto geom_wake_on_collide() const -> bool { return geom_wake_on_collide_; }
auto id() const -> int { return id_; }
void ApplyGlobalImpulse(float px, float py, float pz, float fx, float fy,
float fz);
auto ApplyGlobalImpulse(float px, float py, float pz, float fx, float fy,
float fz) -> void;
auto ApplyImpulse(float px, float py, float pz, float vx, float vy, float vz,
float fdirx, float fdiry, float fdirz, float mag,
float v_mag, float radiusm, bool calc_only) -> float;
void KillConstraints();
auto KillConstraints() -> void;
// Rigid body joint wrapper. This takes ownership of joints it is passed
// all joints should use this mechanism so they are automatically
@ -151,8 +153,8 @@ class RigidBody : public Object {
};
// Used by Joint.
void AddJoint(Joint* j) { joints_.push_back(j); }
void RemoveJoint(Joint* j) {
auto AddJoint(Joint* j) -> void { joints_.push_back(j); }
auto RemoveJoint(Joint* j) -> void {
for (auto i = joints_.begin(); i != joints_.end(); i++) {
if ((*i) == j) {
joints_.erase(i);
@ -160,22 +162,24 @@ class RigidBody : public Object {
}
}
}
void Check();
auto Check() -> void;
auto type() const -> Type { return type_; }
auto collide_type() const -> uint32_t { return collide_type_; }
auto collide_mask() const -> uint32_t { return collide_mask_; }
auto flags() const -> uint32_t { return flags_; }
void set_flags(uint32_t flags) { flags_ = flags; }
auto set_flags(uint32_t flags) -> void { flags_ = flags; }
auto can_cause_impact_damage() const -> bool {
return can_cause_impact_damage_;
}
void set_can_cause_impact_damage(bool val) { can_cause_impact_damage_ = val; }
auto set_can_cause_impact_damage(bool val) -> void {
can_cause_impact_damage_ = val;
}
// Applies to spheres.
auto radius() const -> float { return dimensions_[0]; }
auto GetTransform() -> Matrix44f;
void UpdateBlending();
void AddBlendOffset([[maybe_unused]] float x, float y, float z);
auto UpdateBlending() -> void;
auto AddBlendOffset(float x, float y, float z) -> void;
auto blend_offset() const -> const Vector3f& { return blend_offset_; }
private:

View File

@ -26,9 +26,11 @@ void Node::AddToScene(Scene* scene) {
// (can't create strong refs in constructors)
assert(scene_ == scene);
assert(id_ == 0);
id_ = scene->next_node_id_++;
our_iterator =
scene->nodes_.insert(scene->nodes_.end(), Object::Ref<Node>(this));
scene->AddNode(this, &id_, &iterator_);
// id_ = scene->next_node_id_++;
// our_iterator_ =
// scene->nodes_.insert(scene->nodes_.end(), Object::Ref<Node>(this));
if (GameStream* os = scene->GetGameStream()) {
os->AddNode(this);
}

View File

@ -143,7 +143,7 @@ class Node : public Object {
auto HasAttribute(const std::string& name) const -> bool;
auto has_py_ref() -> bool { return (py_ref_ != nullptr); }
void UpdateConnections();
auto iterator() -> NodeList::iterator { return our_iterator; }
auto iterator() -> NodeList::iterator { return iterator_; }
void CheckBodies();
@ -205,7 +205,7 @@ class Node : public Object {
std::vector<Object::WeakRef<Node> > dependent_nodes_;
std::vector<Part*> parts_;
int64_t id_{};
NodeList::iterator our_iterator;
NodeList::iterator iterator_;
// Put this stuff at the bottom so it gets killed first
PythonRef delegate_;

View File

@ -621,4 +621,11 @@ auto Scene::GetCorrectionMessage(bool blended) -> std::vector<uint8_t> {
void Scene::SetOutputStream(GameStream* val) { output_stream_ = val; }
auto Scene::AddNode(Node* node, int64_t* node_id, NodeList::iterator* i)
-> void {
assert(node && node_id && i);
*node_id = next_node_id_++;
*i = nodes_.insert(nodes_.end(), Object::Ref<Node>(node));
}
} // namespace ballistica

View File

@ -15,16 +15,16 @@ namespace ballistica {
class Scene : public Object {
public:
static void Init();
static auto Init() -> void;
explicit Scene(millisecs_t starttime);
~Scene() override;
void Step();
void Draw(FrameDef* frame_def);
auto Step() -> void;
auto Draw(FrameDef* frame_def) -> void;
auto NewNode(const std::string& type, const std::string& name,
PyObject* delegate) -> Node*;
void PlaySoundAtPosition(Sound* sound, float volume, float x, float y,
float z, bool host_only = false);
void PlaySound(Sound* sound, float volume, bool host_only = false);
auto PlaySoundAtPosition(Sound* sound, float volume, float x, float y,
float z, bool host_only = false) -> void;
auto PlaySound(Sound* sound, float volume, bool host_only = false) -> void;
static auto GetNodeMessageType(const std::string& type_name)
-> NodeMessageType;
static auto GetNodeMessageTypeName(NodeMessageType t) -> std::string;
@ -32,42 +32,48 @@ class Scene : public Object {
auto time() const -> millisecs_t { return time_; }
auto stepnum() const -> int64_t { return stepnum_; }
auto nodes() const -> const NodeList& { return nodes_; }
void AddOutOfBoundsNode(Node* n) { out_of_bounds_nodes_.emplace_back(n); }
auto AddNode(Node*, int64_t* node_id, NodeList::iterator* i) -> void;
auto AddOutOfBoundsNode(Node* n) -> void {
out_of_bounds_nodes_.emplace_back(n);
}
auto IsOutOfBounds(float x, float y, float z) -> bool;
auto dynamics() const -> Dynamics* {
assert(dynamics_.exists());
return dynamics_.get();
}
auto in_step() const -> bool { return in_step_; }
void SetMapBounds(float x, float y, float z, float X, float Y, float Z);
void ScreenSizeChanged();
void LanguageChanged();
void GraphicsQualityChanged(GraphicsQuality q);
auto SetMapBounds(float x, float y, float z, float X, float Y, float Z)
-> void;
auto ScreenSizeChanged() -> void;
auto LanguageChanged() -> void;
auto GraphicsQualityChanged(GraphicsQuality q) -> void;
auto out_of_bounds_nodes() -> const std::vector<Object::WeakRef<Node> >& {
return out_of_bounds_nodes_;
}
void DeleteNode(Node* node);
auto DeleteNode(Node* node) -> void;
auto shutting_down() const -> bool { return shutting_down_; }
void set_shutting_down(bool val) { shutting_down_ = val; }
auto set_shutting_down(bool val) -> void { shutting_down_ = val; }
auto GetGameStream() const -> GameStream*;
void SetPlayerNode(int id, PlayerNode* n);
auto SetPlayerNode(int id, PlayerNode* n) -> void;
auto GetPlayerNode(int id) -> PlayerNode*;
auto use_fixed_vr_overlay() const -> bool { return use_fixed_vr_overlay_; }
void set_use_fixed_vr_overlay(bool val) { use_fixed_vr_overlay_ = val; }
void increment_bg_cover_count() { bg_cover_count_++; }
void decrement_bg_cover_count() { bg_cover_count_--; }
auto set_use_fixed_vr_overlay(bool val) -> void {
use_fixed_vr_overlay_ = val;
}
auto increment_bg_cover_count() -> void { bg_cover_count_++; }
auto decrement_bg_cover_count() -> void { bg_cover_count_--; }
auto has_bg_cover() const -> bool { return (bg_cover_count_ > 0); }
void Dump(GameStream* out);
void DumpNodes(GameStream* out);
auto Dump(GameStream* out) -> void;
auto DumpNodes(GameStream* out) -> void;
auto GetCorrectionMessage(bool blended) -> std::vector<uint8_t>;
void SetOutputStream(GameStream* val);
auto SetOutputStream(GameStream* val) -> void;
auto stream_id() const -> int64_t { return stream_id_; }
void set_stream_id(int64_t val) {
auto set_stream_id(int64_t val) -> void {
assert(stream_id_ == -1);
stream_id_ = val;
}
void clear_stream_id() {
auto clear_stream_id() -> void {
assert(stream_id_ != -1);
stream_id_ = -1;
}
@ -76,11 +82,11 @@ class Scene : public Object {
return last_step_real_time_;
}
auto globals_node() const -> GlobalsNode* { return globals_node_; }
void set_globals_node(GlobalsNode* node) { globals_node_ = node; }
auto set_globals_node(GlobalsNode* node) -> void { globals_node_ = node; }
private:
static void SetupNodeMessageType(const std::string& name, NodeMessageType val,
const std::string& format);
static auto SetupNodeMessageType(const std::string& name, NodeMessageType val,
const std::string& format) -> void;
GlobalsNode* globals_node_{}; // Current globals node (if any).
std::map<int, Object::WeakRef<PlayerNode> > player_nodes_;
@ -102,8 +108,6 @@ class Scene : public Object {
std::vector<Object::WeakRef<Node> > out_of_bounds_nodes_;
NodeList nodes_;
Object::Ref<Dynamics> dynamics_;
friend void Node::AddToScene(Scene*);
friend class ClientSession;
};
} // namespace ballistica