mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 01:44:06 -04:00
update for deadreconing
This commit is contained in:
parent
ce29a01449
commit
2e724b5e4d
@ -8,7 +8,7 @@
|
|||||||
#define BUILDING_DLL BUILDING_DIRECT
|
#define BUILDING_DLL BUILDING_DIRECT
|
||||||
|
|
||||||
#define COMPONENT_LIBS \
|
#define COMPONENT_LIBS \
|
||||||
directbase dcparse showbase
|
directbase dcparse showbase deadrec
|
||||||
|
|
||||||
#define OTHER_LIBS panda pandaexpress dtool
|
#define OTHER_LIBS panda pandaexpress dtool
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
from ShowBaseGlobal import *
|
from ShowBaseGlobal import *
|
||||||
import NodePath
|
import NodePath
|
||||||
import DistributedObject
|
import DistributedObject
|
||||||
|
import Correction
|
||||||
|
import Prediction
|
||||||
|
import Task
|
||||||
|
|
||||||
class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
||||||
"""Distributed Node class:"""
|
"""Distributed Node class:"""
|
||||||
@ -12,6 +15,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
|||||||
self.DistributedNode_initialized
|
self.DistributedNode_initialized
|
||||||
except:
|
except:
|
||||||
self.DistributedNode_initialized = 1
|
self.DistributedNode_initialized = 1
|
||||||
|
self.DeadReconing = None
|
||||||
DistributedObject.DistributedObject.__init__(self, cr)
|
DistributedObject.DistributedObject.__init__(self, cr)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -23,6 +27,43 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
|||||||
self.reparentTo(hidden)
|
self.reparentTo(hidden)
|
||||||
DistributedObject.DistributedObject.delete(self)
|
DistributedObject.DistributedObject.delete(self)
|
||||||
|
|
||||||
|
def setDeadReconing(self, state):
|
||||||
|
self.DeadReconing = state
|
||||||
|
if state:
|
||||||
|
self.Predictor = NullPrediction(Point3(self.getX(), self.getY(),
|
||||||
|
self.getZ()))
|
||||||
|
self.Corrector = SplineCorrection(Point3(self.getX(), self.getY(),
|
||||||
|
self.getZ()), Vec3(0))
|
||||||
|
taskName = self.taskName("correctionPos")
|
||||||
|
# remove any old tasks
|
||||||
|
taskMgr.removeTasksNamed(taskName)
|
||||||
|
# spawn new task
|
||||||
|
task = Task.Task(self.correctPos)
|
||||||
|
taskMgr.spawnTaskNamed(task, taskName)
|
||||||
|
else:
|
||||||
|
self.Predictor = None
|
||||||
|
self.Corrector = None
|
||||||
|
taskName = self.taskName("correctionPos")
|
||||||
|
taskMgr.removeTasksNamed(taskName)
|
||||||
|
|
||||||
|
def setPos(self, x, y, z):
|
||||||
|
if self.DeadReconing:
|
||||||
|
self.Predictor.newTelemetry(Point3(x, y, z))
|
||||||
|
else:
|
||||||
|
NodePath.NodePath.setPos(self, x, y, z)
|
||||||
|
|
||||||
|
def setHpr(self, h, p, r):
|
||||||
|
NodePath.NodePath.setHpr(self, h, p, r)
|
||||||
|
|
||||||
|
def setPosHpr(self, x, y, z, h, p, r):
|
||||||
|
if self.DeadReconing:
|
||||||
|
self.Predictor.newTelemetry(Point3(x, y, z))
|
||||||
|
else:
|
||||||
|
NodePath.NodePath.setPosHpr(self, x, y, z, h, p, r)
|
||||||
|
|
||||||
|
def d_setDeadReconing(self, state):
|
||||||
|
self.sendUpdate("setDeadReconing", [state])
|
||||||
|
|
||||||
def d_setPos(self, x, y, z):
|
def d_setPos(self, x, y, z):
|
||||||
self.sendUpdate("setPos", [x, y, z])
|
self.sendUpdate("setPos", [x, y, z])
|
||||||
|
|
||||||
@ -36,3 +77,10 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
|
|||||||
|
|
||||||
def d_setPosHpr(self, x, y, z, h, p, r):
|
def d_setPosHpr(self, x, y, z, h, p, r):
|
||||||
self.sendUpdate("setPosHpr", [x, y, z, h, p, r])
|
self.sendUpdate("setPosHpr", [x, y, z, h, p, r])
|
||||||
|
|
||||||
|
def correctPos(self, task):
|
||||||
|
self.Corrector.newTarget(self.Predictor.getPos(),
|
||||||
|
self.Predictor.getVel())
|
||||||
|
self.Corrector.step()
|
||||||
|
NodePath.NodePath.setPos(self, self.Corrector.getPos())
|
||||||
|
return Task.cont
|
||||||
|
Loading…
x
Reference in New Issue
Block a user