summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Thronefall/NGS.MeshFusionPro/DynamicObjectsCombiner.cs
blob: a7d611563284498a8d871287fc337e30b23bfee3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections.Generic;

namespace NGS.MeshFusionPro;

public class DynamicObjectsCombiner : ObjectsCombiner<DynamicCombinedObject, DynamicCombineSource>
{
	private ICombinedMeshFactory _factory;

	private DynamicCombinedObjectMatcher _matcher;

	private int _vertexLimit;

	public DynamicObjectsCombiner(ICombinedMeshFactory factory, int vertexLimit)
	{
		_factory = factory;
		_matcher = new DynamicCombinedObjectMatcher(vertexLimit);
		_vertexLimit = vertexLimit;
	}

	public override void AddSource(DynamicCombineSource source)
	{
		if (source.Base.CombineInfo.vertexCount < _vertexLimit)
		{
			base.AddSource(source);
		}
	}

	protected override void CombineSources(DynamicCombinedObject root, IList<DynamicCombineSource> sources)
	{
		root.Combine(sources);
	}

	protected override DynamicCombinedObject CreateCombinedObject(DynamicCombineSource source)
	{
		return DynamicCombinedObject.Create(_factory, source.Base.RendererSettings);
	}

	protected override CombinedObjectMatcher<DynamicCombinedObject, DynamicCombineSource> GetMatcher()
	{
		return _matcher;
	}
}