Skip to content

Commit

Permalink
fix: bulk of fixes (decentraland#536)
Browse files Browse the repository at this point in the history
* Fix decentraland#502
* Fix decentraland#499
* chore: reenable animator and audio
* fix decentraland/builder#134, close decentraland/builder#136
* fix decentraland#537
  • Loading branch information
Agustin Mendez authored and eordano committed Mar 9, 2019
1 parent b31fdb3 commit baf09ef
Show file tree
Hide file tree
Showing 35 changed files with 583 additions and 435 deletions.
18 changes: 11 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ jobs:
- run: sudo apt-get -y -qq install awscli
- run:
name: Deploy to .zone if tests pass and branch is Master
command: aws s3 sync static s3://client.decentraland.zone/ --exclude "branch/*" --acl public-read
# - run:
# name: Deploy to .today if tests pass and branch is Master
# command: aws s3 sync static s3://client.decentraland.today/ --acl public-read
command: aws s3 sync static s3://explorer.decentraland.zone/ --exclude "branch/*" --acl public-read
# - run:
# name: Deploy to .today if tests pass and branch is Master
# command: aws s3 sync static s3://explorer.decentraland.today/ --acl public-read
- run:
name: Deploy tag
name: Deploy tag to .today/tags/$CIRCLE_TAG
command: |
[ ! -z "${CIRCLE_TAG}" ] && aws s3 sync static s3://client.decentraland.today/tags/$CIRCLE_TAG --exclude "tags/*" --acl public-read || true
[ ! -z "${CIRCLE_TAG}" ] && aws s3 sync static s3://explorer.decentraland.today/tags/$CIRCLE_TAG --exclude "tags/*" --acl public-read || true
- run:
name: Deploy tag to .today
command: |
[ ! -z "${CIRCLE_TAG}" ] && aws s3 sync static s3://explorer.decentraland.today/ --exclude "tags/*" --acl public-read || true
pull-deploy:
docker:
Expand All @@ -121,7 +125,7 @@ jobs:
- run: sudo apt-get -y -qq install awscli
- run:
name: Deploy to S3 under subfolder if tests pass and branch is not master
command: aws s3 sync static s3://client.decentraland.zone/branch/$CIRCLE_BRANCH --acl public-read
command: aws s3 sync static s3://explorer.decentraland.zone/branch/$CIRCLE_BRANCH --acl public-read

workflows:
version: 2
Expand Down
142 changes: 0 additions & 142 deletions packages/atomicHelpers/DebugTelemetry.ts

This file was deleted.

20 changes: 13 additions & 7 deletions packages/atomicHelpers/parcelScenePositions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@ export function isOnLimit(value: number): boolean {
return Number.isInteger(value / parcelLimits.parcelSize)
}

export function isOnLimits({ maximum, minimum }: BoundingInfo, verificationText: string): boolean {
export function isOnLimits({ maximum, minimum }: BoundingInfo, parcels: Set<string>): boolean {
// Computes the world-axis-aligned bounding box of an object (including its children),
// accounting for both the object's, and children's, world transforms

auxVec3.x = minimum.x
auxVec3.z = minimum.z
worldToGrid(auxVec3, auxVec2)
if (!verificationText.includes(`${auxVec2.x},${auxVec2.y}`)) {
if (!parcels.has(`${auxVec2.x},${auxVec2.y}`)) {
return false
}

auxVec3.x = isOnLimit(maximum.x) ? minimum.x : maximum.x
auxVec3.z = isOnLimit(maximum.z) ? minimum.z : maximum.z
worldToGrid(auxVec3, auxVec2)
if (!verificationText.includes(`${auxVec2.x},${auxVec2.y}`)) {
if (!parcels.has(`${auxVec2.x},${auxVec2.y}`)) {
return false
}

auxVec3.x = minimum.x
auxVec3.z = isOnLimit(maximum.z) ? minimum.z : maximum.z
worldToGrid(auxVec3, auxVec2)
if (!verificationText.includes(`${auxVec2.x},${auxVec2.y}`)) {
if (!parcels.has(`${auxVec2.x},${auxVec2.y}`)) {
return false
}

auxVec3.x = isOnLimit(maximum.x) ? minimum.x : maximum.x
auxVec3.z = minimum.z
worldToGrid(auxVec3, auxVec2)
if (!verificationText.includes(`${auxVec2.x},${auxVec2.y}`)) {
if (!parcels.has(`${auxVec2.x},${auxVec2.y}`)) {
return false
}

Expand All @@ -84,12 +84,18 @@ export function decodeParcelSceneBoundaries(boundaries: string) {
return { base, parcels }
}

/**
* Converts a position into a string { x: -1, y: 5 } => "-1,5"
*/
export function encodeParcelPosition(base: Vector2Component) {
return `${base.x | 0},${base.y | 0}`
}
export function encodeParcelSceneBoundaries(base: Vector2Component, parcels: Vector2Component[]) {
let str = `${base.x | 0},${base.y | 0}`
let str = encodeParcelPosition(base)

for (let index = 0; index < parcels.length; index++) {
const parcel = parcels[index]
str = str + `;${parcel.x | 0},${parcel.y | 0}`
str = str + `;${encodeParcelPosition(parcel)}`
}

return str
Expand Down
31 changes: 21 additions & 10 deletions packages/dcl/WebGLParcelScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ import { getParcelSceneLimits } from 'atomicHelpers/landHelpers'
import { DEBUG, EDITOR } from 'config'
import { checkParcelSceneBoundaries } from './entities/utils/checkParcelSceneLimits'
import { BaseEntity } from 'engine/entities/BaseEntity'
import { encodeParcelSceneBoundaries, gridToWorld } from 'atomicHelpers/parcelScenePositions'
import { encodeParcelSceneBoundaries, gridToWorld, encodeParcelPosition } from 'atomicHelpers/parcelScenePositions'
import { removeEntityHighlight, highlightEntity } from 'engine/components/ephemeralComponents/HighlightBox'
import { createAxisEntity, createParcelOutline } from './entities/utils/debugEntities'
import { createLogger } from 'shared/logger'
import { DevTools } from 'shared/apis/DevTools'
import { ParcelIdentity } from 'shared/apis/ParcelIdentity'
import { WebGLScene } from './WebGLScene'
import { IEvents } from 'decentraland-ecs/src/decentraland/Types'
import { scene } from 'engine/renderer'

export class WebGLParcelScene extends WebGLScene<LoadableParcelScene> {
public encodedPositions: string

private setOfEntitiesOutsideBoundaries = new Set<BaseEntity>()
private validationInterval = null
private parcelSet = new Set<string>()

private shouldValidateBoundaries = false

constructor(public data: EnvironmentData<LoadableParcelScene>) {
super(
Expand Down Expand Up @@ -46,6 +49,10 @@ export class WebGLParcelScene extends WebGLScene<LoadableParcelScene> {
this.context.logger = this.logger = createLogger(data.data.basePosition.x + ',' + data.data.basePosition.y + ': ')

this.encodedPositions = encodeParcelSceneBoundaries(data.data.basePosition, data.data.parcels)

this.parcelSet.add(encodeParcelPosition(data.data.basePosition))
data.data.parcels.forEach($ => this.parcelSet.add(encodeParcelPosition($)))

Object.assign(this.context.metricsLimits, getParcelSceneLimits(data.data.parcels.length))

// Set a debug name in the root entity
Expand All @@ -57,10 +64,6 @@ export class WebGLParcelScene extends WebGLScene<LoadableParcelScene> {
gridToWorld(this.data.data.basePosition.x, this.data.data.basePosition.y, this.context.rootEntity.position)
this.context.rootEntity.freezeWorldMatrix()

this.validationInterval = setInterval(() => {
this.checkBoundaries()
}, 5000)

this.context.on('metricsUpdate', data => {
if (!EDITOR) {
this.checkLimits(data)
Expand All @@ -69,12 +72,21 @@ export class WebGLParcelScene extends WebGLScene<LoadableParcelScene> {

if (DEBUG) {
this.context.onEntityMatrixChangedObservable.add(_entity => {
this.checkBoundaries()
this.shouldValidateBoundaries = true
})
this.initDebugEntities()
}

this.context.updateMetrics()

scene.onAfterRenderObservable.add(this.afterRender)
}

afterRender = () => {
if (this.shouldValidateBoundaries) {
this.shouldValidateBoundaries = false
this.checkBoundaries()
}
}

registerWorker(worker: SceneWorker): void {
Expand All @@ -94,8 +106,7 @@ export class WebGLParcelScene extends WebGLScene<LoadableParcelScene> {

dispose(): void {
super.dispose()

clearInterval(this.validationInterval)
scene.onAfterRenderObservable.removeCallback(this.afterRender)
}

/**
Expand Down Expand Up @@ -132,7 +143,7 @@ export class WebGLParcelScene extends WebGLScene<LoadableParcelScene> {
*/
checkBoundaries() {
const newSet = new Set<BaseEntity>()
this.context.entities.forEach(entity => checkParcelSceneBoundaries(this.encodedPositions, newSet, entity))
this.context.entities.forEach(entity => checkParcelSceneBoundaries(this.parcelSet, newSet, entity))
// remove the highlight from the entities that were outside but they are no longer outside
this.setOfEntitiesOutsideBoundaries.forEach($ => {
if (!newSet.has($) && this.context.entities.has($.id)) {
Expand Down
21 changes: 8 additions & 13 deletions packages/dcl/entities/utils/checkParcelSceneLimits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,19 @@ function totalBoundingInfo(meshes: BABYLON.AbstractMesh[]) {
* Receives the encoded parcelScene parcels and the entity to traverse
*/
export function checkParcelSceneBoundaries(
encodedParcels: string,
encodedParcels: Set<string>,
objectsOutside: Set<BaseEntity>,
entity: BaseEntity
) {
const numberOfParcels = encodedParcels.replace(/;+/g, ';').split(';').length
const verificationText = ';' + encodedParcels + ';'

const maxHeight = Math.log2(numberOfParcels) * parcelLimits.height
const maxHeight = Math.log2(encodedParcels.size + 1) * parcelLimits.height
const minHeight = -maxHeight

entity.traverseControl(node => {
if (node[ignoreBoundaryCheck]) {
entity.traverseControl(entity => {
if (entity[ignoreBoundaryCheck]) {
return 'BREAK'
}

const mesh = node.getObject3D(BasicShape.nameInEntity)
const mesh = entity.getObject3D(BasicShape.nameInEntity)

if (!mesh) {
return 'CONTINUE'
Expand All @@ -97,17 +94,15 @@ export function checkParcelSceneBoundaries(
return 'CONTINUE'
}

mesh.computeWorldMatrix(true)

const bbox = totalBoundingInfo(meshes)

if (bbox.maximum.y > maxHeight || bbox.minimum.y < minHeight) {
objectsOutside.add(node)
objectsOutside.add(entity)
return 'BREAK'
}

if (!isOnLimits(bbox, verificationText)) {
objectsOutside.add(node)
if (!isOnLimits(bbox, encodedParcels)) {
objectsOutside.add(entity)
return 'BREAK'
}

Expand Down
Loading

0 comments on commit baf09ef

Please sign in to comment.