wowserhq / wowser

World of Warcraft in the browser using JavaScript and WebGL
MIT License
238 stars 63 forks source link

WMO groups aren't fully cloned #151

Open fallenoak opened 8 years ago

fallenoak commented 8 years ago

WMOGroup holds a reference to the root WMO for the group. Unfortunately, we're not passing in the right root WMO reference when calling WMOGroup.clone(), which can have some unpleasant side effects if state for a given WMO doesn't match across its clones.

I just ran in to this issue when working on portal culling. Portals are stored on the root WMO, and include things like world position data. Maps that render multiple copies of the same WMO will have different world placement, which impacts the world position data for portals.

The fix should be as simple as...

Modifying WMOGroup.clone():

clone(wmo) {
  return new this.constructor(wmo, this.groupID, this.data, this.path);
}

Modifying the end of WMOGroupBlueprint.load():

return this.cache.get(path).then((wmoGroup) => {
  return wmoGroup.clone(wmo);
});