This document provides a detailed reference for the C++ core API, primarily focusing on functions exposed to the C# adapter layer via P/Invoke.
- Data Structures and Enums
- General API Functions (
AgentSimApi.h) - C# Adapter API Reference (
UnityAdapter.cs)UnityAdapter.InitUnityAdapter.SetLODThresholdsUnityAdapter.RegisterAgentBehaviourUnityAdapter.UnregisterAgentBehaviourUnityAdapter.RegisterGameObjectUnityAdapter.UnregisterGameObjectUnityAdapter.GetGameObjectByIdUnityAdapter.AddAgentUnityAdapter.RemoveAgentUnityAdapter.GetAgentCountUnityAdapter.GetAgentPositionsUnityAdapter.GetAgentFSMStatesUnityAdapter.GetAgentDataWrapperUnityAdapter.ShutdownUnityAdapter.PopulateWorldSnapshotUnityAdapter.StepSimulationWrapperUnityAdapter.GenerateTestWorldSnapshotUnityAdapter.PopulateIncrementalWorldSnapshotAgentBehaviourAgentBehaviour.ApplyAgentCommand
enum LogLevel {
Trace = 0,
Debug = 1,
Info = 2,
Warn = 3,
Error = 4,
Critical = 5,
Off = 6
};- Description: Defines the severity levels for log messages originating from the C++ core. Used in conjunction with
SetLogCallbackto filter and categorize logs.
struct Vector3 {
float x, y, z;
};- Description: Represents a 3D vector or point in space. Used for positions, directions, and other spatial data.
struct Quaternion {
float x, y, z, w;
};- Description: Represents a rotation in 3D space.
enum class WorldObjectType : int {
NONE = 0,
TREE,
ROCK,
WATER,
FOOD,
SHELTER,
// Add more types as needed
};- Description: Categorizes different types of static or interactive objects in the simulated world.
enum class WorldEventType : int {
NONE = 0,
SOUND,
SMELL,
SIGHT,
TOUCH,
// Add more types as needed
};- Description: Categorizes different types of events that can occur in the simulated world, influencing agent perception.
enum class AgentState : int {
IDLE = 0,
WANDERING,
MOVING_TO_GOAL,
PERFORMING_ACTION,
PURSUING_GOAL,
// Add more states as needed
};- Description: Represents the high-level Finite State Machine (FSM) states an agent can be in.
enum class WorldProperty : int {
HAS_FOOD = 0,
HAS_SHELTER,
IS_THIRSTY,
IS_HUNGRY,
IS_TIRED,
IS_SAFE,
HAS_AXE,
HAS_WOOD,
// Add more world properties as needed
};- Description: Defines various boolean properties that describe the state of an agent's understanding of the world or its personal needs. Used in GOAP planning.
// Using a fixed-size bitset for agent world state conditions
// Max 64 properties for now to fit in a uint64_t
using AgentWorldState = std::bitset<64>;- Description: A bitset representing an agent's current perception of the world state and its internal needs based on
WorldPropertyvalues. Each bit corresponds to aWorldProperty.
struct WorldObject {
int id;
WorldObjectType type;
Vector3 position;
Quaternion rotation;
// Add other relevant properties like health, interactable state, etc.
};- Description: Represents a single observable object in the world. Its data is typically managed by the C# engine and passed to the C++ core.
struct WorldEvent {
int id;
WorldEventType type;
Vector3 position;
float severity; // e.g., loudness for sound, intensity for smell
// Add other relevant properties like duration, source, etc.
};- Description: Represents a single event occurring in the world. Its data is typically managed by the C# engine and passed to the C++ core.
struct WorldSnapshot {
long long timestamp; // Time in milliseconds or simulation ticks
WorldObject* worldObjects;
int numWorldObjects;
WorldEvent* worldEvents;
int numWorldEvents;
// Global world properties
Vector3 sunDirection;
float timeOfDay; // 0.0 to 24.0
// Add other global properties like weather, global resource counts, etc.
};- Description: A comprehensive snapshot of the entire world state at a given time. This structure is typically populated by the C# layer and passed to the C++ core for processing during simulation updates. Memory for
worldObjectsandworldEventsis owned by the C# side.
struct IncrementalWorldSnapshot {
long long timestamp;
// World Objects
WorldObject* addedObjects;
int addedObjectCount;
int* removedObjectIds;
int removedObjectIdCount;
WorldObject* modifiedObjects;
int modifiedObjectCount;
// World Events
WorldEvent* addedEvents;
int addedEventCount;
int* removedEventIds;
int removedEventIdCount;
};- Description: Represents changes to the world state incrementally, containing only objects and events that have been added, removed, or modified since the last snapshot. This is used for optimizing data transfer between C# and C++. Memory for all pointers is owned by the C# side.
struct AgentDebugData {
int agentId;
int lodTier;
int currentGoal;
int fsmState;
Vector3 targetPosition;
const char* currentActionName;
};- Description: A structure used to retrieve detailed debug information about an individual agent from the C++ core. Populated by the C++ core and read by the C# layer for visualization or debugging.
struct Vector2Int {
int x, y;
};- Description: Represents a 2D integer vector, typically used for grid coordinates or similar integer-based spatial data.
struct SimulationStageTimings {
long long worldQueryUpdateMs;
long long totalAgentUpdateMs;
long long perceptionMs;
long long planningMs;
long long executionMs;
long long stateUpdateMs;
};- Description: Provides detailed timing information (in milliseconds) for various stages of the simulation update loop, useful for performance profiling and optimization.
enum class AgentCommandType {
NONE,
MOVE_TO,
ARRIVED_AT_POSITION,
INTERACT_WITH_OBJECT,
PLAY_ANIMATION,
CHANGE_STATE,
PERFORM_ACTION
// ... more command types
};- Description: Defines the types of commands an agent can issue to the game engine. These commands instruct the engine on how to visually or physically represent the agent's actions and states. This enum has a direct C# counterpart (
AgentSimMiddleware.AgentCommandType) with slightly different enum member names (e.g.,MOVE_TOin C++ isMOVE_TO_POSITIONin C#).
struct AgentCommand {
int agentId;
AgentCommandType commandType;
Vector3 targetPosition;
int targetObjectId;
const char* animationName;
int newState;
};- Description: Represents a single command generated by the C++ core for a specific agent, to be processed by the C# game engine. The fields used depend on the
commandType. ForanimationName, the C++ side provides aconst char*, which is marshaled to aIntPtrin the C#AgentCommandstruct (AgentSimMiddleware.AgentCommand). The C# struct provides anAnimationNameproperty to convertIntPtrtostring.
enum LogLevel {
Trace = 0,
Debug = 1,
Info = 2,
Warn = 3,
Error = 4,
Critical = 5,
Off = 6
};- Description: Defines the severity levels for log messages originating from the C++ core. This enum has a direct C# counterpart (
AgentSimMiddleware.UnityAdapter.LogLevel) used for logging integration.
struct Vector3 {
float x, y, z;
};- Description: Represents a 3D vector or point in space. Used for positions, directions, and other spatial data. This struct has a direct C# counterpart (
AgentSimMiddleware.Vector3).
struct Quaternion {
float x, y, z, w;
};- Description: Represents a rotation in 3D space. This struct has a direct C# counterpart (
AgentSimMiddleware.Quaternion).
enum class WorldObjectType : int {
NONE = 0,
TREE,
ROCK,
WATER,
FOOD,
SHELTER,
// Add more types as needed
};- Description: Categorizes different types of static or interactive objects in the simulated world. This enum has a direct C# counterpart (
AgentSimMiddleware.WorldObjectType). The C# version may contain additional types beyond what the C++ core is compiled to understand; the C++ core will only process types it explicitly knows.
enum class WorldEventType : int {
NONE = 0,
SOUND,
SMELL,
SIGHT,
TOUCH,
// Add more types as needed
};- Description: Categorizes different types of events that can occur in the simulated world, influencing agent perception. This enum has a direct C# counterpart (
AgentSimMiddleware.WorldEventType). Similar toWorldObjectType, the C# version may define more event types than the C++ core explicitly handles.
enum class AgentState : int {
IDLE = 0,
WANDERING,
MOVING_TO_GOAL,
PERFORMING_ACTION,
PURSUING_GOAL,
// Add more states as needed
};- Description: Represents the high-level Finite State Machine (FSM) states an agent can be in. This enum has a direct C# counterpart (
AgentSimMiddleware.AgentState).
enum class WorldProperty : int {
HAS_FOOD = 0,
HAS_SHELTER,
IS_THIRSTY,
IS_HUNGRY,
IS_TIRED,
IS_SAFE,
HAS_AXE,
HAS_WOOD,
// Add more world properties as needed
};- Description: Defines various boolean properties that describe the state of an agent's understanding of the world or its personal needs. Used in GOAP planning. This enum has a direct C# counterpart (
AgentSimMiddleware.WorldProperty).
// Using a fixed-size bitset for agent world state conditions
// Max 64 properties for now to fit in a uint64_t
using AgentWorldState = std::bitset<64>;- Description: A bitset representing an agent's current perception of the world state and its internal needs based on
WorldPropertyvalues. Each bit corresponds to aWorldProperty. This type is marshaled as aulongin C#.
struct WorldObject {
int id;
WorldObjectType type;
Vector3 position;
Quaternion rotation;
// Add other relevant properties like health, interactable state, etc.
};- Description: Represents a single observable object in the world. Its data is typically managed by the C# engine and passed to the C++ core. This struct has a direct C# counterpart (
AgentSimMiddleware.WorldObject).
struct WorldEvent {
int id;
WorldEventType type;
Vector3 position;
float severity; // e.g., loudness for sound, intensity for smell
// Add other relevant properties like duration, source, etc.
};- Description: Represents a single event occurring in the world. Its data is typically managed by the C# engine and passed to the C++ core. This struct has a direct C# counterpart (
AgentSimMiddleware.WorldEvent).
struct WorldSnapshot {
long long timestamp; // Time in milliseconds or simulation ticks
WorldObject* worldObjects;
int numWorldObjects;
WorldEvent* worldEvents;
int numWorldEvents;
// Global world properties
Vector3 sunDirection;
float timeOfDay; // 0.0 to 24.0
// Add other global properties like weather, global resource counts, etc.
};- Description: A comprehensive snapshot of the entire world state at a given time. This structure is typically populated by the C# layer and passed to the C++ core for processing during simulation updates. Memory for
worldObjectsandworldEventsis owned by the C# side. This struct has a direct C# counterpart (AgentSimMiddleware.WorldSnapshot) which handles marshaling of pointers.
struct IncrementalWorldSnapshot {
long long timestamp;
// World Objects
WorldObject* addedObjects;
int addedObjectCount;
int* removedObjectIds;
int removedObjectIdCount;
WorldObject* modifiedObjects;
int modifiedObjectCount;
// World Events
WorldEvent* addedEvents;
int addedEventCount;
int* removedEventIds;
int removedEventIdCount;
};- Description: Represents changes to the world state incrementally, containing only objects and events that have been added, removed, or modified since the last snapshot. This is used for optimizing data transfer between C# and C++. Memory for all pointers is owned by the C# side. This struct has a C# counterpart (
AgentSimMiddleware.UnityAdapter.IncrementalWorldSnapshot) which usesIntPtrfor arrays, requiring careful marshaling.
struct AgentDebugData {
int agentId;
int lodTier;
int currentGoal;
int fsmState;
Vector3 targetPosition;
const char* currentActionName;
};- Description: A structure used to retrieve detailed debug information about an individual agent from the C++ core. Populated by the C++ core and read by the C# layer for visualization or debugging. The
currentActionNamefield requires manual string marshaling in C#.
struct Vector2Int {
int x, y;
};- Description: Represents a 2D integer vector, typically used for grid coordinates or similar integer-based spatial data. This struct has a direct C# counterpart (
AgentSimMiddleware.Vector2Int).
struct SimulationStageTimings {
long long worldQueryUpdateMs;
long long totalAgentUpdateMs;
long long perceptionMs;
long long planningMs;
long long executionMs;
long long stateUpdateMs;
};- Description: Provides detailed timing information (in milliseconds) for various stages of the simulation update loop, useful for performance profiling and optimization. This struct has a direct C# counterpart (
AgentSimMiddleware.SimulationStageTimings).
enum class AgentCommandType {
NONE,
MOVE_TO,
ARRIVED_AT_POSITION,
INTERACT_WITH_OBJECT,
PLAY_ANIMATION,
CHANGE_STATE,
PERFORM_ACTION
// ... more command types
};- Description: Defines the types of commands an agent can issue to the game engine. These commands instruct the engine on how to visually or physically represent the agent's actions and states. This enum has a direct C# counterpart (
AgentSimMiddleware.AgentCommandType).
struct AgentCommand {
int agentId;
AgentCommandType commandType;
Vector3 targetPosition;
int targetObjectId;
const char* animationName;
int newState;
};- Description: Represents a single command generated by the C++ core for a specific agent, to be processed by the C# game engine. The fields used depend on the
commandType. ForanimationName, the C# side must copy the string if it needs to persist beyond the current frame. This struct has a direct C# counterpart (AgentSimMiddleware.AgentCommand) which handles string marshaling.
enum class Goal {
GATHER_WOOD,
GET_FOOD,
SATISFY_THIRST,
REACH_TARGET,
FIND_TREE,
GO_TO_NEAREST_FOOD_SOURCE,
COUNT
};- Description: Defines predefined goals that agents can pursue within the simulation. These goals are used in the GOAP planning system. This enum has a direct C# counterpart (
AgentSimMiddleware.Goal).
public struct AgentDisplayData {
public int agentId;
public int lodTier;
public int currentGoal;
public int fsmState;
public Vector3 targetPosition;
public string currentActionName;
}- Description: A C# specific structure used to display agent debug information. It is a convenience wrapper around the raw C++
AgentDebugDatawith thecurrentActionNamestring already marshaled for easier consumption in C#.
AGENTSIM_API void GetLastSimulationTimings(AgentContainer* container, SimulationStageTimings* outTimings);- Description: Retrieves the performance timings for the various stages of the last simulation update.
- Parameters:
container: A pointer to theAgentContainerinstance.outTimings: A pointer to aSimulationStageTimingsstruct that will be populated with the timing data.
- Returns:
void
The AgentSimMiddleware.UnityAdapter class provides the primary interface for Unity to interact with the native C++ simulation core. It handles marshaling data between C# and C++, manages agent lifecycle, and facilitates world state synchronization.
public static bool Init(int maxAgents, string goapJsonFilePath)- Description: Initializes the C++ simulation core and sets up the necessary communication channels. This must be called before any other simulation-related functions.
- Parameters:
maxAgents: The maximum number of agents the simulation is configured to handle.goapJsonFilePath: The path to the GOAP JSON file (e.g., "Data/actions_goals") within Unity'sResourcesfolder, containing definitions for actions and goals.
- Returns:
trueif the simulation was initialized successfully,falseotherwise.
public static void SetLODThresholds(float fullSimDistance, float liteSimDistance)- Description: Configures the Level-of-Detail (LOD) distance thresholds for the C++ simulation. Agents within
fullSimDistancewill be fully simulated, and those withinliteSimDistance(but outsidefullSimDistance) will be lightly simulated. - Parameters:
fullSimDistance: The distance from the camera within which agents receive full simulation updates.liteSimDistance: The distance from the camera within which agents receive lighter simulation updates.
- Returns:
void
public static void RegisterAgentBehaviour(int agentId, AgentBehaviour agentBehaviour)- Description: Registers an
AgentBehaviourinstance with the adapter, associating it with a specific agent ID from the C++ core. This allows the adapter to dispatchAgentCommands to the correct UnityGameObject. - Parameters:
agentId: The unique ID of the agent in the C++ simulation.agentBehaviour: TheAgentBehaviourcomponent associated with the Unity representation of the agent.
- Returns:
void
public static void UnregisterAgentBehaviour(int agentId)- Description: Unregisters an
AgentBehaviourinstance, typically called when an agent is removed from the simulation or its corresponding UnityGameObjectis destroyed. - Parameters:
agentId: The unique ID of the agent to unregister.
- Returns:
void
public static void RegisterGameObject(int id, GameObject gameObject)- Description: Registers a
GameObjectwith its instance ID, allowing the adapter to retrieveGameObjects by their ID for world snapshot generation or command processing. - Parameters:
id: The UnityInstance IDof theGameObject.gameObject: TheGameObjectto register.
- Returns:
void
public static void UnregisterGameObject(int id)- Description: Unregisters a
GameObjectfrom the internal lookup, typically called when aGameObjectis destroyed. - Parameters:
id: The UnityInstance IDof theGameObjectto unregister.
- Returns:
void
public static GameObject GetGameObjectById(int id)- Description: Retrieves a registered
GameObjectby its instance ID. - Parameters:
id: The UnityInstance IDof theGameObject.
- Returns: The
GameObjectif found, otherwisenull.
public static int AddAgent(Vector3 initialPos, Quaternion initialRot, int initialGoal, int initialState)- Description: Adds a new agent to the C++ simulation. This is a convenience wrapper around the native
AddAgentfunction, automatically using the activeAgentContainerhandle. - Parameters:
initialPos: The initial position of the agent in world coordinates.initialRot: The initial rotation of the agent.initialGoal: The initial goal ID for the agent (fromGoalenum).initialState: The initial state ID for the agent (fromAgentStateenum).
- Returns: The unique ID of the newly added agent, or -1 on failure.
public static void RemoveAgent(int agentId)- Description: Removes an agent from the C++ simulation. This is a convenience wrapper around the native
RemoveAgentfunction. - Parameters:
agentId: The ID of the agent to be removed.
- Returns:
void
public static int GetAgentCount()- Description: Retrieves the current number of active agents in the C++ simulation. This is a convenience wrapper around the native
GetAgentCountfunction. - Returns: The number of active agents.
public static void GetAgentPositions([Out] Vector3[] positions, ref int count)- Description: Populates an array with the current positions of all active agents from the C++ simulation. This is a convenience wrapper around the native
GetAgentPositionsfunction. - Parameters:
positions: A pre-allocated array ofVector3structs where agent positions will be written.count: On input, specifies the maximum capacity of thepositionsarray; on output, will be updated with the actual number of positions written.
- Returns:
void
public static void GetAgentFSMStates([Out] int[] states, ref int count)- Description: Populates an array with the current FSM states of all active agents from the C++ simulation. This is a convenience wrapper around the native
GetAgentFSMStatesfunction. - Parameters:
states: A pre-allocated array of integers where agent FSM states will be written.count: On input, specifies the maximum capacity of thestatesarray; on output, will be updated with the actual number of states written.
- Returns:
void
public static AgentDisplayData[] GetAgentDataWrapper()- Description: Retrieves detailed debug data for all active agents, including ID, LOD tier, current goal, FSM state, target position, and current action name. It marshals the string data from C++ for easier consumption in C#.
- Returns: An array of
AgentDisplayDatastructs.
public static void Shutdown()- Description: Shuts down the C++ simulation and cleans up all associated resources. This should be called when the Unity application exits or the simulation is no longer needed.
- Returns:
void
public static WorldSnapshot PopulateWorldSnapshot()- Description: Collects the current world state from the Unity scene (e.g., positions of tagged GameObjects) and populates a
WorldSnapshotstruct. This snapshot is then passed to the C++ core for perception and simulation updates. - Returns: A populated
WorldSnapshotstruct.
public static void StepSimulationWrapper(float deltaTime, Vector3 cameraPosition)- Description: Advances the C++ agent simulation by one step using an incremental world snapshot. It collects changes from the Unity world, passes them to the C++ core, and then processes the
AgentCommands received back from the core to update agent behaviors in Unity. - Parameters:
deltaTime: The time elapsed since the last simulation step, in seconds.cameraPosition: The current position of the main camera, used for LOD calculations.
- Returns:
void
public static WorldSnapshot GenerateTestWorldSnapshot()- Description: Generates a
WorldSnapshotcontaining dummy data for testing purposes. This can be used to provide a simulated world state to the C++ core without requiring a fully populated Unity scene. - Returns: A
WorldSnapshotstruct populated with test data.
public static IncrementalWorldSnapshot PopulateIncrementalWorldSnapshot()- Description: Populates an
IncrementalWorldSnapshotby comparing the current Unity world state with the state from the previous frame. This allows for efficient transfer of only changed world data to the C++ core. - Returns: An
IncrementalWorldSnapshotstruct containing only the changes. Note that the pointers within this struct must be explicitly freed after use to prevent memory leaks (handled internally byStepSimulationWrapper).
public class AgentBehaviour : MonoBehaviour- Description: A Unity
MonoBehaviourscript that attaches to agentGameObjects in the scene. It acts as the visual and interactive representation of an agent, receiving commands from the C++ core and updating its UnityGameObjectaccordingly. - Properties:
AgentId: An integer representing the unique ID of the agent in the C++ simulation. This is typically set in the Unity Inspector.
public void ApplyAgentCommand(AgentCommand command)- Description: Processes a single
AgentCommandreceived from the C++ simulation. This method updates the agent'sGameObjectin Unity based on the command type (e.g., moves the agent, triggers an animation, or changes its visual state). - Parameters:
command: TheAgentCommandto be applied.
- Returns:
void
These functions are directly exposed from the C++ core DLL for interoperability with C# (e.g., Unity).
AGENTSIM_API AgentContainer* CreateAgentContainer(int maxAgents, const char* goapJsonContent);- Description: Initializes the core agent simulation and creates an
AgentContainerinstance. This function sets up necessary internal structures and loads initial GOAP data. - Parameters:
maxAgents: The maximum number of agents the simulation is configured to handle.goapJsonContent: A null-terminated C-style string containing the JSON data for GOAP actions and goals.
- Returns: A pointer to the initialized
AgentContainer. This handle must be passed to subsequent API calls. Returnsnullptron failure.
AGENTSIM_API void DestroyAgentContainer(AgentContainer* container);- Description: Shuts down the agent simulation and cleans up all allocated resources associated with the provided
AgentContainer. - Parameters:
container: A pointer to theAgentContainerinstance to be shut down.
- Returns:
void
AGENTSIM_API void SetLogCallback(LogCallbackFn callback);- Description: Sets a callback function in the C++ core that will be invoked for logging messages. This allows C# to receive and process log output from the native C++ simulation.
- Parameters:
callback: A function pointer (LogCallbackFn) to a C# method that matches the signaturevoid (*LogCallbackFn)(LogLevel level, const char* message). TheLogLevelenum maps to corresponding Unity log types.
- Returns:
void
AGENTSIM_API void SetLODThresholds(AgentContainer* container, float fullSimDistance, float liteSimDistance);- Description: Configures the Level-of-Detail (LOD) thresholds for agent simulation. Agents within
fullSimDistancewill be fully simulated, and those withinliteSimDistance(but outsidefullSimDistance) will be lightly simulated. - Parameters:
container: A pointer to theAgentContainerinstance.fullSimDistance: The distance from the camera within which agents receive full simulation updates.liteSimDistance: The distance from the camera within which agents receive lighter simulation updates.
- Returns:
void
AGENTSIM_API int GetGoalIdByName(AgentContainer* container, const char* goalName);- Description: Retrieves the integer ID associated with a GOAP goal given its string name. This allows C# to reference goals by a stable ID.
- Parameters:
container: A pointer to theAgentContainerinstance.goalName: A null-terminated C-style string representing the name of the goal.
- Returns: The integer ID of the goal, or -1 if the goal name is not found.
AGENTSIM_API void SetVerboseMode(bool enabled);- Description: Enables or disables verbose logging within the C++ core. When enabled, more detailed debug information will be output via the registered log callback.
- Parameters:
enabled: A boolean value;trueto enable verbose mode,falseto disable.
- Returns:
void
AGENTSIM_API int AddAgent(AgentContainer* container, Vector3 initialPos, Quaternion initialRot, int initialGoal, int initialState);- Description: Adds a new agent to the simulation with specified initial properties.
- Parameters:
container: A pointer to theAgentContainerinstance.initialPos: The initial position of the agent in world coordinates.initialRot: The initial rotation of the agent.initialGoal: The initial goal ID for the agent (mapped toGoalenum or its equivalent).initialState: The initial state ID for the agent (mapped toAgentStateenum).
- Returns: The unique ID of the newly added agent, or -1 on failure.
AGENTSIM_API void Update(AgentContainer* container, float deltaTime, const Vector3& cameraPosition, const WorldSnapshot* snapshot, AgentCommand* agentCommands, int* commandCount, int maxCommandCapacity);- Description: Advances the agent simulation by one step using a full
WorldSnapshot. This is the main update function called each frame from the engine. It processes the current world state, updates agents, and generates commands for the engine. - Parameters:
container: A pointer to theAgentContainerinstance.deltaTime: The time elapsed since the last simulation step, in seconds.cameraPosition: The current position of the main camera in the engine, used for Level-of-Detail (LOD) calculations.snapshot: A pointer to aWorldSnapshotstruct containing the current full state of the game world (objects, events, etc.).agentCommands: An array ofAgentCommandstructs pre-allocated by C# to receive commands from the C++ core.commandCount: A pointer to an integer that will be updated by the C++ core to indicate the number ofAgentCommands written to theagentCommandsarray.maxCommandCapacity: The maximum number ofAgentCommands that theagentCommandsarray can hold.
- Returns:
void
AGENTSIM_API void StepSimulationIncremental(AgentContainer* container, float deltaTime, const IncrementalWorldSnapshot* incrementalSnapshot, AgentCommand* agentCommands, int* commandCount, int maxCommandCapacity, const Vector3& cameraPosition);- Description: Advances the agent simulation by one step using an
IncrementalWorldSnapshot. This function is an optimized alternative toUpdatewhen only a subset of world data has changed. - Parameters:
container: A pointer to theAgentContainerinstance.deltaTime: The time elapsed since the last simulation step, in seconds.incrementalSnapshot: A pointer to anIncrementalWorldSnapshotstruct containing only the changes to the world state.agentCommands: An array ofAgentCommandstructs pre-allocated by C# to receive commands from the C++ core.commandCount: A pointer to an integer that will be updated by the C++ core to indicate the number ofAgentCommands written to theagentCommandsarray.maxCommandCapacity: The maximum number ofAgentCommands that theagentCommandsarray can hold.cameraPosition: The current position of the main camera in the engine, used for Level-of-Detail (LOD) calculations.
- Returns:
void
AGENTSIM_API void GetLastSimulationTimings(AgentContainer* container, SimulationStageTimings* outTimings);- Description: Retrieves the performance timings for the various stages of the last simulation update.
- Parameters:
container: A pointer to theAgentContainerinstance.outTimings: A pointer to aSimulationStageTimingsstruct that will be populated with the timing data.
- Returns:
void