Photon Quantum 3.0.0

Public Member Functions | Public Attributes | Protected Member Functions | Properties | List of all members
Quantum.Map Class Reference

The Quantum map is a Quantum asset that contains information about the level and is used by the deterministic simulation to drive gameplay. Only one map can be loaded at a time. More...

Inheritance diagram for Quantum.Map:
Quantum.DynamicMap

Public Member Functions

override void Disposed (IResourceManager resourceManager, Native.Allocator allocator)
 Called by the resource manager when the map asset was disposed to release memory. More...
 
void EnsurePhysicsWorldSizeInValidRange ()
 Post-process and clamp the physics world size. More...
 
NavMesh GetNavMesh (String name)
 Get namvesh by name. More...
 
Int32 GetStaticColliderTrianglesSerializedSize (bool isWriting)
 Get the serialized size of the static collider triangles data. More...
 
override void Loaded (IResourceManager resourceManager, Native.Allocator allocator)
 Called by the resource manager when the map asset was loaded. Used to deserialize map data allocate memory and initialize map data structures. More...
 
void SerializeStaticColliderTriangles (ByteStream stream, Native.Allocator allocator, Boolean write)
 Serialize or deserialize the static collider triangles data. More...
 

Public Attributes

UnmanagedTriangleArray AllRuntimeTriangles = new UnmanagedTriangleArray()
 The unmanaged buffer containing all static triangles for this map. More...
 
PhysicsCommon.BucketAxis BucketingAxis = PhysicsCommon.BucketAxis.X
 Physics entries are put into buckets according to their position in the bucketing axis. More...
 
Int32 BucketsCount = 16
 The amount of buckets used in the broad phase, which are resolved in parallel. Use a reasonable amount according to how many physics entries (colliders) you have. Too many buckets and the handling overhead increases without any performance gain because there are only few entries in each one; too few buckets and there will be an excessive amount of entries in each, slowing down the broad phase performance. More...
 
Int32 BucketsSubdivisions = 8
 Regular queries (overlaps and raycasts) use a stabbing approach for checking as few entries as possible in the buckets subdivisions. Tweak the number in accordance with the expected amount of entries and regular queries you perform. Too many subdivisions will add overhead without performance, while too few will result in queries taking longer to resolve, because they will have to check too many entries. More...
 
SortedDictionary< int, MeshTriangleVerticesCcw > CollidersManagedTriangles = new SortedDictionary<Int32, MeshTriangleVerticesCcw>()
 The edit-time lookup for 3D static collider triangles. More...
 
SortedDictionary< int, MeshUnmanagedTrianglesRefCollidersRuntimeTriangles = new SortedDictionary<Int32, MeshUnmanagedTrianglesRef>()
 The runtime lookup for 3D static collider triangles. More...
 
Int32 GridNodeSize = 4
 The number of Unity units per navmesh grid cell. Must be multiple of 2. More...
 
Int32 GridSizeX = 64
 Number of navmesh grid cells in x-dimension. Toggle Navmesh Grid or Navmesh Area gizmos to preview. More...
 
Int32 GridSizeY = 64
 Number of navmesh grid cells in y-dimension. Toggle Navmesh Grid or Navmesh Area gizmos to preview. More...
 
ComponentPrototypeSet[] MapEntities = Array.Empty<ComponentPrototypeSet>()
 The list of entities baked into this map. More...
 
Dictionary< String, NavMeshNavMeshes
 The lookup table for navmeshes. Use navmesh names to find the navmesh object. The mapping is created during the asset Loaded callback. More...
 
AssetRef< NavMesh >[] NavMeshLinks = Array.Empty<AssetRef<NavMesh>>()
 The list not navmesh assets baked into this map. More...
 
Dictionary< String, Int32 > RegionMap
 The region map lookup table. Use region names to find the region index. The mapping is created during the asset Loaded callback. More...
 
string[] Regions = Array.Empty<string>()
 The list of navmesh region names baked into this map. More...
 
String Scene
 The Unity scene name is baked into the map. It's loaded automatically if Simulation.AutoLoadSceneFromMap is enabled. More...
 
String SceneGuid
 The Unity scene guid is baked into the map for convenience. More...
 
FP SceneMeshCellSize = FP._4
 Defines the size of the cells into which the 3D triangle soup is divided. This number should be adapted based on how dense the meshes' triangles density to get a reasonable amount of triangles per cell. For better visualization enable related fields in the QuantumEditorSettings asset's Collider gizmos section. This will affect the performance of both the broad phase and regular queries. Use the Task Profiler to analyse the performance and find the most suitable number for your game. More...
 
