GE Lua Documentation

Press F to search!

createArrowPool

Definition


-- @/lua/ge/extensions/core/groundMarkerArrows.lua:50

local function createArrowPool(floatingArrowColor)
  local group = scenetree.findObject("arrowPool")
  if not group then
    --log('I', 'arrow', 'Creating new arrow pool')
    -- Create the group if there is none yet
    group = createObject("SimGroup")
    group:registerObject("arrowPool")
    group.canSave = false
    for i = 0, 10 do
      local arrow = createObject('TSStatic')
      arrow:setField('shapeName', 0, "art/shapes/interface/s_mm_arrow_floating.dae")
      arrow.scale = vec3(arrowScale, arrowScale, arrowScale)
      arrow.useInstanceRenderData = true
      --arrow:setField('instanceColor1', 0, "1 1 1 1")
      arrow:setField('collisionType', 0, "None")
      arrow:setField('decalType', 0, "None")

      arrow.canSave = false
      arrow:registerObject(Sim.getUniqueName("arrow"))
      if not simObjectExists(arrow) then
        log('E', 'arrow', 'Error while creating an arrow object, aborting arrow pool creation.')
        return
      end
      group:addObject(arrow)

      -- Create proxy for this arrow
      local id = arrow:getId()
      arrowProxies[id] = {
        pos = vec3(0,0,0),
        rot = quat(0,0,0,1),
        state = "unused",
        wp = nil,
        nudgeForwardSmoother = newTemporalSmoothingNonLinear(3,3),
        nudgeForwardSmootherTarget = 0,
        nearFarScaleSmoother = newTemporalSmoothingNonLinear(15,15, arrowSmall),
        nearFarScaleSmootherTarget = 0,
        alphaSmoother = newTemporalSmoothingNonLinear(5,5, 0),
        alphaSmootherTarget = 0,
      }
      --log('I', 'arrow', 'Created arrow and proxy: ' .. tostring(id))
    end
  else
    --log('I', 'arrow', 'Using existing arrow pool: ' .. tostring(group:getId()))
    -- Reset all proxies to unused state
    for id, proxy in pairs(arrowProxies) do
      proxy.state = "unused"
      proxy.wp = nil
      proxy.nudgeForwardSmoother:set(0)
      proxy.nudgeForwardSmootherTarget = 0
      proxy.nearFarScaleSmoother:set(0)
      proxy.nearFarScaleSmootherTarget = 0
      proxy.alphaSmoother:set(0)
      proxy.alphaSmootherTarget = 0
      local arrow = scenetree.findObjectById(id)
      if arrow then
        arrow.hidden = true
      end
    end
    wpToArrowId = {}
    arrowToWp = {}
  end
end

Callers

@/lua/ge/extensions/core/groundMarkers.lua

  core_groundMarkerArrows.createArrowPool(M.floatingArrowColor)
    if showNavigationArrows then
      core_groundMarkerArrows.createArrowPool(M.floatingArrowColor)
      lastGenerationPos = nil