void ContactListener::BeginContact(b2Contact* contact)
{
	bool looking = true;
    b2Fixture* fixtureA = contact->GetFixtureA();
    b2Fixture* fixtureB = contact->GetFixtureB();
    b2Body* body1 = fixtureA->GetBody();
    b2Body* body2 = fixtureB->GetBody();
	CollisionIdentifier* body1Ident = ((CollisionIdentifier*)body1->GetUserData());
	CollisionIdentifier* body2Ident = ((CollisionIdentifier*)body2->GetUserData());
	
	platBody = NULL;
	player = NULL;

	enemy = NULL;
	water = NULL;
	conveyorBody=NULL;
	
	if ( fixtureA->IsSensor() && fixtureB->GetBody()->GetType() == b2_dynamicBody )
        m_fixturePairs.insert( make_pair(fixtureA, fixtureB) );
    else if ( fixtureB->IsSensor() && fixtureA->GetBody()->GetType() == b2_dynamicBody )
        m_fixturePairs.insert( make_pair(fixtureB, fixtureA) );

	checkObject(body1Ident);

	checkObject(body2Ident);

}
예제 #2
0
int Patch::read(const string &file)
{
  jRoot = json_load_file(file.c_str(), 0, &jError);
  if (!jRoot) {
    gu_log("[Patch::read] unable to read patch file! Error on line %d: %s\n", jError.line, jError.text);
    return PATCH_UNREADABLE;
  }

  if (!checkObject(jRoot, "root element"))
    return PATCH_INVALID;

  init();

  /* TODO json_decref also when PATCH_INVALID */

  if (!readCommons(jRoot))  return setInvalid();
  if (!readColumns(jRoot))  return setInvalid();
  if (!readChannels(jRoot)) return setInvalid();
#ifdef WITH_VST
  if (!readPlugins(jRoot, &masterInPlugins, PATCH_KEY_MASTER_IN_PLUGINS))   return setInvalid();
  if (!readPlugins(jRoot, &masterOutPlugins, PATCH_KEY_MASTER_OUT_PLUGINS)) return setInvalid();
#endif

  json_decref(jRoot);

  sanitize();

  return PATCH_READ_OK;
}
예제 #3
0
파일: physscene.cpp 프로젝트: morlok1/core
void PhysScene::deleteObject(QString name)
{
    int count = checkObject(name);
    if (count != -1)
    {
        delete objects[count];
        objectNames.remove(count);
        objects.remove(count);
    }
}
예제 #4
0
bool
wb_dbs::importVolume(wb_export &e)
{

  e.exportHead(*this);
  buildSectName();
  checkObject(m_oep);
  buildSectOid();
  buildSectClass();
  createFile();

  return true;
}
string PatternRecognitioner::recognize(Mat _img, int minObjSize) {

    vector<PR::Object> objects = segmentImage(_img, minObjSize);

    string outString = "";

    //Check with existing patterns
    for(int i = 0; i < objects.size(); i++){
        outString += checkObject(objects[i]);
        imwrite("Object"+to_string(i)+".png",objects[i].img());
    }

    return outString;
}
예제 #6
0
bool Patch::readColumns(json_t *jContainer)
{
  json_t *jColumns = json_object_get(jContainer, PATCH_KEY_COLUMNS);
  if (!checkArray(jColumns, PATCH_KEY_COLUMNS))
    return 0;

  size_t columnIndex;
  json_t *jColumn;
  json_array_foreach(jColumns, columnIndex, jColumn) {

    string columnIndexStr = "column " + gu_itoa(columnIndex);
    if (!checkObject(jColumn, columnIndexStr.c_str()))
      return 0;

    column_t column;
    if (!setInt(jColumn, PATCH_KEY_COLUMN_INDEX, column.index)) return 0;
    if (!setInt(jColumn, PATCH_KEY_COLUMN_WIDTH, column.width)) return 0;

    columns.push_back(column);
  }
예제 #7
0
파일: dcm1.c 프로젝트: bhavik86/Dicom
CONDITION
DCM_GetFileMeta(DCM_OBJECT ** callerObject, DCM_FILE_META ** fileMeta)
{
    CONDITION 		cond;
    PRIVATE_OBJECT 	**object;

    object = (PRIVATE_OBJECT **) callerObject;
    cond = checkObject(object, "DCM_GetFileMeta");
    if (cond != DCM_NORMAL)	return cond;

    memset(&meta, 0, sizeof(meta));

    cond = DCM_ParseObject(callerObject, metaRequired, (int) DIM_OF(metaRequired), metaOptional, (int) DIM_OF(metaOptional), NULL);
    if (cond != DCM_NORMAL)	return cond;		/* repair */

    *fileMeta = CTN_MALLOC(sizeof(DCM_FILE_META));
    if (*fileMeta == NULL) return 0;		/* repair */

    **fileMeta = meta;
    return DCM_NORMAL;
}
예제 #8
0
struct line *comparelines(int scanline, struct line *a, struct line *b)
{
  struct line *heada = a;
  struct line *headb = b;
  struct line *tmp;

#define OVERLAP(m,n)	(!(a->end<b->start)||(a->start>b->end))

#ifdef DEBUG
   if (a && b)
     {
       printf("%d: ",scanline);
       showscanline("B",b);
       showscanline("A",a);
       printf("\n"); 
     }
#endif

   if (!b || (b && !b->top)) /* Scanline B is completely white */
     {
       //       printf("b is empty\n");
       /* All unique objects in a should be counted */
       while(a)
	{
	  checkObject(a->id, scanline, a->top, a->maxlen,a->start);
	  a = a->next;
	 }
     }
   else
     {
       while(a && b && a->top)
	 {
#ifdef DEBUG
	   printf("[%x    %x]\n", a, b);
#endif
	   if (a->end < b->start)      /* A before B */
	     {
	       //	       printf("A before B\n");
	       /* Object ended on scanline A */
	       if (checkObject(a->id, scanline, a->top, a->maxlen,a->start))
		 {
		   int tmpid = a->id;
		   struct line *good = a;
		   a = a->next;
		   while(a && (a->id == tmpid))
		     {
		       tmp = a;
		       a = a->next;
		       //		       printf("Freeing 4 %x\n",tmp);
		       free(tmp);
		     }
		   good->next = a;
		 }
	       else
		 {
		   if (a)
		     {
		       a = a->next;
		     }
		 }
	     }
	   else if (a->start > b->end) /* A after B */
	     {
	       b = b->next;
	     }
	   else   /* Overlapping, so merge them */
	     {
#ifdef DEBUG
	       printf("Merge A(%d,%d) B(%d,%d)\n",
		      a->start + a->maxlen/2,
		      (scanline+a->top)/2,
		      b->start + b->maxlen/2,
		      (scanline+b->top)/2);
#endif

	       int aend = a->end;
	       int bend = b->end;
	       merge(a,b);
	       if (bend < aend)
		 {
#ifdef DEBUG
		   printf("moving along B(%d)\n",b->id);
#endif
		   b = b->next;
		 }
	       else
		 {
#ifdef DEBUG
		   printf("moving along A(%d)\n",a->id);
#endif
		   a = a->next;
		 }
#ifdef DEBUG
	       printf("after Merge B(%x) A(%x)",b,a);
#endif
	     }
	 }
       //Now maybe B has run out and we need to look for some trailing A's
       // Like above where we considered the remaining A's
#ifdef DEBUG
       if (a)
	 {
	   showscanline("XtraA",a);
	 }
       printf("after showscanline(A)\n");
#endif
       while(b && a && (b->end < a->start))
	 {
	   b = b->next;
	 }
#ifdef DEBUG
       printf("after passing Bs\n");
#endif
       if (!b && a)
	 {
#ifdef DEBUG
	   printf("EXTRACheck A (%d)\n",a->id);
#endif
	   while(a)
	     {
#ifdef DEBUG
	       printf("CHECK(%d)\n",a->id);
#endif
	       checkObject(a->id, scanline, a->top, a->maxlen,a->start);
	       a = a->next;
	     }
	 }
#ifdef DEBUG
       printf("after FINAL A check\n");
#endif
     } /* END ELSE */

#ifdef DEBUG
   printf("Cleanup A\n");
#endif
   a = heada;
#ifdef DEBUG
   showscanline("Cleanup",a);
#endif
   while (a)
     {
       tmp = a;
       a = a->next;
       free(tmp);
     }
#ifdef DEBUG
   printf("Cleanup B?\n");
#endif
   b = headb;
   if (b && !b->top) /* Nothing in the new scan line */
     {
       free(b);
       b = (struct line *)NULL;
     }
#ifdef DEBUG
 printf("Returning %d: ",scanline);
 showscanline("B",b);
 printf("\n"); 
#endif
   return(b);
}
예제 #9
0
void
wb_dbs::checkObject(sOentry *oep)
{
  int nChild = 0;
  pwr_tStatus sts;
  dbs_sQlink *sib_lh;
  dbs_sQlink *sib_ll;
  sOentry *sep;
  dbs_sName n;
  sNentry *nep;    

  // Check object
  if (!oep->flags.b.exist) {
    printf("** Object does not exist!\n");
  }

  m_nTreeObjects++;

  oep->ref = dbs_dMakeRef(dbs_eSect_object, m_sect[dbs_eSect_object].size);
  m_sect[dbs_eSect_object].size += dbs_dAlign(sizeof(dbs_sObject));
  dbs_Qinit(&sts, &oep->o.sib_lh, oep->ref + offsetof(dbs_sObject, sib_lh));
  dbs_Qinit(&sts, &oep->o.sib_ll, oep->ref + offsetof(dbs_sObject, sib_ll));
  dbs_Qinit(&sts, &oep->o.o_ll, oep->ref + offsetof(dbs_sObject, o_ll));

  classInsert(oep);

  switch (oep->o.cid) {
  case pwr_eClass_ClassDef:
    // Version is dependent of attribute objects
    m_v->merep()->classVersion(&sts, cdh_ClassObjidToId(oep->o.oid), &oep->o.time);
    break;
  case pwr_eClass_LibHier:
    if ( !cdh_isClassVolumeClass( m_volume.cid))
      oep->o.flags.b.devOnly = 1;
    break;
  case pwr_eClass_Alias:
    if ( !cdh_isClassVolumeClass( m_volume.cid))
      oep->o.flags.b.isAliasClient = 1;
    break;
  case pwr_eClass_MountVolume:
  case pwr_eClass_CreateVolume:
  case pwr_eClass_MountObject:
    if (m_volume.cid == pwr_eClass_RootVolume || m_volume.cid == pwr_eClass_VolatileVolume) {
      // Root volume or cloned volume
      oep->o.flags.b.isMountClient = 1;
    }
    break;
  default:
    break;    
  }

  oep->o.flags.b.isMountClean = 1;

  // Check all children
  sib_lh = sib_ll = &oep->o.sib_lh;
  for (sep = oep->foep; sep != 0; sep = sep->aoep) {
    if (sep->poep != oep) {
      printf("** Object not linked to right parent!\n");
    }

    checkObject(sep);

    sep->o.pref = oep->ref;
    dbs_Qinsert(&sts, sib_ll, &sep->o.sib_ll, sib_lh);
    sib_ll = &sep->o.sib_ll;
    oep->o.flags.b.isMountClean |= sep->o.flags.b.isMountClean && !sep->o.flags.b.isMountClient;
    nChild++;
  }

  /* Check name table, get reference to first and last child in name order.  */
  memset(&n, 0, sizeof(n));
  n.poix = oep->o.oid.oix;
  nep = (sNentry*)tree_FindSuccessor(&sts, m_name_th, &n);
  if (nep != NULL && nep->n.poix == oep->o.oid.oix) {
    oep->o.name_bt.start = nep->ref;
  }

  n.poix += 1;
  nep = (sNentry*)tree_FindPredecessor(&sts, m_name_th, &n);
  if (nep != NULL && nep->n.poix == oep->o.oid.oix) {
    oep->o.name_bt.end = nep->ref;
  }

  oep->o.name_bt.rsize = dbs_dAlign(sizeof(dbs_sName));
}