mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-12 19:06:09 -10:00
* chore: vendor ImPlot library
Adds ImPlot as a build dependency, to be used for the upcoming ImGui
frame profiler overlay's frametime graph and pie chart.
* feat: add ImGui frame profiler overlay
Replaces the old text-dump frame profile display (-profile_frame_time)
with a runtime-toggleable ImGui/ImPlot overlay showing average/median
frametime, a scrolling frametime graph, and a pie chart of the top
contributors to frame time. Toggled via a new "Frame Profiler Overlay"
option, which also seeds from -profile_frame_time for backward
compatibility and now drives frame profiling collection at runtime
instead of only at startup.
* Add graphics and Vulkan debug stats to ImGui profiler overlay
- Integrated per-backend diagnostic counters into the ImGui frame profiler overlay, triggered by `-gr_debug`.
- Consolidated and cleaned up Vulkan rendering state and descriptor management for compatibility with ImGui's Vulkan pipeline.
- Enabled uniform buffer and draw statistics reporting for enhanced performance insights during debugging.
* Update ImPlot to v1.1 WIP and improve internal consistency
- Adjust copyright notices for extended license coverage (2025-2026).
- Modernize constants with `constexpr` replacements, improving type safety and clarity.
- Enforce `nullptr` usage over `NULL` throughout, aligning with modern C++ practices.
- Add various enhancements to ImPlot legends, markers, and axes behavior.
- Introduce additional helper methods for time handling and timestamp calculations.
- Address UI and typo improvements in comments and documentation, refining accuracy.
* Refactor frame profiler to use per-category self-time accumulation
- Introduced `accumulate_self_times` for single-pass exclusive time computation, improving performance and accuracy.
- Updated `FrameProfiler` and overlay snapshot logic to leverage `Category`'s stable `getId` and `getCount`.
- Replaced pie chart with a stacked bar for frame budget visualization, optimizing rendering cost.
- Cached `get_tid` and `get_pid` with thread-local storage to minimize syscall overhead.
- Added support for unit testing frame profiling functionality and included new test cases.
- Improved code comments and clarified documentation.
* Use dynamic uniform buffers to stop per-draw descriptor set churn in Vulkan
The Material and PerDraw descriptor sets were reallocated and fully rewritten on
essentially every draw call. model_draw_list::render_buffer rebinds ModelData with
a fresh uniform buffer offset for each queued draw, and that offset was part of the
Material set's memoization key, so the cache in VulkanDrawManager::applyMaterial
missed every time - taking a frame-pool allocation, a full template write, the
16-entry material texture resolution and a vkUpdateDescriptorSets with it.
GenericData/Matrices did the same to the PerDraw set. renderShadowDraw was worse
still: all three sets allocated and rewritten per shadow draw, with no memoization
at all.
A large asteroid field (Solaris m21) measured 2566 descriptor sets and 19107
descriptor writes per frame at 1606 model draws, and grew an extra descriptor pool
chunk every frame.
Declare the bindings whose offset moves per draw - MaterialBinding::ModelData,
MaterialBinding::ShadowMapData, PerDrawBinding::GenericData and
PerDrawBinding::Matrices - as eUniformBufferDynamic. DescriptorWriter::setBuffer
now splits a dynamic binding's offset out of the descriptor, writing
{buffer, 0, range} and stashing the offset for vkCmdBindDescriptorSets'
pDynamicOffsets, so an offset-only change leaves the set's contents identical and
the memoization caches start hitting. Shader sources are unchanged.
VulkanStateTracker::bindDescriptorSet now compares the dynamic offsets as well as
the set handle. This is required, not an optimization: the common case is now the
same set rebound with a new offset, and the old handle-only redundancy check would
have skipped that bind and fed every draw the previous draw's uniforms.
renderShadowDraw memoizes its three sets the way applyMaterial does. It does not
invalidate applyMaterial's caches - those record what a set contains, the shadow
pass allocates its own sets rather than overwriting theirs, and it binds through
the state tracker, so the next material cache hit still rebinds correctly.
Also switch allocateFrameSet to the non-allocating allocateDescriptorSets overload;
the vector-returning one heap-allocated once per set, thousands of times a frame.
MAX_SETS_PER_POOL stays at 1024 - the per-frame pool growth it used to log was a
symptom of the churn, and one chunk now covers the scene outright.
Measured on that mission in a Debug build, A/B on the same tree with and without
this change:
descriptor sets/frame @ ~1370 draws 2566 -> 250-345
descriptor writes/frame 19107 -> ~1700-2300
median frametime 92.9/83.6 ms -> 72.0/66.5 ms
Render Buffer (profiler overlay) 24.68 ms (30.8%) -> 12.73 ms (18.4%)
Build Shadow Map 5.44 ms -> off the top-5 entirely
Release builds already inlined most of this away and are unchanged, as expected.
Verified with the validation layers (sync validation enabled): no new VUIDs versus
the same build without the change.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Refactor Vulkan descriptor set binding to reduce dynamic offset churn
- Consolidated dynamic descriptor offset logic into `DescriptorWriter::bindSets`, replacing repetitive `vkCmdBindDescriptorSets` patterns across Vulkan modules.
- Eliminated redundant descriptor binding operations for Material and PerDraw sets by centralizing logic in `bindSets`.
- Simplified descriptors by directly splitting offset changes from descriptor contents, avoiding unnecessary updates.
- Updated comments and documentation to align with the new approach while maintaining reference consistency.
- Applied optimizations across Vulkan modules (`VulkanPostProcessing`, `VulkanDescriptorManager`, etc.) to reduce per-draw overhead and improve readability.
* Enable primitive restart for supported topologies in Vulkan pipeline
- Added `topologySupportsPrimitiveRestart` to determine restart eligibility for each topology.
- Updated `primitiveRestartEnable` to be conditionally set based on topology, addressing compatibility issues with Metal/MoltenVK.
- Prevented crash scenarios on macOS by ensuring pipelines are valid for strip/fan topologies requiring primitive restart.
* Enable VK_KHR_portability_subset for compatibility
* Replace exception with sentinel for non-dynamic Vulkan descriptor bindings
- Introduced `DYNAMIC_SLOT_INVALID` sentinel to replace the throw in `dynamic_offset_slot` for MSVC compatibility.
- Added `static_assert` checks to validate binding constants, ensuring compile-time validation for dynamic offsets.
- Updated comments to clarify design rationale and avoid potential misuse.
* Add memory statistics and tracking to profiler overlay
* fix ci issues
* Add OpenGL memory statistics to the profiler overlay
The memory panel showed no texture bytes and no geometry bytes under
OpenGL. Only the depth renderbuffers went into the render target group.
All three groups now give a value.
Textures: GL_texture_bytes_used holds the bytes of every live texture
cache slot. opengl_texture_release_bytes() removes the bytes of a slot at
each site that drops its texture data. The bitmap render targets record
the bytes of their color texture.
Geometry: the unused GL_vertex_data_in global becomes
GL_geometry_bytes_used, which counts only vertex and index buffers. This
matches the geometry group of the Vulkan backend.
gr_opengl_delete_buffer() sets the size of the buffer to 0, because
opengl_destroy_all_buffers() calls it a second time for a buffer that the
game already deleted.
Render targets: three new functions add the scene textures, the
post-processing textures, and the shadow map to the group. They sum the
bytes at the moment of the call from the textures that exist, thus they
need no bookkeeping at the create and delete sites.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Fix profiler overlay crash on a category that is not a static
The category registry kept a Category pointer for each id. The comment said that all categories
are global statics, but that is not correct. The Lua API tracing_category constructs a Category
and copies it into a script-owned object. The registry then kept a pointer to the dead temporary.
build_overlay_snapshot called getName() on that pointer, made an SCP_string from the garbage
char*, and the process stopped with SIGABRT.
The registry now keeps the name by value and never keeps a Category pointer. getById() becomes
getNameById(), which is all that build_overlay_snapshot needs. A copy of a Category keeps the id
of the original, which stays correct because the id only selects a name.
Add two tests: one shows that the name stays available after the Category object is dead, and one
drives the full path that failed, from processEvent to the overlay snapshot.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Replace category pointers with IDs to prevent use-after-free
- Updated `trace_event` to store `category_id` instead of a pointer to prevent dangling references to category objects that may already be destroyed.
- Modified all references to category names to use `Category::getNameById()` instead of dereferencing pointers.
- Expanded memory statistics in the profiler overlay with new sound, Lua, and OS-level memory usage tracking.
- Added new tests to verify proper use of category IDs in frame profiling and event tracing.
- Improved memory safety and stability across tracing, profiling, and overlay systems.
* Refactor profiler overlay to use snapshot-based frame timing
* Address review feedback on the profiler overlay
Skip complete::end for a scope that did not start. This fixes a crash
when Lua turns the overlay on while a scope is open. Track the GPU begin
event so that turning the overlay off mid-scope still closes it.
Use XSTR 1936 and 1937 for the overlay option. Master now uses 1932
and 1933.
Remove the default value of dynamicOffsets in bindDescriptorSet. Use the
PerDraw binding constants in the PerDraw key.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Use wall-clock frame time and read the history without a copy
The Avg and FPS line used traced self-time, which reads too high.
Measure the time between overlay frames instead. Draw the graph with
PlotLineG so the history deque needs no per-frame copy.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Address second round of review feedback on the profiler overlay
- Make the category registry thread-safe and give categories with the
same name one id, so the registry does not grow without limit.
- Add tests that toggle the profiler inside an open trace scope.
- Correct the next free XSTR id note to 1938.
- Use the existing Windows include block for psapi.h in osapi.cpp.
- Use list_range in ship_get_num_ships() and shorten some comments.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Return size_t from Category::getCount() and tidy the registry code
- Use structured bindings and std::scoped_lock in the category registry.
- Return size_t from getCount() and update its callers and tests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Address third round of review feedback on the profiler overlay
- Move the overlay option strings to XSTR 1940 and 1941. The touch
overlay on master uses 1936 to 1939.
- Give FrameProfiler the main thread ID when it is made. Before, it
used the thread of the first event, which was a race.
- Let mouse motion go to the game while the pointer is over the
overlay, so that mouse flight does not stop there.
- Find the dynamic bindings of the PerDraw key with
dynamic_offset_slot(), as the other call sites do.
- Make disable_inside_open_scope count the GPU timestamp queries, so
that it fails if end() does not close the GPU event.
- Make the copy test copy the category, not bind a reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* apply review suggestions
---------
Co-authored-by: Claude Opus 5 <[email protected]>
455 lines
16 KiB
C++
455 lines
16 KiB
C++
/*
|
|
* Copyright (C) Volition, Inc. 1999. All rights reserved.
|
|
*
|
|
* All source code herein is the property of Volition, Inc. You may not sell
|
|
* or otherwise commercially exploit the source or things you created based on the
|
|
* source.
|
|
*
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _OBJECT_H
|
|
#define _OBJECT_H
|
|
|
|
#include "globalincs/globals.h"
|
|
#include "globalincs/pstypes.h"
|
|
#include "math/vecmat.h"
|
|
#include "object/object_flags.h"
|
|
#include "physics/physics.h"
|
|
#include "physics/physics_state.h"
|
|
#include "io/timer.h" // prevents some include issues with files in the actions folder
|
|
#include "utils/event.h"
|
|
|
|
#include <functional>
|
|
|
|
/*
|
|
* CONSTANTS
|
|
*/
|
|
|
|
#define DEFAULT_SHIELD_SECTIONS 4 // Number of sections in standard shields.
|
|
|
|
#ifndef NDEBUG
|
|
#define OBJECT_CHECK
|
|
#endif
|
|
|
|
//Object types
|
|
#define OBJ_NONE 0 //unused object
|
|
#define OBJ_SHIP 1 //a ship
|
|
#define OBJ_WEAPON 2 //a laser, missile, etc
|
|
#define OBJ_FIREBALL 3 //an explosion
|
|
#define OBJ_START 4 //a starting point marker (player start, etc)
|
|
#define OBJ_WAYPOINT 5 //a waypoint object, maybe only ever used by Fred
|
|
#define OBJ_DEBRIS 6 //a flying piece of ship debris
|
|
//#define OBJ_CMEASURE 7 //a countermeasure, such as chaff
|
|
#define OBJ_GHOST 8 //so far, just a placeholder for when a player dies.
|
|
#define OBJ_POINT 9 // FRED2 briefing icons only; not used by QtFRED. Deprecate with FRED2.
|
|
#define OBJ_SHOCKWAVE 10 // a shockwave
|
|
#define OBJ_WING 11 // not really a type used anywhere, but I need it for Fred.
|
|
#define OBJ_OBSERVER 12 // used for multiplayer observers (possibly single player later)
|
|
#define OBJ_ASTEROID 13 // An asteroid, you know, a big rock, like debris, sort of.
|
|
#define OBJ_JUMP_NODE 14 // A jump node object, used only in Fred.
|
|
#define OBJ_BEAM 15 // beam weapons. we have to roll them into the object system to get the benefits of the collision pairs
|
|
#define OBJ_RAW_POF 16 // A raw pof file. has no physics, ai or anything. Currently only used in the Lab to render tech models
|
|
#define OBJ_PROP 17 // A prop object like a landscape. Similar to ships but is entirely non-interactable with the exception of collisions
|
|
|
|
//Make sure to change Object_type_names in Object.c when adding another type!
|
|
#define MAX_OBJECT_TYPES 18
|
|
|
|
#define UNUSED_OBJNUM (-MAX_OBJECTS*2) // Newer systems use this instead of -1 for invalid object.
|
|
|
|
extern const char *Object_type_names[MAX_OBJECT_TYPES];
|
|
|
|
// each object type should have these functions: (I will use weapon as example)
|
|
//
|
|
// int weapon_create( weapon specific parameters )
|
|
// {
|
|
// ...
|
|
// objnum = obj_create();
|
|
// ... Do some check to correctly handle obj_create returning which
|
|
// means that that object couldn't be created
|
|
// ... Initialize the weapon-specific info in Objects[objnum]
|
|
// return objnum;
|
|
// }
|
|
//
|
|
// void weapon_delete( object * obj )
|
|
// {
|
|
// {Put a call to this in OBJECT.C, function obj_delete_all_that_should_be_dead }
|
|
// WARNING: To kill an object, set it's OF_SHOULD_BE_DEAD flag. Then,
|
|
// this function will get called when it's time to clean up the data.
|
|
// Assert( obj->flags[Object::Object_Flags::Should_be_dead] );
|
|
// ...
|
|
// ... Free up all weapon-specfic data
|
|
// obj_delete(objnum);
|
|
// }
|
|
//
|
|
// void weapon_move( object * obj )
|
|
// {
|
|
// {Put a call to this in ??? }
|
|
// ... Do whatever needs to be done each frame. Usually this amounts
|
|
// to setting the thrust, seeing if we've died, etc.
|
|
// }
|
|
//
|
|
// int weapon_check_collision( object * obj, object * other_obj, vec3d * hitpos )
|
|
// {
|
|
// this should check if a vector from
|
|
// other_obj->last_pos to other_obj->pos with a radius of other_obj->radius
|
|
// collides with object obj. If it does, then fill in hitpos with the point
|
|
// of impact and return non-zero, otherwise return 0 if no impact. Note that
|
|
// this shouldn't take any action... that happens in weapon_hit.
|
|
// }
|
|
|
|
//
|
|
// void weapon_hit( object * obj, object * other_obj, vec3d * hitpos )
|
|
// {
|
|
// {Put a call to this in COLLIDE.C}
|
|
// ... Do what needs to be done when this object gets hit
|
|
// ... Reducing shields, etc
|
|
// }
|
|
|
|
typedef struct obj_flag_name {
|
|
Object::Object_Flags flag;
|
|
char flag_name[TOKEN_LENGTH];
|
|
} obj_flag_name;
|
|
|
|
typedef struct obj_flag_description {
|
|
Object::Object_Flags flag;
|
|
const char *flag_desc;
|
|
} obj_flag_description;
|
|
|
|
extern obj_flag_name Object_flag_names[];
|
|
extern obj_flag_description Object_flag_descriptions[];
|
|
extern const int Num_object_flag_names;
|
|
extern const size_t Num_object_flag_descriptions;
|
|
|
|
struct dock_instance;
|
|
class model_draw_list;
|
|
class polymodel;
|
|
struct polymodel_instance;
|
|
|
|
typedef struct raw_pof_obj {
|
|
int model_num; // The model number of the loaded POF
|
|
int model_instance; // The model instance
|
|
flagset<Object::Raw_Pof_Flags> flags; // Render flags
|
|
} raw_pof_obj;
|
|
|
|
extern SCP_map<int, raw_pof_obj> Pof_objects;
|
|
|
|
class object
|
|
{
|
|
public:
|
|
class object *next, *prev; // for linked lists of objects
|
|
int signature; // Every object ever has a unique signature...
|
|
char type; // what type of object this is... ship, weapon, debris, asteroid, fireball, see OBJ_* defines above
|
|
int parent; // This object's parent.
|
|
int parent_sig; // This object's parent's signature
|
|
int instance; // index into the corresponding type array, i.e. if type == OBJ_SHIP then instance indexes the Ships array
|
|
flagset<Object::Object_Flags> flags; // misc flags. Call obj_set_flags to change this.
|
|
vec3d pos; // absolute x,y,z coordinate of center of object
|
|
matrix orient; // orientation of object in world
|
|
float radius; // 3d size of object - for collision detection
|
|
vec3d last_pos; // where object was last frame
|
|
matrix last_orient; // how the object was oriented last frame
|
|
physics_info phys_info; // a physics object
|
|
SCP_vector<float> shield_quadrant; // Shield is broken into components, quadrants by default.
|
|
float hull_strength; // Remaining hull strength.
|
|
float sim_hull_strength; // Simulated hull strength - used with training weapons.
|
|
SCP_vector<int> objsnd_num; // Index of persistant sound struct.
|
|
ushort net_signature;
|
|
int num_pairs; // How many object pairs this is associated with. When 0 then there are no more.
|
|
|
|
dock_instance *dock_list; // Goober5000 - objects this object is docked to
|
|
dock_instance *dead_dock_list; // Goober5000 - objects this object was docked to when destroyed; replaces dock_objnum_when_dead
|
|
|
|
int collision_group_id; // This is a bitfield. Collision checks will be skipped if A->collision_group_id & B->collision_group_id returns nonzero
|
|
|
|
util::event<void, object*> pre_move_event;
|
|
util::event<void, object*> post_move_event;
|
|
|
|
void clear();
|
|
|
|
|
|
object();
|
|
~object();
|
|
|
|
// An object should never be copied; there are allocated pointers, and linked list shenanigans.
|
|
object(const object& other) = delete;
|
|
object& operator=(const object& other) = delete;
|
|
|
|
// Eventually we want to allow an object to be moved, especially when we get around to making Objects[] dynamic
|
|
object(object&& other) noexcept = delete;
|
|
object& operator=(object&& other) noexcept = delete;
|
|
};
|
|
|
|
struct lua_State;
|
|
namespace scripting {
|
|
class ade_table_entry;
|
|
}
|
|
namespace luacpp {
|
|
class LuaValue;
|
|
}
|
|
|
|
extern int Num_objects;
|
|
extern object Objects[];
|
|
|
|
struct object_h final // prevent subclassing because classes which might use this should have their own isValid member function
|
|
{
|
|
int objnum = -1;
|
|
int sig = -1;
|
|
|
|
object_h(const object* in_objp);
|
|
object_h(int in_objnum);
|
|
object_h();
|
|
|
|
bool isValid() const;
|
|
object* objp() const;
|
|
object* objp_or_null() const;
|
|
};
|
|
|
|
// object backup struct used by Fred.
|
|
typedef struct object_orient_pos {
|
|
vec3d pos;
|
|
matrix orient;
|
|
} object_orient_pos;
|
|
|
|
#ifdef OBJECT_CHECK
|
|
class checkobject
|
|
{
|
|
public:
|
|
int type;
|
|
int signature;
|
|
flagset<Object::Object_Flags> flags;
|
|
int parent_sig;
|
|
|
|
checkobject();
|
|
};
|
|
#endif
|
|
|
|
/*
|
|
* VARIABLES
|
|
*/
|
|
|
|
extern int Object_inited;
|
|
extern int Show_waypoints;
|
|
|
|
extern int Object_next_signature; // The next signature for the next newly created object. Zero is bogus
|
|
extern int Highest_object_index; //highest objnum
|
|
extern int Highest_ever_object_index;
|
|
|
|
extern object obj_free_list;
|
|
extern object obj_used_list;
|
|
extern object obj_create_list;
|
|
|
|
extern int render_total;
|
|
extern int render_order[MAX_OBJECTS];
|
|
|
|
extern object *Viewer_obj; // Which object is the viewer. Can be NULL.
|
|
extern object *Player_obj; // Which object is the player. Has to be valid.
|
|
|
|
// Use this instead of "objp - Objects" to get an object number
|
|
// given it's pointer. This way, we can replace it with a macro
|
|
// to check that the pointer is valid for debugging.
|
|
// This code will break in 64 bit builds when we have more than 2^31 objects but that will probably never happen
|
|
#define OBJ_INDEX(objp) (static_cast<int>((objp)-Objects))
|
|
|
|
/*
|
|
* FUNCTIONS
|
|
*/
|
|
|
|
//do whatever setup needs to be done
|
|
void obj_init();
|
|
|
|
void obj_shutdown();
|
|
|
|
//initialize a new object. adds to the list for the given segment.
|
|
//returns the object number. The object will be a non-rendering, non-physics
|
|
//object. Returns 0 if failed, otherwise object index.
|
|
//You can pass 0 for parent if you don't care about that.
|
|
//You can pass null for orient and/or pos if you don't care.
|
|
int obj_create(ubyte type, int parent_obj, int instance, const matrix *orient, const vec3d *pos, float radius, const flagset<Object::Object_Flags> &flags, bool essential = true);
|
|
|
|
void obj_render(object* obj);
|
|
|
|
void obj_queue_render(object* obj, model_draw_list* scene);
|
|
|
|
//Sorts and renders all the ojbects
|
|
void obj_render_all(const std::function<void(object*)>& render_function, bool* render_viewer_last );
|
|
|
|
//move all objects for the current frame
|
|
void obj_move_all(float frametime); // moves all objects
|
|
|
|
// function to delete an object -- should probably only be called directly from editor code
|
|
void obj_delete(int objnum);
|
|
|
|
void obj_delete_all();
|
|
|
|
void obj_delete_all_that_should_be_dead();
|
|
|
|
// should only be used by the editor!
|
|
void obj_merge_created_list(void);
|
|
|
|
// recalculate object pairs for an object
|
|
#define OBJ_RECALC_PAIRS(obj_to_reset) do { obj_set_flags(obj_to_reset, obj_to_reset->flags - Object::Object_Flags::Collides); obj_set_flags(obj_to_reset, obj_to_reset->flags + Object::Object_Flags::Collides); } while(false);
|
|
|
|
// Returns true if objects A and B are expected to collide in next duration seconds.
|
|
// For purposes of this check, the first object moves from current location to predicted
|
|
// location. The second object is assumed to be where it will be at time duration, NOT
|
|
// where it currently is.
|
|
// radius_scale: 0.0f means use polygon models, else scale sphere size by radius_scale
|
|
// radius_scale == 1.0f means Descent style collisions.
|
|
int objects_will_collide(object *A, object *B, float duration, float radius_scale);
|
|
|
|
// Used for pausing. Seems hacked. Was in PHYSICS, but that broke the TestCode program,
|
|
// so I moved it into the object lib. -John
|
|
void obj_init_all_ships_physics();
|
|
|
|
// Goober5000
|
|
float get_hull_pct(const object *objp, bool allow_negative = false);
|
|
float get_sim_hull_pct(const object *objp, bool allow_negative = false);
|
|
float get_shield_pct(const object *objp);
|
|
|
|
struct ship_registry_entry;
|
|
|
|
// SEXPs evaluated during debriefing are susceptible to a "use-after-free" problem where the object and ship have been deleted but still
|
|
// contain information useful for debriefing. Since the ship registry still contains object and ship indexes, use this rather than the
|
|
// instance and objnum indexes in the object and ship structures themselves.
|
|
float get_hull_pct(const ship_registry_entry *ship_entry, bool allow_negative = false);
|
|
float get_sim_hull_pct(const ship_registry_entry *ship_entry, bool allow_negative = false);
|
|
float get_shield_pct(const ship_registry_entry *ship_entry);
|
|
|
|
// returns the average 3-space position of all ships. useful to find "center" of battle (sort of)
|
|
void obj_get_average_ship_pos(vec3d *pos);
|
|
|
|
// function to deal with firing player things like lasers, missiles, etc.
|
|
// separated out because of multiplayer issues.
|
|
void obj_player_fire_stuff( object *objp, control_info ci );
|
|
|
|
// Call this if you want to change an object flag so that the
|
|
// object code knows what's going on. For instance if you turn
|
|
// off OF_COLLIDES, the object code needs to know this in order to
|
|
// actually turn the object collision detection off. By calling
|
|
// this you shouldn't get Int3's in the checkobject code. If you
|
|
// do, then put code in here to correctly handle the case.
|
|
void obj_set_flags(object *obj, const flagset<Object::Object_Flags>& new_flags);
|
|
|
|
// get the team for any object
|
|
int obj_team(object *objp);
|
|
|
|
void obj_move_all_pre(object *objp, float frametime);
|
|
void obj_move_all_post(object *objp, float frametime);
|
|
|
|
void obj_move_call_physics(object *objp, float frametime);
|
|
|
|
// move an observer object in multiplayer
|
|
void obj_observer_move(float frame_time);
|
|
|
|
/**
|
|
* @brief Checks if the given object is docked with anyone.
|
|
*
|
|
* @returns Nonzero if docked, or
|
|
* @returns 0 if not docked
|
|
*
|
|
* @author Goober5000
|
|
*/
|
|
int object_is_docked(object *objp);
|
|
|
|
/**
|
|
* @brief Checks if the given object is dead-docked with anyone.
|
|
*
|
|
* @returns Nonzero if docked, or
|
|
* @returns 0 if not docked
|
|
*
|
|
* @details An object is "dead-docked" when it is dying and still has objects docked to it. The dead_dock list is
|
|
* populated when the object dies, and is used later on to jettison and maybe damage the docked objects.
|
|
*
|
|
* @author Goober5000
|
|
*/
|
|
int object_is_dead_docked(object *objp);
|
|
|
|
/**
|
|
* @brief Moves a docked object to keep up with the parent object as it moves
|
|
*
|
|
* @param[in,out] objp The docked object
|
|
* @param[in] parent_objp The object that it's docked to
|
|
*
|
|
* @author Goober5000
|
|
*/
|
|
void obj_move_one_docked_object(object *objp, object *parent_objp);
|
|
|
|
//WMC
|
|
void object_set_gliding(object *objp, bool enable=true, bool force = false);
|
|
bool object_get_gliding(object *objp);
|
|
bool object_glide_forced(object* objp);
|
|
int obj_get_by_signature(int sig);
|
|
|
|
int object_get_model_num(const object *objp);
|
|
polymodel *object_get_model(const object *objp);
|
|
int object_get_model_instance_num(const object *objp);
|
|
polymodel_instance *object_get_model_instance(const object *objp);
|
|
|
|
void obj_render_queue_all();
|
|
|
|
/**
|
|
* @brief Compares two object pointers and determines if they refer to the same object
|
|
*
|
|
* @note Two @c nullptr parameters are considered equal
|
|
*
|
|
* @param left The first object pointer, may be @c nullptr
|
|
* @param right The second object pointer, may be @c nullptr
|
|
* @return @c true if the two pointers refer to the same object
|
|
*/
|
|
bool obj_compare(object *left, object *right);
|
|
|
|
////////////////////////////////////////////////////////////
|
|
// physics_state api functions that require the object type
|
|
|
|
/**
|
|
* @brief Populate a physics snapshot directly from the info in an object
|
|
*
|
|
* @param[in,out] snapshot Destination physics snapshot
|
|
* @param[in] objp The object pointer that we are pulling information from
|
|
*
|
|
* @author J Fernandez
|
|
*/
|
|
void physics_populate_snapshot(physics_snapshot& snapshot, const object* objp);
|
|
|
|
/**
|
|
* @brief Change the object's physics info to match the info contained in a snapshot.
|
|
*
|
|
* @param[in,out] objp Destination object pointer
|
|
* @param[in] source The physics snapshot we are pulling information from
|
|
*
|
|
* @details To be used when interpolating or restoring a game state.
|
|
*
|
|
* @author J Fernandez
|
|
*/
|
|
void physics_apply_pstate_to_object(object* objp, const physics_snapshot& source);
|
|
|
|
/**
|
|
*@brief create a raw pof instance
|
|
*
|
|
* @author Mike Nelson
|
|
*/
|
|
int obj_raw_pof_create(const char* pof_filename, const matrix* orient, const vec3d* pos);
|
|
|
|
/**
|
|
* @brief Occupancy snapshot of the object/ship/weapon pools, for the profiler overlay's memory panel
|
|
*
|
|
* @details These pools are fixed-size static arrays, so their footprint is a compile-time
|
|
* constant; what's actually useful to report is how full they are.
|
|
*/
|
|
struct object_memory_stats {
|
|
int objects_used = 0;
|
|
int objects_max = MAX_OBJECTS;
|
|
int objects_peak = 0;
|
|
|
|
int ships_used = 0;
|
|
int ships_max = MAX_SHIPS;
|
|
|
|
int weapons_used = 0;
|
|
int weapons_max = MAX_WEAPONS;
|
|
};
|
|
object_memory_stats obj_get_memory_stats();
|
|
|
|
#endif
|