protected internal override PropertyRecord CreateExistingRecord(bool light) { PropertyRecord record = new PropertyRecord(ID); record.Id = ID; record.NextProp = 2; record.PrevProp = 4; record.InUse = true; PropertyBlock block = new PropertyBlock(); DynamicRecordAllocator stringAllocator = new ReusableRecordsAllocator(64, new DynamicRecord(7)); Value value = Values.of("a string too large to fit in the property block itself"); PropertyStore.EncodeValue(block, 6, value, stringAllocator, null, true); if (light) { block.ValueRecords.Clear(); } record.PropertyBlock = block; return(record); }
public void ShowData(List <TableBlock> blocks, int templateIndex) { if (blocks == null) { this.propertyGrid.SelectedObjects = null; return; } PropertyBlock[] propertyBlocks = new PropertyBlock[blocks.Count]; for (int i = 0; i < blocks.Count; i++) { propertyBlocks[i] = new PropertyBlock(blocks[i].Block, Helper.Template.Data.Files[templateIndex].Blocks.Values[blocks[i].Block.TemplateIndex]); } this.propertyGrid.SelectedObjects = propertyBlocks; this.propertyGrid.ExpandAllGridItems(); // ensure visibility of selected grid item this.propertyGrid.SelectedGridItem.Select(); }
protected override void UpdateProperties() { base.UpdateProperties(); if (PropertyBlock == null || Thread.CurrentThread.ManagedThreadId != 1) { return; } PropertyBlock.SetColor(Shader.PropertyToID("_Color"), new Color(SolidColor.r, SolidColor.g, SolidColor.b, Opacity)); PropertyBlock.SetFloat(WireframeColorPropId, ColorBy == ColorMode.VertexColor ? 1f : 0f); if (Texture != null) { PropertyBlock.SetTexture(TexturePropId, Texture); } UpdateShader(); UpdateRenderers(); }
private void FixTileColor() { if (PropertyBlock == null) { return; } Vector3 localRot = transform.localRotation.eulerAngles; MeshRenderer.GetPropertyBlock(PropertyBlock); Color color1 = PropertyBlock.GetColor(tileColor1ShaderName); Color color3 = PropertyBlock.GetColor(tileColor3ShaderName); switch (tileType) { case TileType.Curve: case TileType.Pathless: if (localRot.y != 0 && localRot.y != 180) { return; } PropertyBlock.SetColor(tileColor3ShaderName, color1); PropertyBlock.SetColor(tileColor1ShaderName, color3); break; case TileType.Straight: case TileType.TCrossing: if (localRot.y != 90 && localRot.y != 270) { return; } PropertyBlock.SetColor(tileColor3ShaderName, color1); PropertyBlock.SetColor(tileColor1ShaderName, color3); break; } MeshRenderer.SetPropertyBlock(PropertyBlock); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToRemoveBlocksDuringIteration() public virtual void ShouldBeAbleToRemoveBlocksDuringIteration() { // GIVEN PropertyRecord record = new PropertyRecord(0); ISet <PropertyBlock> blocks = new HashSet <PropertyBlock>(); for (int i = 0; i < 4; i++) { PropertyBlock block = new PropertyBlock(); record.AddPropertyBlock(block); blocks.Add(block); } // WHEN IEnumerator <PropertyBlock> iterator = record.GetEnumerator(); AssertIteratorRemoveThrowsIllegalState(iterator); // THEN int size = blocks.Count; for (int i = 0; i < size; i++) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertTrue(iterator.hasNext()); //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: PropertyBlock block = iterator.next(); if (i % 2 == 1) { //JAVA TO C# CONVERTER TODO TASK: .NET enumerators are read-only: iterator.remove(); AssertIteratorRemoveThrowsIllegalState(iterator); blocks.remove(block); } } //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: assertFalse(iterator.hasNext()); // and THEN there should only be the non-removed blocks left assertEquals(blocks, Iterables.asSet(record)); }
public static void CheckDataBlock(PropertyBlock block, CheckerEngine <PropertyRecord, Org.Neo4j.Consistency.report.ConsistencyReport_PropertyConsistencyReport> engine, RecordAccess records) { if (block.KeyIndexId < 0) { engine.Report().invalidPropertyKey(block); } else { engine.ComparativeCheck(records.PropertyKey(block.KeyIndexId), PropertyKey(block)); } PropertyType type = block.ForceGetType(); if (type == null) { engine.Report().invalidPropertyType(block); } else { switch (type.innerEnumValue) { case PropertyType.InnerEnum.STRING: engine.ComparativeCheck(records.String(block.SingleValueLong), DynamicReference.String(block)); break; case PropertyType.InnerEnum.ARRAY: engine.ComparativeCheck(records.Array(block.SingleValueLong), DynamicReference.Array(block)); break; default: try { type.value(block, null); } catch (Exception) { engine.Report().invalidPropertyValue(block); } break; } } }
//Draws a property that's also a section header (usually a checkbox) along with a collapse/expand triangle. Returns true if block is expanded. public void DrawPropertyHeader(PropertyBlock block, MaterialProperty prop, string label) { float controlSize = 110; EditorGUIUtility.fieldWidth = controlSize; EditorGUIUtility.labelWidth = 0; EditorGUILayout.BeginHorizontal(); //draw folding triangle and retrieve state Rect r = EditorGUILayout.GetControlRect(GUILayout.Width(0), GUILayout.Height(16)); block.open = EditorGUI.Foldout(r, block.open, "", false); if( !block.label ) { //draw a 10-pixel checkbox or a control-sized whatever-else (combo box usually) r = EditorGUILayout.GetControlRect(GUILayout.Width(block.checkbox ? 10 : controlSize), GUILayout.Height(16)); //draw property with label to the right ShaderProperty(r, prop, ""); } EditorGUILayout.LabelField(label); EditorGUILayout.EndHorizontal(); }
protected internal virtual long CreateAndWritePropertyChain() { if (_hasPropertyId) { return(_propertyId); } if (_propertyBlocksCursor == 0) { return(Record.NO_NEXT_PROPERTY.longValue()); } PropertyRecord currentRecord = PropertyRecord(_propertyIds.next()); long firstRecordId = currentRecord.Id; for (int i = 0; i < _propertyBlocksCursor; i++) { PropertyBlock block = _propertyBlocks[i]; if (currentRecord.Size() + block.Size > PropertyType.PayloadSize) { // This record is full or couldn't fit this block, write it to property store long nextPropertyId = _propertyIds.next(); long prevId = currentRecord.Id; currentRecord.NextProp = nextPropertyId; _propertyStore.updateRecord(currentRecord); currentRecord = PropertyRecord(nextPropertyId); currentRecord.PrevProp = prevId; } // Add this block, there's room for it currentRecord.AddPropertyBlock(block); } if (currentRecord.Size() > 0) { _propertyStore.updateRecord(currentRecord); } return(firstRecordId); }
/** * Prepare to be written */ public void PreWrite() { Property[] array = new Property[this._properties.Count]; this._properties.CopyTo(array, 0); Property[] properties = array; // give each property its index for (int k = 0; k < properties.Length; k++) { properties[k].Index = k; } // allocate the blocks for the property table _blocks = PropertyBlock.CreatePropertyBlockArray(_properties); // prepare each property for writing for (int k = 0; k < properties.Length; k++) { properties[k].PreWrite(); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void addingDuplicatePropertyBlockShouldOverwriteExisting() public virtual void AddingDuplicatePropertyBlockShouldOverwriteExisting() { // Given these things... PropertyRecord record = new PropertyRecord(1); PropertyBlock blockA = new PropertyBlock(); blockA.ValueBlocks = new long[1]; blockA.KeyIndexId = 2; PropertyBlock blockB = new PropertyBlock(); blockB.ValueBlocks = new long[1]; blockB.KeyIndexId = 2; // also 2, thus a duplicate // When we set the property block twice that have the same key record.PropertyBlock = blockA; record.PropertyBlock = blockB; // Then the record should only contain a single block, because blockB overwrote blockA IList <PropertyBlock> propertyBlocks = Iterables.asList(record); assertThat(propertyBlocks, hasItem(blockB)); assertThat(propertyBlocks, hasSize(1)); }
protected internal override void AssertRecordsEqual(PropertyRecord actualRecord, PropertyRecord expectedRecord) { assertNotNull("actualRecord", actualRecord); assertNotNull("expectedRecord", expectedRecord); assertThat("getDeletedRecords", actualRecord.DeletedRecords, @is(expectedRecord.DeletedRecords)); assertThat("getNextProp", actualRecord.NextProp, @is(expectedRecord.NextProp)); assertThat("getEntityId", actualRecord.NodeId, @is(expectedRecord.NodeId)); assertThat("getPrevProp", actualRecord.PrevProp, @is(expectedRecord.PrevProp)); assertThat("getRelId", actualRecord.RelId, @is(expectedRecord.RelId)); assertThat("getId", actualRecord.Id, @is(expectedRecord.Id)); assertThat("getLongId", actualRecord.Id, @is(expectedRecord.Id)); IList <PropertyBlock> actualBlocks = Iterables.asList(actualRecord); IList <PropertyBlock> expectedBlocks = Iterables.asList(expectedRecord); assertThat("getPropertyBlocks().size", actualBlocks.Count, @is(expectedBlocks.Count)); for (int i = 0; i < actualBlocks.Count; i++) { PropertyBlock actualBlock = actualBlocks[i]; PropertyBlock expectedBlock = expectedBlocks[i]; AssertPropertyBlocksEqual(i, actualBlock, expectedBlock); } }
private static bool BlocksEqual(PropertyRecord r1, PropertyRecord r2) { if (r1.Size() != r2.Size()) { return(false); } IList <PropertyBlock> r1Blocks = Blocks(r1); IList <PropertyBlock> r2Blocks = Blocks(r2); if (r1Blocks.Count != r2Blocks.Count) { return(false); } for (int i = 0; i < r1Blocks.Count; i++) { PropertyBlock r1Block = r1Blocks[i]; PropertyBlock r2Block = r2Blocks[i]; if (!Arrays.Equals(r1Block.ValueBlocks, r2Block.ValueBlocks)) { return(false); } } return(true); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.values.storable.Value getNodePropertyValue(long nodeId, int propertyKeyId) throws org.neo4j.internal.kernel.api.exceptions.EntityNotFoundException public override Value GetNodePropertyValue(long nodeId, int propertyKeyId) { NodeRecord node = NodeStore.getRecord(nodeId, NodeStore.newRecord(), FORCE); if (!node.InUse()) { throw new EntityNotFoundException(EntityType.NODE, nodeId); } long firstPropertyId = node.NextProp; if (firstPropertyId == Record.NO_NEXT_PROPERTY.intValue()) { return(Values.NO_VALUE); } foreach (PropertyRecord propertyRecord in PropertyStore.getPropertyRecordChain(firstPropertyId)) { PropertyBlock propertyBlock = propertyRecord.GetPropertyBlock(propertyKeyId); if (propertyBlock != null) { return(propertyBlock.NewPropertyValue(PropertyStore)); } } return(Values.NO_VALUE); }
private void RemoveProperty <P>(RecordAccess_RecordProxy <P, Void> primitiveProxy, int propertyKey, RecordAccess <PropertyRecord, PrimitiveRecord> propertyRecords, PrimitiveRecord primitive, long propertyId) where P : Org.Neo4j.Kernel.impl.store.record.PrimitiveRecord { RecordAccess_RecordProxy <PropertyRecord, PrimitiveRecord> recordChange = propertyRecords.GetOrLoad(propertyId, primitive); PropertyRecord propRecord = recordChange.ForChangingData(); if (!propRecord.InUse()) { throw new System.InvalidOperationException("Unable to delete property[" + propertyId + "] since it is already deleted."); } PropertyBlock block = propRecord.RemovePropertyBlock(propertyKey); if (block == null) { throw new System.InvalidOperationException("Property with index[" + propertyKey + "] is not present in property[" + propertyId + "]"); } foreach (DynamicRecord valueRecord in block.ValueRecords) { Debug.Assert(valueRecord.InUse()); valueRecord.SetInUse(false, block.Type.intValue()); propRecord.AddDeletedRecord(valueRecord); } if (propRecord.Size() > 0) { /* * There are remaining blocks in the record. We do not unlink yet. */ propRecord.Changed = primitive; Debug.Assert(_traverser.assertPropertyChain(primitive, propertyRecords)); } else { UnlinkPropertyRecord(propRecord, propertyRecords, primitiveProxy); } }
public void GetBlockPropertyNames_ValidBlockType_ReturnsPropertyNames() { // Arrange const int id = 1; const string propertyName = "name"; var block = new BlockData { Property = { new PropertyString { Name = "A property", IsPropertyData = false }, new PropertyString { Name = "Another property", IsPropertyData = true }, new PropertyString { Name = "Last property", IsPropertyData = true } } }; var property = new PropertyBlock <BlockData>(block) { Name = propertyName }; var page = new PageData { Property = { property } }; _stubContentLoader.Get <PageData>(new ContentReference(id)).Returns(page); // Act var result = _propertyService.GetBlockPropertyNames(new PropertyReference(id, propertyName)); // Assert CollectionAssert.AreEqual(block.Property.Where(x => x.IsPropertyData).Select(x => x.Name), result); }
private long CreatePropertyChain(PrimitiveRecord owner, IEnumerator <PropertyBlock> properties, RecordAccess <PropertyRecord, PrimitiveRecord> propertyRecords, System.Action <PropertyRecord> createdPropertyRecords) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: if (properties == null || !properties.hasNext()) { return(Record.NO_NEXT_PROPERTY.intValue()); } PropertyRecord currentRecord = propertyRecords.Create(_propertyRecordIdGenerator.nextId(), owner).forChangingData(); createdPropertyRecords(currentRecord); currentRecord.InUse = true; currentRecord.SetCreated(); PropertyRecord firstRecord = currentRecord; while (properties.MoveNext()) { PropertyBlock block = properties.Current; if (currentRecord.Size() + block.Size > PropertyType.PayloadSize) { // Here it means the current block is done for PropertyRecord prevRecord = currentRecord; // Create new record long propertyId = _propertyRecordIdGenerator.nextId(); currentRecord = propertyRecords.Create(propertyId, owner).forChangingData(); createdPropertyRecords(currentRecord); currentRecord.InUse = true; currentRecord.SetCreated(); // Set up links prevRecord.NextProp = propertyId; currentRecord.PrevProp = prevRecord.Id; // Now current is ready to start picking up blocks } currentRecord.AddPropertyBlock(block); } return(firstRecord.Id); }
/** * Prepare to be written Leon */ public void PreWrite() { List <Property> properties = new List <Property>(_properties.Count); for (int i = 0; i < _properties.Count; i++) { properties.Add(_properties[i]); } // give each property its index for (int k = 0; k < properties.Count; k++) { properties[k].Index = k; } // allocate the blocks for the property table _blocks = PropertyBlock.CreatePropertyBlockArray(_bigBigBlockSize, properties); // prepare each property for writing for (int k = 0; k < properties.Count; k++) { properties[k].PreWrite(); } }
public static PropertyBlock[] ParsePropertyBlocks(byte[] buffer, ulong offset, ulong blockSize, ulong maxBlocks) { ArrayList blockList = new ArrayList(); ulong blockNum = 0; while (blockNum < maxBlocks || maxBlocks == 0) { ulong currentOffset = offset + blockNum * blockSize; PropertyBlock block = new PropertyBlock(); block.ValidFlag = GetUInt32(buffer, currentOffset); block.TotalLength = GetUInt32(buffer, currentOffset + 4); block.Unknown = GetUInt32(buffer, currentOffset + 8); if (blockSize == 0) { if (block.TotalLength < 0x1000) { blockSize = 0x1000; } else if (block.TotalLength < 0x2000) { blockSize = 0x2000; } else if (block.TotalLength < 0x4000) { blockSize = 0x4000; } else if (block.TotalLength < 0x8000) { blockSize = 0x8000; } else { Log.WriteLine("[E] Failed to autodetect block size. Dumping only until valid block reached."); blockSize = block.TotalLength; maxBlocks = 0; } Log.WriteLine("[I] Autodetected block size as " + blockSize.ToString("X8")); } Log.WriteLine("[Block: {0:X2}, Length: {1:X8}, Flag: {2:X8}] [Base: {3:X8}]", blockNum, block.TotalLength, block.ValidFlag, currentOffset); if (block.ValidFlag != 0xFFFFFFFF) { bool invalid = false; if (maxBlocks == 0) { if (block.ValidFlag == 0x0000FFFF) { Console.Out.WriteLine(" [I] Detected valid block while maxBlocks set to zero. Finishing."); maxBlocks = blockNum; } else if (block.ValidFlag == 0x00FFFFFF) { } else if (block.ValidFlag == 0x000000FF) { } else if (block.ValidFlag == 0x00000000) { } else { Console.Out.WriteLine(" [I] Detected invalid block while maxBlocks set to zero. Finishing."); maxBlocks = blockNum; invalid = true; } } if ((block.TotalLength > 0x0C) && (block.TotalLength <= blockSize) && !invalid) { block.SubBlocks = ParseSubBlocks(buffer, currentOffset, 0x0C, block.TotalLength - 0x0C); } else if (!invalid) { Console.Out.WriteLine(" [E] Invalid block size"); } } else { Console.Out.WriteLine(" [I] Block empty"); } blockList.Add(block); blockNum++; } return((PropertyBlock[])blockList.ToArray(typeof(PropertyBlock))); }
public virtual PropertyBlock EncodeValue(PropertyBlock block, int propertyKey, Value value) { PropertyStore.encodeValue(block, propertyKey, value, _stringRecordAllocator, _arrayRecordAllocator, _allowStorePointsAndTemporal); return(block); }
public virtual void PrimitiveSetProperty <P>(RecordAccess_RecordProxy <P, Void> primitiveRecordChange, int propertyKey, Value value, RecordAccess <PropertyRecord, PrimitiveRecord> propertyRecords) where P : Org.Neo4j.Kernel.impl.store.record.PrimitiveRecord { PropertyBlock block = EncodePropertyValue(propertyKey, value); P primitive = primitiveRecordChange.ForReadingLinkage(); Debug.Assert(_traverser.assertPropertyChain(primitive, propertyRecords)); int newBlockSizeInBytes = block.Size; // Traverse the existing property chain. Tracking two things along the way: // - (a) Free space for this block (candidateHost) // - (b) Existence of a block with the property key // Chain traversal can be aborted only if: // - (1) (b) occurs and new property block fits where the current is // - (2) (a) occurs and (b) has occurred, but new property block didn't fit // - (3) (b) occurs and (a) has occurred // - (4) Chain ends RecordAccess_RecordProxy <PropertyRecord, PrimitiveRecord> freeHostProxy = null; RecordAccess_RecordProxy <PropertyRecord, PrimitiveRecord> existingHostProxy = null; long prop = primitive.NextProp; while (prop != Record.NO_NEXT_PROPERTY.intValue()) // <-- (4) { RecordAccess_RecordProxy <PropertyRecord, PrimitiveRecord> proxy = propertyRecords.GetOrLoad(prop, primitive); PropertyRecord propRecord = proxy.ForReadingLinkage(); Debug.Assert(propRecord.InUse(), propRecord); // (a) search for free space if (PropertyFitsInside(newBlockSizeInBytes, propRecord)) { freeHostProxy = proxy; if (existingHostProxy != null) { // (2) PropertyRecord freeHost = proxy.ForChangingData(); freeHost.AddPropertyBlock(block); freeHost.Changed = primitive; Debug.Assert(_traverser.assertPropertyChain(primitive, propertyRecords)); return; } } // (b) search for existence of property key PropertyBlock existingBlock = propRecord.GetPropertyBlock(propertyKey); if (existingBlock != null) { // We found an existing property and whatever happens we have to remove the existing // block so that we can add the new one, where ever we decide to place it existingHostProxy = proxy; PropertyRecord existingHost = existingHostProxy.ForChangingData(); RemoveProperty(primitive, existingHost, existingBlock); // Now see if we at this point can add the new block if (newBlockSizeInBytes <= existingBlock.Size || PropertyFitsInside(newBlockSizeInBytes, existingHost)) // fallback check { // (1) yes we could add it right into the host of the existing block existingHost.AddPropertyBlock(block); Debug.Assert(_traverser.assertPropertyChain(primitive, propertyRecords)); return; } else if (freeHostProxy != null) { // (3) yes we could add it to a previously found host with sufficiently free space in it PropertyRecord freeHost = freeHostProxy.ForChangingData(); freeHost.AddPropertyBlock(block); freeHost.Changed = primitive; Debug.Assert(_traverser.assertPropertyChain(primitive, propertyRecords)); return; } // else we can't add it at this point } // Continue down the chain prop = propRecord.NextProp; } // At this point we haven't added the property block, although we may have found room for it // along the way. If we didn't then just create a new record, it's fine PropertyRecord freeHost; if (freeHostProxy == null) { // We couldn't find free space along the way, so create a new host record freeHost = propertyRecords.Create(_propertyRecordIdGenerator.nextId(), primitive).forChangingData(); freeHost.InUse = true; if (primitive.NextProp != Record.NO_NEXT_PROPERTY.intValue()) { // This isn't the first property record for the entity, re-shuffle the first one so that // the new one becomes the first PropertyRecord prevProp = propertyRecords.GetOrLoad(primitive.NextProp, primitive).forChangingLinkage(); Debug.Assert(prevProp.PrevProp == Record.NO_PREVIOUS_PROPERTY.intValue()); prevProp.PrevProp = freeHost.Id; freeHost.NextProp = prevProp.Id; prevProp.Changed = primitive; } // By the way, this is the only condition where the primitive record also needs to change primitiveRecordChange.ForChangingLinkage().NextProp = freeHost.Id; } else { freeHost = freeHostProxy.ForChangingData(); } // At this point we know that we have a host record with sufficient space in it for the block // to add, so simply add it freeHost.AddPropertyBlock(block); Debug.Assert(_traverser.assertPropertyChain(primitive, propertyRecords)); }
public virtual Value GetValue(PropertyBlock propertyBlock) { return(propertyBlock.Type.value(propertyBlock, this)); }
public static void SetSingleBlockValue(PropertyBlock block, int keyId, PropertyType type, long longValue) { block.SingleBlock = SingleBlockLongValue(keyId, type, longValue); }
void Update() { if (Application.isEditor && !Application.isPlaying) { RegenerateCurve(); } shadowMapSize = Mathf.NextPowerOfTwo(shadowMapSize); shadowMapSize = Mathf.Clamp(shadowMapSize, 8, 2048); if (OutputTexture.width != shadowMapSize) { DestroySafe(_texTarget); } PropertyBlock.SetTexture("_MainTex", OutputTexture); var shadowMap = PushRenderTexture(shadowMapSize, shadowMapSize); ShadowCamera.targetTexture = shadowMap; ShadowCamera.rect = new Rect(0, 0, 1, 1); ShadowCamera.Render(); ShadowCamera.targetTexture = null; if (highQualityPenumbras) { ShadowMaterial.EnableKeyword("ULTRA_QUALITY"); } else { ShadowMaterial.DisableKeyword("ULTRA_QUALITY"); } if (solidShadow) { ShadowMaterial.EnableKeyword("SOLID_SHADOW"); } else { ShadowMaterial.DisableKeyword("SOLID_SHADOW"); } ShadowMaterial.SetTexture("_FallOffTex", _fallOffTexture); ShadowMaterial.SetFloat("_BlurSize", blurSize * ((float)shadowMapSize / 512)); ShadowMaterial.SetFloat("_ShadowOffset", shadowBias); ShadowMaterial.SetColor("_ShadowColor", shadowColor); ShadowMaterial.SetColor("_ColorTint", gradientTint); // Calculate the distance between the light and centre var texLightDistance = PushRenderTexture(shadowMapSize, shadowMapSize); Graphics.Blit(shadowMap, texLightDistance, ShadowMaterial, 0); // Stretch it into a dual parabaloid var texStretched = PushRenderTexture(shadowMapSize, shadowMapSize); Graphics.Blit(texLightDistance, texStretched, ShadowMaterial, 1); // Here we compress it into a 1D distance map var texDownSampled = texStretched; var width = shadowMapSize; while (width > 2) { width /= 2; var texDownSampleTemp = PushRenderTexture(width, shadowMapSize); Graphics.Blit(texDownSampled, texDownSampleTemp, ShadowMaterial, 2); texDownSampled = texDownSampleTemp; } // Finally do a distance compare and shadow map Graphics.Blit(texDownSampled, OutputTexture, ShadowMaterial, 3); // Blur the results if (blurIterations > 0) { var pingPong = RenderTexture.GetTemporary(shadowMapSize, shadowMapSize, 0); for (int i = 0; i < blurIterations; i++) { Graphics.Blit(OutputTexture, pingPong, ShadowMaterial, 5); Graphics.Blit(pingPong, OutputTexture, ShadowMaterial, 4); } RenderTexture.ReleaseTemporary(pingPong); } ReleaseAllRenderTextures(); transform.localScale = Vector3.one * _shadowCamera.orthographicSize * 2; Graphics.DrawMesh(_lightmesh, transform.localToWorldMatrix, _lightMaterial, gameObject.layer, null, 0, PropertyBlock); }
internal virtual Value GetArrayFor(PropertyBlock propertyBlock) { EnsureHeavy(propertyBlock); return(GetArrayFor(propertyBlock.ValueRecords)); }
public void TestCreatePropertyBlocks() { // Test with 0 properties ArrayList properties = new ArrayList(); BlockWritable[] blocks = PropertyBlock.CreatePropertyBlockArray(properties); Assert.AreEqual(0, blocks.Length); // Test with 1 property properties.Add(new LocalProperty("Root Entry")); blocks = PropertyBlock.CreatePropertyBlockArray(properties); Assert.AreEqual(1, blocks.Length); byte[] testblock = new byte[512]; for (int j = 0; j < 4; j++) { SetDefaultBlock(testblock, j); } testblock[0x0000] = (byte)'R'; testblock[0x0002] = (byte)'o'; testblock[0x0004] = (byte)'o'; testblock[0x0006] = (byte)'t'; testblock[0x0008] = (byte)' '; testblock[0x000A] = (byte)'E'; testblock[0x000C] = (byte)'n'; testblock[0x000E] = (byte)'t'; testblock[0x0010] = (byte)'r'; testblock[0x0012] = (byte)'y'; testblock[0x0040] = (byte)22; verifyCorrect(blocks, testblock); // Test with 3 properties properties.Add(new LocalProperty("workbook")); properties.Add(new LocalProperty("summary")); blocks = PropertyBlock.CreatePropertyBlockArray(properties); Assert.AreEqual(1, blocks.Length); testblock[0x0080] = (byte)'w'; testblock[0x0082] = (byte)'o'; testblock[0x0084] = (byte)'r'; testblock[0x0086] = (byte)'k'; testblock[0x0088] = (byte)'b'; testblock[0x008A] = (byte)'o'; testblock[0x008C] = (byte)'o'; testblock[0x008E] = (byte)'k'; testblock[0x00C0] = (byte)18; testblock[0x0100] = (byte)'s'; testblock[0x0102] = (byte)'u'; testblock[0x0104] = (byte)'m'; testblock[0x0106] = (byte)'m'; testblock[0x0108] = (byte)'a'; testblock[0x010A] = (byte)'r'; testblock[0x010C] = (byte)'y'; testblock[0x0140] = (byte)16; verifyCorrect(blocks, testblock); // Test with 4 properties properties.Add(new LocalProperty("wintery")); blocks = PropertyBlock.CreatePropertyBlockArray(properties); Assert.AreEqual(1, blocks.Length); testblock[0x0180] = (byte)'w'; testblock[0x0182] = (byte)'i'; testblock[0x0184] = (byte)'n'; testblock[0x0186] = (byte)'t'; testblock[0x0188] = (byte)'e'; testblock[0x018A] = (byte)'r'; testblock[0x018C] = (byte)'y'; testblock[0x01C0] = (byte)16; verifyCorrect(blocks, testblock); // Test with 5 properties properties.Add(new LocalProperty("foo")); blocks = PropertyBlock.CreatePropertyBlockArray(properties); Assert.AreEqual(2, blocks.Length); testblock = new byte[1024]; for (int j = 0; j < 8; j++) { SetDefaultBlock(testblock, j); } testblock[0x0000] = (byte)'R'; testblock[0x0002] = (byte)'o'; testblock[0x0004] = (byte)'o'; testblock[0x0006] = (byte)'t'; testblock[0x0008] = (byte)' '; testblock[0x000A] = (byte)'E'; testblock[0x000C] = (byte)'n'; testblock[0x000E] = (byte)'t'; testblock[0x0010] = (byte)'r'; testblock[0x0012] = (byte)'y'; testblock[0x0040] = (byte)22; testblock[0x0080] = (byte)'w'; testblock[0x0082] = (byte)'o'; testblock[0x0084] = (byte)'r'; testblock[0x0086] = (byte)'k'; testblock[0x0088] = (byte)'b'; testblock[0x008A] = (byte)'o'; testblock[0x008C] = (byte)'o'; testblock[0x008E] = (byte)'k'; testblock[0x00C0] = (byte)18; testblock[0x0100] = (byte)'s'; testblock[0x0102] = (byte)'u'; testblock[0x0104] = (byte)'m'; testblock[0x0106] = (byte)'m'; testblock[0x0108] = (byte)'a'; testblock[0x010A] = (byte)'r'; testblock[0x010C] = (byte)'y'; testblock[0x0140] = (byte)16; testblock[0x0180] = (byte)'w'; testblock[0x0182] = (byte)'i'; testblock[0x0184] = (byte)'n'; testblock[0x0186] = (byte)'t'; testblock[0x0188] = (byte)'e'; testblock[0x018A] = (byte)'r'; testblock[0x018C] = (byte)'y'; testblock[0x01C0] = (byte)16; testblock[0x0200] = (byte)'f'; testblock[0x0202] = (byte)'o'; testblock[0x0204] = (byte)'o'; testblock[0x0240] = (byte)8; verifyCorrect(blocks, testblock); }
public static PropertyBlock[] ParsePropertyBlocks(byte[] buffer, ulong offset, ulong blockSize, ulong maxBlocks) { ArrayList blockList = new ArrayList(); ulong blockNum = 0; while (blockNum < maxBlocks || maxBlocks == 0) { ulong currentOffset = offset + blockNum * blockSize; PropertyBlock block = new PropertyBlock(); block.ValidFlag = GetUInt32(buffer, currentOffset); block.TotalLength = GetUInt32(buffer, currentOffset + 4); block.Unknown = GetUInt32(buffer, currentOffset + 8); if (blockSize == 0) { if (block.TotalLength < 0x1000) { blockSize = 0x1000; } else if (block.TotalLength < 0x2000) { blockSize = 0x2000; } else if (block.TotalLength < 0x4000) { blockSize = 0x4000; } else if (block.TotalLength < 0x8000) { blockSize = 0x8000; } else { Log.WriteLine("[E] Failed to autodetect block size. Dumping only until valid block reached."); blockSize = block.TotalLength; maxBlocks = 0; } Log.WriteLine("[I] Autodetected block size as " + blockSize.ToString("X8")); } Log.WriteLine("[Block: {0:X2}, Length: {1:X8}, Flag: {2:X8}] [Base: {3:X8}]", blockNum, block.TotalLength, block.ValidFlag, currentOffset); if (block.ValidFlag != 0xFFFFFFFF) { bool invalid = false; if (maxBlocks == 0) { if (block.ValidFlag == 0x0000FFFF) { Console.Out.WriteLine(" [I] Detected valid block while maxBlocks set to zero. Finishing."); maxBlocks = blockNum; } else if (block.ValidFlag == 0x00FFFFFF) { } else if (block.ValidFlag == 0x000000FF) { } else if (block.ValidFlag == 0x00000000) { } else { Console.Out.WriteLine(" [I] Detected invalid block while maxBlocks set to zero. Finishing."); maxBlocks = blockNum; invalid = true; } } if ((block.TotalLength > 0x0C) && (block.TotalLength <= blockSize) && !invalid) { block.SubBlocks = ParseSubBlocks(buffer, currentOffset, 0x0C, block.TotalLength - 0x0C); } else if(!invalid) { Console.Out.WriteLine(" [E] Invalid block size"); } } else { Console.Out.WriteLine(" [I] Block empty"); } blockList.Add(block); blockNum++; } return (PropertyBlock[])blockList.ToArray(typeof(PropertyBlock)); }
public virtual void EncodeValue(PropertyBlock block, int keyId, Value value) { EncodeValue(block, keyId, value, _stringStore, _arrayStore, _allowStorePointsAndTemporal); }
public void UpdateProperties(bool batchPropertiesChanged) { var settings = Decal.Settings; // Move decal to appropriate batch if needed if (batchPropertiesChanged) { // Find shader permutation var permuatation = new MaterialPermutation(settings.Mode, settings.LayerMode, settings.LayerProjection, settings.Shape, settings.EnableJitter); // Choose the smallest jitter value of the three textures (or zero if they are all null) var jitter = Min( settings.LayerMode == LayerMode.Triplanar ? Jitter(settings.SampleJitter, settings.XLayer.LayerMask) : null, settings.LayerMode != LayerMode.None ? Jitter(settings.SampleJitter, settings.YLayer.LayerMask) : null, settings.LayerMode == LayerMode.Triplanar ? Jitter(settings.SampleJitter, settings.ZLayer.LayerMask) : null ); // Collect material properties var materialProperties = new MaterialProperties( settings.XLayer.LayerMask, settings.XLayer.LayerMaskScaleOffset, settings.YLayer.LayerMask, settings.YLayer.LayerMaskScaleOffset, settings.ZLayer.LayerMask, settings.ZLayer.LayerMaskScaleOffset, _system.SharedState.BlueNoiseRGBA, new Vector2(29, 31), jitter ); // Update batch if (_batch != null) { _batch.Remove(this); } _batch = _system.SharedState.FindBatch(permuatation, materialProperties); _batch.Add(this); } // Update instance properties struct _properties.Saturation = settings.Saturation; _properties.Fadeout = settings.EdgeFadeoff; _properties.EdgeSharpness = settings.FaceSharpness; if (settings.LayerMode != LayerMode.None) { settings.YLayer.EvaluateRanges(out _properties.YLayer); } if (settings.LayerMode == LayerMode.Triplanar) { settings.XLayer.EvaluateRanges(out _properties.XLayer); settings.ZLayer.EvaluateRanges(out _properties.ZLayer); } // Update material properties block if running non-instanced if (!RenderSettings.Instance.EnableInstancing) { if (PropertyBlock == null) { PropertyBlock = new MaterialPropertyBlock(); } PropertyBlock.Clear(); _properties.LoadInto(PropertyBlock, settings.LayerMode); } }
internal virtual string GetStringFor(PropertyBlock propertyBlock) { EnsureHeavy(propertyBlock); return(GetStringFor(propertyBlock.ValueRecords)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.PropertyRecord readPropertyRecord(long id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException private PropertyRecord ReadPropertyRecord(long id, ReadableChannel channel) { // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+ // prev_prop_id(long)+next_prop_id(long) PropertyRecord record = new PropertyRecord(id); sbyte inUseFlag = channel.Get(); // 1 long nextProp = channel.Long; // 8 long prevProp = channel.Long; // 8 record.NextProp = nextProp; record.PrevProp = prevProp; bool inUse = false; if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) { inUse = true; } bool nodeProperty = true; if ((inUseFlag & Record.REL_PROPERTY.byteValue()) == Record.REL_PROPERTY.byteValue()) { nodeProperty = false; } long primitiveId = channel.Long; // 8 if (primitiveId != -1 && nodeProperty) { record.NodeId = primitiveId; } else if (primitiveId != -1) { record.RelId = primitiveId; } int nrPropBlocks = channel.Get(); Debug.Assert(nrPropBlocks >= 0); if (nrPropBlocks > 0) { record.InUse = true; } while (nrPropBlocks-- > 0) { PropertyBlock block = ReadPropertyBlock(channel); if (block == null) { return(null); } record.AddPropertyBlock(block); } int deletedRecords = ReadDynamicRecords(channel, record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER); if (deletedRecords == -1) { return(null); } Debug.Assert(deletedRecords >= 0); while (deletedRecords-- > 0) { DynamicRecord read = ReadDynamicRecord(channel); if (read == null) { return(null); } record.AddDeletedRecord(read); } if ((inUse && !record.InUse()) || (!inUse && record.InUse())) { throw new System.InvalidOperationException("Weird, inUse was read in as " + inUse + " but the record is " + record); } return(record); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private org.neo4j.kernel.impl.store.record.PropertyRecord readPropertyRecord(long id, org.neo4j.storageengine.api.ReadableChannel channel) throws java.io.IOException private PropertyRecord ReadPropertyRecord(long id, ReadableChannel channel) { // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+ // prev_prop_id(long)+next_prop_id(long) PropertyRecord record = new PropertyRecord(id); sbyte flags = channel.Get(); // 1 bool inUse = bitFlag(flags, Record.IN_USE.byteValue()); bool nodeProperty = !bitFlag(flags, Record.REL_PROPERTY.byteValue()); bool requireSecondaryUnit = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT); bool hasSecondaryUnit = bitFlag(flags, Record.HAS_SECONDARY_UNIT); bool usesFixedReferenceFormat = bitFlag(flags, Record.USES_FIXED_REFERENCE_FORMAT); record.RequiresSecondaryUnit = requireSecondaryUnit; record.UseFixedReferences = usesFixedReferenceFormat; long nextProp = channel.Long; // 8 long prevProp = channel.Long; // 8 record.NextProp = nextProp; record.PrevProp = prevProp; long primitiveId = channel.Long; // 8 if (primitiveId != -1 && nodeProperty) { record.NodeId = primitiveId; } else if (primitiveId != -1) { record.RelId = primitiveId; } if (hasSecondaryUnit) { record.SecondaryUnitId = channel.Long; } int nrPropBlocks = channel.Get(); Debug.Assert(nrPropBlocks >= 0); if (nrPropBlocks > 0) { record.InUse = true; } while (nrPropBlocks-- > 0) { PropertyBlock block = ReadPropertyBlock(channel); if (block == null) { return(null); } record.AddPropertyBlock(block); } int deletedRecords = ReadDynamicRecords(channel, record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER); if (deletedRecords == -1) { return(null); } Debug.Assert(deletedRecords >= 0); while (deletedRecords-- > 0) { DynamicRecord read = ReadDynamicRecord(channel); if (read == null) { return(null); } record.AddDeletedRecord(read); } if ((inUse && !record.InUse()) || (!inUse && record.InUse())) { throw new System.InvalidOperationException("Weird, inUse was read in as " + inUse + " but the record is " + record); } return(record); }
internal static void ReadRaw(EndianAwareBinaryReader reader, out int typeCount, out int objectCount, out TypeHeader[] typeHeaders, out Dictionary <int, List <PropertyBlock> > propertyData, out Tuple <int, int>[] childParentPairs) { // Check file signature var signatureBytes = reader.ReadBytes(Signatures.Signature.Length); if (!signatureBytes.SequenceEqual(Signatures.Signature)) { throw new InvalidRobloxFileException("The file signature does not match."); } typeCount = reader.ReadInt32(); objectCount = reader.ReadInt32(); reader.ReadInt32(); // Reserved reader.ReadInt32(); // Reserved // Deserialize type headers typeHeaders = new TypeHeader[typeCount]; for (var i = 0; i < typeCount; i++) { var typeHeaderSignature = reader.ReadBytes(Signatures.TypeHeaderSignature.Length); if (!typeHeaderSignature.SequenceEqual(Signatures.TypeHeaderSignature)) { throw new InvalidRobloxFileException("Invalid type header signature."); } var decompressedBytes = RobloxLZ4.ReadBlock(reader.Stream); var typeHeader = TypeHeader.Deserialize(decompressedBytes); typeHeaders[i] = typeHeader; } // Read property data propertyData = new Dictionary <int, List <PropertyBlock> >(); // Key is type id byte[] lastPropSignature; while (true) { lastPropSignature = reader.ReadBytes(Signatures.PropBlockSignature.Length); if (!lastPropSignature.SequenceEqual(Signatures.PropBlockSignature)) { break; } var decompressedBytes = RobloxLZ4.ReadBlock(reader.Stream); var propertyBlock = PropertyBlock.Deserialize(decompressedBytes, typeHeaders); if (propertyBlock == null) { continue; } if (!propertyData.ContainsKey(propertyBlock.TypeId)) { propertyData.Add(propertyBlock.TypeId, new List <PropertyBlock>()); } propertyData[propertyBlock.TypeId].Add(propertyBlock); } if (!lastPropSignature.SequenceEqual(Signatures.ParentDataSignature)) { throw new InvalidRobloxFileException("Missing parent data section."); } var parentData = RobloxLZ4.ReadBlock(reader.Stream); childParentPairs = Util.ReadParentData(parentData); var endSignature = reader.ReadBytes(Signatures.EndSignature.Length); if (!endSignature.SequenceEqual(Signatures.EndSignature)) { throw new InvalidRobloxFileException("End signature is missing or invalid."); } }