Skip to content

Conversation

greglemonmapbox
Copy link
Contributor

Related issue

Runtime map updating

Description of changes

  • Added EditorHelper class, which allows us to easily get class references in prop drawers
  • Added MapboxDataProperty, which contains a settable HasChanged bool and a corresponding System.EventHandler that gets fired when HasChanged is set to true
  • ModifierBase, LayerProperties and CoreVectorLayerProperties extend MapboxDataProperty
  • PropertyDrawers for relevant AbstractMap UI classes use resulting bool return value of SerializedObject.ApplyModifiedProperties to set HasChanged to true
  • Image section: Changing DataSource at runtime reloads image layer of map
  • Terrain section: Changing DataSource, ElevationLayerType, and ExaggerationFactor reloads terrain and vector section of map

Known issues

  • Vector section UI changes fire events; right now, VectorLayerVisualizer.UpdateVector listens for these events, but only displays debug message for now.
  • Changing terrain UI causes tiles to be un/re-registered, which means VectorLayerVisualizer re-adds VectorLayerVisualizer.UpdateVector to the various layer properties PropertyHasChanged event, resulting in continually multiplying listener triggering, which can be seen in the resulting debug messages in the console window.

QA checklists

  • Add relevant code comments. Every API class and method should have <summary> description as well as description of parameters.
  • Add tests for new/changed/updated classes and methods!!!
  • Check out conventions in CONTRIBUTING.md.
  • Check out conventions in CODING-STYLE.md
  • Update the changelog
  • Update documentation.

Reviewers

Tag your reviewer(s). Choose wisely.

greglemonmapbox and others added 30 commits July 25, 2018 12:36
…Data method, which overrides DataFetcher.FetchData and accepts DataFetcherParameters as the sole param, which is them cast to required subclasses as needed.
…using _activeTiles dictionary in AbstractMapVisualizer instead. MapVisualizer.RedrawImageLayer listens for event OnMapIdUpdated and handles business of redrawing/refetching image layer, triggering event MapVisualizer.OnImageLayerRedrawn upon completion. Public event AbstractMap.OnImageLayerRedrawn listens for event MapVisualizer.OnImageLayerRedrawn; developers can register custom gameplay functions to listen for this event in their code.
…d return type of TerrainLayer.Factory to TerrainFactoryBase; was being downcast to AbstractMapTileFactory.
… map visualizer

add current terrain strategy field in unity tile
…ges, and do so by calling UpdateProperty in the property script. Removed INotify interface; replaced with simple delegate events instead.
change VectorLayer to inherit from AbstractLayer
…ct map

remove layer redrawn even in map visualizer as command is coming from abstract map now anyway
create OnMapRedrawn event in abstract map to replace individual layer events
…e class they are drawing; initial work on getting general section to trigger changes in UI.
… out SetChildProperties call in AbstractMap line 498.
…sed null values

merged OnErrorOccurred and OnError methods in factories
change vector layer visualizer to create new modules iff they do not already exist (work in progress)
…Drawer.UpdateProperty to ensure update map functionality uses up-to-date data.
…-merge-fresh

# Conflicts:
#	sdkproject/Assets/Mapbox/Unity/Editor/MapManagerEditor.cs
#	sdkproject/Assets/Mapbox/Unity/Editor/PropertyDrawers/ElevationLayerPropertiesDrawer.cs
#	sdkproject/Assets/Mapbox/Unity/Map/AbstractMapVisualizer.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Data/UnityTile.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/AbstractTileFactory.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/ImageDataFetcher.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/MapImageFactory.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/TerrainDataFetcher.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/TerrainFactoryBase.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/TerrainStrategies/ElevatedTerrainStrategy.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/TerrainStrategies/FlatSphereTerrainStrategy.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/TerrainStrategies/LowPolyTerrainStrategy.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorDataFetcher.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/Factories/VectorTileFactory.cs
#	sdkproject/Assets/Mapbox/Unity/MeshGeneration/LayerVisualizers/VectorLayerVisualizer.cs
fix an issue where terrain layer update didn't handle vector layer corrections (snap terrain) correct
…ctLayer.cs function calls with VectorUpdateType enum. UpdateProperty passes new VectorUpdate class instead of serializedProperty. Added additional delegates to VectorLayerProperties for different update types, but maybe we can call OnPropertyUpdated and pass/return VectorUpdateType? Maybe do public Func<VectorUpdateType, VectorUpdateType> OnPropertyUpdated = delegate { return VectorUpdateType}?
…roperties inherits from this. VectorLayerVisualizer assigns methods to delegate; temp solution displays debug messages for "Update Colliders" and "Update Materials". Both property drawers use hard coded 0 index to get a vectorSubLayer, need to find a way to get correct sublayer index to proceed.
…r; vector update is now triggered from material/collider option delegates, figures out which logic it needs to run via dictionary lookup, which retrieves funcion.
…wers now use EditorHelper.GetTargetObjectOfProperty to get class instance, and result check of ApplyModifiedProperties bool value to set HasChanged to true.
…re specific property sets w/ HasChanged = true.
…alls. Removed VectorUpdate class and UpdateProperty method from VectorLayerPropertiesDrawer. LayerProperties now inherits from MapboxDataProperty class. Removed unused OnPropertyUpdatedComplete/Collider/Material delegates from VectorLayerProperties.
…ved Begin/End change check calls, using bool result of ApplyModifiedProperties() to set HasChanged property.
… previous commit. Changed AbstractLayer.NotifyUpdateLayer and AbstractLayer.UpdateLayerHandler to use bool instead of VectorUpdateType as second argument.
…lper.GetTargetObjectOfProperty(property) method.
Copy link
Contributor

