Brainstorming: Physics and Packet Handling for Entities
#11
added the functions, and I tested it a little bit more. It looks good.
Reply
Thanks given by:
#12
You haven't run the $source/AllToLua.bat / .sh script to refresh the Lua bindings. Doesn't really matter, because my nightbuild does that anyway, just for future Smile

So what's the plan now?
Reply
Thanks given by:
#13
Oh, good to know. Well, now more rambling regarding physics:

Is there a reason why we keep the physics implemented on each of the subclasses? shouldn't be the physics the same for all entities? I mean: stuff falls down, friction slows down objects, momentum depends on the mass of the objects, etc....

Maybe implemented in the entity class or cWorld or even as a simulator (probably as a simulator will need the most changes because our simulators only block-aware)
Reply
Thanks given by:
#14
I came to the very same conclusion and started refactoring everything into the cEntity class. But I underestimated the changes needed for this and bugs in other areas have soon overflown my patience, so I stashed that refactoring for later and never actually came back.

I think it's a good idea, just be careful with it, remember that there are a few entities that are not to be physics-emulated - the players, and entities riding other entities.
Reply
Thanks given by:
#15
Yeah, it's a lot of work. I think it will be really beneficial. We'll just need to do a lot of regression testing to be iron out all the details and bugs Smile.

Question for anybody:

MoveToCorrectChunk() function in the entity class, I'm trying to figure out what is the behavior of this function and what the a_bIgnoreOldChunk really does. This function is called after each setposition instead of after each tick, so I was wondering why is that?.
Reply
Thanks given by:
#16
Each entity lives in a cWorld instance, but besides that it is also assigned to a cChunk instance, to the correct chunk. If the entity moves, naturally it may cross chunk borders, so it has to be moved to the correct chunk - removed from the old one and added to the new one.
However, there are special cases when the entity is not removed from the old chunk - such as spawning the entity, or teleporting between worlds. That's what the a_bIgnoreOldChunk does.
(Hope I remember this correctly Smile )
Reply
Thanks given by:
#17
(03-26-2013, 05:25 PM)xoft Wrote: Each entity lives in a cWorld instance, but besides that it is also assigned to a cChunk instance, to the correct chunk. If the entity moves, naturally it may cross chunk borders, so it has to be moved to the correct chunk - removed from the old one and added to the new one.
However, there are special cases when the entity is not removed from the old chunk - such as spawning the entity, or teleporting between worlds. That's what the a_bIgnoreOldChunk does.
(Hope I remember this correctly Smile )

Seems about right Cool
Reply
Thanks given by:
#18
On a related topic, it seems that the vanilla server keeps track of the head rotation on a separate variable and sends a head packet when there is a change. I'll have to create a GetHeadYaw/SeHeadYaw and LookAt(Vector3i &pos) in cPawn, and update the protocol to send the right variable Also, I'll have to update the SetRotation because apparently the vanilla server makes the HeadYaw the same value as the rotation when there is a change... interesting...
Reply
Thanks given by:
#19
Well, we don't need to copy everything verbatim from the vanilla, the headyaw resetting seems a bit weird to me. I'd keep it separate, make the AI decide whether to do that or not.
Reply
Thanks given by:
#20
Yeah, I was thinking just that. Leave the head yaw completely separate from rotation...
Reply
Thanks given by:




Users browsing this thread: 9 Guest(s)