Example #1
0
    def registerParent(self, token, parent):
        if token in self.token2nodepath:
            self.notify.error(
                "registerParent: token '%s' already registered, referencing %s" %
                (token, repr(self.token2nodepath[token])))

        if isDefaultValue(token):
            self.notify.error('parent token (for %s) cannot be a default value (%s)' % (repr(parent), token))

        if type(token) is types.IntType:
            if token > 0xFFFFFFFF:
                self.notify.error('parent token %s (for %s) is out of uint32 range' % (token, repr(parent)))

        self.notify.debug("registering %s as '%s'" % (repr(parent), token))
        self.token2nodepath[token] = parent

        # if we have any pending children, add them
        if token in self.pendingParentToken2children:
            children = self.pendingParentToken2children[token]
            del self.pendingParentToken2children[token]
            for child in children:
                # NOTE: We do a plain-old reparentTo here (non-wrt)
                # under the assumption that the node has been
                # positioned as if it is already under the new parent.
                #
                # The only case that I can think of where the parent
                # node would not have been registered at the time of
                # the reparent request is when we're entering a new
                # zone and manifesting remote toons along with
                # other distributed objects, and a remote toon is
                # requesting to be parented to geometry owned by a
                # distributed object that has not yet been manifested.
                #
                # (The situation in the factory is a little different;
                # the distributed toons of your companions are never
                # disabled, since the toons are in the factory's uberzone.
                # They send out requests to be parented to nodes that
                # may be distributed objects, which may not be generated
                # on your client)
                #
                # It is therefore important for that remote toon to
                # have his position set as a required field, relative
                # to the parent node, after the reparent request.
                # If the node has already been registered, the toon will
                # be in the correct position. Otherwise, the toon will
                # have the correct position but the wrong parent node,
                # until this code runs and corrects the toon's parent
                # node. Since we don't start rendering until all objects
                # in a new zone have been generated, all of that action
                # will happen in a single frame, and the net result will
                # be that the toon will be in the right place when
                # rendering starts.
                self.notify.debug("performing reparent of %s to '%s'" %
                                  (repr(child), token))
                child.reparentTo(self.token2nodepath[token])
                # remove this child from the child->parent table
                assert self.pendingChild2parentToken[child] == token
                del self.pendingChild2parentToken[child]
Example #2
0
 def requestReparent(self, child, parentToken):
     if self.token2nodepath.has_key(parentToken):
         self.privRemoveReparentRequest(child)
         self.notify.debug("performing wrtReparent of %s to '%s'" % (repr(child), parentToken))
         child.wrtReparentTo(self.token2nodepath[parentToken])
     else:
         if isDefaultValue(parentToken):
             self.notify.error('child %s requested reparent to default-value token: %s' % (repr(child), parentToken))
         self.notify.debug("child %s requested reparent to parent '%s' that is not (yet) registered" % (repr(child), parentToken))
         self.privRemoveReparentRequest(child)
         self.pendingChild2parentToken[child] = parentToken
         self.pendingParentToken2children.setdefault(parentToken, [])
         self.pendingParentToken2children[parentToken].append(child)
         child.reparentTo(hidden)
Example #3
0
 def registerParent(self, token, parent):
     if self.token2nodepath.has_key(token):
         self.notify.error("registerParent: token '%s' already registered, referencing %s" % (token, repr(self.token2nodepath[token])))
     if isDefaultValue(token):
         self.notify.error('parent token (for %s) cannot be a default value (%s)' % (repr(parent), token))
     if type(token) is types.IntType:
         if token > 4294967295L:
             self.notify.error('parent token %s (for %s) is out of uint32 range' % (token, repr(parent)))
     self.notify.debug("registering %s as '%s'" % (repr(parent), token))
     self.token2nodepath[token] = parent
     if token in self.pendingParentToken2children:
         children = self.pendingParentToken2children[token]
         del self.pendingParentToken2children[token]
         for child in children:
             self.notify.debug("performing reparent of %s to '%s'" % (repr(child), token))
             child.reparentTo(self.token2nodepath[token])
             del self.pendingChild2parentToken[child]
Example #4
0
 def requestReparent(self, child, parentToken):
     if parentToken in self.token2nodepath:
         # this parent has registered
         # this child may already be waiting on a different parent;
         # make sure they aren't any more
         self.privRemoveReparentRequest(child)
         self.notify.debug("performing wrtReparent of %s to '%s'" %
                           (repr(child), parentToken))
         child.wrtReparentTo(self.token2nodepath[parentToken])
     else:
         if isDefaultValue(parentToken):
             self.notify.error('child %s requested reparent to default-value token: %s' % (repr(child), parentToken))
         self.notify.debug(
             "child %s requested reparent to parent '%s' that is not (yet) registered" %
             (repr(child), parentToken))
         # cancel any pending reparent on behalf of this child
         self.privRemoveReparentRequest(child)
         # make note of this pending parent request
         self.pendingChild2parentToken[child] = parentToken
         self.pendingParentToken2children.setdefault(parentToken, [])
         self.pendingParentToken2children[parentToken].append(child)
         # there is no longer any valid place for the child in the
         # scenegraph; put it under hidden
         child.reparentTo(hidden)