feature requests for dicussion

9 views
Skip to first unread message

Li, Zeyang

unread,
Jul 21, 2014, 8:56:23 AM7/21/14
to cocos2d-...@googlegroups.com
This is a reply to @zhangxm to his reply to my comment on version 3.2 on the official announcement page. I think it's probably better posted here as a feature request.

Improvements to action classes:
Actions should be pooled internally to avoid new allocations. Actions should also support "reset" to allow reuse to an action tree. Better support of piecewise splines are also needed. move actions should support passing in a path function. So instead of BezierTo/By or "SplineTypeTo/By", use MovePath( path ) where path(t) is a function that describes a path. Provide generator classes for piecewise splines, not 4 point splines so I could do Bezier::create( point_list ) => spline(t). Deprecated JumpTo/By, make that a second-order generator function to MovePath. 

Why I say regex is a bad move: 
regex is slow, and easily abused. Usually nodes are tracked in game data structures and rarely needed to query directly from the engine. The frequent need of querying is a sign for bad design.

js-binding allocation issues:
js-binding dynamically create cc.p objects during Node::getPosition binding call. It causes a huge number of small allocations since getPosition gets called quite frequently. I could create a shadow copy of the node position in my js code but have to sync it left and right, since node movement could happen in action classes(MoveTo/MoveBy) or as direct changes to position. Hopefully there is a way to avoid this cc.p allocation in getPosition(). A similar issue goes for boundingBox().

Better components:
lightweight transform node that I could use as a component in my own game object classes. Right now ccnode is this weird monster that supports transform, scheduler, action, rendering, components and physics. It's probably worthwhile to add a light weight NodeBase(or whatever you call it) that allows transform and actions only. I find it a lot easier to organize my code when I use Node as a transform component of my own game object, rather than inheriting directly from it.

Multi-core support:
Task-based global scheduler has almost become a norm nowadays. It would be nice to have it in 2dx since android often run up to 4 cores and a rendering thread is apparently not sufficient. All high end engines have it. I always wanted to write up a more concrete proposal for this but couldn't really find time to do research. Just throwing this out since it's becoming quite popular.

:D,
Zeyang

Hao Wu

unread,
Jul 21, 2014, 1:29:14 PM7/21/14
to Li, Zeyang, cocos2d-...@googlegroups.com
Thanks for your attention,

for action classes, I agree that your suggestion will improve the actions in general, but I think actions are already working pretty good, your proposal is nice, we will add them in the future

for regex node enumerator/finder
Unity has it, SpriteKit has it, we are just following them up, there are people who really like regex, sure it might be slower, but anyone who can use regex will understand the performance overhead, and will live with it.

for returned object, it has to be a copy, otherwise you could modify the reference, which will then change the original values
for example, this code makes no sense at all
node.getPosition().x += 10;
however if getPosition returns a reference to the node position object, then the above line will work as getting the node's x value, then set it back and plus 10.

componentization will slow the engine down, in your case, just use regular node, and don't worry about all the extra features

multi thread: i think there is a basic multi thread feature


--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Li, Zeyang

unread,
Jul 21, 2014, 2:29:22 PM7/21/14
to Hao Wu, cocos2d-...@googlegroups.com
js-binding allocation issue: yes naive translation of native code to js would do what you describe. Exactly how to implement it nicely will require some thought. My point is that in C++ getPosition does some memcpy but it will not allocate a new object on the heap while the js binding one will. These small allocs really show up in profiler.

component styles will slow up the engine by a marginal amount, and ignorably marginal if done properly. There are way better places to look for performance, like my last point: task based job scheduler ( http://dementedvice.wordpress.com/2013/08/27/task-basedparallel-game-engine/ ), or my first point pooled actions.

Reply all
Reply to author
Forward
0 new messages