@@ -8540,6 +8540,75 @@ static int tolua_cocos2d_Vec3_cross(lua_State* tolua_S)
8540
8540
#endif
8541
8541
}
8542
8542
8543
+ static int tolua_cocos2d_random01 (lua_State* tolua_S)
8544
+ {
8545
+ lua_pushnumber (tolua_S, CCRANDOM_0_1 ());
8546
+ return 1 ;
8547
+ }
8548
+
8549
+ static int tolua_cocos2d_Vec2_isLineIntersect (lua_State* tolua_S)
8550
+ {
8551
+ int argc = lua_gettop (tolua_S);
8552
+
8553
+ #if COCOS2D_DEBUG >= 1
8554
+ tolua_Error tolua_err;
8555
+ #endif
8556
+
8557
+ if (4 == argc)
8558
+ {
8559
+ #if COCOS2D_DEBUG >= 1
8560
+ if (!tolua_istable (tolua_S, 1 , 0 , &tolua_err) ||
8561
+ !tolua_istable (tolua_S, 2 , 0 , &tolua_err) ||
8562
+ !tolua_istable (tolua_S, 3 , 0 , &tolua_err)||
8563
+ !tolua_istable (tolua_S, 4 , 0 , &tolua_err))
8564
+ goto tolua_lerror;
8565
+ else
8566
+ #endif
8567
+ {
8568
+ cocos2d::Vec2 x1,y1 ;
8569
+ cocos2d::Vec2 x2,y2;
8570
+
8571
+ float s =0 .0f , t = 0 .0f ;
8572
+
8573
+ bool ok = true ;
8574
+
8575
+ ok &= luaval_to_vec2 (tolua_S, 1 , &x1);
8576
+ if (!ok)
8577
+ return 0 ;
8578
+
8579
+ ok &= luaval_to_vec2 (tolua_S, 2 , &y1 );
8580
+ if (!ok)
8581
+ return 0 ;
8582
+
8583
+ ok &= luaval_to_vec2 (tolua_S, 3 , &x2);
8584
+ if (!ok)
8585
+ return 0 ;
8586
+
8587
+ ok &= luaval_to_vec2 (tolua_S, 4 , &y2);
8588
+ if (!ok)
8589
+ return 0 ;
8590
+
8591
+ bool intersects = Vec2::isLineIntersect (x1, y1 , x2, y2, &s, &t);
8592
+
8593
+ lua_pushboolean (tolua_S, intersects);
8594
+ lua_pushnumber (tolua_S, s);
8595
+ lua_pushnumber (tolua_S, t);
8596
+ return 3 ;
8597
+ }
8598
+ }else
8599
+ {
8600
+ lua_pushboolean (tolua_S, false );
8601
+ lua_pushnumber (tolua_S, 0 );
8602
+ lua_pushnumber (tolua_S, 0 );
8603
+ return 3 ;
8604
+ }
8605
+ #if COCOS2D_DEBUG >= 1
8606
+ tolua_lerror:
8607
+ tolua_error (tolua_S," #ferror in function 'vec2_isLineIntersect'." ,&tolua_err);
8608
+ return 0 ;
8609
+ #endif
8610
+ }
8611
+
8543
8612
static int tolua_cocos2d_Mat4_multiply (lua_State* tolua_S)
8544
8613
{
8545
8614
#if COCOS2D_DEBUG >= 1
@@ -8825,6 +8894,8 @@ int register_all_cocos2dx_math_manual(lua_State* tolua_S)
8825
8894
tolua_function (tolua_S, " mat4_createTranslation" , tolua_cocos2d_Mat4_createTranslation);
8826
8895
tolua_function (tolua_S, " mat4_createRotation" , tolua_cocos2d_Mat4_createRotation);
8827
8896
tolua_function (tolua_S, " vec3_cross" , tolua_cocos2d_Vec3_cross);
8897
+ tolua_function (tolua_S, " vec2_isLineIntersect" , tolua_cocos2d_Vec2_isLineIntersect);
8898
+ tolua_function (tolua_S, " cc_mathutils_random" , tolua_cocos2d_random01);
8828
8899
tolua_endmodule (tolua_S);
8829
8900
return 0 ;
8830
8901
}
0 commit comments