@abhishektrip abhishektrip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@greglemonmapbox @brnkhy Could you please go through the comments and review.

}
}

public int layerId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need an id in GeometryMaterialOptions? LayerId should be part of feature sublayer properties.

using System.Linq;
using System.Reflection;

namespace com.spacepuppyeditor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this namespace to Mapbox.Editor , Add acknowledgement for spacepuppyeditor dev , remove all commented code.

if (element.Contains("["))
{
//var tp = obj.GetType();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can me made to work by swapping the commented lines with the uncommented ones.

using UnityEngine;
using Mapbox.Unity.Map;
using Mapbox.VectorTile.ExtensionMethods;
using com.spacepuppyeditor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace namespace with mapbox.editor.

using System.Linq;
using System;
using Mapbox.VectorTile.ExtensionMethods;
using com.spacepuppyeditor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace with Mapbox.editor.

}

if (tile.MeshFilter.mesh.vertexCount == 0)
//_newVertexList.Count is the vertex count this strategy is expected to use
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment relevant? the check is changed to a different thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no not anymore, that check will probably change soon as well

}

if (tile.MeshFilter.mesh.vertexCount == 0)
//_newVertexList.Count is the vertex count this strategy is expected to use
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment if not relevant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

//OnColliderChange
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?


_defaultStack.MeshModifiers.AddRange(defaultMeshModifierStack);
_defaultStack.GoModifiers.AddRange(defaultGOModifierStack);
//_defaultStack.MeshModifiers.AddRange(defaultMeshModifierStack);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this commented by mistake? Where are we adding default modifiers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@atripathi-mb it's adding default modifiers directly to the list. previously they were added to defaultMeshModifierStack and that list was added to the real mesh mod list using add range.

using System;
using Mapbox.Unity.MeshGeneration.Data;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move MapboxDataProperty to it's own file. Also, namespace for MapboxDataProperty should not be Mapbox.Unity.MeshGeneration.Modifiers

greglemonmapbox and others added 9 commits September 6, 2018 13:51
…related to serialized property work and those referencing external classes; removed dead/commented code. Changed using com.spacepuppyeditor to Mapbox.Editor in relevant classes.
…ugging

removed comments from older versions of the ElevatedTerrainStrategy file
removed two commented out lines in VectorLayerVisualizer to prevent confusion
@abhishektrip abhishektrip merged commit e14b453 into develop Sep 7, 2018
abhishektrip added a commit that referenced this pull request Sep 13, 2018
* develop:
  Terrain section event refactor apply property changes at end of gui (#1009)
  fix an issue where TerrainFactoryBase didn't respect "none" terrain option (#1006)
  API's for runtime editing.  (#1005)
  Image section event refactor (#1002)
  Fix buildingid setting (#998)
  Map update develop merge fresh (#994)
  Improve query height method (#979)
  Mid floor calculation bug fix (#968)
  Updated changelog version to v1.4.6
  update changelog
  change ElevatedTerrainStrategy and ElevatedTerrainWithSidesStrategy classes to create flat terrain mesh on height data errors
  UWP fixes (and more) (#945)
@abhishektrip abhishektrip deleted the map-update-develop-merge-fresh branch October 12, 2018 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants