text
stringlengths
1
93.6k
# end point
x2, y2, z2 = self.app.player.position + self.app.player.forward * MAX_RAY_DIST
current_voxel_pos = glm.ivec3(x1, y1, z1)
self.voxel_id = 0
self.voxel_normal = glm.ivec3(0)
step_dir = -1
dx = glm.sign(x2 - x1)
delta_x = min(dx / (x2 - x1), 10000000.0) if dx != 0 else 10000000.0
max_x = delta_x * (1.0 - glm.fract(x1)) if dx > 0 else delta_x * glm.fract(x1)
dy = glm.sign(y2 - y1)
delta_y = min(dy / (y2 - y1), 10000000.0) if dy != 0 else 10000000.0
max_y = delta_y * (1.0 - glm.fract(y1)) if dy > 0 else delta_y * glm.fract(y1)
dz = glm.sign(z2 - z1)
delta_z = min(dz / (z2 - z1), 10000000.0) if dz != 0 else 10000000.0
max_z = delta_z * (1.0 - glm.fract(z1)) if dz > 0 else delta_z * glm.fract(z1)
while not (max_x > 1.0 and max_y > 1.0 and max_z > 1.0):
result = self.get_voxel_id(voxel_world_pos=current_voxel_pos)
if result[0]:
self.voxel_id, self.voxel_index, self.voxel_local_pos, self.chunk = result
self.voxel_world_pos = current_voxel_pos
if step_dir == 0:
self.voxel_normal.x = -dx
elif step_dir == 1:
self.voxel_normal.y = -dy
else:
self.voxel_normal.z = -dz
return True
if max_x < max_y:
if max_x < max_z:
current_voxel_pos.x += dx
max_x += delta_x
step_dir = 0
else:
current_voxel_pos.z += dz
max_z += delta_z
step_dir = 2
else:
if max_y < max_z:
current_voxel_pos.y += dy
max_y += delta_y
step_dir = 1
else:
current_voxel_pos.z += dz
max_z += delta_z
step_dir = 2
return False
def get_voxel_id(self, voxel_world_pos):
cx, cy, cz = chunk_pos = voxel_world_pos / CHUNK_SIZE
if 0 <= cx < WORLD_W and 0 <= cy < WORLD_H and 0 <= cz < WORLD_D:
chunk_index = cx + WORLD_W * cz + WORLD_AREA * cy
chunk = self.chunks[chunk_index]
lx, ly, lz = voxel_local_pos = voxel_world_pos - chunk_pos * CHUNK_SIZE
voxel_index = lx + CHUNK_SIZE * lz + CHUNK_AREA * ly
voxel_id = chunk.voxels[voxel_index]
return voxel_id, voxel_index, voxel_local_pos, chunk
return 0, 0, 0, 0
# <FILESEP>
"""Create and manage virtual machines.
This script expects that the following environment vars are set:
AZURE_TENANT_ID: your Azure Active Directory tenant id or domain
AZURE_CLIENT_ID: your Azure Active Directory Application Client ID
AZURE_CLIENT_SECRET: your Azure Active Directory Application Secret
AZURE_SUBSCRIPTION_ID: your Azure Subscription Id
"""
import os
import traceback
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.network import NetworkManagementClient
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.compute.models import DiskCreateOption
from msrestazure.azure_exceptions import CloudError
from haikunator import Haikunator
haikunator = Haikunator()
# Azure Datacenter
LOCATION = 'westus'
# Resource Group