String ScenePath
 The Unity scene path is baked into the map for convenience. More...
 
Int32 SerializedTriangleDataUncompressedSize
 How big the serialized triangle data is in uncompressed form. More...
 
Boolean SerializeTrianglesMetadata = false
 If triangles metadata should be serialized (true) or recomputed (false) More...
 
PhysicsCommon.SortAxis SortingAxis = PhysicsCommon.SortAxis.Y
 The queries in a bucket are sorted according to their position in the sorting axis. More...
 
MapStaticCollider2D[] StaticColliders2D = Array.Empty<MapStaticCollider2D>()
 All static 2D colliders baked into this map. More...
 
MapStaticCollider3D[] StaticColliders3D = Array.Empty<MapStaticCollider3D>()
 All static 3D colliders baked into this map. More...
 
SortedDictionary< int, TriangleCCW[]> StaticColliders3DTriangles => null
 Obsolete More...
 
AssetRef< BinaryDataStaticColliders3DTrianglesData
 Binary 3D triangle data is saved on an addition Quantum asset. More...
 
List< PolygonColliderRuntimeDataStaticPolygonColliderData = new List<PolygonColliderRuntimeData>()
 The list of static 2D polygon collider runtime data. More...
 
Int32 TriangleMeshCellSize = -1
 Obsolete. Use SceneMeshCellSize instead for representing the cell size with an FP value. More...
 
AssetRef UserAsset
 An optional generic asset reference that the map can be associated with. More...
 
Int32 WorldSize = 256
 The physics scene size in the bucketing axis. The broad phase is clamped by a bounding box of all physics entries between -WorldSize/2 to WorldSize/2. It is therefore crucial to ensure the world is big enough to encompass all entities. If an entity is outside the world, it will cost you performance as it is added to either the first or last bucket. Everything outside the bounding box is considered to be at the world's edge, from the physics engine perspective, which will result in false collision candidates. In the non bucketing axis, the physics world is only limited by the value range of FP.UsableMin to FP.UsableMax. More...
 

Protected Member Functions

virtual void InitializeStaticTriangles (IResourceManager resourceManager, Native.Allocator allocator)
 Initialize static 3D triangles. More...
 
virtual void ReadTrianglesFromBakeData (ByteStream stream, Native.Allocator allocator)
 Deserialize the static collider triangles data. More...
 
virtual void WriteTrianglesFromBakeData (ByteStream stream)
 Serialize the static collider triangles data. More...
 

Properties

Int32 WorldExtentX [get]
 The world extent in X-dimension that is covered by the Map.GridSizeX. Used by the navmesh system. More...
 
Int32 WorldExtentY [get]
 The world extent in Y-dimension that is covered by the Map.GridSizeY. Used by the navmesh system. More...
 
FPVector2 WorldOffset [get]
 The world offset. Used by the navmesh system. More...
 
Int32 WorldSizeX [get]
 The world size in X-dimension that is covered by the Map.GridSizeX. Used by the navmesh system. More...
 
Int32 WorldSizeY [get]
 The world size in Y-dimension that is covered by the Map.GridSizeY. Used by the navmesh system. More...
 

Detailed Description

The Quantum map is a Quantum asset that contains information about the level and is used by the deterministic simulation to drive gameplay. Only one map can be loaded at a time.

Member Function Documentation

◆ SerializeStaticColliderTriangles()

void Quantum.Map.SerializeStaticColliderTriangles ( ByteStream  stream,
Native.Allocator  allocator,
Boolean  write 
)
inline

Serialize or deserialize the static collider triangles data.

Parameters
streamInput stream
allocatorAllocator
writeWrite or read

◆ WriteTrianglesFromBakeData()

virtual void Quantum.Map.WriteTrianglesFromBakeData ( ByteStream  stream)
inlineprotectedvirtual

Serialize the static collider triangles data.

Parameters
streamThe stream to write to.

◆ ReadTrianglesFromBakeData()

virtual void Quantum.Map.ReadTrianglesFromBakeData ( ByteStream  stream,
Native.Allocator  allocator 
)
inlineprotectedvirtual

Deserialize the static collider triangles data.

Parameters
streamThe stream to read from.
allocatorThe Photon.Deterministic.Native.Allocator for this asset.

◆ GetStaticColliderTrianglesSerializedSize()

