Thanks. So at first glance ScheduleBatch is just about raycasting. I can avoid doing any raycasts at all because i already know the node heights from my heightmap. The work i am doing (incorrectly it seems) in ApplyJob is as follows:
public override void ApplyJob<T>(T mapper, GraphUpdateData data, JobDependencyTracker dependencyTracker)
base.ApplyJob(mapper, data, dependencyTracker);
TerrainGenerator generator = m_terrain.m_terrainGenerator;
int courseSubTilesWidth = generator.GetCourse().GetDims().x * CourseCell.s_subTilesWidth;
int heightMapWidth = courseSubTilesWidth + 1;
for (int idx = 0; idx < data.nodePositions.Length; ++idx)
Vector3 position = data.nodePositions[idx];
position -= new Vector3(0.5f, 0.0f, 0.5f);
position += new Vector3(heightMapWidth / 2, 0.0f, heightMapWidth / 2);
float height = GameStateManager.Instance.GetGameState().m_courseGameState.m_heights[(int)position.z * heightMapWidth + (int)position.x].m_height;
data.nodePositions[idx] = new Vector3(data.nodePositions[idx].x, height, data.nodePositions[idx].z);
data.nodeWalkable[idx] = !GameStateManager.Instance.GetGameState().m_courseGameState.m_occupancy[(int)position.z * courseSubTilesWidth + (int)position.x].m_occupied;
To speed this up I basically want to jobify the loop contents into batches without doing casts. One thing i couldn’t figure out here was how i was supposed to know where in the ‘data’ member i was indexing. I couldn’t get at the GridIndexMapper. Instead I did this based on knowing where the nodes would be in the scene relative to my terrain. It’s a total hack but works.
Can i just spawn myself some jobs without using the dependency tracker?