PhysicsScene.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. require "Physics3D/CollisionScene"
  2. class "PhysicsScene" (CollisionScene)
  3. function PhysicsScene:PhysicsScene(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "CollisionScene" then
  6. self.__ptr = arg[1].__ptr
  7. return
  8. end
  9. end
  10. for k,v in pairs(arg) do
  11. if type(v) == "table" then
  12. if v.__ptr ~= nil then
  13. arg[k] = v.__ptr
  14. end
  15. end
  16. end
  17. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  18. self.__ptr = Physics3D.PhysicsScene(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function PhysicsScene:Update()
  23. local retVal = Physics3D.PhysicsScene_Update(self.__ptr)
  24. end
  25. function PhysicsScene:addPhysicsChild(newEntity, type, mass, friction, restitution, group)
  26. local retVal = Physics3D.PhysicsScene_addPhysicsChild(self.__ptr, newEntity.__ptr, type, mass, friction, restitution, group)
  27. if Polycore.__ptr_lookup[retVal] ~= nil then
  28. return Polycore.__ptr_lookup[retVal]
  29. else
  30. Polycore.__ptr_lookup[retVal] = PhysicsSceneEntity("__skip_ptr__")
  31. Polycore.__ptr_lookup[retVal].__ptr = retVal
  32. return Polycore.__ptr_lookup[retVal]
  33. end
  34. end
  35. function PhysicsScene:trackPhysicsChild(newEntity, type, mass, friction, restitution, group)
  36. local retVal = Physics3D.PhysicsScene_trackPhysicsChild(self.__ptr, newEntity.__ptr, type, mass, friction, restitution, group)
  37. if Polycore.__ptr_lookup[retVal] ~= nil then
  38. return Polycore.__ptr_lookup[retVal]
  39. else
  40. Polycore.__ptr_lookup[retVal] = PhysicsSceneEntity("__skip_ptr__")
  41. Polycore.__ptr_lookup[retVal].__ptr = retVal
  42. return Polycore.__ptr_lookup[retVal]
  43. end
  44. end
  45. function PhysicsScene:addCharacterChild(newEntity, mass, friction, stepSize, group)
  46. local retVal = Physics3D.PhysicsScene_addCharacterChild(self.__ptr, newEntity.__ptr, mass, friction, stepSize, group)
  47. if Polycore.__ptr_lookup[retVal] ~= nil then
  48. return Polycore.__ptr_lookup[retVal]
  49. else
  50. Polycore.__ptr_lookup[retVal] = PhysicsCharacter("__skip_ptr__")
  51. Polycore.__ptr_lookup[retVal].__ptr = retVal
  52. return Polycore.__ptr_lookup[retVal]
  53. end
  54. end
  55. function PhysicsScene:addVehicleChild(newEntity, mass, friction, group)
  56. local retVal = Physics3D.PhysicsScene_addVehicleChild(self.__ptr, newEntity.__ptr, mass, friction, group)
  57. if Polycore.__ptr_lookup[retVal] ~= nil then
  58. return Polycore.__ptr_lookup[retVal]
  59. else
  60. Polycore.__ptr_lookup[retVal] = PhysicsVehicle("__skip_ptr__")
  61. Polycore.__ptr_lookup[retVal].__ptr = retVal
  62. return Polycore.__ptr_lookup[retVal]
  63. end
  64. end
  65. function PhysicsScene:__delete()
  66. Polycore.__ptr_lookup[self.__ptr] = nil
  67. Physics3D.delete_PhysicsScene(self.__ptr)
  68. end