formatting

This commit is contained in:
Dave Schuyler 2006-03-24 00:36:55 +00:00
parent 6e9bab7195
commit 19de130ffd
5 changed files with 75 additions and 48 deletions

View File

@ -96,7 +96,8 @@ class ClockDelta(DirectObject.DirectObject):
timeDelta is equal to the amount of time, in seconds,
that has been added to the global clock
"""
assert self.notify.debug("adjusting timebase by %f seconds" % timeDelta)
assert self.notify.debug(
"adjusting timebase by %f seconds" % timeDelta)
# adjust our timebase by the same amount
self.delta += timeDelta
@ -120,7 +121,8 @@ class ClockDelta(DirectObject.DirectObject):
"""
newDelta = (float(localTime) -
(float(networkTime) / NetworkTimePrecision))
self.newDelta(localTime, newDelta, newUncertainty, trustNew = trustNew)
self.newDelta(
localTime, newDelta, newUncertainty, trustNew = trustNew)
def peerToPeerResync(self, avId, timestamp, serverTime, uncertainty):
"""
@ -142,7 +144,9 @@ class ClockDelta(DirectObject.DirectObject):
# of some other request, and our local timestamp may have
# been resynced since then: ergo, the timestamp in this
# request is meaningless.
assert self.notify.debug("Ignoring request for resync from %s within %.3f s." % (avId, now - self.lastResync))
assert self.notify.debug(
"Ignoring request for resync from %s within %.3f s." %
(avId, now - self.lastResync))
return -1
# The timestamp value will be a timestamp that we sent out
@ -160,13 +164,16 @@ class ClockDelta(DirectObject.DirectObject):
# P2PResyncDelay. If it does not meet these requirements,
# it must be very old indeed, or someone is playing tricks
# on us.
self.notify.info("Ignoring old request for resync from %s." % (avId))
self.notify.info(
"Ignoring old request for resync from %s." % (avId))
else:
# Now the other client has told us his delta and uncertainty
# information, which was generated somewhere in the range
# [-elapsed, 0] seconds ago. That means our complete window
# is wider by that amount.
self.notify.info("Got sync +/- %.3f s, elapsed %.3f s, from %s." % (uncertainty, elapsed, avId))
self.notify.info(
"Got sync +/- %.3f s, elapsed %.3f s, from %s." %
(uncertainty, elapsed, avId))
delta -= elapsed / 2.0
uncertainty += elapsed / 2.0
@ -184,8 +191,12 @@ class ClockDelta(DirectObject.DirectObject):
"""
oldUncertainty = self.getUncertainty()
if oldUncertainty != None:
self.notify.info('previous delta at %.3f s, +/- %.3f s.' % (self.delta, oldUncertainty))
self.notify.info('new delta at %.3f s, +/- %.3f s.' % (newDelta, newUncertainty))
self.notify.info(
'previous delta at %.3f s, +/- %.3f s.' %
(self.delta, oldUncertainty))
self.notify.info(
'new delta at %.3f s, +/- %.3f s.' %
(newDelta, newUncertainty))
# Our previous measurement was self.delta +/- oldUncertainty;
# our new measurement is newDelta +/- newUncertainty. Take
# the intersection of both.
@ -209,7 +220,9 @@ class ClockDelta(DirectObject.DirectObject):
else:
newDelta = (low + high) / 2.0
newUncertainty = (high - low) / 2.0
self.notify.info('intersection at %.3f s, +/- %.3f s.' % (newDelta, newUncertainty))
self.notify.info(
'intersection at %.3f s, +/- %.3f s.' %
(newDelta, newUncertainty))
self.delta = newDelta
self.uncertainty = newUncertainty
@ -261,7 +274,6 @@ class ClockDelta(DirectObject.DirectObject):
ntime = int(math.floor(((localTime - self.delta) * ticksPerSec) + 0.5))
if bits == 16:
return self.__signExtend(ntime)
else:
# Assume the bits is either 16 or 32. If it's 32, no need
# to sign-extend. 32 bits gives us about 227 days of

View File

