Skip to content

Instantly share code, notes, and snippets.

View miguelemosreverte's full-sized avatar
🏠
Working from home

Miguel Lemos miguelemosreverte

🏠
Working from home
  • Cordoba,Argentina
View GitHub Profile
for (uint32 FaceIndex = 0; FaceIndex < 6; ++FaceIndex)
{
TArray<uint16> NewIndices;
// Only draw faces that face empty bricks.
const int32 FacingLocalBrickX = LocalBrickX + FaceNormals[FaceIndex].X;
const int32 FacingLocalBrickY = LocalBrickY + FaceNormals[FaceIndex].Y;
const int32 FacingLocalBrickZ = LocalBrickZ + FaceNormals[FaceIndex].Z;
const uint32 FacingLocalBrickIndex = (FacingLocalBrickY * LocalBricksDim.X + FacingLocalBrickX) * LocalBricksDim.Z + FacingLocalBrickZ;
const uint32 FrontBrickMaterial = LocalBrickMaterials[FacingLocalBrickIndex];
#pragma once
#include <DynamicMeshBuilder.h>
#include "BrickGridComponent.h"
class ComplexShapeBrickFactory
{
public:
ComplexShapeBrickFactory()
@miguelemosreverte
miguelemosreverte / gist:3afd7e368319f169f8659a14727ae638
Created September 3, 2016 04:09
new version of BrickStair Render function
void UBrickStairsRenderer::Render(TArray<uint16>& VertexIndexMap, TArray<FDynamicMeshVertex>& Vertices, TArray<FMaterialBatch>& MaterialBatches, TArray<uint16> NewIndices, int FaceIndex)
{
int Offset = 0;
FFaceBatch& FaceBatch = MaterialBatches[9].FaceBatches[FaceIndex];
uint16* FaceVertexIndex;
//Tall stair step
for (uint32 FaceVertexIndex = 0; FaceVertexIndex < 4; ++FaceVertexIndex)
{
const int VertexIndex = NewIndices[FaceVertexIndex];
@miguelemosreverte
miguelemosreverte / gist:632eea34d79b5c553c906f1f9dabf085
Created September 3, 2016 16:23
Basic BrickStair setup: First for loop is copy pasted, bug appears
void UBrickStairsRenderer::Render(TArray<uint16>& VertexIndexMap, TArray<FDynamicMeshVertex>& Vertices, TArray<FMaterialBatch>& MaterialBatches, TArray<uint16> NewIndices, int FaceIndex)
{
int Offset = 0;
FFaceBatch& FaceBatch = MaterialBatches[9].FaceBatches[FaceIndex];
uint16* FaceVertexIndex;
//Tall stair step
for (uint32 FaceVertexIndex = 0; FaceVertexIndex < 4; ++FaceVertexIndex)
{
const int VertexIndex = NewIndices[FaceVertexIndex];
@miguelemosreverte
miguelemosreverte / gist:dfe195cf3e1502aa5ab2bf4fbd974c8b
Created September 3, 2016 16:25
Basic BrickStair setup: removed the copy pasted for loop, bug is removed too
void UBrickStairsRenderer::Render(TArray<uint16>& VertexIndexMap, TArray<FDynamicMeshVertex>& Vertices, TArray<FMaterialBatch>& MaterialBatches, TArray<uint16> NewIndices, int FaceIndex)
{
int Offset = 0;
FFaceBatch& FaceBatch = MaterialBatches[9].FaceBatches[FaceIndex];
uint16* FaceVertexIndex;
//Tall stair step
for (uint32 FaceVertexIndex = 0; FaceVertexIndex < 4; ++FaceVertexIndex)
{
const int VertexIndex = NewIndices[FaceVertexIndex];
const FVector Position = Vertices[VertexIndex].Position;
@miguelemosreverte
miguelemosreverte / gist:350d441d6e48ea45fb0d358d5960ed8d
Created September 3, 2016 21:07
trying to add 3 times the normal ammount of vertices
void UBrickStairsRenderer::Render(TArray<uint16>& VertexIndexMap, TArray<FDynamicMeshVertex>& Vertices, TArray<FMaterialBatch>& MaterialBatches, TArray<uint16> NewIndices, int FaceIndex)
{
int Offset = 0;
for (int ammountOfTimes = 1; ammountOfTimes <= 3; ++ammountOfTimes)
{
for (uint32 FaceVertexIndex = 0; FaceVertexIndex < 4; ++FaceVertexIndex)
{
const int VertexIndex = NewIndices[FaceVertexIndex];
const FVector Position = Vertices[VertexIndex].Position;
int NewVertexIndex = Vertices.Num();
void UBrickGridComponent::UpdateMaxNonEmptyBrickMap(FBrickRegion& Region, const FInt3 MinDirtyRegionBrickCoordinates, const FInt3 MaxDirtyRegionBrickCoordinates) const
{
// Allocate the map.
if (!Region.MaxNonEmptyBrickRegionZs.Num())
{
Region.MaxNonEmptyBrickRegionZs.SetNumUninitialized(1 << (Parameters.BricksPerRegionLog2.X + Parameters.BricksPerRegionLog2.Y));
}
// For each XY in the chunk, find the highest non-empty brick between the bottom of the chunk and the top of the grid.
FVoxelRegion& Region = *new(Regions) FVoxelRegion;
Region.Coordinates = RegionCoordinates;
// Initialize the region's Voxels to the empty material.
Region.VoxelContents.Init(Parameters.EmptyMaterialIndex, 1 << Parameters.VoxelsPerRegionLog2.SumComponents());
// Compute the region's non-empty height map.
UpdateMaxNonEmptyVoxelMap(Region, FInt3::Scalar(0), VoxelsPerRegion - FInt3::Scalar(1));
@miguelemosreverte
miguelemosreverte / gist:c0de65d67c2c109a6d70aa1ae0c13e80
Created September 11, 2016 00:19
current state of the function
void UVoxelLandscapeComponent::GetRegionComplexVoxelsCoordinates(const FInt3 RegionCoordinates, TArray<FInt3> &outCoordinates, TArray<uint8> &outComplexVoxelIndices)
{
const int32* const RegionIndex = RegionCoordinatesToIndex.Find(RegionCoordinates);
if (RegionIndex)// && RegionCoordinates == FInt3(0, 0, 0))
{
UpdateRegionComplexVoxelsMap(Regions[*RegionIndex], FInt3::Scalar(0), VoxelsPerRegion - FInt3::Scalar(1));
Regions[*RegionIndex].RegionComplexVoxelsIndexes.GenerateKeyArray(outCoordinates);
Regions[*RegionIndex].RegionComplexVoxelsIndexes.GenerateValueArray(outComplexVoxelIndices);
for (FInt3 Coordinates : outCoordinates)
{
@miguelemosreverte
miguelemosreverte / diagonals.py
Created April 13, 2018 22:36
diagonals in matrix
#!/bin/python
from __future__ import print_function
import os
import sys
#
# Complete the diagonalDifference function below.