Merge branch 'v3' into v3-winrt-ogg

This commit is contained in:
Dale Stammen 2015-06-08 08:22:46 -07:00
commit a2b677d300
16 changed files with 303 additions and 131 deletions

View File

@ -69,6 +69,9 @@ Developers:
silverscania
Pass correct parameter to glPixelStorei when creating a texture
stari4ek
Fix VideoPlayer on Android ignore search paths
FlagellumDei
Center the window correctly on windows

View File

@ -20,11 +20,12 @@ cocos2d-x-3.7 ??
[NEW] win10: Added Windows 10.0 Universal App(UWP) support.
[FIX] network: Fix memory leak of HttpClient on iOS and Mac platform.
[FIX] android++: Improve UserDefault's robustness, now the converting behavior is the same as iOS platform.
[FIX] android: Improve UserDefault's robustness, now the converting behavior is the same as iOS platform.
[FIX] android: Fix VideoPlayer on Android ignore search paths.
[FIX] audio: Fixed program may freeze if `AudioEngine::stop` or `AudioEngine::stopAll()` is invoked frequently on Android
[FIX] audio: Fixed audio can't resume if it is interrupted by an incoming phone call.
[FIX] audio: Fixed SimpleAudioEngine::playEffect() lagged on Android 5.0.x
[FIX] ui: TextField scale factor is wrong with multiline text.
[FIX] ui: Text scale factor is wrong with multiline text.
[FIX] 3d: skybox can't move to other position except origin point in world space
[FIX] 3d: terrain can't move to other position except origin point in world space
[FIX] 3rd: fix PIE link error on iOS caused by libpng and libtiff
@ -35,6 +36,7 @@ cocos2d-x-3.7 ??
[FIX] Label: position is wrong if label content is changed after invoking `getLetter(letterIndex)`
[FIX] Label: shadow effect cause OpenGL error on iOS
[FIX] Label: outline effect doesn't match characters well
[FIX] Label: Fixed system font label line height calculation is wrong on Android.
[FIX] ProgressTimer: `setSprite()` doesn't take effect
[FIX] Sprite3D: setGLProgram() does not work
[FIX] Sprite3D: transition breaks when there is a Sprite3D in the scene

View File