@ -39,7 +39,6 @@ public:
virtual void add_entry(CollisionEntry *entry);
virtual bool end_group();
PUBLISHED:
static TypeHandle get_class_type() {
return _type_handle;

View File

@ -40,7 +40,9 @@ PUBLISHED:
protected:
virtual bool handle_entries();
virtual void apply_net_shove(ColliderDef &def, const LVector3f &net_shove, const LVector3f &force_normal);
virtual void apply_net_shove(
ColliderDef &def, const LVector3f &net_shove,
const LVector3f &force_normal);
virtual void apply_linear_force(ColliderDef &def, const LVector3f &force);
private:

View File

@ -436,7 +436,8 @@ write(ostream &out, int indent_level) const {
out << " ignored\n";
}
if (!cnode_path.is_empty() && cnode_path.node()->is_of_type(CollisionNode::get_class_type())) {
if (!cnode_path.is_empty() && cnode_path.node()->is_of_type(
CollisionNode::get_class_type())) {
CollisionNode *cnode = DCAST(CollisionNode, cnode_path.node());
int num_solids = cnode->get_num_solids();
@ -547,7 +548,8 @@ r_traverse(CollisionLevelState &level_state) {
entry._from_node_path = level_state.get_collider_node_path(c);
entry._from = level_state.get_collider(c);
compare_collider_to_node(entry,
compare_collider_to_node(
entry,
level_state.get_parent_bound(c),
level_state.get_local_bound(c),
node_gbv);
@ -588,7 +590,8 @@ r_traverse(CollisionLevelState &level_state) {
entry._from_node_path = level_state.get_collider_node_path(c);
entry._from = level_state.get_collider(c);
compare_collider_to_geom_node(entry,
compare_collider_to_geom_node(
entry,
level_state.get_parent_bound(c),
level_state.get_local_bound(c),
node_gbv);
@ -618,7 +621,8 @@ r_traverse(CollisionLevelState &level_state) {
for (int i = 0; i < num_children; ++i) {
CollisionLevelState next_state(level_state, node->get_child(i));
if (i != index) {
next_state.set_include_mask(next_state.get_include_mask() & ~GeomNode::get_default_collide_mask());
next_state.set_include_mask(next_state.get_include_mask() &
~GeomNode::get_default_collide_mask());
}
r_traverse(next_state);
}

View File

@ -92,6 +92,7 @@ apply_friction(ColliderDef &def, LVector3f& vel, const LVector3f& force,
void PhysicsCollisionHandler::
apply_linear_force(ColliderDef &def, const LVector3f &force) {
}
////////////////////////////////////////////////////////////////////
// Function: PhysicsCollisionHandler::apply_net_shove
// Access: Protected, Virtual
@ -122,18 +123,22 @@ apply_net_shove(ColliderDef &def, const LVector3f& net_shove,
// Copy the force vector while translating it
// into the physics object coordinate system:
LVector3f adjustment=force;
physics_debug(" adjustment set "<<adjustment<<" len "<<adjustment.length());
physics_debug(
" adjustment set "<<adjustment<<" len "<<adjustment.length());
//NodePath np(def._node);
//CPT(TransformState) trans = np.get_net_transform();
//adjustment=adjustment*trans->get_mat();
//physics_debug(" adjustment trn "<<adjustment<<" len "<<adjustment.length());
//physics_debug(
// " adjustment trn "<<adjustment<<" len "<<adjustment.length());
adjustment=adjustment*actor->get_physics_object()->get_lcs();
physics_debug(" adjustment lcs "<<adjustment<<" len "<<adjustment.length());
physics_debug(
" adjustment lcs "<<adjustment<<" len "<<adjustment.length());
adjustment.normalize();
physics_debug(" adjustment nrm "<<adjustment<<" len "<<adjustment.length());
physics_debug(
" adjustment nrm "<<adjustment<<" len "<<adjustment.length());
float adjustmentLength=-(adjustment.dot(vel));
physics_debug(" adjustmentLength "<<adjustmentLength);
@ -145,11 +150,12 @@ apply_net_shove(ColliderDef &def, const LVector3f& net_shove,
#if 0
cerr<<"vel "<<vel<<endl;
cerr<<"net_shove "<<net_shove<<endl;
cerr<<"-force "<<-force<<endl;
actor->get_physics_object()->add_impact(-force, -vel);
cerr<<"force "<<force<<endl;
actor->get_physics_object()->add_impact(force, -vel);
#else
adjustment*=adjustmentLength;
physics_debug(" adjustment mul "<<adjustment<<" len "<<adjustment.length());
physics_debug(
" adjustment mul "<<adjustment<<" len "<<adjustment.length());
// This adjustment to our velocity will not reflect us off the surface,
// but will deflect us parallel (or tangent) to the surface:
@ -167,13 +173,17 @@ apply_net_shove(ColliderDef &def, const LVector3f& net_shove,
#ifndef NDEBUG //[
if (IS_THRESHOLD_EQUAL(vel.length(), old_vel.length(), 0.0001f)) {
// This is a check to see if vel is staying the same:
physics_debug(" vel is about the same length: "<<vel.length()<<" ~ "<<old_vel.length());
physics_debug(
" vel is about the same length: "
<<vel.length()<<" ~ "<<old_vel.length());
} else if (vel.length() > old_vel.length()) {
// This is a check to avoid adding engergy:
physics_debug(" vel got larger "<<vel.length()<<" > "<<old_vel.length());
physics_debug(
" vel got larger "<<vel.length()<<" > "<<old_vel.length());
} else {
// This is a check to avoid losing engergy:
physics_debug(" vel got smaller "<<vel.length()<<" < "<<old_vel.length());
physics_debug(
" vel got smaller "<<vel.length()<<" < "<<old_vel.length());
}
if (vel.length() > 10.0f) {
// This is a check to see if the velocity is higher than I expect it