6
6
#include < daabbcc/daabbcc.h>
7
7
#include < dmsdk/sdk.h>
8
8
9
+ #define RETURN_INVALID_GROUP_ERROR (name, id ) \
10
+ return DM_LUA_ERROR(" %s: Group ID [%i] is invalid or already removed!" , name, id)
11
+
9
12
// //////////////////////////////////////
10
13
// Group Operations
11
14
// //////////////////////////////////////
@@ -35,8 +38,7 @@ static int RemoveGroup(lua_State* L)
35
38
bool isSet = daabbcc::SetTreeGroup (groupID);
36
39
if (!isSet)
37
40
{
38
- daabbcc::ErrorAssert (" RemoveGroup" , groupID);
39
- return 0 ;
41
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.remove_group()" , groupID);
40
42
}
41
43
42
44
daabbcc::RemoveGroup (groupID);
@@ -129,13 +131,12 @@ static inline void ManifoldResult(lua_State* L, uint32_t queryResultSize, dmArra
129
131
static inline int QueryIDSort (lua_State* L)
130
132
{
131
133
DM_LUA_STACK_CHECK (L, 2 );
132
- uint8_t groupID = luaL_checkint (L, 1 );
133
134
135
+ uint8_t groupID = luaL_checkint (L, 1 );
134
136
bool isSet = daabbcc::SetTreeGroup (groupID);
135
137
if (!isSet)
136
138
{
137
- daabbcc::ErrorAssert (" QueryIDSort" , groupID);
138
- return 0 ;
139
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.query_id_sort()" , groupID);
139
140
}
140
141
141
142
int32_t proxyID = luaL_checkint (L, 2 );
@@ -183,13 +184,12 @@ static inline int QueryIDSort(lua_State* L)
183
184
static int QueryAABBSort (lua_State* L)
184
185
{
185
186
DM_LUA_STACK_CHECK (L, 2 );
186
- uint8_t groupID = luaL_checkint (L, 1 );
187
187
188
+ uint8_t groupID = luaL_checkint (L, 1 );
188
189
bool isSet = daabbcc::SetTreeGroup (groupID);
189
190
if (!isSet)
190
191
{
191
- daabbcc::ErrorAssert (" QueryAABBSort" , groupID);
192
- return 0 ;
192
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.query_aabb_sort()" , groupID);
193
193
}
194
194
195
195
float x = luaL_checknumber (L, 2 );
@@ -242,13 +242,12 @@ static int QueryAABBSort(lua_State* L)
242
242
static int QueryAABB (lua_State* L)
243
243
{
244
244
DM_LUA_STACK_CHECK (L, 2 );
245
- uint8_t groupID = luaL_checkint (L, 1 );
246
245
246
+ uint8_t groupID = luaL_checkint (L, 1 );
247
247
bool isSet = daabbcc::SetTreeGroup (groupID);
248
248
if (!isSet)
249
249
{
250
- daabbcc::ErrorAssert (" QueryAABB" , groupID);
251
- return 0 ;
250
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.query_aabb()" , groupID);
252
251
}
253
252
254
253
float x = luaL_checknumber (L, 2 );
@@ -310,12 +309,10 @@ static int QueryID(lua_State* L)
310
309
DM_LUA_STACK_CHECK (L, 2 );
311
310
312
311
uint8_t groupID = luaL_checkint (L, 1 );
313
-
314
312
bool isSet = daabbcc::SetTreeGroup (groupID);
315
313
if (!isSet)
316
314
{
317
- daabbcc::ErrorAssert (" QueryID" , groupID);
318
- return 0 ;
315
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.query_id()" , groupID);
319
316
}
320
317
321
318
int32_t proxyID = luaL_checkint (L, 2 );
@@ -377,12 +374,10 @@ static int RayCast(lua_State* L)
377
374
DM_LUA_STACK_CHECK (L, 2 );
378
375
379
376
uint8_t groupID = luaL_checkint (L, 1 );
380
-
381
377
bool isSet = daabbcc::SetTreeGroup (groupID);
382
378
if (!isSet)
383
379
{
384
- daabbcc::ErrorAssert (" RayCast" , groupID);
385
- return 0 ;
380
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.raycast()" , groupID);
386
381
}
387
382
388
383
float start_x = luaL_checknumber (L, 2 );
@@ -443,12 +438,10 @@ static int RayCastSort(lua_State* L)
443
438
DM_LUA_STACK_CHECK (L, 2 );
444
439
445
440
uint8_t groupID = luaL_checkint (L, 1 );
446
-
447
441
bool isSet = daabbcc::SetTreeGroup (groupID);
448
442
if (!isSet)
449
443
{
450
- daabbcc::ErrorAssert (" RayCast" , groupID);
451
- return 0 ;
444
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.raycast_sort()" , groupID);
452
445
}
453
446
454
447
float start_x = luaL_checknumber (L, 2 );
@@ -502,13 +495,13 @@ static int RayCastSort(lua_State* L)
502
495
503
496
static int AddProxy (lua_State* L)
504
497
{
505
- uint8_t groupID = luaL_checkint (L, 1 );
498
+ DM_LUA_STACK_CHECK (L, 1 );
506
499
500
+ uint8_t groupID = luaL_checkint (L, 1 );
507
501
bool isSet = daabbcc::SetTreeGroup (groupID);
508
502
if (!isSet)
509
503
{
510
- daabbcc::ErrorAssert (" AddProxy" , groupID);
511
- return 0 ;
504
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.insert_aabb()" , groupID);
512
505
}
513
506
514
507
float x = luaL_checknumber (L, 2 );
@@ -531,15 +524,13 @@ static int AddProxy(lua_State* L)
531
524
532
525
static int AddGameObject (lua_State* L)
533
526
{
534
- // DM_LUA_STACK_CHECK(L, 1);
527
+ DM_LUA_STACK_CHECK (L, 1 );
535
528
536
529
uint8_t groupID = luaL_checkint (L, 1 );
537
-
538
530
bool isSet = daabbcc::SetTreeGroup (groupID);
539
531
if (!isSet)
540
532
{
541
- dmLogError (" AddGameObject: Group ID %i is invalid or already removed!" , groupID);
542
- return 0 ;
533
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.insert_gameobject()" , groupID);
543
534
}
544
535
545
536
dmGameObject::HInstance gameobjectInstance = dmScript::CheckGOInstance (L, 2 );
@@ -578,12 +569,10 @@ static int MoveProxy(lua_State* L)
578
569
DM_LUA_STACK_CHECK (L, 0 );
579
570
580
571
uint8_t groupID = luaL_checkint (L, 1 );
581
-
582
572
bool isSet = daabbcc::SetTreeGroup (groupID);
583
573
if (!isSet)
584
574
{
585
- daabbcc::ErrorAssert (" MoveProxy" , groupID);
586
- return 0 ;
575
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.update_aabb()" , groupID);
587
576
}
588
577
589
578
int32_t proxyID = luaL_checkint (L, 2 );
@@ -606,8 +595,7 @@ static int UpdateGameobjectSize(lua_State* L)
606
595
bool isSet = daabbcc::SetTreeGroup (groupID);
607
596
if (!isSet)
608
597
{
609
- daabbcc::ErrorAssert (" UpdateGameobjectSize" , groupID);
610
- return 0 ;
598
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.update_gameobject_size()" , groupID);
611
599
}
612
600
613
601
int32_t proxyID = luaL_checkint (L, 2 );
@@ -628,8 +616,7 @@ static int RemoveProxy(lua_State* L)
628
616
bool isSet = daabbcc::SetTreeGroup (groupID);
629
617
if (!isSet)
630
618
{
631
- daabbcc::ErrorAssert (" RemoveProxy" , groupID);
632
- return 0 ;
619
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.remove()" , groupID);
633
620
}
634
621
635
622
int32_t proxyID = luaL_checkint (L, 2 );
@@ -679,8 +666,7 @@ static int Rebuild(lua_State* L)
679
666
bool isSet = daabbcc::SetTreeGroup (groupID);
680
667
if (!isSet)
681
668
{
682
- daabbcc::ErrorAssert (" Rebuild" , groupID);
683
- return 0 ;
669
+ RETURN_INVALID_GROUP_ERROR (" daabbcc.rebuild()" , groupID);
684
670
}
685
671
686
672
bool fullBuild = lua_toboolean (L, 2 );
0 commit comments