@ -710,14 +710,6 @@ const Vec2& Node::getAnchorPoint() const
void Node::setAnchorPoint(const Vec2& point)
{
#if CC_USE_PHYSICS
if (_physicsBody != nullptr && !point.equals(Vec2::ANCHOR_MIDDLE))
{
CCLOG("Node warning: This node has a physics body, the anchor must be in the middle, you cann't change this to other value.");
return;
}
#endif
if (! point.equals(_anchorPoint))
{
_anchorPoint = point;
@ -2087,14 +2079,6 @@ void Node::setPhysicsBody(PhysicsBody* body)
body->_node = this;
body->retain();
// physics rotation based on body position, but node rotation based on node anthor point
// it cann't support both of them, so I clear the anthor point to default.
if (!getAnchorPoint().equals(Vec2::ANCHOR_MIDDLE))
{
CCLOG("Node warning: setPhysicsBody sets anchor point to Vec2::ANCHOR_MIDDLE.");
setAnchorPoint(Vec2::ANCHOR_MIDDLE);
}
_physicsBody = body;
_physicsScaleStartX = _scaleX;
@ -2133,10 +2117,16 @@ void Node::updatePhysicsBodyTransform(const Mat4& parentTransform, uint32_t pare
if (_physicsBody && ((flags & FLAGS_DIRTY_MASK) || _physicsTransformDirty))
{
_physicsTransformDirty = false;
Vec3 vec3(_position.x, _position.y, 0);
Vec3 vec3(_contentSize.width * 0.5f, _contentSize.height * 0.5f, 0);
Vec3 ret;
parentTransform.transformPoint(vec3, &ret);
_modelViewTransform.transformPoint(vec3, &ret);
_physicsBody->setPosition(Vec2(ret.x, ret.y));
parentTransform.getInversed().transformPoint(&ret);
_offsetX = ret.x - _position.x;
_offsetY = ret.y - _position.y;
_physicsBody->setScale(scaleX / _physicsScaleStartX, scaleY / _physicsScaleStartY);
_physicsBody->setRotation(_physicsRotation - _physicsRotationOffset);
}
@ -2158,7 +2148,7 @@ void Node::updateTransformFromPhysics(const Mat4& parentTransform, uint32_t pare
Vec3 vec3(newPosition.x, newPosition.y, 0);
Vec3 ret;
parentTransform.getInversed().transformPoint(vec3, &ret);
setPosition(ret.x, ret.y);
setPosition(ret.x - _offsetX, ret.y - _offsetY);
}
_physicsRotation = _physicsBody->getRotation();
setRotation(_physicsRotation - _parent->_physicsRotation + _physicsRotationOffset);

View File

@ -1844,6 +1844,9 @@ protected:
PhysicsWorld* _physicsWorld; /** The PhysicsWorld associated with the node.*/
int _physicsBodyAssociatedWith; /** The count of PhysicsBody associated with the node and children.*/
float _physicsRotationOffset; /** Record the rotation value when invoke Node::setPhysicsBody.*/
float _offsetX;
float _offsetY;
#endif
// opacity controls

View File

@ -215,13 +215,17 @@ void Scene::setPhysics3DDebugCamera(Camera* camera)
void Scene::addChild(Node* child, int zOrder, int tag)
{
Node::addChild(child, zOrder, tag);
#if CC_USE_PHYSICS
addChildToPhysicsWorld(child);
#endif
}
void Scene::addChild(Node* child, int zOrder, const std::string &name)
{
Node::addChild(child, zOrder, name);
#if CC_USE_PHYSICS
addChildToPhysicsWorld(child);
#endif
}
Scene* Scene::createWithPhysics()
@ -254,8 +258,6 @@ bool Scene::initWithPhysics()
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
Physics3DWorldDes info;
//TODO: FIX ME
//info.isDebugDrawEnabled = true;
CC_BREAK_IF(! (_physics3DWorld = Physics3DWorld::create(&info)));
_physics3DWorld->retain();
#endif
@ -290,29 +292,6 @@ void Scene::addChildToPhysicsWorld(Node* child)
addToPhysicsWorldFunc(child);
}
#endif
#if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION
if (_physics3DWorld)
{
std::function<void(Node*)> addToPhysicsWorldFunc = nullptr;
addToPhysicsWorldFunc = [this, &addToPhysicsWorldFunc](Node* node) -> void
{
static std::string comName = Physics3DComponent::getPhysics3DComponentName();
auto com = static_cast<Physics3DComponent*>(node->getComponent(comName));
if (com)
{
com->addToPhysicsWorld(_physics3DWorld);
}
auto& children = node->getChildren();
for( const auto &n : children) {
addToPhysicsWorldFunc(n);
}
};
addToPhysicsWorldFunc(child);
}
#endif
}
#endif

View File

@ -353,6 +353,7 @@ void Mesh::draw(Renderer* renderer, float globalZOrder, const Mat4& transform, u
_meshCommand.setSkipBatching(isTransparent);
_meshCommand.setTransparent(isTransparent);
// set default uniforms for Mesh
// 'u_color' and others

View File

@ -1405,14 +1405,16 @@ getTerrainSize : function (
/**
* @method getIntersectionPoint
* @param {cc.Ray} arg0
* @return {vec3_object}
*/
getIntersectionPoint : function (
ray
* @param {cc.Ray|cc.Ray} ray
* @param {vec3_object} vec3
* @return {bool|vec3_object}
*/
getIntersectionPoint : function(
ray,
vec3
)
{
return cc.Vec3;
return false;
},
/**

View File

@ -888,6 +888,16 @@ PhysicsSprite3D : function (
*/
cc.Physics3DWorld = {
/**
* @method setGravity
* @param {vec3_object} arg0
*/
setGravity : function (
vec3
)
{
},
/**
* @method stepSimulate
* @param {float} arg0
@ -929,11 +939,9 @@ physics3dworlddes
},
/**
* @method removePhysics3DConstraint
* @param {cc.Physics3DConstraint} arg0
* @method removeAllPhysics3DObjects
*/
removePhysics3DConstraint : function (
physics3dconstraint
removeAllPhysics3DObjects : function (
)
{
},
@ -973,9 +981,21 @@ hitresult
},
/**
* @method removeAllPhysics3DObjects
* @method getGravity
* @return {vec3_object}
*/
removeAllPhysics3DObjects : function (
getGravity : function (
)
{
return cc.Vec3;
},
/**
* @method removePhysics3DConstraint
* @param {cc.Physics3DConstraint} arg0
*/
removePhysics3DConstraint : function (
physics3dconstraint
)
{
},

View File

@ -4022,22 +4022,43 @@ bool js_cocos2dx_3d_Terrain_getIntersectionPoint(JSContext *cx, uint32_t argc, j
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::Terrain* cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object");
if (argc == 1) {
cocos2d::Ray arg0;
ok &= jsval_to_ray(cx, args.get(0), &arg0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Error processing arguments");
cocos2d::Vec3 ret = cobj->getIntersectionPoint(arg0);
jsval jsret = JSVAL_NULL;
jsret = vector3_to_jsval(cx, ret);
args.rval().set(jsret);
return true;
}
JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getIntersectionPoint : wrong number of arguments: %d, was expecting %d", argc, 1);
JS::RootedObject obj(cx);
cocos2d::Terrain* cobj = NULL;
obj = args.thisv().toObjectOrNull();
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cobj = (cocos2d::Terrain *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_3d_Terrain_getIntersectionPoint : Invalid Native Object");
do {
if (argc == 2) {
cocos2d::Ray arg0;
ok &= jsval_to_ray(cx, args.get(0), &arg0);
if (!ok) { ok = true; break; }
cocos2d::Vec3 arg1;
ok &= jsval_to_vector3(cx, args.get(1), &arg1);
if (!ok) { ok = true; break; }
bool ret = cobj->getIntersectionPoint(arg0, arg1);
jsval jsret = JSVAL_NULL;
jsret = BOOLEAN_TO_JSVAL(ret);
args.rval().set(jsret);
return true;
}
} while(0);
do {
if (argc == 1) {
cocos2d::Ray arg0;
ok &= jsval_to_ray(cx, args.get(0), &arg0);
if (!ok) { ok = true; break; }
cocos2d::Vec3 ret = cobj->getIntersectionPoint(arg0);
jsval jsret = JSVAL_NULL;
jsret = vector3_to_jsval(cx, ret);
args.rval().set(jsret);
return true;
}
} while(0);
JS_ReportError(cx, "js_cocos2dx_3d_Terrain_getIntersectionPoint : wrong number of arguments");
return false;
}
bool js_cocos2dx_3d_Terrain_getNormal(JSContext *cx, uint32_t argc, jsval *vp)

View File

@ -2280,6 +2280,26 @@ void js_register_cocos2dx_physics3d_PhysicsSprite3D(JSContext *cx, JS::HandleObj
JSClass *jsb_cocos2d_Physics3DWorld_class;
JSObject *jsb_cocos2d_Physics3DWorld_prototype;
bool js_cocos2dx_physics3d_Physics3DWorld_setGravity(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : Invalid Native Object");
if (argc == 1) {
cocos2d::Vec3 arg0;
ok &= jsval_to_vector3(cx, args.get(0), &arg0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : Error processing arguments");
cobj->setGravity(arg0);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_setGravity : wrong number of arguments: %d, was expecting %d", argc, 1);
return false;
}
bool js_cocos2dx_physics3d_Physics3DWorld_stepSimulate(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
@ -2357,32 +2377,20 @@ bool js_cocos2dx_physics3d_Physics3DWorld_init(JSContext *cx, uint32_t argc, jsv
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_init : wrong number of arguments: %d, was expecting %d", argc, 1);
return false;
}
bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp)
bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Invalid Native Object");
if (argc == 1) {
cocos2d::Physics3DConstraint* arg0;
do {
if (args.get(0).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull();
jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object");
} while (0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Error processing arguments");
cobj->removePhysics3DConstraint(arg0);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : Invalid Native Object");
if (argc == 0) {
cobj->removeAllPhysics3DObjects();
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : wrong number of arguments: %d, was expecting %d", argc, 1);
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : wrong number of arguments: %d, was expecting %d", argc, 0);
return false;
}
bool js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled(JSContext *cx, uint32_t argc, jsval *vp)
@ -2446,20 +2454,50 @@ bool js_cocos2dx_physics3d_Physics3DWorld_rayCast(JSContext *cx, uint32_t argc,
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_rayCast : wrong number of arguments: %d, was expecting %d", argc, 3);
return false;
}
bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp)
bool js_cocos2dx_physics3d_Physics3DWorld_getGravity(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : Invalid Native Object");
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_getGravity : Invalid Native Object");
if (argc == 0) {
cobj->removeAllPhysics3DObjects();
cocos2d::Vec3 ret = cobj->getGravity();
jsval jsret = JSVAL_NULL;
jsret = vector3_to_jsval(cx, ret);
args.rval().set(jsret);
return true;
}
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_getGravity : wrong number of arguments: %d, was expecting %d", argc, 0);
return false;
}
bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp)
{
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
bool ok = true;
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
js_proxy_t *proxy = jsb_get_js_proxy(obj);
cocos2d::Physics3DWorld* cobj = (cocos2d::Physics3DWorld *)(proxy ? proxy->ptr : NULL);
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Invalid Native Object");
if (argc == 1) {
cocos2d::Physics3DConstraint* arg0;
do {
if (args.get(0).isNull()) { arg0 = nullptr; break; }
if (!args.get(0).isObject()) { ok = false; break; }
js_proxy_t *jsProxy;
JSObject *tmpObj = args.get(0).toObjectOrNull();
jsProxy = jsb_get_js_proxy(tmpObj);
arg0 = (cocos2d::Physics3DConstraint*)(jsProxy ? jsProxy->ptr : NULL);
JSB_PRECONDITION2( arg0, cx, false, "Invalid Native Object");
} while (0);
JSB_PRECONDITION2(ok, cx, false, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : Error processing arguments");
cobj->removePhysics3DConstraint(arg0);
args.rval().setUndefined();
return true;
}
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects : wrong number of arguments: %d, was expecting %d", argc, 0);
JS_ReportError(cx, "js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint : wrong number of arguments: %d, was expecting %d", argc, 1);
return false;
}
bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp)
@ -2766,15 +2804,17 @@ void js_register_cocos2dx_physics3d_Physics3DWorld(JSContext *cx, JS::HandleObje
};
static JSFunctionSpec funcs[] = {
JS_FN("setGravity", js_cocos2dx_physics3d_Physics3DWorld_setGravity, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("stepSimulate", js_cocos2dx_physics3d_Physics3DWorld_stepSimulate, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("needCollisionChecking", js_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("collisionChecking", js_cocos2dx_physics3d_Physics3DWorld_collisionChecking, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("init", js_cocos2dx_physics3d_Physics3DWorld_init, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("removePhysics3DConstraint", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("removeAllPhysics3DObjects", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("isDebugDrawEnabled", js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("removeAllPhysics3DConstraints", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("rayCast", js_cocos2dx_physics3d_Physics3DWorld_rayCast, 3, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("removeAllPhysics3DObjects", js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("getGravity", js_cocos2dx_physics3d_Physics3DWorld_getGravity, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("removePhysics3DConstraint", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("addPhysics3DObject", js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("setDebugDrawEnable", js_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("removePhysics3DObject", js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),

View File

@ -134,15 +134,17 @@ bool js_cocos2dx_physics3d_Physics3DWorld_constructor(JSContext *cx, uint32_t ar
void js_cocos2dx_physics3d_Physics3DWorld_finalize(JSContext *cx, JSObject *obj);
void js_register_cocos2dx_physics3d_Physics3DWorld(JSContext *cx, JS::HandleObject global);
void register_all_cocos2dx_physics3d(JSContext* cx, JS::HandleObject obj);
bool js_cocos2dx_physics3d_Physics3DWorld_setGravity(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_stepSimulate(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_collisionChecking(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_init(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_rayCast(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_getGravity(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject(JSContext *cx, uint32_t argc, jsval *vp);

View File

@ -4,6 +4,13 @@
-- @extend Ref
-- @parent_module cc
--------------------------------
-- set gravity for the physics world
-- @function [parent=#Physics3DWorld] setGravity
-- @param self
-- @param #vec3_table gravity
-- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld)
--------------------------------
-- Simulate one frame.
-- @function [parent=#Physics3DWorld] stepSimulate
@ -24,10 +31,9 @@
-- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld)
--------------------------------
-- Remove a Physics3DConstraint.
-- @function [parent=#Physics3DWorld] removePhysics3DConstraint
-- Remove all Physics3DObjects.
-- @function [parent=#Physics3DWorld] removeAllPhysics3DObjects
-- @param self
-- @param #cc.Physics3DConstraint constraint
-- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld)
--------------------------------
@ -43,9 +49,16 @@
-- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld)
--------------------------------
-- Remove all Physics3DObjects.
-- @function [parent=#Physics3DWorld] removeAllPhysics3DObjects
-- get current gravity
-- @function [parent=#Physics3DWorld] getGravity
-- @param self
-- @return vec3_table#vec3_table ret (return value: vec3_table)
--------------------------------
-- Remove a Physics3DConstraint.
-- @function [parent=#Physics3DWorld] removePhysics3DConstraint
-- @param self
-- @param #cc.Physics3DConstraint constraint
-- @return Physics3DWorld#Physics3DWorld self (return value: cc.Physics3DWorld)
--------------------------------

View File

@ -3978,6 +3978,56 @@ int lua_register_cocos2dx_physics3d_PhysicsSprite3D(lua_State* tolua_S)
return 1;
}
int lua_cocos2dx_physics3d_Physics3DWorld_setGravity(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Physics3DWorld* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Physics3DWorld",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Physics3DWorld*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Vec3 arg0;
ok &= luaval_to_vec3(tolua_S, 2, &arg0, "cc.Physics3DWorld:setGravity");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'", nullptr);
return 0;
}
cobj->setGravity(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:setGravity",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_setGravity'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_physics3d_Physics3DWorld_stepSimulate(lua_State* tolua_S)
{
int argc = 0;
@ -4122,7 +4172,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_collisionChecking(lua_State* tolua_S)
return 0;
}
int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* tolua_S)
int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Physics3DWorld* cobj = nullptr;
@ -4142,32 +4192,29 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* t
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
if (argc == 0)
{
cocos2d::Physics3DConstraint* arg0;
ok &= luaval_to_object<cocos2d::Physics3DConstraint>(tolua_S, 2, "cc.Physics3DConstraint",&arg0, "cc.Physics3DWorld:removePhysics3DConstraint");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr);
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr);
return 0;
}
cobj->removePhysics3DConstraint(arg0);
cobj->removeAllPhysics3DObjects();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removePhysics3DConstraint",argc, 1);
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removeAllPhysics3DObjects",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'.",&tolua_err);
#endif
return 0;
@ -4266,7 +4313,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints(lua_Stat
return 0;
}
int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* tolua_S)
int lua_cocos2dx_physics3d_Physics3DWorld_getGravity(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Physics3DWorld* cobj = nullptr;
@ -4286,7 +4333,7 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* t
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr);
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'", nullptr);
return 0;
}
#endif
@ -4296,19 +4343,69 @@ int lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects(lua_State* t
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'", nullptr);
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'", nullptr);
return 0;
}
cobj->removeAllPhysics3DObjects();
lua_settop(tolua_S, 1);
cocos2d::Vec3 ret = cobj->getGravity();
vec3_to_luaval(tolua_S, ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removeAllPhysics3DObjects",argc, 0);
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:getGravity",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects'.",&tolua_err);
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_getGravity'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint(lua_State* tolua_S)
{
int argc = 0;
cocos2d::Physics3DWorld* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"cc.Physics3DWorld",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::Physics3DWorld*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
cocos2d::Physics3DConstraint* arg0;
ok &= luaval_to_object<cocos2d::Physics3DConstraint>(tolua_S, 2, "cc.Physics3DConstraint",&arg0, "cc.Physics3DWorld:removePhysics3DConstraint");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'", nullptr);
return 0;
}
cobj->removePhysics3DConstraint(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Physics3DWorld:removePhysics3DConstraint",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint'.",&tolua_err);
#endif
return 0;
@ -4630,13 +4727,15 @@ int lua_register_cocos2dx_physics3d_Physics3DWorld(lua_State* tolua_S)
tolua_beginmodule(tolua_S,"Physics3DWorld");
tolua_function(tolua_S,"new",lua_cocos2dx_physics3d_Physics3DWorld_constructor);
tolua_function(tolua_S,"setGravity",lua_cocos2dx_physics3d_Physics3DWorld_setGravity);
tolua_function(tolua_S,"stepSimulate",lua_cocos2dx_physics3d_Physics3DWorld_stepSimulate);
tolua_function(tolua_S,"needCollisionChecking",lua_cocos2dx_physics3d_Physics3DWorld_needCollisionChecking);
tolua_function(tolua_S,"collisionChecking",lua_cocos2dx_physics3d_Physics3DWorld_collisionChecking);
tolua_function(tolua_S,"removePhysics3DConstraint",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint);
tolua_function(tolua_S,"removeAllPhysics3DObjects",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects);
tolua_function(tolua_S,"isDebugDrawEnabled",lua_cocos2dx_physics3d_Physics3DWorld_isDebugDrawEnabled);
tolua_function(tolua_S,"removeAllPhysics3DConstraints",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DConstraints);
tolua_function(tolua_S,"removeAllPhysics3DObjects",lua_cocos2dx_physics3d_Physics3DWorld_removeAllPhysics3DObjects);
tolua_function(tolua_S,"getGravity",lua_cocos2dx_physics3d_Physics3DWorld_getGravity);
tolua_function(tolua_S,"removePhysics3DConstraint",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DConstraint);
tolua_function(tolua_S,"addPhysics3DObject",lua_cocos2dx_physics3d_Physics3DWorld_addPhysics3DObject);
tolua_function(tolua_S,"setDebugDrawEnable",lua_cocos2dx_physics3d_Physics3DWorld_setDebugDrawEnable);
tolua_function(tolua_S,"removePhysics3DObject",lua_cocos2dx_physics3d_Physics3DWorld_removePhysics3DObject);

View File

@ -253,6 +253,8 @@ int register_all_cocos2dx_physics3d(lua_State* tolua_S);

View File

@ -32,6 +32,7 @@
#include "jni/JniHelper.h"
#include "base/CCDirector.h"
#include "base/CCEventListenerKeyboard.h"
#include "platform/CCFileUtils.h"
//-----------------------------------------------------------------------------------------------------------
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxVideoHelper"
@ -193,7 +194,7 @@ VideoPlayer::~VideoPlayer()
void VideoPlayer::setFileName(const std::string& fileName)
{
_videoURL = fileName;
_videoURL = FileUtils::getInstance()->fullPathForFilename(fileName);
_videoSource = VideoPlayer::Source::FILENAME;
setVideoURLJNI(_videoPlayerIndex, (int)Source::FILENAME,_videoURL);
}

View File

@ -55,7 +55,6 @@ using namespace cocos2d::experimental::ui;
-(void) videoFinished:(NSNotification*) notification;
-(void) playStateChange;
+(NSString*) fullPathFromRelativePath:(NSString*) relPath;
@end
@ -138,8 +137,7 @@ using namespace cocos2d::experimental::ui;
self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self.moviePlayer setContentURL:[NSURL URLWithString:@(videoUrl.c_str())]];
} else {
NSString *path = [UIVideoViewWrapperIos fullPathFromRelativePath:@(videoUrl.c_str())];
self.moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]] autorelease];
self.moviePlayer = [[[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:@(videoUrl.c_str())]] autorelease];
self.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
}
self.moviePlayer.allowsAirPlay = false;
@ -260,10 +258,6 @@ using namespace cocos2d::experimental::ui;
}
}
+(NSString*) fullPathFromRelativePath:(NSString*) relPath
{
return [NSString stringWithCString: cocos2d::FileUtils::getInstance()->fullPathForFilename(std::string([relPath UTF8String])).c_str() encoding: [NSString defaultCStringEncoding]];
}
@end
//------------------------------------------------------------------------------------------------------------
@ -293,7 +287,7 @@ VideoPlayer::~VideoPlayer()
void VideoPlayer::setFileName(const std::string& fileName)
{
_videoURL = fileName;
_videoURL = FileUtils::getInstance()->fullPathForFilename(fileName);
_videoSource = VideoPlayer::Source::FILENAME;
[((UIVideoViewWrapperIos*)_videoView) setURL:(int)_videoSource :_videoURL];
}