Int32 Quantum.Map.GetStaticColliderTrianglesSerializedSize ( bool  isWriting)
inline

Get the serialized size of the static collider triangles data.

Parameters
isWritingIf the stream is writing.
Returns
The amount of bytes the triangles occupy.

◆ Disposed()

override void Quantum.Map.Disposed ( IResourceManager  resourceManager,
Native.Allocator  allocator 
)
inline

Called by the resource manager when the map asset was disposed to release memory.

Parameters
resourceManagerResource manager
allocatorAllocator

◆ Loaded()

override void Quantum.Map.Loaded ( IResourceManager  resourceManager,
Native.Allocator  allocator 
)
inline

Called by the resource manager when the map asset was loaded. Used to deserialize map data allocate memory and initialize map data structures.

Parameters
resourceManagerResource manager
allocatorAllocator

◆ InitializeStaticTriangles()

virtual void Quantum.Map.InitializeStaticTriangles ( IResourceManager  resourceManager,
Native.Allocator  allocator 
)
inlineprotectedvirtual

Initialize static 3D triangles.

Parameters
resourceManagerThe resource manager for this asset.
allocatorThe Photon.Deterministic.Native.Allocator for this asset.

Reimplemented in Quantum.DynamicMap.

◆ GetNavMesh()

NavMesh Quantum.Map.GetNavMesh ( String  name)
inline

Get namvesh by name.

Parameters
nameNavmesh name
Returns
Navmesh asset or null.

◆ EnsurePhysicsWorldSizeInValidRange()

void Quantum.Map.EnsurePhysicsWorldSizeInValidRange ( )
inline

Post-process and clamp the physics world size.

Member Data Documentation

◆ UserAsset

AssetRef Quantum.Map.UserAsset

An optional generic asset reference that the map can be associated with.

◆ Scene

String Quantum.Map.Scene

The Unity scene name is baked into the map. It's loaded automatically if Simulation.AutoLoadSceneFromMap is enabled.

◆ ScenePath

String Quantum.Map.ScenePath

The Unity scene path is baked into the map for convenience.

◆ SceneGuid

String Quantum.Map.SceneGuid

The Unity scene guid is baked into the map for convenience.

◆ WorldSize

Int32 Quantum.Map.WorldSize = 256

The physics scene size in the bucketing axis. The broad phase is clamped by a bounding box of all physics entries between -WorldSize/2 to WorldSize/2. It is therefore crucial to ensure the world is big enough to encompass all entities. If an entity is outside the world, it will cost you performance as it is added to either the first or last bucket. Everything outside the bounding box is considered to be at the world's edge, from the physics engine perspective, which will result in false collision candidates. In the non bucketing axis, the physics world is only limited by the value range of FP.UsableMin to FP.UsableMax.

◆ BucketsCount

Int32 Quantum.Map.BucketsCount = 16

The amount of buckets used in the broad phase, which are resolved in parallel. Use a reasonable amount according to how many physics entries (colliders) you have. Too many buckets and the handling overhead increases without any performance gain because there are only few entries in each one; too few buckets and there will be an excessive amount of entries in each, slowing down the broad phase performance.

◆ BucketsSubdivisions

Int32 Quantum.Map.BucketsSubdivisions = 8

Regular queries (overlaps and raycasts) use a stabbing approach for checking as few entries as possible in the buckets subdivisions. Tweak the number in accordance with the expected amount of entries and regular queries you perform. Too many subdivisions will add overhead without performance, while too few will result in queries taking longer to resolve, because they will have to check too many entries.

◆ BucketingAxis

PhysicsCommon.BucketAxis Quantum.Map.BucketingAxis = PhysicsCommon.BucketAxis.X

Physics entries are put into buckets according to their position in the bucketing axis.

◆ SortingAxis

PhysicsCommon.SortAxis Quantum.Map.SortingAxis = PhysicsCommon.SortAxis.Y

The queries in a bucket are sorted according to their position in the sorting axis.

◆ SceneMeshCellSize

FP Quantum.Map.SceneMeshCellSize = FP._4

Defines the size of the cells into which the 3D triangle soup is divided. This number should be adapted based on how dense the meshes' triangles density to get a reasonable amount of triangles per cell. For better visualization enable related fields in the QuantumEditorSettings asset's Collider gizmos section. This will affect the performance of both the broad phase and regular queries. Use the Task Profiler to analyse the performance and find the most suitable number for your game.

◆ TriangleMeshCellSize

Int32 Quantum.Map.TriangleMeshCellSize = -1

