// We have only Update method for explosions, because drawing of explosion is mantained by particles and lights itself public override void UpdateBeforeSimulation() { SwapBuffers(); foreach (var explosionInfo in m_explosionsRead) { MyExplosion explosion = null; m_explosions.AllocateOrCreate(out explosion); if (explosion != null) { explosion.Start(explosionInfo); } } m_explosionsRead.Clear(); // Go over every active explosion and draw it, unless it isn't dead. foreach (var explosion in m_explosions.Active) { if (explosion.Update() == false) { m_explosions.MarkForDeallocate(explosion); } } // Deallocate/delete all lights that are turned off m_explosions.DeallocateAllMarked(); }
internal static MyCullProxy CreateCullProxy() { MyCullProxy item; m_cullProxyPool.AllocateOrCreate(out item); return(item); }
public static T Allocate1 <T>(this MyObjectsPool <T> pool) where T : class, new() { T result; pool.AllocateOrCreate(out result); return(result); }
internal static MyRenderableProxy CreateRenderableProxy() { MyRenderableProxy item; m_rendrableProxyPool.AllocateOrCreate(out item); //item.geometry = null; item.Mesh = LodMeshId.NULL; item.Instancing = InstancingId.NULL; item.DepthShaders = MyMaterialShadersBundleId.NULL; item.Shaders = MyMaterialShadersBundleId.NULL; //item.depthOnlyShaders = null; //item.shaders = null; item.skinningMatrices = null; //item.depthOnlySubmeshes = null; //item.submeshes = null; item.instanceCount = 0; item.flags = 0; item.type = MyMaterialType.OPAQUE; item.objectBuffer = null; item.Parent = null; item.Lod = 0; return(item); }
public IUserGeneratedTexture NewUserTexture(string name, int width, int height, MyGeneratedTextureType type, int numMipLevels) { MyUserGeneratedTexture texture; m_objectsPoolGenerated.AllocateOrCreate(out texture); switch (type) { case MyGeneratedTextureType.RGBA: CreateRGBA(texture, name, new Vector2I(width, height), true, (byte[])null, true, numMipLevels); break; case MyGeneratedTextureType.RGBA_Linear: CreateRGBA(texture, name, new Vector2I(width, height), false, (byte[])null, true, numMipLevels); break; case MyGeneratedTextureType.Alphamask: CreateR(texture, name, new Vector2I(width, height), null, true, numMipLevels); break; default: throw new Exception(); } m_statistics.Add(texture); return(texture); }
// Get new preallocated content from the buffer. // We don't check for size, because it must be done by higher game logic (reinicializing too destroyed level). public static MyVoxelContentCellContent Allocate() { MyVoxelContentCellContent content; m_pool.AllocateOrCreate(out content); return(content); }
internal IDepthArrayTexture CreateDepthCube(string debugName, int size, Format resourceFormat, Format srvFormat, Format dsvFormat, int mipmapLevels = 1) { MyRenderProxy.Assert(size > 0); MyRenderProxy.Assert(mipmapLevels > 0); MyDepthArrayTexture tex; m_depthArrays.AllocateOrCreate(out tex); Texture2DDescription desc = new Texture2DDescription { ArraySize = 6, BindFlags = BindFlags.ShaderResource | BindFlags.DepthStencil, CpuAccessFlags = CpuAccessFlags.None, Format = resourceFormat, Height = size, MipLevels = mipmapLevels, OptionFlags = ResourceOptionFlags.TextureCube, SampleDescription = { Count = 1, Quality = 0 }, Usage = ResourceUsage.Default, Width = size }; ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription { Format = srvFormat, Dimension = ShaderResourceViewDimension.TextureCube, TextureCube = { MipLevels = mipmapLevels, MostDetailedMip = 0 } }; tex.InitDepth(debugName, desc, srvDesc, dsvFormat); if (m_isDeviceInit) { tex.OnDeviceInit(); } return(tex); }
/// <remarks>On big loops, or whenever recommendable, cache the returned reference</remarks> public ITexture GetTexture(string name, MyFileTextureEnum type, bool waitTillLoaded = false, bool skipQualityReduction = false) { if (name == null || name.Length <= 0) { return(ReturnDefaultTexture(type)); } Uri uri; if (!MyResourceUtils.NormalizeFileTextureName(ref name, out uri)) { IGeneratedTexture texture; if (m_generatedTextures.TryGetValue(name, out texture)) { return(texture); } else { MyRenderProxy.Assert(false, "Can't find generated texture with name \"" + name + "\""); return(ReturnDefaultTexture(type)); } } MyFileTexture texOut; if (!m_textures.TryGetValue(name, out texOut)) { if (uri.Scheme != FILE_SCHEME) { Debug.Assert(false, "Cannot initialize a non file texture"); return(ReturnDefaultTexture(type)); } m_texturesPool.AllocateOrCreate(out texOut); texOut.Init(name, uri.LocalPath, type, waitTillLoaded, skipQualityReduction); m_textures.Add(name, texOut); } switch (texOut.TextureState) { case FileTextureState.Unloaded: case FileTextureState.Requested: if (waitTillLoaded) { LoadInternal(name); } else { texOut.TextureState = FileTextureState.Requested; m_requestedTextures.Add(name); } break; case FileTextureState.Loaded: break; } return(texOut); }
public ISingleShadowmap CreateSingleShadowmap(int texSize) { MySingleShadowmap shadowmap; m_objectsPoolSingleShadowmap.AllocateOrCreate(out shadowmap); shadowmap.Init(texSize); return(shadowmap); }
internal static MyCullProxy_2 Allocate() { MyCullProxy_2 cullProxy2 = null; Pool.AllocateOrCreate(out cullProxy2); cullProxy2.Construct(); return(cullProxy2); }
internal static MyActor Create() { MyActor item; m_pool.AllocateOrCreate(out item); item.Construct(); return(item); }
// Add new projectile to the list public static void Add(MyProjectileAmmoDefinition ammoDefinition, Vector3D origin, Vector3 initialVelocity, Vector3 directionNormalized, IMyGunBaseUser user) { //MyProjectile newProjectile = m_projectiles.Allocate(); MyProjectile newProjectile; m_projectiles.AllocateOrCreate(out newProjectile); newProjectile.Start( ammoDefinition, user.IgnoreEntity, origin, initialVelocity, directionNormalized, user.Weapon ); newProjectile.OwnerEntity = user.Owner != null ? user.Owner : user.IgnoreEntity; }
public IGeneratedTexture CreateFromBytePattern(string name, int width, int height, Format format, byte[] pattern) { MyGeneratedTextureFromPattern generated; m_objectsPoolGeneratedFromPattern.AllocateOrCreate(out generated); generated.Init(name, new Vector2I(width, height), format, pattern); return(generated); }
// Add new light to the list, but caller needs to start it using Start() method public static MyLight AddLight() { MyLight result; m_preallocatedLights.AllocateOrCreate(out result); //result.ProxyId = MyDynamicAABBTree.NullNode; return(result); }
internal static MyLinesBatch CreateBatch() { MyLinesBatch batch = null; m_batchesPool.AllocateOrCreate(out batch); batch.Construct(); return(batch); }
public ICascadeShadowMap CreateCsm(int texSize, int numSlices) { MyCascadeShadowMap csm; m_objectsPoolCsm.AllocateOrCreate(out csm); csm.Init(texSize, numSlices); return(csm); }
internal static CellData AllocateOrCreate() { using (m_lock.AcquireExclusiveUsing()) { CellData cell; m_pool.AllocateOrCreate(out cell); return(cell); } }
// Add new projectile to the list public static void Add(MyProjectileAmmoDefinition ammoDefinition, Vector3D origin, Vector3 initialVelocity, Vector3 directionNormalized, IMyGunBaseUser user, MyEntity owner) { //MyProjectile newProjectile = m_projectiles.Allocate(); MyProjectile newProjectile; m_projectiles.AllocateOrCreate(out newProjectile); newProjectile.Start( ammoDefinition, user.IgnoreEntities, origin, initialVelocity, directionNormalized, user.Weapon ); newProjectile.OwnerEntity = user.Owner ?? (user.IgnoreEntities != null && user.IgnoreEntities.Length > 0 ? user.IgnoreEntities[0] : null); newProjectile.OwnerEntityAbsolute = owner; }
internal IUavArrayTexture CreateUavCube(string debugName, int size, Format format, int mipmapLevels = 1) { MyUavArrayTexture tex; m_uavArrays.AllocateOrCreate(out tex); Texture2DDescription desc = new Texture2DDescription { ArraySize = 6, BindFlags = BindFlags.ShaderResource | BindFlags.RenderTarget | BindFlags.UnorderedAccess, CpuAccessFlags = CpuAccessFlags.None, Format = format, Height = size, MipLevels = mipmapLevels, OptionFlags = ResourceOptionFlags.TextureCube, SampleDescription = { Count = 1, Quality = 0 }, Usage = ResourceUsage.Default, Width = size }; ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription { Format = format, Dimension = ShaderResourceViewDimension.TextureCube, TextureCube = { MipLevels = mipmapLevels, MostDetailedMip = 0 } }; tex.InitUav(debugName, desc, srvDesc, format, format); if (m_isDeviceInit) { tex.OnDeviceInit(); } return(tex); }
public IFileArrayTexture CreateFromFiles(string resourceName, string[] inputFiles, MyFileTextureEnum type, string errorTextureFilepath, bool autoDisposeOnUnload) { MyFileArrayTexture array; m_fileTextureArrays.AllocateOrCreate(out array); array.Load(resourceName, inputFiles, type, errorTextureFilepath); if (m_isDeviceInit) { array.OnDeviceInit(); } if (autoDisposeOnUnload) { m_texturesOnAutoDisposal.Add(array); } return(array); }
public IDynamicFileArrayTexture CreateTexture(string name, MyFileTextureEnum type, byte[] bytePattern, Format bytePatternFormat) { MyDynamicFileArrayTexture tex; m_objectsPool.AllocateOrCreate(out tex); tex.Init(name, type, bytePattern, bytePatternFormat); //if (destroyOnUnloadSession) // m_texarraysAutodestroyed.Add(tex); return(tex); }
internal IRtvArrayTexture CreateRtvArray(string debugName, int width, int height, int arraySize, Format format, int mipmapLevels = 1) { MyRenderProxy.Assert(width > 0); MyRenderProxy.Assert(height > 0); MyRenderProxy.Assert(arraySize > 0); MyRenderProxy.Assert(mipmapLevels > 0); MyRtvArrayTexture tex; m_rtvArrays.AllocateOrCreate(out tex); Texture2DDescription desc = new Texture2DDescription { ArraySize = arraySize, BindFlags = BindFlags.ShaderResource | BindFlags.RenderTarget, CpuAccessFlags = CpuAccessFlags.None, Format = format, Height = height, MipLevels = mipmapLevels, OptionFlags = ResourceOptionFlags.None, SampleDescription = { Count = 1, Quality = 0 }, Usage = ResourceUsage.Default, Width = width }; ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription { Format = format, Dimension = ShaderResourceViewDimension.Texture2DArray, Texture2DArray = { ArraySize = arraySize, FirstArraySlice = 0, MipLevels = mipmapLevels, MostDetailedMip = 0 } }; tex.InitRtv(debugName, desc, srvDesc, format); if (m_isDeviceInit) { tex.OnDeviceInit(); } return(tex); }
public void Init() { m_currentLod = 0; m_transitionLod = -1; m_transition = 0; m_transitionStartedAtDistance = 0; m_explicitState = MyInstanceLodState.Solid; m_explicitStateData = 0; m_updatedAtFrameId = 0; m_cachedResultsPool.AllocateOrCreate(out m_cachedResults); MyLodStrategyCachedResultsUtils.InitList(m_cachedResults); }
protected MyBorrowedCustomTexture CreateCustom(string debugName, MyBorrowedTextureKey key) { MyRenderProxy.Assert(m_dictionaryCustomTextures.ContainsKey(key), "The key needs to be used before this call!"); MyRenderProxy.Assert(m_dictionaryCustomTextures[key] != null, "The list needs to be allocated before this call!"); MyBorrowedCustomTexture borrowedCustom; m_objectPoolCustom.AllocateOrCreate(out borrowedCustom); borrowedCustom.Create(key); m_dictionaryCustomTextures[key].Add(borrowedCustom); return(borrowedCustom); }
public void Load(string resourceName, string[] filePaths, MyFileTextureEnum type, string errorTextureFilepath) { m_resourceName = resourceName; if (m_listSubresourceFilenames == null) { m_objectsPoolOfStringLists.AllocateOrCreate(out m_listSubresourceFilenames); } m_listSubresourceFilenames.Clear(); foreach (string path in filePaths) { m_listSubresourceFilenames.Add(path); } m_type = type; ISrvBindable tex = MyManagers.FileTextures.GetTexture(filePaths[0], type); m_size = tex.Size; TextureFormat = Format.Unknown; m_recoverySystem.UseErrorTexture = true; m_recoverySystem.TextureFilepath = errorTextureFilepath; }
protected TResource CreateResource(string name, ref TDescription desc) { TResource resource; m_objectsPool.AllocateOrCreate(out resource); resource.Init(name, ref desc); if (m_isInit) { resource.OnDeviceInit(); } return(resource); }
internal ILinkedArrayTexture CreateLinkedArray(string debugName, ISrvBindable[] srvs) { MyLinkedArrayTexture tex; m_linkedArrays.AllocateOrCreate(out tex); tex.InitLinked(debugName, srvs); if (m_isDeviceInit) { tex.OnDeviceInit(); } return(tex); }
public static void Start(Vector3I min, Vector3I max, MyVoxelBase voxelMap, Action <MyDepositQuery, ConcurrentCachingList <MyEntityOreDeposit>, List <Vector3I> > completionCallback) { MyDepositQuery query = null; m_instancePool.AllocateOrCreate(out query); if (query != null) { query.Min = min; query.Max = max; query.VoxelMap = voxelMap; query.CompletionCallback = completionCallback; MyAPIGateway.Parallel.Start(query, query.m_onComplete); } }
internal IDepthArrayTexture CreateDepthCube(string debugName, int size, Format resourceFormat, Format srvFormat, Format dsvFormat, int mipmapLevels = 1) { MyDepthArrayTexture tex; m_depthArrays.AllocateOrCreate(out tex); Texture2DDescription desc; desc.ArraySize = 6; desc.BindFlags = BindFlags.ShaderResource | BindFlags.DepthStencil; desc.CpuAccessFlags = CpuAccessFlags.None; desc.Format = resourceFormat; desc.Height = size; desc.MipLevels = mipmapLevels; desc.OptionFlags = ResourceOptionFlags.TextureCube; desc.SampleDescription.Count = 1; desc.SampleDescription.Quality = 0; desc.Usage = ResourceUsage.Default; desc.Width = size; ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription(); srvDesc.Format = srvFormat; srvDesc.Dimension = ShaderResourceViewDimension.TextureCube; srvDesc.TextureCube.MipLevels = mipmapLevels; srvDesc.TextureCube.MostDetailedMip = 0; tex.InitDepth(debugName, desc, srvDesc, dsvFormat); if (m_isDeviceInit) { tex.OnDeviceInit(); } return(tex); }
public ICustomTexture CreateTexture(string debugName, int width, int height, int samplesCount = 1, int samplesQuality = 0) { MyCustomTexture tex; m_objectsPool.AllocateOrCreate(out tex); tex.Init(debugName, width, height, samplesCount, samplesQuality); if (m_isDeviceInit) { tex.OnDeviceInit(); } return(tex); }