Obsolete. Use SceneMeshCellSize instead for representing the cell size with an FP value.

◆ StaticColliders3DTrianglesData

AssetRef<BinaryData> Quantum.Map.StaticColliders3DTrianglesData

Binary 3D triangle data is saved on an addition Quantum asset.

◆ SerializeTrianglesMetadata

Boolean Quantum.Map.SerializeTrianglesMetadata = false

If triangles metadata should be serialized (true) or recomputed (false)

◆ GridSizeX

Int32 Quantum.Map.GridSizeX = 64

Number of navmesh grid cells in x-dimension. Toggle Navmesh Grid or Navmesh Area gizmos to preview.

◆ GridSizeY

Int32 Quantum.Map.GridSizeY = 64

Number of navmesh grid cells in y-dimension. Toggle Navmesh Grid or Navmesh Area gizmos to preview.

◆ GridNodeSize

Int32 Quantum.Map.GridNodeSize = 4

The number of Unity units per navmesh grid cell. Must be multiple of 2.

◆ NavMeshLinks

AssetRef<NavMesh> [] Quantum.Map.NavMeshLinks = Array.Empty<AssetRef<NavMesh>>()

The list not navmesh assets baked into this map.

◆ Regions

string [] Quantum.Map.Regions = Array.Empty<string>()

The list of navmesh region names baked into this map.

◆ StaticColliders2D

MapStaticCollider2D [] Quantum.Map.StaticColliders2D = Array.Empty<MapStaticCollider2D>()

All static 2D colliders baked into this map.

◆ StaticColliders3D

MapStaticCollider3D [] Quantum.Map.StaticColliders3D = Array.Empty<MapStaticCollider3D>()

All static 3D colliders baked into this map.

◆ MapEntities

ComponentPrototypeSet [] Quantum.Map.MapEntities = Array.Empty<ComponentPrototypeSet>()

The list of entities baked into this map.

◆ SerializedTriangleDataUncompressedSize

Int32 Quantum.Map.SerializedTriangleDataUncompressedSize

How big the serialized triangle data is in uncompressed form.

◆ CollidersManagedTriangles

SortedDictionary<int, MeshTriangleVerticesCcw> Quantum.Map.CollidersManagedTriangles = new SortedDictionary<Int32, MeshTriangleVerticesCcw>()

The edit-time lookup for 3D static collider triangles.

◆ CollidersRuntimeTriangles

SortedDictionary<int, MeshUnmanagedTrianglesRef> Quantum.Map.CollidersRuntimeTriangles = new SortedDictionary<Int32, MeshUnmanagedTrianglesRef>()

The runtime lookup for 3D static collider triangles.

◆ AllRuntimeTriangles

UnmanagedTriangleArray Quantum.Map.AllRuntimeTriangles = new UnmanagedTriangleArray()

The unmanaged buffer containing all static triangles for this map.

◆ StaticPolygonColliderData

List<PolygonColliderRuntimeData> Quantum.Map.StaticPolygonColliderData = new List<PolygonColliderRuntimeData>()

The list of static 2D polygon collider runtime data.

◆ NavMeshes

Dictionary<String, NavMesh> Quantum.Map.NavMeshes

The lookup table for navmeshes. Use navmesh names to find the navmesh object. The mapping is created during the asset Loaded callback.

◆ RegionMap

Dictionary<String, Int32> Quantum.Map.RegionMap

The region map lookup table. Use region names to find the region index. The mapping is created during the asset Loaded callback.

◆ StaticColliders3DTriangles

SortedDictionary<int, TriangleCCW[]> Quantum.Map.StaticColliders3DTriangles => null

Obsolete

Property Documentation

◆ WorldSizeX

Int32 Quantum.Map.WorldSizeX
get

The world size in X-dimension that is covered by the Map.GridSizeX. Used by the navmesh system.

◆ WorldSizeY

Int32 Quantum.Map.WorldSizeY
get

The world size in Y-dimension that is covered by the Map.GridSizeY. Used by the navmesh system.

◆ WorldExtentX

Int32 Quantum.Map.WorldExtentX
get

The world extent in X-dimension that is covered by the Map.GridSizeX. Used by the navmesh system.

◆ WorldExtentY

Int32 Quantum.Map.WorldExtentY
get

The world extent in Y-dimension that is covered by the Map.GridSizeY. Used by the navmesh system.

◆ WorldOffset

FPVector2 Quantum.Map.WorldOffset
get

The world offset. Used by the navmesh system.